mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
bnxt_en: use bnxt_xdp_buff for xdp context
This adds bnxt_xdp_buff which embeds the xdp_buff struct and stores pointers to hardware RX completion descriptors (rx_cmp and rx_cmp_ext) along with the completion type. Signed-off-by: Chris J Arges <carges@cloudflare.com> Link: https://patch.msgid.link/20260325201139.2501937-2-carges@cloudflare.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
d4383c7c78
commit
542d3ec450
|
|
@ -2112,13 +2112,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
u32 tmp_raw_cons = *raw_cons;
|
||||
u16 cons, prod, cp_cons = RING_CMP(tmp_raw_cons);
|
||||
struct skb_shared_info *sinfo;
|
||||
struct bnxt_xdp_buff bnxt_xdp;
|
||||
struct bnxt_sw_rx_bd *rx_buf;
|
||||
unsigned int len;
|
||||
u8 *data_ptr, agg_bufs, cmp_type;
|
||||
bool xdp_active = false;
|
||||
dma_addr_t dma_addr;
|
||||
struct sk_buff *skb;
|
||||
struct xdp_buff xdp;
|
||||
u32 flags, misc;
|
||||
u32 cmpl_ts;
|
||||
void *data;
|
||||
|
|
@ -2231,9 +2231,14 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
dma_addr = rx_buf->mapping;
|
||||
|
||||
if (bnxt_xdp_attached(bp, rxr)) {
|
||||
bnxt_xdp_buff_init(bp, rxr, cons, data_ptr, len, &xdp);
|
||||
bnxt_xdp.rxcmp = rxcmp;
|
||||
bnxt_xdp.rxcmp1 = rxcmp1;
|
||||
bnxt_xdp.cmp_type = cmp_type;
|
||||
|
||||
bnxt_xdp_buff_init(bp, rxr, cons, data_ptr, len, &bnxt_xdp.xdp);
|
||||
if (agg_bufs) {
|
||||
u32 frag_len = bnxt_rx_agg_netmems_xdp(bp, cpr, &xdp,
|
||||
u32 frag_len = bnxt_rx_agg_netmems_xdp(bp, cpr,
|
||||
&bnxt_xdp.xdp,
|
||||
cp_cons,
|
||||
agg_bufs,
|
||||
false);
|
||||
|
|
@ -2245,12 +2250,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
}
|
||||
|
||||
if (xdp_active) {
|
||||
if (bnxt_rx_xdp(bp, rxr, cons, &xdp, data, &data_ptr, &len, event)) {
|
||||
if (bnxt_rx_xdp(bp, rxr, cons, &bnxt_xdp.xdp, data, &data_ptr,
|
||||
&len, event)) {
|
||||
rc = 1;
|
||||
goto next_rx;
|
||||
}
|
||||
if (xdp_buff_has_frags(&xdp)) {
|
||||
sinfo = xdp_get_shared_info_from_buff(&xdp);
|
||||
if (xdp_buff_has_frags(&bnxt_xdp.xdp)) {
|
||||
sinfo = xdp_get_shared_info_from_buff(&bnxt_xdp.xdp);
|
||||
agg_bufs = sinfo->nr_frags;
|
||||
} else {
|
||||
agg_bufs = 0;
|
||||
|
|
@ -2261,7 +2267,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
if (!xdp_active)
|
||||
skb = bnxt_copy_skb(bnapi, data_ptr, len, dma_addr);
|
||||
else
|
||||
skb = bnxt_copy_xdp(bnapi, &xdp, len, dma_addr);
|
||||
skb = bnxt_copy_xdp(bnapi, &bnxt_xdp.xdp, len,
|
||||
dma_addr);
|
||||
bnxt_reuse_rx_data(rxr, cons, data);
|
||||
if (!skb) {
|
||||
if (agg_bufs) {
|
||||
|
|
@ -2269,7 +2276,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
bnxt_reuse_rx_agg_bufs(cpr, cp_cons, 0,
|
||||
agg_bufs, false);
|
||||
else
|
||||
bnxt_xdp_buff_frags_free(rxr, &xdp);
|
||||
bnxt_xdp_buff_frags_free(rxr,
|
||||
&bnxt_xdp.xdp);
|
||||
}
|
||||
goto oom_next_rx;
|
||||
}
|
||||
|
|
@ -2293,10 +2301,11 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
|
|||
if (!skb)
|
||||
goto oom_next_rx;
|
||||
} else {
|
||||
skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr, &xdp);
|
||||
skb = bnxt_xdp_build_skb(bp, skb, agg_bufs,
|
||||
rxr, &bnxt_xdp.xdp);
|
||||
if (!skb) {
|
||||
/* we should be able to free the old skb here */
|
||||
bnxt_xdp_buff_frags_free(rxr, &xdp);
|
||||
bnxt_xdp_buff_frags_free(rxr, &bnxt_xdp.xdp);
|
||||
goto oom_next_rx;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@
|
|||
|
||||
DECLARE_STATIC_KEY_FALSE(bnxt_xdp_locking_key);
|
||||
|
||||
struct bnxt_xdp_buff {
|
||||
struct xdp_buff xdp;
|
||||
struct rx_cmp *rxcmp;
|
||||
struct rx_cmp_ext *rxcmp1;
|
||||
u8 cmp_type;
|
||||
};
|
||||
|
||||
struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
|
||||
struct bnxt_tx_ring_info *txr,
|
||||
dma_addr_t mapping, u32 len,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user