@@ -99,17 +99,6 @@ ice_alloc_ctrlq_sq_ring(struct ice_hw *hw, struct ice_ctl_q_info *cq)
9999 return - ENOMEM ;
100100 cq -> sq .desc_buf .size = size ;
101101
102- cq -> sq .cmd_buf = devm_kcalloc (ice_hw_to_dev (hw ), cq -> num_sq_entries ,
103- sizeof (struct ice_sq_cd ), GFP_KERNEL );
104- if (!cq -> sq .cmd_buf ) {
105- dmam_free_coherent (ice_hw_to_dev (hw ), cq -> sq .desc_buf .size ,
106- cq -> sq .desc_buf .va , cq -> sq .desc_buf .pa );
107- cq -> sq .desc_buf .va = NULL ;
108- cq -> sq .desc_buf .pa = 0 ;
109- cq -> sq .desc_buf .size = 0 ;
110- return - ENOMEM ;
111- }
112-
113102 return 0 ;
114103}
115104
@@ -188,7 +177,7 @@ ice_alloc_rq_bufs(struct ice_hw *hw, struct ice_ctl_q_info *cq)
188177 if (cq -> rq_buf_size > ICE_AQ_LG_BUF )
189178 desc -> flags |= cpu_to_le16 (ICE_AQ_FLAG_LB );
190179 desc -> opcode = 0 ;
191- /* This is in accordance with Admin queue design, there is no
180+ /* This is in accordance with control queue design, there is no
192181 * register for buffer size configuration
193182 */
194183 desc -> datalen = cpu_to_le16 (bi -> size );
@@ -338,8 +327,6 @@ do { \
338327 (qi)->ring.r.ring##_bi[i].size = 0;\
339328 } \
340329 } \
341- /* free the buffer info list */ \
342- devm_kfree (ice_hw_to_dev (hw ), (qi )-> ring .cmd_buf ); \
343330 /* free DMA head */ \
344331 devm_kfree (ice_hw_to_dev (hw ), (qi )-> ring .dma_head ); \
345332} while (0 )
@@ -405,11 +392,11 @@ static int ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
405392}
406393
407394/**
408- * ice_init_rq - initialize ARQ
395+ * ice_init_rq - initialize receive side of a control queue
409396 * @hw: pointer to the hardware structure
410397 * @cq: pointer to the specific Control queue
411398 *
412- * The main initialization routine for the Admin Receive (Event) Queue .
399+ * The main initialization routine for Receive side of a control queue .
413400 * Prior to calling this function, the driver *MUST* set the following fields
414401 * in the cq->structure:
415402 * - cq->num_rq_entries
@@ -465,7 +452,7 @@ static int ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
465452}
466453
467454/**
468- * ice_shutdown_sq - shutdown the Control ATQ
455+ * ice_shutdown_sq - shutdown the transmit side of a control queue
469456 * @hw: pointer to the hardware structure
470457 * @cq: pointer to the specific Control queue
471458 *
@@ -482,7 +469,7 @@ static int ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
482469 goto shutdown_sq_out ;
483470 }
484471
485- /* Stop firmware AdminQ processing */
472+ /* Stop processing of the control queue */
486473 wr32 (hw , cq -> sq .head , 0 );
487474 wr32 (hw , cq -> sq .tail , 0 );
488475 wr32 (hw , cq -> sq .len , 0 );
@@ -501,7 +488,7 @@ static int ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
501488}
502489
503490/**
504- * ice_aq_ver_check - Check the reported AQ API version.
491+ * ice_aq_ver_check - Check the reported AQ API version
505492 * @hw: pointer to the hardware structure
506493 *
507494 * Checks if the driver should load on a given AQ API version.
@@ -521,14 +508,20 @@ static bool ice_aq_ver_check(struct ice_hw *hw)
521508 } else if (hw -> api_maj_ver == exp_fw_api_ver_major ) {
522509 if (hw -> api_min_ver > (exp_fw_api_ver_minor + 2 ))
523510 dev_info (ice_hw_to_dev (hw ),
524- "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" );
511+ "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" ,
512+ hw -> api_maj_ver , hw -> api_min_ver ,
513+ exp_fw_api_ver_major , exp_fw_api_ver_minor );
525514 else if ((hw -> api_min_ver + 2 ) < exp_fw_api_ver_minor )
526515 dev_info (ice_hw_to_dev (hw ),
527- "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n" );
516+ "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" ,
517+ hw -> api_maj_ver , hw -> api_min_ver ,
518+ exp_fw_api_ver_major , exp_fw_api_ver_minor );
528519 } else {
529520 /* Major API version is older than expected, log a warning */
530521 dev_info (ice_hw_to_dev (hw ),
531- "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n" );
522+ "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" ,
523+ hw -> api_maj_ver , hw -> api_min_ver ,
524+ exp_fw_api_ver_major , exp_fw_api_ver_minor );
532525 }
533526 return true;
534527}
@@ -855,7 +848,7 @@ void ice_destroy_all_ctrlq(struct ice_hw *hw)
855848}
856849
857850/**
858- * ice_clean_sq - cleans Admin send queue (ATQ)
851+ * ice_clean_sq - cleans send side of a control queue
859852 * @hw: pointer to the hardware structure
860853 * @cq: pointer to the specific Control queue
861854 *
@@ -865,41 +858,62 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
865858{
866859 struct ice_ctl_q_ring * sq = & cq -> sq ;
867860 u16 ntc = sq -> next_to_clean ;
868- struct ice_sq_cd * details ;
869861 struct ice_aq_desc * desc ;
870862
871863 desc = ICE_CTL_Q_DESC (* sq , ntc );
872- details = ICE_CTL_Q_DETAILS (* sq , ntc );
873864
874865 while (rd32 (hw , cq -> sq .head ) != ntc ) {
875866 ice_debug (hw , ICE_DBG_AQ_MSG , "ntc %d head %d.\n" , ntc , rd32 (hw , cq -> sq .head ));
876867 memset (desc , 0 , sizeof (* desc ));
877- memset (details , 0 , sizeof (* details ));
878868 ntc ++ ;
879869 if (ntc == sq -> count )
880870 ntc = 0 ;
881871 desc = ICE_CTL_Q_DESC (* sq , ntc );
882- details = ICE_CTL_Q_DETAILS (* sq , ntc );
883872 }
884873
885874 sq -> next_to_clean = ntc ;
886875
887876 return ICE_CTL_Q_DESC_UNUSED (sq );
888877}
889878
879+ /**
880+ * ice_ctl_q_str - Convert control queue type to string
881+ * @qtype: the control queue type
882+ *
883+ * Return: A string name for the given control queue type.
884+ */
885+ static const char * ice_ctl_q_str (enum ice_ctl_q qtype )
886+ {
887+ switch (qtype ) {
888+ case ICE_CTL_Q_UNKNOWN :
889+ return "Unknown CQ" ;
890+ case ICE_CTL_Q_ADMIN :
891+ return "AQ" ;
892+ case ICE_CTL_Q_MAILBOX :
893+ return "MBXQ" ;
894+ case ICE_CTL_Q_SB :
895+ return "SBQ" ;
896+ default :
897+ return "Unrecognized CQ" ;
898+ }
899+ }
900+
890901/**
891902 * ice_debug_cq
892903 * @hw: pointer to the hardware structure
904+ * @cq: pointer to the specific Control queue
893905 * @desc: pointer to control queue descriptor
894906 * @buf: pointer to command buffer
895907 * @buf_len: max length of buf
908+ * @response: true if this is the writeback response
896909 *
897910 * Dumps debug log about control command with descriptor contents.
898911 */
899- static void ice_debug_cq (struct ice_hw * hw , void * desc , void * buf , u16 buf_len )
912+ static void ice_debug_cq (struct ice_hw * hw , struct ice_ctl_q_info * cq ,
913+ void * desc , void * buf , u16 buf_len , bool response )
900914{
901915 struct ice_aq_desc * cq_desc = desc ;
902- u16 len ;
916+ u16 datalen , flags ;
903917
904918 if (!IS_ENABLED (CONFIG_DYNAMIC_DEBUG ) &&
905919 !((ICE_DBG_AQ_DESC | ICE_DBG_AQ_DESC_BUF ) & hw -> debug_mask ))
@@ -908,57 +922,73 @@ static void ice_debug_cq(struct ice_hw *hw, void *desc, void *buf, u16 buf_len)
908922 if (!desc )
909923 return ;
910924
911- len = le16_to_cpu (cq_desc -> datalen );
925+ datalen = le16_to_cpu (cq_desc -> datalen );
926+ flags = le16_to_cpu (cq_desc -> flags );
912927
913- ice_debug (hw , ICE_DBG_AQ_DESC , "CQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n" ,
914- le16_to_cpu (cq_desc -> opcode ),
915- le16_to_cpu (cq_desc -> flags ),
916- le16_to_cpu (cq_desc -> datalen ), le16_to_cpu (cq_desc -> retval ));
917- ice_debug (hw , ICE_DBG_AQ_DESC , "\tcookie (h,l) 0x%08X 0x%08X\n" ,
928+ 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" ,
929+ ice_ctl_q_str (cq -> qtype ), response ? "Response" : "Command" ,
930+ le16_to_cpu (cq_desc -> opcode ), flags , datalen ,
931+ le16_to_cpu (cq_desc -> retval ),
918932 le32_to_cpu (cq_desc -> cookie_high ),
919- le32_to_cpu (cq_desc -> cookie_low ));
920- ice_debug (hw , ICE_DBG_AQ_DESC , "\tparam (0,1) 0x%08X 0x%08X\n" ,
933+ le32_to_cpu (cq_desc -> cookie_low ),
921934 le32_to_cpu (cq_desc -> params .generic .param0 ),
922- le32_to_cpu (cq_desc -> params .generic .param1 ));
923- ice_debug (hw , ICE_DBG_AQ_DESC , "\taddr (h,l) 0x%08X 0x%08X\n" ,
935+ le32_to_cpu (cq_desc -> params .generic .param1 ),
924936 le32_to_cpu (cq_desc -> params .generic .addr_high ),
925937 le32_to_cpu (cq_desc -> params .generic .addr_low ));
926- if (buf && cq_desc -> datalen != 0 ) {
927- ice_debug (hw , ICE_DBG_AQ_DESC_BUF , "Buffer:\n" );
928- if (buf_len < len )
929- len = buf_len ;
930-
931- ice_debug_array (hw , ICE_DBG_AQ_DESC_BUF , 16 , 1 , buf , len );
938+ /* Dump buffer iff 1) one exists and 2) is either a response indicated
939+ * by the DD and/or CMP flag set or a command with the RD flag set.
940+ */
941+ if (buf && cq_desc -> datalen &&
942+ (flags & (ICE_AQ_FLAG_DD | ICE_AQ_FLAG_CMP | ICE_AQ_FLAG_RD ))) {
943+ char prefix [] = KBUILD_MODNAME " 0x12341234 0x12341234 " ;
944+
945+ sprintf (prefix , KBUILD_MODNAME " 0x%08X 0x%08X " ,
946+ le32_to_cpu (cq_desc -> params .generic .addr_high ),
947+ le32_to_cpu (cq_desc -> params .generic .addr_low ));
948+ ice_debug_array_w_prefix (hw , ICE_DBG_AQ_DESC_BUF , prefix ,
949+ buf ,
950+ min_t (u16 , buf_len , datalen ));
932951 }
933952}
934953
935954/**
936- * ice_sq_done - check if FW has processed the Admin Send Queue (ATQ)
955+ * ice_sq_done - poll until the last send on a control queue has completed
937956 * @hw: pointer to the HW struct
938957 * @cq: pointer to the specific Control queue
939958 *
940- * Returns true if the firmware has processed all descriptors on the
941- * admin send queue. Returns false if there are still requests pending.
959+ * Use read_poll_timeout to poll the control queue head, checking until it
960+ * matches next_to_use. According to the control queue designers, this has
961+ * better timing reliability than the DD bit.
962+ *
963+ * Return: true if all the descriptors on the send side of a control queue
964+ * are finished processing, false otherwise.
942965 */
943966static bool ice_sq_done (struct ice_hw * hw , struct ice_ctl_q_info * cq )
944967{
945- /* AQ designers suggest use of head for better
946- * timing reliability than DD bit
968+ u32 head ;
969+
970+ /* Wait a short time before the initial check, to allow hardware time
971+ * for completion.
947972 */
948- return rd32 (hw , cq -> sq .head ) == cq -> sq .next_to_use ;
973+ udelay (5 );
974+
975+ return !rd32_poll_timeout (hw , cq -> sq .head ,
976+ head , head == cq -> sq .next_to_use ,
977+ 20 , ICE_CTL_Q_SQ_CMD_TIMEOUT );
949978}
950979
951980/**
952- * ice_sq_send_cmd - send command to Control Queue (ATQ)
981+ * ice_sq_send_cmd - send command to a control queue
953982 * @hw: pointer to the HW struct
954983 * @cq: pointer to the specific Control queue
955984 * @desc: prefilled descriptor describing the command
956985 * @buf: buffer to use for indirect commands (or NULL for direct commands)
957986 * @buf_size: size of buffer for indirect commands (or 0 for direct commands)
958987 * @cd: pointer to command details structure
959988 *
960- * This is the main send command routine for the ATQ. It runs the queue,
961- * cleans the queue, etc.
989+ * Main command for the transmit side of a control queue. It puts the command
990+ * on the queue, bumps the tail, waits for processing of the command, captures
991+ * command status and results, etc.
962992 */
963993int
964994ice_sq_send_cmd (struct ice_hw * hw , struct ice_ctl_q_info * cq ,
@@ -968,8 +998,6 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
968998 struct ice_dma_mem * dma_buf = NULL ;
969999 struct ice_aq_desc * desc_on_ring ;
9701000 bool cmd_completed = false;
971- struct ice_sq_cd * details ;
972- unsigned long timeout ;
9731001 int status = 0 ;
9741002 u16 retval = 0 ;
9751003 u32 val = 0 ;
@@ -1013,12 +1041,6 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
10131041 goto sq_send_command_error ;
10141042 }
10151043
1016- details = ICE_CTL_Q_DETAILS (cq -> sq , cq -> sq .next_to_use );
1017- if (cd )
1018- * details = * cd ;
1019- else
1020- memset (details , 0 , sizeof (* details ));
1021-
10221044 /* Call clean and check queue available function to reclaim the
10231045 * descriptors that were processed by FW/MBX; the function returns the
10241046 * number of desc available. The clean function called here could be
@@ -1055,28 +1077,17 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
10551077 /* Debug desc and buffer */
10561078 ice_debug (hw , ICE_DBG_AQ_DESC , "ATQ: Control Send queue desc and buffer:\n" );
10571079
1058- ice_debug_cq (hw , (void * )desc_on_ring , buf , buf_size );
1080+ ice_debug_cq (hw , cq , (void * )desc_on_ring , buf , buf_size , false );
10591081
10601082 (cq -> sq .next_to_use )++ ;
10611083 if (cq -> sq .next_to_use == cq -> sq .count )
10621084 cq -> sq .next_to_use = 0 ;
10631085 wr32 (hw , cq -> sq .tail , cq -> sq .next_to_use );
10641086 ice_flush (hw );
10651087
1066- /* Wait a short time before initial ice_sq_done() check, to allow
1067- * hardware time for completion .
1088+ /* Wait for the command to complete. If it finishes within the
1089+ * timeout, copy the descriptor back to temp .
10681090 */
1069- udelay (5 );
1070-
1071- timeout = jiffies + ICE_CTL_Q_SQ_CMD_TIMEOUT ;
1072- do {
1073- if (ice_sq_done (hw , cq ))
1074- break ;
1075-
1076- usleep_range (100 , 150 );
1077- } while (time_before (jiffies , timeout ));
1078-
1079- /* if ready, copy the desc back to temp */
10801091 if (ice_sq_done (hw , cq )) {
10811092 memcpy (desc , desc_on_ring , sizeof (* desc ));
10821093 if (buf ) {
@@ -1108,12 +1119,11 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
11081119
11091120 ice_debug (hw , ICE_DBG_AQ_MSG , "ATQ: desc and buffer writeback:\n" );
11101121
1111- ice_debug_cq (hw , (void * )desc , buf , buf_size );
1122+ ice_debug_cq (hw , cq , (void * )desc , buf , buf_size , true );
11121123
11131124 /* save writeback AQ if requested */
1114- if (details -> wb_desc )
1115- memcpy (details -> wb_desc , desc_on_ring ,
1116- sizeof (* details -> wb_desc ));
1125+ if (cd && cd -> wb_desc )
1126+ memcpy (cd -> wb_desc , desc_on_ring , sizeof (* cd -> wb_desc ));
11171127
11181128 /* update the error if time out occurred */
11191129 if (!cmd_completed ) {
@@ -1154,9 +1164,9 @@ void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode)
11541164 * @e: event info from the receive descriptor, includes any buffers
11551165 * @pending: number of events that could be left to process
11561166 *
1157- * This function cleans one Admin Receive Queue element and returns
1158- * the contents through e. It can also return how many events are
1159- * left to process through 'pending' .
1167+ * Clean one element from the receive side of a control queue. On return 'e'
1168+ * contains contents of the message, and 'pending' contains the number of
1169+ * events left to process.
11601170 */
11611171int
11621172ice_clean_rq_elem (struct ice_hw * hw , struct ice_ctl_q_info * cq ,
@@ -1212,7 +1222,7 @@ ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
12121222
12131223 ice_debug (hw , ICE_DBG_AQ_DESC , "ARQ: desc and buffer:\n" );
12141224
1215- ice_debug_cq (hw , (void * )desc , e -> msg_buf , cq -> rq_buf_size );
1225+ ice_debug_cq (hw , cq , (void * )desc , e -> msg_buf , cq -> rq_buf_size , true );
12161226
12171227 /* Restore the original datalen and buffer address in the desc,
12181228 * FW updates datalen to indicate the event message size
0 commit comments