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

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

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
Extension
.c
Size
45747 bytes
Lines
1784
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

struct otx2_flow {
	struct ethtool_rx_flow_spec flow_spec;
	struct list_head list;
	u32 location;
	u32 entry;
	bool is_vf;
	u8 rss_ctx_id;
#define DMAC_FILTER_RULE		BIT(0)
#define PFC_FLOWCTRL_RULE		BIT(1)
	u16 rule_type;
	int vf;
};

enum dmac_req {
	DMAC_ADDR_UPDATE,
	DMAC_ADDR_DEL
};

static void otx2_clear_ntuple_flow_info(struct otx2_nic *pfvf, struct otx2_flow_config *flow_cfg)
{
	devm_kfree(pfvf->dev, flow_cfg->flow_ent);
	flow_cfg->flow_ent = NULL;
	flow_cfg->max_flows = 0;
}

static int otx2_mcam_pfl_info_get(struct otx2_nic *pfvf, u16 *x4_slots, u8 *kw_type)
{
	struct npc_get_pfl_info_rsp *rsp;
	struct msg_req *req;
	static struct {
		bool is_set;
		u8 kw_type;
		u16 x4_slots;
	} pfl_info;

	/* Avoid sending mboxes for constant information
	 * like x4_slots
	 */
	mutex_lock(&pfvf->mbox.lock);
	if (pfl_info.is_set) {
		*x4_slots = pfl_info.x4_slots;
		*kw_type = pfl_info.kw_type;
		mutex_unlock(&pfvf->mbox.lock);
		return 0;
	}

	req = otx2_mbox_alloc_msg_npc_get_pfl_info(&pfvf->mbox);
	if (!req) {
		mutex_unlock(&pfvf->mbox.lock);
		return -ENOMEM;
	}

	/* Send message to AF */
	if (otx2_sync_mbox_msg(&pfvf->mbox)) {
		mutex_unlock(&pfvf->mbox.lock);
		return -EFAULT;
	}

	rsp = (struct npc_get_pfl_info_rsp *)otx2_mbox_get_rsp
		(&pfvf->mbox.mbox, 0, &req->hdr);

	if (IS_ERR(rsp)) {
		mutex_unlock(&pfvf->mbox.lock);
		return -EFAULT;
	}

	pfl_info.kw_type = rsp->kw_type;
	if (rsp->kw_type == NPC_MCAM_KEY_X2)
		pfl_info.x4_slots = 0;
	else
		pfl_info.x4_slots = rsp->x4_slots;
	pfl_info.is_set = true;

	*x4_slots = pfl_info.x4_slots;
	*kw_type = pfl_info.kw_type;

	mutex_unlock(&pfvf->mbox.lock);
	return 0;
}

static int otx2_get_dft_rl_idx(struct otx2_nic *pfvf, u16 *mcam_idx)
{
	struct npc_get_dft_rl_idxs_rsp *rsp;
	struct msg_req *req;

	mutex_lock(&pfvf->mbox.lock);

	req = otx2_mbox_alloc_msg_npc_get_dft_rl_idxs(&pfvf->mbox);
	if (!req) {
		mutex_unlock(&pfvf->mbox.lock);

Annotation

Implementation Notes