From: Junfeng Guo <junfeng.guo@intel.com>
To: qi.z.zhang@intel.com, qiming.yang@intel.com
Cc: dev@dpdk.org, stable@dpdk.org, ferruh.yigit@intel.com,
junfeng.guo@intel.com, Jacob Keller <jacob.e.keller@intel.com>,
Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Subject: [dpdk-dev] [PATCH v3 5/8] net/ice/base: add capability list AQ function
Date: Fri, 10 Jul 2020 10:14:09 +0800 [thread overview]
Message-ID: <20200710021412.3403562-6-junfeng.guo@intel.com> (raw)
In-Reply-To: <20200710021412.3403562-1-junfeng.guo@intel.com>
From: Qi Zhang <qi.z.zhang@intel.com>
The current implementation for reading device and function capabilities
from firmware, ice_aq_discover_caps, has potentially undesirable
side effects.
ice_aq_discover_caps calls ice_parse_caps, resulting in overwriting the
capabilities stored in the hw structure. This is ok during
initialization, but means that code which wants to read the capabilities
after initialization cannot use ice_aq_discover_caps without being
careful of the side effects.
Factor out the AQ command logic into a new ice_aq_list_caps function.
This will be used by the ice_aq_discover_caps function.
Signed-off-by: Jacob Keller <jacob.e.keller@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>
Acked-by: Qiming Yang <qiming.yang@intel.com>
---
drivers/net/ice/base/ice_common.c | 62 +++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index cab81e0fc..33e29bc0e 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -2007,20 +2007,27 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
}
/**
- * ice_aq_discover_caps - query function/device capabilities
+ * ice_aq_list_caps - query function/device capabilities
* @hw: pointer to the HW struct
- * @buf: a virtual buffer to hold the capabilities
- * @buf_size: Size of the virtual buffer
- * @cap_count: cap count needed if AQ err==ENOMEM
- * @opc: capabilities type to discover - pass in the command opcode
+ * @buf: a buffer to hold the capabilities
+ * @buf_size: size of the buffer
+ * @cap_count: if not NULL, set to the number of capabilities reported
+ * @opc: capabilities type to discover, device or function
* @cd: pointer to command details structure or NULL
*
- * Get the function(0x000a)/device(0x000b) capabilities description from
- * the firmware.
+ * Get the function (0x000A) or device (0x000B) capabilities description from
+ * firmware and store it in the buffer.
+ *
+ * If the cap_count pointer is not NULL, then it is set to the number of
+ * capabilities firmware will report. Note that if the buffer size is too
+ * small, it is possible the command will return ICE_AQ_ERR_ENOMEM. The
+ * cap_count will still be updated in this case. It is recommended that the
+ * buffer size be set to ICE_AQ_MAX_BUF_LEN (the largest possible buffer that
+ * firmware could return) to avoid this.
*/
static enum ice_status
-ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
- enum ice_adminq_opc opc, struct ice_sq_cd *cd)
+ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
+ enum ice_adminq_opc opc, struct ice_sq_cd *cd)
{
struct ice_aqc_list_caps *cmd;
struct ice_aq_desc desc;
@@ -2033,12 +2040,43 @@ ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
return ICE_ERR_PARAM;
ice_fill_dflt_direct_cmd_desc(&desc, opc);
-
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
+
+ if (cap_count)
+ *cap_count = LE32_TO_CPU(cmd->count);
+
+ return status;
+}
+
+/**
+ * ice_aq_discover_caps - query function/device capabilities
+ * @hw: pointer to the HW struct
+ * @buf: a virtual buffer to hold the capabilities
+ * @buf_size: Size of the virtual buffer
+ * @cap_count: cap count needed if AQ err==ENOMEM
+ * @opc: capabilities type to discover - pass in the command opcode
+ * @cd: pointer to command details structure or NULL
+ *
+ * Get the function(0x000a)/device(0x000b) capabilities description from
+ * the firmware.
+ *
+ * NOTE: this function has the side effect of updating the hw->dev_caps or
+ * hw->func_caps by way of calling ice_parse_caps.
+ */
+static enum ice_status
+ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
+ enum ice_adminq_opc opc, struct ice_sq_cd *cd)
+{
+ u32 local_cap_count = 0;
+ enum ice_status status;
+
+ status = ice_aq_list_caps(hw, buf, buf_size, &local_cap_count,
+ opc, cd);
if (!status)
- ice_parse_caps(hw, buf, LE32_TO_CPU(cmd->count), opc);
+ ice_parse_caps(hw, buf, local_cap_count, opc);
else if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOMEM)
- *cap_count = LE32_TO_CPU(cmd->count);
+ *cap_count = local_cap_count;
+
return status;
}
--
2.25.1
next prev parent reply other threads:[~2020-07-10 2:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 5:49 [dpdk-dev] [PATCH v2 0/8] update base code batch 3 Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 1/8] net/ice/base: fix GTP-U inner RSS IPv4 IPv6 co-exist Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 2/8] net/ice/base: cleanup some code style Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 3/8] net/ice/base: move lldp function to common module Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 4/8] net/ice/base: code clean in FDIR module Qi Zhang
2020-07-02 4:20 ` Yang, Qiming
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 5/8] net/ice/base: add capability list AQ function Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 6/8] net/ice/base: split capability parse into separate functions Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 7/8] net/ice/base: clear and free XLT entries on reset Qi Zhang
2020-07-01 5:49 ` [dpdk-dev] [PATCH v2 8/8] net/ice/base: update version Qi Zhang
2020-07-02 4:22 ` [dpdk-dev] [PATCH v2 0/8] update base code batch 3 Yang, Qiming
2020-07-02 13:06 ` Zhang, Qi Z
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 " Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 1/8] net/ice/base: fix GTP-U inner RSS IPv4 IPv6 co-exist Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 2/8] net/ice/base: cleanup some code style Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 3/8] net/ice/base: move LLDP function to common module Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 4/8] net/ice/base: clean code in flow director module Junfeng Guo
2020-07-10 2:14 ` Junfeng Guo [this message]
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 6/8] net/ice/base: split capability parse into separate functions Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 7/8] net/ice/base: clear and free XLT entries on reset Junfeng Guo
2020-07-10 2:14 ` [dpdk-dev] [PATCH v3 8/8] net/ice/base: update version Junfeng Guo
2020-07-10 4:05 ` [dpdk-dev] [PATCH v3 0/8] update base code batch 3 Zhang, Qi Z
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200710021412.3403562-6-junfeng.guo@intel.com \
--to=junfeng.guo@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=jacob.e.keller@intel.com \
--cc=paul.m.stillwell.jr@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).