Skip to content

Commit 34eea5b

Browse files
Cosmin Ratiukuba-moo
Cosmin Ratiu
authored andcommitted
net/mlx5e: CT: Add initial support for Hardware Steering
Connection tracking can offload tuple matches to the NIC either via firmware commands (when the steering mode is dmfs or offload support is disabled due to eswitch being set to legacy) or via software-managed flow steering (smfs). This commit adds stub operations for a third mode, hardware-managed flow steering. This is enabled when both CONFIG_MLX5_TC_CT and CONFIG_MLX5_HW_STEERING are enabled. Signed-off-by: Cosmin Ratiu <[email protected]> Reviewed-by: Jianbo Liu <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent af02dbf commit 34eea5b

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a
6060
ifneq ($(CONFIG_MLX5_TC_CT),)
6161
mlx5_core-y += en/tc_ct.o en/tc/ct_fs_dmfs.o
6262
mlx5_core-$(CONFIG_MLX5_SW_STEERING) += en/tc/ct_fs_smfs.o
63+
mlx5_core-$(CONFIG_MLX5_HW_STEERING) += en/tc/ct_fs_hmfs.o
6364
endif
6465

6566
mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o

drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h

+10
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,14 @@ mlx5_ct_fs_smfs_ops_get(void)
4848
}
4949
#endif /* IS_ENABLED(CONFIG_MLX5_SW_STEERING) */
5050

51+
#if IS_ENABLED(CONFIG_MLX5_HW_STEERING)
52+
struct mlx5_ct_fs_ops *mlx5_ct_fs_hmfs_ops_get(void);
53+
#else
54+
static inline struct mlx5_ct_fs_ops *
55+
mlx5_ct_fs_hmfs_ops_get(void)
56+
{
57+
return NULL;
58+
}
59+
#endif /* IS_ENABLED(CONFIG_MLX5_SW_STEERING) */
60+
5161
#endif /* __MLX5_EN_TC_CT_FS_H__ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
/* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. */
3+
4+
#include "en_tc.h"
5+
#include "en/tc_ct.h"
6+
#include "en/tc/ct_fs.h"
7+
8+
static int mlx5_ct_fs_hmfs_init(struct mlx5_ct_fs *fs, struct mlx5_flow_table *ct,
9+
struct mlx5_flow_table *ct_nat, struct mlx5_flow_table *post_ct)
10+
{
11+
return 0;
12+
}
13+
14+
static void mlx5_ct_fs_hmfs_destroy(struct mlx5_ct_fs *fs)
15+
{
16+
}
17+
18+
static struct mlx5_ct_fs_rule *
19+
mlx5_ct_fs_hmfs_ct_rule_add(struct mlx5_ct_fs *fs, struct mlx5_flow_spec *spec,
20+
struct mlx5_flow_attr *attr, struct flow_rule *flow_rule)
21+
{
22+
return ERR_PTR(-EOPNOTSUPP);
23+
}
24+
25+
static void mlx5_ct_fs_hmfs_ct_rule_del(struct mlx5_ct_fs *fs, struct mlx5_ct_fs_rule *fs_rule)
26+
{
27+
}
28+
29+
static int mlx5_ct_fs_hmfs_ct_rule_update(struct mlx5_ct_fs *fs, struct mlx5_ct_fs_rule *fs_rule,
30+
struct mlx5_flow_spec *spec, struct mlx5_flow_attr *attr)
31+
{
32+
return -EOPNOTSUPP;
33+
}
34+
35+
static struct mlx5_ct_fs_ops hmfs_ops = {
36+
.ct_rule_add = mlx5_ct_fs_hmfs_ct_rule_add,
37+
.ct_rule_del = mlx5_ct_fs_hmfs_ct_rule_del,
38+
.ct_rule_update = mlx5_ct_fs_hmfs_ct_rule_update,
39+
40+
.init = mlx5_ct_fs_hmfs_init,
41+
.destroy = mlx5_ct_fs_hmfs_destroy,
42+
};
43+
44+
struct mlx5_ct_fs_ops *mlx5_ct_fs_hmfs_ops_get(void)
45+
{
46+
return &hmfs_ops;
47+
}

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -2065,10 +2065,19 @@ mlx5_tc_ct_fs_init(struct mlx5_tc_ct_priv *ct_priv)
20652065
struct mlx5_ct_fs_ops *fs_ops = mlx5_ct_fs_dmfs_ops_get();
20662066
int err;
20672067

2068-
if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB &&
2069-
ct_priv->dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS) {
2070-
ct_dbg("Using SMFS ct flow steering provider");
2071-
fs_ops = mlx5_ct_fs_smfs_ops_get();
2068+
if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB) {
2069+
if (ct_priv->dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_HMFS) {
2070+
ct_dbg("Using HMFS ct flow steering provider");
2071+
fs_ops = mlx5_ct_fs_hmfs_ops_get();
2072+
} else if (ct_priv->dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS) {
2073+
ct_dbg("Using SMFS ct flow steering provider");
2074+
fs_ops = mlx5_ct_fs_smfs_ops_get();
2075+
}
2076+
2077+
if (!fs_ops) {
2078+
ct_dbg("Requested flow steering mode is not enabled.");
2079+
return -EOPNOTSUPP;
2080+
}
20722081
}
20732082

20742083
ct_priv->fs = kzalloc(sizeof(*ct_priv->fs) + fs_ops->priv_size, GFP_KERNEL);

0 commit comments

Comments
 (0)