Skip to content

Commit f46e92d

Browse files
Jianbo Liukuba-moo
authored andcommitted
net/mlx5e: Refactor IPsec TX tables creation
Add attribute for IPsec TX creation, pass all needed parameters in it, so tx_create() can be used by eswitch. Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/24d5ab988b0db2d39b7fde321b44ffe885d47828.1690802064.git.leon@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 91bafc6 commit f46e92d

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ struct mlx5e_ipsec_rx {
213213
struct xarray ipsec_obj_id_map;
214214
};
215215

216+
struct mlx5e_ipsec_tx_create_attr {
217+
int prio;
218+
int pol_level;
219+
int sa_level;
220+
int cnt_level;
221+
enum mlx5_flow_namespace_type chains_ns;
222+
};
223+
216224
struct mlx5e_ipsec {
217225
struct mlx5_core_dev *mdev;
218226
struct xarray sadb;

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,29 @@ static void tx_destroy(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_tx *tx,
569569
mlx5_destroy_flow_table(tx->ft.status);
570570
}
571571

572-
static int tx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_tx *tx,
572+
static void ipsec_tx_create_attr_set(struct mlx5e_ipsec *ipsec,
573+
struct mlx5e_ipsec_tx *tx,
574+
struct mlx5e_ipsec_tx_create_attr *attr)
575+
{
576+
attr->prio = 0;
577+
attr->pol_level = 0;
578+
attr->sa_level = 1;
579+
attr->cnt_level = 2;
580+
attr->chains_ns = MLX5_FLOW_NAMESPACE_EGRESS_IPSEC;
581+
}
582+
583+
static int tx_create(struct mlx5e_ipsec *ipsec, struct mlx5e_ipsec_tx *tx,
573584
struct mlx5_ipsec_fs *roce)
574585
{
586+
struct mlx5_core_dev *mdev = ipsec->mdev;
587+
struct mlx5e_ipsec_tx_create_attr attr;
575588
struct mlx5_flow_destination dest = {};
576589
struct mlx5_flow_table *ft;
577590
u32 flags = 0;
578591
int err;
579592

580-
ft = ipsec_ft_create(tx->ns, 2, 0, 1, 0);
593+
ipsec_tx_create_attr_set(ipsec, tx, &attr);
594+
ft = ipsec_ft_create(tx->ns, attr.cnt_level, attr.prio, 1, 0);
581595
if (IS_ERR(ft))
582596
return PTR_ERR(ft);
583597
tx->ft.status = ft;
@@ -590,7 +604,7 @@ static int tx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_tx *tx,
590604
tx->allow_tunnel_mode = mlx5_eswitch_block_encap(mdev);
591605
if (tx->allow_tunnel_mode)
592606
flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
593-
ft = ipsec_ft_create(tx->ns, 1, 0, 4, flags);
607+
ft = ipsec_ft_create(tx->ns, attr.sa_level, attr.prio, 4, flags);
594608
if (IS_ERR(ft)) {
595609
err = PTR_ERR(ft);
596610
goto err_sa_ft;
@@ -599,7 +613,7 @@ static int tx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_tx *tx,
599613

600614
if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_PRIO) {
601615
tx->chains = ipsec_chains_create(
602-
mdev, tx->ft.sa, MLX5_FLOW_NAMESPACE_EGRESS_IPSEC, 0, 0,
616+
mdev, tx->ft.sa, attr.chains_ns, attr.prio, attr.pol_level,
603617
&tx->ft.pol);
604618
if (IS_ERR(tx->chains)) {
605619
err = PTR_ERR(tx->chains);
@@ -609,7 +623,7 @@ static int tx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_tx *tx,
609623
goto connect_roce;
610624
}
611625

612-
ft = ipsec_ft_create(tx->ns, 0, 0, 2, 0);
626+
ft = ipsec_ft_create(tx->ns, attr.pol_level, attr.prio, 2, 0);
613627
if (IS_ERR(ft)) {
614628
err = PTR_ERR(ft);
615629
goto err_pol_ft;
@@ -656,7 +670,7 @@ static int tx_get(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
656670
if (tx->ft.refcnt)
657671
goto skip;
658672

659-
err = tx_create(mdev, tx, ipsec->roce);
673+
err = tx_create(ipsec, tx, ipsec->roce);
660674
if (err)
661675
return err;
662676

0 commit comments

Comments
 (0)