From nobody Wed Nov 15 23:09:05 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SVzPZ2tL8z50rns; Wed, 15 Nov 2023 23:09:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SVzPZ0FJZz3MqM; Wed, 15 Nov 2023 23:09:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2EBPqSz9bjzDkcd3ObgSCFKWfP7vyxCAccDTFjK/4jc=; b=jswKCckpxCpomt7P2IMfEW0EPL3Q4TfQWX6nnlxCxXj2d0o06r3aPO8t63ngMMFvHo6RPl 0wiamLpz64vfB5mJeuCNw/PvmScENZotc2IVSOqgpCA9cqzBPQwB3dGnIimPsqgBlDs9J5 IZIYwZp5h05c+5bLeHDn8HiL8RG88n2gPdaIE2swq9N7nb+LFZ0j9kVZx5DP5DgxsWc6QW XUn0cSRW0bhKh+lqhw42eUB20SzsUREjDIJICznSeVKtjWrqjCQZ6OeUZxC7Ty+AEun/gl wrpXCjRBevCgdaIPEJbEbSZQ3PpDM+cy3yL81GcAaw05GnqEvtFQPwRD4eks2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2EBPqSz9bjzDkcd3ObgSCFKWfP7vyxCAccDTFjK/4jc=; b=P8yjDzENBbV0Khc2V2Tpsqh8cpZfyyn6kbgvSKH+1++Ajmbg0YA88O4hBbTa4VoenPohny 24PMTKOCVCdXCpOcBv8Q/mNV8JMYetuacEjG+cwIUP0qI1OYf2m9UwuygUkzKyWkmFukWl ExrOSSABi0G3H16HlZ4uOWwK5ABBFwXxIWjRj6miS5gN/CdwEN0TezBeNddHpip0xwYF1s ep2Gtw0xZMkh4gF0hj07C2z1s8fr/F5zZDlRGDo8WmxCI2DaOXxtdy8FdMldxb/JCauP2l 2tACALHzbIIOKN6o3iJSHUDCA8V3sqU56FomFrZsdvKLeD3BI1mEg+GKeKeFfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700089746; a=rsa-sha256; cv=none; b=gkiHsgfzexWfR2Afvx+5U4CyCSGSugPKe4C81yjs1Bp6p6k0mwyia2lKVr5yxNz4W/hvN8 pWL70WMe958xBURXCuN/Cs/OR/srEIqa6qzTwi2O70tAXbRYR7TWN+KIrgPs/g8BiHKI37 ZDozH9jku5HCqr+f/cqdqDbixf4wfWIlmgmlc/79ut3VAZ7PnuK9R80iGBlQUrDuvufuvn Xn/0BWAM9xdjS5vkDBivbQKWC1KASdU1bDeo3aY25Ky6f2z/q55AVxOsLDI8zv/xy5jjUB 5pnauM1p/V53PUKTqKNaa0uPf7RLUdDrPqTDBYj1mFYPa/CjeUcUGqauMfLzHQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SVzPY6SdVzbqf; Wed, 15 Nov 2023 23:09:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AFN95qB064597; Wed, 15 Nov 2023 23:09:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AFN957m064594; Wed, 15 Nov 2023 23:09:05 GMT (envelope-from git) Date: Wed, 15 Nov 2023 23:09:05 GMT Message-Id: <202311152309.3AFN957m064594@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: cb054a493a95 - main - mlx5: Refactor flow actions into a struct List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cb054a493a95cbd5a4b00c693c3924622914c51a Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cb054a493a95cbd5a4b00c693c3924622914c51a commit cb054a493a95cbd5a4b00c693c3924622914c51a Author: Mark Bloch AuthorDate: 2023-02-19 10:47:50 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-15 23:08:16 +0000 mlx5: Refactor flow actions into a struct Create a struct to hold flow actions to be used when creating a flow rule. Signed-off-by: Mark Bloch Sponsored by: NVidia networking MFC after: 1 week --- sys/dev/mlx5/fs.h | 11 ++++- sys/dev/mlx5/mlx5_core/fs_core.h | 4 +- sys/dev/mlx5/mlx5_core/mlx5_eswitch.c | 11 +++-- sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 5 ++- sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c | 12 +++++- sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 58 +++++++++++++++++-------- sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c | 70 ++++++++++++++++++++----------- sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c | 6 ++- 8 files changed, 123 insertions(+), 54 deletions(-) diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h index 81384b43131d..7ed7a5380cf1 100644 --- a/sys/dev/mlx5/fs.h +++ b/sys/dev/mlx5/fs.h @@ -82,6 +82,15 @@ struct mlx5_flow_destination { }; }; +enum mlx5_flow_act_actions { + MLX5_FLOW_ACT_ACTIONS_FLOW_TAG = 1 << 0, +}; + +struct mlx5_flow_act { + u32 actions; /* See enum mlx5_flow_act_actions */ + u32 flow_tag; +}; + #define FT_NAME_STR_SZ 20 #define LEFTOVERS_RULE_NUM 2 static inline void build_leftovers_ft_param(char *name, @@ -154,7 +163,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, u32 *match_criteria, u32 *match_value, u32 action, - u32 flow_tag, + struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest); void mlx5_del_flow_rule(struct mlx5_flow_rule **); diff --git a/sys/dev/mlx5/mlx5_core/fs_core.h b/sys/dev/mlx5/mlx5_core/fs_core.h index bd7aade07876..40c6cadf3223 100644 --- a/sys/dev/mlx5/mlx5_core/fs_core.h +++ b/sys/dev/mlx5/mlx5_core/fs_core.h @@ -78,9 +78,9 @@ struct fs_fte { struct fs_base base; u32 val[MLX5_ST_SZ_DW(fte_match_param)]; uint32_t dests_size; - uint32_t flow_tag; struct list_head dests; uint32_t index; /* index in ft */ + struct mlx5_flow_act flow_act; u8 action; /* MLX5_FLOW_CONTEXT_ACTION */ enum fs_fte_status status; }; @@ -290,7 +290,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, u32 *match_val, enum fs_ft_type type, unsigned int table_id, unsigned int index, unsigned int group_id, - unsigned int flow_tag, + struct mlx5_flow_act *flow_act, unsigned short action, int dest_size, struct list_head *dests); /* mlx5_flow_desination */ diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c index 16e25df2b7ab..9f9350e0260b 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c @@ -221,6 +221,7 @@ esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport) int match_header = MLX5_MATCH_OUTER_HEADERS; struct mlx5_flow_destination dest; struct mlx5_flow_rule *flow_rule = NULL; + struct mlx5_flow_act flow_act = {}; u32 *match_v; u32 *match_c; u8 *dmac_v; @@ -253,7 +254,7 @@ esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport) match_c, match_v, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - 0, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(flow_rule)) { printf("mlx5_core: WARN: ""FDB: Failed to add flow rule: dmac_v(%pM) dmac_c(%pM) -> vport(%d), err(%ld)\n", dmac_v, dmac_c, vport, PTR_ERR(flow_rule)); flow_rule = NULL; @@ -783,6 +784,7 @@ static void esw_vport_disable_ingress_acl(struct mlx5_eswitch *esw, static int esw_vport_ingress_config(struct mlx5_eswitch *esw, struct mlx5_vport *vport) { + struct mlx5_flow_act flow_act = {}; struct mlx5_flow_destination dest; u32 *match_v; u32 *match_c; @@ -824,7 +826,7 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, match_c, match_v, MLX5_FLOW_CONTEXT_ACTION_DROP, - 0, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(vport->ingress.drop_rule)) { err = PTR_ERR(vport->ingress.drop_rule); printf("mlx5_core: WARN: ""vport[%d] configure ingress rules, err(%d)\n", vport->vport, err); @@ -839,6 +841,7 @@ out: static int esw_vport_egress_config(struct mlx5_eswitch *esw, struct mlx5_vport *vport) { + struct mlx5_flow_act flow_act = {}; struct mlx5_flow_destination dest; u32 *match_v; u32 *match_c; @@ -883,7 +886,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, match_c, match_v, MLX5_FLOW_CONTEXT_ACTION_ALLOW, - 0, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(vport->egress.allowed_vlan)) { err = PTR_ERR(vport->egress.allowed_vlan); printf("mlx5_core: WARN: ""vport[%d] configure egress allowed vlan rule failed, err(%d)\n", vport->vport, err); @@ -900,7 +903,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, match_c, match_v, MLX5_FLOW_CONTEXT_ACTION_DROP, - 0, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(vport->egress.drop_rule)) { err = PTR_ERR(vport->egress.drop_rule); printf("mlx5_core: WARN: ""vport[%d] configure egress drop rule failed, err(%d)\n", vport->vport, err); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c index 7dcd32ed0c44..5ac0c95c7bca 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -164,7 +164,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, u32 *match_val, enum fs_ft_type type, unsigned int table_id, unsigned int index, unsigned int group_id, - unsigned int flow_tag, + struct mlx5_flow_act *flow_act, unsigned short action, int dest_size, struct list_head *dests) /* mlx5_flow_desination */ { @@ -219,7 +219,8 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); MLX5_SET(flow_context, in_flow_context, group_id, group_id); - MLX5_SET(flow_context, in_flow_context, flow_tag, flow_tag); + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_FLOW_TAG) + MLX5_SET(flow_context, in_flow_context, flow_tag, flow_act->flow_tag); MLX5_SET(flow_context, in_flow_context, action, action); MLX5_SET(flow_context, in_flow_context, destination_list_size, dest_size); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c index 2bdf01081650..69df9ecba210 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c @@ -98,6 +98,10 @@ mlx5e_accel_fs_add_inpcb(struct mlx5e_priv *priv, #endif struct mlx5_flow_rule *flow; struct mlx5_flow_spec *spec; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = flow_tag, + }; spec = kvzalloc(sizeof(*spec), GFP_KERNEL); if (!spec) @@ -161,7 +165,7 @@ mlx5e_accel_fs_add_inpcb(struct mlx5e_priv *priv, spec->match_criteria, spec->match_value, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - flow_tag, + &flow_act, &dest); out: kvfree(spec); @@ -176,6 +180,10 @@ accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv, int type) struct mlx5_flow_destination dest = {}; struct mlx5e_accel_fs_tcp *fs_tcp; struct mlx5_flow_rule *rule; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_DEFAULT_FLOW_TAG, + }; fs_tcp = &priv->fts.accel_tcp; @@ -192,7 +200,7 @@ accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv, int type) priv->fts.vlan.t : fs_tcp->tables[type + 1].t; rule = mlx5_add_flow_rule(fs_tcp->tables[type].t, 0, match_criteria, match_value, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_DEFAULT_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR(rule)) return (PTR_ERR(rule)); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 358eb671de5a..8e203a9662bb 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -303,7 +303,7 @@ static void fs_remove_node_parent_locked(struct fs_base *node) } static struct fs_fte *fs_alloc_fte(u8 action, - u32 flow_tag, + struct mlx5_flow_act *flow_act, u32 *match_value, unsigned int index) { @@ -317,9 +317,9 @@ static struct fs_fte *fs_alloc_fte(u8 action, memcpy(fte->val, match_value, sizeof(fte->val)); fte->base.type = FS_TYPE_FLOW_ENTRY; fte->dests_size = 0; - fte->flow_tag = flow_tag; fte->index = index; INIT_LIST_HEAD(&fte->dests); + fte->flow_act = *flow_act; fte->action = action; return fte; @@ -333,12 +333,16 @@ static struct fs_fte *alloc_star_ft_entry(struct mlx5_flow_table *ft, int err; struct fs_fte *fte; struct mlx5_flow_rule *dst; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_DEFAULT_FLOW_TAG, + }; if (fg->num_ftes == fg->max_ftes) return ERR_PTR(-ENOSPC); fte = fs_alloc_fte(MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_DEFAULT_FLOW_TAG, match_value, index); + &flow_act, match_value, index); if (IS_ERR(fte)) return fte; @@ -442,7 +446,7 @@ static int fs_set_star_rule(struct mlx5_core_dev *dev, match_value, src_ft->type, src_ft->id, src_fte->index, src_ft->star_rule.fg->id, - src_fte->flow_tag, + &src_fte->flow_act, src_fte->action, src_fte->dests_size, &src_fte->dests); @@ -1583,7 +1587,7 @@ static struct mlx5_flow_rule *_fs_add_dst_fte(struct fs_fte *fte, ft->vport, &fte->status, fte->val, ft->type, - ft->id, fte->index, fg->id, fte->flow_tag, + ft->id, fte->index, fg->id, &fte->flow_act, fte->action, fte->dests_size, &fte->dests); if (err) goto free_dst; @@ -1647,14 +1651,14 @@ static unsigned int fs_get_free_fg_index(struct mlx5_flow_group *fg, static struct fs_fte *fs_create_fte(struct mlx5_flow_group *fg, u32 *match_value, u8 action, - u32 flow_tag, + struct mlx5_flow_act *flow_act, struct list_head **prev) { struct fs_fte *fte; int index = 0; index = fs_get_free_fg_index(fg, prev); - fte = fs_alloc_fte(action, flow_tag, match_value, index); + fte = fs_alloc_fte(action, flow_act, match_value, index); if (IS_ERR(fte)) return fte; @@ -1704,7 +1708,7 @@ static void fs_del_dst(struct mlx5_flow_rule *dst) err = mlx5_cmd_fs_set_fte(dev, ft->vport, &fte->status, match_value, ft->type, ft->id, fte->index, fg->id, - fte->flow_tag, fte->action, + &fte->flow_act, fte->action, fte->dests_size, &fte->dests); if (err) { mlx5_core_warn(dev, "%s can't delete dst %s\n", @@ -1740,12 +1744,31 @@ static void fs_del_fte(struct fs_fte *fte) fg->num_ftes--; } +static bool check_conflicting_actions(const struct mlx5_flow_act *act1, + const struct mlx5_flow_act *act2) +{ + u32 action1 = act1->actions; + u32 action2 = act2->actions; + u32 xored_actions; + + xored_actions = action1 ^ action2; + + if (xored_actions & (MLX5_FLOW_ACT_ACTIONS_FLOW_TAG)) + return true; + + if (action1 & MLX5_FLOW_ACT_ACTIONS_FLOW_TAG && + act1->flow_tag != act2->flow_tag) + return true; + + return false; +} + /* assuming parent fg is locked */ /* Add dst algorithm */ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, u32 *match_value, u8 action, - u32 flow_tag, + struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { struct fs_fte *fte; @@ -1759,7 +1782,8 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, /* TODO: Check of size against PRM max size */ mutex_lock(&fte->base.lock); if (fs_match_exact_val(&fg->mask, match_value, &fte->val) && - action == fte->action && flow_tag == fte->flow_tag) { + action == fte->action && + !check_conflicting_actions(flow_act, &fte->flow_act)) { dst = _fs_add_dst_fte(fte, fg, dest); mutex_unlock(&fte->base.lock); if (IS_ERR(dst)) @@ -1775,7 +1799,7 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, goto unlock_fg; } - fte = fs_create_fte(fg, match_value, action, flow_tag, &prev); + fte = fs_create_fte(fg, match_value, action, flow_act, &prev); if (IS_ERR(fte)) { dst = (void *)fte; goto unlock_fg; @@ -1803,7 +1827,8 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, u8 match_criteria_enable, u32 *match_criteria, u32 *match_value, - u8 action, u32 flow_tag, + u8 action, + struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { /*? where dst_entry is allocated*/ @@ -1819,8 +1844,7 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, match_criteria)) { mutex_unlock(&ft->base.lock); - dst = fs_add_dst_fg(g, match_value, - action, flow_tag, dest); + dst = fs_add_dst_fg(g, match_value, action, flow_act, dest); if (PTR_ERR(dst) && PTR_ERR(dst) != -ENOSPC) goto unlock; } @@ -1833,7 +1857,7 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, } dst = fs_add_dst_fg(g, match_value, - action, flow_tag, dest); + action, flow_act, dest); if (IS_ERR(dst)) { /* Remove assumes refcount > 0 and autogroup creates a group * with a refcount = 0. @@ -1854,7 +1878,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, u32 *match_criteria, u32 *match_value, u32 action, - u32 flow_tag, + struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { struct mlx5_flow_rule *dst; @@ -1864,7 +1888,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, if (ns) down_read(&ns->dests_rw_sem); dst = fs_add_dst_ft(ft, match_criteria_enable, match_criteria, - match_value, action, flow_tag, dest); + match_value, action, flow_act, dest); if (ns) up_read(&ns->dests_rw_sem); diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c index 8167c3062100..cb23b80deae4 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c @@ -261,6 +261,10 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, u32 *tirn = priv->tirn; u32 tt_vec; int err = 0; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_ETH_FLOW_TAG, + }; dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; @@ -290,7 +294,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, dest.tir_num = tirn[MLX5E_TT_ANY]; *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -305,7 +309,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -317,7 +321,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -332,7 +336,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -344,7 +348,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -358,7 +362,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -370,7 +374,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -384,7 +388,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -396,7 +400,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -410,7 +414,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -422,7 +426,7 @@ mlx5e_add_eth_addr_rule_sub(struct mlx5e_priv *priv, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, &dest); + &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; } @@ -486,6 +490,10 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) struct mlx5_flow_rule **rule_p; struct mlx5_flow_table *ft = priv->fts.main_vxlan.t; u32 *tirn = priv->tirn_inner_vxlan; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_ETH_FLOW_TAG, + }; int err = 0; dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; @@ -497,7 +505,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV4]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -505,7 +513,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV6]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -516,7 +524,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV4_UDP]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -524,7 +532,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV6_UDP]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -534,7 +542,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV4_TCP]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -542,7 +550,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV6_TCP]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -552,7 +560,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV4_IPSEC_AH]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -560,7 +568,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV6_IPSEC_AH]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -570,7 +578,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) dest.tir_num = tirn[MLX5E_TT_IPV4_IPSEC_ESP]; MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IP); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -579,7 +587,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) MLX5_SET(fte_match_param, mv, inner_headers.ethertype, ETHERTYPE_IPV6); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -589,7 +597,7 @@ mlx5e_add_main_vxlan_rules_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) rule_p = &priv->fts.main_vxlan_rule[MLX5E_TT_ANY]; dest.tir_num = tirn[MLX5E_TT_ANY]; *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(*rule_p)) goto err_del_ai; @@ -686,6 +694,10 @@ mlx5e_add_vlan_rule_sub(struct mlx5e_priv *priv, u8 mc_enable = 0; struct mlx5_flow_rule **rule_p; int err = 0; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_ETH_FLOW_TAG, + }; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.ft = priv->fts.vxlan.t; @@ -719,7 +731,7 @@ mlx5e_add_vlan_rule_sub(struct mlx5e_priv *priv, *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, - MLX5_FS_ETH_FLOW_TAG, + &flow_act, &dest); if (IS_ERR(*rule_p)) { @@ -1679,6 +1691,10 @@ mlx5e_add_vxlan_rule_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv, u8 mc_enable; struct mlx5_flow_rule **rule_p; int err = 0; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_ETH_FLOW_TAG, + }; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.ft = priv->fts.main_vxlan.t; @@ -1693,7 +1709,7 @@ mlx5e_add_vxlan_rule_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv, MLX5_SET(fte_match_param, mv, outer_headers.udp_dport, el->port); *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR(*rule_p)) { err = PTR_ERR(*rule_p); @@ -1809,13 +1825,17 @@ mlx5e_add_vxlan_catchall_rule_sub(struct mlx5e_priv *priv, u32 *mc, u32 *mv) u8 mc_enable = 0; struct mlx5_flow_rule **rule_p; int err = 0; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_ETH_FLOW_TAG, + }; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.ft = priv->fts.main.t; rule_p = &priv->fts.vxlan_catchall_ft_rule; *rule_p = mlx5_add_flow_rule(ft, mc_enable, mc, mv, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, MLX5_FS_ETH_FLOW_TAG, &dest); + MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); if (IS_ERR(*rule_p)) { err = PTR_ERR(*rule_p); diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c index 1b02c8741a56..dc5396d348c5 100644 --- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c +++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c @@ -2180,6 +2180,10 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev, struct mlx5_flow_spec *spec; const void *ib_flow = (const void *)flow_attr + sizeof(*flow_attr); unsigned int spec_index; + struct mlx5_flow_act flow_act = { + .actions = MLX5_FLOW_ACT_ACTIONS_FLOW_TAG, + .flow_tag = MLX5_FS_DEFAULT_FLOW_TAG, + }; u32 action; int err = 0; @@ -2211,7 +2215,7 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev, spec->match_criteria, spec->match_value, action, - MLX5_FS_DEFAULT_FLOW_TAG, + &flow_act, dst); if (IS_ERR(handler->rule)) {