Skip to content

Commit 1a2b60f

Browse files
committed
Merge tag 'mlx5-dr-2021-01-29' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-dr-2021-01-29 Add support for Connect-X6DX Software steering This series adds SW Steering support for Connect-X6DX. Since the STE and actions formats are different on this new HW, we implemented the HW specific STEv1 layer on the infrastructure implemented in previous mlx5 DR patchset to support all the functionalities as previous devices. Most of the code in this series very is low level HW specific, we implement the function pointers for the generic SW steering layer. * tag 'mlx5-dr-2021-01-29' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5: DR, Allow SW steering for sw_owner_v2 devices net/mlx5: DR, Copy all 64B whenever replacing STE in the head of miss-list net/mlx5: DR, Use HW specific logic API when writing STE net/mlx5: DR, Use the right size when writing partial STE into HW net/mlx5: DR, Add STEv1 modify header logic net/mlx5: DR, Add STEv1 action apply logic net/mlx5: DR, Add STEv1 setters and getters net/mlx5: DR, Allow native protocol support for HW STEv1 net/mlx5: DR, Add HW STEv1 match logic net/mlx5: DR, Add match STEv1 structs to ifc net/mlx5: DR, Fix potential shift wrapping of 32-bit value ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents f222a99 + 64f45c0 commit 1a2b60f

File tree

13 files changed

+2169
-44
lines changed

13 files changed

+2169
-44
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o
8585
steering/dr_matcher.o steering/dr_rule.o \
8686
steering/dr_icm_pool.o steering/dr_buddy.o \
8787
steering/dr_ste.o steering/dr_send.o \
88-
steering/dr_ste_v0.o \
88+
steering/dr_ste_v0.o steering/dr_ste_v1.o \
8989
steering/dr_cmd.o steering/dr_fw.o \
9090
steering/dr_action.o steering/fs_dr.o
9191
#

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ int mlx5dr_cmd_query_esw_caps(struct mlx5_core_dev *mdev,
7878
caps->uplink_icm_address_tx =
7979
MLX5_CAP64_ESW_FLOWTABLE(mdev,
8080
sw_steering_uplink_icm_address_tx);
81-
caps->sw_owner =
82-
MLX5_CAP_ESW_FLOWTABLE_FDB(mdev,
83-
sw_owner);
81+
caps->sw_owner_v2 = MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, sw_owner_v2);
82+
if (!caps->sw_owner_v2)
83+
caps->sw_owner = MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, sw_owner);
8484

8585
return 0;
8686
}
@@ -113,10 +113,15 @@ int mlx5dr_cmd_query_device(struct mlx5_core_dev *mdev,
113113
caps->nic_tx_allow_address =
114114
MLX5_CAP64_FLOWTABLE(mdev, sw_steering_nic_tx_action_allow_icm_address);
115115

116-
caps->rx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner);
117-
caps->max_ft_level = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, max_ft_level);
116+
caps->rx_sw_owner_v2 = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner_v2);
117+
caps->tx_sw_owner_v2 = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner_v2);
118+
119+
if (!caps->rx_sw_owner_v2)
120+
caps->rx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner);
121+
if (!caps->tx_sw_owner_v2)
122+
caps->tx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner);
118123

119-
caps->tx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner);
124+
caps->max_ft_level = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, max_ft_level);
120125

121126
caps->log_icm_size = MLX5_CAP_DEV_MEM(mdev, log_steering_sw_icm_size);
122127
caps->hdr_modify_icm_addr =

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#include <linux/mlx5/eswitch.h>
55
#include "dr_types.h"
66

