Skip to contentSkip to conversation

i40e: Fix failure message when XDP is configured in TX only mode

PATCH In review Mateusz Palczewski 5 participants 5 messages Oct 7, 2022 – Nov 9, 2022

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

PATCH 1/1 i40e: Fix failure message when XDP is configured in TX only mode

From: Sylwester Dziedziuch <[email protected]>

When starting xdpsock program in TX only mode:

samples/bpf/xdpsock -i <interface> -t

there was an error on i40e driver:

Failed to allocate some buffers on AF_XDP ZC enabled Rx ring 0 (pf_q 81)

It was caused by trying to allocate RX buffers even though no RX buffers are available because we run in TX only mode.

Fix this by checking for number of available buffers for RX queue when allocating buffers during XDP setup.

Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -2
index e8d1fb8a966b..c06bdc03d2f4 100644
@@ -3554,7 +3554,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
 	struct i40e_hw *hw = &vsi->back->hw;
 	struct i40e_hmc_obj_rxq rx_ctx;
 	i40e_status err = 0;
-	bool ok;
+	bool ok = true;
 	int ret;
 
 	bitmap_zero(ring->state, __I40E_RING_STATE_NBITS);
@@ -3652,7 +3652,9 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
 
 	if (ring->xsk_pool) {
 		xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq);
-		ok = i40e_alloc_rx_buffers_zc(ring, I40E_DESC_UNUSED(ring));
+		if (ring->xsk_pool->free_list_cnt)
+			ok = i40e_alloc_rx_buffers_zc(ring,
+						      I40E_DESC_UNUSED(ring));
 	} else {
 		ok = !i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring));
 	}
Signature · 6 lines
2.31.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

Dear Mateusz, dear Sylwester,

Thank you for the patch.

Am 07.10.22 um 09:24 schrieb Mateusz Palczewski:

Quoted 37 lines

From: Sylwester Dziedziuch <[email protected]>

When starting xdpsock program in TX only mode:

samples/bpf/xdpsock -i <interface> -t

there was an error on i40e driver:

Failed to allocate some buffers on AF_XDP ZC enabled Rx ring 0 (pf_q 81)

It was caused by trying to allocate RX buffers even though no RX buffers are available because we run in TX only mode.

Fix this by checking for number of available buffers for RX queue when allocating buffers during XDP setup.

Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
---
  drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index e8d1fb8a966b..c06bdc03d2f4 100644
@@ -3554,7 +3554,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
  	struct i40e_hw *hw = &vsi->back->hw;
  	struct i40e_hmc_obj_rxq rx_ctx;
  	i40e_status err = 0;
-	bool ok;
+	bool ok = true;
  	int ret;
 
  	bitmap_zero(ring->state, __I40E_RING_STATE_NBITS);

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3655

Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -3652,7 +3652,9 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
 
  	if (ring->xsk_pool) {
  		xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq);
-		ok = i40e_alloc_rx_buffers_zc(ring, I40E_DESC_UNUSED(ring));
+		if (ring->xsk_pool->free_list_cnt)

I would have thought, that in the error case, ok should be initialized to false (at the top).

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3657

Quoted 2 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -0
+			ok = i40e_alloc_rx_buffers_zc(ring,
+						      I40E_DESC_UNUSED(ring));

As you pass ring to i40e_alloc_rx_buffers_zc(), can’t the check not be done there?

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3660

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
  	} else {
  		ok = !i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring));
  	}

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 1 line · Paul Menzel

Dear Mateusz, dear Sylwester,

Hey everyone,

Quoted 12 lines

Thank you for the patch.

Am 07.10.22 um 09:24 schrieb Mateusz Palczewski:

Quoted 7 lines

From: Sylwester Dziedziuch <[email protected]>

When starting xdpsock program in TX only mode:

samples/bpf/xdpsock -i <interface> -t

there was an error on i40e driver:

It's not a strict error, rather information which we tend to ignore lately.

Quoted 8 lines
Quoted 8 lines

Failed to allocate some buffers on AF_XDP ZC enabled Rx ring 0 (pf_q 81)

It was caused by trying to allocate RX buffers even though no RX buffers are available because we run in TX only mode.

Fix this by checking for number of available buffers for RX queue when allocating buffers during XDP setup.

CC Magnus Karlsson <[email protected]>
Quoted 20 lines
Quoted 20 lines
Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
---
  drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index e8d1fb8a966b..c06bdc03d2f4 100644
@@ -3554,7 +3554,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
  	struct i40e_hw *hw = &vsi->back->hw;
  	struct i40e_hmc_obj_rxq rx_ctx;
  	i40e_status err = 0;
-	bool ok;
+	bool ok = true;
  	int ret;
  	bitmap_zero(ring->state, __I40E_RING_STATE_NBITS);
Quoted 8 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3654

Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -3652,7 +3652,9 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
  	if (ring->xsk_pool) {
  		xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq);
