patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Julien Meunier <julien.meunier@nokia.com>
Cc: Akhil Goyal <akhil.goyal@nxp.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'cryptodev: fix checks related to device id' has been queued to LTS release 18.11.6
Date: Tue,  3 Dec 2019 18:26:57 +0000	[thread overview]
Message-ID: <20191203182714.17297-48-ktraynor@redhat.com> (raw)
In-Reply-To: <20191203182714.17297-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to LTS release 18.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/10/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/8db57afd7ab9a3c12d73f1f5461415690b8c173c

Thanks.

Kevin.

---
From 8db57afd7ab9a3c12d73f1f5461415690b8c173c Mon Sep 17 00:00:00 2001
From: Julien Meunier <julien.meunier@nokia.com>
Date: Wed, 16 Oct 2019 13:21:11 +0300
Subject: [PATCH] cryptodev: fix checks related to device id

[ upstream commit 3dd4435cf473f5d10b99282098821fb40b72380f ]

Each cryptodev are indexed with dev_id in the global rte_crypto_devices
variable. nb_devs is incremented / decremented each time a cryptodev is
created / deleted. The goal of nb_devs was to prevent the user to get an
invalid dev_id.

Let's imagine DPDK has configured N cryptodevs. If the cryptodev=1 is
removed at runtime, the latest cryptodev N cannot be accessible, because
nb_devs=N-1 with the current implementaion.

In order to prevent this kind of behavior, let's remove the check with
nb_devs and iterate in all the rte_crypto_devices elements: if data is
not NULL, that means a valid cryptodev is available.

Also, remove max_devs field and use RTE_CRYPTO_MAX_DEVS in order to
unify the code.

Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto devices")

Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 lib/librte_cryptodev/rte_cryptodev.c     | 30 +++++++++++++++++-------
 lib/librte_cryptodev/rte_cryptodev_pmd.h |  1 -
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 9c35e6d9c..f7566fc30 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -51,6 +51,5 @@ static struct rte_cryptodev_global cryptodev_globals = {
 		.devs			= rte_crypto_devices,
 		.data			= { NULL },
-		.nb_devs		= 0,
-		.max_devs		= RTE_CRYPTO_MAX_DEVS
+		.nb_devs		= 0
 };
 
@@ -497,5 +496,5 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
 		return NULL;
 
-	for (i = 0; i < cryptodev_globals.max_devs; i++) {
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
 		dev = &cryptodev_globals.devs[i];
 
@@ -508,4 +507,13 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
 }
 
+static inline uint8_t
+rte_cryptodev_is_valid_device_data(uint8_t dev_id)
+{
+	if (rte_crypto_devices[dev_id].data == NULL)
+		return 0;
+
+	return 1;
+}
+
 unsigned int
 rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
@@ -513,5 +521,5 @@ rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
 	struct rte_cryptodev *dev = NULL;
 
-	if (dev_id >= cryptodev_globals.nb_devs)
+	if (!rte_cryptodev_is_valid_device_data(dev_id))
 		return 0;
 
@@ -532,5 +540,7 @@ rte_cryptodev_get_dev_id(const char *name)
 		return -1;
 
-	for (i = 0; i < cryptodev_globals.nb_devs; i++)
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
+		if (!rte_cryptodev_is_valid_device_data(i))
+			continue;
 		if ((strcmp(cryptodev_globals.devs[i].data->name, name)
 				== 0) &&
@@ -538,4 +548,5 @@ rte_cryptodev_get_dev_id(const char *name)
 						RTE_CRYPTODEV_ATTACHED))
 			return i;
+	}
 
 	return -1;
@@ -553,5 +564,5 @@ rte_cryptodev_device_count_by_driver(uint8_t driver_id)
 	uint8_t i, dev_count = 0;
 
