drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c

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

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
Extension
.c
Size
120394 bytes
Lines
4397
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

if (is_lbk_vf(rvu, pcifunc)) {
			if (promisc == USHRT_MAX)
				return -EINVAL;
			return promisc;
		}

		if (is_cgx_vf(rvu, pcifunc)) {
			if (ucast == USHRT_MAX)
				return -EINVAL;

			return ucast;
		}

		switch (type) {
		case NIXLF_BCAST_ENTRY:
			if (bcast == USHRT_MAX)
				return -EINVAL;
			return bcast;
		case NIXLF_ALLMULTI_ENTRY:
			if (mcast == USHRT_MAX)
				return -EINVAL;
			return mcast;
		case NIXLF_PROMISC_ENTRY:
			if (promisc == USHRT_MAX)
				return -EINVAL;
			return promisc;
		case NIXLF_UCAST_ENTRY:
			if (ucast == USHRT_MAX)
				return -EINVAL;
			return ucast;
		default:
			return -EINVAL;
		}
	}

	/* Check if this is for a PF */
	pf = rvu_get_pf(rvu->pdev, pcifunc);
	if (pf && !(pcifunc & RVU_PFVF_FUNC_MASK)) {
		/* Reserved entries exclude PF0 */
		pf--;
		index = mcam->pf_offset + (pf * RSVD_MCAM_ENTRIES_PER_PF);
		/* Broadcast address matching entry should be first so
		 * that the packet can be replicated to all VFs.
		 */
		if (type == NIXLF_BCAST_ENTRY)
			return index;
		else if (type == NIXLF_ALLMULTI_ENTRY)
			return index + 1;
		else if (type == NIXLF_PROMISC_ENTRY)
			return index + 2;
	}

	return npc_get_ucast_mcam_index(mcam, pcifunc, nixlf);
}

int npc_get_bank(struct npc_mcam *mcam, int index)
{
	struct rvu_hwinfo *hw = container_of(mcam, struct rvu_hwinfo, mcam);
	int bank = index / mcam->banksize;
	struct rvu *rvu = hw->rvu;

	if (is_cn20k(rvu->pdev))
		return bank;

	/* 0,1 & 2,3 banks are combined for this keysize */
	if (mcam->keysize == NPC_MCAM_KEY_X2)
		return bank ? 2 : 0;

	return bank;
}

bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam,
			   int blkaddr, int index)
{
	int bank = npc_get_bank(mcam, index);
	u64 cfg;

	index &= (mcam->banksize - 1);
	if (is_cn20k(rvu->pdev))
		cfg = rvu_read64(rvu, blkaddr,
				 NPC_AF_CN20K_MCAMEX_BANKX_CFG_EXT(index,
								   bank));
	else
		cfg = rvu_read64(rvu, blkaddr,
				 NPC_AF_MCAMEX_BANKX_CFG(index, bank));

	return (cfg & 1);
}

void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,

Annotation

Implementation Notes