All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 07/15] ice: Add functions to rebuild host VLAN/MAC config for a VF
Date: Fri, 15 May 2020 17:51:13 -0700	[thread overview]
Message-ID: <20200516005121.4963-7-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20200516005121.4963-1-anthony.l.nguyen@intel.com>

From: Brett Creeley <brett.creeley@intel.com>

When resetting a VF the VLAN and MAC filter configurations need to be
replayed. Add helper functions for this purpose.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 .../net/ethernet/intel/ice/ice_virtchnl_pf.c  | 121 +++++++++++++-----
 1 file changed, 89 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 1599d89216a5..1212bf42c135 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -540,6 +540,82 @@ static int ice_calc_vf_first_vector_idx(struct ice_pf *pf, struct ice_vf *vf)
 	return pf->sriov_base_vector + vf->vf_id * pf->num_msix_per_vf;
 }
 
+/**
+ * ice_vf_rebuild_host_vlan_cfg - add VLAN 0 filter or rebuild the Port VLAN
+ * @vf: VF to add MAC filters for
+ *
+ * Called after a VF VSI has been re-added/rebuilt during reset. The PF driver
+ * always re-adds either a VLAN 0 or port VLAN based filter after reset.
+ */
+static int ice_vf_rebuild_host_vlan_cfg(struct ice_vf *vf)
+{
+	struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
+	struct device *dev = ice_pf_to_dev(vf->pf);
+	u16 vlan_id = 0;
+	int err;
+
+	if (vf->port_vlan_info) {
+		err = ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true);
+		if (err) {
+			dev_err(dev, "failed to configure port VLAN via VSI parameters for VF %u, error %d\n",
+				vf->vf_id, err);
+			return err;
+		}
+
+		vlan_id = vf->port_vlan_info & VLAN_VID_MASK;
+	}
+
+	/* vlan_id will either be 0 or the port VLAN number */
+	err = ice_vsi_add_vlan(vsi, vlan_id, ICE_FWD_TO_VSI);
+	if (err) {
+		dev_err(dev, "failed to add %s VLAN %u filter for VF %u, error %d\n",
+			vf->port_vlan_info ? "port" : "", vlan_id, vf->vf_id,
+			err);
+		return err;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_vf_rebuild_host_mac_cfg - add broadcast and the VF's perm_addr/LAA
+ * @vf: VF to add MAC filters for
+ *
+ * Called after a VF VSI has been re-added/rebuilt during reset. The PF driver
+ * always re-adds a broadcast filter and the VF's perm_addr/LAA after reset.
+ */
+static int ice_vf_rebuild_host_mac_cfg(struct ice_vf *vf)
+{
+	struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
+	struct device *dev = ice_pf_to_dev(vf->pf);
+	enum ice_status status;
+	u8 broadcast[ETH_ALEN];
+
+	eth_broadcast_addr(broadcast);
+	status = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
+	if (status) {
+		dev_err(dev, "failed to add broadcast MAC filter for VF %u, error %s\n",
+			vf->vf_id, ice_stat_str(status));
+		return ice_status_to_errno(status);
+	}
+
+	vf->num_mac++;
+
+	if (is_valid_ether_addr(vf->dflt_lan_addr.addr)) {
+		status = ice_fltr_add_mac(vsi, vf->dflt_lan_addr.addr,
+					  ICE_FWD_TO_VSI);
+		if (status) {
+			dev_err(dev, "failed to add default unicast MAC filter %pM for VF %u, error %s\n",
+				&vf->dflt_lan_addr.addr[0], vf->vf_id,
+				ice_stat_str(status));
+			return ice_status_to_errno(status);
+		}
+		vf->num_mac++;
+	}
+
+	return 0;
+}
+
 /**
  * ice_alloc_vsi_res - Setup VF VSI and its resources
  * @vf: pointer to the VF structure
@@ -549,10 +625,9 @@ static int ice_calc_vf_first_vector_idx(struct ice_pf *pf, struct ice_vf *vf)
 static int ice_alloc_vsi_res(struct ice_vf *vf)
 {
 	struct ice_pf *pf = vf->pf;
-	u8 broadcast[ETH_ALEN];
 	struct ice_vsi *vsi;
 	struct device *dev;
-	int status = 0;
+	int ret;
 
 	dev = ice_pf_to_dev(pf);
 	/* first vector index is the VFs OICR index */
@@ -567,38 +642,20 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)
 	vf->lan_vsi_idx = vsi->idx;
 	vf->lan_vsi_num = vsi->vsi_num;
 
