[RFC,v3,08/26] dev: move unrelated macros from header

Message ID 20220728152640.547725-9-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Bus and device cleanup for 22.11 |

Commit Message

David Marchand July 28, 2022, 3:26 p.m. UTC
  RTE_FUNC_PTR_OR_* macros have nothing to do with the rte_device object
and associated API.
Move them to rte_common.h and include it where needed.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/qat/qat_device.c                    |  1 +
 drivers/compress/qat/qat_comp_pmd.c                |  1 +
 drivers/crypto/scheduler/rte_cryptodev_scheduler.c |  1 +
 drivers/net/ixgbe/rte_pmd_ixgbe.c                  |  1 +
 drivers/net/liquidio/lio_ethdev.c                  |  1 +
 lib/compressdev/rte_compressdev.c                  |  1 +
 lib/dmadev/rte_dmadev.c                            |  1 +
 lib/eal/include/rte_common.h                       | 11 +++++++++++
 lib/eal/include/rte_dev.h                          | 11 -----------
 lib/ethdev/ethdev_driver.c                         |  1 +
 lib/ethdev/ethdev_pci.h                            |  1 +
 lib/mempool/rte_mempool_ops.c                      |  1 +
 lib/regexdev/rte_regexdev.c                        |  1 +
 lib/security/rte_security.c                        |  1 +
 lib/vhost/vdpa.c                                   |  1 +
 15 files changed, 24 insertions(+), 11 deletions(-)
  

Comments

Bruce Richardson July 28, 2022, 4:38 p.m. UTC | #1
On Thu, Jul 28, 2022 at 05:26:22PM +0200, David Marchand wrote:
> RTE_FUNC_PTR_OR_* macros have nothing to do with the rte_device object
> and associated API.
> Move them to rte_common.h and include it where needed.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Personally, I really don't like these macros at all. I think having the
check explicitly in the code would be far more readable, and would only be
one line of code longer than the macro call. Is there some private header
file we could move these to instead of rte_common.h so we can drop their
use in future if we decide to?
  
David Marchand July 28, 2022, 7:32 p.m. UTC | #2
On Thu, Jul 28, 2022 at 6:38 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Thu, Jul 28, 2022 at 05:26:22PM +0200, David Marchand wrote:
> > RTE_FUNC_PTR_OR_* macros have nothing to do with the rte_device object
> > and associated API.
> > Move them to rte_common.h and include it where needed.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
>
> Personally, I really don't like these macros at all. I think having the
> check explicitly in the code would be far more readable, and would only be
> one line of code longer than the macro call. Is there some private header
> file we could move these to instead of rte_common.h so we can drop their
> use in future if we decide to?

I don't like them either.
Not sure where to put them though...

My "grep-all" shows no user in the projects consuming DPDK I track.
We could mark those macros deprecated, fix our code and drop them later.
  
Bruce Richardson July 29, 2022, 9:58 a.m. UTC | #3
On Thu, Jul 28, 2022 at 09:32:38PM +0200, David Marchand wrote:
> On Thu, Jul 28, 2022 at 6:38 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > On Thu, Jul 28, 2022 at 05:26:22PM +0200, David Marchand wrote:
> > > RTE_FUNC_PTR_OR_* macros have nothing to do with the rte_device object
> > > and associated API.
> > > Move them to rte_common.h and include it where needed.
> > >
> > > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > > ---
> >
> > Personally, I really don't like these macros at all. I think having the
> > check explicitly in the code would be far more readable, and would only be
> > one line of code longer than the macro call. Is there some private header
> > file we could move these to instead of rte_common.h so we can drop their
> > use in future if we decide to?
> 
> I don't like them either.
> Not sure where to put them though...
> 
> My "grep-all" shows no user in the projects consuming DPDK I track.
> We could mark those macros deprecated, fix our code and drop them later.
> 
+1 to that.
Can they be marked as deprecated as part of the move perhaps (assuming we
get agreement to kill them?)
  
David Marchand July 29, 2022, 1:22 p.m. UTC | #4
On Fri, Jul 29, 2022 at 11:59 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
> > > Personally, I really don't like these macros at all. I think having the
> > > check explicitly in the code would be far more readable, and would only be
> > > one line of code longer than the macro call. Is there some private header
> > > file we could move these to instead of rte_common.h so we can drop their
> > > use in future if we decide to?
> >
> > I don't like them either.
> > Not sure where to put them though...
> >
> > My "grep-all" shows no user in the projects consuming DPDK I track.
> > We could mark those macros deprecated, fix our code and drop them later.
> >
> +1 to that.
> Can they be marked as deprecated as part of the move perhaps (assuming we
> get agreement to kill them?)

Yes.
I'll wait for others to chime in, which means this will wait for after
my days off :-).
  
