Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net-next 0/2] ice: preventing VLAN configuration in switchdev
@ 2022-04-25  6:27 Michal Swiatkowski
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps " Michal Swiatkowski
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops Michal Swiatkowski
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Swiatkowski @ 2022-04-25  6:27 UTC (permalink / raw)
  To: intel-wired-lan

In switchdev for any VLAN configuration requested from VF PF should
answer with not supported error. Instead of adding custom ops for all
VLAN ops prevent setting VLAN VF caps.

Thanks for that ugly error from dmesg will be removed as VF should not
send VLAN configuration commands. If it sends any PF driver will
return not supported error because all VLAN opcodes are remove from
allowlist (only in switchdev mode).

Michal Swiatkowski (2):
  ice: don't set VF VLAN caps in switchdev
  ice: remove VLAN representor specific ops

 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 121 ++++++++----------
 1 file changed, 54 insertions(+), 67 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps in switchdev
  2022-04-25  6:27 [Intel-wired-lan] [PATCH net-next 0/2] ice: preventing VLAN configuration in switchdev Michal Swiatkowski
@ 2022-04-25  6:27 ` Michal Swiatkowski
  2022-06-01  6:36   ` Penigalapati, Sandeep
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops Michal Swiatkowski
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Swiatkowski @ 2022-04-25  6:27 UTC (permalink / raw)
  To: intel-wired-lan

In switchdev mode any VLAN manipulation from VF side isn't allowed.
In order to prevent parsing VLAN commands don't set VF VLAN caps.
This will result in removing VLAN specific opcodes from allowlist.
If VF send any VLAN specific opcode PF driver will answer with not
supported error.

With this approach VF driver know that VLAN caps aren't supported so it
shouldn't send VLAN specific opcodes. Thanks to that, some ugly errors
will not show up in dmesg (ex. on creating VFs in switchdev mode
there are errors about not supported VLAN insertion and stripping)

Move setting VLAN caps to separate function, including
switchdev mode specific code.

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 77 ++++++++++++-------
 1 file changed, 50 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
index b47577a2841a..5d07e009bc84 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
@@ -359,6 +359,54 @@ static u16 ice_vc_get_max_frame_size(struct ice_vf *vf)
 	return max_frame_size;
 }
 
