From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45512A052B for ; Wed, 29 Jul 2020 16:26:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BFA31C010; Wed, 29 Jul 2020 16:26:11 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 683F4E07 for ; Wed, 29 Jul 2020 16:26:08 +0200 (CEST) IronPort-SDR: XNqt/Nqfv/nEg3uERgZr1iIkpWiz+YgJJlPcuz952fH227LoAWF2BIxrTpWGml2ORWVI1m3Psj VuIB9mXWpu9Q== X-IronPort-AV: E=McAfee;i="6000,8403,9696"; a="152655135" X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="152655135" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 07:26:08 -0700 IronPort-SDR: QBWsLnNT0YjiaNqGu+bEsp29NrpiSBpZboRpvy7MSQHaCoZlzwOlZT368idN1xGj/QV+LmJ6mY gxm7DclxAZvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="304236820" Received: from adamdybx-mobl.ger.corp.intel.com ([10.104.121.101]) by orsmga002.jf.intel.com with ESMTP; 29 Jul 2020 07:26:06 -0700 From: Adam Dybkowski To: stable@dpdk.org, fiona.trahe@intel.com, luca.boccassi@gmail.com Cc: Adam Dybkowski Date: Wed, 29 Jul 2020 16:22:51 +0200 Message-Id: <20200729142252.177-3-adamx.dybkowski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200729142252.177-1-adamx.dybkowski@intel.com> References: <20200729142252.177-1-adamx.dybkowski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 19.11 3/4] common/qat: get firmware version X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 7444111408ba9a00e40fcc9318b8ae83cac76735 ] This patch adds the function for retrieving QAT firmware version, required to check the internal capabilities that depend on the FW version. Signed-off-by: Adam Dybkowski Acked-by: Fiona Trahe --- drivers/common/qat/qat_adf/icp_qat_fw.h | 2 + drivers/common/qat/qat_qp.c | 93 +++++++++++++++++++++++++ drivers/common/qat/qat_qp.h | 3 + 3 files changed, 98 insertions(+) diff --git a/drivers/common/qat/qat_adf/icp_qat_fw.h b/drivers/common/qat/qat_adf/icp_qat_fw.h index 1265c2a13..be10fc9bd 100644 --- a/drivers/common/qat/qat_adf/icp_qat_fw.h +++ b/drivers/common/qat/qat_adf/icp_qat_fw.h @@ -121,6 +121,8 @@ struct icp_qat_fw_comn_resp { #define ICP_QAT_FW_COMN_CNV_FLAG_MASK 0x1 #define ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS 5 #define ICP_QAT_FW_COMN_CNVNR_FLAG_MASK 0x1 +#define ICP_QAT_FW_COMN_NULL_VERSION_FLAG_BITPOS 0 +#define ICP_QAT_FW_COMN_NULL_VERSION_FLAG_MASK 0x1 #define ICP_QAT_FW_COMN_OV_SRV_TYPE_GET(icp_qat_fw_comn_req_hdr_t) \ icp_qat_fw_comn_req_hdr_t.service_type diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c index 03f11f869..26ec854da 100644 --- a/drivers/common/qat/qat_qp.c +++ b/drivers/common/qat/qat_qp.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -19,6 +20,7 @@ #include "qat_comp.h" #include "adf_transport_access_macros.h" +#define QAT_CQ_MAX_DEQ_RETRIES 10 #define ADF_MAX_DESC 4096 #define ADF_MIN_DESC 128 @@ -685,6 +687,97 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops) return resp_counter; } +/* This is almost same as dequeue_op_burst, without the atomic, without stats + * and without the op. Dequeues one response. + */ +static uint8_t +qat_cq_dequeue_response(struct qat_qp *qp, void *out_data) +{ + uint8_t result = 0; + uint8_t retries = 0; + struct qat_queue *queue = &(qp->rx_q); + struct icp_qat_fw_comn_resp *resp_msg = (struct icp_qat_fw_comn_resp *) + ((uint8_t *)queue->base_addr + queue->head); + + while (retries++ < QAT_CQ_MAX_DEQ_RETRIES && + *(uint32_t *)resp_msg == ADF_RING_EMPTY_SIG) { + /* loop waiting for response until we reach the timeout */ + rte_delay_ms(20); + } + + if (*(uint32_t *)resp_msg != ADF_RING_EMPTY_SIG) { + /* response received */ + result = 1; + + /* check status flag */ + if (ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET( + resp_msg->comn_hdr.comn_status) == + ICP_QAT_FW_COMN_STATUS_FLAG_OK) { + /* success */ + memcpy(out_data, resp_msg, queue->msg_size); + } else { + memset(out_data, 0, queue->msg_size); + } + + queue->head = adf_modulo(queue->head + queue->msg_size, + queue->modulo_mask); + rxq_free_desc(qp, queue); + } + + return result; +} + +/* Sends a NULL message and extracts QAT fw version from the response. + * Used to determine detailed capabilities based on the fw version number. + * This assumes that there are no inflight messages, i.e. assumes there's space + * on the qp, one message is sent and only one response collected. + * Returns fw version number or 0 for unknown version or a negative error code. + */ +int +qat_cq_get_fw_version(struct qat_qp *qp) +{ + struct qat_queue *queue = &(qp->tx_q); + uint8_t *base_addr = (uint8_t *)queue->base_addr; + struct icp_qat_fw_comn_req null_msg; + struct icp_qat_fw_comn_resp response; + + /* prepare the NULL request */ + memset(&null_msg, 0, sizeof(null_msg)); + null_msg.comn_hdr.hdr_flags = + ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(ICP_QAT_FW_COMN_REQ_FLAG_SET); + null_msg.comn_hdr.service_type = ICP_QAT_FW_COMN_REQ_NULL; + null_msg.comn_hdr.service_cmd_id = ICP_QAT_FW_NULL_REQ_SERV_ID; + +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "NULL request", &null_msg, sizeof(null_msg)); +#endif + + /* send the NULL request */ + memcpy(base_addr + queue->tail, &null_msg, sizeof(null_msg)); + queue->tail = adf_modulo(queue->tail + queue->msg_size, + queue->modulo_mask); + txq_write_tail(qp, queue); + + /* receive a response */ + if (qat_cq_dequeue_response(qp, &response)) { + +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "NULL response:", &response, + sizeof(response)); +#endif + /* if LW0 bit 24 is set - then the fw version was returned */ + if (QAT_FIELD_GET(response.comn_hdr.hdr_flags, + ICP_QAT_FW_COMN_NULL_VERSION_FLAG_BITPOS, + ICP_QAT_FW_COMN_NULL_VERSION_FLAG_MASK)) + return response.resrvd[0]; /* return LW4 */ + else + return 0; /* not set - we don't know fw version */ + } + + QAT_LOG(ERR, "No response received"); + return -EINVAL; +} + __rte_weak int qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused, void *op_cookie __rte_unused, diff --git a/drivers/common/qat/qat_qp.h b/drivers/common/qat/qat_qp.h index 980c2ba32..d0bf91509 100644 --- a/drivers/common/qat/qat_qp.h +++ b/drivers/common/qat/qat_qp.h @@ -105,6 +105,9 @@ int qat_qps_per_service(const struct qat_qp_hw_data *qp_hw_data, enum qat_service_type service); +int +qat_cq_get_fw_version(struct qat_qp *qp); + /* Needed for weak function*/ int qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused, -- 2.25.1