Commit 49dcffef authored by Paolo Abeni's avatar Paolo Abeni
Browse files

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: default avatarPaolo Abeni <pabeni@redhat.com>
parents 4a0f07d7 70b2b689
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1833,6 +1833,9 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
	return work_done;

error:
	if (xdp_flags & ENA_XDP_REDIRECT)
		xdp_do_flush();

	adapter = netdev_priv(rx_ring->netdev);

	if (rc == -ENOSPC) {
+5 −0
Original line number Diff line number Diff line
@@ -2614,6 +2614,7 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget)
	struct rx_cmp_ext *rxcmp1;
	u32 cp_cons, tmp_raw_cons;
	u32 raw_cons = cpr->cp_raw_cons;
	bool flush_xdp = false;
	u32 rx_pkts = 0;
	u8 event = 0;

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

	if (event & BNXT_AGG_EVENT)
		bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
	if (flush_xdp)
		xdp_do_flush();

	if (!bnxt_has_work(bp, cpr) && rx_pkts < budget) {
		napi_complete_done(napi, rx_pkts);
+13 −6
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@
static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
				     struct bpf_prog *prog,
				     struct nix_cqe_rx_s *cqe,
				     struct otx2_cq_queue *cq);
				     struct otx2_cq_queue *cq,
				     bool *need_xdp_flush);

static int otx2_nix_cq_op_status(struct otx2_nic *pfvf,
				 struct otx2_cq_queue *cq)
@@ -337,7 +338,7 @@ static bool otx2_check_rcv_errors(struct otx2_nic *pfvf,
static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf,
				 struct napi_struct *napi,
				 struct otx2_cq_queue *cq,
				 struct nix_cqe_rx_s *cqe)
				 struct nix_cqe_rx_s *cqe, bool *need_xdp_flush)
{
	struct nix_rx_parse_s *parse = &cqe->parse;
	struct nix_rx_sg_s *sg = &cqe->sg;
@@ -353,7 +354,7 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf,
	}

	if (pfvf->xdp_prog)
		if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq))
		if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq, need_xdp_flush))
			return;

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

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

		otx2_rcv_pkt_handler(pfvf, napi, cq, cqe);
		otx2_rcv_pkt_handler(pfvf, napi, cq, cqe, &need_xdp_flush);

		cqe->hdr.cqe_type = NIX_XQE_TYPE_INVALID;
		cqe->sg.seg_addr = 0x00;
		processed_cqe++;
		cq->pend_cqe--;
	}
	if (need_xdp_flush)
		xdp_do_flush();

	/* Free CQEs to HW */
	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)
static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
				     struct bpf_prog *prog,
				     struct nix_cqe_rx_s *cqe,
				     struct otx2_cq_queue *cq)
				     struct otx2_cq_queue *cq,
				     bool *need_xdp_flush)
{
	unsigned char *hard_start, *data;
	int qidx = cq->cq_idx;
@@ -1391,8 +1396,10 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,

		otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize,
				    DMA_FROM_DEVICE);
		if (!err)
		if (!err) {
			*need_xdp_flush = true;
			return true;
		}
		put_page(page);
		break;
	default: