Skip to content

Commit 4c6c123

Browse files
CCX-Stingraydavem330
authored andcommitted
bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp
This patch adds a new function that will read pages from the aggregation ring and create an xdp_buff with frags based on the entries in the aggregation ring. Signed-off-by: Andy Gospodarek <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 23e4c04 commit 4c6c123

File tree

1 file changed

+31
-0
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+31
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,27 @@ static struct sk_buff *bnxt_rx_agg_pages_skb(struct bnxt *bp,
11311131
return skb;
11321132
}
11331133

1134+
static u32 bnxt_rx_agg_pages_xdp(struct bnxt *bp,
1135+
struct bnxt_cp_ring_info *cpr,
1136+
struct xdp_buff *xdp, u16 idx,
1137+
u32 agg_bufs, bool tpa)
1138+
{
1139+
struct skb_shared_info *shinfo = xdp_get_shared_info_from_buff(xdp);
1140+
u32 total_frag_len = 0;
1141+
1142+
if (!xdp_buff_has_frags(xdp))
1143+
shinfo->nr_frags = 0;
1144+
1145+
total_frag_len = __bnxt_rx_agg_pages(bp, cpr, shinfo, idx, agg_bufs, tpa);
1146+
1147+
if (total_frag_len) {
1148+
xdp_buff_set_frags_flag(xdp);
1149+
shinfo->nr_frags = agg_bufs;
1150+
shinfo->xdp_frags_size = total_frag_len;
1151+
}
1152+
return total_frag_len;
1153+
}
1154+
11341155
static int bnxt_agg_bufs_valid(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
11351156
u8 agg_bufs, u32 *raw_cons)
11361157
{
@@ -1859,6 +1880,16 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
18591880

18601881
if (bnxt_xdp_attached(bp, rxr)) {
18611882
bnxt_xdp_buff_init(bp, rxr, cons, &data_ptr, &len, &xdp);
1883+
if (agg_bufs) {
1884+
u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp,
1885+
cp_cons, agg_bufs,
1886+
false);
1887+
if (!frag_len) {
1888+
cpr->sw_stats.rx.rx_oom_discards += 1;
1889+
rc = -ENOMEM;
1890+
goto next_rx;
1891+
}
1892+
}
18621893
xdp_active = true;
18631894
}
18641895

0 commit comments

Comments
 (0)