patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v5 01/17] eal: fix comment of OS-specific header files
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox Thomas Monjalon
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam,
	Harini Ramakrishnan, Anand Rawat

The same comment is on top of each rte_os.h file.
It is reworded to remove the mention of "future releases".

Fixes: 428eb983f5f7 ("eal: add OS specific header file")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/freebsd/include/rte_os.h | 5 ++---
 lib/librte_eal/linux/include/rte_os.h   | 5 ++---
 lib/librte_eal/windows/include/rte_os.h | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index eeb750cd81..c16f2a30e9 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * freebsd OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in FreeBSD.
  */
 
 #include <pthread_np.h>
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 218d4fa86e..390b87b3a1 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * linux OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Linux.
  */
 
 #include <sched.h>
diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h
index 7ef38ff06c..f0512f20a6 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * Windows OS. It must not include Windows-specific headers.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Windows.
  */
 
 #include <stdarg.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-26  9:11     ` Bruce Richardson
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux Thomas Monjalon
                     ` (12 subsequent siblings)
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Konstantin Ananyev,
	Ray Kinsella, Neil Horman, Haiyue Wang, David Marchand,
	Adrien Mazarguil

If using busybox for mktemp and awk (as in Alpine),
some bugs prevent the script from running:

1/ It seems busybox mktemp requires the pattern to have at least
6 X and no other suffix.
The same has been fixed for other scripts in the past:
commit 3771edc35438 ("buildtools: fix build for some mktemp")

2/ It seems busybox awk does not accept the regex ^.*{
except if the opening curly brace is escaped.

Fixes: 4c82473412e8 ("build: add internal tag check")
Fixes: 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
Fixes: 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/buildtools/binutils-avx512-check.sh b/buildtools/binutils-avx512-check.sh
index a7e068140f..2a833b64b7 100755
--- a/buildtools/binutils-avx512-check.sh
+++ b/buildtools/binutils-avx512-check.sh
@@ -3,7 +3,7 @@
 # Copyright(c) 2020 Intel Corporation
 
 AS=${AS:-as}
-OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX.o)
+OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX)
 trap 'rm -f "$OBJFILE"' EXIT
 # from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028
 GATHER_PARAMS='0x8(,%ymm1,1),%ymm0{%k2}'
diff --git a/buildtools/check-symbols.sh b/buildtools/check-symbols.sh
index e407553a34..6723e38450 100755
--- a/buildtools/check-symbols.sh
+++ b/buildtools/check-symbols.sh
@@ -18,7 +18,7 @@ then
 	exit 0
 fi
 
-DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
+DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)
 trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh
index 5509b4a7fa..3bf9bd66f8 100755
--- a/buildtools/map-list-symbol.sh
+++ b/buildtools/map-list-symbol.sh
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-26  9:08     ` Bruce Richardson
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally Thomas Monjalon
                     ` (11 subsequent siblings)
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Bruce Richardson

The library execinfo and its header file can be installed on Alpine Linux
where the backtrace feature is not part of musl libc:
	apk add libexecinfo-dev

As a consequence, this library should not be restricted to BSD only.

At the same time, the library and header are detected once and added
globally to be linked with any application, internal or external.

Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 87fc195dbf..50a53dbde8 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -21,9 +21,6 @@ apps = [
 	'test-regex',
 	'test-sad']
 
-# for BSD only
-lib_execinfo = cc.find_library('execinfo', required: false)
-
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
 default_ldflags = []
 if get_option('default_library') == 'static' and not is_windows
@@ -53,7 +50,6 @@ foreach app:apps
 			dep_objs += get_variable(get_option('default_library')
 				 + '_rte_' + d)
 		endforeach
-		dep_objs += lib_execinfo
 
 		link_libs = []
 		if get_option('default_library') == 'static'
diff --git a/app/test/meson.build b/app/test/meson.build
index 561e493a29..099895fc87 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -426,7 +426,6 @@ foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
-test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a3..66a2edcc47 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -125,11 +125,8 @@ if cc.find_library('m', required : false).found()
 	dpdk_extra_ldflags += '-lm'
 endif
 
-# for linux link against dl, for bsd execinfo
 if is_linux
 	link_lib = 'dl'
-elif is_freebsd
-	link_lib = 'execinfo'
 else
 	link_lib = ''
 endif
@@ -166,6 +163,12 @@ if fdt_dep.found() and cc.has_header('fdt.h')
 	dpdk_extra_ldflags += '-lfdt'
 endif
 
+libexecinfo = cc.find_library('libexecinfo', required: false)
+if libexecinfo.found() and cc.has_header('execinfo.h')
+	add_project_link_arguments('-lexecinfo', language: 'c')
+	dpdk_extra_ldflags += '-lexecinfo'
+endif
+
 # check for libbsd
 libbsd = dependency('libbsd', required: false, method: 'pkg-config')
 if libbsd.found()
diff --git a/examples/meson.build b/examples/meson.build
index b9ab24223f..ab06e2da33 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -6,8 +6,6 @@ if get_option('default_library') == 'static'
 	link_whole_libs = dpdk_static_libraries + dpdk_drivers
 endif
 
-execinfo = cc.find_library('execinfo', required: false)
-
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
 all_examples = [
 	'bbdev_app', 'bond',
@@ -76,7 +74,7 @@ foreach example: examples
 	cflags = default_cflags
 	ldflags = default_ldflags
 
-	ext_deps = [execinfo]
+	ext_deps = []
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (2 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-26  9:08     ` Bruce Richardson
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 05/17] eal/linux: fix build with musl Thomas Monjalon
                     ` (10 subsequent siblings)
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

There was an intent to define _GNU_SOURCE globally,
but it was not set in pkg-config for external applications.

The internal definition in config/meson.build is kept,
and one is added in buildtools/pkg-config/meson.build for external apps.
All other specific definitions of _GNU_SOURCE are removed.

Fixes: 5d7b673d5fd6 ("mk: build with _GNU_SOURCE defined by default")
Fixes: 28188cee2aa0 ("build: enable BSD features visibility for FreeBSD")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test/meson.build                              | 2 --
 buildtools/pkg-config/meson.build                 | 1 +
 drivers/bus/fslmc/qbman/include/compat.h          | 3 ---
 drivers/common/dpaax/compat.h                     | 4 ----
 drivers/common/dpaax/meson.build                  | 1 -
 drivers/net/memif/rte_eth_memif.h                 | 4 ----
 drivers/net/mlx5/linux/mlx5_socket.c              | 4 ----
 examples/ip_pipeline/Makefile                     | 2 +-
 examples/performance-thread/l3fwd-thread/main.c   | 4 ----
 examples/performance-thread/pthread_shim/Makefile | 1 -
 examples/pipeline/Makefile                        | 2 +-
 examples/vhost_blk/vhost_blk.c                    | 4 ----
 12 files changed, 3 insertions(+), 29 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index 099895fc87..76eaaea457 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -398,8 +398,6 @@ if cc.has_argument('-Wno-format-truncation')
     cflags += '-Wno-format-truncation'
 endif
 
-# specify -D_GNU_SOURCE unconditionally
-cflags += '-D_GNU_SOURCE'
 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
 cflags += '-fno-strict-aliasing'
 
diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 39a8fd1c8e..d3f3edaa2f 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -3,6 +3,7 @@
 
 pkg = import('pkgconfig')
 pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
+pkg_extra_cflags += '-D_GNU_SOURCE'
 if is_freebsd
 	pkg_extra_cflags += ['-D__BSD_VISIBLE']
 endif
diff --git a/drivers/bus/fslmc/qbman/include/compat.h b/drivers/bus/fslmc/qbman/include/compat.h
index 1ddd69e127..a4471a80af 100644
--- a/drivers/bus/fslmc/qbman/include/compat.h
+++ b/drivers/bus/fslmc/qbman/include/compat.h
@@ -8,9 +8,6 @@
 #ifndef HEADER_COMPAT_H
 #define HEADER_COMPAT_H
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 1a5f36e99e..c69e76ab96 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -10,10 +10,6 @@
 #define __COMPAT_H
 
 #include <sched.h>
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdint.h>
 #include <stdlib.h>
 #include <stddef.h>
diff --git a/drivers/common/dpaax/meson.build b/drivers/common/dpaax/meson.build
index 4535482701..b7f177a62e 100644
--- a/drivers/common/dpaax/meson.build
+++ b/drivers/common/dpaax/meson.build
@@ -10,7 +10,6 @@ sources = files('dpaax_iova_table.c', 'dpaa_of.c', 'caamflib.c')
 
 includes += include_directories('caamflib')
 
-cflags += ['-D_GNU_SOURCE']
 if cc.has_argument('-Wno-cast-qual')
 	cflags += '-Wno-cast-qual'
 endif
diff --git a/drivers/net/memif/rte_eth_memif.h b/drivers/net/memif/rte_eth_memif.h
index 24321d3a39..2038bda742 100644
--- a/drivers/net/memif/rte_eth_memif.h
+++ b/drivers/net/memif/rte_eth_memif.h
@@ -5,10 +5,6 @@
 #ifndef _RTE_ETH_MEMIF_H_
 #define _RTE_ETH_MEMIF_H_
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif				/* GNU_SOURCE */
-
 #include <sys/queue.h>
 
 #include <ethdev_driver.h>
diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 1938453980..b1f41bc102 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,10 +2,6 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 96f492a5ea..7933ad7519 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -47,7 +47,7 @@ $(error "Cannot generate statically-linked binaries with this version of pkg-con
 endif
 endif
 
-CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
+CFLAGS += -I. -DALLOW_EXPERIMENTAL_API
 
 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 4d82fb82ef..10bd33d767 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -2,10 +2,6 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/examples/performance-thread/pthread_shim/Makefile b/examples/performance-thread/pthread_shim/Makefile
index 5aa401dc49..a1f4557cd4 100644
--- a/examples/performance-thread/pthread_shim/Makefile
+++ b/examples/performance-thread/pthread_shim/Makefile
@@ -18,7 +18,6 @@ endif
 endif
 
 CFLAGS += -DALLOW_EXPERIMENTAL_API
-CFLAGS += -D_GNU_SOURCE
 LDFLAGS += "-Wl,--copy-dt-needed-entries"
 
 # Build using pkg-config variables if possible
diff --git a/examples/pipeline/Makefile b/examples/pipeline/Makefile
index fcba51fd4d..92caf4aeb2 100644
--- a/examples/pipeline/Makefile
+++ b/examples/pipeline/Makefile
@@ -38,7 +38,7 @@ $(error "Cannot generate statically-linked binaries with this version of pkg-con
 endif
 endif
 
-CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
+CFLAGS += -I. -DALLOW_EXPERIMENTAL_API
 
 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 7ea60863da..e9361267a6 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -2,12 +2,8 @@
  * Copyright(c) 2010-2019 Intel Corporation
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <pthread.h>
 #include <sched.h>
-
 #include <stdint.h>
 #include <unistd.h>
 #include <stdbool.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 05/17] eal/linux: fix build with musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (3 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 06/17] drivers: fix header includes for musl Thomas Monjalon
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Ferruh Yigit, Jerin Jacob, Dmitry Kozlyuk

In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
In case _GNU_SOURCE is undefined, as in eal_common_errno.c,
it was not possible to include rte_os.h which uses cpu_set_t.

This limitation is removed: if _GNU_SOURCE is not defined,
cpu_set_t related definitions are skipped.
Note: such definitions are unneeded in eal_common_errno.c.

A missing include of fcntl.h is also added.

Bugzilla ID: 35
Fixes: 11b57c698005 ("eal: fix error string function")
Fixes: 176bb37ca6f3 ("eal: introduce internal wrappers for file operations")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 lib/librte_eal/linux/include/rte_os.h | 2 ++
 lib/librte_eal/unix/eal_file.c        | 1 +
 2 files changed, 3 insertions(+)

diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 390b87b3a1..f3f9982f40 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -12,6 +12,7 @@
 
 #include <sched.h>
 
+#ifdef _GNU_SOURCE
 typedef cpu_set_t rte_cpuset_t;
 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
@@ -28,5 +29,6 @@ typedef cpu_set_t rte_cpuset_t;
 	RTE_CPU_FILL(&tmp); \
 	CPU_XOR(dst, &tmp, src); \
 } while (0)
+#endif
 
 #endif /* _RTE_OS_H_ */
diff --git a/lib/librte_eal/unix/eal_file.c b/lib/librte_eal/unix/eal_file.c
index 1b26475ba4..ec554e0096 100644
--- a/lib/librte_eal/unix/eal_file.c
+++ b/lib/librte_eal/unix/eal_file.c
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 06/17] drivers: fix header includes for musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (4 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 05/17] eal/linux: fix build with musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Timothy McDaniel,
	Geoff Thorpe, Shreyansh Jain, Gage Eads

The header files argp.h and error.h do not exist in musl libc
and are not needed in dpaa code.

The header file fcntl.h should not be included from sys/ directory
as done in dlb drivers, it is an error with musl libc.

Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Fixes: 39f373cf015a ("bus/dpaa: add compatibility and helper macros")
Fixes: 19980083fd57 ("event/dlb: add eventdev probe")
Fixes: 5433956d5185 ("event/dlb2: add eventdev probe")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/dpaa/include/netcfg.h | 1 -
 drivers/common/dpaax/compat.h     | 1 -
 drivers/event/dlb/dlb.c           | 2 +-
 drivers/event/dlb/pf/dlb_pf.c     | 3 ++-
 drivers/event/dlb2/dlb2.c         | 2 +-
 drivers/event/dlb2/pf/dlb2_pf.c   | 3 ++-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/dpaa/include/netcfg.h b/drivers/bus/dpaa/include/netcfg.h
index d7d1befd24..bb18a34e3d 100644
--- a/drivers/bus/dpaa/include/netcfg.h
+++ b/drivers/bus/dpaa/include/netcfg.h
@@ -9,7 +9,6 @@
 #define __NETCFG_H
 
 #include <fman.h>
-#include <argp.h>
 
 /* Configuration information related to a specific ethernet port */
 struct fm_eth_port_cfg {
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index c69e76ab96..7166f8cceb 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -30,7 +30,6 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
diff --git a/drivers/event/dlb/dlb.c b/drivers/event/dlb/dlb.c
index 8b26d1d2d2..2fbfc6aed4 100644
--- a/drivers/event/dlb/dlb.c
+++ b/drivers/event/dlb/dlb.c
@@ -10,7 +10,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
diff --git a/drivers/event/dlb/pf/dlb_pf.c b/drivers/event/dlb/pf/dlb_pf.c
index 3aeef6f91d..876c68e51d 100644
--- a/drivers/event/dlb/pf/dlb_pf.c
+++ b/drivers/event/dlb/pf/dlb_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index b28ec58bfb..fb5ff012a4 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -11,7 +11,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #include <rte_common.h>
 #include <rte_config.h>
diff --git a/drivers/event/dlb2/pf/dlb2_pf.c b/drivers/event/dlb2/pf/dlb2_pf.c
index 1a7d8fc294..b85fd3ec56 100644
--- a/drivers/event/dlb2/pf/dlb2_pf.c
+++ b/drivers/event/dlb2/pf/dlb2_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 08/17] bus/pci: support I/O port operations with musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (5 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 06/17] drivers: fix header includes for musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Ferruh Yigit, David Marchand, Yuanhan Liu

From: Natanael Copa <ncopa@alpinelinux.org>

Add a fallback for non-GNU libc systems like musl libc for the
non-standard functions outl_p, outw_p and outb_p.

This solves the following buildtime errors when building with musl libc:
pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
pci_uio.c:(.text+0xadf): undefined reference to `outb_p'

The non-x86 case are handled with macros to factor out various ifdefs.

