[27/28] net/ice/base: add the hook to send AdminQ command

Message ID 20200309114357.31800-28-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series update ice base code |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Qi Zhang March 9, 2020, 11:43 a.m. UTC
  Add the hook to send the PF's AdminQ command in another path, like not
directly to the firmware.

If the AdminQ command is sent through the hook path, it needs to save
the AQ error codes from firmware as the last status for admin control
queue, so that the AdminQ command function can use it to do exception
handling like the buffer size is not enough accorindg to error ENOMEM.

And convert explicitly the hook path result to the ice_status type.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_common.c | 22 ++++++++++++++++++++++
 drivers/net/ice/base/ice_type.h   |  4 ++++
 2 files changed, 26 insertions(+)
  

Patch

diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index 709d8b95a..14c923701 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -1315,6 +1315,28 @@  enum ice_status
 ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf,
 		u16 buf_size, struct ice_sq_cd *cd)
 {
+	if (hw->aq_send_cmd_fn) {
+		enum ice_status status = ICE_ERR_NOT_READY;
+		u16 retval = ICE_AQ_RC_OK;
+
+		ice_acquire_lock(&hw->adminq.sq_lock);
+		if (!hw->aq_send_cmd_fn(hw->aq_send_cmd_param, desc,
+					buf, buf_size)) {
+			retval = LE16_TO_CPU(desc->retval);
+			/* strip off FW internal code */
+			if (retval)
+				retval &= 0xff;
+			if (retval == ICE_AQ_RC_OK)
+				status = ICE_SUCCESS;
+			else
+				status = ICE_ERR_AQ_ERROR;
+		}
+
+		hw->adminq.sq_last_status = (enum ice_aq_err)retval;
+		ice_release_lock(&hw->adminq.sq_lock);
+
+		return status;
+	}
 	return ice_sq_send_cmd(hw, &hw->adminq, desc, buf, buf_size, cd);
 }
 
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index 127e8224d..478940225 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -818,6 +818,10 @@  struct ice_hw {
 	/* Control Queue info */
 	struct ice_ctl_q_info adminq;
 	struct ice_ctl_q_info mailboxq;
+	/* Additional function to send AdminQ command */
+	int (*aq_send_cmd_fn)(void *param, struct ice_aq_desc *desc,
+			      void *buf, u16 buf_size);
+	void *aq_send_cmd_param;
 
 	u8 api_branch;		/* API branch version */
 	u8 api_maj_ver;		/* API major version */