-		ok = i40e_alloc_rx_buffers_zc(ring, I40E_DESC_UNUSED(ring));
+		if (ring->xsk_pool->free_list_cnt)

I would have thought, that in the error case, ok should be initialized to false (at the top).

Then this patch would be pointless. Guys were probably fixing some defect reported that this confusing error message was popping up in dmesg. Having this as false would cause to still print this out.

Quoted 6 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3657

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -0
+			ok = i40e_alloc_rx_buffers_zc(ring,
+						      I40E_DESC_UNUSED(ring));

As you pass ring to i40e_alloc_rx_buffers_zc(), can’t the check not be done there?

Even if we would proceed with this then no as this would hurt hot path callsite.

Quoted 6 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3660

Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
  	} else {
  		ok = !i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring));
  	}
Quoted 7 lines

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw
Quoted 5 lines · Maciej
Quoted 1 line · Paul Menzel

Dear Mateusz, dear Sylwester,

Hey everyone,

Hello,

Quoted 56 lines
Quoted 13 lines

Thank you for the patch.

Am 07.10.22 um 09:24 schrieb Mateusz Palczewski:

Quoted 7 lines

From: Sylwester Dziedziuch <[email protected]>

When starting xdpsock program in TX only mode:

samples/bpf/xdpsock -i <interface> -t

there was an error on i40e driver:

It's not a strict error, rather information which we tend to ignore lately.

Quoted 9 lines
Quoted 9 lines

Failed to allocate some buffers on AF_XDP ZC enabled Rx ring 0 (pf_q
81)

It was caused by trying to allocate RX buffers even though no RX buffers are available because we run in TX only mode.

Fix this by checking for number of available buffers for RX queue when allocating buffers during XDP setup.

CC Magnus Karlsson <[email protected]>
Quoted 9 lines
Quoted 9 lines
Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
Signed-off-by Sylwester Dziedziuch

<[email protected]>

---
  drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 6 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct

Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
index e8d1fb8a966b..c06bdc03d2f4 100644
@@ -3554,7 +3554,7 @@ static int i40e_configure_rx_ring(struct

i40e_ring *ring)

Quoted 11 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring)

Quoted 11 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -2
  	struct i40e_hw *hw = &vsi->back->hw;
  	struct i40e_hmc_obj_rxq rx_ctx;
  	i40e_status err = 0;
-	bool ok;
+	bool ok = true;
  	int ret;
  	bitmap_zero(ring->state, __I40E_RING_STATE_NBITS); @@ -3652,7
+3652,9 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
  	if (ring->xsk_pool) {
  		xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq);
-		ok = i40e_alloc_rx_buffers_zc(ring,

I40E_DESC_UNUSED(ring));

Quoted 9 lines
Quoted 4 lines

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_configure_rx_ring(struct i40e_ring *ring) · line 3655

Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
+		if (ring->xsk_pool->free_list_cnt)

I would have thought, that in the error case, ok should be initialized to false (at the top).

Then this patch would be pointless. Guys were probably fixing some defect reported that this confusing error message was popping up in dmesg. Having this as false would cause to still print this out.

It is exactly what Maciej wrote. In case user didn't provide any buffers we don't need to try allocating them as it will fail anyway. In this case we know we are running in Tx only mode and we should not scare the user with the failure message which is printed if ok is false. That is why we initialize ok to true so in case there are no buffers we skip the allocation and don't print the error message. If there are some buffers available however and the allocation fails then ok will be properly set by i40e_alloc_rx_buffers_zc and the error message will be printed.

Quoted 5 lines
Quoted 3 lines

drivers/net/ethernet/intel/i40e/i40e_main.c

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -0
+			ok = i40e_alloc_rx_buffers_zc(ring,
+

I40E_DESC_UNUSED(ring));

Quoted 1 line
Quoted 19 lines
Quoted 2 lines

As you pass ring to i40e_alloc_rx_buffers_zc(), can’t the check not be done there?

Even if we would proceed with this then no as this would hurt hot path callsite.

Quoted 13 lines
Quoted 4 lines
  	} else {
  		ok = !i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring));
  	}

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v1 1/1
#4 lore raw
In reply to Mateusz Palczewski
Quoted 27 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Mateusz Palczewski
Sent: Friday, October 7, 2022 12:54 PM
To: [email protected]
Cc: Dziedziuch, SylwesterX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v1] i40e: Fix failure message when XDP is configured in TX only mode

From: Sylwester Dziedziuch <[email protected]>

When starting xdpsock program in TX only mode:

samples/bpf/xdpsock -i <interface> -t

there was an error on i40e driver:

Failed to allocate some buffers on AF_XDP ZC enabled Rx ring 0 (pf_q 81)

It was caused by trying to allocate RX buffers even though no RX buffers are available because we run in TX only mode.

Fix this by checking for number of available buffers for RX queue when allocating buffers during XDP setup.

Quoted 7 lines
Fixes 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan