ice: refactor and cleanup control queue logic
Subsystems (2)
cover ice: refactor and cleanup control queue logic
This series includes several minor improvements and refactors to the control queue logic.
Jacob 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.
Jacob, 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.
Jacob 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.
Jacob 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.
---
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
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_controlq.h | 5 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 28 ++-- drivers/net/ethernet/intel/ice/ice_controlq.c | 176 +++++++++++++----------- 4 files changed, 116 insertions(+), 97 deletions(-)
---
base-commit: 10a6545f0bdcbb920c6a8a033fe342111d204915
change-id: 20240805-e810-live-migration-rd32-poll-timeout-218ae6443beb
Best regards,
Signature · 1 line
Jacob Keller <[email protected]>
PATCH 1/7 ice: implement and use rd32_poll_timeout for ice_sq_done timeout
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.h | 2 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 4 +++ drivers/net/ethernet/intel/ice/ice_controlq.c | 38 +++++++++++++-------------- 3 files changed, 23 insertions(+), 21 deletions(-)
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))
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) {
Signature · 1 line
2.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 1/7] ice: implement and use rd32_poll_timeout for ice_sq_done timeout
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 1/7] ice: implement and userd32_poll_timeoutforice_sq_donetimeoutThe
ice_sq_donefunction 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_timeoutfunction implementing this behavior in <linux/iopoll.h>Use of
read_poll_timeoutis preferred over directly coding these loops. However, using it in the ice driver is a bit more difficult because of the rd32 wrapper. Implement ard32_poll_timeoutwrapper based onread_poll_timeout.Refactor
ice_sq_doneto userd32_poll_timeout, replacing the loop callingice_sq_doneinice_sq_send_cmd. This simplifies the logic down to a singleice_sq_done()call.The implementation of
rd32_poll_timeoutuses 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.
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.h | 2 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 4 +++ drivers/net/ethernet/intel/ice/ice_controlq.c | 38 +++++++++++++-------------- 3 files changed, 23 insertions(+), 21 deletions(-)
PATCH 2/7 ice: improve debug print for control queue messages
In reply to Jacob KellerThe 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.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 2/7] ice: improve debug print for control queue messages
Quoted 13 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 2/7] ice: improve debug print for control queue messagesThe
ice_debug_cqfunction 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_cqto 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 oncq->qtype) > and whether this was a command sent by the PF or a response from the queue.
Quoted 8 lines
This helps make the log output easier to understand and consume when debugging.
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.c | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-)
PATCH 3/7 ice: do not clutter debug logs with unused data
In reply to Jacob KellerFrom: 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.
--- drivers/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.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 3/7] ice: do not clutter debug logs with unused data
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 3/7] ice: do not clutter debug logs with unused dataFrom: 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.
Quoted 8 lines
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/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(-)
PATCH 4/7 ice: stop intermixing AQ commands/responses debug dumps
In reply to Jacob KellerFrom: 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_osdep.h | 24 ++++++++++++++---------- drivers/net/ethernet/intel/ice/ice_controlq.c | 21 +++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)
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_ */
drivers/net/ethernet/intel/ice/ice_controlq.c +11 -10
@@ -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" ); +char prefix[] =KBUILD_MODNAME " 0x12341234 0x12341234 " ; -ice_debug_array (hw,ICE_DBG_AQ_DESC_BUF ,16 ,1 , buf, -min_t (u16, buf_len, datalen)); +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)); } }
Signature · 1 line
2.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 4/7] ice: stop intermixing AQ commands/responses debug dumps
Quoted 35 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 4/7] ice: stop intermixing AQ commands/responses debug dumpsFrom: 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.
Quoted 8 lines
Reported-by Jacek Wierzbicki <[email protected]>Signed-off-by Przemek Kitszel <[email protected]>Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_osdep.h | 24 ++++++++++++++---------- drivers/net/ethernet/intel/ice/ice_controlq.c | 21 +++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)
PATCH 5/7 ice: reword comments referring to control queues
In reply to Jacob KellerMany 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.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 5/7] ice: reword comments referring to control queues
Quoted 7 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 5/7] ice: reword comments referring to control queues
Quoted 9 lines
Many comments in
ice_controlq.cuse 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.Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
PATCH 6/7 ice: remove unnecessary control queue cmd_buf arrays
In reply to Jacob KellerThe 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.h | 3 --- drivers/net/ethernet/intel/ice/ice_controlq.c | 29 ++------------------------- 2 files changed, 2 insertions(+), 30 deletions(-)
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;
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) {
Signature · 1 line
2.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 6/7] ice: remove unnecessary control queue cmd_buf arrays
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 6/7] ice: remove unnecessary control queuecmd_bufarraysThe driver allocates a
cmd_bufarray in addition to thedesc_bufarray.
This array stores anice_sq_cdcommand 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_bufarray that is otherwise functionally unused.
Quoted 8 lines
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.
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.h | 3 --- drivers/net/ethernet/intel/ice/ice_controlq.c | 29 ++------------------------- 2 files changed, 2 insertions(+), 30 deletions(-)
PATCH 7/7 ice: Report NVM version numbers on mismatch during load
In reply to Jacob KellerFrom: 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.46.0.124.g2dc1a81c8933
Re: [Intel-wired-lan] [PATCH iwl-next 7/7] ice: Report NVM version numbers on mismatch during load
Quoted 9 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 7, 2024 2:16 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <[email protected]>; "netdev netdev"@vger.kernel.org
Cc: Temerkhanov, Sergey <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kolacinski, Karol <[email protected]>; Wierzbicki, Jacek <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 7/7] ice: Report NVM version numbers on mismatch during loadFrom: Sergey Temerkhanov <[email protected]>
Quoted 9 lines
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.
Signed-off-by Sergey Temerkhanov <[email protected]>Signed-off-by Jacob Keller <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>--- drivers/net/ethernet/intel/ice/ice_controlq.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)