Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <hkelam@marvell.com>
Link: https://patch.msgid.link/20250420032350.4047706-1-hkelam@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hariprasad Kelam and committed by
Jakub Kicinski
b5cdb9b3 3fec58f5

+35 -14
+2
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
··· 1107 1107 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf); 1108 1108 bool otx2_xdp_sq_append_pkt(struct otx2_nic *pfvf, struct xdp_frame *xdpf, 1109 1109 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); 1110 1112 u16 otx2_get_max_mtu(struct otx2_nic *pfvf); 1111 1113 int otx2_handle_ntuple_tc_features(struct net_device *netdev, 1112 1114 netdev_features_t features);
+2 -3
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
··· 1410 1410 } 1411 1411 } 1412 1412 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) 1416 1415 { 1417 1416 struct nix_sqe_sg_s *sg = NULL; 1418 1417 u64 *iova = NULL;
+31 -11
drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c
··· 11 11 #include <net/xdp.h> 12 12 13 13 #include "otx2_common.h" 14 + #include "otx2_struct.h" 14 15 #include "otx2_xsk.h" 15 16 16 17 int otx2_xsk_pool_alloc_buf(struct otx2_nic *pfvf, struct otx2_pool *pool, ··· 197 196 sq->xsk_pool = xsk_get_pool_from_qid(pfvf->netdev, qidx); 198 197 } 199 198 199 + static void otx2_xsk_sq_append_pkt(struct otx2_nic *pfvf, u64 iova, int len, 200 + u16 qidx) 201 + { 202 + struct nix_sqe_hdr_s *sqe_hdr; 203 + struct otx2_snd_queue *sq; 204 + int offset; 205 + 206 + sq = &pfvf->qset.sq[qidx]; 207 + memset(sq->sqe_base + 8, 0, sq->sqe_size - 8); 208 + 209 + sqe_hdr = (struct nix_sqe_hdr_s *)(sq->sqe_base); 210 + 211 + if (!sqe_hdr->total) { 212 + sqe_hdr->aura = sq->aura_id; 213 + sqe_hdr->df = 1; 214 + sqe_hdr->sq = qidx; 215 + sqe_hdr->pnc = 1; 216 + } 217 + sqe_hdr->total = len; 218 + sqe_hdr->sqe_id = sq->head; 219 + 220 + offset = sizeof(*sqe_hdr); 221 + 222 + otx2_xdp_sqe_add_sg(sq, NULL, iova, len, &offset, OTX2_AF_XDP_FRAME); 223 + sqe_hdr->sizem1 = (offset / 16) - 1; 224 + pfvf->hw_ops->sqe_flush(pfvf, sq, offset, qidx); 225 + } 226 + 200 227 void otx2_zc_napi_handler(struct otx2_nic *pfvf, struct xsk_buff_pool *pool, 201 228 int queue, int budget) 202 229 { 203 230 struct xdp_desc *xdp_desc = pool->tx_descs; 204 - int err, i, work_done = 0, batch; 231 + int i, batch; 205 232 206 233 budget = min(budget, otx2_read_free_sqe(pfvf, queue)); 207 234 batch = xsk_tx_peek_release_desc_batch(pool, budget); ··· 240 211 dma_addr_t dma_addr; 241 212 242 213 dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc[i].addr); 243 - err = otx2_xdp_sq_append_pkt(pfvf, NULL, dma_addr, xdp_desc[i].len, 244 - queue, OTX2_AF_XDP_FRAME); 245 - if (!err) { 246 - netdev_err(pfvf->netdev, "AF_XDP: Unable to transfer packet err%d\n", err); 247 - break; 248 - } 249 - work_done++; 214 + otx2_xsk_sq_append_pkt(pfvf, dma_addr, xdp_desc[i].len, queue); 250 215 } 251 - 252 - if (work_done) 253 - xsk_tx_release(pool); 254 216 }