drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c

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

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c
Extension
.c
Size
24338 bytes
Lines
886
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 mlx5_ipsec_miss {
	struct mlx5_flow_group *group;
	struct mlx5_flow_handle *rule;
};

struct mlx5_ipsec_rx_roce {
	struct mlx5_flow_group *g;
	struct mlx5_flow_table *ft;
	struct mlx5_flow_handle *rule;
	struct mlx5_ipsec_miss roce_miss;
	struct mlx5_flow_table *nic_master_ft;
	struct mlx5_flow_group *nic_master_group;
	struct mlx5_flow_handle *nic_master_rule;
	struct mlx5_flow_table *goto_alias_ft;
	u32 alias_id;
	char key[ACCESS_KEY_LEN];

	struct mlx5_flow_table *ft_rdma;
	struct mlx5_flow_namespace *ns_rdma;
};

struct mlx5_ipsec_tx_roce {
	struct mlx5_flow_group *g;
	struct mlx5_flow_table *ft;
	struct mlx5_flow_handle *rule;
	struct mlx5_flow_table *goto_alias_ft;
	u32 alias_id;
	char key[ACCESS_KEY_LEN];
	struct mlx5_flow_namespace *ns;
};

struct mlx5_ipsec_fs {
	struct mlx5_ipsec_rx_roce ipv4_rx;
	struct mlx5_ipsec_rx_roce ipv6_rx;
	struct mlx5_ipsec_tx_roce tx;
	struct mlx5_devcom_comp_dev **devcom;
};

static void ipsec_fs_roce_setup_udp_dport(struct mlx5_flow_spec *spec,
					  u16 dport)
{
	spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS;
	MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.ip_protocol);
	MLX5_SET(fte_match_param, spec->match_value, outer_headers.ip_protocol, IPPROTO_UDP);
	MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.udp_dport);
	MLX5_SET(fte_match_param, spec->match_value, outer_headers.udp_dport, dport);
}

static bool ipsec_fs_create_alias_supported_one(struct mlx5_core_dev *mdev)
{
	u64 obj_allowed = MLX5_CAP_GEN_2_64(mdev, allowed_object_for_other_vhca_access);
	u32 obj_supp = MLX5_CAP_GEN_2(mdev, cross_vhca_object_to_object_supported);

	if (!(obj_supp &
	    MLX5_CROSS_VHCA_OBJ_TO_OBJ_SUPPORTED_LOCAL_FLOW_TABLE_TO_REMOTE_FLOW_TABLE_MISS))
		return false;

	if (!(obj_allowed & MLX5_ALLOWED_OBJ_FOR_OTHER_VHCA_ACCESS_FLOW_TABLE))
		return false;

	return true;
}

static bool ipsec_fs_create_alias_supported(struct mlx5_core_dev *mdev,
					    struct mlx5_core_dev *master_mdev)
{
	if (ipsec_fs_create_alias_supported_one(mdev) &&
	    ipsec_fs_create_alias_supported_one(master_mdev))
		return true;

	return false;
}

static int ipsec_fs_create_aliased_ft(struct mlx5_core_dev *ibv_owner,
				      struct mlx5_core_dev *ibv_allowed,
				      struct mlx5_flow_table *ft,
				      u32 *obj_id, char *alias_key, bool from_event)
{
	u32 aliased_object_id = (ft->type << FT_ID_FT_TYPE_OFFSET) | ft->id;
	u16 vhca_id_to_be_accessed = MLX5_CAP_GEN(ibv_owner, vhca_id);
	struct mlx5_cmd_allow_other_vhca_access_attr allow_attr = {};
	struct mlx5_cmd_alias_obj_create_attr alias_attr = {};
	int ret;
	int i;

	if (!ipsec_fs_create_alias_supported(ibv_owner, ibv_allowed))
		return -EOPNOTSUPP;

	for (i = 0; i < ACCESS_KEY_LEN; i++)
		if (!from_event)

Annotation

Implementation Notes