From: Arek Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: akhil.goyal@nxp.com, fiona.trahe@intel.com,
Arek Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [dpdk-dev] [PATCH v5 2/3] drivers/qat: add multi process handling of driver id
Date: Tue, 7 Jul 2020 17:02:38 +0200 [thread overview]
Message-ID: <20200707150239.13400-3-arkadiuszx.kusztal@intel.com> (raw)
In-Reply-To: <20200707150239.13400-1-arkadiuszx.kusztal@intel.com>
As cryptodev driver_id is allocated per-process, a corner case exists where
binaries for primary and secondary processes could have different
driver_ids if built differently. Add checking in qat PMD to catch and
handle the case where driver_ids are inconsistent.
Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
drivers/common/qat/qat_device.h | 6 ++++++
drivers/crypto/qat/qat_asym.c | 4 ++--
drivers/crypto/qat/qat_asym_pmd.c | 21 +++++++++++++++++----
drivers/crypto/qat/qat_asym_pmd.h | 2 +-
drivers/crypto/qat/qat_sym.c | 2 +-
drivers/crypto/qat/qat_sym.h | 2 +-
drivers/crypto/qat/qat_sym_pmd.c | 27 +++++++++++++++++++++++----
drivers/crypto/qat/qat_sym_pmd.h | 2 +-
8 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h
index b5fe394..e6337c6 100644
--- a/drivers/common/qat/qat_device.h
+++ b/drivers/common/qat/qat_device.h
@@ -92,10 +92,16 @@ struct qat_pci_device {
struct qat_sym_dev_private *sym_dev;
/**< link back to cryptodev private data */
+ int qat_sym_driver_id;
+ /**< Symmetric driver id used by this device */
+
/* Data relating to asymmetric crypto service */
struct qat_asym_dev_private *asym_dev;
/**< link back to cryptodev private data */
+ int qat_asym_driver_id;
+ /**< Symmetric driver id used by this device */
+
/* Data relating to compression service */
struct qat_comp_dev_private *comp_dev;
/**< link back to compressdev private data */
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index ae0dd79..8597381 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -475,7 +475,7 @@ qat_asym_build_request(void *in_op,
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
ctx = (struct qat_asym_session *)
get_asym_session_private_data(
- op->asym->session, cryptodev_qat_asym_driver_id);
+ op->asym->session, qat_asym_driver_id);
if (unlikely(ctx == NULL)) {
QAT_LOG(ERR, "Session has not been created for this device");
goto error;
@@ -693,7 +693,7 @@ qat_asym_process_response(void **op, uint8_t *resp,
if (rx_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
ctx = (struct qat_asym_session *)get_asym_session_private_data(
- rx_op->asym->session, cryptodev_qat_asym_driver_id);
+ rx_op->asym->session, qat_asym_driver_id);
qat_asym_collect_response(rx_op, cookie, ctx->xform);
} else if (rx_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
qat_asym_collect_response(rx_op, cookie, rx_op->asym->xform);
diff --git a/drivers/crypto/qat/qat_asym_pmd.c b/drivers/crypto/qat/qat_asym_pmd.c
index cc448cd..d584ac7 100644
--- a/drivers/crypto/qat/qat_asym_pmd.c
+++ b/drivers/crypto/qat/qat_asym_pmd.c
@@ -11,7 +11,7 @@
#include "qat_sym_capabilities.h"
#include "qat_asym_capabilities.h"
-uint8_t cryptodev_qat_asym_driver_id;
+uint8_t qat_asym_driver_id;
static const struct rte_cryptodev_capabilities qat_gen1_asym_capabilities[] = {
QAT_BASE_GEN1_ASYM_CAPABILITIES,
@@ -63,7 +63,7 @@ static void qat_asym_dev_info_get(struct rte_cryptodev *dev,
QAT_SERVICE_ASYMMETRIC);
info->feature_flags = dev->feature_flags;
info->capabilities = internals->qat_dev_capabilities;
- info->driver_id = cryptodev_qat_asym_driver_id;
+ info->driver_id = qat_asym_driver_id;
/* No limit of number of sessions */
info->sym.max_nb_sessions = 0;
}
@@ -251,6 +251,19 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
struct rte_cryptodev *cryptodev;
struct qat_asym_dev_private *internals;
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ qat_pci_dev->qat_asym_driver_id =
+ qat_asym_driver_id;
+ } else if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ if (qat_pci_dev->qat_asym_driver_id !=
+ qat_asym_driver_id) {
+ QAT_LOG(ERR,
+ "Device %s have different driver id than corresponding device in primary process",
+ name);
+ return -(EFAULT);
+ }
+ }
+
snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s",
qat_pci_dev->name, "asym");
QAT_LOG(DEBUG, "Creating QAT ASYM device %s\n", name);
@@ -268,7 +281,7 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
return -ENODEV;
qat_dev_instance->asym_rte_dev.name = cryptodev->data->name;
- cryptodev->driver_id = cryptodev_qat_asym_driver_id;
+ cryptodev->driver_id = qat_asym_driver_id;
cryptodev->dev_ops = &crypto_qat_ops;
cryptodev->enqueue_burst = qat_asym_pmd_enqueue_op_burst;
@@ -326,4 +339,4 @@ qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev)
static struct cryptodev_driver qat_crypto_drv;
RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv,
cryptodev_qat_asym_driver,
- cryptodev_qat_asym_driver_id);
+ qat_asym_driver_id);
diff --git a/drivers/crypto/qat/qat_asym_pmd.h b/drivers/crypto/qat/qat_asym_pmd.h
index 0535bc6..ddf413f 100644
--- a/drivers/crypto/qat/qat_asym_pmd.h
+++ b/drivers/crypto/qat/qat_asym_pmd.h
@@ -13,7 +13,7 @@
#define CRYPTODEV_NAME_QAT_ASYM_PMD crypto_qat_asym
-extern uint8_t cryptodev_qat_asym_driver_id;
+extern uint8_t qat_asym_driver_id;
/** private data structure for a QAT device.
* This QAT device is a device offering only asymmetric crypto service,
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 55251d1..6d568ab 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -206,7 +206,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
return -EINVAL;
} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
ctx = (struct qat_sym_session *)get_sym_session_private_data(
- op->sym->session, cryptodev_qat_driver_id);
+ op->sym->session, qat_sym_driver_id);
#ifdef RTE_LIBRTE_SECURITY
} else {
ctx = (struct qat_sym_session *)get_sec_session_private_data(
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 02e7239..dbca74e 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -197,7 +197,7 @@ qat_sym_process_response(void **op, uint8_t *resp)
sess = (struct qat_sym_session *)
get_sym_session_private_data(
rx_op->sym->session,
- cryptodev_qat_driver_id);
+ qat_sym_driver_id);
}
rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
diff --git a/drivers/crypto/qat/qat_sym_pmd.c b/drivers/crypto/qat/qat_sym_pmd.c
index bdcb42e..6ef9a34 100644
--- a/drivers/crypto/qat/qat_sym_pmd.c
+++ b/drivers/crypto/qat/qat_sym_pmd.c
@@ -19,7 +19,7 @@
#define MIXED_CRYPTO_MIN_FW_VER 0x04090000
-uint8_t cryptodev_qat_driver_id;
+uint8_t qat_sym_driver_id;
static const struct rte_cryptodev_capabilities qat_gen1_sym_capabilities[] = {
QAT_BASE_GEN1_SYM_CAPABILITIES,
@@ -92,7 +92,7 @@ static void qat_sym_dev_info_get(struct rte_cryptodev *dev,
qat_qps_per_service(sym_hw_qps, QAT_SERVICE_SYMMETRIC);
info->feature_flags = dev->feature_flags;
info->capabilities = internals->qat_dev_capabilities;
- info->driver_id = cryptodev_qat_driver_id;
+ info->driver_id = qat_sym_driver_id;
/* No limit of number of sessions */
info->sym.max_nb_sessions = 0;
}
@@ -317,6 +317,25 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev,
struct rte_cryptodev *cryptodev;
struct qat_sym_dev_private *internals;
+ /*
+ * All processes must use same driver id so they can share sessions.
+ * Store driver_id so we can validate that all processes have the same
+ * value, typically they have, but could differ if binaries built
+ * separately.
+ */
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ qat_pci_dev->qat_sym_driver_id =
+ qat_sym_driver_id;
+ } else if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ if (qat_pci_dev->qat_sym_driver_id !=
+ qat_sym_driver_id) {
+ QAT_LOG(ERR,
+ "Device %s have different driver id than corresponding device in primary process",
+ name);
+ return -(EFAULT);
+ }
+ }
+
#ifdef RTE_LIBRTE_SECURITY
struct rte_security_ctx *security_instance;
#endif
@@ -338,7 +357,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev,
return -ENODEV;
qat_dev_instance->sym_rte_dev.name = cryptodev->data->name;
- cryptodev->driver_id = cryptodev_qat_driver_id;
+ cryptodev->driver_id = qat_sym_driver_id;
cryptodev->dev_ops = &crypto_qat_ops;
cryptodev->enqueue_burst = qat_sym_pmd_enqueue_op_burst;
@@ -434,4 +453,4 @@ qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev)
static struct cryptodev_driver qat_crypto_drv;
RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv,
cryptodev_qat_sym_driver,
- cryptodev_qat_driver_id);
+ qat_sym_driver_id);
diff --git a/drivers/crypto/qat/qat_sym_pmd.h b/drivers/crypto/qat/qat_sym_pmd.h
index c625fef..cf4e1a0 100644
--- a/drivers/crypto/qat/qat_sym_pmd.h
+++ b/drivers/crypto/qat/qat_sym_pmd.h
@@ -23,7 +23,7 @@
#define QAT_SYM_CAP_MIXED_CRYPTO (1 << 0)
#define QAT_SYM_CAP_VALID (1 << 31)
-extern uint8_t cryptodev_qat_driver_id;
+extern uint8_t qat_sym_driver_id;
/** private data structure for a QAT device.
* This QAT device is a device offering only symmetric crypto service,
--
2.1.0
next prev parent reply other threads:[~2020-07-07 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 15:02 [dpdk-dev] [PATCH v5 0/3] drivers/qat: improve handling of multi process Arek Kusztal
2020-07-07 15:02 ` [dpdk-dev] [PATCH v5 1/3] " Arek Kusztal
2020-07-07 15:02 ` Arek Kusztal [this message]
2020-07-07 15:02 ` [dpdk-dev] [PATCH v5 3/3] drivers/qat: add handling of capabilities in " Arek Kusztal
2020-07-07 22:28 ` Akhil Goyal
2020-07-07 15:28 ` [dpdk-dev] [PATCH v5 0/3] drivers/qat: improve handling of " Trahe, Fiona
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=20200707150239.13400-3-arkadiuszx.kusztal@intel.com \
--to=arkadiuszx.kusztal@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
/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).