Skip to contentSkip to conversation

Intel Wired LAN Driver Updates 2019-09-11

GIT PULL New Jeff Kirsher 2 participants 15 messages Sep 11, 2019 – Sep 13, 2019

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

This series contains updates to i40e, ixgbe/vf and iavf.

Wenwen Wang fixes a potential memory leak where 3 allocated variables are not properly cleaned up on failure for ixgbe.

Stefan Assmann fixes a potential kernel panic found when repeatedly spawning and destroying VFs in i40e when a NULL pointer is dereferenced due to a race condition. Fixed up the i40e driver to clear the __I40E_VIRTCHNL_OP_PENDING bit before returning after an invalid minimum transmit rate is requested. Updates the iavf driver to only apply the MAC address change when the PF ACK's the requested change.

Tonghao Zhang updates ixgbe to use the skb_get_queue_mapping() API call instead of the driver accessing the queue mapping directly.

Jake updates i40e to use ktime_get_real_ts64() instead of ktime_to_timespec64(). Removes the define for bit 0x0001 for cloud filters, since it is a reserved bit and not a valid type. Also added code comments to clearly state which bits are reserved and should not be used or defined for cloud filter adminq command. Clarify the macros used to specify the cloud filter fields are individual bits, so use the BIT() macro.

Aleksandr fixes up the print_link_message() to include the "negotiated" FEC status for i40e.

Czeslaw also adds additional log message for devices without FEC in the print_link_message() for i40e.

Colin Ian King reduces the object code size by making the array API static constant.

Magnus fixes a potential receive buffer starvation issue for AF_XDP by kicking the NAPI context of any queue with an attached AF_XDP zero-copy socket.

v2: Removed patch 11 from the original series (Alex Duyck's ITR fix),
so that it can be sent to the net tree.

The following are changes since commit c1609946b8b6485e1d405663004867ea9e92178a:
Merge branch 'qed-Fix-series'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 40GbE

Aleksandr Loktionov (1):
i40e: fix missed "Negotiated" string in i40e_print_link_message()

Colin Ian King (1):
net/ixgbevf: make array api static const, makes object smaller

Czeslaw Zagorski (1):
i40e: Fix message for other card without FEC.

Jacob Keller (4):
i40e: use ktime_get_real_ts64 instead of ktime_to_timespec64
i40e: remove I40E_AQC_ADD_CLOUD_FILTER_OIP
i40e: mark additional missing bits as reserved
i40e: use BIT macro to specify the cloud filter field flags

Magnus Karlsson (1):
i40e: fix potential RX buffer starvation for AF_XDP

Stefan Assmann (3):
i40e: check __I40E_VF_DISABLE bit in i40e_sync_filters_subtask
i40e: clear __I40E_VIRTCHNL_OP_PENDING on invalid min Tx rate
iavf: fix MAC address setting for VFs when filter is rejected

Tonghao Zhang (1):
ixgbe: use skb_get_queue_mapping in tx path

Wenwen Wang (1):
ixgbe: fix memory leaks

 drivers/net/ethernet/intel/i40e/i40e.h        | 10 +++----
 .../net/ethernet/intel/i40e/i40e_adminq_cmd.h |  5 +++-
 drivers/net/ethernet/intel/i40e/i40e_main.c   | 30 ++++++++++++-------
 drivers/net/ethernet/intel/i40e/i40e_ptp.c    |  2 +-
 .../ethernet/intel/i40e/i40e_virtchnl_pf.c    |  3 +-
 drivers/net/ethernet/intel/i40e/i40e_xsk.c    |  5 ++++
 drivers/net/ethernet/intel/iavf/iavf_main.c   |  1 -
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  7 +++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  6 +++-
 .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 14 +++++----
 10 files changed, 57 insertions(+), 26 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/13 ixgbe: fix memory leaks

From: Wenwen Wang <[email protected]>

In ixgbe_configure_clsu32(), 'jump', 'input', and 'mask' are allocated through kzalloc() respectively in a for loop body. Then, ixgbe_clsu32_build_input() is invoked to build the input. If this process fails, next iteration of the for loop will be executed. However, the allocated 'jump', 'input', and 'mask' are not deallocated on this execution path, leading to memory leaks.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4 -0
index 99df595abfba..95c0827dfd4c 100644
@@ -9490,6 +9490,10 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,
 				jump->mat = nexthdr[i].jump;
 				adapter->jump_tables[link_uhtid] = jump;
 				break;
+			} else {
+				kfree(mask);
+				kfree(input);
+				kfree(jump);
 			}
 		}
 		return 0;
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 2/13 i40e: check __I40E_VF_DISABLE bit in i40e_sync_filters_subtask

