drivers/net/ethernet/mscc/ocelot_vcap.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mscc/ocelot_vcap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mscc/ocelot_vcap.c- Extension
.c- Size
- 43676 bytes
- Lines
- 1434
- 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.
- 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
linux/iopoll.hlinux/proc_fs.hsoc/mscc/ocelot_vcap.hocelot_police.hocelot_vcap.h
Detected Declarations
struct vcap_datastruct vcap_policer_entryenum vcap_selenum vcap_cmdfunction vcap_read_update_ctrlfunction vcap_cmdfunction vcap_row_cmdfunction vcap_entry2cachefunction vcap_cache2entryfunction vcap_action2cachefunction vcap_cache2actionfunction vcap_data_offset_getfunction vcap_data_setfunction vcap_data_getfunction vcap_key_field_setfunction vcap_key_setfunction vcap_key_bytes_setfunction vcap_key_l4_port_setfunction vcap_key_bit_setfunction vcap_action_setfunction is2_action_setfunction is2_entry_setfunction is1_action_setfunction is1_entry_setfunction es0_action_setfunction es0_entry_setfunction vcap_entry_getfunction vcap_entry_setfunction ocelot_vcap_policer_addfunction list_for_each_entryfunction ocelot_vcap_policer_delfunction list_for_each_entry_safefunction ocelot_vcap_filter_add_aux_resourcesfunction ocelot_vcap_filter_del_aux_resourcesfunction ocelot_vcap_filter_add_to_blockfunction list_for_each_entryfunction ocelot_vcap_filter_equalfunction ocelot_vcap_block_get_filter_indexfunction list_for_each_entryfunction ocelot_vcap_block_find_filter_by_indexfunction list_for_each_entryfunction ocelot_vcap_block_find_filter_by_idfunction ocelot_match_all_as_mac_etypefunction ocelot_vcap_is_problematic_mac_etypefunction ocelot_vcap_is_problematic_non_mac_etypefunction ocelot_exclusive_mac_etype_filter_rulesfunction ocelot_vcap_filter_addfunction ocelot_vcap_block_remove_filter
Annotated Snippet
struct vcap_data {
u32 entry[VCAP_ENTRY_WIDTH]; /* ENTRY_DAT */
u32 mask[VCAP_ENTRY_WIDTH]; /* MASK_DAT */
u32 action[VCAP_ENTRY_WIDTH]; /* ACTION_DAT */
u32 counter[VCAP_COUNTER_WIDTH]; /* CNT_DAT */
u32 tg; /* TG_DAT */
u32 type; /* Action type */
u32 tg_sw; /* Current type-group */
u32 cnt; /* Current counter */
u32 key_offset; /* Current entry offset */
u32 action_offset; /* Current action offset */
u32 counter_offset; /* Current counter offset */
u32 tg_value; /* Current type-group value */
u32 tg_mask; /* Current type-group mask */
};
static u32 vcap_read_update_ctrl(struct ocelot *ocelot,
const struct vcap_props *vcap)
{
return ocelot_target_read(ocelot, vcap->target, VCAP_CORE_UPDATE_CTRL);
}
static void vcap_cmd(struct ocelot *ocelot, const struct vcap_props *vcap,
u16 ix, int cmd, int sel)
{
u32 value = (VCAP_CORE_UPDATE_CTRL_UPDATE_CMD(cmd) |
VCAP_CORE_UPDATE_CTRL_UPDATE_ADDR(ix) |
VCAP_CORE_UPDATE_CTRL_UPDATE_SHOT);
if ((sel & VCAP_SEL_ENTRY) && ix >= vcap->entry_count)
return;
if (!(sel & VCAP_SEL_ENTRY))
value |= VCAP_CORE_UPDATE_CTRL_UPDATE_ENTRY_DIS;
if (!(sel & VCAP_SEL_ACTION))
value |= VCAP_CORE_UPDATE_CTRL_UPDATE_ACTION_DIS;
if (!(sel & VCAP_SEL_COUNTER))
value |= VCAP_CORE_UPDATE_CTRL_UPDATE_CNT_DIS;
ocelot_target_write(ocelot, vcap->target, value, VCAP_CORE_UPDATE_CTRL);
read_poll_timeout(vcap_read_update_ctrl, value,
(value & VCAP_CORE_UPDATE_CTRL_UPDATE_SHOT) == 0,
10, 100000, false, ocelot, vcap);
}
/* Convert from 0-based row to VCAP entry row and run command */
static void vcap_row_cmd(struct ocelot *ocelot, const struct vcap_props *vcap,
u32 row, int cmd, int sel)
{
vcap_cmd(ocelot, vcap, vcap->entry_count - row - 1, cmd, sel);
}
static void vcap_entry2cache(struct ocelot *ocelot,
const struct vcap_props *vcap,
struct vcap_data *data)
{
u32 entry_words, i;
entry_words = DIV_ROUND_UP(vcap->entry_width, ENTRY_WIDTH);
for (i = 0; i < entry_words; i++) {
ocelot_target_write_rix(ocelot, vcap->target, data->entry[i],
VCAP_CACHE_ENTRY_DAT, i);
ocelot_target_write_rix(ocelot, vcap->target, ~data->mask[i],
VCAP_CACHE_MASK_DAT, i);
}
ocelot_target_write(ocelot, vcap->target, data->tg, VCAP_CACHE_TG_DAT);
}
static void vcap_cache2entry(struct ocelot *ocelot,
const struct vcap_props *vcap,
struct vcap_data *data)
{
u32 entry_words, i;
entry_words = DIV_ROUND_UP(vcap->entry_width, ENTRY_WIDTH);
for (i = 0; i < entry_words; i++) {
data->entry[i] = ocelot_target_read_rix(ocelot, vcap->target,
VCAP_CACHE_ENTRY_DAT, i);
// Invert mask
data->mask[i] = ~ocelot_target_read_rix(ocelot, vcap->target,
VCAP_CACHE_MASK_DAT, i);
}
data->tg = ocelot_target_read(ocelot, vcap->target, VCAP_CACHE_TG_DAT);
}
Annotation
- Immediate include surface: `linux/iopoll.h`, `linux/proc_fs.h`, `soc/mscc/ocelot_vcap.h`, `ocelot_police.h`, `ocelot_vcap.h`.
- Detected declarations: `struct vcap_data`, `struct vcap_policer_entry`, `enum vcap_sel`, `enum vcap_cmd`, `function vcap_read_update_ctrl`, `function vcap_cmd`, `function vcap_row_cmd`, `function vcap_entry2cache`, `function vcap_cache2entry`, `function vcap_action2cache`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
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.