Bugzilla ID: 35
Fixes: 756ce64b1ecd ("eal: introduce PCI ioport API")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/pci/linux/pci_uio.c | 91 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index f3305a2f28..1294f505be 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -489,6 +489,16 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
 }
 #endif
 
+#ifdef RTE_ARCH_X86
+#define pci_uio_inl(reg) inl(reg)
+#define pci_uio_inw(reg) inw(reg)
+#define pci_uio_inb(reg) inb(reg)
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_inl(reg) (*(volatile uint32_t *)(reg))
+#define pci_uio_inw(reg) (*(volatile uint16_t *)(reg))
+#define pci_uio_inb(reg) (*(volatile uint8_t *)(reg))
+#endif
+
 void
 pci_uio_ioport_read(struct rte_pci_ioport *p,
 		    void *data, size_t len, off_t offset)
@@ -500,29 +510,62 @@ pci_uio_ioport_read(struct rte_pci_ioport *p,
 	for (d = data; len > 0; d += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
-			*(uint32_t *)d = inl(reg);
-#else
-			*(uint32_t *)d = *(volatile uint32_t *)reg;
-#endif
+			*(uint32_t *)d = pci_uio_inl(reg);
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
-			*(uint16_t *)d = inw(reg);
-#else
-			*(uint16_t *)d = *(volatile uint16_t *)reg;
-#endif
+			*(uint16_t *)d = pci_uio_inw(reg);
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
-			*d = inb(reg);
-#else
-			*d = *(volatile uint8_t *)reg;
-#endif
+			*d = pci_uio_inb(reg);
 		}
 	}
 }
 
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outl_p(value, port);
+#else
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outl_p(value, reg) (*(volatile uint32_t *)(reg) = (value))
+#endif
+
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outw_p(value, port);
+#else
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outw_p(value, reg) (*(volatile uint16_t *)(reg) = (value))
+#endif
+
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outb_p(value, port);
+#else
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outb_p(value, reg) (*(volatile uint8_t *)(reg) = (value))
+#endif
+
 void
 pci_uio_ioport_write(struct rte_pci_ioport *p,
 		     const void *data, size_t len, off_t offset)
@@ -534,25 +577,13 @@ pci_uio_ioport_write(struct rte_pci_ioport *p,
 	for (s = data; len > 0; s += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
-			outl_p(*(const uint32_t *)s, reg);
-#else
-			*(volatile uint32_t *)reg = *(const uint32_t *)s;
-#endif
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
-			outw_p(*(const uint16_t *)s, reg);
-#else
-			*(volatile uint16_t *)reg = *(const uint16_t *)s;
-#endif
+			pci_uio_outw_p(*(const uint16_t *)s, reg);
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
-			outb_p(*s, reg);
-#else
-			*(volatile uint8_t *)reg = *s;
-#endif
+			pci_uio_outb_p(*s, reg);
 		}
 	}
 }
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 09/17] bus/dpaa: fix 64-bit arch detection
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (6 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 10/17] bus/dpaa: fix build with musl Thomas Monjalon
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Shreyansh Jain,
	Roy Pledge, Geoff Thorpe

From: Natanael Copa <ncopa@alpinelinux.org>

There is no standard saying that __WORDSIZE should be be defined or in
what include it should be defined. Use RTE_ARCH_64 instead.

This solves a warning when building with musl libc:

 warning: "__WORDSIZE" is not defined, evaluates to 0 [-Wundef]

Fixes: 847ee3bd0d1f ("bus/dpaa: support FMAN frame queue lookup")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index 10212f0fd5..7ef2f3b2e3 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -16,7 +16,7 @@ extern "C" {
 #include <rte_eventdev.h>
 
 /* FQ lookups (turn this on for 64bit user-space) */
-#if (__WORDSIZE == 64)
+#ifdef RTE_ARCH_64
 #define CONFIG_FSL_QMAN_FQ_LOOKUP
 /* if FQ lookups are supported, this controls the number of initialised,
  * s/w-consumed FQs that can be supported at any one time.
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 10/17] bus/dpaa: fix build with musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (7 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 11/17] common/dpaax/caamflib: " Thomas Monjalon
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Shreyansh Jain,
	Roy Pledge, Geoff Thorpe

From: Natanael Copa <ncopa@alpinelinux.org>

Fix build with musl libc by using warn(3) instead of using the GNU
specific error(3).

`error(0, errno, ...)` is identical to `warn(...)` so replace:

  error(0, ret, ...);

with the identical:

  errno = ret;
  warn(...);

We could have used the identical `warnx("...: %s", strerror(ret))` but
strerror(3) is not thread-safe and the strerror_r variant has two
incompatible versions, one GNU specific and one XSI-compliant. Avoid the
mess by letting `warn` use the thread-local errno.

This also fixes error message for kzmalloc failures which previously
would always have given "Unknown error -1", since that is what
strerror(-1) returns. Let 'warn' use the proper error message from errno
which is set by kzalloc.

Fixes: 9d32ef0f5d61 ("bus/dpaa: support creating dynamic HW portal")
Fixes: f09ede6c8fd1 ("bus/dpaa: add BMAN driver core")
Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c | 13 +++++++++----
 drivers/bus/dpaa/base/qbman/qman_driver.c | 17 ++++++++++++-----
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index b7009f2299..bcedbaf68f 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@
 #include <dpaa_of.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
-#include <error.h>
+#include <err.h>
 #include <net/if_arp.h>
 #include <assert.h>
 #include <unistd.h>
@@ -90,7 +90,7 @@ netcfg_acquire(void)
 	 */
 	skfd = socket(AF_PACKET, SOCK_RAW, 0);
 	if (unlikely(skfd < 0)) {
-		error(0, errno, "%s(): open(SOCK_RAW)", __func__);
+		warn("%s(): open(SOCK_RAW)", __func__);
 		return NULL;
 	}
 
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index 750b756b93..c0b9e3da77 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -11,6 +11,7 @@
 #include <process.h>
 #include "bman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
 
 /*
  * Global variables of the max portal/pool number this bman version supported
@@ -40,7 +41,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		errno = ret;
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +62,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	map.index = idx;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */
@@ -104,8 +107,10 @@ static int fsl_bman_portal_finish(void)
 	cfg = bman_destroy_affine_portal();
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		warn("process_portal_unmap()");
+	}
 	return ret;
 }
 
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index 6d9aaff164..93375d1ea8 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -9,6 +9,8 @@
 #include <process.h>
 #include "qman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
+
 #include <rte_branch_prediction.h>
 
 /* Global variable containing revision id (even on non-control plane systems
@@ -50,7 +52,8 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	map.index = index;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -96,8 +99,10 @@ static int fsl_qman_portal_finish(void)
 	cfg = qman_destroy_affine_portal(NULL);
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		warn("process_portal_unmap()");
+	}
 	return ret;
 }
 
@@ -146,7 +151,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		/* kzalloc sets errno */
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -155,7 +161,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 11/17] common/dpaax/caamflib: fix build with musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (8 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 10/17] bus/dpaa: fix build with musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Akhil Goyal,
	Horia Geanta Neag

From: Natanael Copa <ncopa@alpinelinux.org>

The swab16/swab32/swab64 are Linux specific and not GNU libc specific.
Keep the check for __GLIBC__ just in case other GNU systems depends on
this (Hurd or GNU/kFreeBSD).

This fixes a build error with musl libc.

Fixes: 04711d41a872 ("crypto/dpaa2_sec: add run-time assembler for descriptor")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/common/dpaax/caamflib/compat.h b/drivers/common/dpaax/caamflib/compat.h
index 36ee4b5335..c1a693498d 100644
--- a/drivers/common/dpaax/caamflib/compat.h
+++ b/drivers/common/dpaax/caamflib/compat.h
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef RTE_EXEC_ENV_LINUX
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -24,7 +24,7 @@
 #error "Undefined endianness"
 #endif
 
-#else
+#else /* !RTE_EXEC_ENV_LINUX */
 #error Environment not supported!
 #endif
 
@@ -40,7 +40,7 @@
 #define __maybe_unused __rte_unused
 #endif
 
