drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c- Extension
.c- Size
- 7174 bytes
- Lines
- 234
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/parman.hreg.hcore.hspectrum.hspectrum_acl_tcam.h
Detected Declarations
function mlxsw_sp_acl_ctcam_region_resizefunction mlxsw_sp_acl_ctcam_region_movefunction mlxsw_sp_acl_ctcam_region_entry_insertfunction mlxsw_sp_acl_ctcam_region_entry_removefunction mlxsw_sp_acl_ctcam_region_entry_action_replacefunction mlxsw_sp_acl_ctcam_region_parman_resizefunction mlxsw_sp_acl_ctcam_region_parman_movefunction mlxsw_sp_acl_ctcam_region_initfunction mlxsw_sp_acl_ctcam_region_finifunction mlxsw_sp_acl_ctcam_chunk_initfunction mlxsw_sp_acl_ctcam_chunk_finifunction mlxsw_sp_acl_ctcam_entry_addfunction mlxsw_sp_acl_ctcam_entry_delfunction mlxsw_sp_acl_ctcam_entry_action_replace
Annotated Snippet
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/parman.h>
#include "reg.h"
#include "core.h"
#include "spectrum.h"
#include "spectrum_acl_tcam.h"
static int
mlxsw_sp_acl_ctcam_region_resize(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam_region *region,
u16 new_size)
{
char ptar_pl[MLXSW_REG_PTAR_LEN];
mlxsw_reg_ptar_pack(ptar_pl, MLXSW_REG_PTAR_OP_RESIZE,
region->key_type, new_size, region->id,
region->tcam_region_info);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptar), ptar_pl);
}
static void
mlxsw_sp_acl_ctcam_region_move(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam_region *region,
u16 src_offset, u16 dst_offset, u16 size)
{
char prcr_pl[MLXSW_REG_PRCR_LEN];
mlxsw_reg_prcr_pack(prcr_pl, MLXSW_REG_PRCR_OP_MOVE,
region->tcam_region_info, src_offset,
region->tcam_region_info, dst_offset, size);
mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(prcr), prcr_pl);
}
static int
mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ctcam_region *cregion,
struct mlxsw_sp_acl_ctcam_entry *centry,
struct mlxsw_sp_acl_rule_info *rulei,
bool fillup_priority)
{
struct mlxsw_sp_acl_tcam_region *region = cregion->region;
struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl);
char ptce2_pl[MLXSW_REG_PTCE2_LEN];
char *act_set;
u32 priority;
char *mask;
char *key;
int err;
err = mlxsw_sp_acl_tcam_priority_get(mlxsw_sp, rulei, &priority,
fillup_priority);
if (err)
return err;
mlxsw_reg_ptce2_pack(ptce2_pl, true, MLXSW_REG_PTCE2_OP_WRITE_WRITE,
region->tcam_region_info,
centry->parman_item.index, priority);
key = mlxsw_reg_ptce2_flex_key_blocks_data(ptce2_pl);
mask = mlxsw_reg_ptce2_mask_data(ptce2_pl);
mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask);
err = cregion->ops->entry_insert(cregion, centry, mask);
if (err)
return err;
/* Only the first action set belongs here, the rest is in KVD */
act_set = mlxsw_afa_block_first_set(rulei->act_block);
mlxsw_reg_ptce2_flex_action_set_memcpy_to(ptce2_pl, act_set);
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce2), ptce2_pl);
if (err)
goto err_ptce2_write;
return 0;
err_ptce2_write:
cregion->ops->entry_remove(cregion, centry);
return err;
}
static void
mlxsw_sp_acl_ctcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ctcam_region *cregion,
struct mlxsw_sp_acl_ctcam_entry *centry)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/parman.h`, `reg.h`, `core.h`, `spectrum.h`, `spectrum_acl_tcam.h`.
- Detected declarations: `function mlxsw_sp_acl_ctcam_region_resize`, `function mlxsw_sp_acl_ctcam_region_move`, `function mlxsw_sp_acl_ctcam_region_entry_insert`, `function mlxsw_sp_acl_ctcam_region_entry_remove`, `function mlxsw_sp_acl_ctcam_region_entry_action_replace`, `function mlxsw_sp_acl_ctcam_region_parman_resize`, `function mlxsw_sp_acl_ctcam_region_parman_move`, `function mlxsw_sp_acl_ctcam_region_init`, `function mlxsw_sp_acl_ctcam_region_fini`, `function mlxsw_sp_acl_ctcam_chunk_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.