In reply to Jeff Kirsher

From: Stefan Assmann <[email protected]>

While testing VF spawn/destroy the following panic occurred.

BUG: unable to handle kernel NULL pointer dereference at 0000000000000029
[...]
Workqueue: i40e i40e_service_task [i40e]
RIP: 0010:i40e_sync_vsi_filters+0x6fd/0xc60 [i40e]
[...]
Call Trace:
 ? __switch_to_asm+0x35/0x70
 ? __switch_to_asm+0x41/0x70
 ? __switch_to_asm+0x35/0x70
 ? _cond_resched+0x15/0x30
 i40e_sync_filters_subtask+0x56/0x70 [i40e]
 i40e_service_task+0x382/0x11b0 [i40e]
 ? __switch_to_asm+0x41/0x70
 ? __switch_to_asm+0x41/0x70
 process_one_work+0x1a7/0x3b0
 worker_thread+0x30/0x390
 ? create_worker+0x1a0/0x1a0
 kthread+0x112/0x130
 ? kthread_bind+0x30/0x30
 ret_from_fork+0x35/0x40

Investigation revealed a race where pf->vf[vsi->vf_id].trusted may get accessed by the watchdog via i40e_sync_filters_subtask() although i40e_free_vfs() already free'd pf->vf.
To avoid this the call to i40e_sync_vsi_filters() in i40e_sync_filters_subtask() needs to be guarded by __I40E_VF_DISABLE, which is also used by i40e_free_vfs().

Note: put the __I40E_VF_DISABLE check after the __I40E_MACVLAN_SYNC_PENDING check as the latter is more likely to trigger.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -0
index e9f2f276bf27..3e2e465f43f9 100644
@@ -2592,6 +2592,10 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
 		return;
 	if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state))
 		return;
+	if (test_and_set_bit(__I40E_VF_DISABLE, pf->state)) {
+		set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state);
+		return;
+	}
 
 	for (v = 0; v < pf->num_alloc_vsi; v++) {
 		if (pf->vsi[v] &&
@@ -2606,6 +2610,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
 			}
 		}
 	}
+	clear_bit(__I40E_VF_DISABLE, pf->state);
 }
 
 /**
Signature · 1 line
2.21.0
#3 lore raw

PATCH v2 3/13 ixgbe: use skb_get_queue_mapping in tx path

In reply to Jeff Kirsher

From: Tonghao Zhang <[email protected]>

Use the common api, and don't access queue_mapping directly.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
index 95c0827dfd4c..dc034f4e8cf6 100644
@@ -8748,7 +8748,7 @@ static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb,
 	if (skb_put_padto(skb, 17))
 		return NETDEV_TX_OK;
 
-	tx_ring = ring ? ring : adapter->tx_ring[skb->queue_mapping];
+	tx_ring = ring ? ring : adapter->tx_ring[skb_get_queue_mapping(skb)];
 	if (unlikely(test_bit(__IXGBE_TX_DISABLED, &tx_ring->state)))
 		return NETDEV_TX_BUSY;
 
Signature · 1 line
2.21.0
#4 lore raw

PATCH v2 4/13 i40e: use ktime_get_real_ts64 instead of ktime_to_timespec64

In reply to Jeff Kirsher

From: Jacob Keller <[email protected]>

Remove a call to ktime_to_timespec64 by calling ktime_get_real_ts64 directly.

---
 drivers/net/ethernet/intel/i40e/i40e_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +1 -1
index 11394a52e21c..9bf1ad4319f5 100644
@@ -725,7 +725,7 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
 	pf->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
 
 	/* Set the previous "reset" time to the current Kernel clock time */
-	pf->ptp_prev_hw_time = ktime_to_timespec64(ktime_get_real());
+	ktime_get_real_ts64(&pf->ptp_prev_hw_time);
 	pf->ptp_reset_start = ktime_get();
 
 	return 0;
Signature · 1 line
2.21.0
#5 lore raw