+/**
+ * ice_vc_get_vlan_caps
+ * @hw: pointer to the hw
+ * @vf: pointer to the VF info
+ * @vsi: pointer to the VSI
+ * @driver_caps: current driver caps
+ *
+ * Return 0 if there is no VLAN caps supported, or VLAN caps value
+ */
+static u32
+ice_vc_get_vlan_caps(struct ice_hw *hw, struct ice_vf *vf, struct ice_vsi *vsi,
+		     u32 driver_caps)
+{
+	if (ice_is_eswitch_mode_switchdev(vf->pf))
+		/* In switchdev setting VLAN from VF isn't supported */
+		return 0;
+
+	if (driver_caps & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
+		/* VLAN offloads based on current device configuration */
+		return VIRTCHNL_VF_OFFLOAD_VLAN_V2;
+	} else if (driver_caps & VIRTCHNL_VF_OFFLOAD_VLAN) {
+		/* allow VF to negotiate VIRTCHNL_VF_OFFLOAD explicitly for
+		 * these two conditions, which amounts to guest VLAN filtering
+		 * and offloads being based on the inner VLAN or the
+		 * inner/single VLAN respectively and don't allow VF to
+		 * negotiate VIRTCHNL_VF_OFFLOAD in any other cases
+		 */
+		if (ice_is_dvm_ena(hw) && ice_vf_is_port_vlan_ena(vf)) {
+			return VIRTCHNL_VF_OFFLOAD_VLAN;
+		} else if (!ice_is_dvm_ena(hw) &&
+			   !ice_vf_is_port_vlan_ena(vf)) {
+			/* configure backward compatible support for VFs that
+			 * only support VIRTCHNL_VF_OFFLOAD_VLAN, the PF is
+			 * configured in SVM, and no port VLAN is configured
+			 */
+			ice_vf_vsi_cfg_svm_legacy_vlan_mode(vsi);
+			return VIRTCHNL_VF_OFFLOAD_VLAN;
+		} else if (ice_is_dvm_ena(hw)) {
+			/* configure software offloaded VLAN support when DVM
+			 * is enabled, but no port VLAN is enabled
+			 */
+			ice_vf_vsi_cfg_dvm_legacy_vlan_mode(vsi);
+		}
+	}
+
+	return 0;
+}
+
 /**
  * ice_vc_get_vf_res_msg
  * @vf: pointer to the VF info
@@ -402,33 +450,8 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
 		goto err;
 	}
 
-	if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
-		/* VLAN offloads based on current device configuration */
-		vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN_V2;
-	} else if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_VLAN) {
-		/* allow VF to negotiate VIRTCHNL_VF_OFFLOAD explicitly for
-		 * these two conditions, which amounts to guest VLAN filtering
-		 * and offloads being based on the inner VLAN or the
-		 * inner/single VLAN respectively and don't allow VF to
-		 * negotiate VIRTCHNL_VF_OFFLOAD in any other cases
-		 */
-		if (ice_is_dvm_ena(hw) && ice_vf_is_port_vlan_ena(vf)) {
-			vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN;
-		} else if (!ice_is_dvm_ena(hw) &&
-			   !ice_vf_is_port_vlan_ena(vf)) {
-			vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN;
-			/* configure backward compatible support for VFs that
-			 * only support VIRTCHNL_VF_OFFLOAD_VLAN, the PF is
-			 * configured in SVM, and no port VLAN is configured
-			 */
-			ice_vf_vsi_cfg_svm_legacy_vlan_mode(vsi);
-		} else if (ice_is_dvm_ena(hw)) {
-			/* configure software offloaded VLAN support when DVM
-			 * is enabled, but no port VLAN is enabled
-			 */
-			ice_vf_vsi_cfg_dvm_legacy_vlan_mode(vsi);
-		}
-	}
+	vfres->vf_cap_flags |= ice_vc_get_vlan_caps(hw, vf, vsi,
+						    vf->driver_caps);
 
 	if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
 		vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_RSS_PF;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops
  2022-04-25  6:27 [Intel-wired-lan] [PATCH net-next 0/2] ice: preventing VLAN configuration in switchdev Michal Swiatkowski
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps " Michal Swiatkowski
@ 2022-04-25  6:27 ` Michal Swiatkowski
  2022-06-01  6:36   ` Penigalapati, Sandeep
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Swiatkowski @ 2022-04-25  6:27 UTC (permalink / raw)
  To: intel-wired-lan

As in switchdev mode VF VLAN caps will not be set there is no need
to have specific VLAN ops for representor that only returns not
supported error.

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 44 ++-----------------
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
index 5d07e009bc84..ba38b76fd305 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
@@ -3520,42 +3520,6 @@ ice_vc_repr_del_mac(struct ice_vf __always_unused *vf, u8 __always_unused *msg)
 				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
 }
 
