[v4,2/9] net/ring: build on Windows

Message ID 20230219231416.22524-3-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Enable building more libraries on Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 19, 2023, 11:14 p.m. UTC
  The command line arguments are stored in node_action_pair
and the name[] was sized to PATH_MAX which does not exist on Windows.
Since the name is either "CREATE" or "ATTACH" it is not
related to PATH_MAX (4096).

With this fix driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/meson.build            | 2 +-
 drivers/net/ring/meson.build    | 6 ------
 drivers/net/ring/rte_eth_ring.c | 4 +++-
 3 files changed, 4 insertions(+), 8 deletions(-)
  

Comments

David Marchand March 9, 2023, 9:10 p.m. UTC | #1
On Mon, Feb 20, 2023 at 12:14 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The command line arguments are stored in node_action_pair
> and the name[] was sized to PATH_MAX which does not exist on Windows.
> Since the name is either "CREATE" or "ATTACH" it is not
> related to PATH_MAX (4096).
>
> With this fix driver builds ok on windows, but need to modify the
> test meson build to skip the eventdev test on Windows.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  app/test/meson.build            | 2 +-
>  drivers/net/ring/meson.build    | 6 ------
>  drivers/net/ring/rte_eth_ring.c | 4 +++-
>  3 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/app/test/meson.build b/app/test/meson.build
> index f34d19e3c3cb..a713f0382280 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
>          driver_test_names += 'link_bonding_mode4_autotest'
>      endif
>  endif
> -if dpdk_conf.has('RTE_NET_RING')
> +if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
>      test_deps += 'net_ring'
>      test_sources += 'test_pmd_ring_perf.c'
>      test_sources += 'test_pmd_ring.c'
> diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
> index 72792e26b05a..3534a3cc2287 100644
> --- a/drivers/net/ring/meson.build
> +++ b/drivers/net/ring/meson.build
> @@ -1,12 +1,6 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017 Intel Corporation
>
> -if is_windows
> -    build = false
> -    reason = 'not supported on Windows'
> -    subdir_done()
> -endif
> -
>  sources = files('rte_eth_ring.c')
>  headers = files('rte_eth_ring.h')
>  pmd_supports_disable_iova_as_pa = true
> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> index bd5a47dd9017..e8bc9b627102 100644
> --- a/drivers/net/ring/rte_eth_ring.c
> +++ b/drivers/net/ring/rte_eth_ring.c
> @@ -9,6 +9,7 @@
>  #include <ethdev_driver.h>
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
> +#include <rte_os_shim.h>

Is it still needed, since this patch drops use of PATH_MAX?


>  #include <rte_string_fns.h>
>  #include <bus_vdev_driver.h>
>  #include <rte_kvargs.h>
> @@ -17,6 +18,7 @@
>  #define ETH_RING_NUMA_NODE_ACTION_ARG  "nodeaction"
>  #define ETH_RING_ACTION_CREATE         "CREATE"
>  #define ETH_RING_ACTION_ATTACH         "ATTACH"
> +#define ETH_RING_ACTION_MAX_LEN                8 /* CREATE | ACTION */
>  #define ETH_RING_INTERNAL_ARG          "internal"
>  #define ETH_RING_INTERNAL_ARG_MAX_LEN  19 /* "0x..16chars..\0" */
>
> @@ -539,7 +541,7 @@ eth_dev_ring_create(const char *name,
>  }
>
>  struct node_action_pair {
> -       char name[PATH_MAX];
> +       char name[ETH_RING_ACTION_MAX_LEN];
>         unsigned int node;
>         enum dev_action action;
>  };
> --
> 2.39.1
>
  
Stephen Hemminger March 9, 2023, 9:21 p.m. UTC | #2
On Thu, 9 Mar 2023 22:10:03 +0100
David Marchand <david.marchand@redhat.com> wrote:

> > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> > index bd5a47dd9017..e8bc9b627102 100644
> > --- a/drivers/net/ring/rte_eth_ring.c
> > +++ b/drivers/net/ring/rte_eth_ring.c
> > @@ -9,6 +9,7 @@
> >  #include <ethdev_driver.h>
> >  #include <rte_malloc.h>
> >  #include <rte_memcpy.h>
> > +#include <rte_os_shim.h>  
> 
> Is it still needed, since this patch drops use of PATH_MAX?

Let me submit a version without, I don't run windows just do cross builds.
  
David Marchand March 10, 2023, 9:34 a.m. UTC | #3
On Thu, Mar 9, 2023 at 10:21 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Thu, 9 Mar 2023 22:10:03 +0100
> David Marchand <david.marchand@redhat.com> wrote:
>
> > > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> > > index bd5a47dd9017..e8bc9b627102 100644
> > > --- a/drivers/net/ring/rte_eth_ring.c
> > > +++ b/drivers/net/ring/rte_eth_ring.c
> > > @@ -9,6 +9,7 @@
> > >  #include <ethdev_driver.h>
> > >  #include <rte_malloc.h>
> > >  #include <rte_memcpy.h>
> > > +#include <rte_os_shim.h>
> >
> > Is it still needed, since this patch drops use of PATH_MAX?
>
> Let me submit a version without, I don't run windows just do cross builds.

