* [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface
@ 2022-12-09 18:54 Tony Nguyen
2022-12-09 19:07 ` Saeed Mahameed
2022-12-12 23:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Tony Nguyen @ 2022-12-09 18:54 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet
Cc: Bartosz Staszewski, netdev, anthony.l.nguyen, maciej.fijalkowski,
magnus.karlsson, bjorn, ast, daniel, hawk, john.fastabend, bpf,
saeed, Mateusz Palczewski, Shwetha Nagaraju
From: Bartosz Staszewski <bartoszx.staszewski@intel.com>
Whenever trying to load XDP prog on downed interface, function i40e_xdp
was passing vsi->rx_buf_len field to i40e_xdp_setup() which was equal 0.
i40e_open() calls i40e_vsi_configure_rx() which configures that field,
but that only happens when interface is up. When it is down, i40e_open()
is not being called, thus vsi->rx_buf_len is not set.
Solution for this is calculate buffer length in newly created
function - i40e_calculate_vsi_rx_buf_len() that return actual buffer
length. Buffer length is being calculated based on the same rules
applied previously in i40e_vsi_configure_rx() function.
Fixes: 613142b0bb88 ("i40e: Log error for oversized MTU on device")
Fixes: 0c8493d90b6b ("i40e: add XDP support for pass and drop actions")
Signed-off-by: Bartosz Staszewski <bartoszx.staszewski@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Tested-by: Shwetha Nagaraju <Shwetha.nagaraju@intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
v3:
- Remove unnecessary braces and parentheses
- Simplify return in i40e_calculate_vsi_rx_buf_len(); return early on
if conditions and remove elses
v2: https://lore.kernel.org/netdev/20221207180842.1096243-1-anthony.l.nguyen@intel.com/
- Change title and rework commit message
- Dropped, previous, patch 1
v1: https://lore.kernel.org/netdev/20221115000324.3040207-1-anthony.l.nguyen@intel.com/
drivers/net/ethernet/intel/i40e/i40e_main.c | 36 ++++++++++++++-------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 6416322d7c18..e6e349f0c945 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -3693,6 +3693,24 @@ static int i40e_vsi_configure_tx(struct i40e_vsi *vsi)
return err;
}
+/**
+ * i40e_calculate_vsi_rx_buf_len - Calculates buffer length
+ *
+ * @vsi: VSI to calculate rx_buf_len from
+ */
+static u16 i40e_calculate_vsi_rx_buf_len(struct i40e_vsi *vsi)
+{
+ if (!vsi->netdev || (vsi->back->flags & I40E_FLAG_LEGACY_RX))
+ return I40E_RXBUFFER_2048;
+
+#if (PAGE_SIZE < 8192)
+ if (!I40E_2K_TOO_SMALL_WITH_PADDING && vsi->netdev->mtu <= ETH_DATA_LEN)
+ return I40E_RXBUFFER_1536 - NET_IP_ALIGN;
+#endif
+
+ return PAGE_SIZE < 8192 ? I40E_RXBUFFER_3072 : I40E_RXBUFFER_2048;
+}
+
/**
* i40e_vsi_configure_rx - Configure the VSI for Rx
* @vsi: the VSI being configured
@@ -3704,20 +3722,14 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)
int err = 0;
u16 i;
- if (!vsi->netdev || (vsi->back->flags & I40E_FLAG_LEGACY_RX)) {
- vsi->max_frame = I40E_MAX_RXBUFFER;
- vsi->rx_buf_len = I40E_RXBUFFER_2048;
+ vsi->max_frame = I40E_MAX_RXBUFFER;
+ vsi->rx_buf_len = i40e_calculate_vsi_rx_buf_len(vsi);
+
#if (PAGE_SIZE < 8192)
- } else if (!I40E_2K_TOO_SMALL_WITH_PADDING &&
- (vsi->netdev->mtu <= ETH_DATA_LEN)) {
+ if (vsi->netdev && !I40E_2K_TOO_SMALL_WITH_PADDING &&
+ vsi->netdev->mtu <= ETH_DATA_LEN)
vsi->max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
- vsi->rx_buf_len = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
#endif
- } else {
- vsi->max_frame = I40E_MAX_RXBUFFER;
- vsi->rx_buf_len = (PAGE_SIZE < 8192) ? I40E_RXBUFFER_3072 :
- I40E_RXBUFFER_2048;
- }
/* set up individual rings */
for (i = 0; i < vsi->num_queue_pairs && !err; i++)
@@ -13282,7 +13294,7 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog,
int i;
/* Don't allow frames that span over multiple buffers */
- if (frame_size > vsi->rx_buf_len) {
+ if (frame_size > i40e_calculate_vsi_rx_buf_len(vsi)) {
NL_SET_ERR_MSG_MOD(extack, "MTU too large to enable XDP");
return -EINVAL;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface
2022-12-09 18:54 [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface Tony Nguyen
@ 2022-12-09 19:07 ` Saeed Mahameed
2022-12-12 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Saeed Mahameed @ 2022-12-09 19:07 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, kuba, pabeni, edumazet, Bartosz Staszewski, netdev,
maciej.fijalkowski, magnus.karlsson, bjorn, ast, daniel, hawk,
john.fastabend, bpf, Mateusz Palczewski, Shwetha Nagaraju
On 09 Dec 10:54, Tony Nguyen wrote:
>From: Bartosz Staszewski <bartoszx.staszewski@intel.com>
>
>Whenever trying to load XDP prog on downed interface, function i40e_xdp
>was passing vsi->rx_buf_len field to i40e_xdp_setup() which was equal 0.
>i40e_open() calls i40e_vsi_configure_rx() which configures that field,
>but that only happens when interface is up. When it is down, i40e_open()
>is not being called, thus vsi->rx_buf_len is not set.
>
>Solution for this is calculate buffer length in newly created
>function - i40e_calculate_vsi_rx_buf_len() that return actual buffer
>length. Buffer length is being calculated based on the same rules
>applied previously in i40e_vsi_configure_rx() function.
>
>Fixes: 613142b0bb88 ("i40e: Log error for oversized MTU on device")
>Fixes: 0c8493d90b6b ("i40e: add XDP support for pass and drop actions")
>Signed-off-by: Bartosz Staszewski <bartoszx.staszewski@intel.com>
>Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
>Tested-by: Shwetha Nagaraju <Shwetha.nagaraju@intel.com>
>Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
>Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
>---
>v3:
>- Remove unnecessary braces and parentheses
>- Simplify return in i40e_calculate_vsi_rx_buf_len(); return early on
>if conditions and remove elses
>
Reviewed-by: Saeed Mahameed <saeed@kernel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface
2022-12-09 18:54 [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface Tony Nguyen
2022-12-09 19:07 ` Saeed Mahameed
@ 2022-12-12 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 23:30 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, kuba, pabeni, edumazet, bartoszx.staszewski, netdev,
maciej.fijalkowski, magnus.karlsson, bjorn, ast, daniel, hawk,
john.fastabend, bpf, saeed, mateusz.palczewski, Shwetha.nagaraju
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 9 Dec 2022 10:54:11 -0800 you wrote:
> From: Bartosz Staszewski <bartoszx.staszewski@intel.com>
>
> Whenever trying to load XDP prog on downed interface, function i40e_xdp
> was passing vsi->rx_buf_len field to i40e_xdp_setup() which was equal 0.
> i40e_open() calls i40e_vsi_configure_rx() which configures that field,
> but that only happens when interface is up. When it is down, i40e_open()
> is not being called, thus vsi->rx_buf_len is not set.
>
> [...]
Here is the summary with links:
- [net,v3,1/1] i40e: Fix the inability to attach XDP program on downed interface
https://git.kernel.org/netdev/net/c/0c87b545a2ed
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-12 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 18:54 [PATCH net v3 1/1] i40e: Fix the inability to attach XDP program on downed interface Tony Nguyen
2022-12-09 19:07 ` Saeed Mahameed
2022-12-12 23:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).