Skip to content

Commit 2cd8696

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: Retain user settings on a VF after RESET_NOTIFY event.
Retain the VF MAC address, default VLAN, TX rate control, trust settings of VFs after firmware reset. Signed-off-by: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 657a33c commit 2cd8696

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9211,7 +9211,7 @@ static int bnxt_open(struct net_device *dev)
92119211
int n = pf->active_vfs;
92129212

92139213
if (n)
9214-
bnxt_cfg_hw_sriov(bp, &n);
9214+
bnxt_cfg_hw_sriov(bp, &n, true);
92159215
}
92169216
bnxt_hwmon_open(bp);
92179217
}

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,43 @@ static int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp)
470470
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
471471
}
472472

473+
/* Caller holds bp->hwrm_cmd_lock mutex lock */
474+
static void __bnxt_set_vf_params(struct bnxt *bp, int vf_id)
475+
{
476+
struct hwrm_func_cfg_input req = {0};
477+
struct bnxt_vf_info *vf;
478+
479+
vf = &bp->pf.vf[vf_id];
480+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
481+
req.fid = cpu_to_le16(vf->fw_fid);
482+
req.flags = cpu_to_le32(vf->func_flags);
483+
484+
if (is_valid_ether_addr(vf->mac_addr)) {
485+
req.enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_DFLT_MAC_ADDR);
486+
memcpy(req.dflt_mac_addr, vf->mac_addr, ETH_ALEN);
487+
}
488+
if (vf->vlan) {
489+
req.enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_DFLT_VLAN);
490+
req.dflt_vlan = cpu_to_le16(vf->vlan);
491+
}
492+
if (vf->max_tx_rate) {
493+
req.enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_MAX_BW);
494+
req.max_bw = cpu_to_le32(vf->max_tx_rate);
495+
#ifdef HAVE_IFLA_TX_RATE
496+
req.enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_MIN_BW);
497+
req.min_bw = cpu_to_le32(vf->min_tx_rate);
498+
#endif
499+
}
500+
if (vf->flags & BNXT_VF_TRUST)
501+
req.flags |= cpu_to_le32(FUNC_CFG_REQ_FLAGS_TRUSTED_VF_ENABLE);
502+
503+
_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
504+
}
505+
473506
/* Only called by PF to reserve resources for VFs, returns actual number of
474507
* VFs configured, or < 0 on error.
475508
*/
476-
static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
509+
static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs, bool reset)
477510
{
478511
struct hwrm_func_vf_resource_cfg_input req = {0};
479512
struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
@@ -545,6 +578,9 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
545578

546579
mutex_lock(&bp->hwrm_cmd_lock);
547580
for (i = 0; i < num_vfs; i++) {
581+
if (reset)
582+
__bnxt_set_vf_params(bp, i);
583+
548584
req.vf_id = cpu_to_le16(pf->first_vf_id + i);
549585
rc = _hwrm_send_message(bp, &req, sizeof(req),
550586
HWRM_CMD_TIMEOUT);
@@ -659,15 +695,15 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
659695
return rc;
660696
}
661697

662-
static int bnxt_func_cfg(struct bnxt *bp, int num_vfs)
698+
static int bnxt_func_cfg(struct bnxt *bp, int num_vfs, bool reset)
663699
{
664700
if (BNXT_NEW_RM(bp))
665-
return bnxt_hwrm_func_vf_resc_cfg(bp, num_vfs);
701+
return bnxt_hwrm_func_vf_resc_cfg(bp, num_vfs, reset);
666702
else
667703
return bnxt_hwrm_func_cfg(bp, num_vfs);
668704
}
669705

670-
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs)
706+
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
671707
{
672708
int rc;
673709

@@ -677,7 +713,7 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs)
677713
return rc;
678714

679715
/* Reserve resources for VFs */
680-
rc = bnxt_func_cfg(bp, *num_vfs);
716+
rc = bnxt_func_cfg(bp, *num_vfs, reset);
681717
if (rc != *num_vfs) {
682718
if (rc <= 0) {
683719
netdev_warn(bp->dev, "Unable to reserve resources for SRIOV.\n");
@@ -758,7 +794,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
758794
if (rc)
759795
goto err_out1;
760796

761-
rc = bnxt_cfg_hw_sriov(bp, num_vfs);
797+
rc = bnxt_cfg_hw_sriov(bp, num_vfs, false);
762798
if (rc)
763799
goto err_out2;
764800

@@ -1144,7 +1180,7 @@ int bnxt_approve_mac(struct bnxt *bp, u8 *mac, bool strict)
11441180
}
11451181
#else
11461182

1147-
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs)
1183+
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
11481184
{
11491185
if (*num_vfs)
11501186
return -EOPNOTSUPP;

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int bnxt_set_vf_link_state(struct net_device *, int, int);
3636
int bnxt_set_vf_spoofchk(struct net_device *, int, bool);
3737
int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trust);
3838
int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs);
39-
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs);
39+
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset);
4040
void bnxt_sriov_disable(struct bnxt *);
4141
void bnxt_hwrm_exec_fwd_req(struct bnxt *);
4242
void bnxt_update_vf_mac(struct bnxt *);

0 commit comments

Comments
 (0)