ice: introduce ice_vf_init_host_cfg function
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 19 Jan 2023 01:16:49 +0000 (17:16 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 6 Feb 2023 17:41:56 +0000 (09:41 -0800)
Introduce a new generic helper ice_vf_init_host_cfg which performs common
host configuration initialization tasks that will need to be done for both
Single Root IOV and the new Scalable IOV implementation.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Marek Szlosek <marek.szlosek@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_sriov.c
drivers/net/ethernet/intel/ice/ice_vf_lib.c
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h

index 6c07f66..5450fa1 100644 (file)
@@ -573,51 +573,19 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
  */
 static int ice_init_vf_vsi_res(struct ice_vf *vf)
 {
-       struct ice_vsi_vlan_ops *vlan_ops;
        struct ice_pf *pf = vf->pf;
-       u8 broadcast[ETH_ALEN];
        struct ice_vsi *vsi;
-       struct device *dev;
        int err;
 
        vf->first_vector_idx = ice_calc_vf_first_vector_idx(pf, vf);
 
-       dev = ice_pf_to_dev(pf);
        vsi = ice_vf_vsi_setup(vf);
        if (!vsi)
                return -ENOMEM;
 
-       err = ice_vsi_add_vlan_zero(vsi);
-       if (err) {
-               dev_warn(dev, "Failed to add VLAN 0 filter for VF %d\n",
-                        vf->vf_id);
-               goto release_vsi;
-       }
-
-       vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
-       err = vlan_ops->ena_rx_filtering(vsi);
-       if (err) {
-               dev_warn(dev, "Failed to enable Rx VLAN filtering for VF %d\n",
-                        vf->vf_id);
-               goto release_vsi;
-       }
-
-       eth_broadcast_addr(broadcast);
-       err = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
-       if (err) {
-               dev_err(dev, "Failed to add broadcast MAC filter for VF %d, error %d\n",
-                       vf->vf_id, err);
-               goto release_vsi;
-       }
-
-       err = ice_vsi_apply_spoofchk(vsi, vf->spoofchk);
-       if (err) {
-               dev_warn(dev, "Failed to initialize spoofchk setting for VF %d\n",
-                        vf->vf_id);
+       err = ice_vf_init_host_cfg(vf, vsi);
+       if (err)
                goto release_vsi;
-       }
-
-       vf->num_mac = 1;
 
        return 0;
 
index b6fd1e8..c93d24f 100644 (file)
@@ -1175,6 +1175,60 @@ struct ice_vsi *ice_vf_ctrl_vsi_setup(struct ice_vf *vf)
 }
 
 /**
+ * ice_vf_init_host_cfg - Initialize host admin configuration
+ * @vf: VF to initialize
+ * @vsi: the VSI created at initialization
+ *
+ * Initialize the VF host configuration. Called during VF creation to setup
+ * VLAN 0, add the VF VSI broadcast filter, and setup spoof checking. It
+ * should only be called during VF creation.
+ */
+int ice_vf_init_host_cfg(struct ice_vf *vf, struct ice_vsi *vsi)
+{
+       struct ice_vsi_vlan_ops *vlan_ops;
+       struct ice_pf *pf = vf->pf;
+       u8 broadcast[ETH_ALEN];
+       struct device *dev;
+       int err;
+
+       dev = ice_pf_to_dev(pf);
+
+       err = ice_vsi_add_vlan_zero(vsi);
+       if (err) {
+               dev_warn(dev, "Failed to add VLAN 0 filter for VF %d\n",
+                        vf->vf_id);
+               return err;
+       }
+
+       vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
+       err = vlan_ops->ena_rx_filtering(vsi);
+       if (err) {
+               dev_warn(dev, "Failed to enable Rx VLAN filtering for VF %d\n",
+                        vf->vf_id);
+               return err;
+       }
+
+       eth_broadcast_addr(broadcast);
+       err = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
+       if (err) {
+               dev_err(dev, "Failed to add broadcast MAC filter for VF %d, status %d\n",
+                       vf->vf_id, err);
+               return err;
+       }
+
+       vf->num_mac = 1;
+
+       err = ice_vsi_apply_spoofchk(vsi, vf->spoofchk);
+       if (err) {
+               dev_warn(dev, "Failed to initialize spoofchk setting for VF %d\n",
+                        vf->vf_id);
+               return err;
+       }
+
+       return 0;
+}
+
+/**
  * ice_vf_invalidate_vsi - invalidate vsi_idx/vsi_num to remove VSI access
  * @vf: VF to remove access to VSI for
  */
index 552d1d0..6f3293b 100644 (file)
@@ -36,6 +36,7 @@ void ice_vf_rebuild_host_cfg(struct ice_vf *vf);
 void ice_vf_ctrl_invalidate_vsi(struct ice_vf *vf);
 void ice_vf_ctrl_vsi_release(struct ice_vf *vf);
 struct ice_vsi *ice_vf_ctrl_vsi_setup(struct ice_vf *vf);
+int ice_vf_init_host_cfg(struct ice_vf *vf, struct ice_vsi *vsi);
 void ice_vf_invalidate_vsi(struct ice_vf *vf);
 void ice_vf_vsi_release(struct ice_vf *vf);
 void ice_vf_set_initialized(struct ice_vf *vf);