-#if defined(__GLIBC__) && !defined(pr_debug)
+#if !defined(pr_debug)
 #if !defined(SUPPRESS_PRINTS) && defined(RTA_DEBUG)
 #define pr_debug(fmt, ...) \
 	RTE_LOG(DEBUG, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -49,7 +49,7 @@
 #endif
 #endif /* pr_debug */
 
-#if defined(__GLIBC__) && !defined(pr_err)
+#if !defined(pr_err)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_err(fmt, ...) \
 	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -58,7 +58,7 @@
 #endif
 #endif /* pr_err */
 
-#if defined(__GLIBC__) && !defined(pr_warn)
+#if !defined(pr_warn)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_warn(fmt, ...) \
 	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -101,7 +101,7 @@
 #endif
 
 /* Use Linux naming convention */
-#ifdef __GLIBC__
+#if defined(RTE_EXEC_ENV_LINUX) || defined(__GLIBC__)
 	#define swab16(x) rte_bswap16(x)
 	#define swab32(x) rte_bswap32(x)
 	#define swab64(x) rte_bswap64(x)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 13/17] net/cxgbe: remove use of uint type
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (9 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 11/17] common/dpaax/caamflib: " Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 14/17] net/igc: " Thomas Monjalon
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Morten Brørup, Rahul Lakkireddy, Kumar Sanghvi

From: Natanael Copa <ncopa@alpinelinux.org>

Improve portability by replacing non-standard 'uint' with 'unsigned int'.

This solves the build error with musl libc:

In file included from ../drivers/net/cxgbe/cxgbe.h:9,
                 from ../drivers/net/cxgbe/cxgbe_ethdev.c:37:
../drivers/net/cxgbe/base/common.h:201:4: error: unknown type name 'uint'
  201 |    uint synmapen:1; /* SYN Map Enable */
      |    ^~~~

Fixes: bfcb257d3014 ("net/cxgbe: enable RSS for VF")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 202a2f4baf..ab100d784c 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -189,15 +189,15 @@ struct rss_params {
 	unsigned int mode;			/* RSS mode */
 	union {
 		struct {
-			uint synmapen:1;	/* SYN Map Enable */
-			uint syn4tupenipv6:1;	/* en 4-tuple IPv6 SYNs hash */
-			uint syn2tupenipv6:1;	/* en 2-tuple IPv6 SYNs hash */
-			uint syn4tupenipv4:1;	/* en 4-tuple IPv4 SYNs hash */
-			uint syn2tupenipv4:1;	/* en 2-tuple IPv4 SYNs hash */
-			uint ofdmapen:1;	/* Offload Map Enable */
-			uint tnlmapen:1;	/* Tunnel Map Enable */
-			uint tnlalllookup:1;	/* Tunnel All Lookup */
-			uint hashtoeplitz:1;	/* use Toeplitz hash */
+			unsigned int synmapen:1;      /* SYN Map Enable */
+			unsigned int syn4tupenipv6:1; /* en 4-tuple IPv6 SYNs hash */
+			unsigned int syn2tupenipv6:1; /* en 2-tuple IPv6 SYNs hash */
+			unsigned int syn4tupenipv4:1; /* en 4-tuple IPv4 SYNs hash */
+			unsigned int syn2tupenipv4:1; /* en 2-tuple IPv4 SYNs hash */
+			unsigned int ofdmapen:1;      /* Offload Map Enable */
+			unsigned int tnlmapen:1;      /* Tunnel Map Enable */
+			unsigned int tnlalllookup:1;  /* Tunnel All Lookup */
+			unsigned int hashtoeplitz:1;  /* use Toeplitz hash */
 		} basicvirtual;
 	} u;
 };
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 14/17] net/igc: remove use of uint type
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (10 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-26  0:49     ` Wang, Haiyue
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
                     ` (2 subsequent siblings)
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, David Marchand, Jeff Guo, Haiyue Wang,
	Ferruh Yigit, Alvin Zhang

Improve portability (especially with musl libc)
by replacing the non-standard type 'uint' with 'size_t'.

Fixes: 746664d546fb ("net/igc: support flow API")
Cc: stable@dpdk.org

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c
index 1bb64d323c..66053060af 100644
--- a/drivers/net/igc/igc_flow.c
+++ b/drivers/net/igc/igc_flow.c
@@ -656,7 +656,7 @@ igc_parse_action_rss(struct rte_eth_dev *dev,
  * Return the pointer of the flow, or NULL for failed
  **/
 static inline struct rte_flow *
-igc_alloc_flow(const void *filter, enum igc_filter_type type, uint inbytes)
+igc_alloc_flow(const void *filter, enum igc_filter_type type, size_t inbytes)
 {
 	/* allocate memory, 8 bytes boundary aligned */
 	struct rte_flow *flow = rte_malloc("igc flow filter",
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (11 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 14/17] net/igc: " Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-03-01  7:30     ` Matan Azrad
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 16/17] app/testpmd: fix build with musl Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Matan Azrad, Viacheslav Ovsiienko, Xueming Li,
	Maxime Coquelin

1/ The function pthread_yield() does not exist in musl libc,
and can be replaced with sched_yield() after including sched.h.

2/ The function pthread_attr_setaffinity_np() does not exist in musl libc,
and can be replaced with pthread_setaffinity_np() after pthread_create().

Fixes: b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling")
Fixes: 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling thread")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 86adc864f5..49632dfaa7 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -3,6 +3,7 @@
  */
 #include <unistd.h>
 #include <stdint.h>
+#include <sched.h>
 #include <fcntl.h>
 #include <sys/eventfd.h>
 
@@ -234,7 +235,7 @@ mlx5_vdpa_timer_sleep(struct mlx5_vdpa_priv *priv, uint32_t max)
 		usleep(priv->timer_delay_us);
 	else
 		/* Give-up CPU to improve polling threads scheduling. */
-		pthread_yield();
+		sched_yield();
 }
 
 static void *
@@ -515,17 +516,6 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 		pthread_cond_init(&priv->timer_cond, NULL);
 		priv->timer_on = 0;
 		pthread_attr_init(&attr);
-		CPU_ZERO(&cpuset);
-		if (priv->event_core != -1)
-			CPU_SET(priv->event_core, &cpuset);
-		else
-			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
-		ret = pthread_attr_setaffinity_np(&attr, sizeof(cpuset),
-						  &cpuset);
-		if (ret) {
-			DRV_LOG(ERR, "Failed to set thread affinity.");
-			return -1;
-		}
 		ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
 		if (ret) {
 			DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
@@ -542,6 +532,17 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 			DRV_LOG(ERR, "Failed to create timer thread.");
 			return -1;
 		}
+		CPU_ZERO(&cpuset);
+		if (priv->event_core != -1)
+			CPU_SET(priv->event_core, &cpuset);
+		else
+			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
+		ret = pthread_setaffinity_np(priv->timer_tid,
+					     sizeof(cpuset), &cpuset);
+		if (ret) {
+			DRV_LOG(ERR, "Failed to set thread affinity.");
+			goto error;
+		}
 		snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
 		ret = pthread_setname_np(priv->timer_tid, name);
 		if (ret) {
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 16/17] app/testpmd: fix build with musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (12 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Morten Brørup, Xiaoyun Li,
	Nélio Laranjeiro, Konstantin Ananyev, Ferruh Yigit

From: Natanael Copa <ncopa@alpinelinux.org>

1/ Improve portability by avoiding use of non-standard 'uint'.
Use uint8_t for hash_key_len as rss_key_len is a uint8_t type.
This solves following build error when building with musl libc:
    app/test-pmd/testpmd.h:813:29: error: unknown type name 'uint'

2/ In musl libc, stdout is of type (FILE * const).
Because of the const qualifier, a dark magic cast
must be achieved through uintptr_t.

Fixes: 8205e241b2b0 ("app/testpmd: add missing type to RSS hash commands")
Fixes: e977e4199a8d ("app/testpmd: add commands to load/unload BPF filters")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test-pmd/bpf_cmd.c | 2 +-
 app/test-pmd/config.c  | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 066619e115..6980291f07 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -20,7 +20,7 @@ static const struct rte_bpf_xsym bpf_xsym[] = {
 		.name = RTE_STR(stdout),
 		.type = RTE_BPF_XTYPE_VAR,
 		.var = {
-			.val = &stdout,
+			.val = (void *)(uintptr_t)&stdout,
 			.desc = {
 				.type = RTE_BPF_ARG_PTR,
 				.size = sizeof(stdout),
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dab8afe5dd..9ca03c236e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2963,7 +2963,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 
 void
 port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
-			 uint hash_key_len)
+			 uint8_t hash_key_len)
 {
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 4aca522859..5437b6229e 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -935,7 +935,7 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 
 void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
-			      uint8_t *hash_key, uint hash_key_len);
+			      uint8_t *hash_key, uint8_t hash_key_len);
 int rx_queue_id_is_invalid(queueid_t rxq_id);
 int tx_queue_id_is_invalid(queueid_t txq_id);
 void setup_gro(const char *onoff, portid_t port_id);
-- 
2.30.1


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

* [dpdk-stable] [PATCH v5 17/17] examples/bbdev: fix header include for musl
       [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
                     ` (13 preceding siblings ...)
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 16/17] app/testpmd: fix build with musl Thomas Monjalon
@ 2021-02-25 18:22   ` Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-25 18:22 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Nicolas Chautru, Amr Mokhtar

The header file unistd.h should not be included from sys/ directory,
it is an error with musl libc.

Fixes: 1ffee690eaa1 ("examples/bbdev: add sample app")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 2e170caf84..20cfd327fb 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -8,7 +8,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <sys/unistd.h>
+#include <unistd.h>
 #include <sys/queue.h>
 #include <stdarg.h>
 #include <ctype.h>
-- 
2.30.1


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

* Re: [dpdk-stable] [PATCH v5 14/17] net/igc: remove use of uint type
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 14/17] net/igc: " Thomas Monjalon
@ 2021-02-26  0:49     ` Wang, Haiyue
  0 siblings, 0 replies; 58+ messages in thread
From: Wang, Haiyue @ 2021-02-26  0:49 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: ncopa, stable, David Marchand, Guo, Jia, Yigit, Ferruh, Zhang, AlvinX

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, February 26, 2021 02:23
> To: dev@dpdk.org
> Cc: ncopa@alpinelinux.org; stable@dpdk.org; David Marchand <david.marchand@redhat.com>; Guo, Jia
> <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>;
> Zhang, AlvinX <alvinx.zhang@intel.com>
> Subject: [PATCH v5 14/17] net/igc: remove use of uint type
> 
> Improve portability (especially with musl libc)
> by replacing the non-standard type 'uint' with 'size_t'.
> 
> Fixes: 746664d546fb ("net/igc: support flow API")
> Cc: stable@dpdk.org
> 
> Suggested-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/net/igc/igc_flow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> 2.30.1


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

* Re: [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally Thomas Monjalon
@ 2021-02-26  9:08     ` Bruce Richardson
  2021-02-26  9:40       ` Thomas Monjalon
  0 siblings, 1 reply; 58+ messages in thread
From: Bruce Richardson @ 2021-02-26  9:08 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, ncopa, stable, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

On Thu, Feb 25, 2021 at 07:22:37PM +0100, Thomas Monjalon wrote:
> There was an intent to define _GNU_SOURCE globally,
> but it was not set in pkg-config for external applications.
> 
Is this something that we really want to do, to force all external apps to
use _GNU_SOURCE when compiling? Do some of our header files rely on
definitions only available with _GNU_SOURCE? If so, we should probably look
to remove that dependency rather than mandating the define.

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

* Re: [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux Thomas Monjalon
@ 2021-02-26  9:08     ` Bruce Richardson
  0 siblings, 0 replies; 58+ messages in thread
From: Bruce Richardson @ 2021-02-26  9:08 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, ncopa, stable

On Thu, Feb 25, 2021 at 07:22:36PM +0100, Thomas Monjalon wrote:
> The library execinfo and its header file can be installed on Alpine Linux
> where the backtrace feature is not part of musl libc:
> 	apk add libexecinfo-dev
> 
> As a consequence, this library should not be restricted to BSD only.
> 
> At the same time, the library and header are detected once and added
> globally to be linked with any application, internal or external.
> 
> Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox Thomas Monjalon
@ 2021-02-26  9:11     ` Bruce Richardson
  0 siblings, 0 replies; 58+ messages in thread
From: Bruce Richardson @ 2021-02-26  9:11 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, ncopa, stable, Konstantin Ananyev, Ray Kinsella,
	Neil Horman, Haiyue Wang, David Marchand, Adrien Mazarguil

On Thu, Feb 25, 2021 at 07:22:35PM +0100, Thomas Monjalon wrote:
> If using busybox for mktemp and awk (as in Alpine),
> some bugs prevent the script from running:
> 
> 1/ It seems busybox mktemp requires the pattern to have at least
> 6 X and no other suffix.
> The same has been fixed for other scripts in the past:
> commit 3771edc35438 ("buildtools: fix build for some mktemp")
> 
> 2/ It seems busybox awk does not accept the regex ^.*{
> except if the opening curly brace is escaped.
> 
> Fixes: 4c82473412e8 ("build: add internal tag check")
> Fixes: 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
> Fixes: 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>


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

* Re: [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally
  2021-02-26  9:08     ` Bruce Richardson
@ 2021-02-26  9:40       ` Thomas Monjalon
  2021-02-26  9:46         ` Bruce Richardson
  0 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-26  9:40 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ncopa, stable, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

26/02/2021 10:08, Bruce Richardson:
> On Thu, Feb 25, 2021 at 07:22:37PM +0100, Thomas Monjalon wrote:
> > There was an intent to define _GNU_SOURCE globally,
> > but it was not set in pkg-config for external applications.
> > 
> Is this something that we really want to do, to force all external apps to
> use _GNU_SOURCE when compiling? Do some of our header files rely on
> definitions only available with _GNU_SOURCE? If so, we should probably look
> to remove that dependency rather than mandating the define.

From patch 5:
In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.

If we avoid mandating _GNU_SOURCE,
we must #ifdef functions relying on rte_cpuset_t in the headers:
	- rte_lcore_cpuset
	- rte_thread_set_affinity
	- rte_thread_get_affinity
	- rte_telemetry_init (internal)
Or a different trick in linux/include/rte_os.h could be:
	typedef void rte_cpuset_t;
so it allows including files, but not using above functions of course.



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

* Re: [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally
  2021-02-26  9:40       ` Thomas Monjalon
@ 2021-02-26  9:46         ` Bruce Richardson
  2021-02-26 10:04           ` Thomas Monjalon
  0 siblings, 1 reply; 58+ messages in thread
From: Bruce Richardson @ 2021-02-26  9:46 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, ncopa, stable, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

On Fri, Feb 26, 2021 at 10:40:32AM +0100, Thomas Monjalon wrote:
> 26/02/2021 10:08, Bruce Richardson:
> > On Thu, Feb 25, 2021 at 07:22:37PM +0100, Thomas Monjalon wrote:
> > > There was an intent to define _GNU_SOURCE globally,
> > > but it was not set in pkg-config for external applications.
> > > 
> > Is this something that we really want to do, to force all external apps to
> > use _GNU_SOURCE when compiling? Do some of our header files rely on
> > definitions only available with _GNU_SOURCE? If so, we should probably look
> > to remove that dependency rather than mandating the define.
> 
> From patch 5:
> In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
> 
> If we avoid mandating _GNU_SOURCE,
> we must #ifdef functions relying on rte_cpuset_t in the headers:
> 	- rte_lcore_cpuset
> 	- rte_thread_set_affinity
> 	- rte_thread_get_affinity
> 	- rte_telemetry_init (internal)
> Or a different trick in linux/include/rte_os.h could be:
> 	typedef void rte_cpuset_t;
> so it allows including files, but not using above functions of course.
> 
Can we just define _GNU_SOURCE in the header file with rte_cpuset_t?

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

* Re: [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally
  2021-02-26  9:46         ` Bruce Richardson
@ 2021-02-26 10:04           ` Thomas Monjalon
  2021-02-28 12:53             ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
  0 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-26 10:04 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ncopa, stable, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

26/02/2021 10:46, Bruce Richardson:
> On Fri, Feb 26, 2021 at 10:40:32AM +0100, Thomas Monjalon wrote:
> > 26/02/2021 10:08, Bruce Richardson:
> > > On Thu, Feb 25, 2021 at 07:22:37PM +0100, Thomas Monjalon wrote:
> > > > There was an intent to define _GNU_SOURCE globally,
> > > > but it was not set in pkg-config for external applications.
> > > > 
> > > Is this something that we really want to do, to force all external apps to
> > > use _GNU_SOURCE when compiling? Do some of our header files rely on
> > > definitions only available with _GNU_SOURCE? If so, we should probably look
> > > to remove that dependency rather than mandating the define.
> > 
> > From patch 5:
> > In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
> > 
> > If we avoid mandating _GNU_SOURCE,
> > we must #ifdef functions relying on rte_cpuset_t in the headers:
> > 	- rte_lcore_cpuset
> > 	- rte_thread_set_affinity
> > 	- rte_thread_get_affinity
> > 	- rte_telemetry_init (internal)
> > Or a different trick in linux/include/rte_os.h could be:
> > 	typedef void rte_cpuset_t;
> > so it allows including files, but not using above functions of course.
> > 
> Can we just define _GNU_SOURCE in the header file with rte_cpuset_t?

That would be the simplest solution yes :)
I don't really like defining such flag in a header file because
it impacts all code coming after the include.
It would mean all includes done after DPDK ones behave differently.

I vote for the trick:
#ifdef _GNU_SOURCE
	typedef cpu_set_t rte_cpuset_t;
#else
	typedef void rte_cpuset_t;
#endif

Opinions?



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

* [dpdk-stable] [PATCH v6 01/17] eal: fix comment of OS-specific header files
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 02/17] buildtools: fix build with busybox Thomas Monjalon
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam,
	Anand Rawat, Harini Ramakrishnan

The same comment is on top of each rte_os.h file.
It is reworded to remove the mention of "future releases".

Fixes: 428eb983f5f7 ("eal: add OS specific header file")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/freebsd/include/rte_os.h | 5 ++---
 lib/librte_eal/linux/include/rte_os.h   | 5 ++---
 lib/librte_eal/windows/include/rte_os.h | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index eeb750cd81..c16f2a30e9 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * freebsd OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in FreeBSD.
  */
 
 #include <pthread_np.h>
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 218d4fa86e..390b87b3a1 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * linux OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Linux.
  */
 
 #include <sched.h>
diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h
index 7ef38ff06c..f0512f20a6 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * Windows OS. It must not include Windows-specific headers.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Windows.
  */
 
 #include <stdarg.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 02/17] buildtools: fix build with busybox
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 03/17] build: detect execinfo library on Linux Thomas Monjalon
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Konstantin Ananyev,
	Ray Kinsella, Neil Horman, David Marchand, Haiyue Wang,
	Adrien Mazarguil

If using busybox for mktemp and awk (as in Alpine),
some bugs prevent the script from running:

1/ It seems busybox mktemp requires the pattern to have at least
6 X and no other suffix.
The same has been fixed for other scripts in the past:
commit 3771edc35438 ("buildtools: fix build for some mktemp")

2/ It seems busybox awk does not accept the regex ^.*{
except if the opening curly brace is escaped.

Fixes: 4c82473412e8 ("build: add internal tag check")
Fixes: 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
Fixes: 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/buildtools/binutils-avx512-check.sh b/buildtools/binutils-avx512-check.sh
index a7e068140f..2a833b64b7 100755
--- a/buildtools/binutils-avx512-check.sh
+++ b/buildtools/binutils-avx512-check.sh
@@ -3,7 +3,7 @@
 # Copyright(c) 2020 Intel Corporation
 
 AS=${AS:-as}
-OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX.o)
+OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX)
 trap 'rm -f "$OBJFILE"' EXIT
 # from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028
 GATHER_PARAMS='0x8(,%ymm1,1),%ymm0{%k2}'
diff --git a/buildtools/check-symbols.sh b/buildtools/check-symbols.sh
index e407553a34..6723e38450 100755
--- a/buildtools/check-symbols.sh
+++ b/buildtools/check-symbols.sh
@@ -18,7 +18,7 @@ then
 	exit 0
 fi
 
-DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
+DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)
 trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh
index 5509b4a7fa..3bf9bd66f8 100755
--- a/buildtools/map-list-symbol.sh
+++ b/buildtools/map-list-symbol.sh
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 03/17] build: detect execinfo library on Linux
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 02/17] buildtools: fix build with busybox Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Bruce Richardson

The library execinfo and its header file can be installed on Alpine Linux
where the backtrace feature is not part of musl libc:
	apk add libexecinfo-dev

As a consequence, this library should not be restricted to BSD only.

At the same time, the library and header are detected once and added
globally to be linked with any application, internal or external.

Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 87fc195dbf..50a53dbde8 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -21,9 +21,6 @@ apps = [
 	'test-regex',
 	'test-sad']
 
-# for BSD only
-lib_execinfo = cc.find_library('execinfo', required: false)
-
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
 default_ldflags = []
 if get_option('default_library') == 'static' and not is_windows
@@ -53,7 +50,6 @@ foreach app:apps
 			dep_objs += get_variable(get_option('default_library')
 				 + '_rte_' + d)
 		endforeach
-		dep_objs += lib_execinfo
 
 		link_libs = []
 		if get_option('default_library') == 'static'
diff --git a/app/test/meson.build b/app/test/meson.build
index 561e493a29..099895fc87 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -426,7 +426,6 @@ foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
-test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a3..66a2edcc47 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -125,11 +125,8 @@ if cc.find_library('m', required : false).found()
 	dpdk_extra_ldflags += '-lm'
 endif
 
-# for linux link against dl, for bsd execinfo
 if is_linux
 	link_lib = 'dl'
-elif is_freebsd
-	link_lib = 'execinfo'
 else
 	link_lib = ''
 endif
@@ -166,6 +163,12 @@ if fdt_dep.found() and cc.has_header('fdt.h')
 	dpdk_extra_ldflags += '-lfdt'
 endif
 
+libexecinfo = cc.find_library('libexecinfo', required: false)
+if libexecinfo.found() and cc.has_header('execinfo.h')
+	add_project_link_arguments('-lexecinfo', language: 'c')
+	dpdk_extra_ldflags += '-lexecinfo'
+endif
+
 # check for libbsd
 libbsd = dependency('libbsd', required: false, method: 'pkg-config')
 if libbsd.found()
diff --git a/examples/meson.build b/examples/meson.build
index b9ab24223f..ab06e2da33 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -6,8 +6,6 @@ if get_option('default_library') == 'static'
 	link_whole_libs = dpdk_static_libraries + dpdk_drivers
 endif
 
-execinfo = cc.find_library('execinfo', required: false)
-
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
 all_examples = [
 	'bbdev_app', 'bond',
@@ -76,7 +74,7 @@ foreach example: examples
 	cflags = default_cflags
 	ldflags = default_ldflags
 
-	ext_deps = [execinfo]
+	ext_deps = []
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 04/17] build: remove redundant _GNU_SOURCE definitions
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (2 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 03/17] build: detect execinfo library on Linux Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 05/17] eal: fix build with musl Thomas Monjalon
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Anatoly Burakov, Marcin Smoczynski, Konstantin Ananyev,
	Xueming Li, Xiaoyu Min

The feature macro _GNU_SOURCE is defined globally,
but there was some remaining useless settings.

The internal definition in config/meson.build is kept,
all other internal definitions of _GNU_SOURCE are removed,
except in examples, which can be built as external applications.
Note: external applications do not inherit of _GNU_SOURCE.

Fixes: 5d7b673d5fd6 ("mk: build with _GNU_SOURCE defined by default")
Fixes: 28188cee2aa0 ("build: enable BSD features visibility for FreeBSD")
Fixes: e6cdc54cc0ef ("net/mlx5: add socket server for external tools")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test/meson.build                     | 2 --
 drivers/bus/fslmc/qbman/include/compat.h | 3 ---
 drivers/common/dpaax/compat.h            | 4 ----
 drivers/common/dpaax/meson.build         | 1 -
 drivers/net/memif/rte_eth_memif.h        | 4 ----
 drivers/net/mlx5/linux/mlx5_socket.c     | 4 ----
 6 files changed, 18 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index 099895fc87..76eaaea457 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -398,8 +398,6 @@ if cc.has_argument('-Wno-format-truncation')
     cflags += '-Wno-format-truncation'
 endif
 
-# specify -D_GNU_SOURCE unconditionally
-cflags += '-D_GNU_SOURCE'
 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
 cflags += '-fno-strict-aliasing'
 
diff --git a/drivers/bus/fslmc/qbman/include/compat.h b/drivers/bus/fslmc/qbman/include/compat.h
index 1ddd69e127..a4471a80af 100644
--- a/drivers/bus/fslmc/qbman/include/compat.h
+++ b/drivers/bus/fslmc/qbman/include/compat.h
@@ -8,9 +8,6 @@
 #ifndef HEADER_COMPAT_H
 #define HEADER_COMPAT_H
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 1a5f36e99e..c69e76ab96 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -10,10 +10,6 @@
 #define __COMPAT_H
 
 #include <sched.h>
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdint.h>
 #include <stdlib.h>
 #include <stddef.h>
diff --git a/drivers/common/dpaax/meson.build b/drivers/common/dpaax/meson.build
index 4535482701..b7f177a62e 100644
--- a/drivers/common/dpaax/meson.build
+++ b/drivers/common/dpaax/meson.build
@@ -10,7 +10,6 @@ sources = files('dpaax_iova_table.c', 'dpaa_of.c', 'caamflib.c')
 
 includes += include_directories('caamflib')
 
-cflags += ['-D_GNU_SOURCE']
 if cc.has_argument('-Wno-cast-qual')
 	cflags += '-Wno-cast-qual'
 endif
diff --git a/drivers/net/memif/rte_eth_memif.h b/drivers/net/memif/rte_eth_memif.h
index 24321d3a39..2038bda742 100644
--- a/drivers/net/memif/rte_eth_memif.h
+++ b/drivers/net/memif/rte_eth_memif.h
@@ -5,10 +5,6 @@
 #ifndef _RTE_ETH_MEMIF_H_
 #define _RTE_ETH_MEMIF_H_
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif				/* GNU_SOURCE */
-
 #include <sys/queue.h>
 
 #include <ethdev_driver.h>
diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 1938453980..b1f41bc102 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,10 +2,6 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 05/17] eal: fix build with musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (3 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 06/17] drivers: fix header includes for musl Thomas Monjalon
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam,
	Kevin Laatz, Ferruh Yigit, Jerin Jacob

In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
In case _GNU_SOURCE is undefined, as in eal_common_errno.c,
it was not possible to include rte_os.h which uses cpu_set_t.

This limitation is removed: if CPU_SETSIZE is not defined,
cpu_set_t related definitions and functions are skipped.
Note: such definitions are unneeded in eal_common_errno.c.

Applications which do not define _GNU_SOURCE may miss cpu_set_t related
features on musl. Such case is detected by RTE_HAS_CPUSET being undefined,
so functions which depend on rte_cpuset_t will be unavailable.

A missing include of fcntl.h is also added.

Bugzilla ID: 35
Fixes: 11b57c698005 ("eal: fix error string function")
Fixes: 176bb37ca6f3 ("eal: introduce internal wrappers for file operations")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 doc/api/doxy-api.conf.in                | 3 ++-
 lib/librte_eal/freebsd/include/rte_os.h | 1 +
 lib/librte_eal/include/rte_lcore.h      | 4 ++++
 lib/librte_eal/include/rte_thread.h     | 4 ++++
 lib/librte_eal/linux/include/rte_os.h   | 3 +++
 lib/librte_eal/unix/eal_file.c          | 1 +
 lib/librte_eal/windows/include/sched.h  | 1 +
 lib/librte_telemetry/rte_telemetry.h    | 4 ++++
 8 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 5c883b613b..a536bcb493 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -80,7 +80,8 @@ INPUT                   += @API_EXAMPLES@
 FILE_PATTERNS           = rte_*.h \
                           cmdline.h
 PREDEFINED              = __DOXYGEN__ \
-			   VFIO_PRESENT \
+                          RTE_HAS_CPUSET \
+                          VFIO_PRESENT \
                           __attribute__(x)=
 
 OPTIMIZE_OUTPUT_FOR_C   = YES
diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index c16f2a30e9..627f0483ab 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -13,6 +13,7 @@
 #include <pthread_np.h>
 
 typedef cpuset_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) do \
 { \
 	cpuset_t tmp; \
diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h
index 0fe0bd839c..1550b75da0 100644
--- a/lib/librte_eal/include/rte_lcore.h
+++ b/lib/librte_eal/include/rte_lcore.h
@@ -186,6 +186,8 @@ __rte_experimental
 int
 rte_lcore_to_cpu_id(int lcore_id);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -200,6 +202,8 @@ __rte_experimental
 rte_cpuset_t
 rte_lcore_cpuset(unsigned int lcore_id);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Test if an lcore is enabled.
  *
diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h
index e640ea1857..ac5a89b1ad 100644
--- a/lib/librte_eal/include/rte_thread.h
+++ b/lib/librte_eal/include/rte_thread.h
@@ -25,6 +25,8 @@ extern "C" {
  */
 typedef struct eal_tls_key *rte_tls_key;
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * Set core affinity of the current thread.
  * Support both EAL and non-EAL thread and update TLS.
@@ -46,6 +48,8 @@ int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
  */
 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Create a TLS data key visible to all threads in the process.
  * the created key is later used to get/set a value.
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 390b87b3a1..1618b4df22 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -12,7 +12,9 @@
 
 #include <sched.h>
 
+#ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
 typedef cpu_set_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
 #define RTE_CPU_FILL(set) do \
@@ -28,5 +30,6 @@ typedef cpu_set_t rte_cpuset_t;
 	RTE_CPU_FILL(&tmp); \
 	CPU_XOR(dst, &tmp, src); \
 } while (0)
+#endif
 
 #endif /* _RTE_OS_H_ */
diff --git a/lib/librte_eal/unix/eal_file.c b/lib/librte_eal/unix/eal_file.c
index 1b26475ba4..ec554e0096 100644
--- a/lib/librte_eal/unix/eal_file.c
+++ b/lib/librte_eal/unix/eal_file.c
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
diff --git a/lib/librte_eal/windows/include/sched.h b/lib/librte_eal/windows/include/sched.h
index fbe07f742c..ff572b5dcb 100644
--- a/lib/librte_eal/windows/include/sched.h
+++ b/lib/librte_eal/windows/include/sched.h
@@ -28,6 +28,7 @@ extern "C" {
 typedef struct _rte_cpuset_s {
 	long long _bits[_NUM_SETS(CPU_SETSIZE)];
 } rte_cpuset_t;
+#define RTE_HAS_CPUSET
 
 #define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << _WHICH_BIT(b)))
 
diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h
index f8e54dc68e..3ff3a42d78 100644
--- a/lib/librte_telemetry/rte_telemetry.h
+++ b/lib/librte_telemetry/rte_telemetry.h
@@ -292,6 +292,8 @@ __rte_experimental
 int
 rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @internal
  * Initialize Telemetry.
@@ -314,6 +316,8 @@ int
 rte_telemetry_init(const char *runtime_dir, rte_cpuset_t *cpuset,
 		const char **err_str);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Get a pointer to a container with memory allocated. The container is to be
  * used embedded within an existing telemetry dict/array.
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 06/17] drivers: fix header includes for musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (4 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 05/17] eal: fix build with musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Timothy McDaniel,
	Shreyansh Jain, Geoff Thorpe, Gage Eads

The header files argp.h and error.h do not exist in musl libc
and are not needed in dpaa code.

The header file fcntl.h should not be included from sys/ directory
as done in dlb drivers, it is an error with musl libc.

Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Fixes: 39f373cf015a ("bus/dpaa: add compatibility and helper macros")
Fixes: 19980083fd57 ("event/dlb: add eventdev probe")
Fixes: 5433956d5185 ("event/dlb2: add eventdev probe")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/dpaa/include/netcfg.h | 1 -
 drivers/common/dpaax/compat.h     | 1 -
 drivers/event/dlb/dlb.c           | 2 +-
 drivers/event/dlb/pf/dlb_pf.c     | 3 ++-
 drivers/event/dlb2/dlb2.c         | 2 +-
 drivers/event/dlb2/pf/dlb2_pf.c   | 3 ++-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/dpaa/include/netcfg.h b/drivers/bus/dpaa/include/netcfg.h
index d7d1befd24..bb18a34e3d 100644
--- a/drivers/bus/dpaa/include/netcfg.h
+++ b/drivers/bus/dpaa/include/netcfg.h
@@ -9,7 +9,6 @@
 #define __NETCFG_H
 
 #include <fman.h>
-#include <argp.h>
 
 /* Configuration information related to a specific ethernet port */
 struct fm_eth_port_cfg {
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index c69e76ab96..7166f8cceb 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -30,7 +30,6 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
diff --git a/drivers/event/dlb/dlb.c b/drivers/event/dlb/dlb.c
index 8b26d1d2d2..2fbfc6aed4 100644
--- a/drivers/event/dlb/dlb.c
+++ b/drivers/event/dlb/dlb.c
@@ -10,7 +10,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
diff --git a/drivers/event/dlb/pf/dlb_pf.c b/drivers/event/dlb/pf/dlb_pf.c
index 3aeef6f91d..876c68e51d 100644
--- a/drivers/event/dlb/pf/dlb_pf.c
+++ b/drivers/event/dlb/pf/dlb_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index b28ec58bfb..fb5ff012a4 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -11,7 +11,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #include <rte_common.h>
 #include <rte_config.h>
diff --git a/drivers/event/dlb2/pf/dlb2_pf.c b/drivers/event/dlb2/pf/dlb2_pf.c
index 1a7d8fc294..b85fd3ec56 100644
--- a/drivers/event/dlb2/pf/dlb2_pf.c
+++ b/drivers/event/dlb2/pf/dlb2_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
-- 
2.30.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally
  2021-02-26 10:04           ` Thomas Monjalon
@ 2021-02-28 12:53             ` Thomas Monjalon
  0 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ncopa, stable, Hemant Agrawal, Sachin Saxena,
	Jakub Grajciar, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Cristian Dumitrescu, John McNamara, Maxime Coquelin, Chenbo Xia,
	Anatoly Burakov, Konstantin Ananyev, Marcin Smoczynski

26/02/2021 11:04, Thomas Monjalon:
> 26/02/2021 10:46, Bruce Richardson:
> > On Fri, Feb 26, 2021 at 10:40:32AM +0100, Thomas Monjalon wrote:
> > > 26/02/2021 10:08, Bruce Richardson:
> > > > On Thu, Feb 25, 2021 at 07:22:37PM +0100, Thomas Monjalon wrote:
> > > > > There was an intent to define _GNU_SOURCE globally,
> > > > > but it was not set in pkg-config for external applications.
> > > > > 
> > > > Is this something that we really want to do, to force all external apps to
> > > > use _GNU_SOURCE when compiling? Do some of our header files rely on
> > > > definitions only available with _GNU_SOURCE? If so, we should probably look
> > > > to remove that dependency rather than mandating the define.
> > > 
> > > From patch 5:
> > > In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
> > > 
> > > If we avoid mandating _GNU_SOURCE,
> > > we must #ifdef functions relying on rte_cpuset_t in the headers:
> > > 	- rte_lcore_cpuset
> > > 	- rte_thread_set_affinity
> > > 	- rte_thread_get_affinity
> > > 	- rte_telemetry_init (internal)
> > > Or a different trick in linux/include/rte_os.h could be:
> > > 	typedef void rte_cpuset_t;
> > > so it allows including files, but not using above functions of course.
> > > 
> > Can we just define _GNU_SOURCE in the header file with rte_cpuset_t?
> 
> That would be the simplest solution yes :)
> I don't really like defining such flag in a header file because
> it impacts all code coming after the include.
> It would mean all includes done after DPDK ones behave differently.
> 
> I vote for the trick:
> #ifdef _GNU_SOURCE
> 	typedef cpu_set_t rte_cpuset_t;
> #else
> 	typedef void rte_cpuset_t;
> #endif
> 
> Opinions?

I changed my mind, I think it is saner to not export functions
which use rte_cpuset_t, if the type is not defined.
The type definition is detected thanks to CPU_SETSIZE
and a new definition is used inside DPDK: RTE_HAS_CPUSET.
I think it is more elegant and easier to debug.
I am sending a v6.



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

* [dpdk-stable] [PATCH v6 08/17] bus/pci: support I/O port operations with musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (5 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 06/17] drivers: fix header includes for musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Ferruh Yigit, Yuanhan Liu, David Marchand

From: Natanael Copa <ncopa@alpinelinux.org>

Add a fallback for non-GNU libc systems like musl libc for the
non-standard functions outl_p, outw_p and outb_p.

This solves the following buildtime errors when building with musl libc:
pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
pci_uio.c:(.text+0xadf): undefined reference to `outb_p'

The non-x86 case are handled with macros to factor out various ifdefs.

Bugzilla ID: 35
Fixes: 756ce64b1ecd ("eal: introduce PCI ioport API")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/pci/linux/pci_uio.c | 91 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index f3305a2f28..1294f505be 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -489,6 +489,16 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
 }
 #endif
 
+#ifdef RTE_ARCH_X86
+#define pci_uio_inl(reg) inl(reg)
+#define pci_uio_inw(reg) inw(reg)
+#define pci_uio_inb(reg) inb(reg)
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_inl(reg) (*(volatile uint32_t *)(reg))
+#define pci_uio_inw(reg) (*(volatile uint16_t *)(reg))
+#define pci_uio_inb(reg) (*(volatile uint8_t *)(reg))
+#endif
+
 void
 pci_uio_ioport_read(struct rte_pci_ioport *p,
 		    void *data, size_t len, off_t offset)
@@ -500,29 +510,62 @@ pci_uio_ioport_read(struct rte_pci_ioport *p,
 	for (d = data; len > 0; d += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
-			*(uint32_t *)d = inl(reg);
-#else
-			*(uint32_t *)d = *(volatile uint32_t *)reg;
-#endif
+			*(uint32_t *)d = pci_uio_inl(reg);
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
-			*(uint16_t *)d = inw(reg);
-#else
-			*(uint16_t *)d = *(volatile uint16_t *)reg;
-#endif
+			*(uint16_t *)d = pci_uio_inw(reg);
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
-			*d = inb(reg);
-#else
-			*d = *(volatile uint8_t *)reg;
-#endif
+			*d = pci_uio_inb(reg);
 		}
 	}
 }
 
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outl_p(value, port);
+#else
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outl_p(value, reg) (*(volatile uint32_t *)(reg) = (value))
+#endif
+
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outw_p(value, port);
+#else
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outw_p(value, reg) (*(volatile uint16_t *)(reg) = (value))
+#endif
+
+#ifdef RTE_ARCH_X86
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+#ifdef __GLIBC__
+	outb_p(value, port);
+#else
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif
+}
+#else /* !RTE_ARCH_X86 */
+#define pci_uio_outb_p(value, reg) (*(volatile uint8_t *)(reg) = (value))
+#endif
+
 void
 pci_uio_ioport_write(struct rte_pci_ioport *p,
 		     const void *data, size_t len, off_t offset)
@@ -534,25 +577,13 @@ pci_uio_ioport_write(struct rte_pci_ioport *p,
 	for (s = data; len > 0; s += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
-			outl_p(*(const uint32_t *)s, reg);
-#else
-			*(volatile uint32_t *)reg = *(const uint32_t *)s;
-#endif
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
-			outw_p(*(const uint16_t *)s, reg);
-#else
-			*(volatile uint16_t *)reg = *(const uint16_t *)s;
-#endif
+			pci_uio_outw_p(*(const uint16_t *)s, reg);
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
-			outb_p(*s, reg);
-#else
-			*(volatile uint8_t *)reg = *s;
-#endif
+			pci_uio_outb_p(*s, reg);
 		}
 	}
 }
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 09/17] bus/dpaa: fix 64-bit arch detection
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (6 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 10/17] bus/dpaa: fix build with musl Thomas Monjalon
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Shreyansh Jain,
	Geoff Thorpe, Roy Pledge

