[v2,4/4] lib: reduce global variable usage

Message ID 20181005162612.31906-4-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/4] add missing static keyword to globals |

Checks

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

Commit Message

Ferruh Yigit Oct. 5, 2018, 4:26 p.m. UTC
  Some global variables can be eliminated, since they are not part of
public interface, it is free to remove them.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_compressdev/rte_compressdev.c     | 32 ++++++++----------
 lib/librte_compressdev/rte_compressdev_pmd.h |  5 ---
 lib/librte_cryptodev/rte_cryptodev.c         | 34 +++++++++-----------
 lib/librte_cryptodev/rte_cryptodev_pmd.h     |  3 --
 lib/librte_eventdev/rte_eventdev.c           |  8 ++---
 lib/librte_eventdev/rte_eventdev_pmd.h       |  2 --
 lib/librte_rawdev/rte_rawdev.c               | 10 +++---
 lib/librte_rawdev/rte_rawdev_pmd.h           |  2 --
 8 files changed, 37 insertions(+), 59 deletions(-)
  

Comments

Jerin Jacob Oct. 7, 2018, 12:22 p.m. UTC | #1
-----Original Message-----
> Date: Fri, 5 Oct 2018 17:26:11 +0100
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> To: Reshma Pattan <reshma.pattan@intel.com>, Hemant Agrawal
>  <hemant.agrawal@nxp.com>, Shreyansh Jain <shreyansh.jain@nxp.com>, Ashish
>  Gupta <ashish.gupta@cavium.com>, Fiona Trahe <fiona.trahe@intel.com>,
>  Pablo de Lara <pablo.de.lara.guarch@intel.com>, Akhil Goyal
>  <akhil.goyal@nxp.com>, Declan Doherty <declan.doherty@intel.com>, Fan
>  Zhang <roy.fan.zhang@intel.com>, Rahul Lakkireddy
>  <rahul.lakkireddy@chelsio.com>, Gaetan Rivet <gaetan.rivet@6wind.com>, Qi
>  Zhang <qi.z.zhang@intel.com>, Xiao Wang <xiao.w.wang@intel.com>, Beilei
>  Xing <beilei.xing@intel.com>, Wenzhuo Lu <wenzhuo.lu@intel.com>,
>  Konstantin Ananyev <konstantin.ananyev@intel.com>, Rasesh Mody
>  <rasesh.mody@cavium.com>, Harish Patil <harish.patil@cavium.com>, Shahed
>  Shaikh <shahed.shaikh@cavium.com>, Andrew Rybchenko
>  <arybchenko@solarflare.com>, Jasvinder Singh <jasvinder.singh@intel.com>,
>  Cristian Dumitrescu <cristian.dumitrescu@intel.com>, Keith Wiles
>  <keith.wiles@intel.com>, Nipun Gupta <nipun.gupta@nxp.com>, Anatoly
>  Burakov <anatoly.burakov@intel.com>, Thomas Monjalon
>  <thomas@monjalon.net>, Jerin Jacob <jerin.jacob@caviumnetworks.com>,
>  Olivier Matz <olivier.matz@6wind.com>, Ashish Gupta
>  <ashish.gupta@caviumnetworks.com>
> CC: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>
> Subject: [PATCH v2 4/4] lib: reduce global variable usage
> X-Mailer: git-send-email 2.17.1
> 
> 
> Some global variables can be eliminated, since they are not part of
> public interface, it is free to remove them.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
  
Shreyansh Jain Oct. 8, 2018, 8:45 a.m. UTC | #2
On Friday 05 October 2018 09:56 PM, Ferruh Yigit wrote:
> Some global variables can be eliminated, since they are not part of
> public interface, it is free to remove them.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>   lib/librte_compressdev/rte_compressdev.c     | 32 ++++++++----------
>   lib/librte_compressdev/rte_compressdev_pmd.h |  5 ---
>   lib/librte_cryptodev/rte_cryptodev.c         | 34 +++++++++-----------
>   lib/librte_cryptodev/rte_cryptodev_pmd.h     |  3 --
>   lib/librte_eventdev/rte_eventdev.c           |  8 ++---
>   lib/librte_eventdev/rte_eventdev_pmd.h       |  2 --
>   lib/librte_rawdev/rte_rawdev.c               | 10 +++---
>   lib/librte_rawdev/rte_rawdev_pmd.h           |  2 --
>   8 files changed, 37 insertions(+), 59 deletions(-)

