[v6,06/16] compress/qat: check that correct firmware is in use
diff mbox series

Message ID 1531411499-13156-7-git-send-email-fiona.trahe@intel.com
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers show
Series
  • compress/qat: add compression PMD
Related show

Checks

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

Commit Message

Trahe, Fiona July 12, 2018, 4:04 p.m. UTC
Check bit in response message to verify that correct firmware
is in use for compression. If not return an error.

Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
---
 drivers/compress/qat/qat_comp.c | 16 +++++++++++++++-
 drivers/compress/qat/qat_comp.h |  2 ++
 2 files changed, 17 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/compress/qat/qat_comp.c b/drivers/compress/qat/qat_comp.c
index a32d6ef..e8019eb 100644
--- a/drivers/compress/qat/qat_comp.c
+++ b/drivers/compress/qat/qat_comp.c
@@ -2,7 +2,6 @@ 
  * Copyright(c) 2018 Intel Corporation
  */
 
-
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_hexdump.h>
@@ -79,6 +78,8 @@  qat_comp_process_response(void **op, uint8_t *resp)
 			(struct icp_qat_fw_comp_resp *)resp;
 	struct rte_comp_op *rx_op = (struct rte_comp_op *)(uintptr_t)
 			(resp_msg->opaque_data);
+	struct qat_comp_xform *qat_xform = (struct qat_comp_xform *)
+				(rx_op->private_xform);
 
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 	QAT_DP_LOG(DEBUG, "Direction: %s",
@@ -88,6 +89,19 @@  qat_comp_process_response(void **op, uint8_t *resp)
 			sizeof(struct icp_qat_fw_comp_resp));
 #endif
 
+	if (likely(qat_xform->qat_comp_request_type
+			!= QAT_COMP_REQUEST_DECOMPRESS)) {
+		if (unlikely(ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(
+				resp_msg->comn_resp.hdr_flags)
+					== ICP_QAT_FW_COMP_NO_CNV)) {
+			rx_op->status = RTE_COMP_OP_STATUS_ERROR;
+			rx_op->debug_status = ERR_CODE_QAT_COMP_WRONG_FW;
+			*op = (void *)rx_op;
+			QAT_DP_LOG(ERR, "QAT has wrong firmware");
+			return 0;
+		}
+	}
+
 	if ((ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(resp_msg->comn_resp.comn_status)
 		| ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(
 				resp_msg->comn_resp.comn_status)) !=
diff --git a/drivers/compress/qat/qat_comp.h b/drivers/compress/qat/qat_comp.h
index 46105b4..937f3c8 100644
--- a/drivers/compress/qat/qat_comp.h
+++ b/drivers/compress/qat/qat_comp.h
@@ -15,6 +15,8 @@ 
 #include "icp_qat_fw_comp.h"
 #include "icp_qat_fw_la.h"
 
+#define ERR_CODE_QAT_COMP_WRONG_FW -99
+
 enum qat_comp_request_type {
 	QAT_COMP_REQUEST_FIXED_COMP_STATELESS,
 	QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,