4545#include "mlx5_core.h"
4646#include "lib/eq.h"
4747#include "lib/tout.h"
48+ #define CREATE_TRACE_POINTS
49+ #include "diag/cmd_tracepoint.h"
4850
4951enum {
5052 CMD_IF_REV = 5 ,
@@ -785,27 +787,14 @@ EXPORT_SYMBOL(mlx5_cmd_out_err);
785787static void cmd_status_print (struct mlx5_core_dev * dev , void * in , void * out )
786788{
787789 u16 opcode , op_mod ;
788- u32 syndrome ;
789- u8 status ;
790790 u16 uid ;
791- int err ;
792-
793- syndrome = MLX5_GET (mbox_out , out , syndrome );
794- status = MLX5_GET (mbox_out , out , status );
795791
796792 opcode = MLX5_GET (mbox_in , in , opcode );
797793 op_mod = MLX5_GET (mbox_in , in , op_mod );
798794 uid = MLX5_GET (mbox_in , in , uid );
799795
800- err = cmd_status_to_err (status );
801-
802796 if (!uid && opcode != MLX5_CMD_OP_DESTROY_MKEY )
803797 mlx5_cmd_out_err (dev , opcode , op_mod , out );
804- else
805- mlx5_core_dbg (dev ,
806- "%s(0x%x) op_mod(0x%x) uid(%d) failed, status %s(0x%x), syndrome (0x%x), err(%d)\n" ,
807- mlx5_command_str (opcode ), opcode , op_mod , uid ,
808- cmd_status_str (status ), status , syndrome , err );
809798}
810799
811800int mlx5_cmd_check (struct mlx5_core_dev * dev , int err , void * in , void * out )
@@ -1016,14 +1005,14 @@ static void cmd_work_handler(struct work_struct *work)
10161005 cmd_ent_get (ent );
10171006 set_bit (MLX5_CMD_ENT_STATE_PENDING_COMP , & ent -> state );
10181007
1008+ cmd_ent_get (ent ); /* for the _real_ FW event on completion */
10191009 /* Skip sending command to fw if internal error */
10201010 if (mlx5_cmd_is_down (dev ) || !opcode_allowed (& dev -> cmd , ent -> op )) {
10211011 ent -> ret = - ENXIO ;
10221012 mlx5_cmd_comp_handler (dev , 1ULL << ent -> idx , true);
10231013 return ;
10241014 }
10251015
1026- cmd_ent_get (ent ); /* for the _real_ FW event on completion */
10271016 /* ring doorbell after the descriptor is valid */
10281017 mlx5_core_dbg (dev , "writing 0x%x to command doorbell\n" , 1 << ent -> idx );
10291018 wmb ();
@@ -1672,8 +1661,8 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16721661 cmd_ent_put (ent ); /* timeout work was canceled */
16731662
16741663 if (!forced || /* Real FW completion */
1675- pci_channel_offline (dev -> pdev ) || /* FW is inaccessible */
1676- dev -> state == MLX5_DEVICE_STATE_INTERNAL_ERROR )
1664+ mlx5_cmd_is_down (dev ) || /* No real FW completion is expected */
1665+ ! opcode_allowed ( cmd , ent -> op ) )
16771666 cmd_ent_put (ent );
16781667
16791668 ent -> ts2 = ktime_get_ns ();
@@ -1892,6 +1881,16 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
18921881 return err ;
18931882}
18941883
1884+ static void mlx5_cmd_err_trace (struct mlx5_core_dev * dev , u16 opcode , u16 op_mod , void * out )
1885+ {
1886+ u32 syndrome = MLX5_GET (mbox_out , out , syndrome );
1887+ u8 status = MLX5_GET (mbox_out , out , status );
1888+
1889+ trace_mlx5_cmd (mlx5_command_str (opcode ), opcode , op_mod ,
1890+ cmd_status_str (status ), status , syndrome ,
1891+ cmd_status_to_err (status ));
1892+ }
1893+
18951894static void cmd_status_log (struct mlx5_core_dev * dev , u16 opcode , u8 status ,
18961895 u32 syndrome , int err )
18971896{
@@ -1914,16 +1913,18 @@ static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
19141913}
19151914
19161915/* preserve -EREMOTEIO for outbox.status != OK, otherwise return err as is */
1917- static int cmd_status_err (struct mlx5_core_dev * dev , int err , u16 opcode , void * out )
1916+ static int cmd_status_err (struct mlx5_core_dev * dev , int err , u16 opcode , u16 op_mod , void * out )
19181917{
19191918 u32 syndrome = MLX5_GET (mbox_out , out , syndrome );
19201919 u8 status = MLX5_GET (mbox_out , out , status );
19211920
19221921 if (err == - EREMOTEIO ) /* -EREMOTEIO is preserved */
19231922 err = - EIO ;
19241923
1925- if (!err && status != MLX5_CMD_STAT_OK )
1924+ if (!err && status != MLX5_CMD_STAT_OK ) {
19261925 err = - EREMOTEIO ;
1926+ mlx5_cmd_err_trace (dev , opcode , op_mod , out );
1927+ }
19271928
19281929 cmd_status_log (dev , opcode , status , syndrome , err );
19291930 return err ;
@@ -1951,9 +1952,9 @@ int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int
19511952{
19521953 int err = cmd_exec (dev , in , in_size , out , out_size , NULL , NULL , false);
19531954 u16 opcode = MLX5_GET (mbox_in , in , opcode );
1955+ u16 op_mod = MLX5_GET (mbox_in , in , op_mod );
19541956
1955- err = cmd_status_err (dev , err , opcode , out );
1956- return err ;
1957+ return cmd_status_err (dev , err , opcode , op_mod , out );
19571958}
19581959EXPORT_SYMBOL (mlx5_cmd_do );
19591960
@@ -1997,8 +1998,9 @@ int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
19971998{
19981999 int err = cmd_exec (dev , in , in_size , out , out_size , NULL , NULL , true);
19992000 u16 opcode = MLX5_GET (mbox_in , in , opcode );
2001+ u16 op_mod = MLX5_GET (mbox_in , in , op_mod );
20002002
2001- err = cmd_status_err (dev , err , opcode , out );
2003+ err = cmd_status_err (dev , err , opcode , op_mod , out );
20022004 return mlx5_cmd_check (dev , err , in , out );
20032005}
20042006EXPORT_SYMBOL (mlx5_cmd_exec_polling );
@@ -2034,7 +2036,7 @@ static void mlx5_cmd_exec_cb_handler(int status, void *_work)
20342036 struct mlx5_async_ctx * ctx ;
20352037
20362038 ctx = work -> ctx ;
2037- status = cmd_status_err (ctx -> dev , status , work -> opcode , work -> out );
2039+ status = cmd_status_err (ctx -> dev , status , work -> opcode , work -> op_mod , work -> out );
20382040 work -> user_callback (status , work );
20392041 if (atomic_dec_and_test (& ctx -> num_inflight ))
20402042 complete (& ctx -> inflight_done );
@@ -2049,6 +2051,7 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
20492051 work -> ctx = ctx ;
20502052 work -> user_callback = callback ;
20512053 work -> opcode = MLX5_GET (mbox_in , in , opcode );
2054+ work -> op_mod = MLX5_GET (mbox_in , in , op_mod );
20522055 work -> out = out ;
20532056 if (WARN_ON (!atomic_inc_not_zero (& ctx -> num_inflight )))
20542057 return - EIO ;
0 commit comments