DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] crypto/octeontx: fix global variable multiple definitions
@ 2019-10-04  9:44 Anoob Joseph
  2019-10-09  9:49 ` Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Anoob Joseph @ 2019-10-04  9:44 UTC (permalink / raw)
  To: Akhil Goyal, Pablo de Lara
  Cc: Anoob Joseph, Jerin Jacob, Narayana Prasad, Ankur Dwivedi, dev, stable

'cpt_logtype' & 'otx_cryptodev_driver_id' global variables are defined
in a header file which was causing multiple definitions of the
variables. Fixed it by moving the required vars to the .c file and
introducing a new macro so the CPT_LOG macros in common/cpt would use
the associated PMD log var.

Issue has been detected by '-fno-common' gcc flag.

Fixes: bfe2ae495ee2 ("crypto/octeontx: add PMD skeleton")
Cc: stable@dpdk.org

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/common/cpt/cpt_pmd_logs.h                 | 12 +++++-------
 drivers/crypto/octeontx/otx_cryptodev.c           | 23 +++++++----------------
 drivers/crypto/octeontx/otx_cryptodev.h           |  6 +++++-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.h |  2 ++
 drivers/crypto/octeontx/otx_cryptodev_ops.c       |  6 +++---
 5 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/common/cpt/cpt_pmd_logs.h b/drivers/common/cpt/cpt_pmd_logs.h
index 4cbec4e..174326c 100644
--- a/drivers/common/cpt/cpt_pmd_logs.h
+++ b/drivers/common/cpt/cpt_pmd_logs.h
@@ -11,8 +11,12 @@
  * This file defines log macros
  */
 
+/*
+ * otx*_cryptodev.h file would define the CPT_LOGTYPE macro for the
+ * platform.
+ */
 #define CPT_PMD_DRV_LOG_RAW(level, fmt, args...) \
-		rte_log(RTE_LOG_ ## level, cpt_logtype, \
+		rte_log(RTE_LOG_ ## level, CPT_LOGTYPE, \
 			"cpt: %s(): " fmt "\n", __func__, ##args)
 
 #define CPT_PMD_INIT_FUNC_TRACE() CPT_PMD_DRV_LOG_RAW(DEBUG, " >>")
@@ -41,10 +45,4 @@
 #define CPT_LOG_DP_ERR(fmt, args...) \
 	CPT_LOG_DP(ERR, fmt, ## args)
 
-/*
- * cpt_logtype will be used for common logging. This field would be initialized
- * by otx_* driver routines during PCI probe.
- */
-int cpt_logtype;
-
 #endif /* _CPT_PMD_LOGS_H_ */
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index 8df4b71..ddece13 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -9,13 +9,13 @@
 #include <rte_log.h>
 #include <rte_pci.h>
 
-/* CPT common headers */
-#include "cpt_pmd_logs.h"
-
 #include "otx_cryptodev.h"
 #include "otx_cryptodev_ops.h"
 
-static int otx_cryptodev_logtype;
+#include "cpt_pmd_logs.h"
+
+uint8_t otx_cryptodev_driver_id;
+int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -27,12 +27,6 @@ static struct rte_pci_id pci_id_cpt_table[] = {
 	},
 };
 
-static void
-otx_cpt_logtype_init(void)
-{
-	cpt_logtype = otx_cryptodev_logtype;
-}
-
 static int
 otx_cpt_pci_probe(struct rte_pci_driver *pci_drv,
 			struct rte_pci_device *pci_dev)
@@ -57,9 +51,6 @@ otx_cpt_pci_probe(struct rte_pci_driver *pci_drv,
 	/* init user callbacks */
 	TAILQ_INIT(&(cryptodev->link_intr_cbs));
 
-	/* init logtype used in common */
-	otx_cpt_logtype_init();
-
 	/* Invoke PMD device initialization function */
 	retval = otx_cpt_dev_create(cryptodev);
 	if (retval == 0)
@@ -125,7 +116,7 @@ RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 RTE_INIT(otx_cpt_init_log)
 {
 	/* Bus level logs */
-	otx_cryptodev_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cryptodev_logtype >= 0)
-		rte_log_set_level(otx_cryptodev_logtype, RTE_LOG_NOTICE);
+	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
+	if (otx_cpt_logtype >= 0)
+		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
 }
diff --git a/drivers/crypto/octeontx/otx_cryptodev.h b/drivers/crypto/octeontx/otx_cryptodev.h
index 6c2871d..b66ef4a 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.h
+++ b/drivers/crypto/octeontx/otx_cryptodev.h
@@ -12,9 +12,13 @@
 #define PCI_VENDOR_ID_CAVIUM		0x177d
 #define CPT_81XX_PCI_VF_DEVICE_ID	0xa041
 
+#define CPT_LOGTYPE otx_cpt_logtype
+
+extern int otx_cpt_logtype;
+
 /*
  * Crypto device driver ID
  */
-uint8_t otx_cryptodev_driver_id;
+extern uint8_t otx_cryptodev_driver_id;
 
 #endif /* _OTX_CRYPTODEV_H_ */
diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h
index 63c199e..063c636 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h
+++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h
@@ -13,6 +13,8 @@
 #include <rte_memory.h>
 #include <rte_prefetch.h>
 
+#include "otx_cryptodev.h"
+
 #include "cpt_common.h"
 #include "cpt_hw_types.h"
 #include "cpt_mcode_defines.h"
diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 9628ffa..118168a 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -10,14 +10,14 @@
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 
-#include "cpt_pmd_logs.h"
-#include "cpt_ucode.h"
-
 #include "otx_cryptodev.h"
 #include "otx_cryptodev_capabilities.h"
 #include "otx_cryptodev_hw_access.h"
 #include "otx_cryptodev_ops.h"
 
+#include "cpt_pmd_logs.h"
+#include "cpt_ucode.h"
+
 /* Forward declarations */
 
 static int
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] crypto/octeontx: fix global variable multiple definitions
  2019-10-04  9:44 [dpdk-dev] [PATCH] crypto/octeontx: fix global variable multiple definitions Anoob Joseph
@ 2019-10-09  9:49 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2019-10-09  9:49 UTC (permalink / raw)
  To: Anoob Joseph, Pablo de Lara
  Cc: Jerin Jacob, Narayana Prasad, Ankur Dwivedi, dev, stable


> 
> 'cpt_logtype' & 'otx_cryptodev_driver_id' global variables are defined
> in a header file which was causing multiple definitions of the
> variables. Fixed it by moving the required vars to the .c file and
> introducing a new macro so the CPT_LOG macros in common/cpt would use
> the associated PMD log var.
> 
> Issue has been detected by '-fno-common' gcc flag.
> 
> Fixes: bfe2ae495ee2 ("crypto/octeontx: add PMD skeleton")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anoob Joseph <anoobj@marvell.com>
> Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
Applied to dpdk-next-crypto

Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04  9:44 [dpdk-dev] [PATCH] crypto/octeontx: fix global variable multiple definitions Anoob Joseph
2019-10-09  9:49 ` Akhil Goyal

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox