* [PATCH net v2 0/3] Bug fixes from XDP patch series
@ 2025-05-06 11:05 Meghana Malladi
2025-05-06 11:05 ` [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev Meghana Malladi
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Meghana Malladi @ 2025-05-06 11:05 UTC (permalink / raw)
To: namcao, horms, m-malladi, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
This patch series fixes the bugs introduced while adding
xdp support in the icssg driver, and were reproduced while
running xdp-trafficgen to generate xdp traffic on icssg interfaces.
v1: https://lore.kernel.org/all/20250428120459.244525-1-m-malladi@ti.com/
Meghana Malladi (3):
net: ti: icssg-prueth: Set XDP feature flags for ndev
net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue
access
net: ti: icssg-prueth: Report BQL before sending XDP packets
drivers/net/ethernet/ti/icssg/icssg_common.c | 15 +++++++++++++--
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 16 ++++++++++------
2 files changed, 23 insertions(+), 8 deletions(-)
base-commit: 8c2e6b26ffe243be1e78f5a4bfb1a857d6e6f6d6
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev
2025-05-06 11:05 [PATCH net v2 0/3] Bug fixes from XDP patch series Meghana Malladi
@ 2025-05-06 11:05 ` Meghana Malladi
2025-05-06 18:20 ` Jacob Keller
2025-05-06 11:05 ` [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access Meghana Malladi
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Meghana Malladi @ 2025-05-06 11:05 UTC (permalink / raw)
To: namcao, horms, m-malladi, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
xdp_features demonstrates what all XDP capabilities are supported
on a given network device. The driver needs to set these xdp_features
flag to let the network stack know what XDP features a given driver
is supporting. These flags need to be set for a given ndev irrespective
of any XDP program being loaded or not.
Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 443f90fa6557..ee35fecf61e7 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -1109,11 +1109,6 @@ static int emac_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frame
static int emac_xdp_setup(struct prueth_emac *emac, struct netdev_bpf *bpf)
{
struct bpf_prog *prog = bpf->prog;
- xdp_features_t val;
-
- val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
- NETDEV_XDP_ACT_NDO_XMIT;
- xdp_set_features_flag(emac->ndev, val);
if (!emac->xdpi.prog && !prog)
return 0;
@@ -1291,6 +1286,10 @@ static int prueth_netdev_init(struct prueth *prueth,
ndev->hw_features = NETIF_F_SG;
ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
ndev->hw_features |= NETIF_PRUETH_HSR_OFFLOAD_FEATURES;
+ xdp_set_features_flag(ndev,
+ NETDEV_XDP_ACT_BASIC |
+ NETDEV_XDP_ACT_REDIRECT |
+ NETDEV_XDP_ACT_NDO_XMIT);
netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll);
hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC,
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access
2025-05-06 11:05 [PATCH net v2 0/3] Bug fixes from XDP patch series Meghana Malladi
2025-05-06 11:05 ` [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev Meghana Malladi
@ 2025-05-06 11:05 ` Meghana Malladi
2025-05-06 18:21 ` Jacob Keller
2025-05-06 11:05 ` [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets Meghana Malladi
2025-05-08 1:40 ` [PATCH net v2 0/3] Bug fixes from XDP patch series patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Meghana Malladi @ 2025-05-06 11:05 UTC (permalink / raw)
To: namcao, horms, m-malladi, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
Add __netif_tx_lock() to ensure that only one packet is being
transmitted at a time to avoid race conditions in the netif_txq
struct and prevent packet data corruption. Failing to do so causes
kernel panic with the following error:
[ 2184.746764] ------------[ cut here ]------------
[ 2184.751412] kernel BUG at lib/dynamic_queue_limits.c:99!
[ 2184.756728] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
logs: https://gist.github.com/MeghanaMalladiTI/9c7aa5fc3b7fb03f87c74aad487956e9
The lock is acquired before calling emac_xmit_xdp_frame() and released after the
call returns. This ensures that the TX queue is protected from concurrent access
during the transmission of XDP frames.
Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---
Changes from v1 (v2-v1):
- Move netif_tx_lock/unlock outside of the loop, reported by Jesper Dangaard Brouer <hawk@kernel.org>
drivers/net/ethernet/ti/icssg/icssg_common.c | 7 ++++++-
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 7 ++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c
index 79f2d86acf21..36d5cb25c017 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_common.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_common.c
@@ -650,6 +650,8 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
struct page *page, u32 *len)
{
struct net_device *ndev = emac->ndev;
+ struct netdev_queue *netif_txq;
+ int cpu = smp_processor_id();
struct bpf_prog *xdp_prog;
struct xdp_frame *xdpf;
u32 pkt_len = *len;
@@ -669,8 +671,11 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
goto drop;
}
- q_idx = smp_processor_id() % emac->tx_ch_num;
+ q_idx = cpu % emac->tx_ch_num;
+ netif_txq = netdev_get_tx_queue(ndev, q_idx);
+ __netif_tx_lock(netif_txq, cpu);
result = emac_xmit_xdp_frame(emac, xdpf, page, q_idx);
+ __netif_tx_unlock(netif_txq);
if (result == ICSSG_XDP_CONSUMED) {
ndev->stats.tx_dropped++;
goto drop;
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index ee35fecf61e7..86fc1278127c 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -1075,17 +1075,21 @@ static int emac_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frame
{
struct prueth_emac *emac = netdev_priv(dev);
struct net_device *ndev = emac->ndev;
+ struct netdev_queue *netif_txq;
+ int cpu = smp_processor_id();
struct xdp_frame *xdpf;
unsigned int q_idx;
int nxmit = 0;
u32 err;
int i;
- q_idx = smp_processor_id() % emac->tx_ch_num;
+ q_idx = cpu % emac->tx_ch_num;
+ netif_txq = netdev_get_tx_queue(ndev, q_idx);
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
return -EINVAL;
+ __netif_tx_lock(netif_txq, cpu);
for (i = 0; i < n; i++) {
xdpf = frames[i];
err = emac_xmit_xdp_frame(emac, xdpf, NULL, q_idx);
@@ -1095,6 +1099,7 @@ static int emac_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frame
}
nxmit++;
}
+ __netif_tx_unlock(netif_txq);
return nxmit;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets
2025-05-06 11:05 [PATCH net v2 0/3] Bug fixes from XDP patch series Meghana Malladi
2025-05-06 11:05 ` [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev Meghana Malladi
2025-05-06 11:05 ` [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access Meghana Malladi
@ 2025-05-06 11:05 ` Meghana Malladi
2025-05-06 18:22 ` Jacob Keller
2025-05-08 1:40 ` [PATCH net v2 0/3] Bug fixes from XDP patch series patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Meghana Malladi @ 2025-05-06 11:05 UTC (permalink / raw)
To: namcao, horms, m-malladi, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
When sending out any kind of traffic, it is essential that the driver
keeps reporting BQL of the number of bytes that have been sent so that
BQL can track the amount of data in the queue and prevents it from
overflowing. If BQL is not reported, the driver may continue sending
packets even when the queue is full, leading to packet loss, congestion
and decreased network performance. Currently this is missing in
emac_xmit_xdp_frame() and this patch fixes it.
Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---
Changes from v1 (v2-v1):
- reordered the patches in the series as suggested by Jakub Kicinski <kuba@kernel.org>
- Dropped patch 3/4 from v1 as suggested by Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ti/icssg/icssg_common.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c
index 36d5cb25c017..5b8fdb882172 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_common.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_common.c
@@ -187,7 +187,6 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
xdp_return_frame(xdpf);
break;
default:
- netdev_err(ndev, "tx_complete: invalid swdata type %d\n", swdata->type);
prueth_xmit_free(tx_chn, desc_tx);
ndev->stats.tx_dropped++;
continue;
@@ -567,6 +566,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
{
struct cppi5_host_desc_t *first_desc;
struct net_device *ndev = emac->ndev;
+ struct netdev_queue *netif_txq;
struct prueth_tx_chn *tx_chn;
dma_addr_t desc_dma, buf_dma;
struct prueth_swdata *swdata;
@@ -620,12 +620,17 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
swdata->data.xdpf = xdpf;
}
+ /* Report BQL before sending the packet */
+ netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
+ netdev_tx_sent_queue(netif_txq, xdpf->len);
+
cppi5_hdesc_set_pktlen(first_desc, xdpf->len);
desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc);
ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma);
if (ret) {
netdev_err(ndev, "xdp tx: push failed: %d\n", ret);
+ netdev_tx_completed_queue(netif_txq, 1, xdpf->len);
goto drop_free_descs;
}
@@ -984,6 +989,7 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma);
if (ret) {
netdev_err(ndev, "tx: push failed: %d\n", ret);
+ netdev_tx_completed_queue(netif_txq, 1, pkt_len);
goto drop_free_descs;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev
2025-05-06 11:05 ` [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev Meghana Malladi
@ 2025-05-06 18:20 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-05-06 18:20 UTC (permalink / raw)
To: Meghana Malladi, namcao, horms, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
On 5/6/2025 4:05 AM, Meghana Malladi wrote:
> xdp_features demonstrates what all XDP capabilities are supported
> on a given network device. The driver needs to set these xdp_features
> flag to let the network stack know what XDP features a given driver
> is supporting. These flags need to be set for a given ndev irrespective
> of any XDP program being loaded or not.
>
> Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
> Signed-off-by: Meghana Malladi <m-malladi@ti.com>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access
2025-05-06 11:05 ` [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access Meghana Malladi
@ 2025-05-06 18:21 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-05-06 18:21 UTC (permalink / raw)
To: Meghana Malladi, namcao, horms, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
On 5/6/2025 4:05 AM, Meghana Malladi wrote:
> Add __netif_tx_lock() to ensure that only one packet is being
> transmitted at a time to avoid race conditions in the netif_txq
> struct and prevent packet data corruption. Failing to do so causes
> kernel panic with the following error:
>
> [ 2184.746764] ------------[ cut here ]------------
> [ 2184.751412] kernel BUG at lib/dynamic_queue_limits.c:99!
> [ 2184.756728] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
>
> logs: https://gist.github.com/MeghanaMalladiTI/9c7aa5fc3b7fb03f87c74aad487956e9
>
> The lock is acquired before calling emac_xmit_xdp_frame() and released after the
> call returns. This ensures that the TX queue is protected from concurrent access
> during the transmission of XDP frames.
>
> Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
> Signed-off-by: Meghana Malladi <m-malladi@ti.com>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets
2025-05-06 11:05 ` [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets Meghana Malladi
@ 2025-05-06 18:22 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-05-06 18:22 UTC (permalink / raw)
To: Meghana Malladi, namcao, horms, john.fastabend, hawk, daniel, ast,
pabeni, kuba, edumazet, davem, andrew+netdev
Cc: bpf, linux-kernel, netdev, linux-arm-kernel, srk,
Vignesh Raghavendra, Roger Quadros, danishanwar
On 5/6/2025 4:05 AM, Meghana Malladi wrote:
> When sending out any kind of traffic, it is essential that the driver
> keeps reporting BQL of the number of bytes that have been sent so that
> BQL can track the amount of data in the queue and prevents it from
> overflowing. If BQL is not reported, the driver may continue sending
> packets even when the queue is full, leading to packet loss, congestion
> and decreased network performance. Currently this is missing in
> emac_xmit_xdp_frame() and this patch fixes it.
>
> Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")
> Signed-off-by: Meghana Malladi <m-malladi@ti.com>
> ---
>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 0/3] Bug fixes from XDP patch series
2025-05-06 11:05 [PATCH net v2 0/3] Bug fixes from XDP patch series Meghana Malladi
` (2 preceding siblings ...)
2025-05-06 11:05 ` [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets Meghana Malladi
@ 2025-05-08 1:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-08 1:40 UTC (permalink / raw)
To: Meghana Malladi
Cc: namcao, horms, john.fastabend, hawk, daniel, ast, pabeni, kuba,
edumazet, davem, andrew+netdev, bpf, linux-kernel, netdev,
linux-arm-kernel, srk, vigneshr, rogerq, danishanwar
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 6 May 2025 16:35:43 +0530 you wrote:
> This patch series fixes the bugs introduced while adding
> xdp support in the icssg driver, and were reproduced while
> running xdp-trafficgen to generate xdp traffic on icssg interfaces.
>
> v1: https://lore.kernel.org/all/20250428120459.244525-1-m-malladi@ti.com/
>
> Meghana Malladi (3):
> net: ti: icssg-prueth: Set XDP feature flags for ndev
> net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue
> access
> net: ti: icssg-prueth: Report BQL before sending XDP packets
>
> [...]
Here is the summary with links:
- [net,v2,1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev
https://git.kernel.org/netdev/net/c/e5641daa0ea1
- [net,v2,2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access
https://git.kernel.org/netdev/net/c/8b3fae3e2376
- [net,v2,3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets
https://git.kernel.org/netdev/net/c/1884fc85ae6e
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] 8+ messages in thread
end of thread, other threads:[~2025-05-08 1:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06 11:05 [PATCH net v2 0/3] Bug fixes from XDP patch series Meghana Malladi
2025-05-06 11:05 ` [PATCH net v2 1/3] net: ti: icssg-prueth: Set XDP feature flags for ndev Meghana Malladi
2025-05-06 18:20 ` Jacob Keller
2025-05-06 11:05 ` [PATCH net v2 2/3] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access Meghana Malladi
2025-05-06 18:21 ` Jacob Keller
2025-05-06 11:05 ` [PATCH net v2 3/3] net: ti: icssg-prueth: Report BQL before sending XDP packets Meghana Malladi
2025-05-06 18:22 ` Jacob Keller
2025-05-08 1:40 ` [PATCH net v2 0/3] Bug fixes from XDP patch series 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).