All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH S57 01/14] ice: Re-send some AQ commands, as result of EBUSY AQ error
@ 2021-03-25 22:35 Tony Nguyen
  2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 02/14] ice: Modify recursive way of adding nodes Tony Nguyen
                   ` (13 more replies)
  0 siblings, 14 replies; 28+ messages in thread
From: Tony Nguyen @ 2021-03-25 22:35 UTC (permalink / raw)
  To: intel-wired-lan

From: Chinh T Cao <chinh.t.cao@intel.com>

Retry sending some AQ commands, as result of EBUSY AQ error.
ice_aqc_opc_get_link_topo
ice_aqc_opc_lldp_stop
ice_aqc_opc_lldp_start
ice_aqc_opc_lldp_filter_ctrl

This change follows the latest guidelines from HW team. It is
better to retry the same AQ command several times, as the result
of EBUSY, instead of returning error to the caller right away.

Signed-off-by: Chinh T Cao <chinh.t.cao@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_common.c   | 81 ++++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_common.h   |  3 +
 drivers/net/ethernet/intel/ice/ice_controlq.c |  2 +-
 3 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 34fddbc30822..f1573d653321 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1292,6 +1292,85 @@ const struct ice_ctx_ele ice_tlan_ctx_info[] = {
  */
 DEFINE_MUTEX(ice_global_cfg_lock_sw);
 
+/**
+ * ice_should_retry_sq_send_cmd
+ * @opcode: AQ opcode
+ *
+ * Decide if we should retry the send command routine for the ATQ, depending
+ * on the opcode.
+ */
+static bool ice_should_retry_sq_send_cmd(u16 opcode)
+{
+	switch (opcode) {
+	case ice_aqc_opc_get_link_topo:
+	case ice_aqc_opc_lldp_stop:
+	case ice_aqc_opc_lldp_start:
+	case ice_aqc_opc_lldp_filter_ctrl:
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * ice_sq_send_cmd_retry - send command to Control Queue (ATQ)
+ * @hw: pointer to the HW struct
+ * @cq: pointer to the specific Control queue
+ * @desc: prefilled descriptor describing the command
+ * @buf: buffer to use for indirect commands (or NULL for direct commands)
+ * @buf_size: size of buffer for indirect commands (or 0 for direct commands)
+ * @cd: pointer to command details structure
+ *
+ * Retry sending the FW Admin Queue command, multiple times, to the FW Admin
+ * Queue if the EBUSY AQ error is returned.
+ */
+static enum ice_status
+ice_sq_send_cmd_retry(struct ice_hw *hw, struct ice_ctl_q_info *cq,
+		      struct ice_aq_desc *desc, void *buf, u16 buf_size,
+		      struct ice_sq_cd *cd)
+{
+	struct ice_aq_desc desc_cpy;
+	enum ice_status status;
+	bool is_cmd_for_retry;
+	u8 *buf_cpy = NULL;
+	u8 idx = 0;
+	u16 opcode;
+
+	opcode = le16_to_cpu(desc->opcode);
+	is_cmd_for_retry = ice_should_retry_sq_send_cmd(opcode);
+	memset(&desc_cpy, 0, sizeof(desc_cpy));
+
+	if (is_cmd_for_retry) {
+		if (buf) {
+			buf_cpy = kzalloc(buf_size, GFP_KERNEL);
+			if (!buf_cpy)
+				return ICE_ERR_NO_MEMORY;
+		}
+
+		memcpy(&desc_cpy, desc, sizeof(desc_cpy));
+	}
+
+	do {
+		status = ice_sq_send_cmd(hw, cq, desc, buf, buf_size, cd);
+
+		if (!is_cmd_for_retry || !status ||
+		    hw->adminq.sq_last_status != ICE_AQ_RC_EBUSY)
+			break;
+
+		if (buf_cpy)
+			memcpy(buf, buf_cpy, buf_size);
+
+		memcpy(desc, &desc_cpy, sizeof(desc_cpy));
+
+		mdelay(ICE_SQ_SEND_DELAY_TIME_MS);
+
+	} while (++idx < ICE_SQ_SEND_MAX_EXECUTE);
+
+	kfree(buf_cpy);
+
+	return status;
+}
+
 /**
  * ice_aq_send_cmd - send FW Admin Queue command to FW Admin Queue
  * @hw: pointer to the HW struct
@@ -1333,7 +1412,7 @@ ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf,
 		break;
 	}
 
-	status = ice_sq_send_cmd(hw, &hw->adminq, desc, buf, buf_size, cd);
+	status = ice_sq_send_cmd_retry(hw, &hw->adminq, desc, buf, buf_size, cd);
 	if (lock_acquired)
 		mutex_unlock(&ice_global_cfg_lock_sw);
 
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index 81fd69cb1485..d14406b11c92 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -11,6 +11,9 @@
 #include "ice_switch.h"
 #include <linux/avf/virtchnl.h>
 
+#define ICE_SQ_SEND_DELAY_TIME_MS	10
+#define ICE_SQ_SEND_MAX_EXECUTE		3
+
 enum ice_status ice_init_hw(struct ice_hw *hw);
 void ice_deinit_hw(struct ice_hw *hw);
 enum ice_status ice_check_reset(struct ice_hw *hw);
diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c
index b2d8a5932b1d..0f207a42ea77 100644
--- a/drivers/net/ethernet/intel/ice/ice_controlq.c
+++ b/drivers/net/ethernet/intel/ice/ice_controlq.c
@@ -892,7 +892,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)
  * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
- * @desc: prefilled descriptor describing the command (non DMA mem)
+ * @desc: prefilled descriptor describing the command
  * @buf: buffer to use for indirect commands (or NULL for direct commands)
  * @buf_size: size of buffer for indirect commands (or 0 for direct commands)
  * @cd: pointer to command details structure
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-04-07 23:14 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25 22:35 [Intel-wired-lan] [PATCH S57 01/14] ice: Re-send some AQ commands, as result of EBUSY AQ error Tony Nguyen
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 02/14] ice: Modify recursive way of adding nodes Tony Nguyen
2021-03-31 20:48   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 03/14] ice: Align macro names to the specification Tony Nguyen
2021-03-31 20:55   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 04/14] ice: Ignore EMODE return for opcode 0x0605 Tony Nguyen
2021-03-31 20:59   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 05/14] ice: Remove unnecessary checker loop Tony Nguyen
2021-03-31 21:01   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 06/14] ice: Rename a couple of variables Tony Nguyen
2021-03-31 21:36   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 07/14] ice: Fix error return codes in ice_set_link_ksettings Tony Nguyen
2021-04-07 23:14   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 08/14] ice: Replace some memsets and memcpys with assignment Tony Nguyen
2021-03-31 21:39   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 09/14] ice: Use default configuration mode for PHY configuration Tony Nguyen
2021-04-05 22:49   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 10/14] ice: Limit forced overrides based on FW version Tony Nguyen
2021-04-05 22:48   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 11/14] ice: Remove unnecessary variable Tony Nguyen
2021-03-31 21:48   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 12/14] ice: Use local variable instead of pointer derefs Tony Nguyen
2021-03-31 21:50   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 13/14] ice: Remove rx_gro_dropped stat Tony Nguyen
2021-03-31 21:52   ` Brelinski, TonyX
2021-03-25 22:35 ` [Intel-wired-lan] [PATCH S57 14/14] ice: Remove unnecessary checks in add/kill_vid ndo ops Tony Nguyen
2021-03-31 21:58   ` Brelinski, TonyX
2021-03-31 20:41 ` [Intel-wired-lan] [PATCH S57 01/14] ice: Re-send some AQ commands, as result of EBUSY AQ error Brelinski, TonyX

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.