drivers/net/ethernet/microchip/vcap/vcap_api.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/vcap/vcap_api.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/vcap/vcap_api.c- Extension
.c- Size
- 99154 bytes
- Lines
- 3612
- 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
linux/types.hvcap_api_private.hvcap_api_kunit.c
Detected Declarations
struct vcap_rule_movestruct vcap_enabled_portfunction vcap_iter_setfunction vcap_iter_skip_tgfunction vcap_iter_updatefunction vcap_iter_initfunction vcap_iter_nextfunction vcap_set_bitfunction vcap_encode_bitfunction vcap_encode_fieldfunction vcap_encode_typegroupsfunction vcap_bitarray_zerofunction vcap_get_bitfunction vcap_decode_fieldfunction vcap_verify_keystream_keysetfunction vcap_verify_typegroupsfunction vcap_find_keystream_typegroup_swfunction vcap_find_keystream_keysetsfunction vcap_addr_keysetsfunction vcap_keyfield_typegroupfunction vcap_keyfield_countfunction vcap_encode_keyfieldfunction vcap_encode_keyfield_typegroupsfunction vcap_copy_to_w32befunction vcap_copy_from_client_keyfieldfunction vcap_copy_from_client_actionfieldfunction vcap_encode_rule_keysetfunction vcap_actionfieldsfunction vcap_actionfieldsetfunction vcap_actionfield_typegroupfunction vcap_actionfield_countfunction vcap_encode_actionfieldfunction vcap_encode_actionfield_typegroupsfunction vcap_encode_rule_actionsetfunction vcap_encode_rulefunction vcap_api_checkfunction vcap_erase_cachefunction vcap_set_rule_set_keysetfunction vcap_set_rule_set_actionsetfunction vcap_rule_existsfunction vcap_get_locked_rulefunction vcap_lookup_rule_by_cookiefunction list_for_each_entryfunction vcap_admin_rule_countfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entry_safe
Annotated Snippet
struct vcap_rule_move {
int addr; /* address to move */
int offset; /* change in address */
int count; /* blocksize of addresses to move */
};
/* Stores the filter cookie and chain id that enabled the port */
struct vcap_enabled_port {
struct list_head list; /* for insertion in enabled ports list */
struct net_device *ndev; /* the enabled port */
unsigned long cookie; /* filter that enabled the port */
int src_cid; /* source chain id */
int dst_cid; /* destination chain id */
};
void vcap_iter_set(struct vcap_stream_iter *itr, int sw_width,
const struct vcap_typegroup *tg, u32 offset)
{
memset(itr, 0, sizeof(*itr));
itr->offset = offset;
itr->sw_width = sw_width;
itr->regs_per_sw = DIV_ROUND_UP(sw_width, 32);
itr->tg = tg;
}
static void vcap_iter_skip_tg(struct vcap_stream_iter *itr)
{
/* Compensate the field offset for preceding typegroups.
* A typegroup table ends with an all-zero terminator.
*/
while (itr->tg->width && itr->offset >= itr->tg->offset) {
itr->offset += itr->tg->width;
itr->tg++; /* next typegroup */
}
}
void vcap_iter_update(struct vcap_stream_iter *itr)
{
int sw_idx, sw_bitpos;
/* Calculate the subword index and bitposition for current bit */
sw_idx = itr->offset / itr->sw_width;
sw_bitpos = itr->offset % itr->sw_width;
/* Calculate the register index and bitposition for current bit */
itr->reg_idx = (sw_idx * itr->regs_per_sw) + (sw_bitpos / 32);
itr->reg_bitpos = sw_bitpos % 32;
}
void vcap_iter_init(struct vcap_stream_iter *itr, int sw_width,
const struct vcap_typegroup *tg, u32 offset)
{
vcap_iter_set(itr, sw_width, tg, offset);
vcap_iter_skip_tg(itr);
vcap_iter_update(itr);
}
void vcap_iter_next(struct vcap_stream_iter *itr)
{
itr->offset++;
vcap_iter_skip_tg(itr);
vcap_iter_update(itr);
}
static void vcap_set_bit(u32 *stream, struct vcap_stream_iter *itr, bool value)
{
u32 mask = BIT(itr->reg_bitpos);
u32 *p = &stream[itr->reg_idx];
if (value)
*p |= mask;
else
*p &= ~mask;
}
static void vcap_encode_bit(u32 *stream, struct vcap_stream_iter *itr, bool val)
{
/* When intersected by a type group field, stream the type group bits
* before continuing with the value bit
*/
while (itr->tg->width &&
itr->offset >= itr->tg->offset &&
itr->offset < itr->tg->offset + itr->tg->width) {
int tg_bitpos = itr->tg->offset - itr->offset;
vcap_set_bit(stream, itr, (itr->tg->value >> tg_bitpos) & 0x1);
itr->offset++;
vcap_iter_update(itr);
}
vcap_set_bit(stream, itr, val);
}
Annotation
- Immediate include surface: `linux/types.h`, `vcap_api_private.h`, `vcap_api_kunit.c`.
- Detected declarations: `struct vcap_rule_move`, `struct vcap_enabled_port`, `function vcap_iter_set`, `function vcap_iter_skip_tg`, `function vcap_iter_update`, `function vcap_iter_init`, `function vcap_iter_next`, `function vcap_set_bit`, `function vcap_encode_bit`, `function vcap_encode_field`.
- 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.