mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 07:29:12 -04:00
net: ti: cpsw: Add metadata support for xdp mode
Set metadata size building the skb from xdp_buff in cpsw/cpsw_new drivers. ti cpsw and cpsw_new drivers set xdp headroom at least to CPSW_HEADROOM_NA: CPSW_HEADROOM_NA max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + NET_IP_ALIGN so the headroom is large enough to contain xdp_frame and xdp metadata. Please note this patch is just compiled tested. Reviewed-by: Michal Kubiak <michal.kubiak@intel.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20250318-mvneta-xdp-meta-v2-7-b6075778f61f@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
c313d35f60
commit
b3a54be70c
@@ -351,6 +351,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
int ret = 0, port, ch = xmeta->ch;
|
||||
int headroom = CPSW_HEADROOM_NA;
|
||||
struct net_device *ndev = xmeta->ndev;
|
||||
u32 metasize = 0;
|
||||
struct cpsw_priv *priv;
|
||||
struct page_pool *pool;
|
||||
struct sk_buff *skb;
|
||||
@@ -400,7 +401,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
size -= CPSW_RX_VLAN_ENCAP_HDR_SIZE;
|
||||
}
|
||||
|
||||
xdp_prepare_buff(&xdp, pa, headroom, size, false);
|
||||
xdp_prepare_buff(&xdp, pa, headroom, size, true);
|
||||
|
||||
port = priv->emac_port + cpsw->data.dual_emac;
|
||||
ret = cpsw_run_xdp(priv, ch, &xdp, page, port, &len);
|
||||
@@ -408,6 +409,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
goto requeue;
|
||||
|
||||
headroom = xdp.data - xdp.data_hard_start;
|
||||
metasize = xdp.data - xdp.data_meta;
|
||||
|
||||
/* XDP prog can modify vlan tag, so can't use encap header */
|
||||
status &= ~CPDMA_RX_VLAN_ENCAP;
|
||||
@@ -423,6 +425,8 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
|
||||
skb_reserve(skb, headroom);
|
||||
skb_put(skb, len);
|
||||
if (metasize)
|
||||
skb_metadata_set(skb, metasize);
|
||||
skb->dev = ndev;
|
||||
if (status & CPDMA_RX_VLAN_ENCAP)
|
||||
cpsw_rx_vlan_encap(skb);
|
||||
|
||||
@@ -293,6 +293,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
struct page_pool *pool;
|
||||
struct sk_buff *skb;
|
||||
struct xdp_buff xdp;
|
||||
u32 metasize = 0;
|
||||
int ret = 0;
|
||||
dma_addr_t dma;
|
||||
|
||||
@@ -345,13 +346,14 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
size -= CPSW_RX_VLAN_ENCAP_HDR_SIZE;
|
||||
}
|
||||
|
||||
xdp_prepare_buff(&xdp, pa, headroom, size, false);
|
||||
xdp_prepare_buff(&xdp, pa, headroom, size, true);
|
||||
|
||||
ret = cpsw_run_xdp(priv, ch, &xdp, page, priv->emac_port, &len);
|
||||
if (ret != CPSW_XDP_PASS)
|
||||
goto requeue;
|
||||
|
||||
headroom = xdp.data - xdp.data_hard_start;
|
||||
metasize = xdp.data - xdp.data_meta;
|
||||
|
||||
/* XDP prog can modify vlan tag, so can't use encap header */
|
||||
status &= ~CPDMA_RX_VLAN_ENCAP;
|
||||
@@ -368,6 +370,8 @@ static void cpsw_rx_handler(void *token, int len, int status)
|
||||
skb->offload_fwd_mark = priv->offload_fwd_mark;
|
||||
skb_reserve(skb, headroom);
|
||||
skb_put(skb, len);
|
||||
if (metasize)
|
||||
skb_metadata_set(skb, metasize);
|
||||
skb->dev = ndev;
|
||||
if (status & CPDMA_RX_VLAN_ENCAP)
|
||||
cpsw_rx_vlan_encap(skb);
|
||||
|
||||
Reference in New Issue
Block a user