Skip to content

Commit 1ab6dc3

Browse files
kliteynSaeed Mahameed
authored andcommitted
net/mlx5: DR, Add support for flow sampler offload
Add SW steering support for sFlow / flow sampler action. Signed-off-by: Yevgeny Kliteynik <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 6f85155 commit 1ab6dc3

File tree

6 files changed

+124
-3
lines changed

6 files changed

+124
-3
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
3131
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
3232
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
3333
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
34+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
3435
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_NON_TERM,
3536
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
3637
[DR_ACTION_TYP_TNL_L2_TO_L2] = DR_ACTION_STATE_DECAP,
@@ -45,6 +46,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
4546
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
4647
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
4748
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
49+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
4850
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_DECAP,
4951
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_DECAP,
5052
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -57,13 +59,15 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
5759
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
5860
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
5961
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
62+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
6063
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_ENCAP,
6164
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_ENCAP,
6265
},
6366
[DR_ACTION_STATE_MODIFY_HDR] = {
6467
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
6568
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
6669
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
70+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
6771
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_MODIFY_HDR,
6872
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_HDR,
6973
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -74,6 +78,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
7478
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
7579
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
7680
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
81+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
7782
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_MODIFY_VLAN,
7883
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_VLAN,
7984
[DR_ACTION_TYP_POP_VLAN] = DR_ACTION_STATE_MODIFY_VLAN,
@@ -86,6 +91,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
8691
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
8792
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
8893
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
94+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
8995
[DR_ACTION_TYP_TAG] = DR_ACTION_STATE_NON_TERM,
9096
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
9197
[DR_ACTION_TYP_TNL_L2_TO_L2] = DR_ACTION_STATE_DECAP,
@@ -104,6 +110,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
104110
[DR_ACTION_STATE_NO_ACTION] = {
105111
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
106112
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
113+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
107114
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
108115
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
109116
[DR_ACTION_TYP_L2_TO_TNL_L3] = DR_ACTION_STATE_ENCAP,
@@ -114,11 +121,13 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
114121
[DR_ACTION_STATE_ENCAP] = {
115122
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
116123
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
124+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
117125
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_ENCAP,
118126
},
119127
[DR_ACTION_STATE_MODIFY_HDR] = {
120128
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
121129
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
130+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
122131
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_HDR,
123132
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
124133
[DR_ACTION_TYP_L2_TO_TNL_L3] = DR_ACTION_STATE_ENCAP,
@@ -128,6 +137,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
128137
[DR_ACTION_STATE_MODIFY_VLAN] = {
129138
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
130139
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
140+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
131141
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_VLAN,
132142
[DR_ACTION_TYP_PUSH_VLAN] = DR_ACTION_STATE_MODIFY_VLAN,
133143
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -137,6 +147,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
137147
[DR_ACTION_STATE_NON_TERM] = {
138148
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
139149
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
150+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
140151
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
141152
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
142153
[DR_ACTION_TYP_L2_TO_TNL_L3] = DR_ACTION_STATE_ENCAP,
@@ -152,6 +163,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
152163
[DR_ACTION_STATE_NO_ACTION] = {
153164
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
154165
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
166+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
155167
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
156168
[DR_ACTION_TYP_TNL_L2_TO_L2] = DR_ACTION_STATE_DECAP,
157169
[DR_ACTION_TYP_TNL_L3_TO_L2] = DR_ACTION_STATE_DECAP,
@@ -166,6 +178,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
166178
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
167179
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
168180
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_DECAP,
181+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
169182
[DR_ACTION_TYP_MODIFY_HDR] = DR_ACTION_STATE_MODIFY_HDR,
170183
[DR_ACTION_TYP_POP_VLAN] = DR_ACTION_STATE_MODIFY_VLAN,
171184
[DR_ACTION_TYP_VPORT] = DR_ACTION_STATE_TERM,
@@ -178,11 +191,13 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
178191
[DR_ACTION_TYP_QP] = DR_ACTION_STATE_TERM,
179192
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
180193
[DR_ACTION_TYP_VPORT] = DR_ACTION_STATE_TERM,
194+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
181195
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_ENCAP,
182196
},
183197
[DR_ACTION_STATE_MODIFY_HDR] = {
184198
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
185199
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
200+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
186201
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_HDR,
187202
[DR_ACTION_TYP_VPORT] = DR_ACTION_STATE_TERM,
188203
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -192,6 +207,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
192207
[DR_ACTION_STATE_MODIFY_VLAN] = {
193208
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
194209
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
210+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
195211
[DR_ACTION_TYP_POP_VLAN] = DR_ACTION_STATE_MODIFY_VLAN,
196212
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_VLAN,
197213
[DR_ACTION_TYP_VPORT] = DR_ACTION_STATE_TERM,
@@ -203,6 +219,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
203219
[DR_ACTION_STATE_NON_TERM] = {
204220
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
205221
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
222+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
206223
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
207224
[DR_ACTION_TYP_TNL_L2_TO_L2] = DR_ACTION_STATE_DECAP,
208225
[DR_ACTION_TYP_TNL_L3_TO_L2] = DR_ACTION_STATE_DECAP,
@@ -221,6 +238,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
221238
[DR_ACTION_STATE_NO_ACTION] = {
222239
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
223240
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
241+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
224242
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
225243
[DR_ACTION_TYP_MODIFY_HDR] = DR_ACTION_STATE_MODIFY_HDR,
226244
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -233,11 +251,13 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
233251
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
234252
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
235253
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_ENCAP,
254+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
236255
[DR_ACTION_TYP_VPORT] = DR_ACTION_STATE_TERM,
237256
},
238257
[DR_ACTION_STATE_MODIFY_HDR] = {
239258
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
240259
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
260+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
241261
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_HDR,
242262
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
243263
[DR_ACTION_TYP_L2_TO_TNL_L3] = DR_ACTION_STATE_ENCAP,
@@ -248,6 +268,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
248268
[DR_ACTION_STATE_MODIFY_VLAN] = {
249269
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
250270
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
271+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
251272
[DR_ACTION_TYP_PUSH_VLAN] = DR_ACTION_STATE_MODIFY_VLAN,
252273
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_MODIFY_VLAN,
253274
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -258,6 +279,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
258279
[DR_ACTION_STATE_NON_TERM] = {
259280
[DR_ACTION_TYP_DROP] = DR_ACTION_STATE_TERM,
260281
[DR_ACTION_TYP_FT] = DR_ACTION_STATE_TERM,
282+
[DR_ACTION_TYP_SAMPLER] = DR_ACTION_STATE_TERM,
261283
[DR_ACTION_TYP_CTR] = DR_ACTION_STATE_NON_TERM,
262284
[DR_ACTION_TYP_MODIFY_HDR] = DR_ACTION_STATE_MODIFY_HDR,
263285
[DR_ACTION_TYP_L2_TO_TNL_L2] = DR_ACTION_STATE_ENCAP,
@@ -519,6 +541,10 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
519541
attr.reformat.size = action->reformat->size;
520542
attr.reformat.id = action->reformat->id;
521543
break;
544+
case DR_ACTION_TYP_SAMPLER:
545+
attr.final_icm_addr = rx_rule ? action->sampler->rx_icm_addr :
546+
action->sampler->tx_icm_addr;
547+
break;
522548
case DR_ACTION_TYP_VPORT:
523549
attr.hit_gvmi = action->vport->caps->vhca_gvmi;
524550
dest_action = action;
@@ -612,6 +638,7 @@ static unsigned int action_size[DR_ACTION_TYP_MAX] = {
612638
[DR_ACTION_TYP_VPORT] = sizeof(struct mlx5dr_action_vport),
613639
[DR_ACTION_TYP_PUSH_VLAN] = sizeof(struct mlx5dr_action_push_vlan),
614640
[DR_ACTION_TYP_INSERT_HDR] = sizeof(struct mlx5dr_action_reformat),
641+
[DR_ACTION_TYP_SAMPLER] = sizeof(struct mlx5dr_action_sampler),
615642
};
616643

617644
static struct mlx5dr_action *
@@ -824,6 +851,31 @@ struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value)
824851
return action;
825852
}
826853

854+
struct mlx5dr_action *
855+
mlx5dr_action_create_flow_sampler(struct mlx5dr_domain *dmn, u32 sampler_id)
856+
{
857+
struct mlx5dr_action *action;
858+
u64 icm_rx, icm_tx;
859+
int ret;
860+
861+
ret = mlx5dr_cmd_query_flow_sampler(dmn->mdev, sampler_id,
862+
&icm_rx, &icm_tx);
863+
if (ret)
864+
return NULL;
865+
866+
action = dr_action_create_generic(DR_ACTION_TYP_SAMPLER);
867+
if (!action)
868+
return NULL;
869+
870+
action->sampler->dmn = dmn;
871+
action->sampler->sampler_id = sampler_id;
872+
action->sampler->rx_icm_addr = icm_rx;
873+
action->sampler->tx_icm_addr = icm_tx;
874+
875+
refcount_inc(&dmn->refcount);
876+
return action;
877+
}
878+
827879
static int
828880
dr_action_verify_reformat_params(enum mlx5dr_action_type reformat_type,
829881
struct mlx5dr_domain *dmn,
@@ -1624,6 +1676,9 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
16241676
kfree(action->rewrite->data);
16251677
refcount_dec(&action->rewrite->dmn->refcount);
16261678
break;
1679+
case DR_ACTION_TYP_SAMPLER:
1680+
refcount_dec(&action->sampler->dmn->refcount);
1681+
break;
16271682
default:
16281683
break;
16291684
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,36 @@ int mlx5dr_cmd_query_flow_table(struct mlx5_core_dev *dev,
228228
return 0;
229229
}
230230

231+
int mlx5dr_cmd_query_flow_sampler(struct mlx5_core_dev *dev,
232+
u32 sampler_id,
233+
u64 *rx_icm_addr,
234+
u64 *tx_icm_addr)
235+
{
236+
u32 out[MLX5_ST_SZ_DW(query_sampler_obj_out)] = {};
237+
u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {};
238+
void *attr;
239+
int ret;
240+
241+
MLX5_SET(general_obj_in_cmd_hdr, in, opcode,
242+
MLX5_CMD_OP_QUERY_GENERAL_OBJECT);
243+
MLX5_SET(general_obj_in_cmd_hdr, in, obj_type,
244+
MLX5_GENERAL_OBJECT_TYPES_SAMPLER);
245+
MLX5_SET(general_obj_in_cmd_hdr, in, obj_id, sampler_id);
246+
247+
ret = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
248+
if (ret)
249+
return ret;
250+
251+
attr = MLX5_ADDR_OF(query_sampler_obj_out, out, sampler_object);
252+
253+
*rx_icm_addr = MLX5_GET64(sampler_obj, attr,
254+
sw_steering_icm_address_rx);
255+
*tx_icm_addr = MLX5_GET64(sampler_obj, attr,
256+
sw_steering_icm_address_tx);
257+
258+
return 0;
259+
}
260+
231261
int mlx5dr_cmd_sync_steering(struct mlx5_core_dev *mdev)
232262
{
233263
u32 in[MLX5_ST_SZ_DW(sync_steering_in)] = {};
@@ -711,6 +741,9 @@ int mlx5dr_cmd_set_fte(struct mlx5_core_dev *dev,
711741
fte->dest_arr[i].vport.reformat_id);
712742
}
713743
break;
744+
case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
745+
id = fte->dest_arr[i].sampler_id;
746+
break;
714747
default:
715748
id = fte->dest_arr[i].tir_num;
716749
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ enum mlx5dr_action_type {
124124
DR_ACTION_TYP_POP_VLAN,
125125
DR_ACTION_TYP_PUSH_VLAN,
126126
DR_ACTION_TYP_INSERT_HDR,
127+
DR_ACTION_TYP_SAMPLER,
127128
DR_ACTION_TYP_MAX,
128129
};
129130

@@ -919,6 +920,13 @@ struct mlx5dr_action_reformat {
919920
u8 param_1;
920921
};
921922

923+
struct mlx5dr_action_sampler {
924+
struct mlx5dr_domain *dmn;
925+
u64 rx_icm_addr;
926+
u64 tx_icm_addr;
927+
u32 sampler_id;
928+
};
929+
922930
struct mlx5dr_action_dest_tbl {
923931
u8 is_fw_tbl:1;
924932
union {
@@ -962,6 +970,7 @@ struct mlx5dr_action {
962970
void *data;
963971
struct mlx5dr_action_rewrite *rewrite;
964972
struct mlx5dr_action_reformat *reformat;
973+
struct mlx5dr_action_sampler *sampler;
965974
struct mlx5dr_action_dest_tbl *dest_tbl;
966975
struct mlx5dr_action_ctr *ctr;
967976
struct mlx5dr_action_vport *vport;
@@ -1116,6 +1125,10 @@ int mlx5dr_cmd_query_gvmi(struct mlx5_core_dev *mdev,
11161125
bool other_vport, u16 vport_number, u16 *gvmi);
11171126
int mlx5dr_cmd_query_esw_caps(struct mlx5_core_dev *mdev,
11181127
struct mlx5dr_esw_caps *caps);
1128+
int mlx5dr_cmd_query_flow_sampler(struct mlx5_core_dev *dev,
1129+
u32 sampler_id,
1130+
u64 *rx_icm_addr,
1131+
u64 *tx_icm_addr);
11191132
int mlx5dr_cmd_sync_steering(struct mlx5_core_dev *mdev);
11201133
int mlx5dr_cmd_set_fte_modify_and_vport(struct mlx5_core_dev *mdev,
11211134
u32 table_type,
@@ -1303,6 +1316,7 @@ struct mlx5dr_cmd_flow_destination_hw_info {
13031316
u32 ft_num;
13041317
u32 ft_id;
13051318
u32 counter_id;
1319+
u32 sampler_id;
13061320
struct {
13071321
u16 num;
13081322
u16 vhca_id;

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
387387
if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
388388
list_for_each_entry(dst, &fte->node.children, node.list) {
389389
enum mlx5_flow_destination_type type = dst->dest_attr.type;
390-
u32 ft_id;
390+
u32 id;
391391

392392
if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX ||
393393
num_term_actions >= MLX5_FLOW_CONTEXT_ACTION_MAX) {
@@ -425,9 +425,20 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
425425
num_term_actions++;
426426
break;
427427
case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM:
428-
ft_id = dst->dest_attr.ft_num;
428+
id = dst->dest_attr.ft_num;
429429
tmp_action = mlx5dr_action_create_dest_table_num(domain,
430-
ft_id);
430+
id);
431+
if (!tmp_action) {
432+
err = -ENOMEM;
433+
goto free_actions;
434+
}
435+
fs_dr_actions[fs_dr_num_actions++] = tmp_action;
436+
term_actions[num_term_actions++].dest = tmp_action;
437+
break;
438+
case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
439+
id = dst->dest_attr.sampler_id;
440+
tmp_action = mlx5dr_action_create_flow_sampler(domain,
441+
id);
431442
if (!tmp_action) {
432443
err = -ENOMEM;
433444
goto free_actions;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ struct mlx5dr_action *mlx5dr_action_create_drop(void);
100100

101101
struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
102102

103+
struct mlx5dr_action *
104+
mlx5dr_action_create_flow_sampler(struct mlx5dr_domain *dmn, u32 sampler_id);
105+
103106
struct mlx5dr_action *
104107
mlx5dr_action_create_flow_counter(u32 counter_id);
105108

include/linux/mlx5/mlx5_ifc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11083,6 +11083,11 @@ struct mlx5_ifc_create_sampler_obj_in_bits {
1108311083
struct mlx5_ifc_sampler_obj_bits sampler_object;
1108411084
};
1108511085

11086+
struct mlx5_ifc_query_sampler_obj_out_bits {
11087+
struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr;
11088+
struct mlx5_ifc_sampler_obj_bits sampler_object;
11089+
};
11090+
1108611091
enum {
1108711092
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_KEY_SIZE_128 = 0x0,
1108811093
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_KEY_SIZE_256 = 0x1,

0 commit comments

Comments
 (0)