@@ -511,10 +511,11 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
511
511
struct mlx5_flow_rule * dst ;
512
512
void * in_flow_context , * vlan ;
513
513
void * in_match_value ;
514
+ int reformat_id = 0 ;
514
515
unsigned int inlen ;
515
516
int dst_cnt_size ;
517
+ u32 * in , action ;
516
518
void * in_dests ;
517
- u32 * in ;
518
519
int err ;
519
520
520
521
if (mlx5_set_extended_dest (dev , fte , & extended_dest ))
@@ -553,22 +554,42 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
553
554
554
555
MLX5_SET (flow_context , in_flow_context , extended_destination ,
555
556
extended_dest );
556
- if (extended_dest ) {
557
- u32 action ;
558
557
559
- action = fte -> action .action &
560
- ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ;
561
- MLX5_SET (flow_context , in_flow_context , action , action );
562
- } else {
563
- MLX5_SET (flow_context , in_flow_context , action ,
564
- fte -> action .action );
565
- if (fte -> action .pkt_reformat )
566
- MLX5_SET (flow_context , in_flow_context , packet_reformat_id ,
567
- fte -> action .pkt_reformat -> id );
558
+ action = fte -> action .action ;
559
+ if (extended_dest )
560
+ action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ;
561
+
562
+ MLX5_SET (flow_context , in_flow_context , action , action );
563
+
564
+ if (!extended_dest && fte -> action .pkt_reformat ) {
565
+ struct mlx5_pkt_reformat * pkt_reformat = fte -> action .pkt_reformat ;
566
+
567
+ if (pkt_reformat -> owner == MLX5_FLOW_RESOURCE_OWNER_SW ) {
568
+ reformat_id = mlx5_fs_dr_action_get_pkt_reformat_id (pkt_reformat );
569
+ if (reformat_id < 0 ) {
570
+ mlx5_core_err (dev ,
571
+ "Unsupported SW-owned pkt_reformat type (%d) in FW-owned table\n" ,
572
+ pkt_reformat -> reformat_type );
573
+ err = reformat_id ;
574
+ goto err_out ;
575
+ }
576
+ } else {
577
+ reformat_id = fte -> action .pkt_reformat -> id ;
578
+ }
568
579
}
569
- if (fte -> action .modify_hdr )
580
+
581
+ MLX5_SET (flow_context , in_flow_context , packet_reformat_id , (u32 )reformat_id );
582
+
583
+ if (fte -> action .modify_hdr ) {
584
+ if (fte -> action .modify_hdr -> owner == MLX5_FLOW_RESOURCE_OWNER_SW ) {
585
+ mlx5_core_err (dev , "Can't use SW-owned modify_hdr in FW-owned table\n" );
586
+ err = - EOPNOTSUPP ;
587
+ goto err_out ;
588
+ }
589
+
570
590
MLX5_SET (flow_context , in_flow_context , modify_header_id ,
571
591
fte -> action .modify_hdr -> id );
592
+ }
572
593
573
594
MLX5_SET (flow_context , in_flow_context , encrypt_decrypt_type ,
574
595
fte -> action .crypto .type );
@@ -885,6 +906,8 @@ static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns,
885
906
886
907
pkt_reformat -> id = MLX5_GET (alloc_packet_reformat_context_out ,
887
908
out , packet_reformat_id );
909
+ pkt_reformat -> owner = MLX5_FLOW_RESOURCE_OWNER_FW ;
910
+
888
911
kfree (in );
889
912
return err ;
890
913
}
@@ -969,6 +992,7 @@ static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns,
969
992
err = mlx5_cmd_exec (dev , in , inlen , out , sizeof (out ));
970
993
971
994
modify_hdr -> id = MLX5_GET (alloc_modify_header_context_out , out , modify_header_id );
995
+ modify_hdr -> owner = MLX5_FLOW_RESOURCE_OWNER_FW ;
972
996
kfree (in );
973
997
return err ;
974
998
}
0 commit comments