Skip to content

Commit d942fe1

Browse files
MeghanaMalladiTIkuba-moo
authored andcommitted
net: ti: icssg-prueth: Fix skb handling for XDP_PASS
emac_rx_packet() is a common function for handling traffic for both xdp and non-xdp use cases. Use common logic for handling skb with or without xdp to prevent any incorrect packet processing. This patch fixes ping working with XDP_PASS for icssg driver. Fixes: 62aa324 ("net: ti: icssg-prueth: Add XDP support") Signed-off-by: Meghana Malladi <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e6d7626 commit d942fe1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,9 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state)
706706
struct page_pool *pool;
707707
struct sk_buff *skb;
708708
struct xdp_buff xdp;
709+
int headroom, ret;
709710
u32 *psdata;
710711
void *pa;
711-
int ret;
712712

713713
*xdp_state = 0;
714714
pool = rx_chn->pg_pool;
@@ -757,22 +757,23 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state)
757757
xdp_prepare_buff(&xdp, pa, PRUETH_HEADROOM, pkt_len, false);
758758

759759
*xdp_state = emac_run_xdp(emac, &xdp, page, &pkt_len);
760-
if (*xdp_state == ICSSG_XDP_PASS)
761-
skb = xdp_build_skb_from_buff(&xdp);
762-
else
760+
if (*xdp_state != ICSSG_XDP_PASS)
763761
goto requeue;
762+
headroom = xdp.data - xdp.data_hard_start;
763+
pkt_len = xdp.data_end - xdp.data;
764764
} else {
765-
/* prepare skb and send to n/w stack */
766-
skb = napi_build_skb(pa, PAGE_SIZE);
765+
headroom = PRUETH_HEADROOM;
767766
}
768767

768+
/* prepare skb and send to n/w stack */
769+
skb = napi_build_skb(pa, PAGE_SIZE);
769770
if (!skb) {
770771
ndev->stats.rx_dropped++;
771772
page_pool_recycle_direct(pool, page);
772773
goto requeue;
773774
}
774775

775-
skb_reserve(skb, PRUETH_HEADROOM);
776+
skb_reserve(skb, headroom);
776777
skb_put(skb, pkt_len);
777778
skb->dev = ndev;
778779

0 commit comments

Comments
 (0)