[...]

> diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
> index 62b6b97ef..9f1e3592d 100644
> --- a/lib/librte_rawdev/rte_rawdev.c
> +++ b/lib/librte_rawdev/rte_rawdev.c
> @@ -35,21 +35,19 @@
>   /* dynamic log identifier */
>   int librawdev_logtype;
>   
> -struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
> +static struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
>   
> -struct rte_rawdev *rte_rawdevs = &rte_rawdevices[0];
> +struct rte_rawdev *rte_rawdevs = rte_rawdevices;
>   
>   static struct rte_rawdev_global rawdev_globals = {
>   	.nb_devs		= 0
>   };
>   
> -struct rte_rawdev_global *rte_rawdev_globals = &rawdev_globals;
> -
>   /* Raw device, northbound API implementation */
>   uint8_t
>   rte_rawdev_count(void)
>   {
> -	return rte_rawdev_globals->nb_devs;
> +	return rawdev_globals.nb_devs;
>   }
>   
>   uint16_t
> @@ -60,7 +58,7 @@ rte_rawdev_get_dev_id(const char *name)
>   	if (!name)
>   		return -EINVAL;
>   
> -	for (i = 0; i < rte_rawdev_globals->nb_devs; i++)
> +	for (i = 0; i < rawdev_globals.nb_devs; i++)
>   		if ((strcmp(rte_rawdevices[i].name, name)
>   				== 0) &&
>   				(rte_rawdevices[i].attached ==
> diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h
> index bb9bbc350..811e51d07 100644
> --- a/lib/librte_rawdev/rte_rawdev_pmd.h
> +++ b/lib/librte_rawdev/rte_rawdev_pmd.h
> @@ -73,8 +73,6 @@ struct rte_rawdev_global {
>   	uint16_t nb_devs;
>   };
>   
> -extern struct rte_rawdev_global *rte_rawdev_globals;
> -/** Pointer to global raw devices data structure. */
>   extern struct rte_rawdev *rte_rawdevs;
>   /** The pool of rte_rawdev structures. */

I think `rte_rawdevs` can also be removed from an exposed symbol. In all 
cases (at least for now), this is being accessed using an API (and no 
macros). There should be no need for people to read this directly if 
sufficient get_by_* APIs are available.

Wouldn't same be valid for rte_compressdevs as well?

Besides the above:

Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
  
Ferruh Yigit Oct. 8, 2018, 9:11 a.m. UTC | #3
On 10/8/2018 9:45 AM, Shreyansh Jain wrote:
> On Friday 05 October 2018 09:56 PM, Ferruh Yigit wrote:
>> Some global variables can be eliminated, since they are not part of
>> public interface, it is free to remove them.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>>   lib/librte_compressdev/rte_compressdev.c     | 32 ++++++++----------
>>   lib/librte_compressdev/rte_compressdev_pmd.h |  5 ---
>>   lib/librte_cryptodev/rte_cryptodev.c         | 34 +++++++++-----------
>>   lib/librte_cryptodev/rte_cryptodev_pmd.h     |  3 --
>>   lib/librte_eventdev/rte_eventdev.c           |  8 ++---
>>   lib/librte_eventdev/rte_eventdev_pmd.h       |  2 --
>>   lib/librte_rawdev/rte_rawdev.c               | 10 +++---
>>   lib/librte_rawdev/rte_rawdev_pmd.h           |  2 --
>>   8 files changed, 37 insertions(+), 59 deletions(-)
> 
> [...]
> 
>> diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
>> index 62b6b97ef..9f1e3592d 100644
>> --- a/lib/librte_rawdev/rte_rawdev.c
>> +++ b/lib/librte_rawdev/rte_rawdev.c
>> @@ -35,21 +35,19 @@
>>   /* dynamic log identifier */
>>   int librawdev_logtype;
>>   
>> -struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
>> +static struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
>>   
>> -struct rte_rawdev *rte_rawdevs = &rte_rawdevices[0];
>> +struct rte_rawdev *rte_rawdevs = rte_rawdevices;
>>   
>>   static struct rte_rawdev_global rawdev_globals = {
>>   	.nb_devs		= 0
>>   };
>>   
>> -struct rte_rawdev_global *rte_rawdev_globals = &rawdev_globals;
>> -
>>   /* Raw device, northbound API implementation */
>>   uint8_t
>>   rte_rawdev_count(void)
>>   {
>> -	return rte_rawdev_globals->nb_devs;
>> +	return rawdev_globals.nb_devs;
>>   }
>>   
>>   uint16_t
>> @@ -60,7 +58,7 @@ rte_rawdev_get_dev_id(const char *name)
>>   	if (!name)
>>   		return -EINVAL;
>>   
>> -	for (i = 0; i < rte_rawdev_globals->nb_devs; i++)
>> +	for (i = 0; i < rawdev_globals.nb_devs; i++)
>>   		if ((strcmp(rte_rawdevices[i].name, name)
>>   				== 0) &&
>>   				(rte_rawdevices[i].attached ==
>> diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h
>> index bb9bbc350..811e51d07 100644
>> --- a/lib/librte_rawdev/rte_rawdev_pmd.h
>> +++ b/lib/librte_rawdev/rte_rawdev_pmd.h
>> @@ -73,8 +73,6 @@ struct rte_rawdev_global {
>>   	uint16_t nb_devs;
>>   };
>>   
>> -extern struct rte_rawdev_global *rte_rawdev_globals;
>> -/** Pointer to global raw devices data structure. */
>>   extern struct rte_rawdev *rte_rawdevs;
>>   /** The pool of rte_rawdev structures. */
> 
> I think `rte_rawdevs` can also be removed from an exposed symbol. In all 
> cases (at least for now), this is being accessed using an API (and no 
> macros). There should be no need for people to read this directly if 
> sufficient get_by_* APIs are available.

+1 to make it library internal.

But `rte_rawdevs` is both in public header and .map file, so it is part of
public API, we can't remove it without deprecation process.
And I want to leave the decision of removing an public symbol to library
maintainers.

> 
> Wouldn't same be valid for rte_compressdevs as well?

`rte_compressdevs` is already removed, but if you mean `rte_cryptodevs` it has
same problem with `rte_rawdevs`, it is part of API.

> Besides the above:
> 
> Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
>
  
Shreyansh Jain Oct. 8, 2018, 9:27 a.m. UTC | #4
On Monday 08 October 2018 02:41 PM, Ferruh Yigit wrote:
> On 10/8/2018 9:45 AM, Shreyansh Jain wrote:
>> On Friday 05 October 2018 09:56 PM, Ferruh Yigit wrote:
>>> Some global variables can be eliminated, since they are not part of
>>> public interface, it is free to remove them.
>>>
>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>> ---
>>>    lib/librte_compressdev/rte_compressdev.c     | 32 ++++++++----------
>>>    lib/librte_compressdev/rte_compressdev_pmd.h |  5 ---
>>>    lib/librte_cryptodev/rte_cryptodev.c         | 34 +++++++++-----------
>>>    lib/librte_cryptodev/rte_cryptodev_pmd.h     |  3 --
>>>    lib/librte_eventdev/rte_eventdev.c           |  8 ++---
>>>    lib/librte_eventdev/rte_eventdev_pmd.h       |  2 --
>>>    lib/librte_rawdev/rte_rawdev.c               | 10 +++---
>>>    lib/librte_rawdev/rte_rawdev_pmd.h           |  2 --
>>>    8 files changed, 37 insertions(+), 59 deletions(-)
>>
>> [...]
>>
>>> diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
>>> index 62b6b97ef..9f1e3592d 100644
>>> --- a/lib/librte_rawdev/rte_rawdev.c
>>> +++ b/lib/librte_rawdev/rte_rawdev.c
>>> @@ -35,21 +35,19 @@
>>>    /* dynamic log identifier */
>>>    int librawdev_logtype;
>>>    
>>> -struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
>>> +static struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
>>>    
>>> -struct rte_rawdev *rte_rawdevs = &rte_rawdevices[0];
>>> +struct rte_rawdev *rte_rawdevs = rte_rawdevices;
>>>    
>>>    static struct rte_rawdev_global rawdev_globals = {
>>>    	.nb_devs		= 0
>>>    };
>>>    
>>> -struct rte_rawdev_global *rte_rawdev_globals = &rawdev_globals;
>>> -
>>>    /* Raw device, northbound API implementation */
>>>    uint8_t
>>>    rte_rawdev_count(void)
>>>    {
>>> -	return rte_rawdev_globals->nb_devs;
>>> +	return rawdev_globals.nb_devs;
>>>    }
>>>    
>>>    uint16_t
>>> @@ -60,7 +58,7 @@ rte_rawdev_get_dev_id(const char *name)
>>>    	if (!name)
>>>    		return -EINVAL;
>>>    
>>> -	for (i = 0; i < rte_rawdev_globals->nb_devs; i++)
>>> +	for (i = 0; i < rawdev_globals.nb_devs; i++)
>>>    		if ((strcmp(rte_rawdevices[i].name, name)
>>>    				== 0) &&
>>>    				(rte_rawdevices[i].attached ==
>>> diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h
>>> index bb9bbc350..811e51d07 100644
>>> --- a/lib/librte_rawdev/rte_rawdev_pmd.h
>>> +++ b/lib/librte_rawdev/rte_rawdev_pmd.h
>>> @@ -73,8 +73,6 @@ struct rte_rawdev_global {
>>>    	uint16_t nb_devs;
>>>    };
>>>    
>>> -extern struct rte_rawdev_global *rte_rawdev_globals;
>>> -/** Pointer to global raw devices data structure. */
>>>    extern struct rte_rawdev *rte_rawdevs;
>>>    /** The pool of rte_rawdev structures. */
>>
>> I think `rte_rawdevs` can also be removed from an exposed symbol. In all
>> cases (at least for now), this is being accessed using an API (and no
>> macros). There should be no need for people to read this directly if
>> sufficient get_by_* APIs are available.
> 
> +1 to make it library internal.
> 
> But `rte_rawdevs` is both in public header and .map file, so it is part of
> public API, we can't remove it without deprecation process.
> And I want to leave the decision of removing an public symbol to library
> maintainers.

Yes, I missed that part :)
I will fix it in next release by sending deprecation in this.

> 
>>
>> Wouldn't same be valid for rte_compressdevs as well?
> 
> `rte_compressdevs` is already removed, but if you mean `rte_cryptodevs` it has
> same problem with `rte_rawdevs`, it is part of API.

Ah yes, my mistake.
I was thinking about rte_eventdevs and rte_cryptodevs (but, this symbol 
is being used by a crypto/scheduler)

> 
>> Besides the above:
>>
>> Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
>>
>
  

Patch

diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index 9091dd6ee..10101ebbe 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -18,19 +18,15 @@ 
 #define RTE_COMPRESSDEV_DETACHED  (0)
 #define RTE_COMPRESSDEV_ATTACHED  (1)
 
-struct rte_compressdev rte_comp_devices[RTE_COMPRESS_MAX_DEVS];
-
-struct rte_compressdev *rte_compressdevs = &rte_comp_devices[0];
+static struct rte_compressdev rte_comp_devices[RTE_COMPRESS_MAX_DEVS];
 
 static struct rte_compressdev_global compressdev_globals = {
-		.devs			= &rte_comp_devices[0],
+		.devs			= rte_comp_devices,
 		.data			= { NULL },
 		.nb_devs		= 0,
 		.max_devs		= RTE_COMPRESS_MAX_DEVS
 };
 
-struct rte_compressdev_global *rte_compressdev_globals = &compressdev_globals;
-
 const struct rte_compressdev_capabilities * __rte_experimental
 rte_compressdev_capability_get(uint8_t dev_id,
 			enum rte_comp_algorithm algo)
@@ -78,7 +74,7 @@  rte_compressdev_get_feature_name(uint64_t flag)
 static struct rte_compressdev *
 rte_compressdev_get_dev(uint8_t dev_id)
 {
-	return &rte_compressdev_globals->devs[dev_id];
+	return &compressdev_globals.devs[dev_id];
 }
 
 struct rte_compressdev * __rte_experimental
@@ -90,8 +86,8 @@  rte_compressdev_pmd_get_named_dev(const char *name)
 	if (name == NULL)
 		return NULL;
 
-	for (i = 0; i < rte_compressdev_globals->max_devs; i++) {
-		dev = &rte_compressdev_globals->devs[i];
+	for (i = 0; i < compressdev_globals.max_devs; i++) {
+		dev = &compressdev_globals.devs[i];
 
 		if ((dev->attached == RTE_COMPRESSDEV_ATTACHED) &&
 				(strcmp(dev->data->name, name) == 0))
@@ -106,7 +102,7 @@  rte_compressdev_is_valid_dev(uint8_t dev_id)
 {
 	struct rte_compressdev *dev = NULL;
 
-	if (dev_id >= rte_compressdev_globals->nb_devs)
+	if (dev_id >= compressdev_globals.nb_devs)
 		return 0;
 
 	dev = rte_compressdev_get_dev(dev_id);
@@ -125,10 +121,10 @@  rte_compressdev_get_dev_id(const char *name)
 	if (name == NULL)
 		return -1;
 
-	for (i = 0; i < rte_compressdev_globals->nb_devs; i++)
-		if ((strcmp(rte_compressdev_globals->devs[i].data->name, name)
+	for (i = 0; i < compressdev_globals.nb_devs; i++)
+		if ((strcmp(compressdev_globals.devs[i].data->name, name)
 				== 0) &&
-				(rte_compressdev_globals->devs[i].attached ==
+				(compressdev_globals.devs[i].attached ==
 						RTE_COMPRESSDEV_ATTACHED))
 			return i;
 
@@ -138,7 +134,7 @@  rte_compressdev_get_dev_id(const char *name)
 uint8_t __rte_experimental
 rte_compressdev_count(void)
 {
-	return rte_compressdev_globals->nb_devs;
+	return compressdev_globals.nb_devs;
 }
 
 uint8_t __rte_experimental
@@ -146,8 +142,8 @@  rte_compressdev_devices_get(const char *driver_name, uint8_t *devices,
 	uint8_t nb_devices)
 {
 	uint8_t i, count = 0;
-	struct rte_compressdev *devs = rte_compressdev_globals->devs;
-	uint8_t max_devs = rte_compressdev_globals->max_devs;
+	struct rte_compressdev *devs = compressdev_globals.devs;
+	uint8_t max_devs = compressdev_globals.max_devs;
 
 	for (i = 0; i < max_devs && count < nb_devices;	i++) {
 
@@ -578,7 +574,7 @@  uint16_t __rte_experimental
 rte_compressdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
 		struct rte_comp_op **ops, uint16_t nb_ops)
 {
-	struct rte_compressdev *dev = &rte_compressdevs[dev_id];
+	struct rte_compressdev *dev = &rte_comp_devices[dev_id];
 
 	nb_ops = (*dev->dequeue_burst)
 			(dev->data->queue_pairs[qp_id], ops, nb_ops);
@@ -590,7 +586,7 @@  uint16_t __rte_experimental
 rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 		struct rte_comp_op **ops, uint16_t nb_ops)
 {
-	struct rte_compressdev *dev = &rte_compressdevs[dev_id];
+	struct rte_compressdev *dev = &rte_comp_devices[dev_id];
 
 	return (*dev->enqueue_burst)(
 			dev->data->queue_pairs[qp_id], ops, nb_ops);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.h b/lib/librte_compressdev/rte_compressdev_pmd.h
index 38e9ea02b..043353c99 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.h
+++ b/lib/librte_compressdev/rte_compressdev_pmd.h
@@ -51,11 +51,6 @@  struct rte_compressdev_global {
 	uint8_t max_devs;		/**< Max number of devices */
 };
 
-/** Pointer to global array of comp devices */
-extern struct rte_compressdev *rte_compressdevs;
-/** Pointer to global comp devices data structure */
-extern struct rte_compressdev_global *rte_compressdev_globals;
-
 /**
  * Get the rte_compressdev structure device pointer for the named device.
  *
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 63ae23f00..6c3c2a9cd 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -43,19 +43,17 @@ 
 
 static uint8_t nb_drivers;
 
-struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS];
+static struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS];
 
-struct rte_cryptodev *rte_cryptodevs = &rte_crypto_devices[0];
+struct rte_cryptodev *rte_cryptodevs = rte_crypto_devices;
 
 static struct rte_cryptodev_global cryptodev_globals = {
-		.devs			= &rte_crypto_devices[0],
+		.devs			= rte_crypto_devices,
 		.data			= { NULL },
 		.nb_devs		= 0,
 		.max_devs		= RTE_CRYPTO_MAX_DEVS
 };
 
-struct rte_cryptodev_global *rte_cryptodev_globals = &cryptodev_globals;
-
 /* spinlock for crypto device callbacks */
 static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
@@ -486,7 +484,7 @@  rte_cryptodev_get_feature_name(uint64_t flag)
 struct rte_cryptodev *
 rte_cryptodev_pmd_get_dev(uint8_t dev_id)
 {
-	return &rte_cryptodev_globals->devs[dev_id];
+	return &cryptodev_globals.devs[dev_id];
 }
 
 struct rte_cryptodev *
@@ -498,8 +496,8 @@  rte_cryptodev_pmd_get_named_dev(const char *name)
 	if (name == NULL)
 		return NULL;
 
-	for (i = 0; i < rte_cryptodev_globals->max_devs; i++) {
-		dev = &rte_cryptodev_globals->devs[i];
+	for (i = 0; i < cryptodev_globals.max_devs; i++) {
+		dev = &cryptodev_globals.devs[i];
 
 		if ((dev->attached == RTE_CRYPTODEV_ATTACHED) &&
 				(strcmp(dev->data->name, name) == 0))
@@ -514,7 +512,7 @@  rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
 {
 	struct rte_cryptodev *dev = NULL;
 
-	if (dev_id >= rte_cryptodev_globals->nb_devs)
+	if (dev_id >= cryptodev_globals.nb_devs)
 		return 0;
 
 	dev = rte_cryptodev_pmd_get_dev(dev_id);
@@ -533,10 +531,10 @@  rte_cryptodev_get_dev_id(const char *name)
 	if (name == NULL)
 		return -1;
 
-	for (i = 0; i < rte_cryptodev_globals->nb_devs; i++)
-		if ((strcmp(rte_cryptodev_globals->devs[i].data->name, name)
+	for (i = 0; i < cryptodev_globals.nb_devs; i++)
+		if ((strcmp(cryptodev_globals.devs[i].data->name, name)
 				== 0) &&
-				(rte_cryptodev_globals->devs[i].attached ==
+				(cryptodev_globals.devs[i].attached ==
 						RTE_CRYPTODEV_ATTACHED))
 			return i;
 
@@ -546,7 +544,7 @@  rte_cryptodev_get_dev_id(const char *name)
 uint8_t
 rte_cryptodev_count(void)
 {
-	return rte_cryptodev_globals->nb_devs;
+	return cryptodev_globals.nb_devs;
 }
 
 uint8_t
@@ -554,9 +552,9 @@  rte_cryptodev_device_count_by_driver(uint8_t driver_id)
 {
 	uint8_t i, dev_count = 0;
 
-	for (i = 0; i < rte_cryptodev_globals->max_devs; i++)
-		if (rte_cryptodev_globals->devs[i].driver_id == driver_id &&
-			rte_cryptodev_globals->devs[i].attached ==
+	for (i = 0; i < cryptodev_globals.max_devs; i++)
+		if (cryptodev_globals.devs[i].driver_id == driver_id &&
+			cryptodev_globals.devs[i].attached ==
 					RTE_CRYPTODEV_ATTACHED)
 			dev_count++;
 
@@ -568,8 +566,8 @@  rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
 	uint8_t nb_devices)
 {
 	uint8_t i, count = 0;
-	struct rte_cryptodev *devs = rte_cryptodev_globals->devs;
-	uint8_t max_devs = rte_cryptodev_globals->max_devs;
+	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++) {
 
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 6ff49d64d..1b6cafd17 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -71,9 +71,6 @@  struct cryptodev_driver {
 	uint8_t id;
 };
 
-/** pointer to global crypto devices data structure. */
-extern struct rte_cryptodev_global *rte_cryptodev_globals;
-
 /**
  * Get the rte_cryptodev structure device pointer for the device. Assumes a
  * valid device index.
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index e70315e49..ebaf3087d 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -37,20 +37,18 @@ 
 
 static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
 
-struct rte_eventdev *rte_eventdevs = &rte_event_devices[0];
+struct rte_eventdev *rte_eventdevs = rte_event_devices;
 
 static struct rte_eventdev_global eventdev_globals = {
 	.nb_devs		= 0
 };
 
-struct rte_eventdev_global *rte_eventdev_globals = &eventdev_globals;
-
 /* Event dev north bound API implementation */
 
 uint8_t
 rte_event_dev_count(void)
 {
-	return rte_eventdev_globals->nb_devs;
+	return eventdev_globals.nb_devs;
 }
 
 int
@@ -62,7 +60,7 @@  rte_event_dev_get_dev_id(const char *name)
 	if (!name)
 		return -EINVAL;
 
-	for (i = 0; i < rte_eventdev_globals->nb_devs; i++) {
+	for (i = 0; i < eventdev_globals.nb_devs; i++) {
 		cmp = (strncmp(rte_event_devices[i].data->name, name,
 				RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
 			(rte_event_devices[i].dev ? (strncmp(
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index aa6e52c63..1a01326b8 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -87,8 +87,6 @@  struct rte_eventdev_global {
 	uint8_t nb_devs;	/**< Number of devices found */
 };
 
-extern struct rte_eventdev_global *rte_eventdev_globals;
-/** Pointer to global event devices data structure. */
 extern struct rte_eventdev *rte_eventdevs;
 /** The pool of rte_eventdev structures. */
 
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index 62b6b97ef..9f1e3592d 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -35,21 +35,19 @@ 
 /* dynamic log identifier */
 int librawdev_logtype;
 
-struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
+static struct rte_rawdev rte_rawdevices[RTE_RAWDEV_MAX_DEVS];
 
-struct rte_rawdev *rte_rawdevs = &rte_rawdevices[0];
+struct rte_rawdev *rte_rawdevs = rte_rawdevices;
 
 static struct rte_rawdev_global rawdev_globals = {
 	.nb_devs		= 0
 };
 
-struct rte_rawdev_global *rte_rawdev_globals = &rawdev_globals;
-
 /* Raw device, northbound API implementation */
 uint8_t
 rte_rawdev_count(void)
 {
-	return rte_rawdev_globals->nb_devs;
+	return rawdev_globals.nb_devs;
 }
 
 uint16_t
@@ -60,7 +58,7 @@  rte_rawdev_get_dev_id(const char *name)
 	if (!name)
 		return -EINVAL;
 
-	for (i = 0; i < rte_rawdev_globals->nb_devs; i++)
+	for (i = 0; i < rawdev_globals.nb_devs; i++)
 		if ((strcmp(rte_rawdevices[i].name, name)
 				== 0) &&
 				(rte_rawdevices[i].attached ==
diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h
index bb9bbc350..811e51d07 100644
--- a/lib/librte_rawdev/rte_rawdev_pmd.h
+++ b/lib/librte_rawdev/rte_rawdev_pmd.h
@@ -73,8 +73,6 @@  struct rte_rawdev_global {
 	uint16_t nb_devs;
 };
 
-extern struct rte_rawdev_global *rte_rawdev_globals;
-/** Pointer to global raw devices data structure. */
 extern struct rte_rawdev *rte_rawdevs;
 /** The pool of rte_rawdev structures. */