From: Natanael Copa <ncopa@alpinelinux.org>

There is no standard saying that __WORDSIZE should be be defined or in
what include it should be defined. Use RTE_ARCH_64 instead.

This solves a warning when building with musl libc:

 warning: "__WORDSIZE" is not defined, evaluates to 0 [-Wundef]

Fixes: 847ee3bd0d1f ("bus/dpaa: support FMAN frame queue lookup")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index 10212f0fd5..7ef2f3b2e3 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -16,7 +16,7 @@ extern "C" {
 #include <rte_eventdev.h>
 
 /* FQ lookups (turn this on for 64bit user-space) */
-#if (__WORDSIZE == 64)
+#ifdef RTE_ARCH_64
 #define CONFIG_FSL_QMAN_FQ_LOOKUP
 /* if FQ lookups are supported, this controls the number of initialised,
  * s/w-consumed FQs that can be supported at any one time.
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 10/17] bus/dpaa: fix build with musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (7 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 11/17] common/dpaax/caamflib: " Thomas Monjalon
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Geoff Thorpe,
	Shreyansh Jain, Roy Pledge

From: Natanael Copa <ncopa@alpinelinux.org>

Fix build with musl libc by using warn(3) instead of using the GNU
specific error(3).

`error(0, errno, ...)` is identical to `warn(...)` so replace:

  error(0, ret, ...);

with the identical:

  errno = ret;
  warn(...);

We could have used the identical `warnx("...: %s", strerror(ret))` but
strerror(3) is not thread-safe and the strerror_r variant has two
incompatible versions, one GNU specific and one XSI-compliant. Avoid the
mess by letting `warn` use the thread-local errno.

This also fixes error message for kzmalloc failures which previously
would always have given "Unknown error -1", since that is what
strerror(-1) returns. Let 'warn' use the proper error message from errno
which is set by kzalloc.

Fixes: 9d32ef0f5d61 ("bus/dpaa: support creating dynamic HW portal")
Fixes: f09ede6c8fd1 ("bus/dpaa: add BMAN driver core")
Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c | 13 +++++++++----
 drivers/bus/dpaa/base/qbman/qman_driver.c | 17 ++++++++++++-----
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index b7009f2299..bcedbaf68f 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@
 #include <dpaa_of.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
-#include <error.h>
+#include <err.h>
 #include <net/if_arp.h>
 #include <assert.h>
 #include <unistd.h>
@@ -90,7 +90,7 @@ netcfg_acquire(void)
 	 */
 	skfd = socket(AF_PACKET, SOCK_RAW, 0);
 	if (unlikely(skfd < 0)) {
-		error(0, errno, "%s(): open(SOCK_RAW)", __func__);
+		warn("%s(): open(SOCK_RAW)", __func__);
 		return NULL;
 	}
 
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index 750b756b93..c0b9e3da77 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -11,6 +11,7 @@
 #include <process.h>
 #include "bman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
 
 /*
  * Global variables of the max portal/pool number this bman version supported
@@ -40,7 +41,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		errno = ret;
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +62,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	map.index = idx;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */
@@ -104,8 +107,10 @@ static int fsl_bman_portal_finish(void)
 	cfg = bman_destroy_affine_portal();
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		warn("process_portal_unmap()");
+	}
 	return ret;
 }
 
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index 6d9aaff164..93375d1ea8 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -9,6 +9,8 @@
 #include <process.h>
 #include "qman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