PATCH v2 5/13 i40e: remove I40E_AQC_ADD_CLOUD_FILTER_OIP

In reply to Jeff Kirsher

From: Jacob Keller <[email protected]>

The bit 0x0001 used in the cloud filters adminq command is reserved, and is not actually a valid type.

The Linux driver has never used this type, and it's not clear if any driver ever has.

---
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h +1 -1
index 21cccec328e3..7ff768761659 100644
@@ -1382,7 +1382,7 @@ struct i40e_aqc_cloud_filters_element_data {
 #define I40E_AQC_ADD_CLOUD_FILTER_MASK	(0x3F << \
 					I40E_AQC_ADD_CLOUD_FILTER_SHIFT)
 /* 0x0000 reserved */
-#define I40E_AQC_ADD_CLOUD_FILTER_OIP			0x0001
+/* 0x0001 reserved */
 /* 0x0002 reserved */
 #define I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN		0x0003
 #define I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID	0x0004
Signature · 1 line
2.21.0
#6 lore raw

PATCH v2 6/13 i40e: mark additional missing bits as reserved

In reply to Jeff Kirsher

From: Jacob Keller <[email protected]>

Mark bits 0xD through 0xF for the command flags of a cloud filter as reserved. These bits are not yet defined and are considered as reserved in the data sheet.

---
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h +3 -0
index 7ff768761659..530613f31527 100644
@@ -1394,6 +1394,9 @@ struct i40e_aqc_cloud_filters_element_data {
 #define I40E_AQC_ADD_CLOUD_FILTER_IMAC			0x000A
 #define I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC	0x000B
 #define I40E_AQC_ADD_CLOUD_FILTER_IIP			0x000C
+/* 0x000D reserved */
+/* 0x000E reserved */
+/* 0x000F reserved */
 /* 0x0010 to 0x0017 is for custom filters */
 #define I40E_AQC_ADD_CLOUD_FILTER_IP_PORT		0x0010 /* Dest IP + L4 Port */
 #define I40E_AQC_ADD_CLOUD_FILTER_MAC_PORT		0x0011 /* Dest MAC + L4 Port */
Signature · 1 line
2.21.0
#7 lore raw

PATCH v2 7/13 i40e: fix missed "Negotiated" string in i40e_print_link_message()

In reply to Jeff Kirsher

From: Aleksandr Loktionov <[email protected]>

The "Negotiated" string in i40e_print_link_message() function was missed. This string has been added to the dmesg and small refactoring done removing common substrings and unifying link status message format. Without this patch it was not clear that FEC is related to negotiated FEC.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +10 -9
index 3e2e465f43f9..700f38ec8e91 100644
@@ -6569,19 +6569,19 @@ void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
 	}
 
 	if (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_25GB) {
-		req_fec = ", Requested FEC: None";
-		fec = ", FEC: None";
-		an = ", Autoneg: False";
+		req_fec = "None";
+		fec = "None";
+		an = "False";
 
 		if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED)
-			an = ", Autoneg: True";
+			an = "True";
 
 		if (pf->hw.phy.link_info.fec_info &
 		    I40E_AQ_CONFIG_FEC_KR_ENA)
-			fec = ", FEC: CL74 FC-FEC/BASE-R";
+			fec = "CL74 FC-FEC/BASE-R";
 		else if (pf->hw.phy.link_info.fec_info &
 			 I40E_AQ_CONFIG_FEC_RS_ENA)
