@@ -511,10 +511,11 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
511511 struct mlx5_flow_rule * dst ;
512512 void * in_flow_context , * vlan ;
513513 void * in_match_value ;
514+ int reformat_id = 0 ;
514515 unsigned int inlen ;
515516 int dst_cnt_size ;
517+ u32 * in , action ;
516518 void * in_dests ;
517- u32 * in ;
518519 int err ;
519520
520521 if (mlx5_set_extended_dest (dev , fte , & extended_dest ))
@@ -553,22 +554,42 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
553554
554555 MLX5_SET (flow_context , in_flow_context , extended_destination ,
555556 extended_dest );
556- if (extended_dest ) {
557- u32 action ;
558557
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+ }
568579 }
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+
570590 MLX5_SET (flow_context , in_flow_context , modify_header_id ,
571591 fte -> action .modify_hdr -> id );
592+ }
572593
573594 MLX5_SET (flow_context , in_flow_context , encrypt_decrypt_type ,
574595 fte -> action .crypto .type );
@@ -885,6 +906,8 @@ static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns,
885906
886907 pkt_reformat -> id = MLX5_GET (alloc_packet_reformat_context_out ,
887908 out , packet_reformat_id );
909+ pkt_reformat -> owner = MLX5_FLOW_RESOURCE_OWNER_FW ;
910+
888911 kfree (in );
889912 return err ;
890913}
@@ -969,6 +992,7 @@ static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns,
969992 err = mlx5_cmd_exec (dev , in , inlen , out , sizeof (out ));
970993
971994 modify_hdr -> id = MLX5_GET (alloc_modify_header_context_out , out , modify_header_id );
995+ modify_hdr -> owner = MLX5_FLOW_RESOURCE_OWNER_FW ;
972996 kfree (in );
973997 return err ;
974998}
0 commit comments