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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/ipv6.hlinux/sort.hotx2_common.h
Detected Declarations
struct otx2_flowenum dmac_reqfunction otx2_clear_ntuple_flow_infofunction otx2_mcam_pfl_info_getfunction otx2_get_dft_rl_idxfunction otx2_free_ntuple_mcam_entriesfunction otx2_alloc_mcam_entriesfunction otx2_mcam_entry_initfunction otx2vf_mcam_flow_initfunction otx2_mcam_flow_initfunction otx2_mcam_flow_delfunction otx2_do_add_macfilterfunction otx2_add_macfilterfunction otx2_get_mcamentry_for_macfunction otx2_del_macfilterfunction list_for_each_entryfunction otx2_add_flow_to_listfunction list_for_each_entryfunction otx2_get_maxflowsfunction otx2_get_flowfunction list_for_each_entryfunction otx2_get_all_flowsfunction otx2_prepare_ipv4_flowfunction otx2_prepare_ipv6_flowfunction otx2_prepare_flow_requestfunction cpu_to_be32function otx2_get_kw_typefunction otx2_is_flow_rule_dmacfilterfunction otx2_add_flow_msgfunction otx2_add_flow_with_pfmacfunction otx2_add_flowfunction otx2_remove_flow_msgfunction otx2_update_rem_pfmacfunction list_for_each_entryfunction otx2_remove_flowfunction otx2_rss_ctx_flow_delfunction list_for_each_entry_safefunction otx2_destroy_ntuple_flowsfunction list_for_each_entry_safefunction otx2_destroy_mcam_flowsfunction list_for_each_entry_safefunction otx2_install_rxvlan_offload_flowfunction otx2_delete_rxvlan_offload_flowfunction otx2_enable_rxvlanfunction otx2_dmacflt_reinstall_flowsfunction list_for_each_entryfunction otx2_dmacflt_update_pfmac_flowexport otx2_alloc_mcam_entries
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
- Immediate include surface: `net/ipv6.h`, `linux/sort.h`, `otx2_common.h`.
- Detected declarations: `struct otx2_flow`, `enum dmac_req`, `function otx2_clear_ntuple_flow_info`, `function otx2_mcam_pfl_info_get`, `function otx2_get_dft_rl_idx`, `function otx2_free_ntuple_mcam_entries`, `function otx2_alloc_mcam_entries`, `function otx2_mcam_entry_init`, `function otx2vf_mcam_flow_init`, `function otx2_mcam_flow_init`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.