-			fec = ", FEC: CL108 RS-FEC";
+			fec = "CL108 RS-FEC";
 
 		/* 'CL108 RS-FEC' should be displayed when RS is requested, or
 		 * both RS and FC are requested
@@ -6590,13 +6590,14 @@ void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
 		    (I40E_AQ_REQUEST_FEC_KR | I40E_AQ_REQUEST_FEC_RS)) {
 			if (vsi->back->hw.phy.link_info.req_fec_info &
 			    I40E_AQ_REQUEST_FEC_RS)
-				req_fec = ", Requested FEC: CL108 RS-FEC";
+				req_fec = "CL108 RS-FEC";
 			else
-				req_fec = ", Requested FEC: CL74 FC-FEC/BASE-R";
+				req_fec = "CL74 FC-FEC/BASE-R";
 		}
 	}
 
-	netdev_info(vsi->netdev, "NIC Link is Up, %sbps Full Duplex%s%s%s, Flow Control: %s\n",
+	netdev_info(vsi->netdev,
+		    "NIC Link is Up, %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s, Autoneg: %s, Flow Control: %s\n",
 		    speed, req_fec, fec, an, fc);
 }
 
Signature · 1 line
2.21.0
#8 lore raw

PATCH v2 8/13 i40e: Fix message for other card without FEC.

In reply to Jeff Kirsher

From: Czeslaw Zagorski <[email protected]>

When variable "req_fec, fec, an" are empty,
dmesg shows log with "Requested FEC: , Negotiated FEC: , Autoneg:". Add link dmesg log for cards without FEC.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +7 -3
index 700f38ec8e91..6031223eafab 100644
@@ -6594,11 +6594,15 @@ void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
 			else
 				req_fec = "CL74 FC-FEC/BASE-R";
 		}
+		netdev_info(vsi->netdev,
+			    "NIC Link is Up, %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s, Autoneg: %s, Flow Control: %s\n",
+			    speed, req_fec, fec, an, fc);
+	} else {
+		netdev_info(vsi->netdev,
+			    "NIC Link is Up, %sbps Full Duplex, Flow Control: %s\n",
+			    speed, fc);
 	}
 
-	netdev_info(vsi->netdev,
-		    "NIC Link is Up, %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s, Autoneg: %s, Flow Control: %s\n",
-		    speed, req_fec, fec, an, fc);
 }
 
 /**
Signature · 1 line
2.21.0
#9 lore raw

PATCH v2 9/13 i40e: use BIT macro to specify the cloud filter field flags

In reply to Jeff Kirsher

From: Jacob Keller <[email protected]>

The macros used to specify the cloud filter fields are intended to be individual bits. Declare them using the BIT() macro to make their intention a little more clear.

---
 drivers/net/ethernet/intel/i40e/i40e.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +5 -5
index f1a1bd324b50..2af9f6308f84 100644
@@ -243,11 +243,11 @@ struct i40e_fdir_filter {
 	u32 fd_id;
 };
 
-#define I40E_CLOUD_FIELD_OMAC	0x01
-#define I40E_CLOUD_FIELD_IMAC	0x02
-#define I40E_CLOUD_FIELD_IVLAN	0x04
-#define I40E_CLOUD_FIELD_TEN_ID	0x08
-#define I40E_CLOUD_FIELD_IIP	0x10
+#define I40E_CLOUD_FIELD_OMAC		BIT(0)
+#define I40E_CLOUD_FIELD_IMAC		BIT(1)
+#define I40E_CLOUD_FIELD_IVLAN		BIT(2)
+#define I40E_CLOUD_FIELD_TEN_ID		BIT(3)
+#define I40E_CLOUD_FIELD_IIP		BIT(4)
 
 #define I40E_CLOUD_FILTER_FLAGS_OMAC	I40E_CLOUD_FIELD_OMAC
 #define I40E_CLOUD_FILTER_FLAGS_IMAC	I40E_CLOUD_FIELD_IMAC
Signature · 1 line
2.21.0
#10 lore raw

PATCH v2 10/13 i40e: clear __I40E_VIRTCHNL_OP_PENDING on invalid min Tx rate

In reply to Jeff Kirsher

From: Stefan Assmann <[email protected]>

In the case of an invalid min Tx rate being requested i40e_ndo_set_vf_bw() immediately returns -EINVAL instead of releasing __I40E_VIRTCHNL_OP_PENDING first.

---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -1
index f8aa4deceb5e..3d2440838822 100644
@@ -4263,7 +4263,8 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
 	if (min_tx_rate) {
 		dev_err(&pf->pdev->dev, "Invalid min tx rate (%d) (greater than 0) specified for VF %d.\n",
 			min_tx_rate, vf_id);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto error;
 	}
 
 	vf = &pf->vf[vf_id];
Signature · 1 line
2.21.0
#11 lore raw

PATCH v2 11/13 iavf: fix MAC address setting for VFs when filter is rejected

In reply to Jeff Kirsher

From: Stefan Assmann <[email protected]>

Currently iavf unconditionally applies MAC address change requests. This brings the VF in a state where it is no longer able to pass traffic if the PF rejects a MAC filter change for the VF.
A typical scenario for a rejected MAC filter is for an untrusted VF to request to change the MAC address when an administratively set MAC is present.

To keep iavf working in this scenario the MAC filter handling in iavf needs to act on the PF reply regarding the MAC filter change. In the case of an ack the new MAC address gets set, whereas in the case of a nack the previous MAC address needs to stay in place.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c     | 1 -
 drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 7 +++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -1
index 07f5541a0f01..8f310e520b06 100644
@@ -804,7 +804,6 @@ static int iavf_set_mac(struct net_device *netdev, void *p)
 
 	if (f) {
 		ether_addr_copy(hw->mac.addr, addr->sa_data);
-		ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
 	}
 
 	return (f == NULL) ? -ENOMEM : 0;
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +7 -0
index d49d58a6de80..c46770eba320 100644
@@ -1252,6 +1252,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		case VIRTCHNL_OP_ADD_ETH_ADDR:
 			dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
 				iavf_stat_str(&adapter->hw, v_retval));
+			/* restore administratively set MAC address */
+			ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
 			break;
 		case VIRTCHNL_OP_DEL_VLAN:
 			dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
