* [PATCH net] bnx2x: use the right build_skb() helper
@ 2023-03-29 0:00 Jakub Kicinski
2023-03-29 12:35 ` Leon Romanovsky
2023-03-30 4:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-03-29 0:00 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, Jakub Kicinski, Thomas Voegtle, aelior,
skalluru, manishc, keescook
build_skb() no longer accepts slab buffers. Since slab use is fairly
uncommon we prefer the drivers to call a separate slab_build_skb()
function appropriately.
bnx2x uses the old semantics where size of 0 meant buffer from slab.
It sets the fp->rx_frag_size to 0 for MTUs which don't fit in a page.
It needs to call slab_build_skb().
This fixes the WARN_ONCE() of incorrect API use seen with bnx2x.
Reported-by: Thomas Voegtle <tv@lio96.de>
Link: https://lore.kernel.org/all/b8f295e4-ba57-8bfb-7d9c-9d62a498a727@lio96.de/
Fixes: ce098da1497c ("skbuff: Introduce slab_build_skb()")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: aelior@marvell.com
CC: skalluru@marvell.com
CC: manishc@marvell.com
CC: keescook@chromium.org
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 16c490692f42..12083b9679b5 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -672,6 +672,18 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
return 0;
}
+static struct sk_buff *
+bnx2x_build_skb(const struct bnx2x_fastpath *fp, void *data)
+{
+ struct sk_buff *skb;
+
+ if (fp->rx_frag_size)
+ skb = build_skb(data, fp->rx_frag_size);
+ else
+ skb = slab_build_skb(data);
+ return skb;
+}
+
static void bnx2x_frag_free(const struct bnx2x_fastpath *fp, void *data)
{
if (fp->rx_frag_size)
@@ -779,7 +791,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping),
fp->rx_buf_size, DMA_FROM_DEVICE);
if (likely(new_data))
- skb = build_skb(data, fp->rx_frag_size);
+ skb = bnx2x_build_skb(fp, data);
if (likely(skb)) {
#ifdef BNX2X_STOP_ON_ERROR
@@ -1046,7 +1058,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
dma_unmap_addr(rx_buf, mapping),
fp->rx_buf_size,
DMA_FROM_DEVICE);
- skb = build_skb(data, fp->rx_frag_size);
+ skb = bnx2x_build_skb(fp, data);
if (unlikely(!skb)) {
bnx2x_frag_free(fp, data);
bnx2x_fp_qstats(bp, fp)->
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] bnx2x: use the right build_skb() helper
2023-03-29 0:00 [PATCH net] bnx2x: use the right build_skb() helper Jakub Kicinski
@ 2023-03-29 12:35 ` Leon Romanovsky
2023-03-30 4:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-03-29 12:35 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, Thomas Voegtle, aelior, skalluru,
manishc, keescook
On Tue, Mar 28, 2023 at 05:00:13PM -0700, Jakub Kicinski wrote:
> build_skb() no longer accepts slab buffers. Since slab use is fairly
> uncommon we prefer the drivers to call a separate slab_build_skb()
> function appropriately.
>
> bnx2x uses the old semantics where size of 0 meant buffer from slab.
> It sets the fp->rx_frag_size to 0 for MTUs which don't fit in a page.
> It needs to call slab_build_skb().
>
> This fixes the WARN_ONCE() of incorrect API use seen with bnx2x.
>
> Reported-by: Thomas Voegtle <tv@lio96.de>
> Link: https://lore.kernel.org/all/b8f295e4-ba57-8bfb-7d9c-9d62a498a727@lio96.de/
> Fixes: ce098da1497c ("skbuff: Introduce slab_build_skb()")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: aelior@marvell.com
> CC: skalluru@marvell.com
> CC: manishc@marvell.com
> CC: keescook@chromium.org
> ---
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] bnx2x: use the right build_skb() helper
2023-03-29 0:00 [PATCH net] bnx2x: use the right build_skb() helper Jakub Kicinski
2023-03-29 12:35 ` Leon Romanovsky
@ 2023-03-30 4:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-30 4:40 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, tv, aelior, skalluru, manishc,
keescook
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 28 Mar 2023 17:00:13 -0700 you wrote:
> build_skb() no longer accepts slab buffers. Since slab use is fairly
> uncommon we prefer the drivers to call a separate slab_build_skb()
> function appropriately.
>
> bnx2x uses the old semantics where size of 0 meant buffer from slab.
> It sets the fp->rx_frag_size to 0 for MTUs which don't fit in a page.
> It needs to call slab_build_skb().
>
> [...]
Here is the summary with links:
- [net] bnx2x: use the right build_skb() helper
https://git.kernel.org/netdev/net/c/8c495270845d
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:[~2023-03-30 4:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 0:00 [PATCH net] bnx2x: use the right build_skb() helper Jakub Kicinski
2023-03-29 12:35 ` Leon Romanovsky
2023-03-30 4:40 ` 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).