drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c- Extension
.c- Size
- 21876 bytes
- Lines
- 785
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
lan966x_main.hlan966x_vcap_ag_api.hvcap_api.hvcap_api_client.hvcap_api_debugfs.h
Detected Declarations
struct lan966x_vcap_cmd_cbfunction lan966x_vcap_read_update_ctrlfunction lan966x_vcap_wait_updatefunction __lan966x_vcap_range_initfunction lan966x_vcap_is1_cid_to_lookupfunction lan966x_vcap_is2_cid_to_lookupfunction lan966x_vcap_is1_get_port_keysetsfunction lan966x_vcap_is2_get_port_keysetsfunction lan966x_vcap_validate_keysetfunction lan966x_vcap_is2_is_first_chainfunction lan966x_vcap_is1_add_default_fieldsfunction lan966x_vcap_is2_add_default_fieldsfunction lan966x_vcap_es0_add_default_fieldsfunction lan966x_vcap_add_default_fieldsfunction lan966x_vcap_cache_erasefunction lan966x_es0_read_esdx_counterfunction lan966x_es0_write_esdx_counterfunction lan966x_vcap_cache_writefunction lan966x_vcap_cache_readfunction lan966x_vcap_range_initfunction lan966x_vcap_updatefunction lan966x_vcap_movefunction lan966x_vcap_admin_freefunction lan966x_vcap_admin_allocfunction lan966x_vcap_block_initfunction lan966x_vcap_port_key_deselectionfunction lan966x_vcap_initfunction lan966x_vcap_deinitfunction list_for_each_entry_safe
Annotated Snippet
struct lan966x_vcap_cmd_cb {
struct lan966x *lan966x;
u32 instance;
};
static u32 lan966x_vcap_read_update_ctrl(const struct lan966x_vcap_cmd_cb *cb)
{
return lan_rd(cb->lan966x, VCAP_UPDATE_CTRL(cb->instance));
}
static void lan966x_vcap_wait_update(struct lan966x *lan966x, int instance)
{
const struct lan966x_vcap_cmd_cb cb = { .lan966x = lan966x,
.instance = instance };
u32 val;
readx_poll_timeout(lan966x_vcap_read_update_ctrl, &cb, val,
(val & VCAP_UPDATE_CTRL_UPDATE_SHOT) == 0, 10,
100000);
}
static void __lan966x_vcap_range_init(struct lan966x *lan966x,
struct vcap_admin *admin,
u32 addr,
u32 count)
{
lan_wr(VCAP_MV_CFG_MV_NUM_POS_SET(0) |
VCAP_MV_CFG_MV_SIZE_SET(count - 1),
lan966x, VCAP_MV_CFG(admin->tgt_inst));
lan_wr(VCAP_UPDATE_CTRL_UPDATE_CMD_SET(VCAP_CMD_INITIALIZE) |
VCAP_UPDATE_CTRL_UPDATE_ENTRY_DIS_SET(0) |
VCAP_UPDATE_CTRL_UPDATE_ACTION_DIS_SET(0) |
VCAP_UPDATE_CTRL_UPDATE_CNT_DIS_SET(0) |
VCAP_UPDATE_CTRL_UPDATE_ADDR_SET(addr) |
VCAP_UPDATE_CTRL_CLEAR_CACHE_SET(true) |
VCAP_UPDATE_CTRL_UPDATE_SHOT_SET(1),
lan966x, VCAP_UPDATE_CTRL(admin->tgt_inst));
lan966x_vcap_wait_update(lan966x, admin->tgt_inst);
}
static int lan966x_vcap_is1_cid_to_lookup(int cid)
{
int lookup = 0;
if (cid >= LAN966X_VCAP_CID_IS1_L1 &&
cid < LAN966X_VCAP_CID_IS1_L2)
lookup = 1;
else if (cid >= LAN966X_VCAP_CID_IS1_L2 &&
cid < LAN966X_VCAP_CID_IS1_MAX)
lookup = 2;
return lookup;
}
static int lan966x_vcap_is2_cid_to_lookup(int cid)
{
if (cid >= LAN966X_VCAP_CID_IS2_L1 &&
cid < LAN966X_VCAP_CID_IS2_MAX)
return 1;
return 0;
}
/* Return the list of keysets for the vcap port configuration */
static int
lan966x_vcap_is1_get_port_keysets(struct net_device *ndev, int lookup,
struct vcap_keyset_list *keysetlist,
u16 l3_proto)
{
struct lan966x_port *port = netdev_priv(ndev);
struct lan966x *lan966x = port->lan966x;
u32 val;
val = lan_rd(lan966x, ANA_VCAP_S1_CFG(port->chip_port, lookup));
/* Collect all keysets for the port in a list */
if (l3_proto == ETH_P_ALL || l3_proto == ETH_P_IP) {
switch (ANA_VCAP_S1_CFG_KEY_IP4_CFG_GET(val)) {
case VCAP_IS1_PS_IPV4_7TUPLE:
vcap_keyset_list_add(keysetlist, VCAP_KFS_7TUPLE);
break;
case VCAP_IS1_PS_IPV4_5TUPLE_IP4:
vcap_keyset_list_add(keysetlist, VCAP_KFS_5TUPLE_IP4);
break;
case VCAP_IS1_PS_IPV4_NORMAL:
vcap_keyset_list_add(keysetlist, VCAP_KFS_NORMAL);
break;
}
Annotation
- Immediate include surface: `lan966x_main.h`, `lan966x_vcap_ag_api.h`, `vcap_api.h`, `vcap_api_client.h`, `vcap_api_debugfs.h`.
- Detected declarations: `struct lan966x_vcap_cmd_cb`, `function lan966x_vcap_read_update_ctrl`, `function lan966x_vcap_wait_update`, `function __lan966x_vcap_range_init`, `function lan966x_vcap_is1_cid_to_lookup`, `function lan966x_vcap_is2_cid_to_lookup`, `function lan966x_vcap_is1_get_port_keysets`, `function lan966x_vcap_is2_get_port_keysets`, `function lan966x_vcap_validate_keyset`, `function lan966x_vcap_is2_is_first_chain`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.