Skip to content

Commit cbfdefc

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add HWS root namespace functions
Add flow steering commands structure for HW steering. Implement create, destroy and set peer HW steering root namespace functions. Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Yevgeny Kliteynik <[email protected]> Reviewed-by: Mark Bloch <[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 afc6649 commit cbfdefc

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ mlx5_core-$(CONFIG_MLX5_HW_STEERING) += steering/hws/cmd.o \
151151
steering/hws/bwc.o \
152152
steering/hws/debug.o \
153153
steering/hws/vport.o \
154-
steering/hws/bwc_complex.o
155-
154+
steering/hws/bwc_complex.o \
155+
steering/hws/fs_hws.o
156156

157157
#
158158
# SF device

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/rhashtable.h>
3939
#include <linux/llist.h>
4040
#include <steering/sws/fs_dr.h>
41+
#include <steering/hws/fs_hws.h>
4142

4243
#define FDB_TC_MAX_CHAIN 3
4344
#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
@@ -126,7 +127,8 @@ enum fs_fte_status {
126127

127128
enum mlx5_flow_steering_mode {
128129
MLX5_FLOW_STEERING_MODE_DMFS,
129-
MLX5_FLOW_STEERING_MODE_SMFS
130+
MLX5_FLOW_STEERING_MODE_SMFS,
131+
MLX5_FLOW_STEERING_MODE_HMFS,
130132
};
131133

132134
enum mlx5_flow_steering_capabilty {
@@ -293,7 +295,10 @@ struct mlx5_flow_group {
293295
struct mlx5_flow_root_namespace {
294296
struct mlx5_flow_namespace ns;
295297
enum mlx5_flow_steering_mode mode;
296-
struct mlx5_fs_dr_domain fs_dr_domain;
298+
union {
299+
struct mlx5_fs_dr_domain fs_dr_domain;
300+
struct mlx5_fs_hws_context fs_hws_context;
301+
};
297302
enum fs_flow_table_type table_type;
298303
struct mlx5_core_dev *dev;
299304
struct mlx5_flow_table *root_ft;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
/* Copyright (c) 2025 NVIDIA Corporation & Affiliates */
3+
4+
#include <mlx5_core.h>
5+
#include <fs_core.h>
6+
#include <fs_cmd.h>
7+
#include "mlx5hws.h"
8+
9+
#define MLX5HWS_CTX_MAX_NUM_OF_QUEUES 16
10+
#define MLX5HWS_CTX_QUEUE_SIZE 256
11+
12+
static int mlx5_cmd_hws_create_ns(struct mlx5_flow_root_namespace *ns)
13+
{
14+
struct mlx5hws_context_attr hws_ctx_attr = {};
15+
16+
hws_ctx_attr.queues = min_t(int, num_online_cpus(),
17+
MLX5HWS_CTX_MAX_NUM_OF_QUEUES);
18+
hws_ctx_attr.queue_size = MLX5HWS_CTX_QUEUE_SIZE;
19+
20+
ns->fs_hws_context.hws_ctx =
21+
mlx5hws_context_open(ns->dev, &hws_ctx_attr);
22+
if (!ns->fs_hws_context.hws_ctx) {
23+
mlx5_core_err(ns->dev, "Failed to create hws flow namespace\n");
24+
return -EINVAL;
25+
}
26+
return 0;
27+
}
28+
29+
static int mlx5_cmd_hws_destroy_ns(struct mlx5_flow_root_namespace *ns)
30+
{
31+
return mlx5hws_context_close(ns->fs_hws_context.hws_ctx);
32+
}
33+
34+
static int mlx5_cmd_hws_set_peer(struct mlx5_flow_root_namespace *ns,
35+
struct mlx5_flow_root_namespace *peer_ns,
36+
u16 peer_vhca_id)
37+
{
38+
struct mlx5hws_context *peer_ctx = NULL;
39+
40+
if (peer_ns)
41+
peer_ctx = peer_ns->fs_hws_context.hws_ctx;
42+
mlx5hws_context_set_peer(ns->fs_hws_context.hws_ctx, peer_ctx,
43+
peer_vhca_id);
44+
return 0;
45+
}
46+
47+
static const struct mlx5_flow_cmds mlx5_flow_cmds_hws = {
48+
.create_ns = mlx5_cmd_hws_create_ns,
49+
.destroy_ns = mlx5_cmd_hws_destroy_ns,
50+
.set_peer = mlx5_cmd_hws_set_peer,
51+
};
52+
53+
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void)
54+
{
55+
return &mlx5_flow_cmds_hws;
56+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) 2025 NVIDIA Corporation & Affiliates */
3+
4+
#ifndef _MLX5_FS_HWS_
5+
#define _MLX5_FS_HWS_
6+
7+
#include "mlx5hws.h"
8+
9+
struct mlx5_fs_hws_context {
10+
struct mlx5hws_context *hws_ctx;
11+
};
12+
13+
#ifdef CONFIG_MLX5_HW_STEERING
14+
15+
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void);
16+
17+
#else
18+
19+
static inline const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void)
20+
{
21+
return NULL;
22+
}
23+
24+
#endif /* CONFIG_MLX5_HWS_STEERING */
25+
#endif

0 commit comments

Comments
 (0)