+
 #include <rte_branch_prediction.h>
 
 /* Global variable containing revision id (even on non-control plane systems
@@ -50,7 +52,8 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	map.index = index;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -96,8 +99,10 @@ static int fsl_qman_portal_finish(void)
 	cfg = qman_destroy_affine_portal(NULL);
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		warn("process_portal_unmap()");
+	}
 	return ret;
 }
 
@@ -146,7 +151,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		/* kzalloc sets errno */
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -155,7 +161,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 11/17] common/dpaax/caamflib: fix build with musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (8 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 10/17] bus/dpaa: fix build with musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Sachin Saxena, Akhil Goyal,
	Horia Geanta Neag

From: Natanael Copa <ncopa@alpinelinux.org>

The swab16/swab32/swab64 are Linux specific and not GNU libc specific.
Keep the check for __GLIBC__ just in case other GNU systems depends on
this (Hurd or GNU/kFreeBSD).

This fixes a build error with musl libc.

Fixes: 04711d41a872 ("crypto/dpaa2_sec: add run-time assembler for descriptor")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/common/dpaax/caamflib/compat.h b/drivers/common/dpaax/caamflib/compat.h
index 36ee4b5335..c1a693498d 100644
--- a/drivers/common/dpaax/caamflib/compat.h
+++ b/drivers/common/dpaax/caamflib/compat.h
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef RTE_EXEC_ENV_LINUX
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -24,7 +24,7 @@
 #error "Undefined endianness"
 #endif
 
-#else
+#else /* !RTE_EXEC_ENV_LINUX */
 #error Environment not supported!
 #endif
 
@@ -40,7 +40,7 @@
 #define __maybe_unused __rte_unused
 #endif
 
