Skip to content

Commit 4bec3ce

Browse files
committed
Merge tag 'mlx5-updates-2021-06-26' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2021-06-26 This series provides small updates to mlx5 driver. 1) Increase hairpin buffer size 2) Improve peroformance in SF allocation 3) Add IPsec support to uplink representor 4) Add stats for number of deleted kTLS TX offloaded connections 5) Add support for flow sampler in SW steering ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 3095f51 + 5589b8f commit 4bec3ce

File tree

14 files changed

+152
-16
lines changed

14 files changed

+152
-16
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv)
428428
spin_lock_init(&ipsec->sadb_rx_lock);
429429
ida_init(&ipsec->halloc);
430430
ipsec->en_priv = priv;
431-
ipsec->en_priv->ipsec = ipsec;
432431
ipsec->no_trailer = !!(mlx5_accel_ipsec_device_caps(priv->mdev) &
433432
MLX5_ACCEL_IPSEC_CAP_RX_NO_TRAILER);
434433
ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0,
@@ -438,6 +437,7 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv)
438437
return -ENOMEM;
439438
}
440439

440+
priv->ipsec = ipsec;
441441
mlx5e_accel_ipsec_fs_init(priv);
442442
netdev_dbg(priv->netdev, "IPSec attached to netdevice\n");
443443
return 0;

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ void mlx5e_ktls_del_tx(struct net_device *netdev, struct tls_context *tls_ctx)
138138
priv = netdev_priv(netdev);
139139
mdev = priv->mdev;
140140

141+
atomic64_inc(&priv_tx->sw_stats->tx_tls_del);
141142
mlx5e_destroy_tis(mdev, priv_tx->tisn);
142143
mlx5_ktls_destroy_key(mdev, priv_tx->key_id);
143144
kfree(priv_tx);

drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
struct mlx5e_tls_sw_stats {
4444
atomic64_t tx_tls_ctx;
45+
atomic64_t tx_tls_del;
4546
atomic64_t tx_tls_drop_metadata;
4647
atomic64_t tx_tls_drop_resync_alloc;
4748
atomic64_t tx_tls_drop_no_sync_data;

drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static const struct counter_desc mlx5e_tls_sw_stats_desc[] = {
4747

4848
static const struct counter_desc mlx5e_ktls_sw_stats_desc[] = {
4949
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_ctx) },
50+
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_del) },
5051
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, rx_tls_ctx) },
5152
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, rx_tls_del) },
5253
};

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "lib/mlx5.h"
5252
#define CREATE_TRACE_POINTS
5353
#include "diag/en_rep_tracepoint.h"
54+
#include "en_accel/ipsec.h"
5455

5556
#define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
5657
max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
@@ -630,13 +631,19 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev,
630631
struct net_device *netdev)
631632
{
632633
struct mlx5e_priv *priv = netdev_priv(netdev);
634+
int err;
635+
636+
err = mlx5e_ipsec_init(priv);
637+
if (err)
638+
mlx5_core_err(mdev, "Uplink rep IPsec initialization failed, %d\n", err);
633639

634640
mlx5e_vxlan_set_netdev_info(priv);
635641
return mlx5e_init_rep(mdev, netdev);
636642
}
637643

638644
static void mlx5e_cleanup_rep(struct mlx5e_priv *priv)
639645
{
646+
mlx5e_ipsec_cleanup(priv);
640647
}
641648

642649
static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
846846
hash_hairpin_info(peer_id, match_prio));
847847
mutex_unlock(&priv->fs.tc.hairpin_tbl_lock);
848848

849-
params.log_data_size = 15;
849+
params.log_data_size = 16;
850850
params.log_data_size = min_t(u8, params.log_data_size,
851851
MLX5_CAP_GEN(priv->mdev, log_max_hairpin_wq_data_sz));
852852
params.log_data_size = max_t(u8, params.log_data_size,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,9 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
15041504
(d1->type == MLX5_FLOW_DESTINATION_TYPE_TIR &&
15051505
d1->tir_num == d2->tir_num) ||
15061506
(d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM &&
1507-
d1->ft_num == d2->ft_num))
1507+
d1->ft_num == d2->ft_num) ||
1508+
(d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER &&
1509+
d1->sampler_id == d2->sampler_id))
15081510
return true;
15091511
}
15101512

drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,29 @@ static int mlx5_sf_hw_table_id_alloc(struct mlx5_sf_hw_table *table, u32 control
7373
u32 usr_sfnum)
7474
{
7575
struct mlx5_sf_hwc_table *hwc;
76+
int free_idx = -1;
7677
int i;
7778

7879
hwc = mlx5_sf_controller_to_hwc(table->dev, controller);
7980
if (!hwc->sfs)
8081
return -ENOSPC;
8182

82-
/* Check if sf with same sfnum already exists or not. */
8383
for (i = 0; i < hwc->max_fn; i++) {
84+
if (!hwc->sfs[i].allocated && free_idx == -1) {
85+
free_idx = i;
86+
continue;
87+
}
88+
8489
if (hwc->sfs[i].allocated && hwc->sfs[i].usr_sfnum == usr_sfnum)
8590
return -EEXIST;
8691
}
87-
/* Find the free entry and allocate the entry from the array */
88-
for (i = 0; i < hwc->max_fn; i++) {
89-
if (!hwc->sfs[i].allocated) {
90-
hwc->sfs[i].usr_sfnum = usr_sfnum;
91-
hwc->sfs[i].allocated = true;
92-
return i;
93-
}
94-
}
95-
return -ENOSPC;
92+
93+
if (free_idx == -1)
94+
return -ENOSPC;
95+
96+
hwc->sfs[free_idx].usr_sfnum = usr_sfnum;
97+
hwc->sfs[free_idx].allocated = true;
98+
return free_idx;
9699
}
97100

98101
static void mlx5_sf_hw_table_id_free(struct mlx5_sf_hw_table *table, u32 controller, int id)

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
}

0 commit comments

Comments
 (0)