Skip to content

Commit 49dcffe

Browse files
author
Paolo Abeni
committed
Merge branch 'add-missing-xdp_do_flush-invocations'
Sebastian Andrzej Siewior says: ==================== Add missing xdp_do_flush() invocations. I've been looking at the drivers/ XDP users and noticed that some XDP_REDIRECT user don't invoke xdp_do_flush() at the end. ==================== Link: https://lore.kernel.org/r/20230918153611.165722-1-bigeasy@linutronix.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 4a0f07d + 70b2b68 commit 49dcffe

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,9 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
18331833
return work_done;
18341834

18351835
error:
1836+
if (xdp_flags & ENA_XDP_REDIRECT)
1837+
xdp_do_flush();
1838+
18361839
adapter = netdev_priv(rx_ring->netdev);
18371840

18381841
if (rc == -ENOSPC) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,7 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget)
26142614
struct rx_cmp_ext *rxcmp1;
26152615
u32 cp_cons, tmp_raw_cons;
26162616
u32 raw_cons = cpr->cp_raw_cons;
2617+
bool flush_xdp = false;
26172618
u32 rx_pkts = 0;
26182619
u8 event = 0;
26192620

@@ -2648,6 +2649,8 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget)
26482649
rx_pkts++;
26492650
else if (rc == -EBUSY) /* partial completion */
26502651
break;
2652+
if (event & BNXT_REDIRECT_EVENT)
2653+
flush_xdp = true;
26512654
} else if (unlikely(TX_CMP_TYPE(txcmp) ==
26522655
CMPL_BASE_TYPE_HWRM_DONE)) {
26532656
bnxt_hwrm_handler(bp, txcmp);
@@ -2667,6 +2670,8 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget)
26672670

26682671
if (event & BNXT_AGG_EVENT)
26692672
bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
2673+
if (flush_xdp)
2674+
xdp_do_flush();
26702675

26712676
if (!bnxt_has_work(bp, cpr) && rx_pkts < budget) {
26722677
napi_complete_done(napi, rx_pkts);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
3030
struct bpf_prog *prog,
3131
struct nix_cqe_rx_s *cqe,
32-
struct otx2_cq_queue *cq);
32+
struct otx2_cq_queue *cq,
33+
bool *need_xdp_flush);
3334

3435
static int otx2_nix_cq_op_status(struct otx2_nic *pfvf,
3536
struct otx2_cq_queue *cq)
@@ -337,7 +338,7 @@ static bool otx2_check_rcv_errors(struct otx2_nic *pfvf,
337338
static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf,
338339
struct napi_struct *napi,
339340
struct otx2_cq_queue *cq,
340-
struct nix_cqe_rx_s *cqe)
341+
struct nix_cqe_rx_s *cqe, bool *need_xdp_flush)
341342
{
342343
struct nix_rx_parse_s *parse = &cqe->parse;
343344
struct nix_rx_sg_s *sg = &cqe->sg;
@@ -353,7 +354,7 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf,
353354
}
354355

355356
if (pfvf->xdp_prog)
356-
if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq))
357+
if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq, need_xdp_flush))
357358
return;
358359

359360
skb = napi_get_frags(napi);
@@ -388,6 +389,7 @@ static int otx2_rx_napi_handler(struct otx2_nic *pfvf,
388389
struct napi_struct *napi,
389390
struct otx2_cq_queue *cq, int budget)
390391
{
392+
bool need_xdp_flush = false;
391393
struct nix_cqe_rx_s *cqe;
392394
int processed_cqe = 0;
393395

@@ -409,13 +411,15 @@ static int otx2_rx_napi_handler(struct otx2_nic *pfvf,
409411
cq->cq_head++;
410412
cq->cq_head &= (cq->cqe_cnt - 1);
411413

412-
otx2_rcv_pkt_handler(pfvf, napi, cq, cqe);
414+
otx2_rcv_pkt_handler(pfvf, napi, cq, cqe, &need_xdp_flush);
413415

414416
cqe->hdr.cqe_type = NIX_XQE_TYPE_INVALID;
415417
cqe->sg.seg_addr = 0x00;
416418
processed_cqe++;
417419
cq->pend_cqe--;
418420
}
421+
if (need_xdp_flush)
422+
xdp_do_flush();
419423

420424
/* Free CQEs to HW */
421425
otx2_write64(pfvf, NIX_LF_CQ_OP_DOOR,
@@ -1354,7 +1358,8 @@ bool otx2_xdp_sq_append_pkt(struct otx2_nic *pfvf, u64 iova, int len, u16 qidx)
13541358
static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
13551359
struct bpf_prog *prog,
13561360
struct nix_cqe_rx_s *cqe,
1357-
struct otx2_cq_queue *cq)
1361+
struct otx2_cq_queue *cq,
1362+
bool *need_xdp_flush)
13581363
{
13591364
unsigned char *hard_start, *data;
13601365
int qidx = cq->cq_idx;
@@ -1391,8 +1396,10 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
13911396

13921397
otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize,
13931398
DMA_FROM_DEVICE);
1394-
if (!err)
1399+
if (!err) {
1400+
*need_xdp_flush = true;
13951401
return true;
1402+
}
13961403
put_page(page);
13971404
break;
13981405
default:

0 commit comments

Comments
 (0)