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 EE8ACA2E8C for ; Thu, 5 Sep 2019 16:54:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D21551EFEE; Thu, 5 Sep 2019 16:53:36 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id C60941EFA6; Thu, 5 Sep 2019 16:53:27 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2019 07:53:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,470,1559545200"; d="scan'208";a="182846362" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.223.78]) by fmsmga008.fm.intel.com with ESMTP; 05 Sep 2019 07:53:25 -0700 From: Ferruh Yigit To: Gagandeep Singh , Hemant Agrawal , Akhil Goyal Cc: dev@dpdk.org, stable@dpdk.org Date: Thu, 5 Sep 2019 15:53:10 +0100 Message-Id: <20190905145315.19395-6-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905145315.19395-1-ferruh.yigit@intel.com> References: <20190905145315.19395-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 05/10] crypto/dpaa2_sec: fix global variable multiple definitions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 'rta_sec_era' global variable is defined in 'crypto/dpaa2_sec', 'crypto/caam_jr' & 'crypto/dpaa_sec' PMDs with the same name. This means they share same storage when application linked with static DPDK library, which is not the intention. Three differing drivers sharing same global variable is a defect. Variable has been used by multiple header files in static inline functions and these header files are shared by all three PMDs, this forces using same variable name in three PMDs. Since the variable is used only single .c file in 'crypto/dpaa2_sec' & 'crypto/dpaa_sec' converting global variable to 'static', this requires removing 'extern' definition from header files, and this requires moving the global variable definition before including those headers in .c files. For 'crypto/caam_jr' multiple .c files exists and includes these headers which prevent making variable static, so only one file has the global variable and others has 'extern' keyword on .c files. This change should let all three drivers have their own storage for the 'rta_sec_era' global variable without multiple definitions. Fixes: 1d678de329ab ("crypto/caam_jr: add basic job ring routines") Fixes: c3e85bdcc6e6 ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit --- drivers/crypto/caam_jr/caam_jr.c | 5 +++-- drivers/crypto/caam_jr/caam_jr_hw.c | 3 +++ drivers/crypto/caam_jr/caam_jr_uio.c | 3 +++ drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 5 +++-- drivers/crypto/dpaa2_sec/hw/rta.h | 1 - drivers/crypto/dpaa2_sec/hw/rta/fifo_load_store_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/header_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/key_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/load_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/math_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/move_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/operation_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/protocol_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/seq_in_out_ptr_cmd.h | 2 -- drivers/crypto/dpaa2_sec/hw/rta/store_cmd.h | 2 -- drivers/crypto/dpaa_sec/dpaa_sec.c | 5 +++-- 18 files changed, 15 insertions(+), 31 deletions(-) diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index 77c030347..3503f806f 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -17,6 +17,9 @@ #include #include +#include +enum rta_sec_era rta_sec_era; + #include #include #include @@ -34,8 +37,6 @@ static uint8_t cryptodev_driver_id; int caam_jr_logtype; -enum rta_sec_era rta_sec_era; - /* Lists the states possible for the SEC user space driver. */ enum sec_driver_state_e { SEC_DRIVER_STATE_IDLE, /* Driver not initialized */ diff --git a/drivers/crypto/caam_jr/caam_jr_hw.c b/drivers/crypto/caam_jr/caam_jr_hw.c index 4a2b08995..0ea83622f 100644 --- a/drivers/crypto/caam_jr/caam_jr_hw.c +++ b/drivers/crypto/caam_jr/caam_jr_hw.c @@ -11,6 +11,9 @@ #include #include +#include +extern enum rta_sec_era rta_sec_era; + #include #include #include diff --git a/drivers/crypto/caam_jr/caam_jr_uio.c b/drivers/crypto/caam_jr/caam_jr_uio.c index afd75c9a6..acc1bb14c 100644 --- a/drivers/crypto/caam_jr/caam_jr_uio.c +++ b/drivers/crypto/caam_jr/caam_jr_uio.c @@ -18,6 +18,9 @@ #include #include +#include +extern enum rta_sec_era rta_sec_era; + #include #include #include diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 26458e5d1..a1483df7f 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -28,6 +28,9 @@ #include #include +#include +static enum rta_sec_era rta_sec_era = RTA_SEC_ERA_8; + #include "dpaa2_sec_priv.h" #include "dpaa2_sec_event.h" #include "dpaa2_sec_logs.h" @@ -58,8 +61,6 @@ typedef uint64_t dma_addr_t; #define SEC_FLC_DHR_OUTBOUND -114 #define SEC_FLC_DHR_INBOUND 0 -enum rta_sec_era rta_sec_era = RTA_SEC_ERA_8; - static uint8_t cryptodev_driver_id; int dpaa2_logtype_sec; diff --git a/drivers/crypto/dpaa2_sec/hw/rta.h b/drivers/crypto/dpaa2_sec/hw/rta.h index c4bbad0b4..8a9f87fd1 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta.h +++ b/drivers/crypto/dpaa2_sec/hw/rta.h @@ -149,7 +149,6 @@ * - SEC HW block revision format is "v" * - SEC revision format is "x.y" */ -extern enum rta_sec_era rta_sec_era; /** * rta_set_sec_era - Set SEC Era HW block revision for which the RTA library diff --git a/drivers/crypto/dpaa2_sec/hw/rta/fifo_load_store_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/fifo_load_store_cmd.h index 8c807aaa2..0ec21b07b 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/fifo_load_store_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/fifo_load_store_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_FIFO_LOAD_STORE_CMD_H__ #define __RTA_FIFO_LOAD_STORE_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static const uint32_t fifo_load_table[][2] = { /*1*/ { PKA0, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_PK_A0 }, { PKA1, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_PK_A1 }, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/header_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/header_cmd.h index 0c7ea9387..dab69ad5c 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/header_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/header_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_HEADER_CMD_H__ #define __RTA_HEADER_CMD_H__ -extern enum rta_sec_era rta_sec_era; - /* Allowed job header flags for each SEC Era. */ static const uint32_t job_header_flags[] = { DNR | TD | MTD | SHR | REO, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h index 546d22e98..b915e1cd9 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_JUMP_CMD_H__ #define __RTA_JUMP_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static const uint32_t jump_test_cond[][2] = { { NIFP, JUMP_COND_NIFP }, { NIP, JUMP_COND_NIP }, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/key_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/key_cmd.h index 1ec21234a..f6dee13c6 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/key_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/key_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_KEY_CMD_H__ #define __RTA_KEY_CMD_H__ -extern enum rta_sec_era rta_sec_era; - /* Allowed encryption flags for each SEC Era */ static const uint32_t key_enc_flags[] = { ENC, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/load_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/load_cmd.h index f3b0dcfcb..6ed7d5ce5 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/load_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/load_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_LOAD_CMD_H__ #define __RTA_LOAD_CMD_H__ -extern enum rta_sec_era rta_sec_era; - /* Allowed length and offset masks for each SEC Era in case DST = DCTRL */ static const uint32_t load_len_mask_allowed[] = { 0x000000ee, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/math_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/math_cmd.h index 5b28cbabb..6b0ea7cb8 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/math_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/math_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_MATH_CMD_H__ #define __RTA_MATH_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static const uint32_t math_op1[][2] = { /*1*/ { MATH0, MATH_SRC0_REG0 }, { MATH1, MATH_SRC0_REG1 }, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/move_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/move_cmd.h index a7ff7c675..a5d2508ed 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/move_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/move_cmd.h @@ -24,8 +24,6 @@ #define __MOVEB 2 #define __MOVEDW 3 -extern enum rta_sec_era rta_sec_era; - static const uint32_t move_src_table[][2] = { /*1*/ { CONTEXT1, MOVE_SRC_CLASS1CTX }, { CONTEXT2, MOVE_SRC_CLASS2CTX }, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h index 94f775e2e..2f56f8955 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_NFIFO_CMD_H__ #define __RTA_NFIFO_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static const uint32_t nfifo_src[][2] = { /*1*/ { IFIFO, NFIFOENTRY_STYPE_DFIFO }, { OFIFO, NFIFOENTRY_STYPE_OFIFO }, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/operation_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/operation_cmd.h index b85760e5b..7262327e7 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/operation_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/operation_cmd.h @@ -12,8 +12,6 @@ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif -extern enum rta_sec_era rta_sec_era; - static inline int __rta_alg_aai_aes(uint16_t aai) { diff --git a/drivers/crypto/dpaa2_sec/hw/rta/protocol_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/protocol_cmd.h index cf8dfb910..1001e6ca9 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/protocol_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/protocol_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_PROTOCOL_CMD_H__ #define __RTA_PROTOCOL_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static inline int __rta_ssl_proto(uint16_t protoinfo) { diff --git a/drivers/crypto/dpaa2_sec/hw/rta/seq_in_out_ptr_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/seq_in_out_ptr_cmd.h index ceb6a8719..1a22c0702 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/seq_in_out_ptr_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/seq_in_out_ptr_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_SEQ_IN_OUT_PTR_CMD_H__ #define __RTA_SEQ_IN_OUT_PTR_CMD_H__ -extern enum rta_sec_era rta_sec_era; - /* Allowed SEQ IN PTR flags for each SEC Era. */ static const uint32_t seq_in_ptr_flags[] = { RBS | INL | SGF | PRE | EXT | RTO, diff --git a/drivers/crypto/dpaa2_sec/hw/rta/store_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/store_cmd.h index 8b58e544d..da847118c 100644 --- a/drivers/crypto/dpaa2_sec/hw/rta/store_cmd.h +++ b/drivers/crypto/dpaa2_sec/hw/rta/store_cmd.h @@ -8,8 +8,6 @@ #ifndef __RTA_STORE_CMD_H__ #define __RTA_STORE_CMD_H__ -extern enum rta_sec_era rta_sec_era; - static const uint32_t store_src_table[][2] = { /*1*/ { KEY1SZ, LDST_CLASS_1_CCB | LDST_SRCDST_WORD_KEYSZ_REG }, { KEY2SZ, LDST_CLASS_2_CCB | LDST_SRCDST_WORD_KEYSZ_REG }, diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 122c80a07..578e3cd05 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -29,6 +29,9 @@ #include #include +#include +static enum rta_sec_era rta_sec_era; + /* RTA header files */ #include #include @@ -39,8 +42,6 @@ #include #include -enum rta_sec_era rta_sec_era; - int dpaa_logtype_sec; static uint8_t cryptodev_driver_id; -- 2.21.0