-	for (i = 0; i < cryptodev_globals.max_devs; i++)
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++)
 		if (cryptodev_globals.devs[i].driver_id == driver_id &&
 			cryptodev_globals.devs[i].attached ==
@@ -568,7 +579,8 @@ rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
 	uint8_t i, count = 0;
 	struct rte_cryptodev *devs = cryptodev_globals.devs;
-	uint8_t max_devs = cryptodev_globals.max_devs;
 
-	for (i = 0; i < max_devs && count < nb_devices;	i++) {
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS && count < nb_devices; i++) {
+		if (!rte_cryptodev_is_valid_device_data(i))
+			continue;
 
 		if (devs[i].attached == RTE_CRYPTODEV_ATTACHED) {
@@ -1019,5 +1031,5 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
 	struct rte_cryptodev *dev;
 
-	if (dev_id >= cryptodev_globals.nb_devs) {
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
 		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return;
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 1b6cafd17..529791226 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -62,5 +62,4 @@ struct rte_cryptodev_global {
 	/**< Device private data */
 	uint8_t nb_devs;		/**< Number of devices found */
-	uint8_t max_devs;		/**< Max number of devices */
 };
 
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-03 17:29:54.548620095 +0000
+++ 0048-cryptodev-fix-checks-related-to-device-id.patch	2019-12-03 17:29:51.773749474 +0000
@@ -1 +1 @@
-From 3dd4435cf473f5d10b99282098821fb40b72380f Mon Sep 17 00:00:00 2001
+From 8db57afd7ab9a3c12d73f1f5461415690b8c173c Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 3dd4435cf473f5d10b99282098821fb40b72380f ]
+
@@ -23 +24,0 @@
-Cc: stable@dpdk.org
@@ -33 +34 @@
-index b16ef7b2c..89aa2ed3e 100644
+index 9c35e6d9c..f7566fc30 100644
@@ -44 +45 @@
-@@ -513,5 +512,5 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
+@@ -497,5 +496,5 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
@@ -51 +52 @@
-@@ -524,4 +523,13 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
+@@ -508,4 +507,13 @@ rte_cryptodev_pmd_get_named_dev(const char *name)
@@ -65 +66 @@
-@@ -529,5 +537,5 @@ rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
+@@ -513,5 +521,5 @@ rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
@@ -72 +73 @@
-@@ -548,5 +556,7 @@ rte_cryptodev_get_dev_id(const char *name)
+@@ -532,5 +540,7 @@ rte_cryptodev_get_dev_id(const char *name)
@@ -81 +82 @@
-@@ -554,4 +564,5 @@ rte_cryptodev_get_dev_id(const char *name)
+@@ -538,4 +548,5 @@ rte_cryptodev_get_dev_id(const char *name)
@@ -87 +88 @@
-@@ -569,5 +580,5 @@ rte_cryptodev_device_count_by_driver(uint8_t driver_id)
+@@ -553,5 +564,5 @@ rte_cryptodev_device_count_by_driver(uint8_t driver_id)
@@ -94 +95 @@
-@@ -584,7 +595,8 @@ rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
+@@ -568,7 +579,8 @@ rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
@@ -105 +106 @@
-@@ -1102,5 +1114,5 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
+@@ -1019,5 +1031,5 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
@@ -113 +114 @@
-index defe05ea0..fba14f2fa 100644
+index 1b6cafd17..529791226 100644


  parent reply	other threads:[~2019-12-03 18:29 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 18:26 [dpdk-stable] patch 'ethdev: remove redundant device info cleanup before get' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/sfc: fix missing notification on link status change' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vhost: fix slave request fd leak' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bonding: fix link speed update in broadcast mode' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'app/testpmd: fix crash on port reset' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vhost: forbid reallocation when running' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vhost: fix vring address handling during live migration' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vhost: protect vring access done by application' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/vhost: fix redundant queue state event' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vhost: fix vring memory partially mapped' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/virtio: fix Rx stats with vectorized functions' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/virtio: get all pending Rx packets in vectorized paths' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/mlx5: fix BlueField VF type recognition' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: add prefix to global functions' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: fix null access when allocating CLIP entry' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: fix slot allocation for IPv6 flows' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: fix parsing VLAN ID rewrite action' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: fix prefetch for non-coalesced Tx packets' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: avoid polling link status before device start' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/ixgbe: fix X553 speed capability' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/i40e: set speed to undefined for default case' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bonding: fix slave id types' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bonding: fix OOB access in other aggregator modes' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/null: fix multi-process Rx and Tx' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: remove duplicate barrier' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: replace memory barrier for doorbell response' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: enforce IO barrier for doorbell command' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: fix flow steering' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: fix accessing variable before null check' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/szedata2: fix dependency " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/bnxt: fix multicast filter programming' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/qede: limit Rx ring index read for debug' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/atlantic: add FW mailbox guard mutex' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'net/cxgbe: fix races on flow API operations' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'event/sw: fix xstats reset value' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'event/dpaa2: fix default queue configuration' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'build: avoid overlinking' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'vfio: fix leak with multiprocess' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'service: use log for error messages' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'test/mbuf: fix forged mbuf in clone test' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'eal/ppc: fix 64-bit atomic exchange operation' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'devtools: fix cleanup of checkpatch temporary file' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'event/dpaa: fix number of supported atomic flows' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'test/lpm: fix measured cycles for delete' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'eal/linux: restore specific hugepage ordering for ppc' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'eal: remove dead code on NUMA node detection' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'crypto/dpaa_sec: fix auth-cipher check for AEAD' " Kevin Traynor
2019-12-03 18:26 ` Kevin Traynor [this message]
2019-12-03 18:26 ` [dpdk-stable] patch 'doc: fix typo in l2fwd-crypto guide' " Kevin Traynor
2019-12-03 18:26 ` [dpdk-stable] patch 'crypto/qat: fix null auth when using VFIO' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'crypto/qat: fix AES CMAC mininum digest size' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'lib/distributor: fix deadlock on aarch64' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'test/distributor: fix spurious failure' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'bus/pci: remove useless link dependency on ethdev' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/mlx5: validate flow rule item order' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'test/bonding: fix LSC related cases' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'test/bonding: fix LSC timeout unit' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/enic: fix probe for secondary process' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/enic: fix crash in " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/tap: fix blocked Rx packets' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/bnxt: return error if setting link up fails' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/bnxt: remove unnecessary variable assignment' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/qede/base: fix page index for PBL chains' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/bnxt: fix dereference before null check' " Kevin Traynor
2019-12-03 18:27 ` [dpdk-stable] patch 'net/bnxt: cleanup comments' " Kevin Traynor

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=20191203182714.17297-48-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=akhil.goyal@nxp.com \
    --cc=julien.meunier@nokia.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).