Good thing you did.

So we still need this include for hack on strdup.
So the v4 series is enough.

If I manage to merge it today..., I'll simply update the commitlog.

libtmp_rte_net_ring.a.p" "-Idrivers" "-I..\drivers"
"-Idrivers\net\ring" "-I..\drivers\net\ring" "-Ilib\ethdev"
"-I..\lib\ethdev" "-I." "-I.." "-Iconfig" "-I..\config"
"-Ilib\eal\include" "-I..\lib\eal\include" "-Ilib\eal\windows\include"
"-I..\lib\eal\windows\include" "-Ilib\eal\x86\include"
"-I..\lib\eal\x86\include" "-Ilib\eal\common" "-I..\lib\eal\common"
"-Ilib\eal" "-I..\lib\eal" "-Ilib\kvargs" "-I..\lib\kvargs"
"-Ilib\net" "-I..\lib\net" "-Ilib\mbuf" "-I..\lib\mbuf"
"-Ilib\mempool" "-I..\lib\mempool" "-Ilib\ring" "-I..\lib\ring"
"-Ilib\metrics" "-I..\lib\metrics" "-Ilib\telemetry"
"-I..\lib\telemetry" "-Ilib\meter" "-I..\lib\meter"
"-Idrivers\bus\pci" "-I..\drivers\bus\pci"
"-I..\drivers\bus\pci\windows" "-Ilib\pci" "-I..\lib\pci"
"-Idrivers\bus\vdev" "-I..\drivers\bus\vdev" "-IC:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc" "-Xclang"
"-fcolor-diagnostics" "-pipe" "-D_FILE_OFFSET_BITS=64" "-Wall"
"-Winvalid-pch" "-Wextra" "-Werror" "-O3" "-include" "rte_config.h"
"-Wcast-qual" "-Wdeprecated" "-Wformat" "-Wformat-nonliteral"
"-Wformat-security" "-Wmissing-declarations" "-Wmissing-prototypes"
"-Wnested-externs" "-Wold-style-definition" "-Wpointer-arith"
"-Wsign-compare" "-Wstrict-prototypes" "-Wundef" "-Wwrite-strings"
"-Wno-address-of-packed-member" "-Wno-missing-field-initializers"
"-D_GNU_SOURCE" "-D_WIN32_WINNT=0x0A00" "-D_CRT_SECURE_NO_WARNINGS"
"-march=native" "-DALLOW_EXPERIMENTAL_API" "-DALLOW_INTERNAL_API"
"-DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.ring" -MD -MQ
drivers/libtmp_rte_net_ring.a.p/net_ring_rte_eth_ring.c.obj -MF
"drivers\libtmp_rte_net_ring.a.p\net_ring_rte_eth_ring.c.obj.d" -o
drivers/libtmp_rte_net_ring.a.p/net_ring_rte_eth_ring.c.obj "-c"
../drivers/net/ring/rte_eth_ring.c
../drivers/net/ring/rte_eth_ring.c:564:9: error: 'strdup' is
deprecated: The POSIX name for this item is deprecated. Instead, use
the ISO C and C++ conformant name: _strdup. See online help for
details. [-Werror,-Wdeprecated-declarations]
        name = strdup(value);
               ^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.18362.0\ucrt\string.h:535:20: note: 'strdup' has
been explicitly marked deprecated here
    _Check_return_ _CRT_NONSTDC_DEPRECATE(_strdup)
                   ^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.18362.0\ucrt\corecrt.h:335:50: note: expanded
from macro '_CRT_NONSTDC_DEPRECATE'
        #define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT(
           \
                                                 ^
C:\Program Files (x86)\Microsoft Visual
Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:310:47:
note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
1 error generated
  

Patch

diff --git a/app/test/meson.build b/app/test/meson.build
index f34d19e3c3cb..a713f0382280 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -390,7 +390,7 @@  if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bd5a47dd9017..e8bc9b627102 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -9,6 +9,7 @@ 
 #include <ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
+#include <rte_os_shim.h>
 #include <rte_string_fns.h>
 #include <bus_vdev_driver.h>
 #include <rte_kvargs.h>
@@ -17,6 +18,7 @@ 
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_ACTION_MAX_LEN		8 /* CREATE | ACTION */
 #define ETH_RING_INTERNAL_ARG		"internal"
 #define ETH_RING_INTERNAL_ARG_MAX_LEN	19 /* "0x..16chars..\0" */
 
@@ -539,7 +541,7 @@  eth_dev_ring_create(const char *name,
 }
 
 struct node_action_pair {
-	char name[PATH_MAX];
+	char name[ETH_RING_ACTION_MAX_LEN];
 	unsigned int node;
 	enum dev_action action;
 };