]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ice: Introduce ice_init_mac_fltr and move ice_napi_del
authorTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 16 Apr 2019 17:34:50 +0000 (10:34 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 30 May 2019 05:51:35 +0000 (22:51 -0700)
Consolidate adding unicast and broadcast MAC filters in a single new
function ice_init_mac_fltr.

Move ice_napi_del to ice_lib.c

Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_lib.h
drivers/net/ethernet/intel/ice/ice_main.c

index 8db9427d863fe20bca8d495917e94aa4ec57d3c9..230f733817d082c9da6d28623c6164f3f90b768c 100644 (file)
@@ -2733,6 +2733,21 @@ void ice_vsi_dis_irq(struct ice_vsi *vsi)
        }
 }
 
+/**
+ * ice_napi_del - Remove NAPI handler for the VSI
+ * @vsi: VSI for which NAPI handler is to be removed
+ */
+void ice_napi_del(struct ice_vsi *vsi)
+{
+       int v_idx;
+
+       if (!vsi->netdev)
+               return;
+
+       ice_for_each_q_vector(vsi, v_idx)
+               netif_napi_del(&vsi->q_vectors[v_idx]->napi);
+}
+
 /**
  * ice_vsi_release - Delete a VSI and free its resources
  * @vsi: the VSI being removed
index 3605b7ca9120e1213e5e7e9f931b8d57f7f741b2..e223767755cbf99b220993641649e699499761d2 100644 (file)
@@ -49,6 +49,8 @@ struct ice_vsi *
 ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
              enum ice_vsi_type type, u16 vf_id);
 
+void ice_napi_del(struct ice_vsi *vsi);
+
 int ice_vsi_release(struct ice_vsi *vsi);
 
 void ice_vsi_close(struct ice_vsi *vsi);
index 0bcc8402a5eedcf047bb689703b9cd8450d246c3..da62a901b35508de173d04399f1fa2c2de6bbd71 100644 (file)
@@ -108,6 +108,67 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)
        }
 }
 
+/**
+ * ice_init_mac_fltr - Set initial MAC filters
+ * @pf: board private structure
+ *
+ * Set initial set of mac filters for PF VSI; configure filters for permanent
+ * address and broadcast address. If an error is encountered, netdevice will be
+ * unregistered.
+ */
+static int ice_init_mac_fltr(struct ice_pf *pf)
+{
+       LIST_HEAD(tmp_add_list);
+       u8 broadcast[ETH_ALEN];
+       struct ice_vsi *vsi;
+       int status;
+
+       vsi = ice_find_vsi_by_type(pf, ICE_VSI_PF);
+       if (!vsi)
+               return -EINVAL;
+
+       /* To add a MAC filter, first add the MAC to a list and then
+        * pass the list to ice_add_mac.
+        */
+
+        /* Add a unicast MAC filter so the VSI can get its packets */
+       status = ice_add_mac_to_list(vsi, &tmp_add_list,
+                                    vsi->port_info->mac.perm_addr);
+       if (status)
+               goto unregister;
+
+       /* VSI needs to receive broadcast traffic, so add the broadcast
+        * MAC address to the list as well.
+        */
+       eth_broadcast_addr(broadcast);
+       status = ice_add_mac_to_list(vsi, &tmp_add_list, broadcast);
+       if (status)
+               goto free_mac_list;
+
+       /* Program MAC filters for entries in tmp_add_list */
+       status = ice_add_mac(&pf->hw, &tmp_add_list);
+       if (status)
+               status = -ENOMEM;
+
+free_mac_list:
+       ice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);
+
+unregister:
+       /* We aren't useful with no MAC filters, so unregister if we
+        * had an error
+        */
+       if (status && vsi->netdev->reg_state == NETREG_REGISTERED) {
+               dev_err(&pf->pdev->dev,
+                       "Could not add MAC filters error %d. Unregistering device\n",
+                       status);
+               unregister_netdev(vsi->netdev);
+               free_netdev(vsi->netdev);
+               vsi->netdev = NULL;
+       }
+
+       return status;
+}
+
 /**
  * ice_add_mac_to_sync_list - creates list of MAC addresses to be synced
  * @netdev: the net device on which the sync is happening
@@ -1649,21 +1710,6 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
        return 0;
 }
 
-/**
- * ice_napi_del - Remove NAPI handler for the VSI
- * @vsi: VSI for which NAPI handler is to be removed
- */
-static void ice_napi_del(struct ice_vsi *vsi)
-{
-       int v_idx;
-
-       if (!vsi->netdev)
-               return;
-
-       ice_for_each_q_vector(vsi, v_idx)
-               netif_napi_del(&vsi->q_vectors[v_idx]->napi);
-}
-
 /**
  * ice_napi_add - register NAPI handler for the VSI
  * @vsi: VSI for which NAPI handler is to be registered
@@ -1900,8 +1946,6 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,
  */
 static int ice_setup_pf_sw(struct ice_pf *pf)
 {
-       LIST_HEAD(tmp_add_list);
-       u8 broadcast[ETH_ALEN];
        struct ice_vsi *vsi;
        int status = 0;
 
@@ -1926,38 +1970,12 @@ static int ice_setup_pf_sw(struct ice_pf *pf)
         */
        ice_napi_add(vsi);
 
-       /* To add a MAC filter, first add the MAC to a list and then
-        * pass the list to ice_add_mac.
-        */
-
-        /* Add a unicast MAC filter so the VSI can get its packets */
-       status = ice_add_mac_to_list(vsi, &tmp_add_list,
-                                    vsi->port_info->mac.perm_addr);
+       status = ice_init_mac_fltr(pf);
        if (status)
                goto unroll_napi_add;
 
-       /* VSI needs to receive broadcast traffic, so add the broadcast
-        * MAC address to the list as well.
-        */
-       eth_broadcast_addr(broadcast);
-       status = ice_add_mac_to_list(vsi, &tmp_add_list, broadcast);
-       if (status)
-               goto free_mac_list;
-
-       /* program MAC filters for entries in tmp_add_list */
-       status = ice_add_mac(&pf->hw, &tmp_add_list);
-       if (status) {
-               dev_err(&pf->pdev->dev, "Could not add MAC filters\n");
-               status = -ENOMEM;
-               goto free_mac_list;
-       }
-
-       ice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);
        return status;
 
-free_mac_list:
-       ice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);
-
 unroll_napi_add:
        if (vsi) {
                ice_napi_del(vsi);