drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c- Extension
.c- Size
- 10034 bytes
- Lines
- 343
- 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
linux/kernel.hlinux/parman.hreg.hspectrum.hcore_acl_flex_actions.hspectrum_mr.h
Detected Declarations
struct mlxsw_sp1_mr_tcam_regionstruct mlxsw_sp1_mr_tcamstruct mlxsw_sp1_mr_tcam_routefunction mlxsw_sp1_mr_tcam_route_replacefunction mlxsw_sp1_mr_tcam_route_removefunction mlxsw_sp1_mr_tcam_protocol_regionfunction mlxsw_sp1_mr_tcam_route_parman_item_addfunction mlxsw_sp1_mr_tcam_route_parman_item_removefunction mlxsw_sp1_mr_tcam_route_createfunction mlxsw_sp1_mr_tcam_route_destroyfunction mlxsw_sp1_mr_tcam_route_updatefunction mlxsw_sp1_mr_tcam_region_allocfunction mlxsw_sp1_mr_tcam_region_freefunction mlxsw_sp1_mr_tcam_region_parman_resizefunction mlxsw_sp1_mr_tcam_region_parman_movefunction mlxsw_sp1_mr_tcam_region_initfunction mlxsw_sp1_mr_tcam_region_finifunction mlxsw_sp1_mr_tcam_initfunction mlxsw_sp1_mr_tcam_fini
Annotated Snippet
struct mlxsw_sp1_mr_tcam_region {
struct mlxsw_sp *mlxsw_sp;
enum mlxsw_reg_rtar_key_type rtar_key_type;
struct parman *parman;
struct parman_prio *parman_prios;
};
struct mlxsw_sp1_mr_tcam {
struct mlxsw_sp1_mr_tcam_region tcam_regions[MLXSW_SP_L3_PROTO_MAX];
};
struct mlxsw_sp1_mr_tcam_route {
struct parman_item parman_item;
struct parman_prio *parman_prio;
};
static int mlxsw_sp1_mr_tcam_route_replace(struct mlxsw_sp *mlxsw_sp,
struct parman_item *parman_item,
struct mlxsw_sp_mr_route_key *key,
struct mlxsw_afa_block *afa_block)
{
char rmft2_pl[MLXSW_REG_RMFT2_LEN];
switch (key->proto) {
case MLXSW_SP_L3_PROTO_IPV4:
mlxsw_reg_rmft2_ipv4_pack(rmft2_pl, true, parman_item->index,
key->vrid,
MLXSW_REG_RMFT2_IRIF_MASK_IGNORE, 0,
ntohl(key->group.addr4),
ntohl(key->group_mask.addr4),
ntohl(key->source.addr4),
ntohl(key->source_mask.addr4),
mlxsw_afa_block_first_set(afa_block));
break;
case MLXSW_SP_L3_PROTO_IPV6:
mlxsw_reg_rmft2_ipv6_pack(rmft2_pl, true, parman_item->index,
key->vrid,
MLXSW_REG_RMFT2_IRIF_MASK_IGNORE, 0,
key->group.addr6,
key->group_mask.addr6,
key->source.addr6,
key->source_mask.addr6,
mlxsw_afa_block_first_set(afa_block));
}
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rmft2), rmft2_pl);
}
static int mlxsw_sp1_mr_tcam_route_remove(struct mlxsw_sp *mlxsw_sp,
struct parman_item *parman_item,
struct mlxsw_sp_mr_route_key *key)
{
struct in6_addr zero_addr = IN6ADDR_ANY_INIT;
char rmft2_pl[MLXSW_REG_RMFT2_LEN];
switch (key->proto) {
case MLXSW_SP_L3_PROTO_IPV4:
mlxsw_reg_rmft2_ipv4_pack(rmft2_pl, false, parman_item->index,
key->vrid, 0, 0, 0, 0, 0, 0, NULL);
break;
case MLXSW_SP_L3_PROTO_IPV6:
mlxsw_reg_rmft2_ipv6_pack(rmft2_pl, false, parman_item->index,
key->vrid, 0, 0, zero_addr, zero_addr,
zero_addr, zero_addr, NULL);
break;
}
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rmft2), rmft2_pl);
}
static struct mlxsw_sp1_mr_tcam_region *
mlxsw_sp1_mr_tcam_protocol_region(struct mlxsw_sp1_mr_tcam *mr_tcam,
enum mlxsw_sp_l3proto proto)
{
return &mr_tcam->tcam_regions[proto];
}
static int
mlxsw_sp1_mr_tcam_route_parman_item_add(struct mlxsw_sp1_mr_tcam *mr_tcam,
struct mlxsw_sp1_mr_tcam_route *route,
struct mlxsw_sp_mr_route_key *key,
enum mlxsw_sp_mr_route_prio prio)
{
struct mlxsw_sp1_mr_tcam_region *tcam_region;
int err;
tcam_region = mlxsw_sp1_mr_tcam_protocol_region(mr_tcam, key->proto);
err = parman_item_add(tcam_region->parman,
&tcam_region->parman_prios[prio],
&route->parman_item);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/parman.h`, `reg.h`, `spectrum.h`, `core_acl_flex_actions.h`, `spectrum_mr.h`.
- Detected declarations: `struct mlxsw_sp1_mr_tcam_region`, `struct mlxsw_sp1_mr_tcam`, `struct mlxsw_sp1_mr_tcam_route`, `function mlxsw_sp1_mr_tcam_route_replace`, `function mlxsw_sp1_mr_tcam_route_remove`, `function mlxsw_sp1_mr_tcam_protocol_region`, `function mlxsw_sp1_mr_tcam_route_parman_item_add`, `function mlxsw_sp1_mr_tcam_route_parman_item_remove`, `function mlxsw_sp1_mr_tcam_route_create`, `function mlxsw_sp1_mr_tcam_route_destroy`.
- 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.