@@ -456,6 +456,17 @@ static void setup_fte_reg_a(struct mlx5_flow_spec *spec)
456
456
misc_parameters_2 .metadata_reg_a , MLX5_ETH_WQE_FT_META_IPSEC );
457
457
}
458
458
459
+ static void setup_fte_reg_c0 (struct mlx5_flow_spec * spec , u32 reqid )
460
+ {
461
+ /* Pass policy check before choosing this SA */
462
+ spec -> match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS_2 ;
463
+
464
+ MLX5_SET (fte_match_param , spec -> match_criteria ,
465
+ misc_parameters_2 .metadata_reg_c_0 , reqid );
466
+ MLX5_SET (fte_match_param , spec -> match_value ,
467
+ misc_parameters_2 .metadata_reg_c_0 , reqid );
468
+ }
469
+
459
470
static int setup_modify_header (struct mlx5_core_dev * mdev , u32 val , u8 dir ,
460
471
struct mlx5_flow_act * flow_act )
461
472
{
@@ -470,6 +481,11 @@ static int setup_modify_header(struct mlx5_core_dev *mdev, u32 val, u8 dir,
470
481
MLX5_ACTION_IN_FIELD_METADATA_REG_B );
471
482
ns_type = MLX5_FLOW_NAMESPACE_KERNEL ;
472
483
break ;
484
+ case XFRM_DEV_OFFLOAD_OUT :
485
+ MLX5_SET (set_action_in , action , field ,
486
+ MLX5_ACTION_IN_FIELD_METADATA_REG_C_0 );
487
+ ns_type = MLX5_FLOW_NAMESPACE_EGRESS ;
488
+ break ;
473
489
default :
474
490
return - EINVAL ;
475
491
}
@@ -646,6 +662,7 @@ static int tx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
646
662
setup_fte_reg_a (spec );
647
663
break ;
648
664
case XFRM_DEV_OFFLOAD_PACKET :
665
+ setup_fte_reg_c0 (spec , attrs -> reqid );
649
666
err = setup_pkt_reformat (mdev , attrs , & flow_act );
650
667
if (err )
651
668
goto err_pkt_reformat ;
@@ -712,6 +729,11 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
712
729
713
730
setup_fte_no_frags (spec );
714
731
732
+ err = setup_modify_header (mdev , attrs -> reqid , XFRM_DEV_OFFLOAD_OUT ,
733
+ & flow_act );
734
+ if (err )
735
+ goto err_mod_header ;
736
+
715
737
switch (attrs -> action ) {
716
738
case XFRM_POLICY_ALLOW :
717
739
flow_act .action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ;
@@ -741,10 +763,13 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
741
763
}
742
764
743
765
kvfree (spec );
744
- pol_entry -> rule = rule ;
766
+ pol_entry -> ipsec_rule .rule = rule ;
767
+ pol_entry -> ipsec_rule .modify_hdr = flow_act .modify_hdr ;
745
768
return 0 ;
746
769
747
770
err_action :
771
+ mlx5_modify_header_dealloc (mdev , flow_act .modify_hdr );
772
+ err_mod_header :
748
773
kvfree (spec );
749
774
err_alloc :
750
775
tx_ft_put (pol_entry -> ipsec );
@@ -807,7 +832,7 @@ static int rx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
807
832
}
808
833
809
834
kvfree (spec );
810
- pol_entry -> rule = rule ;
835
+ pol_entry -> ipsec_rule . rule = rule ;
811
836
return 0 ;
812
837
813
838
err_action :
@@ -964,16 +989,18 @@ int mlx5e_accel_ipsec_fs_add_pol(struct mlx5e_ipsec_pol_entry *pol_entry)
964
989
965
990
void mlx5e_accel_ipsec_fs_del_pol (struct mlx5e_ipsec_pol_entry * pol_entry )
966
991
{
992
+ struct mlx5e_ipsec_rule * ipsec_rule = & pol_entry -> ipsec_rule ;
967
993
struct mlx5_core_dev * mdev = mlx5e_ipsec_pol2dev (pol_entry );
968
994
969
- mlx5_del_flow_rules (pol_entry -> rule );
995
+ mlx5_del_flow_rules (ipsec_rule -> rule );
970
996
971
- if (pol_entry -> attrs .dir == XFRM_DEV_OFFLOAD_OUT ) {
972
- tx_ft_put ( pol_entry -> ipsec );
997
+ if (pol_entry -> attrs .dir == XFRM_DEV_OFFLOAD_IN ) {
998
+ rx_ft_put ( mdev , pol_entry -> ipsec , pol_entry -> attrs . family );
973
999
return ;
974
1000
}
975
1001
976
- rx_ft_put (mdev , pol_entry -> ipsec , pol_entry -> attrs .family );
1002
+ mlx5_modify_header_dealloc (mdev , ipsec_rule -> modify_hdr );
1003
+ tx_ft_put (pol_entry -> ipsec );
977
1004
}
978
1005
979
1006
void mlx5e_accel_ipsec_fs_cleanup (struct mlx5e_ipsec * ipsec )
0 commit comments