drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c
Extension
.c
Size
19746 bytes
Lines
645
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mlxsw_sp_acl_atcam_lkey_id_ht_key {
	char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* MSB blocks */
	u8 erp_id;
};

struct mlxsw_sp_acl_atcam_lkey_id {
	struct rhash_head ht_node;
	struct mlxsw_sp_acl_atcam_lkey_id_ht_key ht_key;
	refcount_t refcnt;
	u32 id;
};

struct mlxsw_sp_acl_atcam_region_ops {
	int (*init)(struct mlxsw_sp_acl_atcam_region *aregion);
	void (*fini)(struct mlxsw_sp_acl_atcam_region *aregion);
	struct mlxsw_sp_acl_atcam_lkey_id *
		(*lkey_id_get)(struct mlxsw_sp_acl_atcam_region *aregion,
			       char *enc_key, u8 erp_id);
	void (*lkey_id_put)(struct mlxsw_sp_acl_atcam_region *aregion,
			    struct mlxsw_sp_acl_atcam_lkey_id *lkey_id);
};

struct mlxsw_sp_acl_atcam_region_generic {
	struct mlxsw_sp_acl_atcam_lkey_id dummy_lkey_id;
};

struct mlxsw_sp_acl_atcam_region_12kb {
	struct rhashtable lkey_ht;
	unsigned int max_lkey_id;
	unsigned long *used_lkey_id;
};

static const struct rhashtable_params mlxsw_sp_acl_atcam_lkey_id_ht_params = {
	.key_len = sizeof(struct mlxsw_sp_acl_atcam_lkey_id_ht_key),
	.key_offset = offsetof(struct mlxsw_sp_acl_atcam_lkey_id, ht_key),
	.head_offset = offsetof(struct mlxsw_sp_acl_atcam_lkey_id, ht_node),
};

static const struct rhashtable_params mlxsw_sp_acl_atcam_entries_ht_params = {
	.key_len = sizeof(struct mlxsw_sp_acl_atcam_entry_ht_key),
	.key_offset = offsetof(struct mlxsw_sp_acl_atcam_entry, ht_key),
	.head_offset = offsetof(struct mlxsw_sp_acl_atcam_entry, ht_node),
};

static bool
mlxsw_sp_acl_atcam_is_centry(const struct mlxsw_sp_acl_atcam_entry *aentry)
{
	return mlxsw_sp_acl_erp_mask_is_ctcam(aentry->erp_mask);
}

static int
mlxsw_sp_acl_atcam_region_generic_init(struct mlxsw_sp_acl_atcam_region *aregion)
{
	struct mlxsw_sp_acl_atcam_region_generic *region_generic;

	region_generic = kzalloc_obj(*region_generic);
	if (!region_generic)
		return -ENOMEM;

	refcount_set(&region_generic->dummy_lkey_id.refcnt, 1);
	aregion->priv = region_generic;

	return 0;
}

static void
mlxsw_sp_acl_atcam_region_generic_fini(struct mlxsw_sp_acl_atcam_region *aregion)
{
	kfree(aregion->priv);
}

static struct mlxsw_sp_acl_atcam_lkey_id *
mlxsw_sp_acl_atcam_generic_lkey_id_get(struct mlxsw_sp_acl_atcam_region *aregion,
				       char *enc_key, u8 erp_id)
{
	struct mlxsw_sp_acl_atcam_region_generic *region_generic;

	region_generic = aregion->priv;
	return &region_generic->dummy_lkey_id;
}

static void
mlxsw_sp_acl_atcam_generic_lkey_id_put(struct mlxsw_sp_acl_atcam_region *aregion,
				       struct mlxsw_sp_acl_atcam_lkey_id *lkey_id)
{
}

static const struct mlxsw_sp_acl_atcam_region_ops
mlxsw_sp_acl_atcam_region_generic_ops = {
	.init		= mlxsw_sp_acl_atcam_region_generic_init,

Annotation

Implementation Notes