@@ -1319,6 +1321,11 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		}
 	}
 	switch (v_opcode) {
+	case VIRTCHNL_OP_ADD_ETH_ADDR: {
+		if (!ether_addr_equal(netdev->dev_addr, adapter->hw.mac.addr))
+			ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
+		}
+		break;
 	case VIRTCHNL_OP_GET_STATS: {
 		struct iavf_eth_stats *stats =
 			(struct iavf_eth_stats *)msg;
Signature · 1 line
2.21.0
#12 lore raw

PATCH v2 12/13 net/ixgbevf: make array api static const, makes object smaller

In reply to Jeff Kirsher

From: Colin Ian King <[email protected]>

Don't populate the array API on the stack but instead make it static const. Makes the object code smaller by 58 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  82969	   9763	    256	  92988	  16b3c	ixgbevf/ixgbevf_main.o

After:

   text	   data	    bss	    dec	    hex	filename
  82815	   9859	    256	  92930	  16b02	ixgbevf/ixgbevf_main.o

(gcc version 9.2.1, amd64)

---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +8 -6
index 75e849a64db7..75e93ce2ed99 100644
@@ -2261,12 +2261,14 @@ static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
 static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)
 {
 	struct ixgbe_hw *hw = &adapter->hw;
-	int api[] = { ixgbe_mbox_api_14,
-		      ixgbe_mbox_api_13,
-		      ixgbe_mbox_api_12,
-		      ixgbe_mbox_api_11,
-		      ixgbe_mbox_api_10,
-		      ixgbe_mbox_api_unknown };
+	static const int api[] = {
+		ixgbe_mbox_api_14,
+		ixgbe_mbox_api_13,
+		ixgbe_mbox_api_12,
+		ixgbe_mbox_api_11,
+		ixgbe_mbox_api_10,
+		ixgbe_mbox_api_unknown
+	};
 	int err, idx = 0;
 
 	spin_lock_bh(&adapter->mbx_lock);
Signature · 1 line
2.21.0
#13 lore raw

PATCH v2 13/13 i40e: fix potential RX buffer starvation for AF_XDP

In reply to Jeff Kirsher

From: Magnus Karlsson <[email protected]>

When the RX rings are created they are also populated with buffers so that packets can be received. Usually these are kernel buffers, but for AF_XDP in zero-copy mode, these are user-space buffers and in this case the application might not have sent down any buffers to the driver at this point. And if no buffers are allocated at ring creation time, no packets can be received and no interrupts will be generated so the NAPI poll function that allocates buffers to the rings will never get executed.

To rectify this, we kick the NAPI context of any queue with an attached AF_XDP zero-copy socket in two places in the code. Once after an XDP program has loaded and once after the umem is registered. This take care of both cases: XDP program gets loaded first then AF_XDP socket is created, and the reverse, AF_XDP socket is created first, then XDP program is loaded.

Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +5 -0
index 0373bc6c7e61..feb5bd54d840 100644
@@ -157,6 +157,11 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid)
 		err = i40e_queue_pair_enable(vsi, qid);
 		if (err)
 			return err;
+
+		/* Kick start the NAPI context so that receiving will start */
+		err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
+		if (err)
+			return err;
 	}
 
 	return 0;
Signature · 1 line
2.21.0