drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
Extension
.c
Size
30575 bytes
Lines
1168
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 mlx5e_psp_tx {
	struct mlx5_flow_namespace *ns;
	struct mlx5_flow_table *ft;
	struct mlx5_flow_group *fg;
	struct mlx5_flow_handle *rule;
	struct mutex mutex; /* Protect PSP TX steering */
	u32 refcnt;
	struct mlx5_fc *tx_counter;
};

struct mlx5e_psp_rx_err {
	struct mlx5_flow_table *ft;
	struct mlx5_flow_handle *rule;
	struct mlx5_flow_handle *auth_fail_rule;
	struct mlx5_flow_handle *err_rule;
	struct mlx5_flow_handle *bad_rule;
	struct mlx5_modify_hdr *copy_modify_hdr;
};

struct mlx5e_accel_fs_psp_prot {
	struct mlx5_flow_table *ft;
	struct mlx5_flow_group *miss_group;
	struct mlx5_flow_handle *miss_rule;
	struct mlx5_modify_hdr *rx_modify_hdr;
	struct mlx5_flow_destination default_dest;
	struct mlx5e_psp_rx_err rx_err;
	u32 refcnt;
	struct mutex prot_mutex; /* protect ESP4/ESP6 protocol */
	struct mlx5_flow_handle *def_rule;
};

struct mlx5e_accel_fs_psp {
	struct mlx5e_accel_fs_psp_prot fs_prot[ACCEL_FS_PSP_NUM_TYPES];
	struct mlx5_fc *rx_counter;
	struct mlx5_fc *rx_auth_fail_counter;
	struct mlx5_fc *rx_err_counter;
	struct mlx5_fc *rx_bad_counter;
};

struct mlx5e_psp_fs {
	struct mlx5_core_dev *mdev;
	struct mlx5e_psp_tx *tx_fs;
	/* Rx manage */
	struct mlx5e_flow_steering *fs;
	struct mlx5e_accel_fs_psp *rx_fs;
};

/* PSP RX flow steering */
static enum mlx5_traffic_types fs_psp2tt(enum accel_fs_psp_type i)
{
	if (i == ACCEL_FS_PSP4)
		return MLX5_TT_IPV4_UDP;

	return MLX5_TT_IPV6_UDP;
}

static void accel_psp_fs_rx_err_del_rules(struct mlx5e_psp_fs *fs,
					  struct mlx5e_psp_rx_err *rx_err)
{
	if (rx_err->bad_rule) {
		mlx5_del_flow_rules(rx_err->bad_rule);
		rx_err->bad_rule = NULL;
	}

	if (rx_err->err_rule) {
		mlx5_del_flow_rules(rx_err->err_rule);
		rx_err->err_rule = NULL;
	}

	if (rx_err->auth_fail_rule) {
		mlx5_del_flow_rules(rx_err->auth_fail_rule);
		rx_err->auth_fail_rule = NULL;
	}

	if (rx_err->rule) {
		mlx5_del_flow_rules(rx_err->rule);
		rx_err->rule = NULL;
	}

	if (rx_err->copy_modify_hdr) {
		mlx5_modify_header_dealloc(fs->mdev, rx_err->copy_modify_hdr);
		rx_err->copy_modify_hdr = NULL;
	}
}

static void accel_psp_fs_rx_err_destroy_ft(struct mlx5e_psp_fs *fs,
					   struct mlx5e_psp_rx_err *rx_err)
{
	accel_psp_fs_rx_err_del_rules(fs, rx_err);

Annotation

Implementation Notes