Skip to content

Commit ea78f20

Browse files
committed
Merge branch 'bug-fixes-from-xdp-patch-series'
Meghana Malladi says: ==================== Bug fixes from XDP patch series 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/ ==================== Link: https://patch.msgid.link/20250506110546.4065715-1-m-malladi@ti.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents f5c79ff + 1884fc8 commit ea78f20

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

drivers/net/ethernet/ti/icssg/icssg_common.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
187187
xdp_return_frame(xdpf);
188188
break;
189189
default:
190-
netdev_err(ndev, "tx_complete: invalid swdata type %d\n", swdata->type);
191190
prueth_xmit_free(tx_chn, desc_tx);
192191
ndev->stats.tx_dropped++;
193192
continue;
@@ -567,6 +566,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
567566
{
568567
struct cppi5_host_desc_t *first_desc;
569568
struct net_device *ndev = emac->ndev;
569+
struct netdev_queue *netif_txq;
570570
struct prueth_tx_chn *tx_chn;
571571
dma_addr_t desc_dma, buf_dma;
572572
struct prueth_swdata *swdata;
@@ -620,12 +620,17 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
620620
swdata->data.xdpf = xdpf;
621621
}
622622

623+
/* Report BQL before sending the packet */
624+
netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
625+
netdev_tx_sent_queue(netif_txq, xdpf->len);
626+
623627
cppi5_hdesc_set_pktlen(first_desc, xdpf->len);
624628
desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc);
625629

626630
ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma);
627631
if (ret) {
628632
netdev_err(ndev, "xdp tx: push failed: %d\n", ret);
633+
netdev_tx_completed_queue(netif_txq, 1, xdpf->len);
629634
goto drop_free_descs;
630635
}
631636

@@ -650,6 +655,8 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
650655
struct page *page, u32 *len)
651656
{
652657
struct net_device *ndev = emac->ndev;
658+
struct netdev_queue *netif_txq;
659+
int cpu = smp_processor_id();
653660
struct bpf_prog *xdp_prog;
654661
struct xdp_frame *xdpf;
655662
u32 pkt_len = *len;
@@ -669,8 +676,11 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
669676
goto drop;
670677
}
671678

672-
q_idx = smp_processor_id() % emac->tx_ch_num;
679+
q_idx = cpu % emac->tx_ch_num;
680+
netif_txq = netdev_get_tx_queue(ndev, q_idx);
681+
__netif_tx_lock(netif_txq, cpu);
673682
result = emac_xmit_xdp_frame(emac, xdpf, page, q_idx);
683+
__netif_tx_unlock(netif_txq);
674684
if (result == ICSSG_XDP_CONSUMED) {
675685
ndev->stats.tx_dropped++;
676686
goto drop;
@@ -979,6 +989,7 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
979989
ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma);
980990
if (ret) {
981991
netdev_err(ndev, "tx: push failed: %d\n", ret);
992+
netdev_tx_completed_queue(netif_txq, 1, pkt_len);
982993
goto drop_free_descs;
983994
}
984995

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,17 +1075,21 @@ static int emac_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frame
10751075
{
10761076
struct prueth_emac *emac = netdev_priv(dev);
10771077
struct net_device *ndev = emac->ndev;
1078+
struct netdev_queue *netif_txq;
1079+
int cpu = smp_processor_id();
10781080
struct xdp_frame *xdpf;
10791081
unsigned int q_idx;
10801082
int nxmit = 0;
10811083
u32 err;
10821084
int i;
10831085

1084-
q_idx = smp_processor_id() % emac->tx_ch_num;
1086+
q_idx = cpu % emac->tx_ch_num;
1087+
netif_txq = netdev_get_tx_queue(ndev, q_idx);
10851088

10861089
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
10871090
return -EINVAL;
10881091

1092+
__netif_tx_lock(netif_txq, cpu);
10891093
for (i = 0; i < n; i++) {
10901094
xdpf = frames[i];
10911095
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
10951099
}
10961100
nxmit++;
10971101
}
1102+
__netif_tx_unlock(netif_txq);
10981103

10991104
return nxmit;
11001105
}
@@ -1109,11 +1114,6 @@ static int emac_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frame
11091114
static int emac_xdp_setup(struct prueth_emac *emac, struct netdev_bpf *bpf)
11101115
{
11111116
struct bpf_prog *prog = bpf->prog;
1112-
xdp_features_t val;
1113-
1114-
val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
1115-
NETDEV_XDP_ACT_NDO_XMIT;
1116-
xdp_set_features_flag(emac->ndev, val);
11171117

11181118
if (!emac->xdpi.prog && !prog)
11191119
return 0;
@@ -1291,6 +1291,10 @@ static int prueth_netdev_init(struct prueth *prueth,
12911291
ndev->hw_features = NETIF_F_SG;
12921292
ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
12931293
ndev->hw_features |= NETIF_PRUETH_HSR_OFFLOAD_FEATURES;
1294+
xdp_set_features_flag(ndev,
1295+
NETDEV_XDP_ACT_BASIC |
1296+
NETDEV_XDP_ACT_REDIRECT |
1297+
NETDEV_XDP_ACT_NDO_XMIT);
12941298

12951299
netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll);
12961300
hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC,

0 commit comments

Comments
 (0)