Skip to content

Commit 6a48fae

Browse files
Maor GottliebSaeed Mahameed
authored andcommitted
net/mlx5: Add direct rule fs_cmd implementation
Add support to create flow steering objects via direct rule API (SW steering). New layer is added - fs_dr, this layer translates the command that fs_core sends to the FW into direct rule API. In case that direct rule is not supported in some feature then -EOPNOTSUPP is returned. Signed-off-by: Maor Gottlieb <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent fb86f12 commit 6a48fae

File tree

7 files changed

+717
-6
lines changed

7 files changed

+717
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o
7373
steering/dr_icm_pool.o steering/dr_crc32.o \
7474
steering/dr_ste.o steering/dr_send.o \
7575
steering/dr_cmd.o steering/dr_fw.o \
76-
steering/dr_action.o
76+
steering/dr_action.o steering/fs_dr.o

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace
135135
{
136136
}
137137

138+
static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns,
139+
struct mlx5_flow_root_namespace *peer_ns)
140+
{
141+
return 0;
142+
}
143+
144+
static int mlx5_cmd_stub_create_ns(struct mlx5_flow_root_namespace *ns)
145+
{
146+
return 0;
147+
}
148+
149+
static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns)
150+
{
151+
return 0;
152+
}
153+
138154
static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns,
139155
struct mlx5_flow_table *ft, u32 underlay_qpn,
140156
bool disconnect)
@@ -838,7 +854,10 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = {
838854
.packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc,
839855
.packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc,
840856
.modify_header_alloc = mlx5_cmd_modify_header_alloc,
841-
.modify_header_dealloc = mlx5_cmd_modify_header_dealloc
857+
.modify_header_dealloc = mlx5_cmd_modify_header_dealloc,
858+
.set_peer = mlx5_cmd_stub_set_peer,
859+
.create_ns = mlx5_cmd_stub_create_ns,
860+
.destroy_ns = mlx5_cmd_stub_destroy_ns,
842861
};
843862

844863
static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
@@ -854,10 +873,13 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
854873
.packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc,
855874
.packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc,
856875
.modify_header_alloc = mlx5_cmd_stub_modify_header_alloc,
857-
.modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc
876+
.modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc,
877+
.set_peer = mlx5_cmd_stub_set_peer,
878+
.create_ns = mlx5_cmd_stub_create_ns,
879+
.destroy_ns = mlx5_cmd_stub_destroy_ns,
858880
};
859881

860-
static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void)
882+
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void)
861883
{
862884
return &mlx5_flow_cmds;
863885
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ struct mlx5_flow_cmds {
9393

9494
void (*modify_header_dealloc)(struct mlx5_flow_root_namespace *ns,
9595
struct mlx5_modify_hdr *modify_hdr);
96+
97+
int (*set_peer)(struct mlx5_flow_root_namespace *ns,
98+
struct mlx5_flow_root_namespace *peer_ns);
99+
100+
int (*create_ns)(struct mlx5_flow_root_namespace *ns);
101+
int (*destroy_ns)(struct mlx5_flow_root_namespace *ns);
96102
};
97103

98104
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
@@ -108,5 +114,6 @@ int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len,
108114
u32 *out);
109115

110116
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type);
117+
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
111118

112119
#endif

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,3 +2991,9 @@ void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev,
29912991
kfree(pkt_reformat);
29922992
}
29932993
EXPORT_SYMBOL(mlx5_packet_reformat_dealloc);
2994+
2995+
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
2996+
struct mlx5_flow_root_namespace *peer_ns)
2997+
{
2998+
return ns->cmds->set_peer(ns, peer_ns);
2999+
}

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,23 @@
3737
#include <linux/mlx5/fs.h>
3838
#include <linux/rhashtable.h>
3939
#include <linux/llist.h>
40+
#include <steering/fs_dr.h>
4041

4142
struct mlx5_modify_hdr {
4243
enum mlx5_flow_namespace_type ns_type;
43-
u32 id;
44+
union {
45+
struct mlx5_fs_dr_action action;
46+
u32 id;
47+
};
4448
};
4549

4650
struct mlx5_pkt_reformat {
4751
enum mlx5_flow_namespace_type ns_type;
4852
int reformat_type; /* from mlx5_ifc */
49-
u32 id;
53+
union {
54+
struct mlx5_fs_dr_action action;
55+
u32 id;
56+
};
5057
};
5158

5259
/* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only,
@@ -139,6 +146,7 @@ struct mlx5_flow_handle {
139146
/* Type of children is mlx5_flow_group */
140147
struct mlx5_flow_table {
141148
struct fs_node node;
149+
struct mlx5_fs_dr_table fs_dr_table;
142150
u32 id;
143151
u16 vport;
144152
unsigned int max_fte;
@@ -179,6 +187,7 @@ struct mlx5_ft_underlay_qp {
179187
/* Type of children is mlx5_flow_rule */
180188
struct fs_fte {
181189
struct fs_node node;
190+
struct mlx5_fs_dr_rule fs_dr_rule;
182191
u32 val[MLX5_ST_SZ_DW_MATCH_PARAM];
183192
u32 dests_size;
184193
u32 index;
@@ -214,6 +223,7 @@ struct mlx5_flow_group_mask {
214223
/* Type of children is fs_fte */
215224
struct mlx5_flow_group {
216225
struct fs_node node;
226+
struct mlx5_fs_dr_matcher fs_dr_matcher;
217227
struct mlx5_flow_group_mask mask;
218228
u32 start_index;
219229
u32 max_ftes;
@@ -225,6 +235,7 @@ struct mlx5_flow_group {
225235

226236
struct mlx5_flow_root_namespace {
227237
struct mlx5_flow_namespace ns;
238+
struct mlx5_fs_dr_domain fs_dr_domain;
228239
enum fs_flow_table_type table_type;
229240
struct mlx5_core_dev *dev;
230241
struct mlx5_flow_table *root_ft;
@@ -242,6 +253,11 @@ void mlx5_fc_queue_stats_work(struct mlx5_core_dev *dev,
242253
void mlx5_fc_update_sampling_interval(struct mlx5_core_dev *dev,
243254
unsigned long interval);
244255

256+
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
257+
258+
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
259+
struct mlx5_flow_root_namespace *peer_ns);
260+
245261
int mlx5_init_fs(struct mlx5_core_dev *dev);
246262
void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
247263

0 commit comments

Comments
 (0)