David Marchand Aug. 24, 2022, 6:50 a.m. UTC | #5
On Fri, Jul 29, 2022 at 3:22 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Fri, Jul 29, 2022 at 11:59 AM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> > > > Personally, I really don't like these macros at all. I think having the
> > > > check explicitly in the code would be far more readable, and would only be
> > > > one line of code longer than the macro call. Is there some private header
> > > > file we could move these to instead of rte_common.h so we can drop their
> > > > use in future if we decide to?
> > >
> > > I don't like them either.
> > > Not sure where to put them though...
> > >
> > > My "grep-all" shows no user in the projects consuming DPDK I track.
> > > We could mark those macros deprecated, fix our code and drop them later.
> > >
> > +1 to that.
> > Can they be marked as deprecated as part of the move perhaps (assuming we
> > get agreement to kill them?)

Let's see if techboard members have an opinion.

>
> Yes.
> I'll wait for others to chime in, which means this will wait for after
> my days off :-).
  
Thomas Monjalon Aug. 24, 2022, 7:39 a.m. UTC | #6
24/08/2022 08:50, David Marchand:
> On Fri, Jul 29, 2022 at 3:22 PM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > On Fri, Jul 29, 2022 at 11:59 AM Bruce Richardson
> > <bruce.richardson@intel.com> wrote:
> > > > > Personally, I really don't like these macros at all. I think having the
> > > > > check explicitly in the code would be far more readable, and would only be
> > > > > one line of code longer than the macro call. Is there some private header
> > > > > file we could move these to instead of rte_common.h so we can drop their
> > > > > use in future if we decide to?
> > > >
> > > > I don't like them either.
> > > > Not sure where to put them though...
> > > >
> > > > My "grep-all" shows no user in the projects consuming DPDK I track.
> > > > We could mark those macros deprecated, fix our code and drop them later.
> > > >
> > > +1 to that.
> > > Can they be marked as deprecated as part of the move perhaps (assuming we
> > > get agreement to kill them?)
> 
> Let's see if techboard members have an opinion.

These macros have no added value for an external user.
I think it is OK to mark them deprecated and plan for a future removal.

Copy of the code for the context:

/** Macros to check for invalid function pointers. */
#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
       if ((func) == NULL) \
               return retval; \
} while (0)

#define RTE_FUNC_PTR_OR_RET(func) do { \
       if ((func) == NULL) \
               return; \
} while (0)
  
Morten Brørup Aug. 24, 2022, 11:52 a.m. UTC | #7
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Wednesday, 24 August 2022 09.39
> 
> 24/08/2022 08:50, David Marchand:
> > On Fri, Jul 29, 2022 at 3:22 PM David Marchand
> > <david.marchand@redhat.com> wrote:
> > >
> > > On Fri, Jul 29, 2022 at 11:59 AM Bruce Richardson
> > > <bruce.richardson@intel.com> wrote:
> > > > > > Personally, I really don't like these macros at all. I think
> having the
> > > > > > check explicitly in the code would be far more readable, and
> would only be
> > > > > > one line of code longer than the macro call. Is there some
> private header
> > > > > > file we could move these to instead of rte_common.h so we can
> drop their
> > > > > > use in future if we decide to?
> > > > >
> > > > > I don't like them either.
> > > > > Not sure where to put them though...
> > > > >
> > > > > My "grep-all" shows no user in the projects consuming DPDK I
> track.
> > > > > We could mark those macros deprecated, fix our code and drop
> them later.
> > > > >
> > > > +1 to that.
> > > > Can they be marked as deprecated as part of the move perhaps
> (assuming we
> > > > get agreement to kill them?)
> >
> > Let's see if techboard members have an opinion.
> 
> These macros have no added value for an external user.
> I think it is OK to mark them deprecated and plan for a future removal.

+1 from a community member :-)

> 
> Copy of the code for the context:
> 
> /** Macros to check for invalid function pointers. */
> #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
>        if ((func) == NULL) \
>                return retval; \
> } while (0)
> 
> #define RTE_FUNC_PTR_OR_RET(func) do { \
>        if ((func) == NULL) \
>                return; \
> } while (0)
> 
> 
>
  
Thomas Monjalon Aug. 24, 2022, 12:53 p.m. UTC | #8
24/08/2022 13:52, Morten Brørup:
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > 24/08/2022 08:50, David Marchand:
> > > On Fri, Jul 29, 2022 at 3:22 PM David Marchand
> > > <david.marchand@redhat.com> wrote:
> > > > > > I don't like them either.
> > > > > > Not sure where to put them though...
> > > > > >
> > > > > > My "grep-all" shows no user in the projects consuming DPDK I
> > track.
> > > > > > We could mark those macros deprecated, fix our code and drop
> > them later.
> > > > > >
> > > > > +1 to that.
> > > > > Can they be marked as deprecated as part of the move perhaps
> > (assuming we
> > > > > get agreement to kill them?)
> > >
> > > Let's see if techboard members have an opinion.
> > 
> > These macros have no added value for an external user.
> > I think it is OK to mark them deprecated and plan for a future removal.
> 
> +1 from a community member :-)

As usual, your voice is very valuable Morten :)
  

Patch

diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index db4b087d2b..6583cf0554 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -2,6 +2,7 @@ 
  * Copyright(c) 2018-2022 Intel Corporation
  */
 
+#include <rte_common.h>
 #include <rte_string_fns.h>
 #include <rte_devargs.h>
 #include <ctype.h>
diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c
index dc8db84a68..e4cac159be 100644
--- a/drivers/compress/qat/qat_comp_pmd.c
+++ b/drivers/compress/qat/qat_comp_pmd.c
@@ -2,6 +2,7 @@ 
  * Copyright(c) 2015-2022 Intel Corporation
  */
 
+#include <rte_common.h>
 #include <rte_malloc.h>
 
 #include "qat_comp.h"
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1e0c4fe464..88c9b21cd8 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -1,6 +1,7 @@ 
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Intel Corporation
  */
+#include <rte_common.h>
 #include <rte_string_fns.h>
 #include <rte_reorder.h>
 #include <rte_cryptodev.h>
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.c b/drivers/net/ixgbe/rte_pmd_ixgbe.c
index 9729f8575f..8ae4d9b39a 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe.c
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c
@@ -2,6 +2,7 @@ 
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <rte_common.h>
 #include <ethdev_driver.h>
 
 #include "base/ixgbe_api.h"
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index 90ffe31b9f..ccbd0ff849 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -2,6 +2,7 @@ 
  * Copyright(c) 2017 Cavium, Inc
  */
 
+#include <rte_common.h>
 #include <rte_string_fns.h>
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c
index 22c438f2dd..12469042f7 100644
--- a/lib/compressdev/rte_compressdev.c
+++ b/lib/compressdev/rte_compressdev.c
@@ -6,6 +6,7 @@ 
 #include <stdio.h>
 #include <inttypes.h>
 
+#include <rte_common.h>
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_eal.h>
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 174d4c40ae..e199b888c8 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -5,6 +5,7 @@ 
 
 #include <inttypes.h>
 
+#include <rte_common.h>
 #include <rte_eal.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index a96cc2a138..e2d1271c53 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -861,6 +861,17 @@  rte_log2_u64(uint64_t v)
 /** Number of elements in the array. */
 #define	RTE_DIM(a)	(sizeof (a) / sizeof ((a)[0]))
 
+/** Macros to check for invalid function pointers. */
+#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
+	if ((func) == NULL) \
+		return retval; \
+} while (0)
+
+#define RTE_FUNC_PTR_OR_RET(func) do { \
+	if ((func) == NULL) \
+		return; \
+} while (0)
+
 /**
  * Converts a numeric string to the equivalent uint64_t value.
  * As well as straight number conversion, also recognises the suffixes
diff --git a/lib/eal/include/rte_dev.h b/lib/eal/include/rte_dev.h
index e6ff1218f9..24f9122558 100644
--- a/lib/eal/include/rte_dev.h
+++ b/lib/eal/include/rte_dev.h
@@ -36,17 +36,6 @@  typedef void (*rte_dev_event_cb_fn)(const char *device_name,
 					enum rte_dev_event_type event,
 					void *cb_arg);
 
-/* Macros to check for invalid function pointers */
-#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
-	if ((func) == NULL) \
-		return retval; \
-} while (0)
-
-#define RTE_FUNC_PTR_OR_RET(func) do { \
-	if ((func) == NULL) \
-		return; \
-} while (0)
-
 /**
  * Device policies.
  */
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index a285f213f0..86f5a37874 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -2,6 +2,7 @@ 
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <rte_common.h>
 #include <rte_kvargs.h>
 #include <rte_malloc.h>
 
diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h
index 0549842709..b4bb460dcb 100644
--- a/lib/ethdev/ethdev_pci.h
+++ b/lib/ethdev/ethdev_pci.h
@@ -10,6 +10,7 @@ 
 extern "C" {
 #endif
 
+#include <rte_common.h>
 #include <rte_malloc.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 2d36dee8f0..d60235a7e3 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -6,6 +6,7 @@ 
 #include <stdio.h>
 #include <string.h>
 
+#include <rte_common.h>
 #include <rte_string_fns.h>
 #include <rte_mempool.h>
 #include <rte_errno.h>
diff --git a/lib/regexdev/rte_regexdev.c b/lib/regexdev/rte_regexdev.c
index 02a388bc5d..aa57ab5bfa 100644
--- a/lib/regexdev/rte_regexdev.c
+++ b/lib/regexdev/rte_regexdev.c
@@ -5,6 +5,7 @@ 
 
 #include <string.h>
 
+#include <rte_common.h>
 #include <rte_memzone.h>
 #include <rte_string_fns.h>
 
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index 4f5e4b4d49..046b6496d2 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,6 +4,7 @@ 
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_common.h>
 #include <rte_cryptodev.h>
 #include <rte_dev.h>
 #include <rte_telemetry.h>
diff --git a/lib/vhost/vdpa.c b/lib/vhost/vdpa.c
index b2a2919fc0..bdebcbe565 100644
--- a/lib/vhost/vdpa.c
+++ b/lib/vhost/vdpa.c
@@ -10,6 +10,7 @@ 
 
 #include <sys/queue.h>
 
+#include <rte_common.h>
 #include <rte_class.h>
 #include <rte_malloc.h>
 #include <rte_spinlock.h>