Intel Wired LAN Driver Updates 2024-08-26 (ice)
Subsystems (3)
Tony Nguyen
maintainerThis series contains updates to ice driver only.
Jake implements and uses rd32_poll_timeout to replace a jiffies loop for calling ice_sq_done. The rd32_poll_timeout() function is designed to allow simplifying other places in the driver where we need to read a register until it matches a known value.
Jake, Bruce, and Przemek update ice_debug_cq() to be more robust, and more useful for tracing control queue messages sent and received by the device driver.
Jake rewords several commands in the ice_control.c file which previously referred to the "Admin queue" when they were actually generic functions usable on any control queue.
Jake removes the unused and unnecessary cmd_buf array allocation for send queues. This logic originally was going to be useful if we ever implemented asynchronous completion of transmit messages. This support is unlikely to materialize, so the overhead of allocating a command buffer is unnecessary.
Sergey improves the log messages when the ice driver reports that the NVM version on the device is not supported by the driver. Now, these messages include both the discovered NVM version and the requested/expected NVM version.
Aleksandr Mishin corrects overallocation of memory related to adding scheduler nodes.
The following are changes since commit 18aaa82bd36ae3d4eaa3f1d1d8cf643e39f151cd:
net: netlink: Remove the dump_cb_mutex field from struct netlink_sock
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 100GbE
Aleksandr Mishin (1):
ice: Adjust over allocation of memory in ice_sched_add_root_node() and
ice_sched_add_node()
Bruce Allan (1):
ice: do not clutter debug logs with unused data
Jacob Keller (4):
ice: implement and use rd32_poll_timeout for ice_sq_done timeout
ice: improve debug print for control queue messages
ice: reword comments referring to control queues
ice: remove unnecessary control queue cmd_buf arrays
Przemek Kitszel (1):
ice: stop intermixing AQ commands/responses debug dumps
Sergey Temerkhanov (1):
ice: Report NVM version numbers on mismatch during load
.../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_controlq.c | 178 +++++++++--------- drivers/net/ethernet/intel/ice/ice_controlq.h | 5 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 28 ++- drivers/net/ethernet/intel/ice/ice_sched.c | 6 +- 5 files changed, 119 insertions(+), 102 deletions(-)
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 1/8 ice: implement and use rd32_poll_timeout for ice_sq_done timeout
From: Jacob Keller <[email protected]>
The ice_sq_done function is used to check the control queue head register and determine whether or not the control queue processing is done. This function is called in a loop checking against jiffies for a specified timeout.
The pattern of reading a register in a loop until a condition is true or a timeout is reached is a relatively common pattern. In fact, the kernel provides a read_poll_timeout function implementing this behavior in <linux/iopoll.h>
Use of read_poll_timeout is preferred over directly coding these loops. However, using it in the ice driver is a bit more difficult because of the rd32 wrapper. Implement a rd32_poll_timeout wrapper based on read_poll_timeout.
Refactor ice_sq_done to use rd32_poll_timeout, replacing the loop calling ice_sq_done in ice_sq_send_cmd. This simplifies the logic down to a single ice_sq_done() call.
The implementation of rd32_poll_timeout uses microseconds for its timeout value, so update the CQ timeout macros used to be specified in microseconds units as well instead of using HZ for jiffies.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 38 +++++++++---------- drivers/net/ethernet/intel/ice/ice_controlq.h | 2 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 4 ++ 3 files changed, 23 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +18 -20
@@ -933,19 +933,29 @@ static void ice_debug_cq(struct ice_hw *hw, void *desc, void *buf, u16 buf_len) }/** -* ice_sq_done - check if FW has processed the Admin Send Queue (ATQ) +* ice_sq_done - poll until the last send on a control queue has completed * @hw: pointer to the HW struct * @cq: pointer to the specific Control queue * -* Returns true if the firmware has processed all descriptors on the -* admin send queue. Returns false if there are still requests pending. +* Use read_poll_timeout to poll the control queue head, checking until it +* matches next_to_use. According to the control queue designers, this has +* better timing reliability than the DD bit. +* +* Return: true if all the descriptors on the send side of a control queue +* are finished processing, false otherwise. */ static bool ice_sq_done (struct ice_hw *hw,struct ice_ctl_q_info *cq) { -/* AQ designers suggest use of head for better -* timing reliability than DD bit +u32 head; + +/* Wait a short time before the initial check, to allow hardware time +* for completion. */ -return rd32 (hw, cq->sq.head) == cq->sq.next_to_use; +udelay (5 ); + +return !rd32_poll_timeout (hw, cq->sq.head, + head, head == cq->sq.next_to_use, +20 ,ICE_CTL_Q_SQ_CMD_TIMEOUT ); }/**
@@ -969,7 +979,6 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,struct ice_aq_desc *desc_on_ring;bool cmd_completed = false;struct ice_sq_cd *details; -unsigned long timeout;int status =0 ;u16 retval =0 ;u32 val =0 ;
@@ -1063,20 +1072,9 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,wr32 (hw, cq->sq.tail, cq->sq.next_to_use);ice_flush (hw); -/* Wait a short time before initial ice_sq_done() check, to allow -* hardware time for completion. +/* Wait for the command to complete. If it finishes within the +* timeout, copy the descriptor back to temp. */ -udelay (5 ); - - timeout = jiffies +ICE_CTL_Q_SQ_CMD_TIMEOUT ; -do { -if (ice_sq_done (hw, cq)) -break ; - -usleep_range (100 ,150 ); - }while (time_before (jiffies, timeout)); - -/* if ready, copy the desc back to temp */ if (ice_sq_done (hw, cq)) {memcpy (desc, desc_on_ring,sizeof (*desc));if (buf) {
drivers/net/ethernet/intel/ice/ice_controlq.h +1 -1
@@ -43,7 +43,7 @@ enum ice_ctl_q { };/* Control Queue timeout settings - max delay 1s */ -#define ICE_CTL_Q_SQ_CMD_TIMEOUT HZ/* Wait max 1s */ +#define ICE_CTL_Q_SQ_CMD_TIMEOUT USEC_PER_SEC#define ICE_CTL_Q_ADMIN_INIT_TIMEOUT 10/* Count 10 times */ #define ICE_CTL_Q_ADMIN_INIT_MSEC 100/* Check every 100msec */
drivers/net/ethernet/intel/ice/ice_osdep.h +4 -0
@@ -12,6 +12,7 @@#include <linux/ethtool.h> #include <linux/etherdevice.h> #include <linux/if_ether.h> +#include <linux/iopoll.h> #include <linux/pci_ids.h> #ifndef CONFIG_64BIT #include <linux/io-64-nonatomic-lo-hi.h>
@@ -23,6 +24,9 @@#define wr64 (a, reg, value) writeq((value), ((a)->hw_addr + (reg)))#define rd64 (a, reg) readq((a)->hw_addr + (reg)) +#define rd32_poll_timeout (a, addr, val, cond, delay_us, timeout_us) \ + read_poll_timeout(rd32, val, cond, delay_us, timeout_us, false, a, addr) +#define ice_flush (a) rd32((a), GLGEN_STAT)#define ICE_M (m, s) ((m ## U) << (s))
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 2/8 ice: improve debug print for control queue messages
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The ice_debug_cq function is called to print debug data for a control queue descriptor in multiple places. This includes both before we send a message on a transmit queue, after the writeback completion of a message on the transmit queue, and when we receive a message on a receive queue.
This function does not include data about *which* control queue the message is on, nor whether it was what we sent to the queue or what we received from the queue.
Modify ice_debug_cq to take two extra parameters, a pointer to the control queue and a boolean indicating if this was a response or a command. Improve the debug messages by replacing "CQ CMD" with a string indicating which specific control queue (based on cq->qtype) and whether this was a command sent by the PF or a response from the queue.
This helps make the log output easier to understand and consume when debugging.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +31 -5
@@ -887,16 +887,41 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)return ICE_CTL_Q_DESC_UNUSED (sq); } +/** +* ice_ctl_q_str - Convert control queue type to string +* @qtype: the control queue type +* +* Return: A string name for the given control queue type. +*/ +static const char *ice_ctl_q_str (enum ice_ctl_q qtype) +{ +switch (qtype) { +case ICE_CTL_Q_UNKNOWN : +return "Unknown CQ" ; +case ICE_CTL_Q_ADMIN : +return "AQ" ; +case ICE_CTL_Q_MAILBOX : +return "MBXQ" ; +case ICE_CTL_Q_SB : +return "SBQ" ; +default : +return "Unrecognized CQ" ; + } +} +/** * ice_debug_cq * @hw: pointer to the hardware structure +* @cq: pointer to the specific Control queue * @desc: pointer to control queue descriptor * @buf: pointer to command buffer * @buf_len: max length of buf +* @response: true if this is the writeback response * * Dumps debug log about control command with descriptor contents. */ -static void ice_debug_cq (struct ice_hw *hw,void *desc,void *buf,u16 buf_len) +static void ice_debug_cq (struct ice_hw *hw,struct ice_ctl_q_info *cq, +void *desc,void *buf,u16 buf_len,bool response) {struct ice_aq_desc *cq_desc = desc;u16 len;
@@ -910,7 +935,8 @@ static void ice_debug_cq(struct ice_hw *hw, void *desc, void *buf, u16 buf_len) len =le16_to_cpu (cq_desc->datalen); -ice_debug (hw,ICE_DBG_AQ_DESC ,"CQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n" , +ice_debug (hw,ICE_DBG_AQ_DESC ,"%s %s: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n" , +ice_ctl_q_str (cq->qtype), response ?"Response" :"Command" ,le16_to_cpu (cq_desc->opcode),le16_to_cpu (cq_desc->flags),le16_to_cpu (cq_desc->datalen),le16_to_cpu (cq_desc->retval));
@@ -1064,7 +1090,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,/* Debug desc and buffer */ ice_debug (hw,ICE_DBG_AQ_DESC ,"ATQ: Control Send queue desc and buffer:\n" ); -ice_debug_cq (hw, (void *)desc_on_ring, buf, buf_size); +ice_debug_cq (hw, cq, (void *)desc_on_ring, buf, buf_size, false); (cq->sq.next_to_use)++;if (cq->sq.next_to_use == cq->sq.count)
@@ -1106,7 +1132,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,ice_debug (hw,ICE_DBG_AQ_MSG ,"ATQ: desc and buffer writeback:\n" ); -ice_debug_cq (hw, (void *)desc, buf, buf_size); +ice_debug_cq (hw, cq, (void *)desc, buf, buf_size, true);/* save writeback AQ if requested */ if (details->wb_desc)
@@ -1210,7 +1236,7 @@ ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,ice_debug (hw,ICE_DBG_AQ_DESC ,"ARQ: desc and buffer:\n" ); -ice_debug_cq (hw, (void *)desc, e->msg_buf, cq->rq_buf_size); +ice_debug_cq (hw, cq, (void *)desc, e->msg_buf, cq->rq_buf_size, true);/* Restore the original datalen and buffer address in the desc, * FW updates datalen to indicate the event message size
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 3/8 ice: do not clutter debug logs with unused data
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
Currently, debug logs are unnecessarily cluttered with the contents of command data buffers even if the receiver of that command (i.e. FW or MBX) are not told to read the buffer. Change to only log command data buffers when the RD flag (indicates receiver needs to read the buffer) is set. Continue to log response data buffer when the returned datalen is non-zero.
Also, rename a local variable to reflect what is in the hardware specification and how it is used elsewhere in the code, use local variables instead of duplicating endian conversions unnecessarily and remove an unnecessary assignment.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 ++++ drivers/net/ethernet/intel/ice/ice_controlq.c | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +4 -0
@@ -2632,12 +2632,16 @@ struct ice_aq_desc {/* FW defined boundary for a large buffer, 4k >= Large buffer > 512 bytes */ #define ICE_AQ_LG_BUF 512 +#define ICE_AQ_FLAG_DD_S 0 +#define ICE_AQ_FLAG_CMP_S 1#define ICE_AQ_FLAG_ERR_S 2#define ICE_AQ_FLAG_LB_S 9#define ICE_AQ_FLAG_RD_S 10#define ICE_AQ_FLAG_BUF_S 12#define ICE_AQ_FLAG_SI_S 13 +#define ICE_AQ_FLAG_DD BIT(ICE_AQ_FLAG_DD_S)/* 0x1 */ +#define ICE_AQ_FLAG_CMP BIT(ICE_AQ_FLAG_CMP_S)/* 0x2 */ #define ICE_AQ_FLAG_ERR BIT(ICE_AQ_FLAG_ERR_S)/* 0x4 */ #define ICE_AQ_FLAG_LB BIT(ICE_AQ_FLAG_LB_S)/* 0x200 */ #define ICE_AQ_FLAG_RD BIT(ICE_AQ_FLAG_RD_S)/* 0x400 */
drivers/net/ethernet/intel/ice/ice_controlq.c +12 -9
@@ -924,7 +924,7 @@ static void ice_debug_cq(struct ice_hw *hw, struct ice_ctl_q_info *cq, void *desc, void *buf, u16 buf_len, bool response) { struct ice_aq_desc *cq_desc = desc; -u16 len; +u16 datalen, flags;if (!IS_ENABLED (CONFIG_DYNAMIC_DEBUG ) && !((ICE_DBG_AQ_DESC |ICE_DBG_AQ_DESC_BUF ) & hw->debug_mask))
@@ -933,13 +933,13 @@ static void ice_debug_cq(struct ice_hw *hw, struct ice_ctl_q_info *cq,if (!desc)return ; - len =le16_to_cpu (cq_desc->datalen); + datalen =le16_to_cpu (cq_desc->datalen); + flags =le16_to_cpu (cq_desc->flags);ice_debug (hw,ICE_DBG_AQ_DESC ,"%s %s: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n" ,ice_ctl_q_str (cq->qtype), response ?"Response" :"Command" , -le16_to_cpu (cq_desc->opcode), -le16_to_cpu (cq_desc->flags), -le16_to_cpu (cq_desc->datalen),le16_to_cpu (cq_desc->retval)); +le16_to_cpu (cq_desc->opcode), flags, datalen, +le16_to_cpu (cq_desc->retval));ice_debug (hw,ICE_DBG_AQ_DESC ,"\tcookie (h,l) 0x%08X 0x%08X\n" ,le32_to_cpu (cq_desc->cookie_high),le32_to_cpu (cq_desc->cookie_low));
@@ -949,12 +949,15 @@ static void ice_debug_cq(struct ice_hw *hw, struct ice_ctl_q_info *cq,ice_debug (hw,ICE_DBG_AQ_DESC ,"\taddr (h,l) 0x%08X 0x%08X\n" ,le32_to_cpu (cq_desc->params.generic.addr_high),le32_to_cpu (cq_desc->params.generic.addr_low)); -if (buf && cq_desc->datalen !=0 ) { +/* Dump buffer iff 1) one exists and 2) is either a response indicated +* by the DD and/or CMP flag set or a command with the RD flag set. +*/ +if (buf && cq_desc->datalen && + (flags & (ICE_AQ_FLAG_DD |ICE_AQ_FLAG_CMP |ICE_AQ_FLAG_RD ))) {ice_debug (hw,ICE_DBG_AQ_DESC_BUF ,"Buffer:\n" ); -if (buf_len < len) - len = buf_len; -ice_debug_array (hw,ICE_DBG_AQ_DESC_BUF ,16 ,1 , buf, len); +ice_debug_array (hw,ICE_DBG_AQ_DESC_BUF ,16 ,1 , buf, +min_t (u16, buf_len, datalen)); } }
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 4/8 ice: stop intermixing AQ commands/responses debug dumps
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
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.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 23 +++++++++--------- drivers/net/ethernet/intel/ice/ice_osdep.h | 24 +++++++++++-------- 2 files changed, 26 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +12 -11
@@ -936,17 +936,14 @@ static void ice_debug_cq(struct ice_hw *hw, struct ice_ctl_q_info *cq, datalen =le16_to_cpu (cq_desc->datalen); flags =le16_to_cpu (cq_desc->flags); -ice_debug (hw,ICE_DBG_AQ_DESC ,"%s %s: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n" , +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" ,ice_ctl_q_str (cq->qtype), response ?"Response" :"Command" ,le16_to_cpu (cq_desc->opcode), flags, datalen, -le16_to_cpu (cq_desc->retval)); -ice_debug (hw,ICE_DBG_AQ_DESC ,"\tcookie (h,l) 0x%08X 0x%08X\n" , +le16_to_cpu (cq_desc->retval),le32_to_cpu (cq_desc->cookie_high), -le32_to_cpu (cq_desc->cookie_low)); -ice_debug (hw,ICE_DBG_AQ_DESC ,"\tparam (0,1) 0x%08X 0x%08X\n" , +le32_to_cpu (cq_desc->cookie_low),le32_to_cpu (cq_desc->params.generic.param0), -le32_to_cpu (cq_desc->params.generic.param1)); -ice_debug (hw,ICE_DBG_AQ_DESC ,"\taddr (h,l) 0x%08X 0x%08X\n" , +le32_to_cpu (cq_desc->params.generic.param1),le32_to_cpu (cq_desc->params.generic.addr_high),le32_to_cpu (cq_desc->params.generic.addr_low));/* Dump buffer iff 1) one exists and 2) is either a response indicated
@@ -954,10 +951,14 @@ static void ice_debug_cq(struct ice_hw *hw, struct ice_ctl_q_info *cq,*/ if (buf && cq_desc->datalen && (flags & (ICE_AQ_FLAG_DD |ICE_AQ_FLAG_CMP |ICE_AQ_FLAG_RD ))) { -ice_debug (hw,ICE_DBG_AQ_DESC_BUF ,"Buffer:\n" ); - -ice_debug_array (hw,ICE_DBG_AQ_DESC_BUF ,16 ,1 , buf, -min_t (u16, buf_len, datalen)); +char prefix[] =KBUILD_MODNAME " 0x12341234 0x12341234 " ; + +sprintf (prefix,KBUILD_MODNAME " 0x%08X 0x%08X " , +le32_to_cpu (cq_desc->params.generic.addr_high), +le32_to_cpu (cq_desc->params.generic.addr_low)); +ice_debug_array_w_prefix (hw,ICE_DBG_AQ_DESC_BUF , prefix, + buf, +min_t (u16, buf_len, datalen)); } }
drivers/net/ethernet/intel/ice/ice_osdep.h +14 -10
@@ -43,11 +43,10 @@ struct device *ice_hw_to_dev(struct ice_hw *hw); #define ice_debug(hw, type, fmt, args...) \ dev_dbg(ice_hw_to_dev(hw), fmt, ##args) -#define ice_debug_array (hw, type, rowsize, groupsize, buf, len) \ - print_hex_dump_debug(KBUILD_MODNAME " ", \ - DUMP_PREFIX_OFFSET, rowsize, \ - groupsize, buf, len, false) -#else +#define _ice_debug_array (hw, type, prefix, rowsize, groupsize, buf, len) \ + print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET, \ + rowsize, groupsize, buf, len, false) +#else /* CONFIG_DYNAMIC_DEBUG */ #define ice_debug(hw, type, fmt, args...) \ do { \ if ((type) & (hw)->debug_mask) \
@@ -55,16 +54,15 @@ do { \ } while (0)#ifdef DEBUG -#define ice_debug_array (hw, type, rowsize, groupsize, buf, len) \ +#define _ice_debug_array (hw, type, prefix, rowsize, groupsize, buf, len) \ do { \ if ((type) & (hw)->debug_mask) \ - print_hex_dump_debug(KBUILD_MODNAME, \ - DUMP_PREFIX_OFFSET, \ + print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,\ rowsize, groupsize, buf, \ len, false); \ } while (0) -#else -#define ice_debug_array (hw, type, rowsize, groupsize, buf, len) \ +#else /* DEBUG */ +#define _ice_debug_array (hw, type, prefix, rowsize, groupsize, buf, len) \ do { \ struct ice_hw *hw_l = hw; \ if ((type) & (hw_l)->debug_mask) { \
@@ -82,4 +80,10 @@ do { \#endif /* DEBUG */ #endif /* CONFIG_DYNAMIC_DEBUG */ +#define ice_debug_array (hw, type, rowsize, groupsize, buf, len) \ + _ice_debug_array(hw, type, KBUILD_MODNAME, rowsize, groupsize, buf, len) + +#define ice_debug_array_w_prefix (hw, type, prefix, buf, len) \ + _ice_debug_array(hw, type, prefix, 16, 1, buf, len) +#endif /* _ICE_OSDEP_H_ */
Signature · 1 line
2.42.0
Re: [PATCH net-next 4/8] ice: stop intermixing AQ commands/responses debug dumps
Quoted 52 lines · Tony Nguyen
From: Przemek Kitszel <[email protected]>
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 usingprint_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 toKBUILD_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 anice_debug_array_w_prefix(). Build the prefix by combiningKBUILD_MODNAMEwith the databuffer address usingsnprintf().These changes make it possible to unambiguously determine what data belongs to what control queue message.
Reported-by Jacek Wierzbicki <[email protected]>Signed-off-by Przemek Kitszel <[email protected]>Signed-off-by Jacob Keller <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.c | 23 +++++++++--------- drivers/net/ethernet/intel/ice/ice_osdep.h | 24 +++++++++++-------- 2 files changed, 26 insertions(+), 21 deletions(-)
[...]
Thanks
Tony Nguyen
maintainerPATCH 5/8 ice: reword comments referring to control queues
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
Many comments in ice_controlq.c use the term "Admin queue" despite the code being intended for arbitrary control queues, not just the Admin queue. Reword the comments to make it clear that this code is the generic control queue logic that is shared by all of the control queues, and is not specific to the Admin queue.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +13 -12
@@ -188,7 +188,7 @@ ice_alloc_rq_bufs(struct ice_hw *hw, struct ice_ctl_q_info *cq)if (cq->rq_buf_size >ICE_AQ_LG_BUF ) desc->flags |=cpu_to_le16 (ICE_AQ_FLAG_LB ); desc->opcode =0 ; -/* This is in accordance with Admin queue design, there is no +/* This is in accordance with control queue design, there is no * register for buffer size configuration */ desc->datalen =cpu_to_le16 (bi->size);
@@ -405,11 +405,11 @@ static int ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) }/** -* ice_init_rq - initialize ARQ +* ice_init_rq - initialize receive side of a control queue * @hw: pointer to the hardware structure * @cq: pointer to the specific Control queue * -* The main initialization routine for the Admin Receive (Event) Queue. +* The main initialization routine for Receive side of a control queue. * Prior to calling this function, the driver *MUST* set the following fields * in the cq->structure: * - cq->num_rq_entries
@@ -465,7 +465,7 @@ static int ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq) }/** -* ice_shutdown_sq - shutdown the Control ATQ +* ice_shutdown_sq - shutdown the transmit side of a control queue * @hw: pointer to the hardware structure * @cq: pointer to the specific Control queue *
@@ -482,7 +482,7 @@ static int ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) goto shutdown_sq_out; } -/* Stop firmware AdminQ processing */ +/* Stop processing of the control queue */ wr32 (hw, cq->sq.head,0 );wr32 (hw, cq->sq.tail,0 );wr32 (hw, cq->sq.len,0 );
@@ -855,7 +855,7 @@ void ice_destroy_all_ctrlq(struct ice_hw *hw) }/** -* ice_clean_sq - cleans Admin send queue (ATQ) +* ice_clean_sq - cleans send side of a control queue * @hw: pointer to the hardware structure * @cq: pointer to the specific Control queue *
@@ -989,7 +989,7 @@ static bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq) }/** -* ice_sq_send_cmd - send command to Control Queue (ATQ) +* ice_sq_send_cmd - send command to a control queue * @hw: pointer to the HW struct * @cq: pointer to the specific Control queue * @desc: prefilled descriptor describing the command
@@ -997,8 +997,9 @@ static bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq)* @buf_size: size of buffer for indirect commands (or 0 for direct commands) * @cd: pointer to command details structure * -* This is the main send command routine for the ATQ. It runs the queue, -* cleans the queue, etc. +* Main command for the transmit side of a control queue. It puts the command +* on the queue, bumps the tail, waits for processing of the command, captures +* command status and results, etc. */ int ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
@@ -1182,9 +1183,9 @@ void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode)* @e: event info from the receive descriptor, includes any buffers * @pending: number of events that could be left to process * -* This function cleans one Admin Receive Queue element and returns -* the contents through e. It can also return how many events are -* left to process through 'pending'. +* Clean one element from the receive side of a control queue. On return 'e' +* contains contents of the message, and 'pending' contains the number of +* events left to process. */ int ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 6/8 ice: remove unnecessary control queue cmd_buf arrays
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The driver allocates a cmd_buf array in addition to the desc_buf array. This array stores an ice_sq_cd command details structure for each entry in the control queue ring.
The contents of the structure are copied from the value passed in via ice_sq_send_cmd, and include only a pointer to storage for the write back descriptor contents.
Originally this array was intended to support asynchronous completion including features such as a callback function. This support was never implemented. All that exists today is needless copying and resetting of a cmd_buf array that is otherwise functionally unused.
Since we do not plan to implement asynchronous completions, drop this unnecessary memory and logic. This saves memory for each control queue, and avoids the pointless copying and memset.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 29 ++----------------- drivers/net/ethernet/intel/ice/ice_controlq.h | 3 -- 2 files changed, 2 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +2 -27
@@ -99,17 +99,6 @@ ice_alloc_ctrlq_sq_ring(struct ice_hw *hw, struct ice_ctl_q_info *cq)return -ENOMEM ; cq->sq.desc_buf.size = size; - cq->sq.cmd_buf =devm_kcalloc (ice_hw_to_dev (hw), cq->num_sq_entries, -sizeof (struct ice_sq_cd ),GFP_KERNEL ); -if (!cq->sq.cmd_buf) { -dmam_free_coherent (ice_hw_to_dev (hw), cq->sq.desc_buf.size, - cq->sq.desc_buf.va, cq->sq.desc_buf.pa); - cq->sq.desc_buf.va =NULL ; - cq->sq.desc_buf.pa =0 ; - cq->sq.desc_buf.size =0 ; -return -ENOMEM ; - } -return 0 ; }
@@ -338,8 +327,6 @@ do { \ (qi)->ring.r.ring##_bi[i].size = 0;\ } \ } \ -/* free the buffer info list */ \ -devm_kfree (ice_hw_to_dev (hw), (qi)->ring.cmd_buf); \/* free DMA head */ \devm_kfree (ice_hw_to_dev (hw), (qi)->ring.dma_head); \ }while (0 )
@@ -865,21 +852,17 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) {struct ice_ctl_q_ring *sq = &cq->sq;u16 ntc = sq->next_to_clean; -struct ice_sq_cd *details;struct ice_aq_desc *desc; desc =ICE_CTL_Q_DESC (*sq, ntc); - details =ICE_CTL_Q_DETAILS (*sq, ntc);while (rd32 (hw, cq->sq.head) != ntc) {ice_debug (hw,ICE_DBG_AQ_MSG ,"ntc %d head %d.\n" , ntc,rd32 (hw, cq->sq.head));memset (desc,0 ,sizeof (*desc)); -memset (details,0 ,sizeof (*details)); ntc++;if (ntc == sq->count) ntc =0 ; desc =ICE_CTL_Q_DESC (*sq, ntc); - details =ICE_CTL_Q_DETAILS (*sq, ntc); } sq->next_to_clean = ntc;
@@ -1009,7 +992,6 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,struct ice_dma_mem *dma_buf =NULL ;struct ice_aq_desc *desc_on_ring;bool cmd_completed = false; -struct ice_sq_cd *details;int status =0 ;u16 retval =0 ;u32 val =0 ;
@@ -1053,12 +1035,6 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq, goto sq_send_command_error; } - details =ICE_CTL_Q_DETAILS (cq->sq, cq->sq.next_to_use); -if (cd) - *details = *cd; -else -memset (details,0 ,sizeof (*details)); -/* Call clean and check queue available function to reclaim the * descriptors that were processed by FW/MBX; the function returns the * number of desc available. The clean function called here could be
@@ -1140,9 +1116,8 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,ice_debug_cq (hw, cq, (void *)desc, buf, buf_size, true);/* save writeback AQ if requested */ -if (details->wb_desc) -memcpy (details->wb_desc, desc_on_ring, -sizeof (*details->wb_desc)); +if (cd && cd->wb_desc) +memcpy (cd->wb_desc, desc_on_ring,sizeof (*cd->wb_desc));/* update the error if time out occurred */ if (!cmd_completed) {
drivers/net/ethernet/intel/ice/ice_controlq.h +0 -3
@@ -50,7 +50,6 @@ enum ice_ctl_q {struct ice_ctl_q_ring {void *dma_head;/* Virtual address to DMA head */ struct ice_dma_mem desc_buf;/* descriptor ring memory */ -void *cmd_buf;/* command buffer memory */ union {struct ice_dma_mem *sq_bi;
@@ -80,8 +79,6 @@ struct ice_sq_cd {struct ice_aq_desc *wb_desc; }; -#define ICE_CTL_Q_DETAILS (R , i) (&(((struct ice_sq_cd *)((R).cmd_buf))[i])) -/* rq event information */ struct ice_rq_event_info {struct ice_aq_desc desc;
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 7/8 ice: Report NVM version numbers on mismatch during load
In reply to Tony NguyenFrom: Sergey Temerkhanov <[email protected]>
Report NVM version numbers (both detected and expected) when a mismatch b/w driver and firmware is detected. This provides more useful information about which NVM version the driver expects, rather than requiring manual code inspection.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +10 -4
@@ -488,7 +488,7 @@ static int ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) }/** -* ice_aq_ver_check - Check the reported AQ API version. +* ice_aq_ver_check - Check the reported AQ API version * @hw: pointer to the hardware structure * * Checks if the driver should load on a given AQ API version.
@@ -508,14 +508,20 @@ static bool ice_aq_ver_check(struct ice_hw *hw) }else if (hw->api_maj_ver == exp_fw_api_ver_major) {if (hw->api_min_ver > (exp_fw_api_ver_minor +2 ))dev_info (ice_hw_to_dev (hw), -"The driver for the device detected a newer version of the NVM image than expected. Please install the most recent version of the network driver.\n" ); +"The driver for the device detected a newer version (%u.%u) of the NVM image than expected (%u.%u). Please install the most recent version of the network driver.\n" , + hw->api_maj_ver, hw->api_min_ver, + exp_fw_api_ver_major, exp_fw_api_ver_minor);else if ((hw->api_min_ver +2 ) < exp_fw_api_ver_minor)dev_info (ice_hw_to_dev (hw), -"The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n" ); +"The driver for the device detected an older version (%u.%u) of the NVM image than expected (%u.%u). Please update the NVM image.\n" , + hw->api_maj_ver, hw->api_min_ver, + exp_fw_api_ver_major, exp_fw_api_ver_minor); }else {/* Major API version is older than expected, log a warning */ dev_info (ice_hw_to_dev (hw), -"The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n" ); +"The driver for the device detected an older version (%u.%u) of the NVM image than expected (%u.%u). Please update the NVM image.\n" , + hw->api_maj_ver, hw->api_min_ver, + exp_fw_api_ver_major, exp_fw_api_ver_minor); }return true; }
Signature · 1 line
2.42.0
Tony Nguyen
maintainerPATCH 8/8 ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node()
In reply to Tony NguyenFrom: Aleksandr Mishin <[email protected]>
In ice_sched_add_root_node() and ice_sched_add_node() there are calls to devm_kcalloc() in order to allocate memory for array of pointers to 'ice_sched_node' structure. But incorrect types are used as sizeof() arguments in these calls (structures instead of pointers) which leads to over allocation of memory.
Adjust over allocation of memory by correcting types in devm_kcalloc() sizeof() arguments.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/ethernet/intel/ice/ice_sched.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_sched.c +2 -4
@@ -28,9 +28,8 @@ ice_sched_add_root_node(struct ice_port_info *pi,if (!root)return -ENOMEM ; -/* coverity[suspicious_sizeof] */ root->children =devm_kcalloc (ice_hw_to_dev (hw), hw->max_children[0 ], -sizeof (*root),GFP_KERNEL ); +sizeof (*root->children),GFP_KERNEL );if (!root->children) {devm_kfree (ice_hw_to_dev (hw), root);return -ENOMEM ;
@@ -186,10 +185,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,if (!node)return -ENOMEM ;if (hw->max_children[layer]) { -/* coverity[suspicious_sizeof] */ node->children =devm_kcalloc (ice_hw_to_dev (hw), hw->max_children[layer], -sizeof (*node),GFP_KERNEL ); +sizeof (*node->children),GFP_KERNEL );if (!node->children) {devm_kfree (ice_hw_to_dev (hw), node);return -ENOMEM ;
Signature · 1 line
2.42.0
This series was applied to netdev/net-next.git (main) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Tony Nguyen <[email protected]>:
Quoted 8 lines · On Mon, 26 Aug 2024 15:46:40 -0700 you wrote:
This series contains updates to ice driver only.
Jake implements and uses
rd32_poll_timeoutto replace a jiffies loop for callingice_sq_done. Therd32_poll_timeout()function is designed to allow simplifying other places in the driver where we need to read a register until it matches a known value.[...]
Here is the summary with links:
- [net-next,1/8] ice: implement and use rd32_poll_timeout for ice_sq_done timeout
https://git.kernel.org/netdev/net-next/c/5f6df173f92e - [net-next,2/8] ice: improve debug print for control queue messages https://git.kernel.org/netdev/net-next/c/caf4daae871c - [net-next,3/8] ice: do not clutter debug logs with unused data https://git.kernel.org/netdev/net-next/c/6bd7cb522b1c - [net-next,4/8] ice: stop intermixing AQ commands/responses debug dumps https://git.kernel.org/netdev/net-next/c/74ce564a30ef - [net-next,5/8] ice: reword comments referring to control queues https://git.kernel.org/netdev/net-next/c/1d95d9256cfa - [net-next,6/8] ice: remove unnecessary control queue cmd_buf arrays https://git.kernel.org/netdev/net-next/c/448711c1dad0 - [net-next,7/8] ice: Report NVM version numbers on mismatch during load https://git.kernel.org/netdev/net-next/c/b1703d5f794d - [net-next,8/8] ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node() https://git.kernel.org/netdev/net-next/c/62fdaf9e8056
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html