@@ -673,7 +673,7 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv,
673
673
}
674
674
}
675
675
676
- static struct mlx5_flow_handle *
676
+ static int
677
677
mlx5e_tc_add_nic_flow (struct mlx5e_priv * priv ,
678
678
struct mlx5e_tc_flow_parse_attr * parse_attr ,
679
679
struct mlx5e_tc_flow * flow ,
@@ -689,14 +689,12 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
689
689
.reformat_id = 0 ,
690
690
};
691
691
struct mlx5_fc * counter = NULL ;
692
- struct mlx5_flow_handle * rule ;
693
692
bool table_created = false;
694
693
int err , dest_ix = 0 ;
695
694
696
695
if (flow -> flags & MLX5E_TC_FLOW_HAIRPIN ) {
697
696
err = mlx5e_hairpin_flow_add (priv , flow , parse_attr , extack );
698
697
if (err ) {
699
- rule = ERR_PTR (err );
700
698
goto err_add_hairpin_flow ;
701
699
}
702
700
if (flow -> flags & MLX5E_TC_FLOW_HAIRPIN_RSS ) {
@@ -716,7 +714,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
716
714
if (attr -> action & MLX5_FLOW_CONTEXT_ACTION_COUNT ) {
717
715
counter = mlx5_fc_create (dev , true);
718
716
if (IS_ERR (counter )) {
719
- rule = ERR_CAST (counter );
717
+ err = PTR_ERR (counter );
720
718
goto err_fc_create ;
721
719
}
722
720
dest [dest_ix ].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER ;
@@ -729,10 +727,8 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
729
727
err = mlx5e_attach_mod_hdr (priv , flow , parse_attr );
730
728
flow_act .modify_id = attr -> mod_hdr_id ;
731
729
kfree (parse_attr -> mod_hdr_actions );
732
- if (err ) {
733
- rule = ERR_PTR (err );
730
+ if (err )
734
731
goto err_create_mod_hdr_id ;
735
- }
736
732
}
737
733
738
734
if (IS_ERR_OR_NULL (priv -> fs .tc .t )) {
@@ -758,7 +754,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
758
754
"Failed to create tc offload table\n" );
759
755
netdev_err (priv -> netdev ,
760
756
"Failed to create tc offload table\n" );
761
- rule = ERR_CAST (priv -> fs .tc .t );
757
+ err = PTR_ERR (priv -> fs .tc .t );
762
758
goto err_create_ft ;
763
759
}
764
760
@@ -768,13 +764,15 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
768
764
if (attr -> match_level != MLX5_MATCH_NONE )
769
765
parse_attr -> spec .match_criteria_enable = MLX5_MATCH_OUTER_HEADERS ;
770
766
771
- rule = mlx5_add_flow_rules (priv -> fs .tc .t , & parse_attr -> spec ,
772
- & flow_act , dest , dest_ix );
767
+ flow -> rule [ 0 ] = mlx5_add_flow_rules (priv -> fs .tc .t , & parse_attr -> spec ,
768
+ & flow_act , dest , dest_ix );
773
769
774
- if (IS_ERR (rule ))
770
+ if (IS_ERR (flow -> rule [0 ])) {
771
+ err = PTR_ERR (flow -> rule [0 ]);
775
772
goto err_add_rule ;
773
+ }
776
774
777
- return rule ;
775
+ return 0 ;
778
776
779
777
err_add_rule :
780
778
if (table_created ) {
@@ -790,7 +788,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
790
788
if (flow -> flags & MLX5E_TC_FLOW_HAIRPIN )
791
789
mlx5e_hairpin_flow_del (priv , flow );
792
790
err_add_hairpin_flow :
793
- return rule ;
791
+ return err ;
794
792
}
795
793
796
794
static void mlx5e_tc_del_nic_flow (struct mlx5e_priv * priv ,
@@ -825,7 +823,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
825
823
struct mlx5e_tc_flow * flow ,
826
824
struct netlink_ext_ack * extack );
827
825
828
- static struct mlx5_flow_handle *
826
+ static int
829
827
mlx5e_tc_add_fdb_flow (struct mlx5e_priv * priv ,
830
828
struct mlx5e_tc_flow_parse_attr * parse_attr ,
831
829
struct mlx5e_tc_flow * flow ,
@@ -834,21 +832,20 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
834
832
struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
835
833
struct mlx5_esw_flow_attr * attr = flow -> esw_attr ;
836
834
struct net_device * out_dev , * encap_dev = NULL ;
837
- struct mlx5_flow_handle * rule = NULL ;
838
835
struct mlx5_fc * counter = NULL ;
839
836
struct mlx5e_rep_priv * rpriv ;
840
837
struct mlx5e_priv * out_priv ;
841
- int err ;
838
+ int err = 0 , encap_err = 0 ;
842
839
843
840
if (attr -> action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ) {
844
841
out_dev = __dev_get_by_index (dev_net (priv -> netdev ),
845
842
attr -> parse_attr -> mirred_ifindex );
846
- err = mlx5e_attach_encap (priv , & parse_attr -> tun_info ,
847
- out_dev , & encap_dev , flow , extack );
848
- if ( err ) {
849
- rule = ERR_PTR ( err );
850
- if ( err != - EAGAIN )
851
- goto err_attach_encap ;
843
+ encap_err = mlx5e_attach_encap (priv , & parse_attr -> tun_info ,
844
+ out_dev , & encap_dev , flow ,
845
+ extack );
846
+ if ( encap_err && encap_err != - EAGAIN ) {
847
+ err = encap_err ;
848
+ goto err_attach_encap ;
852
849
}
853
850
out_priv = netdev_priv (encap_dev );
854
851
rpriv = out_priv -> ppriv ;
@@ -857,49 +854,49 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
857
854
}
858
855
859
856
err = mlx5_eswitch_add_vlan_action (esw , attr );
860
- if (err ) {
861
- rule = ERR_PTR (err );
857
+ if (err )
862
858
goto err_add_vlan ;
863
- }
864
859
865
860
if (attr -> action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) {
866
861
err = mlx5e_attach_mod_hdr (priv , flow , parse_attr );
867
862
kfree (parse_attr -> mod_hdr_actions );
868
- if (err ) {
869
- rule = ERR_PTR (err );
863
+ if (err )
870
864
goto err_mod_hdr ;
871
- }
872
865
}
873
866
874
867
if (attr -> action & MLX5_FLOW_CONTEXT_ACTION_COUNT ) {
875
868
counter = mlx5_fc_create (esw -> dev , true);
876
869
if (IS_ERR (counter )) {
877
- rule = ERR_CAST (counter );
870
+ err = PTR_ERR (counter );
878
871
goto err_create_counter ;
879
872
}
880
873
881
874
attr -> counter = counter ;
882
875
}
883
876
884
- /* we get here if (1) there's no error (rule being null) or when
877
+ /* we get here if (1) there's no error or when
885
878
* (2) there's an encap action and we're on -EAGAIN (no valid neigh)
886
879
*/
887
- if (rule != ERR_PTR (- EAGAIN )) {
888
- rule = mlx5_eswitch_add_offloaded_rule (esw , & parse_attr -> spec , attr );
889
- if (IS_ERR (rule ))
880
+ if (encap_err != - EAGAIN ) {
881
+ flow -> rule [0 ] = mlx5_eswitch_add_offloaded_rule (esw , & parse_attr -> spec , attr );
882
+ if (IS_ERR (flow -> rule [0 ])) {
883
+ err = PTR_ERR (flow -> rule [0 ]);
890
884
goto err_add_rule ;
885
+ }
891
886
892
887
if (attr -> mirror_count ) {
893
888
flow -> rule [1 ] = mlx5_eswitch_add_fwd_rule (esw , & parse_attr -> spec , attr );
894
- if (IS_ERR (flow -> rule [1 ]))
889
+ if (IS_ERR (flow -> rule [1 ])) {
890
+ err = PTR_ERR (flow -> rule [1 ]);
895
891
goto err_fwd_rule ;
892
+ }
896
893
}
897
894
}
898
- return rule ;
895
+
896
+ return encap_err ;
899
897
900
898
err_fwd_rule :
901
- mlx5_eswitch_del_offloaded_rule (esw , rule , attr );
902
- rule = flow -> rule [1 ];
899
+ mlx5_eswitch_del_offloaded_rule (esw , flow -> rule [0 ], attr );
903
900
err_add_rule :
904
901
mlx5_fc_destroy (esw -> dev , counter );
905
902
err_create_counter :
@@ -911,7 +908,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
911
908
if (attr -> action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT )
912
909
mlx5e_detach_encap (priv , flow );
913
910
err_attach_encap :
914
- return rule ;
911
+ return err ;
915
912
}
916
913
917
914
static void mlx5e_tc_del_fdb_flow (struct mlx5e_priv * priv ,
@@ -2959,22 +2956,17 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
2959
2956
extack );
2960
2957
if (err < 0 )
2961
2958
goto err_free ;
2962
- flow -> rule [0 ] = mlx5e_tc_add_fdb_flow (priv , parse_attr , flow ,
2963
- extack );
2959
+ err = mlx5e_tc_add_fdb_flow (priv , parse_attr , flow , extack );
2964
2960
} else {
2965
2961
err = parse_tc_nic_actions (priv , f -> exts , parse_attr , flow ,
2966
2962
extack );
2967
2963
if (err < 0 )
2968
2964
goto err_free ;
2969
- flow -> rule [0 ] = mlx5e_tc_add_nic_flow (priv , parse_attr , flow ,
2970
- extack );
2965
+ err = mlx5e_tc_add_nic_flow (priv , parse_attr , flow , extack );
2971
2966
}
2972
2967
2973
- if (IS_ERR (flow -> rule [0 ])) {
2974
- err = PTR_ERR (flow -> rule [0 ]);
2975
- if (err != - EAGAIN )
2976
- goto err_free ;
2977
- }
2968
+ if (err && err != - EAGAIN )
2969
+ goto err_free ;
2978
2970
2979
2971
if (err != - EAGAIN )
2980
2972
flow -> flags |= MLX5E_TC_FLOW_OFFLOADED ;
0 commit comments