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

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c
Extension
.c
Size
6180 bytes
Lines
246
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/* Marvell RVU Ethernet driver
 *
 * Copyright (C) 2024 Marvell.
 *
 */

#include <linux/bpf_trace.h>
#include <linux/stringify.h>
#include <net/xdp_sock_drv.h>
#include <net/xdp.h>

#include "otx2_common.h"
#include "otx2_struct.h"
#include "otx2_xsk.h"

int otx2_xsk_pool_alloc_buf(struct otx2_nic *pfvf, struct otx2_pool *pool,
			    dma_addr_t *dma, int idx)
{
	struct xdp_buff *xdp;
	int delta;

	xdp = xsk_buff_alloc(pool->xsk_pool);
	if (!xdp)
		return -ENOMEM;

	pool->xdp[pool->xdp_top++] = xdp;
	*dma = OTX2_DATA_ALIGN(xsk_buff_xdp_get_dma(xdp));
	/* Adjust xdp->data for unaligned addresses */
	delta = *dma - xsk_buff_xdp_get_dma(xdp);
	xdp->data += delta;

	return 0;
}

static int otx2_xsk_ctx_disable(struct otx2_nic *pfvf, u16 qidx, int aura_id)
{
	struct nix_cn10k_aq_enq_req *cn10k_rq_aq;
	struct npa_aq_enq_req *aura_aq;
	struct npa_aq_enq_req *pool_aq;
	struct nix_aq_enq_req *rq_aq;

	if (test_bit(CN10K_LMTST, &pfvf->hw.cap_flag)) {
		cn10k_rq_aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox);
		if (!cn10k_rq_aq)
			return -ENOMEM;
		cn10k_rq_aq->qidx = qidx;
		cn10k_rq_aq->rq.ena = 0;
		cn10k_rq_aq->rq_mask.ena = 1;
		cn10k_rq_aq->ctype = NIX_AQ_CTYPE_RQ;
		cn10k_rq_aq->op = NIX_AQ_INSTOP_WRITE;
	} else {
		rq_aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox);
		if (!rq_aq)
			return -ENOMEM;
		rq_aq->qidx = qidx;
		rq_aq->sq.ena = 0;
		rq_aq->sq_mask.ena = 1;
		rq_aq->ctype = NIX_AQ_CTYPE_RQ;
		rq_aq->op = NIX_AQ_INSTOP_WRITE;
	}

	aura_aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox);
	if (!aura_aq)
		goto fail;

	aura_aq->aura_id = aura_id;
	aura_aq->aura.ena = 0;
	aura_aq->aura_mask.ena = 1;
	aura_aq->ctype = NPA_AQ_CTYPE_AURA;
	aura_aq->op = NPA_AQ_INSTOP_WRITE;

	pool_aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox);
	if (!pool_aq)
		goto fail;

	pool_aq->aura_id = aura_id;
	pool_aq->pool.ena = 0;
	pool_aq->pool_mask.ena = 1;

	pool_aq->ctype = NPA_AQ_CTYPE_POOL;
	pool_aq->op = NPA_AQ_INSTOP_WRITE;

	return otx2_sync_mbox_msg(&pfvf->mbox);

fail:
	otx2_mbox_reset(&pfvf->mbox.mbox, 0);
	return -ENOMEM;
}

Annotation

Implementation Notes