Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: stop intermixing AQ commands/responses debug dumps

The ice_debug_cq() function is called to generate a debug log of control
queue messages both sent and received. It currently does this over a
potential total of 6 different printk invocations.

The main logic prints over 4 calls to ice_debug():

1. The metadata including opcode, flags, datalength and return value.
2. The cookie in the descriptor.
3. The parameter values.
4. The address for the databuffer.

In addition, if the descriptor has a data buffer, it can be logged with two
additional prints:

5. A message indicating the start of the data buffer.
6. The actual data buffer, printed using print_hex_dump_debug.

This can lead to trouble in the event that two different PFs are logging
messages. The messages become intermixed and it may not be possible to
determine which part of the output belongs to which control queue message.

To fix this, it needs to be possible to unambiguously determine which
messages belong together. This is trivial for the messages that comprise
the main printing. Combine them together into a single invocation of
ice_debug().

The message containing a hex-dump of the data buffer is a bit more
complicated. This is printed separately as part of print_hex_dump_debug.
This function takes a prefix, which is currently always set to
KBUILD_MODNAME. Extend this prefix to include the buffer address for the
databuffer, which is printed as part of the main print, and which is
guaranteed to be unique for each buffer.

Refactor the ice_debug_array(), introducing an ice_debug_array_w_prefix().
Build the prefix by combining KBUILD_MODNAME with the databuffer address
using snprintf().

These changes make it possible to unambiguously determine what data belongs
to what control queue message.

Reported-by: Jacek Wierzbicki <jacek.wierzbicki@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Przemek Kitszel and committed by
Tony Nguyen
74ce564a 6bd7cb52

+25 -20
+11 -10
drivers/net/ethernet/intel/ice/ice_controlq.c
··· 936 936 datalen = le16_to_cpu(cq_desc->datalen); 937 937 flags = le16_to_cpu(cq_desc->flags); 938 938 939 - ice_debug(hw, ICE_DBG_AQ_DESC, "%s %s: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n", 939 + ice_debug(hw, ICE_DBG_AQ_DESC, "%s %s: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n\tcookie (h,l) 0x%08X 0x%08X\n\tparam (0,1) 0x%08X 0x%08X\n\taddr (h,l) 0x%08X 0x%08X\n", 940 940 ice_ctl_q_str(cq->qtype), response ? "Response" : "Command", 941 941 le16_to_cpu(cq_desc->opcode), flags, datalen, 942 - le16_to_cpu(cq_desc->retval)); 943 - ice_debug(hw, ICE_DBG_AQ_DESC, "\tcookie (h,l) 0x%08X 0x%08X\n", 942 + le16_to_cpu(cq_desc->retval), 944 943 le32_to_cpu(cq_desc->cookie_high), 945 - le32_to_cpu(cq_desc->cookie_low)); 946 - ice_debug(hw, ICE_DBG_AQ_DESC, "\tparam (0,1) 0x%08X 0x%08X\n", 944 + le32_to_cpu(cq_desc->cookie_low), 947 945 le32_to_cpu(cq_desc->params.generic.param0), 948 - le32_to_cpu(cq_desc->params.generic.param1)); 949 - ice_debug(hw, ICE_DBG_AQ_DESC, "\taddr (h,l) 0x%08X 0x%08X\n", 946 + le32_to_cpu(cq_desc->params.generic.param1), 950 947 le32_to_cpu(cq_desc->params.generic.addr_high), 951 948 le32_to_cpu(cq_desc->params.generic.addr_low)); 952 949 /* Dump buffer iff 1) one exists and 2) is either a response indicated ··· 951 954 */ 952 955 if (buf && cq_desc->datalen && 953 956 (flags & (ICE_AQ_FLAG_DD | ICE_AQ_FLAG_CMP | ICE_AQ_FLAG_RD))) { 954 - ice_debug(hw, ICE_DBG_AQ_DESC_BUF, "Buffer:\n"); 957 + char prefix[] = KBUILD_MODNAME " 0x12341234 0x12341234 "; 955 958 956 - ice_debug_array(hw, ICE_DBG_AQ_DESC_BUF, 16, 1, buf, 957 - min_t(u16, buf_len, datalen)); 959 + sprintf(prefix, KBUILD_MODNAME " 0x%08X 0x%08X ", 960 + le32_to_cpu(cq_desc->params.generic.addr_high), 961 + le32_to_cpu(cq_desc->params.generic.addr_low)); 962 + ice_debug_array_w_prefix(hw, ICE_DBG_AQ_DESC_BUF, prefix, 963 + buf, 964 + min_t(u16, buf_len, datalen)); 958 965 } 959 966 } 960 967
+14 -10
drivers/net/ethernet/intel/ice/ice_osdep.h
··· 43 43 #define ice_debug(hw, type, fmt, args...) \ 44 44 dev_dbg(ice_hw_to_dev(hw), fmt, ##args) 45 45 46 - #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 47 - print_hex_dump_debug(KBUILD_MODNAME " ", \ 48 - DUMP_PREFIX_OFFSET, rowsize, \ 49 - groupsize, buf, len, false) 50 - #else 46 + #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \ 47 + print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET, \ 48 + rowsize, groupsize, buf, len, false) 49 + #else /* CONFIG_DYNAMIC_DEBUG */ 51 50 #define ice_debug(hw, type, fmt, args...) \ 52 51 do { \ 53 52 if ((type) & (hw)->debug_mask) \ ··· 54 55 } while (0) 55 56 56 57 #ifdef DEBUG 57 - #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 58 + #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \ 58 59 do { \ 59 60 if ((type) & (hw)->debug_mask) \ 60 - print_hex_dump_debug(KBUILD_MODNAME, \ 61 - DUMP_PREFIX_OFFSET, \ 61 + print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,\ 62 62 rowsize, groupsize, buf, \ 63 63 len, false); \ 64 64 } while (0) 65 - #else 66 - #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 65 + #else /* DEBUG */ 66 + #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \ 67 67 do { \ 68 68 struct ice_hw *hw_l = hw; \ 69 69 if ((type) & (hw_l)->debug_mask) { \ ··· 79 81 } while (0) 80 82 #endif /* DEBUG */ 81 83 #endif /* CONFIG_DYNAMIC_DEBUG */ 84 + 85 + #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 86 + _ice_debug_array(hw, type, KBUILD_MODNAME, rowsize, groupsize, buf, len) 87 + 88 + #define ice_debug_array_w_prefix(hw, type, prefix, buf, len) \ 89 + _ice_debug_array(hw, type, prefix, 16, 1, buf, len) 82 90 83 91 #endif /* _ICE_OSDEP_H_ */