-static int ice_vc_repr_add_vlan(struct ice_vf *vf, u8 __always_unused *msg)
-{
-	dev_dbg(ice_pf_to_dev(vf->pf),
-		"Can't add VLAN in switchdev mode for VF %d\n", vf->vf_id);
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ADD_VLAN,
-				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
-}
-
-static int ice_vc_repr_del_vlan(struct ice_vf *vf, u8 __always_unused *msg)
-{
-	dev_dbg(ice_pf_to_dev(vf->pf),
-		"Can't delete VLAN in switchdev mode for VF %d\n", vf->vf_id);
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DEL_VLAN,
-				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
-}
-
-static int ice_vc_repr_ena_vlan_stripping(struct ice_vf *vf)
-{
-	dev_dbg(ice_pf_to_dev(vf->pf),
-		"Can't enable VLAN stripping in switchdev mode for VF %d\n",
-		vf->vf_id);
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
-				     VIRTCHNL_STATUS_ERR_NOT_SUPPORTED,
-				     NULL, 0);
-}
-
-static int ice_vc_repr_dis_vlan_stripping(struct ice_vf *vf)
-{
-	dev_dbg(ice_pf_to_dev(vf->pf),
-		"Can't disable VLAN stripping in switchdev mode for VF %d\n",
-		vf->vf_id);
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
-				     VIRTCHNL_STATUS_ERR_NOT_SUPPORTED,
-				     NULL, 0);
-}
-
 static int
 ice_vc_repr_cfg_promiscuous_mode(struct ice_vf *vf, u8 __always_unused *msg)
 {
@@ -3582,10 +3546,10 @@ static const struct ice_virtchnl_ops ice_virtchnl_repr_ops = {
 	.config_rss_lut = ice_vc_config_rss_lut,
 	.get_stats_msg = ice_vc_get_stats_msg,
 	.cfg_promiscuous_mode_msg = ice_vc_repr_cfg_promiscuous_mode,
-	.add_vlan_msg = ice_vc_repr_add_vlan,
-	.remove_vlan_msg = ice_vc_repr_del_vlan,
-	.ena_vlan_stripping = ice_vc_repr_ena_vlan_stripping,
-	.dis_vlan_stripping = ice_vc_repr_dis_vlan_stripping,
+	.add_vlan_msg = ice_vc_add_vlan_msg,
+	.remove_vlan_msg = ice_vc_remove_vlan_msg,
+	.ena_vlan_stripping = ice_vc_ena_vlan_stripping,
+	.dis_vlan_stripping = ice_vc_dis_vlan_stripping,
 	.handle_rss_cfg_msg = ice_vc_handle_rss_cfg,
 	.add_fdir_fltr_msg = ice_vc_add_fdir_fltr,
 	.del_fdir_fltr_msg = ice_vc_del_fdir_fltr,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops Michal Swiatkowski
@ 2022-06-01  6:36   ` Penigalapati, Sandeep
  0 siblings, 0 replies; 5+ messages in thread
From: Penigalapati, Sandeep @ 2022-06-01  6:36 UTC (permalink / raw)
  To: intel-wired-lan

>-----Original Message-----
>From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
>Michal Swiatkowski
>Sent: Monday, April 25, 2022 11:58 AM
To: intel-wired-lan@lists.osuosl.org
>Cc: Wilczynski, Michal <michal.wilczynski@intel.com>
>Subject: [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor
>specific ops
>
>As in switchdev mode VF VLAN caps will not be set there is no need to have
>specific VLAN ops for representor that only returns not supported error.
>
>Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>---
> drivers/net/ethernet/intel/ice/ice_virtchnl.c | 44 ++-----------------
> 1 file changed, 4 insertions(+), 40 deletions(-)
>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps in switchdev
  2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps " Michal Swiatkowski
@ 2022-06-01  6:36   ` Penigalapati, Sandeep
  0 siblings, 0 replies; 5+ messages in thread
From: Penigalapati, Sandeep @ 2022-06-01  6:36 UTC (permalink / raw)
  To: intel-wired-lan

>-----Original Message-----
>From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
>Michal Swiatkowski
>Sent: Monday, April 25, 2022 11:58 AM
To: intel-wired-lan@lists.osuosl.org
>Cc: Wilczynski, Michal <michal.wilczynski@intel.com>
>Subject: [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps in
>switchdev
>
>In switchdev mode any VLAN manipulation from VF side isn't allowed.
>In order to prevent parsing VLAN commands don't set VF VLAN caps.
>This will result in removing VLAN specific opcodes from allowlist.
>If VF send any VLAN specific opcode PF driver will answer with not supported
>error.
>
>With this approach VF driver know that VLAN caps aren't supported so it
>shouldn't send VLAN specific opcodes. Thanks to that, some ugly errors will
>not show up in dmesg (ex. on creating VFs in switchdev mode there are errors
>about not supported VLAN insertion and stripping)
>
>Move setting VLAN caps to separate function, including switchdev mode
>specific code.
>
>Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>---
> drivers/net/ethernet/intel/ice/ice_virtchnl.c | 77 ++++++++++++-------
> 1 file changed, 50 insertions(+), 27 deletions(-)
>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-01  6:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-25  6:27 [Intel-wired-lan] [PATCH net-next 0/2] ice: preventing VLAN configuration in switchdev Michal Swiatkowski
2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps " Michal Swiatkowski
2022-06-01  6:36   ` Penigalapati, Sandeep
2022-04-25  6:27 ` [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops Michal Swiatkowski
2022-06-01  6:36   ` Penigalapati, Sandeep

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox