[PATCH v4 37/44] net/sxe2: wrap command params fill debug log in macro

liujie5 at linkdatatechnology.com liujie5 at linkdatatechnology.com
Thu Aug 27 04:39:54 CEST 2026


From: Jie Liu <liujie5 at linkdatatechnology.com>

sxe2_drv_cmd_params_fill() passes the opcode string as a parameter to
__sxe2_drv_cmd_params_fill() just to emit a debug log, and the debug
log is executed unconditionally on every command fill.

Move the PMD_DEV_LOG_DEBUG into the macro body wrapped in a do/while
block, dropping the opc_str parameter so the opcode stringization is
performed at the call site and the macro is a proper multi-statement
block.

Cc: stephen at networkplumber.org
Signed-off-by: Jie Liu <liujie5 at linkdatatechnology.com>
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sxe2/sxe2_cmd_chnl.c b/drivers/net/sxe2/sxe2_cmd_chnl.c
index 705d259412..b17d80d917 100644
--- a/drivers/net/sxe2/sxe2_cmd_chnl.c
+++ b/drivers/net/sxe2/sxe2_cmd_chnl.c
@@ -26,10 +26,9 @@ static void sxe2_drv_trace_id_alloc(uint64_t *trace_id)
 }
 
 static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
-		struct sxe2_drv_cmd_params *cmd, uint32_t opc, const char *opc_str,
+		struct sxe2_drv_cmd_params *cmd, uint32_t opc,
 		void *in_data, uint32_t in_len, void *out_data, uint32_t out_len)
 {
-	PMD_DEV_LOG_DEBUG(adapter, DRV, "cmd opcode:%s", opc_str);
 	cmd->timeout = SXE2_DRV_CMD_DFLT_TIMEOUT;
 	cmd->opcode  = opc;
 	cmd->vsi_id  = adapter->vsi_ctxt.dpdk_vsi_id;
@@ -44,8 +43,10 @@ static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
 }
 
 #define sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len) \
-	__sxe2_drv_cmd_params_fill(adapter, cmd, opc, #opc, in_data, in_len, out_data, out_len)
-
+	do { \
+		PMD_DEV_LOG_DEBUG(adapter, DRV, "cmd opcode:%s", #opc); \
+		__sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len); \
+	} while (0)
 
 int32_t sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter, struct sxe2_drv_dev_caps_resp *dev_caps)
 {
-- 
2.52.0



More information about the dev mailing list