drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c- Extension
.c- Size
- 69026 bytes
- Lines
- 2353
- 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.
- 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
kunit/test.hvcap_api.hvcap_api_client.hvcap_model_kunit.h
Detected Declarations
function test_val_keysetfunction test_add_def_fieldsfunction test_cache_erasefunction test_cache_initfunction test_cache_readfunction test_cache_writefunction test_cache_updatefunction test_cache_movefunction vcap_test_port_infofunction vcap_test_api_initfunction test_vcap_xn_rule_creatorfunction test_init_rule_deletionfunction vcap_api_set_bit_1_testfunction vcap_api_set_bit_0_testfunction vcap_api_iterator_init_testfunction vcap_api_iterator_next_testfunction vcap_api_encode_typegroups_testfunction vcap_api_encode_bit_testfunction vcap_api_encode_field_testfunction vcap_api_encode_short_field_testfunction vcap_api_encode_keyfield_testfunction vcap_api_encode_max_keyfield_testfunction vcap_api_encode_actionfield_testfunction vcap_api_keyfield_typegroup_testfunction vcap_api_actionfield_typegroup_testfunction vcap_api_vcap_keyfields_testfunction vcap_api_vcap_actionfields_testfunction vcap_api_encode_rule_keyset_testfunction vcap_api_encode_rule_actionset_testfunction vcap_free_ckffunction list_for_each_entry_safefunction vcap_api_rule_add_keyvalue_testfunction vcap_free_caffunction list_for_each_entry_safefunction vcap_api_rule_add_actionvalue_testfunction vcap_api_rule_find_keyset_basic_testfunction vcap_api_rule_find_keyset_failed_testfunction vcap_api_rule_find_keyset_many_testfunction vcap_api_encode_rule_testfunction vcap_api_set_rule_counter_testfunction vcap_api_get_rule_counter_testfunction vcap_api_rule_insert_in_order_testfunction vcap_api_rule_insert_reverse_order_testfunction vcap_api_rule_remove_at_end_testfunction vcap_api_rule_remove_in_middle_testfunction vcap_api_rule_remove_in_front_testfunction vcap_api_next_lookup_basic_testfunction vcap_api_next_lookup_advanced_test
Annotated Snippet
switch (admin->vtype) {
case VCAP_TYPE_IS0:
for (idx = 0; idx < kslist->cnt; idx++) {
if (kslist->keysets[idx] == VCAP_KFS_ETAG)
return kslist->keysets[idx];
if (kslist->keysets[idx] == VCAP_KFS_PURE_5TUPLE_IP4)
return kslist->keysets[idx];
if (kslist->keysets[idx] == VCAP_KFS_NORMAL_5TUPLE_IP4)
return kslist->keysets[idx];
if (kslist->keysets[idx] == VCAP_KFS_NORMAL_7TUPLE)
return kslist->keysets[idx];
}
break;
case VCAP_TYPE_IS2:
for (idx = 0; idx < kslist->cnt; idx++) {
if (kslist->keysets[idx] == VCAP_KFS_MAC_ETYPE)
return kslist->keysets[idx];
if (kslist->keysets[idx] == VCAP_KFS_ARP)
return kslist->keysets[idx];
if (kslist->keysets[idx] == VCAP_KFS_IP_7TUPLE)
return kslist->keysets[idx];
}
break;
default:
pr_info("%s:%d: no validation for VCAP %d\n",
__func__, __LINE__, admin->vtype);
break;
}
}
return -EINVAL;
}
/* Callback used by the VCAP API */
static void test_add_def_fields(struct net_device *ndev,
struct vcap_admin *admin,
struct vcap_rule *rule)
{
if (admin->vinst == 0 || admin->vinst == 2)
vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_1);
else
vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_0);
}
/* Callback used by the VCAP API */
static void test_cache_erase(struct vcap_admin *admin)
{
if (test_cache_erase_count) {
memset(admin->cache.keystream, 0, test_cache_erase_count);
memset(admin->cache.maskstream, 0, test_cache_erase_count);
memset(admin->cache.actionstream, 0, test_cache_erase_count);
test_cache_erase_count = 0;
}
}
/* Callback used by the VCAP API */
static void test_cache_init(struct net_device *ndev, struct vcap_admin *admin,
u32 start, u32 count)
{
test_init_start = start;
test_init_count = count;
}
/* Callback used by the VCAP API */
static void test_cache_read(struct net_device *ndev, struct vcap_admin *admin,
enum vcap_selection sel, u32 start, u32 count)
{
u32 *keystr, *mskstr, *actstr;
int idx;
pr_debug("%s:%d: %d %d\n", __func__, __LINE__, start, count);
switch (sel) {
case VCAP_SEL_ENTRY:
keystr = &admin->cache.keystream[start];
mskstr = &admin->cache.maskstream[start];
for (idx = 0; idx < count; ++idx) {
pr_debug("%s:%d: keydata[%02d]: 0x%08x\n", __func__,
__LINE__, start + idx, keystr[idx]);
}
for (idx = 0; idx < count; ++idx) {
/* Invert the mask before decoding starts */
mskstr[idx] = ~mskstr[idx];
pr_debug("%s:%d: mskdata[%02d]: 0x%08x\n", __func__,
__LINE__, start + idx, mskstr[idx]);
}
break;
case VCAP_SEL_ACTION:
actstr = &admin->cache.actionstream[start];
for (idx = 0; idx < count; ++idx) {
pr_debug("%s:%d: actdata[%02d]: 0x%08x\n", __func__,
__LINE__, start + idx, actstr[idx]);
Annotation
- Immediate include surface: `kunit/test.h`, `vcap_api.h`, `vcap_api_client.h`, `vcap_model_kunit.h`.
- Detected declarations: `function test_val_keyset`, `function test_add_def_fields`, `function test_cache_erase`, `function test_cache_init`, `function test_cache_read`, `function test_cache_write`, `function test_cache_update`, `function test_cache_move`, `function vcap_test_port_info`, `function vcap_test_api_init`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.