Commit 3da895b2 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-mlx5-hws-set-of-fixes-and-adjustments'

Tariq Toukan says:

====================
net/mlx5: HWS, set of fixes and adjustments

This patch series by Yevgeny and Vlad introduces a set of steering fixes
and adjustments.
====================

Link: https://patch.msgid.link/1747766802-958178-1-git-send-email-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 945301db 01e035fd
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -527,7 +527,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
	struct mlx5_flow_rule *dst;
	void *in_flow_context, *vlan;
	void *in_match_value;
	int reformat_id = 0;
	u32 reformat_id = 0;
	unsigned int inlen;
	int dst_cnt_size;
	u32 *in, action;
@@ -580,23 +580,21 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
	MLX5_SET(flow_context, in_flow_context, action, action);

	if (!extended_dest && fte->act_dests.action.pkt_reformat) {
		struct mlx5_pkt_reformat *pkt_reformat = fte->act_dests.action.pkt_reformat;
		struct mlx5_pkt_reformat *pkt_reformat =
			fte->act_dests.action.pkt_reformat;

		if (pkt_reformat->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
			reformat_id = mlx5_fs_dr_action_get_pkt_reformat_id(pkt_reformat);
			if (reformat_id < 0) {
		err = mlx5_fs_get_packet_reformat_id(pkt_reformat,
						     &reformat_id);
		if (err) {
			mlx5_core_err(dev,
					      "Unsupported SW-owned pkt_reformat type (%d) in FW-owned table\n",
				      "Unsupported pkt_reformat type (%d)\n",
				      pkt_reformat->reformat_type);
				err = reformat_id;
			goto err_out;
		}
		} else {
			reformat_id = fte->act_dests.action.pkt_reformat->id;
		}
	}

	MLX5_SET(flow_context, in_flow_context, packet_reformat_id, (u32)reformat_id);
	MLX5_SET(flow_context, in_flow_context, packet_reformat_id,
		 reformat_id);

	if (fte->act_dests.action.modify_hdr) {
		if (fte->act_dests.action.modify_hdr->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
+26 −5
Original line number Diff line number Diff line
@@ -1830,14 +1830,35 @@ static int create_auto_flow_group(struct mlx5_flow_table *ft,
	return err;
}

int mlx5_fs_get_packet_reformat_id(struct mlx5_pkt_reformat *pkt_reformat,
				   u32 *id)
{
	switch (pkt_reformat->owner) {
	case MLX5_FLOW_RESOURCE_OWNER_FW:
		*id = pkt_reformat->id;
		return 0;
	case MLX5_FLOW_RESOURCE_OWNER_SW:
		return mlx5_fs_dr_action_get_pkt_reformat_id(pkt_reformat, id);
	case MLX5_FLOW_RESOURCE_OWNER_HWS:
		return mlx5_fs_hws_action_get_pkt_reformat_id(pkt_reformat, id);
	default:
		return -EINVAL;
	}
}

static bool mlx5_pkt_reformat_cmp(struct mlx5_pkt_reformat *p1,
				  struct mlx5_pkt_reformat *p2)
{
	return p1->owner == p2->owner &&
		(p1->owner == MLX5_FLOW_RESOURCE_OWNER_FW ?
		 p1->id == p2->id :
		 mlx5_fs_dr_action_get_pkt_reformat_id(p1) ==
		 mlx5_fs_dr_action_get_pkt_reformat_id(p2));
	int err1, err2;
	u32 id1, id2;

	if (p1->owner != p2->owner)
		return false;

	err1 = mlx5_fs_get_packet_reformat_id(p1, &id1);
	err2 = mlx5_fs_get_packet_reformat_id(p2, &id2);

	return !err1 && !err2 && id1 == id2;
}

static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ struct mlx5_flow_definer {
enum mlx5_flow_resource_owner {
	MLX5_FLOW_RESOURCE_OWNER_FW,
	MLX5_FLOW_RESOURCE_OWNER_SW,
	MLX5_FLOW_RESOURCE_OWNER_HWS,
};

struct mlx5_modify_hdr {
@@ -386,6 +387,9 @@ u32 mlx5_fs_get_capabilities(struct mlx5_core_dev *dev, enum mlx5_flow_namespace

struct mlx5_flow_root_namespace *find_root(struct fs_node *node);

int mlx5_fs_get_packet_reformat_id(struct mlx5_pkt_reformat *pkt_reformat,
				   u32 *id);

#define fs_get_obj(v, _node)  {v = container_of((_node), typeof(*v), node); }

#define fs_list_for_each_entry(pos, root)		\
+43 −28
Original line number Diff line number Diff line
@@ -72,6 +72,11 @@ enum mlx5hws_action_type mlx5hws_action_get_type(struct mlx5hws_action *action)
	return action->type;
}

struct mlx5_core_dev *mlx5hws_action_get_dev(struct mlx5hws_action *action)
{
	return action->ctx->mdev;
}

static int hws_action_get_shared_stc_nic(struct mlx5hws_context *ctx,
					 enum mlx5hws_context_shared_stc_type stc_type,
					 u8 tbl_type)
@@ -1185,14 +1190,15 @@ hws_action_create_modify_header_hws(struct mlx5hws_action *action,
				    struct mlx5hws_action_mh_pattern *pattern,
				    u32 log_bulk_size)
{
	u16 num_actions, max_mh_actions = 0, hw_max_actions;
	struct mlx5hws_context *ctx = action->ctx;
	u16 num_actions, max_mh_actions = 0;
	int i, ret, size_in_bytes;
	u32 pat_id, arg_id = 0;
	__be64 *new_pattern;
	size_t pat_max_sz;

	pat_max_sz = MLX5HWS_ARG_CHUNK_SIZE_MAX * MLX5HWS_ARG_DATA_SIZE;
	hw_max_actions = pat_max_sz / MLX5HWS_MODIFY_ACTION_SIZE;
	size_in_bytes = pat_max_sz * sizeof(__be64);
	new_pattern = kcalloc(num_of_patterns, size_in_bytes, GFP_KERNEL);
	if (!new_pattern)
@@ -1202,16 +1208,20 @@ hws_action_create_modify_header_hws(struct mlx5hws_action *action,
	for (i = 0; i < num_of_patterns; i++) {
		size_t new_num_actions;
		size_t cur_num_actions;
		u32 nope_location;
		u32 nop_locations;

		cur_num_actions = pattern[i].sz / MLX5HWS_MODIFY_ACTION_SIZE;

		mlx5hws_pat_calc_nope(pattern[i].data, cur_num_actions,
				      pat_max_sz / MLX5HWS_MODIFY_ACTION_SIZE,
				      &new_num_actions, &nope_location,
		ret = mlx5hws_pat_calc_nop(pattern[i].data, cur_num_actions,
					   hw_max_actions, &new_num_actions,
					   &nop_locations,
					   &new_pattern[i * pat_max_sz]);
		if (ret) {
			mlx5hws_err(ctx, "Too many actions after nop insertion\n");
			goto free_new_pat;
		}

		action[i].modify_header.nope_locations = nope_location;
		action[i].modify_header.nop_locations = nop_locations;
		action[i].modify_header.num_of_actions = new_num_actions;

		max_mh_actions = max(max_mh_actions, new_num_actions);
@@ -1258,7 +1268,7 @@ hws_action_create_modify_header_hws(struct mlx5hws_action *action,
				MLX5_GET(set_action_in, pattern[i].data, action_type);
		} else {
			/* Multiple modify actions require a pattern */
			if (unlikely(action[i].modify_header.nope_locations)) {
			if (unlikely(action[i].modify_header.nop_locations)) {
				size_t pattern_sz;

				pattern_sz = action[i].modify_header.num_of_actions *
@@ -2100,21 +2110,23 @@ static void hws_action_modify_write(struct mlx5hws_send_engine *queue,
				    u32 arg_idx,
				    u8 *arg_data,
				    u16 num_of_actions,
				    u32 nope_locations)
				    u32 nop_locations)
{
	u8 *new_arg_data = NULL;
	int i, j;

	if (unlikely(nope_locations)) {
	if (unlikely(nop_locations)) {
		new_arg_data = kcalloc(num_of_actions,
				       MLX5HWS_MODIFY_ACTION_SIZE, GFP_KERNEL);
		if (unlikely(!new_arg_data))
			return;

		for (i = 0, j = 0; i < num_of_actions; i++, j++) {
			memcpy(&new_arg_data[j], arg_data, MLX5HWS_MODIFY_ACTION_SIZE);
			if (BIT(i) & nope_locations)
		for (i = 0, j = 0; j < num_of_actions; i++, j++) {
			if (BIT(i) & nop_locations)
				j++;
			memcpy(&new_arg_data[j * MLX5HWS_MODIFY_ACTION_SIZE],
			       &arg_data[i * MLX5HWS_MODIFY_ACTION_SIZE],
			       MLX5HWS_MODIFY_ACTION_SIZE);
		}
	}

@@ -2210,6 +2222,7 @@ hws_action_setter_modify_header(struct mlx5hws_actions_apply_data *apply,
	struct mlx5hws_action *action;
	u32 arg_sz, arg_idx;
	u8 *single_action;
	u8 max_actions;
	__be32 stc_idx;

	rule_action = &apply->rule_action[setter->idx_double];
@@ -2237,9 +2250,12 @@ hws_action_setter_modify_header(struct mlx5hws_actions_apply_data *apply,

		apply->wqe_data[MLX5HWS_ACTION_OFFSET_DW7] =
			*(__be32 *)MLX5_ADDR_OF(set_action_in, single_action, data);
	} else {
		return;
	}

	/* Argument offset multiple with number of args per these actions */
		arg_sz = mlx5hws_arg_get_arg_size(action->modify_header.max_num_of_actions);
	max_actions = action->modify_header.max_num_of_actions;
	arg_sz = mlx5hws_arg_get_arg_size(max_actions);
	arg_idx = rule_action->modify_header.offset * arg_sz;

	apply->wqe_data[MLX5HWS_ACTION_OFFSET_DW7] = htonl(arg_idx);
@@ -2250,8 +2266,7 @@ hws_action_setter_modify_header(struct mlx5hws_actions_apply_data *apply,
					action->modify_header.arg_id + arg_idx,
					rule_action->modify_header.data,
					action->modify_header.num_of_actions,
						action->modify_header.nope_locations);
		}
					action->modify_header.nop_locations);
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ struct mlx5hws_action {
					u32 pat_id;
					u32 arg_id;
					__be64 single_action;
					u32 nope_locations;
					u32 nop_locations;
					u8 num_of_patterns;
					u8 single_action_type;
					u8 num_of_actions;
Loading