Skip to content

Commit 6f0b692

Browse files
Chris MiSaeed Mahameed
authored andcommitted
net/mlx5e: Introduce post action infrastructure
Some tc actions are modeled in hardware using multiple tables causing a tc action list split. For example, CT action is modeled by jumping to a ct table which is controlled by nf flowtable. sFlow jumps in hardware to a sample table, which continues to a "default table" where it should continue processing the action list. Multi table actions are modeled in hardware using a unique fte_id. The fte_id is set before jumping to a table. Split actions continue to a post-action table where the matched fte_id value continues the execution the tc action list. Currently the post-action design is implemented only by the ct action. Introduce post action infrastructure as a pre-step for reusing it with the sFlow offload feature. Init and destroy the common post action table. Refactor the ct offload to use the common post table infrastructure in the next patch. Signed-off-by: Chris Mi <[email protected]> Reviewed-by: Oz Shlomo <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2799797 commit 6f0b692

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \
4444
lib/fs_chains.o en/tc_tun.o \
4545
esw/indir_table.o en/tc_tun_encap.o \
4646
en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \
47-
en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o
47+
en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o \
48+
en/tc/post_act.o
4849
mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o
4950
mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
5051

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
4+
#include "post_act.h"
5+
#include "mlx5_core.h"
6+
7+
struct mlx5e_post_act {
8+
enum mlx5_flow_namespace_type ns_type;
9+
struct mlx5_fs_chains *chains;
10+
struct mlx5_flow_table *ft;
11+
struct mlx5e_priv *priv;
12+
};
13+
14+
struct mlx5e_post_act *
15+
mlx5e_tc_post_act_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
16+
enum mlx5_flow_namespace_type ns_type)
17+
{
18+
struct mlx5e_post_act *post_act;
19+
int err;
20+
21+
if (ns_type == MLX5_FLOW_NAMESPACE_FDB &&
22+
!MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, ignore_flow_level)) {
23+
mlx5_core_warn(priv->mdev, "firmware level support is missing\n");
24+
err = -EOPNOTSUPP;
25+
goto err_check;
26+
} else if (!MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ignore_flow_level)) {
27+
mlx5_core_warn(priv->mdev, "firmware level support is missing\n");
28+
err = -EOPNOTSUPP;
29+
goto err_check;
30+
}
31+
32+
post_act = kzalloc(sizeof(*post_act), GFP_KERNEL);
33+
if (!post_act) {
34+
err = -ENOMEM;
35+
goto err_check;
36+
}
37+
post_act->ft = mlx5_chains_create_global_table(chains);
38+
if (IS_ERR(post_act->ft)) {
39+
err = PTR_ERR(post_act->ft);
40+
mlx5_core_warn(priv->mdev, "failed to create post action table, err: %d\n", err);
41+
goto err_ft;
42+
}
43+
post_act->chains = chains;
44+
post_act->ns_type = ns_type;
45+
post_act->priv = priv;
46+
return post_act;
47+
48+
err_ft:
49+
kfree(post_act);
50+
err_check:
51+
return ERR_PTR(err);
52+
}
53+
54+
void
55+
mlx5e_tc_post_act_destroy(struct mlx5e_post_act *post_act)
56+
{
57+
if (IS_ERR_OR_NULL(post_act))
58+
return;
59+
60+
mlx5_chains_destroy_global_table(post_act->chains, post_act->ft);
61+
kfree(post_act);
62+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3+
4+
#ifndef __MLX5_POST_ACTION_H__
5+
#define __MLX5_POST_ACTION_H__
6+
7+
#include "en.h"
8+
#include "lib/fs_chains.h"
9+
10+
struct mlx5e_post_act *
11+
mlx5e_tc_post_act_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
12+
enum mlx5_flow_namespace_type ns_type);
13+
14+
void
15+
mlx5e_tc_post_act_destroy(struct mlx5e_post_act *post_act);
16+
17+
#endif /* __MLX5_POST_ACTION_H__ */

0 commit comments

Comments
 (0)