-#if defined(__GLIBC__) && !defined(pr_debug)
+#if !defined(pr_debug)
 #if !defined(SUPPRESS_PRINTS) && defined(RTA_DEBUG)
 #define pr_debug(fmt, ...) \
 	RTE_LOG(DEBUG, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -49,7 +49,7 @@
 #endif
 #endif /* pr_debug */
 
-#if defined(__GLIBC__) && !defined(pr_err)
+#if !defined(pr_err)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_err(fmt, ...) \
 	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -58,7 +58,7 @@
 #endif
 #endif /* pr_err */
 
-#if defined(__GLIBC__) && !defined(pr_warn)
+#if !defined(pr_warn)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_warn(fmt, ...) \
 	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -101,7 +101,7 @@
 #endif
 
 /* Use Linux naming convention */
-#ifdef __GLIBC__
+#if defined(RTE_EXEC_ENV_LINUX) || defined(__GLIBC__)
 	#define swab16(x) rte_bswap16(x)
 	#define swab32(x) rte_bswap32(x)
 	#define swab64(x) rte_bswap64(x)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 13/17] net/cxgbe: remove use of uint type
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (9 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 11/17] common/dpaax/caamflib: " Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 14/17] net/igc: " Thomas Monjalon
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Morten Brørup, Rahul Lakkireddy, Kumar Sanghvi

From: Natanael Copa <ncopa@alpinelinux.org>

Improve portability by replacing non-standard 'uint' with 'unsigned int'.

This solves the build error with musl libc:

In file included from ../drivers/net/cxgbe/cxgbe.h:9,
                 from ../drivers/net/cxgbe/cxgbe_ethdev.c:37:
../drivers/net/cxgbe/base/common.h:201:4: error: unknown type name 'uint'
  201 |    uint synmapen:1; /* SYN Map Enable */
      |    ^~~~

Fixes: bfcb257d3014 ("net/cxgbe: enable RSS for VF")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 202a2f4baf..ab100d784c 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -189,15 +189,15 @@ struct rss_params {
 	unsigned int mode;			/* RSS mode */
 	union {
 		struct {
-			uint synmapen:1;	/* SYN Map Enable */
-			uint syn4tupenipv6:1;	/* en 4-tuple IPv6 SYNs hash */
-			uint syn2tupenipv6:1;	/* en 2-tuple IPv6 SYNs hash */
-			uint syn4tupenipv4:1;	/* en 4-tuple IPv4 SYNs hash */
-			uint syn2tupenipv4:1;	/* en 2-tuple IPv4 SYNs hash */
-			uint ofdmapen:1;	/* Offload Map Enable */
-			uint tnlmapen:1;	/* Tunnel Map Enable */
-			uint tnlalllookup:1;	/* Tunnel All Lookup */
-			uint hashtoeplitz:1;	/* use Toeplitz hash */
+			unsigned int synmapen:1;      /* SYN Map Enable */
+			unsigned int syn4tupenipv6:1; /* en 4-tuple IPv6 SYNs hash */
+			unsigned int syn2tupenipv6:1; /* en 2-tuple IPv6 SYNs hash */
+			unsigned int syn4tupenipv4:1; /* en 4-tuple IPv4 SYNs hash */
+			unsigned int syn2tupenipv4:1; /* en 2-tuple IPv4 SYNs hash */
+			unsigned int ofdmapen:1;      /* Offload Map Enable */
+			unsigned int tnlmapen:1;      /* Tunnel Map Enable */
+			unsigned int tnlalllookup:1;  /* Tunnel All Lookup */
+			unsigned int hashtoeplitz:1;  /* use Toeplitz hash */
 		} basicvirtual;
 	} u;
 };
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 14/17] net/igc: remove use of uint type
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (10 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, David Marchand, Haiyue Wang, Jeff Guo,
	Alvin Zhang, Ferruh Yigit

Improve portability (especially with musl libc)
by replacing the non-standard type 'uint' with 'size_t'.

Fixes: 746664d546fb ("net/igc: support flow API")
Cc: stable@dpdk.org

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c
index 1bb64d323c..66053060af 100644
--- a/drivers/net/igc/igc_flow.c
+++ b/drivers/net/igc/igc_flow.c
@@ -656,7 +656,7 @@ igc_parse_action_rss(struct rte_eth_dev *dev,
  * Return the pointer of the flow, or NULL for failed
  **/
 static inline struct rte_flow *
-igc_alloc_flow(const void *filter, enum igc_filter_type type, uint inbytes)
+igc_alloc_flow(const void *filter, enum igc_filter_type type, size_t inbytes)
 {
 	/* allocate memory, 8 bytes boundary aligned */
 	struct rte_flow *flow = rte_malloc("igc flow filter",
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (11 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 14/17] net/igc: " Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 16/17] app/testpmd: fix build with musl Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Matan Azrad, Viacheslav Ovsiienko, Xueming Li,
	Maxime Coquelin

1/ The function pthread_yield() does not exist in musl libc,
and can be replaced with sched_yield() after including sched.h.

2/ The function pthread_attr_setaffinity_np() does not exist in musl libc,
and can be replaced with pthread_setaffinity_np() after pthread_create().

Fixes: b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling")
Fixes: 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling thread")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 86adc864f5..49632dfaa7 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -3,6 +3,7 @@
  */
 #include <unistd.h>
 #include <stdint.h>
+#include <sched.h>
 #include <fcntl.h>
 #include <sys/eventfd.h>
 
@@ -234,7 +235,7 @@ mlx5_vdpa_timer_sleep(struct mlx5_vdpa_priv *priv, uint32_t max)
 		usleep(priv->timer_delay_us);
 	else
 		/* Give-up CPU to improve polling threads scheduling. */
-		pthread_yield();
+		sched_yield();
 }
 
 static void *
@@ -515,17 +516,6 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 		pthread_cond_init(&priv->timer_cond, NULL);
 		priv->timer_on = 0;
 		pthread_attr_init(&attr);
-		CPU_ZERO(&cpuset);
-		if (priv->event_core != -1)
-			CPU_SET(priv->event_core, &cpuset);
-		else
-			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
-		ret = pthread_attr_setaffinity_np(&attr, sizeof(cpuset),
-						  &cpuset);
-		if (ret) {
-			DRV_LOG(ERR, "Failed to set thread affinity.");
-			return -1;
-		}
 		ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
 		if (ret) {
 			DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
@@ -542,6 +532,17 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 			DRV_LOG(ERR, "Failed to create timer thread.");
 			return -1;
 		}
+		CPU_ZERO(&cpuset);
+		if (priv->event_core != -1)
+			CPU_SET(priv->event_core, &cpuset);
+		else
+			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
+		ret = pthread_setaffinity_np(priv->timer_tid,
+					     sizeof(cpuset), &cpuset);
+		if (ret) {
+			DRV_LOG(ERR, "Failed to set thread affinity.");
+			goto error;
+		}
 		snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
 		ret = pthread_setname_np(priv->timer_tid, name);
 		if (ret) {
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 16/17] app/testpmd: fix build with musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (12 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Morten Brørup, Xiaoyun Li,
	Nélio Laranjeiro, Konstantin Ananyev, Ferruh Yigit

From: Natanael Copa <ncopa@alpinelinux.org>

1/ Improve portability by avoiding use of non-standard 'uint'.
Use uint8_t for hash_key_len as rss_key_len is a uint8_t type.
This solves following build error when building with musl libc:
    app/test-pmd/testpmd.h:813:29: error: unknown type name 'uint'

2/ In musl libc, stdout is of type (FILE * const).
Because of the const qualifier, a dark magic cast
must be achieved through uintptr_t.

Fixes: 8205e241b2b0 ("app/testpmd: add missing type to RSS hash commands")
Fixes: e977e4199a8d ("app/testpmd: add commands to load/unload BPF filters")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test-pmd/bpf_cmd.c | 2 +-
 app/test-pmd/config.c  | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 066619e115..6980291f07 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -20,7 +20,7 @@ static const struct rte_bpf_xsym bpf_xsym[] = {
 		.name = RTE_STR(stdout),
 		.type = RTE_BPF_XTYPE_VAR,
 		.var = {
-			.val = &stdout,
+			.val = (void *)(uintptr_t)&stdout,
 			.desc = {
 				.type = RTE_BPF_ARG_PTR,
 				.size = sizeof(stdout),
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dab8afe5dd..9ca03c236e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2963,7 +2963,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 
 void
 port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
-			 uint hash_key_len)
+			 uint8_t hash_key_len)
 {
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 4aca522859..5437b6229e 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -935,7 +935,7 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 
 void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
-			      uint8_t *hash_key, uint hash_key_len);
+			      uint8_t *hash_key, uint8_t hash_key_len);
 int rx_queue_id_is_invalid(queueid_t rxq_id);
 int tx_queue_id_is_invalid(queueid_t txq_id);
 void setup_gro(const char *onoff, portid_t port_id);
-- 
2.30.1


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

* [dpdk-stable] [PATCH v6 17/17] examples/bbdev: fix header include for musl
       [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
                     ` (13 preceding siblings ...)
  2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 16/17] app/testpmd: fix build with musl Thomas Monjalon
@ 2021-02-28 12:53   ` Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-02-28 12:53 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Nicolas Chautru, Amr Mokhtar

The header file unistd.h should not be included from sys/ directory,
it is an error with musl libc.

Fixes: 1ffee690eaa1 ("examples/bbdev: add sample app")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 2e170caf84..20cfd327fb 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -8,7 +8,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <sys/unistd.h>
+#include <unistd.h>
 #include <sys/queue.h>
 #include <stdarg.h>
 #include <ctype.h>
-- 
2.30.1


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

* Re: [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl
  2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
@ 2021-03-01  7:30     ` Matan Azrad
  0 siblings, 0 replies; 58+ messages in thread
From: Matan Azrad @ 2021-03-01  7:30 UTC (permalink / raw)
  To: NBU-Contact-Thomas Monjalon, dev
  Cc: ncopa, stable, Slava Ovsiienko, Xueming(Steven) Li, Maxime Coquelin



From: Thomas Monjalon
> 1/ The function pthread_yield() does not exist in musl libc, and can be replaced
> with sched_yield() after including sched.h.
> 
> 2/ The function pthread_attr_setaffinity_np() does not exist in musl libc, and
> can be replaced with pthread_setaffinity_np() after pthread_create().
> 
> Fixes: b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling")
> Fixes: 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling
> thread")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@nvidia.com>

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

* [dpdk-stable] [PATCH v7 01/17] eal: fix comment of OS-specific header files
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox Thomas Monjalon
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand,
	Bruce Richardson, Dmitry Kozlyuk, Narcisa Ana Maria Vasile,
	Dmitry Malloy, Pallavi Kadam, Anand Rawat, Harini Ramakrishnan

The same comment is on top of each rte_os.h file.
It is reworded to remove the mention of "future releases".

Fixes: 428eb983f5f7 ("eal: add OS specific header file")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/freebsd/include/rte_os.h | 5 ++---
 lib/librte_eal/linux/include/rte_os.h   | 5 ++---
 lib/librte_eal/windows/include/rte_os.h | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index eeb750cd81..c16f2a30e9 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * freebsd OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in FreeBSD.
  */
 
 #include <pthread_np.h>
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 218d4fa86e..390b87b3a1 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * linux OS. Functions will be added in future releases.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Linux.
  */
 
 #include <sched.h>
diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h
index 7ef38ff06c..f0512f20a6 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -6,9 +6,8 @@
 #define _RTE_OS_H_
 
 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * Windows OS. It must not include Windows-specific headers.
+ * This header should contain any definition
+ * which is not supported natively or named differently in Windows.
  */
 
 #include <stdarg.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-22  8:52     ` Kinsella, Ray
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 03/17] build: detect execinfo library on Linux Thomas Monjalon
                     ` (12 subsequent siblings)
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Bruce Richardson, Andrew Rybchenko,
	David Marchand, Konstantin Ananyev, Ray Kinsella, Neil Horman,
	Haiyue Wang, Adrien Mazarguil

If using busybox for mktemp and awk (as in Alpine),
some bugs prevent the script from running:

1/ It seems busybox mktemp requires the pattern to have at least
6 X and no other suffix.
The same has been fixed for other scripts in the past:
commit 3771edc35438 ("buildtools: fix build for some mktemp")

2/ It seems busybox awk does not accept the regex ^.*{
except if the opening curly brace is escaped.

Fixes: 4c82473412e8 ("build: add internal tag check")
Fixes: 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
Fixes: 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/buildtools/binutils-avx512-check.sh b/buildtools/binutils-avx512-check.sh
index a7e068140f..2a833b64b7 100755
--- a/buildtools/binutils-avx512-check.sh
+++ b/buildtools/binutils-avx512-check.sh
@@ -3,7 +3,7 @@
 # Copyright(c) 2020 Intel Corporation
 
 AS=${AS:-as}
-OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX.o)
+OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX)
 trap 'rm -f "$OBJFILE"' EXIT
 # from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028
 GATHER_PARAMS='0x8(,%ymm1,1),%ymm0{%k2}'
diff --git a/buildtools/check-symbols.sh b/buildtools/check-symbols.sh
index e407553a34..6723e38450 100755
--- a/buildtools/check-symbols.sh
+++ b/buildtools/check-symbols.sh
@@ -18,7 +18,7 @@ then
 	exit 0
 fi
 
-DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
+DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)
 trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh
index 5509b4a7fa..3bf9bd66f8 100755
--- a/buildtools/map-list-symbol.sh
+++ b/buildtools/map-list-symbol.sh
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 03/17] build: detect execinfo library on Linux
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev; +Cc: ncopa, stable, Bruce Richardson, Andrew Rybchenko, David Marchand

The library execinfo and its header file can be installed on Alpine Linux
where the backtrace feature is not part of musl libc:
	apk add libexecinfo-dev

As a consequence, this library should not be restricted to BSD only.

At the same time, the library and header are detected once and added
globally to be linked with any application, internal or external.

Fixes: 9065b1fac65f ("build: fix dependency on execinfo for BSD meson builds")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 87fc195dbf..50a53dbde8 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -21,9 +21,6 @@ apps = [
 	'test-regex',
 	'test-sad']
 
-# for BSD only
-lib_execinfo = cc.find_library('execinfo', required: false)
-
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
 default_ldflags = []
 if get_option('default_library') == 'static' and not is_windows
@@ -53,7 +50,6 @@ foreach app:apps
 			dep_objs += get_variable(get_option('default_library')
 				 + '_rte_' + d)
 		endforeach
-		dep_objs += lib_execinfo
 
 		link_libs = []
 		if get_option('default_library') == 'static'
diff --git a/app/test/meson.build b/app/test/meson.build
index 561e493a29..099895fc87 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -426,7 +426,6 @@ foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
-test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a3..66a2edcc47 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -125,11 +125,8 @@ if cc.find_library('m', required : false).found()
 	dpdk_extra_ldflags += '-lm'
 endif
 
-# for linux link against dl, for bsd execinfo
 if is_linux
 	link_lib = 'dl'
-elif is_freebsd
-	link_lib = 'execinfo'
 else
 	link_lib = ''
 endif
@@ -166,6 +163,12 @@ if fdt_dep.found() and cc.has_header('fdt.h')
 	dpdk_extra_ldflags += '-lfdt'
 endif
 
+libexecinfo = cc.find_library('libexecinfo', required: false)
+if libexecinfo.found() and cc.has_header('execinfo.h')
+	add_project_link_arguments('-lexecinfo', language: 'c')
+	dpdk_extra_ldflags += '-lexecinfo'
+endif
+
 # check for libbsd
 libbsd = dependency('libbsd', required: false, method: 'pkg-config')
 if libbsd.found()
diff --git a/examples/meson.build b/examples/meson.build
index 3fe08d4ca5..d065a6a08b 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -6,8 +6,6 @@ if get_option('default_library') == 'static'
 	link_whole_libs = dpdk_static_libraries + dpdk_drivers
 endif
 
-execinfo = cc.find_library('execinfo', required: false)
-
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
 all_examples = [
 	'bbdev_app', 'bond',
@@ -82,7 +80,7 @@ foreach example: examples
 	cflags = default_cflags
 	ldflags = default_ldflags
 
-	ext_deps = [execinfo]
+	ext_deps = []
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 04/17] build: remove redundant _GNU_SOURCE definitions
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (2 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 03/17] build: detect execinfo library on Linux Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 05/17] eal: fix build with musl Thomas Monjalon
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand, Hemant Agrawal,
	Sachin Saxena, Jakub Grajciar, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Anatoly Burakov, Konstantin Ananyev,
	Marcin Smoczynski, Xiaoyu Min, Xueming Li

The feature macro _GNU_SOURCE is defined globally,
but there was some remaining useless settings.

The internal definition in config/meson.build is kept,
all other internal definitions of _GNU_SOURCE are removed,
except in examples, which can be built as external applications.
Note: external applications do not inherit of _GNU_SOURCE.

Fixes: 5d7b673d5fd6 ("mk: build with _GNU_SOURCE defined by default")
Fixes: 28188cee2aa0 ("build: enable BSD features visibility for FreeBSD")
Fixes: e6cdc54cc0ef ("net/mlx5: add socket server for external tools")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 app/test/meson.build                     | 2 --
 drivers/bus/fslmc/qbman/include/compat.h | 3 ---
 drivers/common/dpaax/compat.h            | 4 ----
 drivers/common/dpaax/meson.build         | 1 -
 drivers/net/memif/rte_eth_memif.h        | 4 ----
 drivers/net/mlx5/linux/mlx5_socket.c     | 4 ----
 6 files changed, 18 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index 099895fc87..76eaaea457 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -398,8 +398,6 @@ if cc.has_argument('-Wno-format-truncation')
     cflags += '-Wno-format-truncation'
 endif
 
-# specify -D_GNU_SOURCE unconditionally
-cflags += '-D_GNU_SOURCE'
 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
 cflags += '-fno-strict-aliasing'
 
diff --git a/drivers/bus/fslmc/qbman/include/compat.h b/drivers/bus/fslmc/qbman/include/compat.h
index 1ddd69e127..a4471a80af 100644
--- a/drivers/bus/fslmc/qbman/include/compat.h
+++ b/drivers/bus/fslmc/qbman/include/compat.h
@@ -8,9 +8,6 @@
 #ifndef HEADER_COMPAT_H
 #define HEADER_COMPAT_H
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 1a5f36e99e..c69e76ab96 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -10,10 +10,6 @@
 #define __COMPAT_H
 
 #include <sched.h>
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <stdint.h>
 #include <stdlib.h>
 #include <stddef.h>
diff --git a/drivers/common/dpaax/meson.build b/drivers/common/dpaax/meson.build
index 4535482701..b7f177a62e 100644
--- a/drivers/common/dpaax/meson.build
+++ b/drivers/common/dpaax/meson.build
@@ -10,7 +10,6 @@ sources = files('dpaax_iova_table.c', 'dpaa_of.c', 'caamflib.c')
 
 includes += include_directories('caamflib')
 
-cflags += ['-D_GNU_SOURCE']
 if cc.has_argument('-Wno-cast-qual')
 	cflags += '-Wno-cast-qual'
 endif
diff --git a/drivers/net/memif/rte_eth_memif.h b/drivers/net/memif/rte_eth_memif.h
index 24321d3a39..2038bda742 100644
--- a/drivers/net/memif/rte_eth_memif.h
+++ b/drivers/net/memif/rte_eth_memif.h
@@ -5,10 +5,6 @@
 #ifndef _RTE_ETH_MEMIF_H_
 #define _RTE_ETH_MEMIF_H_
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif				/* GNU_SOURCE */
-
 #include <sys/queue.h>
 
 #include <ethdev_driver.h>
diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 1938453980..b1f41bc102 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,10 +2,6 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 05/17] eal: fix build with musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (3 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 07/17] common/dpaax/caamflib: " Thomas Monjalon
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand,
	Bruce Richardson, Dmitry Kozlyuk, Narcisa Ana Maria Vasile,
	Dmitry Malloy, Pallavi Kadam, Kevin Laatz, Jerin Jacob,
	Ferruh Yigit

In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
In case _GNU_SOURCE is undefined, as in eal_common_errno.c,
it was not possible to include rte_os.h which uses cpu_set_t.

This limitation is removed: if CPU_SETSIZE is not defined,
cpu_set_t related definitions and functions are skipped.
Note: such definitions are unneeded in eal_common_errno.c.

Applications which do not define _GNU_SOURCE may miss cpu_set_t related
features on musl. Such case is detected by RTE_HAS_CPUSET being undefined,
so functions which depend on rte_cpuset_t will be unavailable.

A missing include of fcntl.h is also added.

Bugzilla ID: 35
Fixes: 11b57c698005 ("eal: fix error string function")
Fixes: 176bb37ca6f3 ("eal: introduce internal wrappers for file operations")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 doc/api/doxy-api.conf.in                | 3 ++-
 lib/librte_eal/freebsd/include/rte_os.h | 1 +
 lib/librte_eal/include/rte_lcore.h      | 4 ++++
 lib/librte_eal/include/rte_thread.h     | 4 ++++
 lib/librte_eal/linux/include/rte_os.h   | 3 +++
 lib/librte_eal/unix/eal_file.c          | 1 +
 lib/librte_eal/windows/include/sched.h  | 1 +
 lib/librte_telemetry/rte_telemetry.h    | 4 ++++
 8 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 5eb31508fd..b3c5cdfeca 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -81,7 +81,8 @@ INPUT                   += @API_EXAMPLES@
 FILE_PATTERNS           = rte_*.h \
                           cmdline.h
 PREDEFINED              = __DOXYGEN__ \
-			   VFIO_PRESENT \
+                          RTE_HAS_CPUSET \
+                          VFIO_PRESENT \
                           __attribute__(x)=
 
 OPTIMIZE_OUTPUT_FOR_C   = YES
diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index c16f2a30e9..627f0483ab 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -13,6 +13,7 @@
 #include <pthread_np.h>
 
 typedef cpuset_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) do \
 { \
 	cpuset_t tmp; \
diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h
index 0fe0bd839c..1550b75da0 100644
--- a/lib/librte_eal/include/rte_lcore.h
+++ b/lib/librte_eal/include/rte_lcore.h
@@ -186,6 +186,8 @@ __rte_experimental
 int
 rte_lcore_to_cpu_id(int lcore_id);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -200,6 +202,8 @@ __rte_experimental
 rte_cpuset_t
 rte_lcore_cpuset(unsigned int lcore_id);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Test if an lcore is enabled.
  *
diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h
index e640ea1857..ac5a89b1ad 100644
--- a/lib/librte_eal/include/rte_thread.h
+++ b/lib/librte_eal/include/rte_thread.h
@@ -25,6 +25,8 @@ extern "C" {
  */
 typedef struct eal_tls_key *rte_tls_key;
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * Set core affinity of the current thread.
  * Support both EAL and non-EAL thread and update TLS.
@@ -46,6 +48,8 @@ int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
  */
 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Create a TLS data key visible to all threads in the process.
  * the created key is later used to get/set a value.
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 390b87b3a1..1618b4df22 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -12,7 +12,9 @@
 
 #include <sched.h>
 
+#ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
 typedef cpu_set_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
 #define RTE_CPU_FILL(set) do \
@@ -28,5 +30,6 @@ typedef cpu_set_t rte_cpuset_t;
 	RTE_CPU_FILL(&tmp); \
 	CPU_XOR(dst, &tmp, src); \
 } while (0)
+#endif
 
 #endif /* _RTE_OS_H_ */
diff --git a/lib/librte_eal/unix/eal_file.c b/lib/librte_eal/unix/eal_file.c
index 1b26475ba4..ec554e0096 100644
--- a/lib/librte_eal/unix/eal_file.c
+++ b/lib/librte_eal/unix/eal_file.c
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
diff --git a/lib/librte_eal/windows/include/sched.h b/lib/librte_eal/windows/include/sched.h
index fbe07f742c..ff572b5dcb 100644
--- a/lib/librte_eal/windows/include/sched.h
+++ b/lib/librte_eal/windows/include/sched.h
@@ -28,6 +28,7 @@ extern "C" {
 typedef struct _rte_cpuset_s {
 	long long _bits[_NUM_SETS(CPU_SETSIZE)];
 } rte_cpuset_t;
+#define RTE_HAS_CPUSET
 
 #define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << _WHICH_BIT(b)))
 
diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h
index f7c8534b82..027b048d78 100644
--- a/lib/librte_telemetry/rte_telemetry.h
+++ b/lib/librte_telemetry/rte_telemetry.h
@@ -292,6 +292,8 @@ __rte_experimental
 int
 rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @internal
  * Initialize Telemetry.
@@ -314,6 +316,8 @@ int
 rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset,
 		const char **err_str);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Get a pointer to a container with memory allocated. The container is to be
  * used embedded within an existing telemetry dict/array.
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 07/17] common/dpaax/caamflib: fix build with musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (4 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 05/17] eal: fix build with musl Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Andrew Rybchenko, David Marchand,
	Sachin Saxena, Akhil Goyal, Horia Geanta Neag

From: Natanael Copa <ncopa@alpinelinux.org>

The swab16/swab32/swab64 are Linux specific and not GNU libc specific.
Keep the check for __GLIBC__ just in case other GNU systems depends on
this (Hurd or GNU/kFreeBSD).

This fixes a build error with musl libc.

Fixes: 04711d41a872 ("crypto/dpaa2_sec: add run-time assembler for descriptor")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/common/dpaax/caamflib/compat.h b/drivers/common/dpaax/caamflib/compat.h
index 36ee4b5335..c1a693498d 100644
--- a/drivers/common/dpaax/caamflib/compat.h
+++ b/drivers/common/dpaax/caamflib/compat.h
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef RTE_EXEC_ENV_LINUX
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -24,7 +24,7 @@
 #error "Undefined endianness"
 #endif
 
-#else
+#else /* !RTE_EXEC_ENV_LINUX */
 #error Environment not supported!
 #endif
 
@@ -40,7 +40,7 @@
 #define __maybe_unused __rte_unused
 #endif
 
-#if defined(__GLIBC__) && !defined(pr_debug)
+#if !defined(pr_debug)
 #if !defined(SUPPRESS_PRINTS) && defined(RTA_DEBUG)
 #define pr_debug(fmt, ...) \
 	RTE_LOG(DEBUG, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -49,7 +49,7 @@
 #endif
 #endif /* pr_debug */
 
-#if defined(__GLIBC__) && !defined(pr_err)
+#if !defined(pr_err)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_err(fmt, ...) \
 	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -58,7 +58,7 @@
 #endif
 #endif /* pr_err */
 
-#if defined(__GLIBC__) && !defined(pr_warn)
+#if !defined(pr_warn)
 #if !defined(SUPPRESS_PRINTS)
 #define pr_warn(fmt, ...) \
 	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
@@ -101,7 +101,7 @@
 #endif
 
 /* Use Linux naming convention */
-#ifdef __GLIBC__
+#if defined(RTE_EXEC_ENV_LINUX) || defined(__GLIBC__)
 	#define swab16(x) rte_bswap16(x)
 	#define swab32(x) rte_bswap32(x)
 	#define swab64(x) rte_bswap64(x)
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 09/17] bus/dpaa: fix 64-bit arch detection
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (5 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 07/17] common/dpaax/caamflib: " Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 10/17] bus/dpaa: fix build with musl Thomas Monjalon
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Hemant Agrawal, Andrew Rybchenko, David Marchand,
	Sachin Saxena, Roy Pledge, Geoff Thorpe, Shreyansh Jain

From: Natanael Copa <ncopa@alpinelinux.org>

There is no standard saying that __WORDSIZE should be be defined or in
what include it should be defined. Use RTE_ARCH_64 instead.

This solves a warning when building with musl libc:

 warning: "__WORDSIZE" is not defined, evaluates to 0 [-Wundef]

Fixes: 847ee3bd0d1f ("bus/dpaa: support FMAN frame queue lookup")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index 10212f0fd5..7ef2f3b2e3 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -16,7 +16,7 @@ extern "C" {
 #include <rte_eventdev.h>
 
 /* FQ lookups (turn this on for 64bit user-space) */
-#if (__WORDSIZE == 64)
+#ifdef RTE_ARCH_64
 #define CONFIG_FSL_QMAN_FQ_LOOKUP
 /* if FQ lookups are supported, this controls the number of initialised,
  * s/w-consumed FQs that can be supported at any one time.
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 10/17] bus/dpaa: fix build with musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (6 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 11/17] bus/pci: support I/O port operations " Thomas Monjalon
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand, Hemant Agrawal,
	Sachin Saxena, Roy Pledge, Shreyansh Jain, Geoff Thorpe

From: Natanael Copa <ncopa@alpinelinux.org>

The header files argp.h and error.h do not exist in musl libc.

Fix build with musl libc by using err(3) instead of
the GNU-specific error(3).

We could have used the identical errx("...: %s", strerror(ret))` but
strerror(3) is not thread-safe and the strerror_r variant has two
incompatible versions, one GNU specific and one XSI-compliant.
Avoid the mess by letting "err" use the thread-local errno.

This also fixes error message for kzmalloc failures which previously
would always have given "Unknown error -1", since that is what
strerror(-1) returns. Let "err" use the proper error message from errno
which is set by kzalloc.

Fixes: 9d32ef0f5d61 ("bus/dpaa: support creating dynamic HW portal")
Fixes: f09ede6c8fd1 ("bus/dpaa: add BMAN driver core")
Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Fixes: 39f373cf015a ("bus/dpaa: add compatibility and helper macros")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c | 13 +++++++++----
 drivers/bus/dpaa/base/qbman/qman_driver.c | 17 ++++++++++++-----
 drivers/bus/dpaa/include/netcfg.h         |  1 -
 drivers/common/dpaax/compat.h             |  1 -
 5 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index b7009f2299..120deb0bb6 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@
 #include <dpaa_of.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
-#include <error.h>
+#include <err.h>
 #include <net/if_arp.h>
 #include <assert.h>
 #include <unistd.h>
@@ -90,7 +90,7 @@ netcfg_acquire(void)
 	 */
 	skfd = socket(AF_PACKET, SOCK_RAW, 0);
 	if (unlikely(skfd < 0)) {
-		error(0, errno, "%s(): open(SOCK_RAW)", __func__);
+		err(0, "%s(): open(SOCK_RAW)", __func__);
 		return NULL;
 	}
 
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index 750b756b93..ee35e03da1 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -11,6 +11,7 @@
 #include <process.h>
 #include "bman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
 
 /*
  * Global variables of the max portal/pool number this bman version supported
@@ -40,7 +41,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		errno = ret;
+		err(0, "pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +62,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	map.index = idx;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		err(0, "process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */
@@ -104,8 +107,10 @@ static int fsl_bman_portal_finish(void)
 	cfg = bman_destroy_affine_portal();
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		err(0, "process_portal_unmap()");
+	}
 	return ret;
 }
 
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index 6d9aaff164..dfbafe581a 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -9,6 +9,8 @@
 #include <process.h>
 #include "qman_priv.h"
 #include <sys/ioctl.h>
+#include <err.h>
+
 #include <rte_branch_prediction.h>
 
 /* Global variable containing revision id (even on non-control plane systems
@@ -50,7 +52,8 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	map.index = index;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		err(0, "process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -96,8 +99,10 @@ static int fsl_qman_portal_finish(void)
 	cfg = qman_destroy_affine_portal(NULL);
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
-	if (ret)
-		error(0, ret, "process_portal_unmap()");
+	if (ret) {
+		errno = ret;
+		err(0, "process_portal_unmap()");
+	}
 	return ret;
 }
 
@@ -146,7 +151,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		/* kzalloc sets errno */
+		err(0, "q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -155,7 +161,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		errno = ret;
+		err(0, "process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
diff --git a/drivers/bus/dpaa/include/netcfg.h b/drivers/bus/dpaa/include/netcfg.h
index d7d1befd24..bb18a34e3d 100644
--- a/drivers/bus/dpaa/include/netcfg.h
+++ b/drivers/bus/dpaa/include/netcfg.h
@@ -9,7 +9,6 @@
 #define __NETCFG_H
 
 #include <fman.h>
-#include <argp.h>
 
 /* Configuration information related to a specific ethernet port */
 struct fm_eth_port_cfg {
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index c69e76ab96..7166f8cceb 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -30,7 +30,6 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 11/17] bus/pci: support I/O port operations with musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (7 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 10/17] bus/dpaa: fix build with musl Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 12/17] net/cxgbe: remove use of uint type Thomas Monjalon
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand, Ferruh Yigit,
	Yuanhan Liu, David Marchand

Add a fallback for non-GNU libc systems like musl libc for the
non-standard functions outl_p, outw_p and outb_p.

It solves the following errors when building with musl libc:
	pci_uio.c: undefined reference to 'outw_p'
	pci_uio.c: undefined reference to 'outl_p'
	pci_uio.c: undefined reference to 'outb_p'

Bugzilla ID: 35
Fixes: 756ce64b1ecd ("eal: introduce PCI ioport API")
Cc: stable@dpdk.org

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/pci/linux/pci_uio.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 0907051e04..39ebeac2a0 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -526,13 +526,18 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
 #endif
 
 #if defined(RTE_ARCH_X86)
+
 static inline uint8_t ioread8(void *addr)
 {
 	uint8_t val;
 
 	val = (uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint8_t *)addr :
+#ifdef __GLIBC__
 		inb_p((unsigned long)addr);
+#else
+		inb((unsigned long)addr);
+#endif
 
 	return val;
 }
@@ -543,7 +548,11 @@ static inline uint16_t ioread16(void *addr)
 
 	val = (uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint16_t *)addr :
+#ifdef __GLIBC__
 		inw_p((unsigned long)addr);
+#else
+		inw((unsigned long)addr);
+#endif
 
 	return val;
 }
@@ -554,7 +563,11 @@ static inline uint32_t ioread32(void *addr)
 
 	val = (uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint32_t *)addr :
+#ifdef __GLIBC__
 		inl_p((unsigned long)addr);
+#else
+		inl((unsigned long)addr);
+#endif
 
 	return val;
 }
@@ -563,23 +576,37 @@ static inline void iowrite8(uint8_t val, void *addr)
 {
 	(uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint8_t *)addr = val :
+#ifdef __GLIBC__
 		outb_p(val, (unsigned long)addr);
+#else
+		outb(val, (unsigned long)addr);
+#endif
 }
 
 static inline void iowrite16(uint16_t val, void *addr)
 {
 	(uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint16_t *)addr = val :
+#ifdef __GLIBC__
 		outw_p(val, (unsigned long)addr);
+#else
+		outw(val, (unsigned long)addr);
+#endif
 }
 
 static inline void iowrite32(uint32_t val, void *addr)
 {
 	(uint64_t)(uintptr_t)addr >= PIO_MAX ?
 		*(volatile uint32_t *)addr = val :
+#ifdef __GLIBC__
 		outl_p(val, (unsigned long)addr);
-}
 #else
+		outl(val, (unsigned long)addr);
+#endif
+}
+
+#else /* !RTE_ARCH_X86 */
+
 static inline uint8_t ioread8(void *addr)
 {
 	return *(volatile uint8_t *)addr;
@@ -609,7 +636,8 @@ static inline void iowrite32(uint32_t val, void *addr)
 {
 	*(volatile uint32_t *)addr = val;
 }
-#endif
+
+#endif /* !RTE_ARCH_X86 */
 
 void
 pci_uio_ioport_read(struct rte_pci_ioport *p,
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 12/17] net/cxgbe: remove use of uint type
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (8 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 11/17] bus/pci: support I/O port operations " Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 13/17] net/igc: " Thomas Monjalon
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Morten Brørup, Andrew Rybchenko,
	David Marchand, Rahul Lakkireddy, Kumar Sanghvi

From: Natanael Copa <ncopa@alpinelinux.org>

Improve portability by replacing non-standard 'uint' with 'unsigned int'.

This solves the build error with musl libc:

In file included from ../drivers/net/cxgbe/cxgbe.h:9,
                 from ../drivers/net/cxgbe/cxgbe_ethdev.c:37:
../drivers/net/cxgbe/base/common.h:201:4: error: unknown type name 'uint'
  201 |    uint synmapen:1; /* SYN Map Enable */
      |    ^~~~

Fixes: bfcb257d3014 ("net/cxgbe: enable RSS for VF")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 202a2f4baf..ab100d784c 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -189,15 +189,15 @@ struct rss_params {
 	unsigned int mode;			/* RSS mode */
 	union {
 		struct {
-			uint synmapen:1;	/* SYN Map Enable */
-			uint syn4tupenipv6:1;	/* en 4-tuple IPv6 SYNs hash */
-			uint syn2tupenipv6:1;	/* en 2-tuple IPv6 SYNs hash */
-			uint syn4tupenipv4:1;	/* en 4-tuple IPv4 SYNs hash */
-			uint syn2tupenipv4:1;	/* en 2-tuple IPv4 SYNs hash */
-			uint ofdmapen:1;	/* Offload Map Enable */
-			uint tnlmapen:1;	/* Tunnel Map Enable */
-			uint tnlalllookup:1;	/* Tunnel All Lookup */
-			uint hashtoeplitz:1;	/* use Toeplitz hash */
+			unsigned int synmapen:1;      /* SYN Map Enable */
+			unsigned int syn4tupenipv6:1; /* en 4-tuple IPv6 SYNs hash */
+			unsigned int syn2tupenipv6:1; /* en 2-tuple IPv6 SYNs hash */
+			unsigned int syn4tupenipv4:1; /* en 4-tuple IPv4 SYNs hash */
+			unsigned int syn2tupenipv4:1; /* en 2-tuple IPv4 SYNs hash */
+			unsigned int ofdmapen:1;      /* Offload Map Enable */
+			unsigned int tnlmapen:1;      /* Tunnel Map Enable */
+			unsigned int tnlalllookup:1;  /* Tunnel All Lookup */
+			unsigned int hashtoeplitz:1;  /* use Toeplitz hash */
 		} basicvirtual;
 	} u;
 };
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 13/17] net/igc: remove use of uint type
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (9 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 12/17] net/cxgbe: remove use of uint type Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, David Marchand, Haiyue Wang, Andrew Rybchenko,
	Jeff Guo, Ferruh Yigit, Alvin Zhang

Improve portability (especially with musl libc)
by replacing the non-standard type 'uint' with 'size_t'.

Fixes: 746664d546fb ("net/igc: support flow API")
Cc: stable@dpdk.org

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c
index 1bb64d323c..66053060af 100644
--- a/drivers/net/igc/igc_flow.c
+++ b/drivers/net/igc/igc_flow.c
@@ -656,7 +656,7 @@ igc_parse_action_rss(struct rte_eth_dev *dev,
  * Return the pointer of the flow, or NULL for failed
  **/
 static inline struct rte_flow *
-igc_alloc_flow(const void *filter, enum igc_filter_type type, uint inbytes)
+igc_alloc_flow(const void *filter, enum igc_filter_type type, size_t inbytes)
 {
 	/* allocate memory, 8 bytes boundary aligned */
 	struct rte_flow *flow = rte_malloc("igc flow filter",
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (10 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 13/17] net/igc: " Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl Thomas Monjalon
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Matan Azrad, Andrew Rybchenko, David Marchand,
	Viacheslav Ovsiienko, Xueming Li, Maxime Coquelin

1/ The function pthread_yield() does not exist in musl libc,
and can be replaced with sched_yield() after including sched.h.

2/ The function pthread_attr_setaffinity_np() does not exist in musl libc,
and can be replaced with pthread_setaffinity_np() after pthread_create().

Fixes: b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling")
Fixes: 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling thread")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@nvidia.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 86adc864f5..49632dfaa7 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -3,6 +3,7 @@
  */
 #include <unistd.h>
 #include <stdint.h>
+#include <sched.h>
 #include <fcntl.h>
 #include <sys/eventfd.h>
 
@@ -234,7 +235,7 @@ mlx5_vdpa_timer_sleep(struct mlx5_vdpa_priv *priv, uint32_t max)
 		usleep(priv->timer_delay_us);
 	else
 		/* Give-up CPU to improve polling threads scheduling. */
-		pthread_yield();
+		sched_yield();
 }
 
 static void *
@@ -515,17 +516,6 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 		pthread_cond_init(&priv->timer_cond, NULL);
 		priv->timer_on = 0;
 		pthread_attr_init(&attr);
-		CPU_ZERO(&cpuset);
-		if (priv->event_core != -1)
-			CPU_SET(priv->event_core, &cpuset);
-		else
-			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
-		ret = pthread_attr_setaffinity_np(&attr, sizeof(cpuset),
-						  &cpuset);
-		if (ret) {
-			DRV_LOG(ERR, "Failed to set thread affinity.");
-			return -1;
-		}
 		ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
 		if (ret) {
 			DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
@@ -542,6 +532,17 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 			DRV_LOG(ERR, "Failed to create timer thread.");
 			return -1;
 		}
+		CPU_ZERO(&cpuset);
+		if (priv->event_core != -1)
+			CPU_SET(priv->event_core, &cpuset);
+		else
+			cpuset = rte_lcore_cpuset(rte_get_main_lcore());
+		ret = pthread_setaffinity_np(priv->timer_tid,
+					     sizeof(cpuset), &cpuset);
+		if (ret) {
+			DRV_LOG(ERR, "Failed to set thread affinity.");
+			goto error;
+		}
 		snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
 		ret = pthread_setname_np(priv->timer_tid, name);
 		if (ret) {
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (11 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 15:47     ` McDaniel, Timothy
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 16/17] app/testpmd: fix build with musl Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand,
	Timothy McDaniel, Gage Eads

The header file fcntl.h should not be included from sys/ directory
as done in dlb drivers, it is an error with musl libc.

Fixes: 19980083fd57 ("event/dlb: add eventdev probe")
Fixes: 5433956d5185 ("event/dlb2: add eventdev probe")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/event/dlb/dlb.c         | 2 +-
 drivers/event/dlb/pf/dlb_pf.c   | 3 ++-
 drivers/event/dlb2/dlb2.c       | 2 +-
 drivers/event/dlb2/pf/dlb2_pf.c | 3 ++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/event/dlb/dlb.c b/drivers/event/dlb/dlb.c
index 1174ab3d2b..60084ced3b 100644
--- a/drivers/event/dlb/dlb.c
+++ b/drivers/event/dlb/dlb.c
@@ -10,7 +10,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
diff --git a/drivers/event/dlb/pf/dlb_pf.c b/drivers/event/dlb/pf/dlb_pf.c
index 2f7e30abbd..5445c2d57d 100644
--- a/drivers/event/dlb/pf/dlb_pf.c
+++ b/drivers/event/dlb/pf/dlb_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index b28ec58bfb..fb5ff012a4 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -11,7 +11,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #include <rte_common.h>
 #include <rte_config.h>
diff --git a/drivers/event/dlb2/pf/dlb2_pf.c b/drivers/event/dlb2/pf/dlb2_pf.c
index 1142da5b25..cfb22efe8a 100644
--- a/drivers/event/dlb2/pf/dlb2_pf.c
+++ b/drivers/event/dlb2/pf/dlb2_pf.c
@@ -6,12 +6,13 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/mman.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_dev.h>
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 16/17] app/testpmd: fix build with musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (12 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Morten Brørup, Andrew Rybchenko,
	David Marchand, Xiaoyun Li, Nélio Laranjeiro,
	Konstantin Ananyev, Ferruh Yigit

From: Natanael Copa <ncopa@alpinelinux.org>

1/ Improve portability by avoiding use of non-standard 'uint'.
Use uint8_t for hash_key_len as rss_key_len is a uint8_t type.
This solves following build error when building with musl libc:
    app/test-pmd/testpmd.h:813:29: error: unknown type name 'uint'

2/ In musl libc, stdout is of type (FILE * const).
Because of the const qualifier, a dark magic cast
must be achieved through uintptr_t.

Fixes: 8205e241b2b0 ("app/testpmd: add missing type to RSS hash commands")
Fixes: e977e4199a8d ("app/testpmd: add commands to load/unload BPF filters")
Cc: stable@dpdk.org

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 app/test-pmd/bpf_cmd.c | 2 +-
 app/test-pmd/config.c  | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 066619e115..6980291f07 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -20,7 +20,7 @@ static const struct rte_bpf_xsym bpf_xsym[] = {
 		.name = RTE_STR(stdout),
 		.type = RTE_BPF_XTYPE_VAR,
 		.var = {
-			.val = &stdout,
+			.val = (void *)(uintptr_t)&stdout,
 			.desc = {
 				.type = RTE_BPF_ARG_PTR,
 				.size = sizeof(stdout),
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 576d5acab5..e865de10a4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2674,7 +2674,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 
 void
 port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
-			 uint hash_key_len)
+			 uint8_t hash_key_len)
 {
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index af40859170..a87ccb0f0f 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -936,7 +936,7 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 
 void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
-			      uint8_t *hash_key, uint hash_key_len);
+			      uint8_t *hash_key, uint8_t hash_key_len);
 int rx_queue_id_is_invalid(queueid_t rxq_id);
 int tx_queue_id_is_invalid(queueid_t txq_id);
 void setup_gro(const char *onoff, portid_t port_id);
-- 
2.30.1


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

* [dpdk-stable] [PATCH v7 17/17] examples/bbdev: fix header include for musl
       [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
                     ` (13 preceding siblings ...)
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 16/17] app/testpmd: fix build with musl Thomas Monjalon
@ 2021-03-19 14:57   ` Thomas Monjalon
  14 siblings, 0 replies; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-19 14:57 UTC (permalink / raw)
  To: dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand, Nicolas Chautru,
	Amr Mokhtar

The header file unistd.h should not be included from sys/ directory,
it is an error with musl libc.

Fixes: 1ffee690eaa1 ("examples/bbdev: add sample app")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 2e170caf84..20cfd327fb 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -8,7 +8,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <sys/unistd.h>
+#include <unistd.h>
 #include <sys/queue.h>
 #include <stdarg.h>
 #include <ctype.h>
-- 
2.30.1


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

* Re: [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl Thomas Monjalon
@ 2021-03-19 15:47     ` McDaniel, Timothy
  0 siblings, 0 replies; 58+ messages in thread
From: McDaniel, Timothy @ 2021-03-19 15:47 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: ncopa, stable, Andrew Rybchenko, David Marchand, Gage Eads



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, March 19, 2021 9:57 AM
> To: dev@dpdk.org
> Cc: ncopa@alpinelinux.org; stable@dpdk.org; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>; David Marchand
> <david.marchand@redhat.com>; McDaniel, Timothy
> <timothy.mcdaniel@intel.com>; Gage Eads <gage.eads@intel.com>
> Subject: [PATCH v7 15/17] event/dlb: fix header includes for musl
> 
> The header file fcntl.h should not be included from sys/ directory
> as done in dlb drivers, it is an error with musl libc.
> 
> Fixes: 19980083fd57 ("event/dlb: add eventdev probe")
> Fixes: 5433956d5185 ("event/dlb2: add eventdev probe")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Acked-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/event/dlb/dlb.c         | 2 +-
>  drivers/event/dlb/pf/dlb_pf.c   | 3 ++-
>  drivers/event/dlb2/dlb2.c       | 2 +-
>  drivers/event/dlb2/pf/dlb2_pf.c | 3 ++-
>  4 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/event/dlb/dlb.c b/drivers/event/dlb/dlb.c
> index 1174ab3d2b..60084ced3b 100644
> --- a/drivers/event/dlb/dlb.c
> +++ b/drivers/event/dlb/dlb.c
> @@ -10,7 +10,7 @@
>  #include <stdint.h>
>  #include <stdio.h>
>  #include <string.h>
> -#include <sys/fcntl.h>
> +#include <fcntl.h>
>  #include <sys/mman.h>
>  #include <unistd.h>
> 
> diff --git a/drivers/event/dlb/pf/dlb_pf.c b/drivers/event/dlb/pf/dlb_pf.c
> index 2f7e30abbd..5445c2d57d 100644
> --- a/drivers/event/dlb/pf/dlb_pf.c
> +++ b/drivers/event/dlb/pf/dlb_pf.c
> @@ -6,12 +6,13 @@
>  #include <stdbool.h>
>  #include <stdio.h>
>  #include <sys/mman.h>
> -#include <sys/fcntl.h>
> +#include <fcntl.h>
>  #include <sys/time.h>
>  #include <errno.h>
>  #include <assert.h>
>  #include <unistd.h>
>  #include <string.h>
> +
>  #include <rte_debug.h>
>  #include <rte_log.h>
>  #include <rte_dev.h>
> diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
> index b28ec58bfb..fb5ff012a4 100644
> --- a/drivers/event/dlb2/dlb2.c
> +++ b/drivers/event/dlb2/dlb2.c
> @@ -11,7 +11,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <sys/mman.h>
> -#include <sys/fcntl.h>
> +#include <fcntl.h>
> 
>  #include <rte_common.h>
>  #include <rte_config.h>
> diff --git a/drivers/event/dlb2/pf/dlb2_pf.c b/drivers/event/dlb2/pf/dlb2_pf.c
> index 1142da5b25..cfb22efe8a 100644
> --- a/drivers/event/dlb2/pf/dlb2_pf.c
> +++ b/drivers/event/dlb2/pf/dlb2_pf.c
> @@ -6,12 +6,13 @@
>  #include <stdbool.h>
>  #include <stdio.h>
>  #include <sys/mman.h>
> -#include <sys/fcntl.h>
> +#include <fcntl.h>
>  #include <sys/time.h>
>  #include <errno.h>
>  #include <assert.h>
>  #include <unistd.h>
>  #include <string.h>
> +
>  #include <rte_debug.h>
>  #include <rte_log.h>
>  #include <rte_dev.h>
> --
> 2.30.1

ack


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

* Re: [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox
  2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox Thomas Monjalon
@ 2021-03-22  8:52     ` Kinsella, Ray
  2021-03-22  8:55       ` Thomas Monjalon
  0 siblings, 1 reply; 58+ messages in thread
From: Kinsella, Ray @ 2021-03-22  8:52 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: ncopa, stable, Bruce Richardson, Andrew Rybchenko,
	David Marchand, Konstantin Ananyev, Neil Horman, Haiyue Wang,
	Adrien Mazarguil



On 19/03/2021 14:57, Thomas Monjalon wrote:
> If using busybox for mktemp and awk (as in Alpine),
> some bugs prevent the script from running:
> 
> 1/ It seems busybox mktemp requires the pattern to have at least
> 6 X and no other suffix.
> The same has been fixed for other scripts in the past:
> commit 3771edc35438 ("buildtools: fix build for some mktemp")
> 
> 2/ It seems busybox awk does not accept the regex ^.*{
> except if the opening curly brace is escaped.
> 
> Fixes: 4c82473412e8 ("build: add internal tag check")
> Fixes: 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
> Fixes: 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Acked-by: David Marchand <david.marchand@redhat.com>
> ---
>  buildtools/binutils-avx512-check.sh | 2 +-
>  buildtools/check-symbols.sh         | 2 +-
>  buildtools/map-list-symbol.sh       | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/buildtools/binutils-avx512-check.sh b/buildtools/binutils-avx512-check.sh
> index a7e068140f..2a833b64b7 100755
> --- a/buildtools/binutils-avx512-check.sh
> +++ b/buildtools/binutils-avx512-check.sh
> @@ -3,7 +3,7 @@
>  # Copyright(c) 2020 Intel Corporation
>  
>  AS=${AS:-as}
> -OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX.o)
> +OBJFILE=$(mktemp -t dpdk.binutils-check.XXXXXX)
>  trap 'rm -f "$OBJFILE"' EXIT
>  # from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028
>  GATHER_PARAMS='0x8(,%ymm1,1),%ymm0{%k2}'
> diff --git a/buildtools/check-symbols.sh b/buildtools/check-symbols.sh
> index e407553a34..6723e38450 100755
> --- a/buildtools/check-symbols.sh
> +++ b/buildtools/check-symbols.sh
> @@ -18,7 +18,7 @@ then
>  	exit 0
>  fi
>  
> -DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
> +DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)

Does it make sense to change it to

DUMPFILE=$(mktemp -t dpdk.${0##*/}.objdump.XXXXXX) 

So we can preserve what the file is in the filename?

>  trap 'rm -f "$DUMPFILE"' EXIT
>  objdump -t $OBJFILE >$DUMPFILE
>  
> diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh
> index 5509b4a7fa..3bf9bd66f8 100755
> --- a/buildtools/map-list-symbol.sh
> +++ b/buildtools/map-list-symbol.sh
> @@ -44,7 +44,7 @@ for file in $@; do
>  			ret = 1;
>  		}
>  	}
> -	/^.*{/ {
> +	/^.*\{/ {
>  		if ("'$section'" == "all" || $1 == "'$section'") {
>  			current_section = $1;
>  		}
> 

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

* Re: [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox
  2021-03-22  8:52     ` Kinsella, Ray
@ 2021-03-22  8:55       ` Thomas Monjalon
  2021-03-22  9:01         ` Kinsella, Ray
  0 siblings, 1 reply; 58+ messages in thread
From: Thomas Monjalon @ 2021-03-22  8:55 UTC (permalink / raw)
  To: Kinsella, Ray
  Cc: dev, ncopa, stable, Bruce Richardson, Andrew Rybchenko,
	David Marchand, Konstantin Ananyev, Haiyue Wang,
	Adrien Mazarguil

22/03/2021 09:52, Kinsella, Ray:
> On 19/03/2021 14:57, Thomas Monjalon wrote:
> > --- a/buildtools/check-symbols.sh
> > +++ b/buildtools/check-symbols.sh
> > -DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
> > +DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)
> 
> Does it make sense to change it to
> 
> DUMPFILE=$(mktemp -t dpdk.${0##*/}.objdump.XXXXXX)
> 
> So we can preserve what the file is in the filename?

Yes could be.
There is already the name of the script in the temp filename,
but I am OK to add more details.

If there is no other comment, I will change when applying.



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

* Re: [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox
  2021-03-22  8:55       ` Thomas Monjalon
@ 2021-03-22  9:01         ` Kinsella, Ray
  0 siblings, 0 replies; 58+ messages in thread
From: Kinsella, Ray @ 2021-03-22  9:01 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, ncopa, stable, Bruce Richardson, Andrew Rybchenko,
	David Marchand, Konstantin Ananyev, Haiyue Wang,
	Adrien Mazarguil



On 22/03/2021 08:55, Thomas Monjalon wrote:
> 22/03/2021 09:52, Kinsella, Ray:
>> On 19/03/2021 14:57, Thomas Monjalon wrote:
>>> --- a/buildtools/check-symbols.sh
>>> +++ b/buildtools/check-symbols.sh
>>> -DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
>>> +DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXXXXX)
>>
>> Does it make sense to change it to
>>
>> DUMPFILE=$(mktemp -t dpdk.${0##*/}.objdump.XXXXXX)
>>
>> So we can preserve what the file is in the filename?
> 
> Yes could be.
> There is already the name of the script in the temp filename,
> but I am OK to add more details.
> 
> If there is no other comment, I will change when applying.
> 
Nothing from me ...
 

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

end of thread, other threads:[~2021-03-22  9:01 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190313170657.16688-1-ncopa@alpinelinux.org>
     [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-02-26  9:11     ` Bruce Richardson
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-02-26  9:08     ` Bruce Richardson
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally Thomas Monjalon
2021-02-26  9:08     ` Bruce Richardson
2021-02-26  9:40       ` Thomas Monjalon
2021-02-26  9:46         ` Bruce Richardson
2021-02-26 10:04           ` Thomas Monjalon
2021-02-28 12:53             ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 05/17] eal/linux: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 06/17] drivers: fix header includes for musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 11/17] common/dpaax/caamflib: " Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 14/17] net/igc: " Thomas Monjalon
2021-02-26  0:49     ` Wang, Haiyue
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-03-01  7:30     ` Matan Azrad
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
     [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 05/17] eal: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 06/17] drivers: fix header includes for musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 11/17] common/dpaax/caamflib: " Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 14/17] net/igc: " Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
     [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-03-22  8:52     ` Kinsella, Ray
2021-03-22  8:55       ` Thomas Monjalon
2021-03-22  9:01         ` Kinsella, Ray
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 05/17] eal: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 07/17] common/dpaax/caamflib: " Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 11/17] bus/pci: support I/O port operations " Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 12/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 13/17] net/igc: " Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl Thomas Monjalon
2021-03-19 15:47     ` McDaniel, Timothy
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 17/17] examples/bbdev: fix header include for musl Thomas Monjalon

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/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 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


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