bnxt_en: set mac address and uc_list bug fixes.
v2 cover bnxt_en: set mac address and uc_list bug fixes.
Fix ndo_set_mac_address() for PF and VF.
Re-apply uc_list after chip reset.
v2: Fix compile error if CONFIG_BNXT_SRIOV is not set.
Michael Chan (3):
bnxt_en: Fixed incorrect implementation of ndo_set_mac_address
bnxt_en: enforce proper storing of MAC address
bnxt_en: Setup uc_list mac filters after resetting the chip.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-- 2 files changed, 34 insertions(+), 17 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/3 bnxt_en: Fixed incorrect implementation of ndo_set_mac_address
From: Jeffrey Huang <[email protected]>
The existing ndo_set_mac_address only copies the new MAC addr and didn't set the new MAC addr to the HW. The correct way is to delete the existing default MAC filter from HW and add the new one. Because of RFS filters are also dependent on the default mac filter l2 context, the driver must go thru close_nic() to delete the default MAC and RFS filters, then open_nic() to set the default MAC address to HW.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +10 -1
@@ -5212,13 +5212,22 @@ init_err:static int bnxt_change_mac_addr (struct net_device *dev,void *p) {struct sockaddr *addr = p; +struct bnxt *bp =netdev_priv (dev); +int rc =0 ;if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; +if (ether_addr_equal (addr->sa_data, dev->dev_addr)) +return 0 ; +memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); +if (netif_running (dev)) { +bnxt_close_nic (bp, false, false); + rc =bnxt_open_nic (bp, false, false); + } -return 0 ; +return rc; }/* rtnl_lock held */
Signature · 1 line
1.8.3.1
PATCH v2 2/3 bnxt_en: enforce proper storing of MAC address
In reply to Michael ChanFrom: Jeffrey Huang <[email protected]>
For PF, the bp->pf.mac_addr always holds the permanent MAC addr assigned by the HW. For VF, the bp->vf.mac_addr always holds the administrator assigned VF MAC addr. The random generated VF MAC addr should never get stored to bp->vf.mac_addr. This way, when the VF wants to change the MAC address, we can tell if the adminstrator has already set it and disallow the VF from changing it.
v2: Fix compile error if CONFIG_BNXT_SRIOV is not set.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 +++---- 2 files changed, 16 insertions(+), 11 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +13 -7
@@ -3625,6 +3625,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp) pf->fw_fid =le16_to_cpu (resp->fid); pf->port_id =le16_to_cpu (resp->port_id);memcpy (pf->mac_addr, resp->perm_mac_address,ETH_ALEN ); +memcpy (bp->dev->dev_addr, pf->mac_addr,ETH_ALEN ); pf->max_rsscos_ctxs =le16_to_cpu (resp->max_rsscos_ctx); pf->max_cp_rings =le16_to_cpu (resp->max_cmpl_rings); pf->max_tx_rings =le16_to_cpu (resp->max_tx_rings);
@@ -3648,8 +3649,11 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp) vf->fw_fid =le16_to_cpu (resp->fid);memcpy (vf->mac_addr, resp->perm_mac_address,ETH_ALEN ); -if (!is_valid_ether_addr (vf->mac_addr)) -random_ether_addr (vf->mac_addr); +if (is_valid_ether_addr (vf->mac_addr)) +/* overwrite netdev dev_adr with admin VF MAC */ +memcpy (bp->dev->dev_addr, vf->mac_addr,ETH_ALEN ); +else +random_ether_addr (bp->dev->dev_addr); vf->max_rsscos_ctxs =le16_to_cpu (resp->max_rsscos_ctx); vf->max_cp_rings =le16_to_cpu (resp->max_cmpl_rings);
@@ -5218,6 +5222,11 @@ static int bnxt_change_mac_addr(struct net_device *dev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; +#ifdef CONFIG_BNXT_SRIOV +if (BNXT_VF (bp) &&is_valid_ether_addr (bp->vf.mac_addr)) +return -EADDRNOTAVAIL ; +#endif +if (ether_addr_equal (addr->sa_data, dev->dev_addr))return 0 ;
@@ -5695,15 +5704,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp); dflt_rings =netif_get_num_default_rss_queues (); -if (BNXT_PF (bp)) { -memcpy (dev->dev_addr, bp->pf.mac_addr,ETH_ALEN ); +if (BNXT_PF (bp)) bp->pf.max_irqs = max_irqs; - }else {#if defined(CONFIG_BNXT_SRIOV ) -memcpy (dev->dev_addr, bp->vf.mac_addr,ETH_ALEN ); + else bp->vf.max_irqs = max_irqs;#endif - }bnxt_get_max_rings (bp, &max_rx_rings, &max_tx_rings); bp->rx_nr_rings =min_t (int, dflt_rings, max_rx_rings); bp->tx_nr_rings_per_tc =min_t (int, dflt_rings, max_tx_rings);
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +3 -4
@@ -804,10 +804,9 @@ void bnxt_update_vf_mac(struct bnxt *bp)if (!is_valid_ether_addr (resp->perm_mac_address)) goto update_vf_mac_exit; -if (ether_addr_equal (resp->perm_mac_address, bp->vf.mac_addr)) - goto update_vf_mac_exit; - -memcpy (bp->vf.mac_addr, resp->perm_mac_address,ETH_ALEN ); +if (!ether_addr_equal (resp->perm_mac_address, bp->vf.mac_addr)) +memcpy (bp->vf.mac_addr, resp->perm_mac_address,ETH_ALEN ); +/* overwrite netdev dev_adr with admin VF MAC */ memcpy (bp->dev->dev_addr, bp->vf.mac_addr,ETH_ALEN ); update_vf_mac_exit:mutex_unlock (&bp->hwrm_cmd_lock);
Signature · 1 line
1.8.3.1
PATCH v2 3/3 bnxt_en: Setup uc_list mac filters after resetting the chip.
In reply to Michael ChanCall bnxt_cfg_rx_mode() in bnxt_init_chip() to setup uc_list and mc_list mac address filters. Before the patch, uc_list is not setup again after chip reset (such as ethtool ring size change) and macvlans don't work any more after that.
Modify bnxt_cfg_rx_mode() to return error codes appropriately so that the init chip sequence can detect any failures.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -5
@@ -3884,6 +3884,8 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp)#endif } +static int bnxt_cfg_rx_mode (struct bnxt *); +static int bnxt_init_chip (struct bnxt *bp,bool irq_re_init) {int rc =0 ;
@@ -3950,11 +3952,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) bp->vnic_info[0 ].rx_mask |=CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS ; - rc =bnxt_hwrm_cfa_l2_set_rx_mask (bp,0 ); -if (rc) { -netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %x\n" , rc); + rc =bnxt_cfg_rx_mode (bp); +if (rc) goto err_out; - } rc =bnxt_hwrm_set_coal (bp);if (rc)
@@ -4869,7 +4869,7 @@ static void bnxt_set_rx_mode(struct net_device *dev) } } -static void bnxt_cfg_rx_mode (struct bnxt *bp) +static int bnxt_cfg_rx_mode (struct bnxt *bp) {struct net_device *dev = bp->dev;struct bnxt_vnic_info *vnic = &bp->vnic_info[0 ];
@@ -4918,6 +4918,7 @@ static void bnxt_cfg_rx_mode(struct bnxt *bp)netdev_err (bp->dev,"HWRM vnic filter failure rc: %x\n" , rc); vnic->uc_filter_count = i; +return rc; } }
@@ -4926,6 +4927,8 @@ skip_uc:if (rc)netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %x\n" , rc); + +return rc; } static netdev_features_t bnxt_fix_features(struct net_device *dev,
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Wed, 2 Dec 2015 01:54:05 -0500
Quoted 4 lines
Fix
ndo_set_mac_address()for PF and VF.
Re-applyuc_listafter chip reset.v2: Fix compile error if
CONFIG_BNXT_SRIOVis not set.
Series applied, thanks Michael.