-	/* Check if port VLAN exist before, and restore it accordingly */
-	if (vf->port_vlan_info) {
-		ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true);
-		if (ice_vsi_add_vlan(vsi, vf->port_vlan_info & VLAN_VID_MASK,
-				     ICE_FWD_TO_VSI))
-			dev_warn(ice_pf_to_dev(pf), "Failed to add Port VLAN %d filter for VF %d\n",
-				 vf->port_vlan_info & VLAN_VID_MASK, vf->vf_id);
-	} else {
-		/* set VLAN 0 filter by default when no port VLAN is
-		 * enabled. If a port VLAN is enabled we don't want
-		 * untagged broadcast/multicast traffic seen on the VF
-		 * interface.
-		 */
-		if (ice_vsi_add_vlan(vsi, 0, ICE_FWD_TO_VSI))
-			dev_warn(ice_pf_to_dev(pf), "Failed to add VLAN 0 filter for VF %d, MDD events will trigger. Reset the VF, disable spoofchk, or enable 8021q module on the guest\n",
-				 vf->vf_id);
+	ret = ice_vf_rebuild_host_vlan_cfg(vf);
+	if (ret) {
+		dev_err(dev, "failed to rebuild default MAC configuration for VF %d, error %d\n",
+			vf->vf_id, ret);
+		goto ice_alloc_vsi_res_exit;
 	}
 
-	if (is_valid_ether_addr(vf->dflt_lan_addr.addr)) {
-		status = ice_fltr_add_mac(vsi, vf->dflt_lan_addr.addr,
-					  ICE_FWD_TO_VSI);
-		if (status)
-			goto ice_alloc_vsi_res_exit;
-	}
 
-	eth_broadcast_addr(broadcast);
-	status = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
-	if (status)
-		dev_err(dev, "could not add mac filters error %d\n",
-			status);
-	else
-		vf->num_mac = 1;
+	ret = ice_vf_rebuild_host_mac_cfg(vf);
+	if (ret) {
+		dev_err(dev, "failed to rebuild default MAC configuration for VF %d, error %d\n",
+			vf->vf_id, ret);
+		goto ice_alloc_vsi_res_exit;
+	}
 
 	/* Clear this bit after VF initialization since we shouldn't reclaim
 	 * and reassign interrupts for synchronous or asynchronous VFR events.
@@ -607,7 +664,7 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)
 	 * more vectors.
 	 */
 ice_alloc_vsi_res_exit:
-	return status;
+	return ret;
 }
 
 /**
-- 
2.20.1


  parent reply	other threads:[~2020-05-16  0:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  0:51 [Intel-wired-lan] [PATCH S45 01/15] ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings Tony Nguyen
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 02/15] ice: Simplify ice_sriov_configure Tony Nguyen
2020-05-28 21:39   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 03/15] ice: Add helper function for clearing VPGEN_VFRTRIG Tony Nguyen
2020-05-28 21:39   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 04/15] ice: Separate VF VSI initialization/creation from reset flow Tony Nguyen
2020-05-28 21:40   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 05/15] ice: Renaming and simplification in VF init path Tony Nguyen
2020-05-28 21:40   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 06/15] ice: Add function to set trust mode bit on reset Tony Nguyen
2020-05-28 21:41   ` Bowers, AndrewX
2020-05-16  0:51 ` Tony Nguyen [this message]
2020-05-28 21:41   ` [Intel-wired-lan] [PATCH S45 07/15] ice: Add functions to rebuild host VLAN/MAC config for a VF Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 08/15] ice: remove VM/VF disable command on CORER/GLOBR reset Tony Nguyen
2020-05-28 21:41   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 09/15] ice: Refactor VF reset Tony Nguyen
2020-05-28 21:42   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 10/15] ice: Refactor VF VSI release and setup functions Tony Nguyen
2020-05-28 21:42   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 11/15] ice: allow host to clear administratively set VF MAC Tony Nguyen
2020-05-28 21:43   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 12/15] ice: support adding 16 unicast/multicast filter on untrusted VF Tony Nguyen
2020-05-28 21:43   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 13/15] ice: Fix transmit for all software offloaded VLANs Tony Nguyen
2020-05-28 21:44   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 14/15] ice: Increase timeout after PFR Tony Nguyen
2020-05-28 21:44   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 15/15] ice: Update ICE_PHY_TYPE_HIGH_MAX_INDEX value Tony Nguyen
2020-05-28 21:44   ` Bowers, AndrewX
2020-05-28 21:38 ` [Intel-wired-lan] [PATCH S45 01/15] ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings Bowers, AndrewX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200516005121.4963-7-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.