Skip to contentSkip to conversation

iavf: Fix handling of vlan strip virtual channel messages

PATCH New Michal Maloszewski 2 participants 2 messages Jan 13, 2022 – Jan 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: Fix handling of vlan strip virtual channel messages

Modify netdev->features for vlan stripping based on virtual channel messages received from the PF. Change is needed to synchronize vlan strip status between PF sysfs and iavf ethtool.

Fixes 310a2ad92e3f ("virtchnl: rename i40e to generic virtchnl")

---
v3: NETIF_F_HW_VLAN_RX changed into NETIF_F_HW_VLAN_CTAG_RX because there's no such definition since Linux 3.10. The code is the same as the one from OOT. Code successfully passed inner review. netdev_update_features() function is not added because it causes infinite loop.

 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +42 -0
index a40e29455f7d..1805c1ae3bf4 100644
@@ -1490,6 +1490,24 @@ void iavf_request_reset(struct iavf_adapter *adapter)
 	adapter->current_op = VIRTCHNL_OP_UNKNOWN;
 }
 
+/**
+ * iavf_netdev_features_vlan_strip_set - update vlan strip status
+ * @netdev: ptr to netdev being adjusted
+ * @enable: enable or disable vlan strip
+ *
+ * Helper function to change vlan strip status in netdev->features.
+ */
+static void iavf_netdev_features_vlan_strip_set(struct net_device *netdev,
+						const bool enable)
+{
+	if (enable)
+		netdev->features |=
+			NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_RX;
+	else
+		netdev->features &=
+			~NETIF_F_HW_VLAN_CTAG_RX & ~NETIF_F_HW_VLAN_CTAG_RX;
+}
+
 /**
  * iavf_virtchnl_completion
  * @adapter: adapter structure
@@ -1713,8 +1731,18 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 			}
 			break;
 		case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
+			dev_warn(&adapter->pdev->dev, "Changing VLAN Stripping is not allowed when Port VLAN is configured\n");
+			/* Vlan stripping could not be enabled by ethtool.
+			 * Disable it in netdev->features.
+			 */
+			iavf_netdev_features_vlan_strip_set(netdev, false);
+			break;
 		case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
 			dev_warn(&adapter->pdev->dev, "Changing VLAN Stripping is not allowed when Port VLAN is configured\n");
+			/* Vlan stripping could not be disabled by ethtool.
+			 * Enable it in netdev->features.
+			 */
+			iavf_netdev_features_vlan_strip_set(netdev, true);
 			break;
 		default:
 			dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
@@ -1960,6 +1988,20 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		spin_unlock_bh(&adapter->adv_rss_lock);
 		}
 		break;
+	case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
+		/* PF enabled vlan strip on this VF.
+		 * Update netdev->features if needed to be in sync with ethtool.
+		 */
+		if (!v_retval)
+			iavf_netdev_features_vlan_strip_set(netdev, true);
+		break;
+	case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
+		/* PF disabled vlan strip on this VF.
+		 * Update netdev->features if needed to be in sync with ethtool.
+		 */
+		if (!v_retval)
+			iavf_netdev_features_vlan_strip_set(netdev, false);
+		break;
 	default:
 		if (adapter->current_op && (v_opcode != adapter->current_op))
 			dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 iavf: Fix handling of vlan strip virtual channel messages

Quoted 5 lines · Michal Maloszewski

Modify netdev->features for vlan stripping based on virtual channel messages received from the PF. Change is needed to synchronize vlan strip status between PF sysfs and iavf ethtool.

Fixes 310a2ad92e3f ("virtchnl: rename i40e to generic virtchnl")

Please use the commit that introduced the functional issue, not a rename patch.

Quoted 11 lines

---
v3: NETIF_F_HW_VLAN_RX changed into NETIF_F_HW_VLAN_CTAG_RX because there's
no such definition since Linux 3.10. The code is the same as the one from OOT.
Code successfully passed inner review. netdev_update_features() function is not added
because it causes infinite loop.

This is a v1, but there's a v3 changelog?

Quoted 22 lines

?.../net/ethernet/intel/iavf/iavf_virtchnl.c?? | 42
+++++++++++++++++++
?1 file changed, 42 insertions(+)

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +0 -0
index a40e29455f7d..1805c1ae3bf4 100644
@@ -1490,6 +1490,24 @@ void iavf_request_reset(struct iavf_adapter
 *adapter)
 ????????adapter->current_op = VIRTCHNL_OP_UNKNOWN;
 ?}

?

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +8 -0
+/**
+ * iavf_netdev_features_vlan_strip_set - update vlan strip status
+ * @netdev: ptr to netdev being adjusted
+ * @enable: enable or disable vlan strip
+ *
+ * Helper function to change vlan strip status in netdev->features.
+ */
+static void iavf_netdev_features_vlan_strip_set(struct net_device
Quoted 7 lines

*netdev, +???????????????????????????????????????????????const bool enable) +{
+???????if (enable)
+???????????????netdev->features |= +???????????????????????NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_RX;

These are the same flag.

Quoted 4 lines

+???????else +???????????????netdev->features &= +???????????????????????~NETIF_F_HW_VLAN_CTAG_RX & ~NETIF_F_HW_VLAN_CTAG_RX;

Same here.

Quoted 5 lines
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +2 -0
+}
+

?/**
? * iavf_virtchnl_completion
? * @adapter: adapter structure