@@ -31,6 +31,7 @@ next_action_state[DR_ACTION_DOMAIN_MAX][DR_ACTION_STATE_MAX][DR_ACTION_TYP_MAX]
31
31
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
32
32
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
33
33
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
34
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
34
35
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_NON_TERM ,
35
36
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
36
37
[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]
45
46
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
46
47
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
47
48
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
49
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
48
50
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_DECAP ,
49
51
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_DECAP ,
50
52
[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]
57
59
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
58
60
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
59
61
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
62
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
60
63
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_ENCAP ,
61
64
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_ENCAP ,
62
65
},
63
66
[DR_ACTION_STATE_MODIFY_HDR ] = {
64
67
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
65
68
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
66
69
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
70
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
67
71
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_MODIFY_HDR ,
68
72
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_HDR ,
69
73
[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]
74
78
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
75
79
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
76
80
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
81
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
77
82
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_MODIFY_VLAN ,
78
83
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_VLAN ,
79
84
[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]
86
91
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
87
92
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
88
93
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
94
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
89
95
[DR_ACTION_TYP_TAG ] = DR_ACTION_STATE_NON_TERM ,
90
96
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
91
97
[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]
104
110
[DR_ACTION_STATE_NO_ACTION ] = {
105
111
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
106
112
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
113
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
107
114
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
108
115
[DR_ACTION_TYP_L2_TO_TNL_L2 ] = DR_ACTION_STATE_ENCAP ,
109
116
[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]
114
121
[DR_ACTION_STATE_ENCAP ] = {
115
122
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
116
123
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
124
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
117
125
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_ENCAP ,
118
126
},
119
127
[DR_ACTION_STATE_MODIFY_HDR ] = {
120
128
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
121
129
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
130
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
122
131
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_HDR ,
123
132
[DR_ACTION_TYP_L2_TO_TNL_L2 ] = DR_ACTION_STATE_ENCAP ,
124
133
[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]
128
137
[DR_ACTION_STATE_MODIFY_VLAN ] = {
129
138
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
130
139
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
140
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
131
141
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_VLAN ,
132
142
[DR_ACTION_TYP_PUSH_VLAN ] = DR_ACTION_STATE_MODIFY_VLAN ,
133
143
[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]
137
147
[DR_ACTION_STATE_NON_TERM ] = {
138
148
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
139
149
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
150
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
140
151
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
141
152
[DR_ACTION_TYP_L2_TO_TNL_L2 ] = DR_ACTION_STATE_ENCAP ,
142
153
[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]
152
163
[DR_ACTION_STATE_NO_ACTION ] = {
153
164
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
154
165
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
166
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
155
167
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
156
168
[DR_ACTION_TYP_TNL_L2_TO_L2 ] = DR_ACTION_STATE_DECAP ,
157
169
[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]
166
178
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
167
179
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
168
180
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_DECAP ,
181
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
169
182
[DR_ACTION_TYP_MODIFY_HDR ] = DR_ACTION_STATE_MODIFY_HDR ,
170
183
[DR_ACTION_TYP_POP_VLAN ] = DR_ACTION_STATE_MODIFY_VLAN ,
171
184
[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]
178
191
[DR_ACTION_TYP_QP ] = DR_ACTION_STATE_TERM ,
179
192
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
180
193
[DR_ACTION_TYP_VPORT ] = DR_ACTION_STATE_TERM ,
194
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
181
195
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_ENCAP ,
182
196
},
183
197
[DR_ACTION_STATE_MODIFY_HDR ] = {
184
198
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
185
199
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
200
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
186
201
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_HDR ,
187
202
[DR_ACTION_TYP_VPORT ] = DR_ACTION_STATE_TERM ,
188
203
[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]
192
207
[DR_ACTION_STATE_MODIFY_VLAN ] = {
193
208
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
194
209
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
210
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
195
211
[DR_ACTION_TYP_POP_VLAN ] = DR_ACTION_STATE_MODIFY_VLAN ,
196
212
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_VLAN ,
197
213
[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]
203
219
[DR_ACTION_STATE_NON_TERM ] = {
204
220
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
205
221
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
222
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
206
223
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
207
224
[DR_ACTION_TYP_TNL_L2_TO_L2 ] = DR_ACTION_STATE_DECAP ,
208
225
[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]
221
238
[DR_ACTION_STATE_NO_ACTION ] = {
222
239
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
223
240
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
241
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
224
242
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
225
243
[DR_ACTION_TYP_MODIFY_HDR ] = DR_ACTION_STATE_MODIFY_HDR ,
226
244
[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]
233
251
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
234
252
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
235
253
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_ENCAP ,
254
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
236
255
[DR_ACTION_TYP_VPORT ] = DR_ACTION_STATE_TERM ,
237
256
},
238
257
[DR_ACTION_STATE_MODIFY_HDR ] = {
239
258
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
240
259
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
260
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
241
261
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_HDR ,
242
262
[DR_ACTION_TYP_L2_TO_TNL_L2 ] = DR_ACTION_STATE_ENCAP ,
243
263
[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]
248
268
[DR_ACTION_STATE_MODIFY_VLAN ] = {
249
269
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
250
270
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
271
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
251
272
[DR_ACTION_TYP_PUSH_VLAN ] = DR_ACTION_STATE_MODIFY_VLAN ,
252
273
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_MODIFY_VLAN ,
253
274
[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]
258
279
[DR_ACTION_STATE_NON_TERM ] = {
259
280
[DR_ACTION_TYP_DROP ] = DR_ACTION_STATE_TERM ,
260
281
[DR_ACTION_TYP_FT ] = DR_ACTION_STATE_TERM ,
282
+ [DR_ACTION_TYP_SAMPLER ] = DR_ACTION_STATE_TERM ,
261
283
[DR_ACTION_TYP_CTR ] = DR_ACTION_STATE_NON_TERM ,
262
284
[DR_ACTION_TYP_MODIFY_HDR ] = DR_ACTION_STATE_MODIFY_HDR ,
263
285
[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,
519
541
attr .reformat .size = action -> reformat -> size ;
520
542
attr .reformat .id = action -> reformat -> id ;
521
543
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 ;
522
548
case DR_ACTION_TYP_VPORT :
523
549
attr .hit_gvmi = action -> vport -> caps -> vhca_gvmi ;
524
550
dest_action = action ;
@@ -612,6 +638,7 @@ static unsigned int action_size[DR_ACTION_TYP_MAX] = {
612
638
[DR_ACTION_TYP_VPORT ] = sizeof (struct mlx5dr_action_vport ),
613
639
[DR_ACTION_TYP_PUSH_VLAN ] = sizeof (struct mlx5dr_action_push_vlan ),
614
640
[DR_ACTION_TYP_INSERT_HDR ] = sizeof (struct mlx5dr_action_reformat ),
641
+ [DR_ACTION_TYP_SAMPLER ] = sizeof (struct mlx5dr_action_sampler ),
615
642
};
616
643
617
644
static struct mlx5dr_action *
@@ -824,6 +851,31 @@ struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value)
824
851
return action ;
825
852
}
826
853
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
+
827
879
static int
828
880
dr_action_verify_reformat_params (enum mlx5dr_action_type reformat_type ,
829
881
struct mlx5dr_domain * dmn ,
@@ -1624,6 +1676,9 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
1624
1676
kfree (action -> rewrite -> data );
1625
1677
refcount_dec (& action -> rewrite -> dmn -> refcount );
1626
1678
break ;
1679
+ case DR_ACTION_TYP_SAMPLER :
1680
+ refcount_dec (& action -> sampler -> dmn -> refcount );
1681
+ break ;
1627
1682
default :
1628
1683
break ;
1629
1684
}
0 commit comments