Skip to content

Commit b5cdb9b

Browse files
Hariprasad Kelamkuba-moo
authored andcommitted
octeontx2-pf: AF_XDP: code clean up
The current API, otx2_xdp_sq_append_pkt, verifies the number of available descriptors before sending packets to the hardware. However, for AF_XDP, this check is unnecessary because the batch value is already determined based on the free descriptors. This patch introduces a new API, "otx2_xsk_sq_append_pkt" to address this. Remove the logic for releasing the TX buffers, as it is implicitly handled by xsk_tx_peek_release_desc_batch Signed-off-by: Hariprasad Kelam <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3fec58f commit b5cdb9b

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,8 @@ int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);
11071107
int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf);
11081108
bool otx2_xdp_sq_append_pkt(struct otx2_nic *pfvf, struct xdp_frame *xdpf,
11091109
u64 iova, int len, u16 qidx, u16 flags);
1110+
void otx2_xdp_sqe_add_sg(struct otx2_snd_queue *sq, struct xdp_frame *xdpf,
1111+
u64 dma_addr, int len, int *offset, u16 flags);
11101112
u16 otx2_get_max_mtu(struct otx2_nic *pfvf);
11111113
int otx2_handle_ntuple_tc_features(struct net_device *netdev,
11121114
netdev_features_t features);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,8 @@ void otx2_free_pending_sqe(struct otx2_nic *pfvf)
14101410
}
14111411
}
14121412

1413-
static void otx2_xdp_sqe_add_sg(struct otx2_snd_queue *sq,
1414-
struct xdp_frame *xdpf,
1415-
u64 dma_addr, int len, int *offset, u16 flags)
1413+
void otx2_xdp_sqe_add_sg(struct otx2_snd_queue *sq, struct xdp_frame *xdpf,
1414+
u64 dma_addr, int len, int *offset, u16 flags)
14161415
{
14171416
struct nix_sqe_sg_s *sg = NULL;
14181417
u64 *iova = NULL;

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <net/xdp.h>
1212

1313
#include "otx2_common.h"
14+
#include "otx2_struct.h"
1415
#include "otx2_xsk.h"
1516

1617
int otx2_xsk_pool_alloc_buf(struct otx2_nic *pfvf, struct otx2_pool *pool,
@@ -196,11 +197,39 @@ void otx2_attach_xsk_buff(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, int
196197
sq->xsk_pool = xsk_get_pool_from_qid(pfvf->netdev, qidx);
197198
}
198199

200+
static void otx2_xsk_sq_append_pkt(struct otx2_nic *pfvf, u64 iova, int len,
201+
u16 qidx)
202+
{
203+
struct nix_sqe_hdr_s *sqe_hdr;
204+
struct otx2_snd_queue *sq;
205+
int offset;
206+
207+
sq = &pfvf->qset.sq[qidx];
208+
memset(sq->sqe_base + 8, 0, sq->sqe_size - 8);
209+
210+
sqe_hdr = (struct nix_sqe_hdr_s *)(sq->sqe_base);
211+
212+
if (!sqe_hdr->total) {
213+
sqe_hdr->aura = sq->aura_id;
214+
sqe_hdr->df = 1;
215+
sqe_hdr->sq = qidx;
216+
sqe_hdr->pnc = 1;
217+
}
218+
sqe_hdr->total = len;
219+
sqe_hdr->sqe_id = sq->head;
220+
221+
offset = sizeof(*sqe_hdr);
222+
223+
otx2_xdp_sqe_add_sg(sq, NULL, iova, len, &offset, OTX2_AF_XDP_FRAME);
224+
sqe_hdr->sizem1 = (offset / 16) - 1;
225+
pfvf->hw_ops->sqe_flush(pfvf, sq, offset, qidx);
226+
}
227+
199228
void otx2_zc_napi_handler(struct otx2_nic *pfvf, struct xsk_buff_pool *pool,
200229
int queue, int budget)
201230
{
202231
struct xdp_desc *xdp_desc = pool->tx_descs;
203-
int err, i, work_done = 0, batch;
232+
int i, batch;
204233

205234
budget = min(budget, otx2_read_free_sqe(pfvf, queue));
206235
batch = xsk_tx_peek_release_desc_batch(pool, budget);
@@ -211,15 +240,6 @@ void otx2_zc_napi_handler(struct otx2_nic *pfvf, struct xsk_buff_pool *pool,
211240
dma_addr_t dma_addr;
212241

213242
dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc[i].addr);
214-
err = otx2_xdp_sq_append_pkt(pfvf, NULL, dma_addr, xdp_desc[i].len,
215-
queue, OTX2_AF_XDP_FRAME);
216-
if (!err) {
217-
netdev_err(pfvf->netdev, "AF_XDP: Unable to transfer packet err%d\n", err);
218-
break;
219-
}
220-
work_done++;
243+
otx2_xsk_sq_append_pkt(pfvf, dma_addr, xdp_desc[i].len, queue);
221244
}
222-
223-
if (work_done)
224-
xsk_tx_release(pool);
225245
}

0 commit comments

Comments
 (0)