7+
#define DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, dmn_type) \
8+
((dmn)->info.caps.dmn_type##_sw_owner || \
9+
((dmn)->info.caps.dmn_type##_sw_owner_v2 && \
10+
(dmn)->info.caps.sw_format_ver <= MLX5_STEERING_FORMAT_CONNECTX_6DX))
11+
712
static int dr_domain_init_cache(struct mlx5dr_domain *dmn)
813
{
914
/* Per vport cached FW FT for checksum recalculation, this
@@ -187,6 +192,7 @@ static int dr_domain_query_fdb_caps(struct mlx5_core_dev *mdev,
187192
return ret;
188193

189194
dmn->info.caps.fdb_sw_owner = dmn->info.caps.esw_caps.sw_owner;
195+
dmn->info.caps.fdb_sw_owner_v2 = dmn->info.caps.esw_caps.sw_owner_v2;
190196
dmn->info.caps.esw_rx_drop_address = dmn->info.caps.esw_caps.drop_icm_address_rx;
191197
dmn->info.caps.esw_tx_drop_address = dmn->info.caps.esw_caps.drop_icm_address_tx;
192198

@@ -229,18 +235,13 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev,
229235
if (ret)
230236
return ret;
231237

232-
if (dmn->info.caps.sw_format_ver != MLX5_STEERING_FORMAT_CONNECTX_5) {
233-
mlx5dr_err(dmn, "SW steering is not supported on this device\n");
234-
return -EOPNOTSUPP;
235-
}
236-
237238
ret = dr_domain_query_fdb_caps(mdev, dmn);
238239
if (ret)
239240
return ret;
240241

241242
switch (dmn->type) {
242243
case MLX5DR_DOMAIN_TYPE_NIC_RX:
243-
if (!dmn->info.caps.rx_sw_owner)
244+
if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, rx))
244245
return -ENOTSUPP;
245246

246247
dmn->info.supp_sw_steering = true;
@@ -249,7 +250,7 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev,
249250
dmn->info.rx.drop_icm_addr = dmn->info.caps.nic_rx_drop_address;
250251
break;
251252
case MLX5DR_DOMAIN_TYPE_NIC_TX:
252-
if (!dmn->info.caps.tx_sw_owner)
253+
if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, tx))
253254
return -ENOTSUPP;
254255

255256
dmn->info.supp_sw_steering = true;
@@ -261,7 +262,7 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev,
261262
if (!dmn->info.caps.eswitch_manager)
262263
return -ENOTSUPP;
263264

264-
if (!dmn->info.caps.fdb_sw_owner)
265+
if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, fdb))
265266
return -ENOTSUPP;
266267

267268
dmn->info.rx.ste_type = MLX5DR_STE_TYPE_RX;

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ dr_mask_is_vxlan_gpe_set(struct mlx5dr_match_misc3 *misc3)
113113
static bool
114114
dr_matcher_supp_vxlan_gpe(struct mlx5dr_cmd_caps *caps)
115115
{
116-
return caps->flex_protocols & MLX5_FLEX_PARSER_VXLAN_GPE_ENABLED;
116+
return (caps->sw_format_ver == MLX5_STEERING_FORMAT_CONNECTX_6DX) ||
117+
(caps->flex_protocols & MLX5_FLEX_PARSER_VXLAN_GPE_ENABLED);
117118
}
118119

119120
static bool
@@ -135,7 +136,8 @@ static bool dr_mask_is_tnl_geneve_set(struct mlx5dr_match_misc *misc)
135136
static bool
136137
dr_matcher_supp_tnl_geneve(struct mlx5dr_cmd_caps *caps)
137138
{
138-
return caps->flex_protocols & MLX5_FLEX_PARSER_GENEVE_ENABLED;
139+
return (caps->sw_format_ver == MLX5_STEERING_FORMAT_CONNECTX_6DX) ||
140+
(caps->flex_protocols & MLX5_FLEX_PARSER_GENEVE_ENABLED);
139141
}
140142

141143
static bool
@@ -148,12 +150,14 @@ dr_mask_is_tnl_geneve(struct mlx5dr_match_param *mask,
148150

149151
static int dr_matcher_supp_icmp_v4(struct mlx5dr_cmd_caps *caps)
150152
{
151-
return caps->flex_protocols & MLX5_FLEX_PARSER_ICMP_V4_ENABLED;
153+
return (caps->sw_format_ver == MLX5_STEERING_FORMAT_CONNECTX_6DX) ||
154+
(caps->flex_protocols & MLX5_FLEX_PARSER_ICMP_V4_ENABLED);
152155
}
153156

154157
static int dr_matcher_supp_icmp_v6(struct mlx5dr_cmd_caps *caps)
155158
{
156-
return caps->flex_protocols & MLX5_FLEX_PARSER_ICMP_V6_ENABLED;
159+
return (caps->sw_format_ver == MLX5_STEERING_FORMAT_CONNECTX_6DX) ||
160+
(caps->flex_protocols & MLX5_FLEX_PARSER_ICMP_V6_ENABLED);
157161
}
158162

159163
static bool dr_mask_is_icmpv6_set(struct mlx5dr_match_misc3 *misc3)

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int dr_rule_append_to_miss_list(struct mlx5dr_ste_ctx *ste_ctx,
3030
mlx5dr_ste_get_icm_addr(new_last_ste));
3131
list_add_tail(&new_last_ste->miss_list_node, miss_list);
3232

33-
mlx5dr_send_fill_and_append_ste_send_info(last_ste, DR_STE_SIZE_REDUCED,
33+
mlx5dr_send_fill_and_append_ste_send_info(last_ste, DR_STE_SIZE_CTRL,
3434
0, last_ste->hw_ste,
3535
ste_info_last, send_list, true);
3636

@@ -106,14 +106,19 @@ dr_rule_handle_one_ste_in_update_list(struct mlx5dr_ste_send_info *ste_info,
106106
int ret;
107107

108108
list_del(&ste_info->send_list);
109+
110+
/* Copy data to ste, only reduced size or control, the last 16B (mask)
111+
* is already written to the hw.
112+
*/
113+
if (ste_info->size == DR_STE_SIZE_CTRL)
114+
memcpy(ste_info->ste->hw_ste, ste_info->data, DR_STE_SIZE_CTRL);
115+
else
116+
memcpy(ste_info->ste->hw_ste, ste_info->data, DR_STE_SIZE_REDUCED);
117+
109118
ret = mlx5dr_send_postsend_ste(dmn, ste_info->ste, ste_info->data,
110119
ste_info->size, ste_info->offset);
111120
if (ret)
112121
goto out;
113-
/* Copy data to ste, only reduced size, the last 16B (mask)
114-
* is already written to the hw.
115-
*/
116-
memcpy(ste_info->ste->hw_ste, ste_info->data, DR_STE_SIZE_REDUCED);
117122

118123
out:
119124
kfree(ste_info);
@@ -456,7 +461,7 @@ dr_rule_rehash_htbl(struct mlx5dr_rule *rule,
456461
ste_to_update = cur_htbl->pointing_ste;
457462
}
458463

459-
mlx5dr_send_fill_and_append_ste_send_info(ste_to_update, DR_STE_SIZE_REDUCED,
464+
mlx5dr_send_fill_and_append_ste_send_info(ste_to_update, DR_STE_SIZE_CTRL,
460465
0, ste_to_update->hw_ste, ste_info,
461466
update_list, false);
462467

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ int mlx5dr_send_postsend_ste(struct mlx5dr_domain *dmn, struct mlx5dr_ste *ste,
431431
{
432432
struct postsend_info send_info = {};
433433

434+
mlx5dr_ste_prepare_for_postsend(dmn->ste_ctx, data, size);
435+
434436
send_info.write.addr = (uintptr_t)data;
435437
send_info.write.length = size;
436438
send_info.write.lkey = 0;
@@ -457,6 +459,8 @@ int mlx5dr_send_postsend_htbl(struct mlx5dr_domain *dmn,
457459
if (ret)
458460
return ret;
459461

462+
mlx5dr_ste_prepare_for_postsend(dmn->ste_ctx, formatted_ste, DR_STE_SIZE);
463+
460464
/* Send the data iteration times */
461465
for (i = 0; i < iterations; i++) {
462466
u32 ste_index = i * (byte_size / DR_STE_SIZE);
@@ -480,6 +484,10 @@ int mlx5dr_send_postsend_htbl(struct mlx5dr_domain *dmn,
480484
/* Copy bit_mask */
481485
memcpy(data + ste_off + DR_STE_SIZE_REDUCED,
482486
mask, DR_STE_SIZE_MASK);
487+
/* Only when we have mask we need to re-arrange the STE */
488+
mlx5dr_ste_prepare_for_postsend(dmn->ste_ctx,
489+
data + (j * DR_STE_SIZE),
490+
DR_STE_SIZE);
483491
}
484492
}
485493

@@ -509,6 +517,7 @@ int mlx5dr_send_postsend_formatted_htbl(struct mlx5dr_domain *dmn,
509517
u32 byte_size = htbl->chunk->byte_size;
510518
int iterations;
511519
int num_stes;
520+
u8 *copy_dst;
512521
u8 *data;
513522
int ret;
514523
int i;
@@ -518,20 +527,22 @@ int mlx5dr_send_postsend_formatted_htbl(struct mlx5dr_domain *dmn,
518527
if (ret)
519528
return ret;
520529

521-
for (i = 0; i < num_stes; i++) {
522-
u8 *copy_dst;
523-
524-
/* Copy the same ste on the data buffer */
525-
copy_dst = data + i * DR_STE_SIZE;
526-
memcpy(copy_dst, ste_init_data, DR_STE_SIZE);
527-
528-
if (update_hw_ste) {
529-
/* Copy the reduced ste to hash table ste_arr */
530+
if (update_hw_ste) {
531+
/* Copy the reduced STE to hash table ste_arr */
532+
for (i = 0; i < num_stes; i++) {
530533
copy_dst = htbl->hw_ste_arr + i * DR_STE_SIZE_REDUCED;
531534
memcpy(copy_dst, ste_init_data, DR_STE_SIZE_REDUCED);
532535
}
533536
}
534537

538+
mlx5dr_ste_prepare_for_postsend(dmn->ste_ctx, ste_init_data, DR_STE_SIZE);
539+
540+
/* Copy the same STE on the data buffer */
541+
for (i = 0; i < num_stes; i++) {
542+
copy_dst = data + i * DR_STE_SIZE;
543+
memcpy(copy_dst, ste_init_data, DR_STE_SIZE);
544+
}
545+
535546
/* Send the data iteration times */
536547
for (i = 0; i < iterations; i++) {
537548
u8 ste_index = i * (byte_size / DR_STE_SIZE);

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,17 @@ dr_ste_remove_head_ste(struct mlx5dr_ste_ctx *ste_ctx,
211211
* |_ste_| --> |_next_ste_| -->|__| -->|__| -->/0
212212
*/
213213
static void
214-
dr_ste_replace_head_ste(struct mlx5dr_ste *ste, struct mlx5dr_ste *next_ste,
214+
dr_ste_replace_head_ste(struct mlx5dr_matcher_rx_tx *nic_matcher,
215+
struct mlx5dr_ste *ste,
216+
struct mlx5dr_ste *next_ste,
215217
struct mlx5dr_ste_send_info *ste_info_head,
216218
struct list_head *send_ste_list,
217219
struct mlx5dr_ste_htbl *stats_tbl)
218220

219221
{
220222
struct mlx5dr_ste_htbl *next_miss_htbl;
223+
u8 hw_ste[DR_STE_SIZE] = {};
224+
int sb_idx;
221225

222226
next_miss_htbl = next_ste->htbl;
223227

@@ -230,13 +234,19 @@ dr_ste_replace_head_ste(struct mlx5dr_ste *ste, struct mlx5dr_ste *next_ste,
230234
/* Move data from next into ste */
231235
dr_ste_replace(ste, next_ste);
232236

237+
/* Copy all 64 hw_ste bytes */
238+
memcpy(hw_ste, ste->hw_ste, DR_STE_SIZE_REDUCED);
239+
sb_idx = ste->ste_chain_location - 1;
240+
mlx5dr_ste_set_bit_mask(hw_ste,
241+
nic_matcher->ste_builder[sb_idx].bit_mask);
242+
233243
/* Del the htbl that contains the next_ste.
234244
* The origin htbl stay with the same number of entries.
235245
*/
236246
mlx5dr_htbl_put(next_miss_htbl);
237247

238-
mlx5dr_send_fill_and_append_ste_send_info(ste, DR_STE_SIZE_REDUCED,
239-
0, ste->hw_ste,
248+
mlx5dr_send_fill_and_append_ste_send_info(ste, DR_STE_SIZE,
249+
0, hw_ste,
240250
ste_info_head,
241251
send_ste_list,
242252
true /* Copy data */);
@@ -264,7 +274,7 @@ static void dr_ste_remove_middle_ste(struct mlx5dr_ste_ctx *ste_ctx,
264274
miss_addr = ste_ctx->get_miss_addr(ste->hw_ste);
265275
ste_ctx->set_miss_addr(prev_ste->hw_ste, miss_addr);
266276

267-
mlx5dr_send_fill_and_append_ste_send_info(prev_ste, DR_STE_SIZE_REDUCED, 0,
277+
mlx5dr_send_fill_and_append_ste_send_info(prev_ste, DR_STE_SIZE_CTRL, 0,
268278
prev_ste->hw_ste, ste_info,
269279
send_ste_list, true /* Copy data*/);
270280

@@ -316,7 +326,8 @@ void mlx5dr_ste_free(struct mlx5dr_ste *ste,
316326
stats_tbl);
317327
} else {
318328
/* First but not only entry in the list */
319-
dr_ste_replace_head_ste(ste, next_ste, &ste_info_head,
329+
dr_ste_replace_head_ste(nic_matcher, ste,
330+
next_ste, &ste_info_head,
320331
&send_ste_list, stats_tbl);
321332
put_on_origin_table = false;
322333
}
@@ -356,6 +367,13 @@ void mlx5dr_ste_set_hit_addr_by_next_htbl(struct mlx5dr_ste_ctx *ste_ctx,
356367
ste_ctx->set_hit_addr(hw_ste, chunk->icm_addr, chunk->num_of_entries);
357368
}
358369

370+
void mlx5dr_ste_prepare_for_postsend(struct mlx5dr_ste_ctx *ste_ctx,
371+
u8 *hw_ste_p, u32 ste_size)
372+
{
373+
if (ste_ctx->prepare_for_postsend)
374+
ste_ctx->prepare_for_postsend(hw_ste_p, ste_size);
375+
}
376+
359377
/* Init one ste as a pattern for ste data array */
360378
void mlx5dr_ste_set_formatted_ste(struct mlx5dr_ste_ctx *ste_ctx,
361379
u16 gvmi,
@@ -1127,7 +1145,7 @@ void mlx5dr_ste_build_src_gvmi_qpn(struct mlx5dr_ste_ctx *ste_ctx,
11271145

11281146
static struct mlx5dr_ste_ctx *mlx5dr_ste_ctx_arr[] = {
11291147
[MLX5_STEERING_FORMAT_CONNECTX_5] = &ste_ctx_v0,
1130-
[MLX5_STEERING_FORMAT_CONNECTX_6DX] = NULL,
1148+
[MLX5_STEERING_FORMAT_CONNECTX_6DX] = &ste_ctx_v1,
11311149
};
11321150

11331151
struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx(u8 version)

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ struct mlx5dr_ste_ctx {
160160
u8 *hw_action,
161161
u32 hw_action_sz,
162162
u16 *used_hw_action_num);
163+
164+
/* Send */
165+
void (*prepare_for_postsend)(u8 *hw_ste_p, u32 ste_size);
163166
};
164167

165168
extern struct mlx5dr_ste_ctx ste_ctx_v0;
169+
extern struct mlx5dr_ste_ctx ste_ctx_v1;
166170

167171
#endif /* _DR_STE_ */

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ static void dr_ste_v0_set_miss_addr(u8 *hw_ste_p, u64 miss_addr)
248248
static u64 dr_ste_v0_get_miss_addr(u8 *hw_ste_p)
249249
{
250250
u64 index =
251-
(MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_31_6) |
252-
MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_39_32) << 26);
251+
((u64)MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_31_6) |
252+
((u64)MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_39_32)) << 26);
253253

254254
return index << 6;
255255
}

0 commit comments

Comments
 (0)