Skip to contentSkip to conversation

ixgbe: Prevent unsupported configurations with XDP

PATCH Superseded Tony Nguyen 3 participants 3 messages Jul 30, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tony Nguyen

author maintainer
#0 lore raw

PATCH 1/1 ixgbe: Prevent unsupported configurations with XDP

These changes address comments by Jakub Kicinski on
commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP").

Change the MTU check with XDP to allow any supported value and only reject those outside of the range as opposed to rejecting any change when XDP is active. In situations where MTU size is not supported, return -EINVAL instead of -EPERM.

Add checks when enabling SRIOV or DCB as those are not supported with XDP.

CC Jakub Kicinski <[email protected]>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 23 +++++++++++++++++++++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c |  5 +++++
 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +21 -2
index 447098005490..5a594f0fcba5 100644
@@ -6620,8 +6620,18 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu)
 	struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
 	if (adapter->xdp_prog) {
-		e_warn(probe, "MTU cannot be changed while XDP program is loaded\n");
-		return -EPERM;
+		int new_frame_size = new_mtu + ETH_HLEN + ETH_FCS_LEN +
+				     VLAN_HLEN;
+		int i;
+
+		for (i = 0; i < adapter->num_rx_queues; i++) {
+			struct ixgbe_ring *ring = adapter->rx_ring[i];
+
+			if (new_frame_size > ixgbe_rx_bufsz(ring)) {
+				e_warn(probe, "Requested MTU size is not supported with XDP\n");
+				return -EINVAL;
+			}
+		}
 	}
 
 	/*
@@ -8983,6 +8993,15 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
 
 #ifdef CONFIG_IXGBE_DCB
 	if (tc) {
+		if (adapter->xdp_prog) {
+			e_warn(probe, "DCB is not supported with XDP\n");
+
+			ixgbe_init_interrupt_scheme(adapter);
+			if (netif_running(dev))
+				ixgbe_open(dev);
+			return -EINVAL;
+		}
+
 		netdev_set_num_tc(dev, tc);
 		ixgbe_set_prio_tc_map(adapter);
 
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +5 -0
index 6f59933cdff7..9264a5f8a5d0 100644
@@ -53,6 +53,11 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter,
 	struct ixgbe_hw *hw = &adapter->hw;
 	int i;
 
+	if (adapter->xdp_prog) {
+		e_warn(probe, "SRIOV is not supported with XDP\n");
+		return -EINVAL;
+	}
+
 	/* Enable VMDq flag so device will be set in VM mode */
 	adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED |
 			  IXGBE_FLAG_VMDQ_ENABLED;
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/1 ixgbe: Prevent unsupported configurations with XDP

Quoted 8 lines · Tony Nguyen

These changes address comments by Jakub Kicinski on
commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP").

Change the MTU check with XDP to allow any supported value and only reject those outside of the range as opposed to rejecting any change when XDP is active. In situations where MTU size is not supported, return -EINVAL instead of -EPERM.

Quoted 5 lines

Add checks when enabling SRIOV or DCB as those are not supported with XDP.

CC Jakub Kicinski <[email protected]>

Thank you! Buffer size and DCB checks look good AFAIU the ixgbe code :) But..

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +0 -0
index 6f59933cdff7..9264a5f8a5d0 100644
@@ -53,6 +53,11 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter,
 	struct ixgbe_hw *hw = &adapter->hw;

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter, · line 63

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +5 -0
 	int i;
 
+	if (adapter->xdp_prog) {
+		e_warn(probe, "SRIOV is not supported with XDP\n");
+		return -EINVAL;
+	}
+
 	/* Enable VMDq flag so device will be set in VM mode */
 	adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED |
 			  IXGBE_FLAG_VMDQ_ENABLED;

Is there not another path that could enable SR-IOV via ixgbe_fwd_add()?

#2 lore raw

PATCH 1/1 ixgbe: Prevent unsupported configurations with XDP

Quoted 29 lines

From: Jakub Kicinski [mailto:jakub.kicinski at netronome.com]
Sent: Monday, July 30, 2018 12:41 PM

Quoted 8 lines · Tony Nguyen

These changes address comments by Jakub Kicinski on commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP").

Change the MTU check with XDP to allow any supported value and only reject those outside of the range as opposed to rejecting any change when XDP is active. In situations where MTU size is not supported, return -EINVAL instead of -EPERM.

Quoted 5 lines

Add checks when enabling SRIOV or DCB as those are not supported with XDP.

CC Jakub Kicinski <[email protected]>

Thank you! Buffer size and DCB checks look good AFAIU the ixgbe code :) But..

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c static int __ixgbe_enable_sriov(struct ixgbe_adapter

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +0 -0
index 6f59933cdff7..9264a5f8a5d0 100644
@@ -53,6 +53,11 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter

*adapter,

Quoted 3 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +0 -0
 	struct ixgbe_hw *hw = &adapter->hw;
 	int i;
 
Quoted 10 lines

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter, · line 63

Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +5 -0
+	if (adapter->xdp_prog) {
+		e_warn(probe, "SRIOV is not supported with XDP\n");
+		return -EINVAL;
+	}
+
 	/* Enable VMDq flag so device will be set in VM mode */
 	adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED |
 			  IXGBE_FLAG_VMDQ_ENABLED;

Is there not another path that could enable SR-IOV via ixgbe_fwd_add()?

That's for offloaded macvlans but it does enable SRIOV for it. I'll do a v2 and add that as well.