Skip to contentSkip to conversation

Build fixes for musl libc

PATCH NAK Natanael Copa 16 participants 130 messages Mar 13, 2019 – Mar 23, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v3 cover Build fixes for musl libc

A set of patches to fix build with musl libc. I also did a few cleanups wrt macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch
v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

Natanael Copa (15):
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/fslmc: fix compile error with musl libc
bus/fslmc: remove unused include of error.h
net/nfp: build fix for musl libc
app/test: include fcntl.h due to use of O_RDONLY app/test: fix setting of -D_GNU_SOURCE with meson bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros net/netvsc: fix compile warning for fcntl.h include eal/linux: simplify debug message in sigbus_handler

 app/test-pmd/testpmd.h                     |  2 +-
 app/test/meson.build                       |  2 +-
 app/test/test_eal_flags.c                  |  1 +
 drivers/bus/dpaa/base/fman/netcfg_layer.c  |  4 +-
 drivers/bus/dpaa/base/qbman/bman_driver.c  |  6 +-
 drivers/bus/dpaa/base/qbman/qman_driver.c  | 12 ++--
 drivers/bus/dpaa/include/compat.h          |  2 +-
 drivers/bus/dpaa/include/fsl_qman.h        |  3 +-
 drivers/bus/fslmc/qbman/include/compat.h   |  2 +-
 drivers/bus/pci/linux/pci_uio.c            | 82 ++++++++++++++--------
 drivers/crypto/dpaa2_sec/hw/compat.h       | 36 +++++-----
 drivers/net/cxgbe/base/common.h            | 18 ++---
 drivers/net/netvsc/hn_vf.c                 |  2 +-
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |  2 +
 lib/librte_eal/linux/eal/eal_dev.c         |  4 +-
 15 files changed, 99 insertions(+), 79 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/15 app/testpmd: replace uint with unsigned int

Improve portability by avoid use non-standard 'uint'.

This fixes following build error when building with musl libc:

In file included from ../app/test-pmd/cmdline.c:75:
../app/test-pmd/testpmd.h:809:29: error: unknown type name 'uint'; did you mean 'int'?

          uint8_t *hash_key, uint hash_key_len);
                             ^~~~
                             int
---
 app/test-pmd/testpmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.h +1 -1
index fa4887853..84ef3fc30 100644
@@ -806,7 +806,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, unsigned int 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);
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH v3 01/15] app/testpmd: replace uint with unsigned int

Hi Nataneal,

Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Natanael Copa
Sent: Wednesday, March 13, 2019 5:07 PM
To: [email protected]
Cc: Natanael Copa <[email protected]>
Subject: [dpdk-dev] [PATCH v3 01/15] app/testpmd: replace uint with unsigned int

This should have the fix keyword in the commit line and a fixes line should be added. Suggest something like the following:

" app/testpmd: fix build error with musl libc"

Quoted 11 lines

Improve portability by avoid use non-standard 'uint'.

This fixes following build error when building with musl libc:

In file included from ../app/test-pmd/cmdline.c:75:
../app/test-pmd/testpmd.h:809:29: error: unknown type name 'uint'; did you mean 'int'?

          uint8_t *hash_key, uint hash_key_len);
                             ^~~~
                             int

./dpdk /devtools/check-git-log.sh -1
Line too long:

        ../app/test-pmd/testpmd.h:809:29: error: unknown type name 'uint'; did you mean 'int'?

Wrong tag:
This fixes following build error when building with musl libc:

Need to wrap the compile error message to pass the check-git-log.sh checks.

Quoted 10 lines
---
 app/test-pmd/testpmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

fa4887853..84ef3fc30 100644

app/test-pmd/testpmd.h int set_vf_rate_limit(portid_t port_id, uint16_t vf, · line 810

Quoted 5 lines
app/test-pmd/testpmd.h +0 -1
@@ -806,7 +806,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);

uint should be replaced by uint8_t instead of unsigned int. The rss_key_len is a uint8_t type.

Quoted 6 lines
app/test-pmd/testpmd.h +1 -0
+			      uint8_t *hash_key, unsigned int 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.21.0

Regards,

Bernard.

#3 lore raw

Re: [PATCH v3 01/15] app/testpmd: replace uint with unsigned int

In reply to Natanael Copa

13/03/2019 18:06, Natanael Copa:

Quoted 1 line

Improve portability by avoid use non-standard 'uint'.

After running git grep '\<uint\>', I see there is also an occurence in examples/tep_termination/vxlan.c

#4 lore raw

Re: [dpdk-dev] [PATCH v3 01/15] app/testpmd: replace uint with unsigned int

Hi Natanael

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Saturday, March 30, 2019 10:17 PM
To: Natanael Copa <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 01/15] app/testpmd: replace uint with unsigned int

Quoted 7 lines

13/03/2019 18:06, Natanael Copa:

Quoted 1 line

Improve portability by avoid use non-standard 'uint'.

After running git grep '\<uint\>', I see there is also an occurence in examples/tep_termination/vxlan.c

An update to this patchset is needed if you want to get it applied in 19.08

Regards,

Bernard.

#5 lore raw

PATCH v3 2/15 net/cxgbe: replace uint with unsigned int

In reply to Natanael Copa

Improve portability and fix build error with musl libc:

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

---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +9 -9
index 973d4d7dd..1f52609c6 100644
@@ -198,15 +198,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;
 };
Signature · 1 line
2.21.0
#6 lore raw

PATCH v3 3/15 bus/pci: add fallback for out[lwb]_p for non GNU libc

In reply to Natanael Copa

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

This ifixes 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'

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

---
 drivers/bus/pci/linux/pci_uio.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/bus/pci/linux/pci_uio.c +29 -3
index 09ecbb7aa..e1dd8c875 100644
@@ -14,6 +14,32 @@
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif
 
 #include <rte_log.h>
@@ -527,21 +553,21 @@ pci_uio_ioport_write(struct rte_pci_ioport *p,
 		if (len >= 4) {
 			size = 4;
 #if defined(RTE_ARCH_X86)
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif
 		} else if (len >= 2) {
 			size = 2;
 #if defined(RTE_ARCH_X86)
-			outw_p(*(const uint16_t *)s, reg);
+			pci_uio_outw_p(*(const uint16_t *)s, reg);
 #else
 			*(volatile uint16_t *)reg = *(const uint16_t *)s;
 #endif
 		} else {
 			size = 1;
 #if defined(RTE_ARCH_X86)
-			outb_p(*s, reg);
+			pci_uio_outb_p(*s, reg);
 #else
 			*(volatile uint8_t *)reg = *s;
 #endif
Signature · 1 line
2.21.0
#7 lore raw

Re: [PATCH v3 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc

13/03/2019 18:06, Natanael Copa:

Quoted 9 lines

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

This ifixes 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'

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Please use this syntax:
Bugzilla ID: 35

[...]

Quoted 29 lines

#if defined(RTE_ARCH_X86)
#include <sys/io.h>

drivers/bus/pci/linux/pci_uio.c +26 -0
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif

[...]

drivers/bus/pci/linux/pci_uio.c pci_uio_ioport_write(struct rte_pci_ioport *p, · line 559

Quoted 6 lines

#if defined(RTE_ARCH_X86)

drivers/bus/pci/linux/pci_uio.c +1 -1
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif

Could we manage non-x86 case in the macros pci_uio_out?

Thanks

#8 lore raw

Re: [dpdk-dev] [PATCH v3 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc

Quoted 9 lines · On Sat, 30 Mar 2019 23:22:27 +0100 Thomas Monjalon <[email protected]> wrote:

13/03/2019 18:06, Natanael Copa:

Quoted 8 lines

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

This ifixes 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'

Quoted 4 lines
Quoted 1 line

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Please use this syntax:
Bugzilla ID: 35

Ok.

Quoted 32 lines

[...]

Quoted 29 lines

#if defined(RTE_ARCH_X86)
#include <sys/io.h>

drivers/bus/pci/linux/pci_uio.c +26 -0
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif  

[...]

Quoted 8 lines

drivers/bus/pci/linux/pci_uio.c pci_uio_ioport_write(struct rte_pci_ioport *p, · line 559

Quoted 6 lines

#if defined(RTE_ARCH_X86)

drivers/bus/pci/linux/pci_uio.c +1 -1
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif  

Could we manage non-x86 case in the macros pci_uio_out?

I did that in separate commit. Do you want do both in same commit?

Quoted 4 lines

Thanks

#9 lore raw

Re: [dpdk-dev] [PATCH v3 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc

04/07/2019 14:16, Natanael Copa:

Quoted 60 lines
Quoted 9 lines · On Sat, 30 Mar 2019 23:22:27 +0100 Thomas Monjalon <[email protected]> wrote:

13/03/2019 18:06, Natanael Copa:

Quoted 8 lines

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

This ifixes 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'

Quoted 4 lines
Quoted 1 line

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Please use this syntax:
Bugzilla ID: 35

Ok.

Quoted 32 lines

[...]

Quoted 29 lines

#if defined(RTE_ARCH_X86)
#include <sys/io.h>

drivers/bus/pci/linux/pci_uio.c +26 -0
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif  

[...]

Quoted 8 lines

drivers/bus/pci/linux/pci_uio.c pci_uio_ioport_write(struct rte_pci_ioport *p, · line 559

Quoted 6 lines

#if defined(RTE_ARCH_X86)

drivers/bus/pci/linux/pci_uio.c +1 -1
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif  

Could we manage non-x86 case in the macros pci_uio_out?

Quoted 1 line

I did that in separate commit. Do you want do both in same commit?

Maybe change the order of commits?
Anyway I think you need to rebase and resend this series :)

#10 lore raw

Re: [dpdk-dev] [PATCH v3 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc

Quoted 61 lines · On Thu, 04 Jul 2019 15:20:55 +0200 Thomas Monjalon <[email protected]> wrote:

04/07/2019 14:16, Natanael Copa:

Quoted 60 lines
Quoted 9 lines · On Sat, 30 Mar 2019 23:22:27 +0100 Thomas Monjalon <[email protected]> wrote:

13/03/2019 18:06, Natanael Copa:

Quoted 8 lines

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

This ifixes 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'

Quoted 4 lines
Quoted 1 line

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Please use this syntax:
Bugzilla ID: 35

Ok.

Quoted 40 lines

[...]

Quoted 29 lines

#if defined(RTE_ARCH_X86)
#include <sys/io.h>

drivers/bus/pci/linux/pci_uio.c +26 -0
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif    

[...]

drivers/bus/pci/linux/pci_uio.c pci_uio_ioport_write(struct rte_pci_ioport *p, · line 559

Quoted 6 lines

#if defined(RTE_ARCH_X86)

drivers/bus/pci/linux/pci_uio.c +1 -1
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif    

Could we manage non-x86 case in the macros pci_uio_out?

Quoted 3 lines
Quoted 1 line

I did that in separate commit. Do you want do both in same commit?

Maybe change the order of commits?

That would mean that first commit would use a define or inline that is not yet introduced :)

Quoted 1 line

Anyway I think you need to rebase and resend this series :)

I'm on it. Thanks for your feedback.

-nc

#11 lore raw

PATCH v3 4/15 bus/pci: factor out various ifdefs in pci_uio_ioport_{read, write}

In reply to Natanael Copa

define the macros so we can remove various #if defined(RTE_ARCH_X86)

Ref: https://bugs.dpdk.org/show_bug.cgi?id=35#c6

---
 drivers/bus/pci/linux/pci_uio.c | 54 +++++++++++++++------------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/bus/pci/linux/pci_uio.c +24 -30
index e1dd8c875..b0470358d 100644
@@ -14,11 +14,18 @@
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
+
+#define pci_uio_inl(reg) inl(reg)
+#define pci_uio_inw(reg) inw(reg)
+#define pci_uio_inb(reg) inb(reg)
+
 #if defined(__GLIBC__)
+
 #define pci_uio_outl_p outl_p
 #define pci_uio_outw_p outw_p
 #define pci_uio_outb_p outb_p
-#else
+
+#else /* defined(__GLIBC__) */
 static inline void
 pci_uio_outl_p(unsigned int value, unsigned short int port)
 {
@@ -39,8 +46,19 @@ pci_uio_outb_p(unsigned char value, unsigned short int port)
 	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
 			      "Nd" (port));
 }
-#endif
-#endif
+#endif /* defined(__GLIBC__) */
+
+#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))
+
+#define pci_uio_outl_p(value, reg) (*(volatile uint32_t *)(reg) = (value))
+#define pci_uio_outw_p(value, reg) (*(volatile uint16_t *)(reg) = (value))
+#define pci_uio_outb_p(value, reg) (*(volatile uint8_t *)(reg) = (value))
+
+#endif /* RTE_ARCH_X86 */
 
 #include <rte_log.h>
 #include <rte_pci.h>
@@ -518,25 +536,13 @@ 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);
 		}
 	}
 }
@@ -552,25 +558,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)
 			pci_uio_outl_p(*(const uint32_t *)s, reg);
-#else
-			*(volatile uint32_t *)reg = *(const uint32_t *)s;
-#endif
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
 			pci_uio_outw_p(*(const uint16_t *)s, reg);
-#else
-			*(volatile uint16_t *)reg = *(const uint16_t *)s;
-#endif
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
 			pci_uio_outb_p(*s, reg);
-#else
-			*(volatile uint8_t *)reg = *s;
-#endif
 		}
 	}
 }
Signature · 1 line
2.21.0
#12 lore raw

Re: [PATCH v3 04/15] bus/pci: factor out various ifdefs in pci_uio_ioport_{read, write}

13/03/2019 18:06, Natanael Copa:

Quoted 42 lines

define the macros so we can remove various #if defined(RTE_ARCH_X86)

Ref: https://bugs.dpdk.org/show_bug.cgi?id=35#c6

---
 drivers/bus/pci/linux/pci_uio.c | 54 +++++++++++++++------------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/bus/pci/linux/pci_uio.c +11 -3
index e1dd8c875..b0470358d 100644
@@ -14,11 +14,18 @@
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
+
+#define pci_uio_inl(reg) inl(reg)
+#define pci_uio_inw(reg) inw(reg)
+#define pci_uio_inb(reg) inb(reg)
+
 #if defined(__GLIBC__)
+
 #define pci_uio_outl_p outl_p
 #define pci_uio_outw_p outw_p
 #define pci_uio_outb_p outb_p
-#else
+
+#else /* defined(__GLIBC__) */
 static inline void
 pci_uio_outl_p(unsigned int value, unsigned short int port)
 {
@@ -39,8 +46,19 @@ pci_uio_outb_p(unsigned char value, unsigned short int port)
 	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
 			      "Nd" (port));
 }
-#endif
-#endif
+#endif /* defined(__GLIBC__) */
+
+#else /* RTE_ARCH_X86 */

drivers/bus/pci/linux/pci_uio.c pci_uio_outb_p(unsigned char value, unsigned short int port) · line 61

Quoted 10 lines
drivers/bus/pci/linux/pci_uio.c +10 -0
+
+#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))
+
+#define pci_uio_outl_p(value, reg) (*(volatile uint32_t *)(reg) = (value))
+#define pci_uio_outw_p(value, reg) (*(volatile uint16_t *)(reg) = (value))
+#define pci_uio_outb_p(value, reg) (*(volatile uint8_t *)(reg) = (value))
+
+#endif /* RTE_ARCH_X86 */

I think I would prefer having the #ifdef inside the macros, instead of redefining the macros.

#13 lore raw

PATCH v3 5/15 bus/fslmc: fix compile error with musl libc

In reply to Natanael Copa

This fixes the following compile error with musl libc:

../drivers/bus/fslmc/qbman/include/compat.h:41:10: error: 'stdout' undeclared (first use in this function)

   fflush(stdout); \
          ^~~~~~
---
 drivers/bus/fslmc/qbman/include/compat.h | 1 +
 1 file changed, 1 insertion(+)
drivers/bus/fslmc/qbman/include/compat.h +1 -0
index 655bff4b6..ae84528b9 100644
@@ -11,6 +11,7 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <errno.h>
Signature · 1 line
2.21.0
#14 lore raw

PATCH v3 6/15 bus/fslmc: remove unused include of error.h

In reply to Natanael Copa

Fixes following build error with musl libc:

In file included from ../drivers/bus/fslmc/qbman/qbman_debug.c:6:
../drivers/bus/fslmc/qbman/include/compat.h:21:10: fatal error: error.h: No such file or directory

 #include <error.h>
          ^~~~~~~~~

Apparently it is not used anywere in qbman so simply remove the include.

---
 drivers/bus/fslmc/qbman/include/compat.h | 1 -
 1 file changed, 1 deletion(-)
drivers/bus/fslmc/qbman/include/compat.h +0 -1
index ae84528b9..1ddd69e12 100644
@@ -18,7 +18,6 @@
 #include <string.h>
 #include <malloc.h>
 #include <unistd.h>
-#include <error.h>
 #include <linux/types.h>
 #include <rte_atomic.h>
 
Signature · 1 line
2.21.0
#15 lore raw

PATCH v3 7/15 net/nfp: build fix for musl libc

In reply to Natanael Copa

Fixes following build error on systems without execinfo.h:

../drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c:19:10: fatal error: execinfo.h: No such file or directory

 #include <execinfo.h>
          ^~~~~~~~~~~~
---
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +2 -0
index 39bd48a83..93ee310f5 100644
@@ -16,7 +16,9 @@
 
 #include <assert.h>
 #include <stdio.h>
+#if defined(RTE_BACKTRACE)
 #include <execinfo.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdint.h>
Signature · 1 line
2.21.0
Acked-by on v3 7/15
#16 lore raw

Re: [PATCH v3 07/15] net/nfp: build fix for musl libc

Quoted 9 lines · Natanael Copa

Fixes following build error on systems without execinfo.h:

../drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c:19:10: fatal error:
execinfo.h: No such file or directory

 #include <execinfo.h>
          ^~~~~~~~~~~~
Quoted 23 lines
---
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +2 -1
index 39bd48a83..93ee310f5 100644
@@ -16,7 +16,9 @@
 
 #include <assert.h>
 #include <stdio.h>
+#if defined(RTE_BACKTRACE)
 #include <execinfo.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdint.h>
--

2.21.0

#17 lore raw

PATCH v3 8/15 app/test: include fcntl.h due to use of O_RDONLY

In reply to Natanael Copa

Fix following build error with musl libc:

../app/test/test_eal_flags.c:152:55: error: 'O_RDONLY' undeclared (first use in this function)

      fd = openat(dirfd(hugepage_dir), dirent->d_name, O_RDONLY);
                                                       ^~~~~~~~
---
 app/test/test_eal_flags.c | 1 +
 1 file changed, 1 insertion(+)
app/test/test_eal_flags.c +1 -0
index 1a64b0900..d626dd712 100644
@@ -17,6 +17,7 @@
 #include <sys/wait.h>
 #include <sys/file.h>
 #include <limits.h>
+#include <fcntl.h>
 
 #include <rte_per_lcore.h>
 #include <rte_debug.h>
Signature · 1 line
2.21.0
#18 lore raw

PATCH v3 9/15 app/test: fix setting of -D_GNU_SOURCE with meson

In reply to Natanael Copa

in app/test/meson.build the default_cflag is never used so the -D_GNU_SOURCE was never passed as intended.

Fixes the following build error with musl libc:

../lib/librte_eal/common/include/rte_lcore.h:26:9: error: unknown type name 'cpu_set_t'

 typedef cpu_set_t rte_cpuset_t;
         ^~~~~~~~~

The problem is that cpu_set_t is only defined when _GNU_SOURCE is set.

---
 app/test/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/meson.build +1 -1
index 05e5ddeb0..2f2ec5057 100644
@@ -298,7 +298,7 @@ if cc.has_argument('-Wno-format-truncation')
 endif
 
 # specify -D_GNU_SOURCE unconditionally
-default_cflags += '-D_GNU_SOURCE'
+cflags += '-D_GNU_SOURCE'
 
 test_dep_objs = []
 if dpdk_conf.has('RTE_LIBRTE_COMPRESSDEV')
Signature · 1 line
2.21.0
#19 lore raw

PATCH v3 10/15 bus/dpaa: use warn(3) instead of error(3) to improve portability

In reply to Natanael Copa

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

This also fixes error message for kzmalloc failures which previously would have given "Unknown error -1".

---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c |  6 +++---
 drivers/bus/dpaa/base/qbman/qman_driver.c | 12 ++++++------
 drivers/bus/dpaa/include/compat.h         |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index 6b5224203..0c3a1bfa3 100644
@@ -8,7 +8,7 @@
 #include <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>
@@ -89,7 +89,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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +3 -3
index 750b756b9..dbe00d1c9 100644
@@ -40,7 +40,7 @@ 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()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +60,7 @@ 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()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */
@@ -105,7 +105,7 @@ static int fsl_bman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
drivers/bus/dpaa/base/qbman/qman_driver.c +6 -6
index ba153396d..163a66b30 100644
@@ -41,7 +41,7 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	qpcfg.cpu = -1;
@@ -62,7 +62,7 @@ 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()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -109,7 +109,7 @@ static int fsl_qman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
@@ -156,7 +156,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -164,7 +164,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		kfree(q_pcfg);
 		return NULL;
 	}
@@ -190,7 +190,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
drivers/bus/dpaa/include/compat.h +1 -1
index 412265779..0c01c5514 100644
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
+#include <err.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.21.0
#20 lore raw

Re: [PATCH v3 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability

13/03/2019 18:06, Natanael Copa:

Quoted 4 lines

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

This also fixes error message for kzmalloc failures which previously would have given "Unknown error -1".

I think this patch requires more explanations about what was the error, why using warn, and how it is related to kzmalloc failure log. Thanks

#21 lore raw

Re: [dpdk-dev] [PATCH v3 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability

In reply to Natanael Copa

NAK
error is different from warning - the return value is also not carried.

-----Original Message-----
From: dev <[email protected]> On Behalf Of Natanael Copa
Sent: Wednesday, March 13, 2019 10:37 PM
To: [email protected]
Cc: Natanael Copa <[email protected]>
Subject: [dpdk-dev] [PATCH v3 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability

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

This also fixes error message for kzmalloc failures which previously would have given "Unknown error -1".

---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--  drivers/bus/dpaa/base/qbman/bman_driver.c |  6 +++---  drivers/bus/dpaa/base/qbman/qman_driver.c | 12 ++++++------
 drivers/bus/dpaa/include/compat.h         |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index 6b5224203..0c3a1bfa3 100644
@@ -8,7 +8,7 @@
 #include <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>
@@ -89,7 +89,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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +2 -2
index 750b756b9..dbe00d1c9 100644
@@ -40,7 +40,7 @@ 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()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +60,7 @@ 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()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */ @@ -105,7 +105,7 @@ static int fsl_bman_portal_finish(void)

DPAA_BUG_ON(cfg != &pcfg);
ret = process_portal_unmap(&map.addr);
if (ret)
- error(0, ret, "process_portal_unmap()");
+ warn("process_portal_unmap()");
return ret;
}

drivers/bus/dpaa/base/qbman/qman_driver.c +6 -6
index ba153396d..163a66b30 100644
@@ -41,7 +41,7 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	qpcfg.cpu = -1;
@@ -62,7 +62,7 @@ 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()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -109,7 +109,7 @@ static int fsl_qman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
@@ -156,7 +156,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -164,7 +164,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		kfree(q_pcfg);
 		return NULL;
 	}
@@ -190,7 +190,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
drivers/bus/dpaa/include/compat.h +1 -1
index 412265779..0c01c5514 100644
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
+#include <err.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>

--
2.21.0

#22 lore raw

Re: [dpdk-dev] [PATCH v3 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability

10/07/2020 07:13, Hemant Agrawal:

Quoted 2 lines

NAK
error is different from warning - the return value is also not carried.

It seems this comment has been ignored so far.
I will address it in a v7.

#23 lore raw

PATCH v3 11/15 bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0

In reply to Natanael Copa

There is no standard saying that __WORDSIZE should be be defined or in what include it should be defined. Use a portable way to detect 64 bit environment.

This fixes a warning when building with musl libc:

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

---
 drivers/bus/dpaa/include/fsl_qman.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/dpaa/include/fsl_qman.h +2 -1
index e43841499..7f3f40d49 100644
@@ -11,11 +11,12 @@
 extern "C" {
 #endif
 
+#include <limits.h>
 #include <dpaa_rbtree.h>
 #include <rte_eventdev.h>
 
 /* FQ lookups (turn this on for 64bit user-space) */
-#if (__WORDSIZE == 64)
+#if (ULONG_MAX == 0xffffffffffffffff)
 #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.
Signature · 1 line
2.21.0
#24 lore raw

Re: [PATCH v3 11/15] bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0

13/03/2019 18:06, Natanael Copa:

Quoted 10 lines

There is no standard saying that __WORDSIZE should be be defined or in what include it should be defined. Use a portable way to detect 64 bit environment.

This fixes a warning when building with musl libc:

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

---

[...]

drivers/bus/dpaa/include/fsl_qman.h line 19

Quoted 2 lines
drivers/bus/dpaa/include/fsl_qman.h +1 -1
-#if (__WORDSIZE == 64)
+#if (ULONG_MAX == 0xffffffffffffffff)

There is a more explicit config in DPDK: RTE_ARCH_64

#26 lore raw

PATCH v3 12/15 crypto/dpaa2_sec: build fix for musl libc

In reply to Natanael Copa

The swab16/swab32/swab64 are Linux specific and nog 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.

---
 drivers/crypto/dpaa2_sec/hw/compat.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/dpaa2_sec/hw/compat.h +5 -5
index ce946ccb5..1362045ca 100644
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef __linux__
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -40,7 +40,7 @@
 #define __maybe_unused __attribute__((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(__linux__) || defined(__GLIBC__)
 	#define swab16(x) rte_bswap16(x)
 	#define swab32(x) rte_bswap32(x)
 	#define swab64(x) rte_bswap64(x)
Signature · 1 line
2.21.0
Acked-by on v3 12/15
#27 lore raw

Re: [dpdk-dev] [PATCH v3 12/15] crypto/dpaa2_sec: build fix for musl libc

The location of the file has been changed from
drivers/crypto/dpaa2_sec/hw/compat.h
to:
drivers/common/dpaax/caamflib/compat.h

In next version you can add

-----Original Message-----
From: dev <[email protected]> On Behalf Of Natanael Copa
Sent: Wednesday, March 13, 2019 10:37 PM
To: [email protected]
Cc: Natanael Copa <[email protected]>
Subject: [dpdk-dev] [PATCH v3 12/15] crypto/dpaa2_sec: build fix for musl libc

The swab16/swab32/swab64 are Linux specific and nog 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.

---
 drivers/crypto/dpaa2_sec/hw/compat.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/dpaa2_sec/hw/compat.h +3 -3
index ce946ccb5..1362045ca 100644
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef __linux__
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -40,7 +40,7 @@
 #define __maybe_unused __attribute__((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(__linux__) || defined(__GLIBC__)
#define swab16(x) rte_bswap16(x)
#define swab32(x) rte_bswap32(x)
#define swab64(x) rte_bswap64(x)
--
2.21.0

#28 lore raw

PATCH v3 13/15 crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros

In reply to Natanael Copa

Simplify pr_debug, pr_err and pr_warn macros by add an intermediate pr_msg macro. This way we only need test for SUPPRESS_PRINTS once.

---
 drivers/crypto/dpaa2_sec/hw/compat.h | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/crypto/dpaa2_sec/hw/compat.h +12 -16
index 1362045ca..e36229f5f 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __attribute__((unused))
 #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0)
+#else
+#define pr_msg(l, fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
Signature · 1 line
2.21.0
#29 lore raw

Re: [PATCH v3 13/15] crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros

13/03/2019 18:06, Natanael Copa:

Quoted 4 lines

Simplify pr_debug, pr_err and pr_warn macros by add an intermediate pr_msg macro. This way we only need test for SUPPRESS_PRINTS once.

Adding more Cc for review.

Acked-by on v3 13/15
#31 lore raw

Re: [dpdk-dev] [PATCH v3 13/15] crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros

In reply to Natanael Copa

Change it to new location drivers/common/dpaax/caamflib/compat.h

-----Original Message-----
From: dev <[email protected]> On Behalf Of Natanael Copa
Sent: Wednesday, March 13, 2019 10:37 PM
To: [email protected]
Cc: Natanael Copa <[email protected]>
Subject: [dpdk-dev] [PATCH v3 13/15] crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros

Simplify pr_debug, pr_err and pr_warn macros by add an intermediate pr_msg macro. This way we only need test for SUPPRESS_PRINTS once.

---
 drivers/crypto/dpaa2_sec/hw/compat.h | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/crypto/dpaa2_sec/hw/compat.h +10 -16
index 1362045ca..e36229f5f 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __attribute__((unused))  #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0) #else #define pr_msg(l, 
+fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__) #endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
--

2.21.0

#32 lore raw

PATCH v3 14/15 net/netvsc: fix compile warning for fcntl.h include

In reply to Natanael Copa

Fix the following warning when building with musl libc:

In file included from ../drivers/net/netvsc/hn_vf.c:14:
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
^~~~~~~

---
 drivers/net/netvsc/hn_vf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netvsc/hn_vf.c +1 -1
index 3f714ec99..6eeacb659 100644
@@ -10,8 +10,8 @@
 #include <errno.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <fcntl.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
 #include <sys/uio.h>
 
 #include <rte_ether.h>
Signature · 1 line
2.21.0
#33 lore raw

PATCH v3 15/15 eal/linux: simplify debug message in sigbus_handler

In reply to Natanael Copa

There is no guarantee that pthread_self() returns the thread ID or that pthread_t is an integer. The thread ID is not that useful so simply remove it.

This fixes the following warning when building with musl libc:

../lib/librte_eal/linuxapp/eal/eal_dev.c: In function 'sigbus_handler':
../lib/librte_eal/linuxapp/eal/eal_dev.c:70:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
(int)pthread_self(), info->si_addr);
^

---
 lib/librte_eal/linux/eal/eal_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/linux/eal/eal_dev.c +2 -2
index 2830c8687..c41809380 100644
@@ -66,8 +66,8 @@ static void sigbus_handler(int signum, siginfo_t *info,
 {
 	int ret;
 
-	RTE_LOG(DEBUG, EAL, "Thread[%d] catch SIGBUS, fault address:%p\n",
-		(int)pthread_self(), info->si_addr);
+	RTE_LOG(DEBUG, EAL, "Thread catch SIGBUS, fault address:%p\n",
+		info->si_addr);
 
 	rte_spinlock_lock(&failure_handle_lock);
 	ret = rte_bus_sigbus_handler(info->si_addr);
Signature · 1 line
2.21.0
#34 lore raw
In reply to Natanael Copa

When I try building I'm still getting this error

/root/dpdk/app/test-pmd/bpf_cmd.c:23:11: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] .val = &stdout,

Quoted 43 lines · Natanael Copa

A set of patches to fix build with musl libc. I also did a few cleanups wrt macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch
v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

Natanael Copa (15):
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/fslmc: fix compile error with musl libc
bus/fslmc: remove unused include of error.h
net/nfp: build fix for musl libc
app/test: include fcntl.h due to use of O_RDONLY app/test: fix setting of -D_GNU_SOURCE with meson bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros net/netvsc: fix compile warning for fcntl.h include eal/linux: simplify debug message in sigbus_handler

  app/test-pmd/testpmd.h                     |  2 +-
  app/test/meson.build                       |  2 +-
  app/test/test_eal_flags.c                  |  1 +
  drivers/bus/dpaa/base/fman/netcfg_layer.c  |  4 +-
  drivers/bus/dpaa/base/qbman/bman_driver.c  |  6 +-
  drivers/bus/dpaa/base/qbman/qman_driver.c  | 12 ++--
  drivers/bus/dpaa/include/compat.h          |  2 +-
  drivers/bus/dpaa/include/fsl_qman.h        |  3 +-
  drivers/bus/fslmc/qbman/include/compat.h   |  2 +-
  drivers/bus/pci/linux/pci_uio.c            | 82 ++++++++++++++--------
  drivers/crypto/dpaa2_sec/hw/compat.h       | 36 +++++-----
  drivers/net/cxgbe/base/common.h            | 18 ++---
  drivers/net/netvsc/hn_vf.c                 |  2 +-
  drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |  2 +
  lib/librte_eal/linux/eal/eal_dev.c         |  4 +-
  15 files changed, 99 insertions(+), 79 deletions(-)
#35 lore raw
In reply to Natanael Copa

13/03/2019 18:06, Natanael Copa:

Quoted 9 lines

A set of patches to fix build with musl libc. I also did a few cleanups wrt macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch
v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

Quoted 16 lines

Natanael Copa (15):
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/fslmc: fix compile error with musl libc
bus/fslmc: remove unused include of error.h
net/nfp: build fix for musl libc
app/test: include fcntl.h due to use of O_RDONLY app/test: fix setting of -D_GNU_SOURCE with meson bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros net/netvsc: fix compile warning for fcntl.h include eal/linux: simplify debug message in sigbus_handler

Thanks for the cleanup.

Some patches may deserve more reviews.
If you send a new version, please use --to-cmd devtools/get-maintainer.sh so the maintainers will be Cc'ed.

All these patches are fixes and may be interesting to backport them in the latest LTS or other stable releases.
In order to help with backporting, please fill "Fixes:" tag and add Cc: stable when relevant.
The exact recommendation is described in this doc chapter:
http://doc.dpdk.org/guides/contributing/patches.html#commit-messages-body

In order to help, I already fixed 7 commit messages and merged them. The remaining patches, requiring a v4, are:
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros

#36 lore raw
Quoted 41 lines · Thomas Monjalon

13/03/2019 18:06, Natanael Copa:

Quoted 1 line

A set of patches to fix build with musl libc. I also did a few cleanups

wrt

Quoted 8 lines

macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch
v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

Quoted 16 lines

Natanael Copa (15):
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/fslmc: fix compile error with musl libc
bus/fslmc: remove unused include of error.h
net/nfp: build fix for musl libc
app/test: include fcntl.h due to use of O_RDONLY app/test: fix setting of -D_GNU_SOURCE with meson bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros net/netvsc: fix compile warning for fcntl.h include eal/linux: simplify debug message in sigbus_handler

Thanks for the cleanup.

Some patches may deserve more reviews.
If you send a new version, please use --to-cmd devtools/get-maintainer.sh so the maintainers will be Cc'ed.

All these patches are fixes and may be interesting to backport them in the latest LTS or other stable releases.
In order to help with backporting, please fill "Fixes:" tag and add Cc: stable when relevant.
The exact recommendation is described in this doc chapter:
http://doc.dpdk.org/guides/contributing/patches.html#commit-messages-body

Quoted 11 lines

In order to help, I already fixed 7 commit messages and merged them. The remaining patches, requiring a v4, are:
app/testpmd: replace uint with unsigned int
net/cxgbe: replace uint with unsigned int
bus/pci: add fallback for out[lwb]_p for non GNU libc bus/pci: factor out various ifdefs in pci_uio_ioport_{read,write} bus/dpaa: use warn(3) instead of error(3) to improve portability bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 crypto/dpaa2_sec: build fix for musl libc crypto/dpaa2_sec: simplify pr_{debug,err,warn} macros

If you intend to send a v4, I noticed a few more "uint" in the tree, I suppose this is worth fixing them:

$ git grep -w uint
app/test-pmd/config.c:                   uint hash_key_len)
examples/tep_termination/vxlan.c:       uint vport_id;
Signature · 1 line
David Marchand
#37 lore raw
In reply to Thomas Monjalon

A set of patches to fix build with musl libc. I also did a few cleanups wrt macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch

v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

v4 rebase against main and deal with renames/moves.
fix commit messages to make check-git-log.sh happy. improve error(3) -> warn(3) patch and clarify commit message. update __WORDSIZE patch to use RTE_ARCH_64
add "Fixes:" tags
add a couple of patches fro eal

Sorry that it took so long time to follow up.

Natanael Copa (8):
app/testpmd: fix uint build error with musl libc net/cxgbe: fix uint build error with musl libc bus/pci: add fallback for out* for non GNU libc bus/dpaa: use warn instead of error to improve portability bus/dpaa: fix detection of 64 bit arch common/dpaax: build fix for musl libc common/dpaax: simplify pr debug/err/warn macros
eal: add missing include to fix build with musl libc

 app/test-pmd/config.c                     |  2 +-
 app/test-pmd/testpmd.h                    |  2 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 +-
 drivers/bus/dpaa/base/qbman/bman_driver.c | 12 ++-
 drivers/bus/dpaa/base/qbman/qman_driver.c | 15 ++--
 drivers/bus/dpaa/include/fsl_qman.h       |  2 +-
 drivers/bus/pci/linux/pci_uio.c           | 95 +++++++++++++++--------
 drivers/common/dpaax/caamflib/compat.h    | 36 ++++-----
 drivers/net/cxgbe/base/common.h           | 18 ++---
 lib/librte_eal/unix/eal_file.c            |  1 +
 10 files changed, 113 insertions(+), 74 deletions(-)

--
2.29.2

#38 lore raw

PATCH v4 1/8 app/testpmd: fix uint build error with musl libc

Improve portability by avoid use 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:

In file included from ../app/test-pmd/cmdline.c:74:
../app/test-pmd/testpmd.h:813:29: error: unknown type name 'uint'; did you mean 'int'?

  813 |          uint8_t *hash_key, uint hash_key_len);
      |                             ^~~~
      |                             int
Fixes 8205e241b2b0 ("app/testpmd: add missing type to RSS hash commands")
---
 app/test-pmd/config.c  | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +1 -1
index 755d1dfc9..8ec091077 100644
@@ -3015,7 +3015,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;
app/test-pmd/testpmd.h +1 -1
index 519d5517e..1cb6a6d04 100644
@@ -945,7 +945,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);
Signature · 1 line
2.29.2
Reviewed-by on v4 1/8
#39 lore raw

Re: [dpdk-dev] [PATCH v4 1/8] app/testpmd: fix uint build error withmusl libc

Quoted 54 lines

From: dev [mailto:[email protected]] On Behalf Of Natanael Copa
Sent: Thursday, November 5, 2020 10:17 PM

Improve portability by avoid use 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:

In file included from ../app/test-pmd/cmdline.c:74:
../app/test-pmd/testpmd.h:813:29: error: unknown type name 'uint'; did you mean 'int'?

  813 |          uint8_t *hash_key, uint hash_key_len);
      |                             ^~~~
      |                             int
Fixes 8205e241b2b0 ("app/testpmd: add missing type to RSS hash

commands")
Cc: [email protected]

---
 app/test-pmd/config.c  | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +1 -1
index 755d1dfc9..8ec091077 100644
@@ -3015,7 +3015,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)
 {
app/test-pmd/config.c +0 -0
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
app/test-pmd/testpmd.h +1 -1
index 519d5517e..1cb6a6d04 100644
@@ -945,7 +945,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);
Quoted 4 lines

void setup_gro(const char *onoff, portid_t port_id);
--
2.29.2

Ethdev RSS hash key length is uint8_t, so this patch is correct not using unsigned int as replacement.

#40 lore raw

PATCH v4 2/8 net/cxgbe: fix uint build error with musl libc

In reply to Natanael Copa

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")
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +9 -9
index 8fe8e2a36..c1d09dfad 100644
@@ -201,15 +201,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;
 };
Signature · 1 line
2.29.2
Reviewed-by on v4 2/8
#41 lore raw

Re: [dpdk-dev] [PATCH v4 2/8] net/cxgbe: fix uint build error with musllibc

Quoted 63 lines

From: dev [mailto:[email protected]] On Behalf Of Natanael Copa
Sent: Thursday, November 5, 2020 10:17 PM

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")
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +2 -9
index 8fe8e2a36..c1d09dfad 100644
@@ -201,15 +201,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 */

drivers/net/cxgbe/base/common.h +1 -0
+			unsigned int syn2tupenipv6:1;	/* en 2-tuple IPv6 SYNs

hash */

drivers/net/cxgbe/base/common.h +1 -0
+			unsigned int syn4tupenipv4:1;	/* en 4-tuple IPv4 SYNs

hash */

drivers/net/cxgbe/base/common.h +1 -0
+			unsigned int syn2tupenipv4:1;	/* en 2-tuple IPv4 SYNs

hash */

drivers/net/cxgbe/base/common.h +1 -0
+			unsigned int ofdmapen:1;	/* Offload Map Enable

*/

drivers/net/cxgbe/base/common.h +3 -1
+			unsigned int tnlmapen:1;	/* Tunnel Map Enable */
+			unsigned int tnlalllookup:1;	/* Tunnel All Lookup */
+			unsigned int hashtoeplitz:1;	/* use Toeplitz hash */
 		} basicvirtual;
 	} u;
 };
--
Quoted 2 lines

2.29.2

#42 lore raw

PATCH v4 3/8 bus/pci: add fallback for out* for non GNU libc

In reply to Natanael Copa

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'

We also handle the non-x86 with macros to factor out various ifdefs in the code.

Bugzilla ID: 35

Fixes c752998b5e2e ("pci: introduce library and driver")
---
 drivers/bus/pci/linux/pci_uio.c | 95 ++++++++++++++++++++++-----------
 1 file changed, 64 insertions(+), 31 deletions(-)
drivers/bus/pci/linux/pci_uio.c +64 -31
index f3305a2f2..626c8a2cc 100644
@@ -14,7 +14,64 @@
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
-#endif
+
+#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 /* RTE_ARCH_X86 */
+
+
+#if defined(RTE_ARCH_X86)
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+#if defined(__GLIBC__)
+	outl_p(value, port);
+#else /* __GLIBC__ */
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif /* __GLIBC__ */
+}
+#else /* RTE_ARCH_X86 */
+#define pci_uio_outl_p(value, reg) (*(volatile uint32_t *)(reg) = (value))
+#endif /* RTE_ARCH_X86 */
+
+#if defined(RTE_ARCH_X86)
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+#if defined(__GLIBC__)
+	outw_p(value, port);
+#else /* __GLIBC__ */
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif /* __GLIBC__ */
+}
+#else /* RTE_ARCH_X86 */
+#define pci_uio_outw_p(value, reg) (*(volatile uint16_t *)(reg) = (value))
+#endif /* RTE_ARCH_X86 */
+
+#if defined(RTE_ARCH_X86)
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+#if defined(__GLIBC__)
+	outb_p(value, port);
+#else /* __GLIBC__ */
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+#endif /* __GLIBC__ */
+}
+#else /* RTE_ARCH_X86 */
+#define pci_uio_outb_p(value, reg) (*(volatile uint8_t *)(reg) = (value))
+#endif /* RTE_ARCH_X86 */
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
@@ -500,25 +557,13 @@ 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);
 		}
 	}
 }
@@ -534,25 +579,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);
 		}
 	}
 }
Signature · 1 line
2.29.2
#43 lore raw

PATCH v4 4/8 bus/dpaa: use warn instead of error to improve portability

In reply to Natanael Copa

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")
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c | 12 ++++++++----
 drivers/bus/dpaa/base/qbman/qman_driver.c | 15 ++++++++++-----
 3 files changed, 20 insertions(+), 11 deletions(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index b7009f229..bcedbaf68 100644
@@ -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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +8 -4
index 750b756b9..8c9a98c48 100644
@@ -40,7 +40,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 +61,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 +106,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;
 }
 
drivers/bus/dpaa/base/qbman/qman_driver.c +10 -5
index 6d9aaff16..4cff2c161 100644
@@ -50,7 +50,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 +97,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 +149,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 +159,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;
 	}
Signature · 1 line
2.29.2
#44 lore raw

Re: [dpdk-dev] [PATCH v4 4/8] bus/dpaa: use warn instead of error to improve portability

I ran into this error and fixed it by removing the include directive for error.h:

/drivers/common/dpaax/compat.h:37:10: fatal error: error.h: No such file or directory

Not sure if this change was missing or if there is some other way the build should be configured.

#45 lore raw

PATCH v4 5/8 bus/dpaa: fix detection of 64 bit arch

In reply to Natanael Copa

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")
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/dpaa/include/fsl_qman.h +1 -1
index 10212f0fd..7ef2f3b2e 100644
@@ -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.
Signature · 1 line
2.29.2
#46 lore raw

PATCH v4 6/8 common/dpaax: build fix for musl libc

In reply to Natanael Copa

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")
---
 drivers/common/dpaax/caamflib/compat.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/common/dpaax/caamflib/compat.h +5 -5
index 36ee4b533..e755c77af 100644
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#ifdef __GLIBC__
+#ifdef __linux__
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -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(__linux__) || defined(__GLIBC__)
 	#define swab16(x) rte_bswap16(x)
 	#define swab32(x) rte_bswap32(x)
 	#define swab64(x) rte_bswap64(x)
Signature · 1 line
2.29.2
#47 lore raw

PATCH v4 7/8 common/dpaax: simplify pr debug/err/warn macros

In reply to Natanael Copa

Simplify pr_debug, pr_err and pr_warn macros by add an intermediate pr_msg macro. This way we only need test for SUPPRESS_PRINTS once.

---
 drivers/common/dpaax/caamflib/compat.h | 28 +++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/common/dpaax/caamflib/compat.h +12 -16
index e755c77af..11c916412 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __rte_unused
 #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0)
+#else
+#define pr_msg(l, fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
Signature · 1 line
2.29.2
#48 lore raw

PATCH v4 8/8 eal: add missing include to fix build with musl libc

In reply to Natanael Copa

Solve the build error with musl libc:

../lib/librte_eal/unix/eal_file.c: In function 'eal_file_open':
../lib/librte_eal/unix/eal_file.c:22:15: error: 'O_RDONLY' undeclared (first use in this function)

   22 |   sys_flags = O_RDONLY;
      |               ^~~~~~~~
Fixes 176bb37ca6f3 ("eal: introduce internal wrappers for file operations")
---
 lib/librte_eal/unix/eal_file.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/unix/eal_file.c +1 -0
index 1b26475ba..ec554e009 100644
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
Signature · 1 line
2.29.2
#49 lore raw
In reply to Natanael Copa

05/11/2020 22:17, Natanael Copa:

Quoted 8 lines

v4 rebase against main and deal with renames/moves.
fix commit messages to make check-git-log.sh happy. improve error(3) -> warn(3) patch and clarify commit message. update __WORDSIZE patch to use RTE_ARCH_64
add "Fixes:" tags
add a couple of patches fro eal

Sorry that it took so long time to follow up.

No problem, that's very good to receive these fixes. Thanks

#50 lore raw
In reply to Natanael Copa

Hello Natanael,

Quoted 20 lines · Natanael Copa

A set of patches to fix build with musl libc. I also did a few cleanups wrt macros and fixed a few scary compiler warnings while at it.

Please note that those are only compile tested on x86_64 with musl libc.

v2 has some code style fixes reported by checkpatch

v3 is a full reroll of the entire patch set to enable automatted tests
and logic for patchwork patchset.

v4 rebase against main and deal with renames/moves.
fix commit messages to make check-git-log.sh happy. improve error(3) -> warn(3) patch and clarify commit message. update __WORDSIZE patch to use RTE_ARCH_64
add "Fixes:" tags
add a couple of patches fro eal

Sorry that it took so long time to follow up.

Quoted 9 lines

Natanael Copa (8):
app/testpmd: fix uint build error with musl libc net/cxgbe: fix uint build error with musl libc bus/pci: add fallback for out* for non GNU libc bus/dpaa: use warn instead of error to improve portability bus/dpaa: fix detection of 64 bit arch common/dpaax: build fix for musl libc common/dpaax: simplify pr debug/err/warn macros
eal: add missing include to fix build with musl libc

- I suppose you got the mails with the build errors from the robot. Build is broken in dpaa (missing a few <err.h> includes).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/429242867#L1005

- I still see a uint use in drivers/net/igc.
How about:

drivers/net/igc/igc_flow.c +1 -1
index 1bb64d323c..66053060af 100644
@@ -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",
Signature · 1 line
David Marchand
#51 lore raw

Hi Natanael,

06/11/2020 11:44, David Marchand:

Quoted 5 lines

Hello Natanael,

- I suppose you got the mails with the build errors from the robot. Build is broken in dpaa (missing a few <err.h> includes).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/429242867#L1005

Please could send a new version fixing the build issues? If you don't have time, just ask for someone to follow-up, we probably can find a volunteer.

#52 lore raw

Hi,

Sorry, I thought I would be able to allocate time yesterday but got distracted.

I would appreciate if someone else could follow up, since I don’t know when I´ll find time for it.

Thanks!

-nc

Quoted 16 lines

18. feb. 2021 kl. 17:13 skrev Thomas Monjalon <[email protected]>:

Hi Natanael,

06/11/2020 11:44, David Marchand:

Quoted 5 lines

Hello Natanael,

- I suppose you got the mails with the build errors from the robot. Build is broken in dpaa (missing a few <err.h> includes).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/429242867#L1005

Please could send a new version fixing the build issues? If you don't have time, just ask for someone to follow-up, we probably can find a volunteer.

#53 lore raw

20/02/2021 09:51, Natanael Copa:

Quoted 8 lines

18. feb. 2021 kl. 17:13 skrev Thomas Monjalon <[email protected]>:

Quoted 7 lines

06/11/2020 11:44, David Marchand:

Quoted 5 lines

Hello Natanael,

- I suppose you got the mails with the build errors from the robot. Build is broken in dpaa (missing a few <err.h> includes).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/429242867#L1005

Quoted 7 lines
Quoted 3 lines

Please could send a new version fixing the build issues? If you don't have time, just ask for someone to follow-up, we probably can find a volunteer.

Sorry, I thought I would be able to allocate time yesterday but got distracted.

I would appreciate if someone else could follow up, since I don’t know when I´ll find time for it.

I am taking over the series, adding multiple fixes to make Alpine fully supported.
I will send a v5 soon.

#54 lore raw

v5 cover Alpine/musl build support

In reply to Natanael Copa

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

The goal is to run a container with the following Dockerfile:
8< ------------
FROM alpine

# DPDK prerequisites

RUN apk --no-cache add \
    gcc libc-dev bsd-compat-headers linux-headers \
    python3 py3-elftools meson ninja \
    libexecinfo-dev numactl-dev zlib-dev libpcap-dev libbpf-dev openssl-dev
# mlx prerequisites
RUN apk --no-cache add \
    git cmake libnl3-dev
RUN git clone https://github.com/linux-rdma/rdma-core.git
WORKDIR /rdma-core/build
RUN cmake -DNO_MAN_PAGES=1 -DNO_PYVERBS=1 -GNinja ..
RUN ninja install
WORKDIR /
# download
ARG version
RUN if [ "$version" = git ] ; then \
        git clone http://dpdk.org/git/dpdk dpdk-$version ;\
    else \
        wget http://fast.dpdk.org/rel/dpdk-$version.tar.xz && \
        tar xf dpdk-$version.tar.xz ;\
    fi
# build
WORKDIR dpdk-$version/build
RUN meson ..
RUN ninja install
8< ------------

Natanael Copa (7):
bus/pci: support I/O port operations with musl
bus/dpaa: fix 64-bit arch detection
bus/dpaa: fix build with musl
common/dpaax/caamflib: fix build with musl
common/dpaax/caamflib: simplify log macros
net/cxgbe: remove use of uint type
app/testpmd: fix build with musl

Thomas Monjalon (10):
eal: fix comment of OS-specific header files
buildtools: fix build with busybox
build: detect execinfo library on Linux
build: define _GNU_SOURCE globally
eal/linux: fix build with musl
drivers: fix header includes for musl
drivers: replace page size definitions with function net/igc: remove use of uint type
vdpa/mlx5: replace pthread functions unavailable in musl examples/bbdev: fix header include for musl

 app/meson.build                               |  4 -
 app/test-pmd/bpf_cmd.c                        |  2 +-
 app/test-pmd/config.c                         |  2 +-
 app/test-pmd/testpmd.h                        |  2 +-
 app/test/meson.build                          |  3 -
 buildtools/binutils-avx512-check.sh           |  2 +-
 buildtools/check-symbols.sh                   |  2 +-
 buildtools/map-list-symbol.sh                 |  2 +-
 buildtools/pkg-config/meson.build             |  1 +
 config/meson.build                            |  9 +-
 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/fsl_qman.h           |  2 +-
 drivers/bus/dpaa/include/netcfg.h             |  1 -
 drivers/bus/fslmc/qbman/include/compat.h      |  3 -
 drivers/bus/pci/linux/pci_uio.c               | 91 +++++++++++++------
 drivers/bus/pci/linux/pci_vfio.c              |  9 +-
 drivers/bus/vmbus/linux/vmbus_uio.c           |  4 +-
 drivers/bus/vmbus/private.h                   |  5 +-
 drivers/bus/vmbus/rte_vmbus_reg.h             |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c          |  4 +-
 drivers/common/dpaax/caamflib/compat.h        | 40 ++++----
 drivers/common/dpaax/compat.h                 |  5 -
 drivers/common/dpaax/meson.build              |  1 -
 drivers/crypto/virtio/virtio_pci.h            |  3 +-
 drivers/event/dlb/dlb.c                       |  9 +-
 drivers/event/dlb/dlb_priv.h                  |  2 -
 drivers/event/dlb/pf/base/dlb_osdep.h         |  2 +-
 drivers/event/dlb/pf/dlb_main.h               |  5 +-
 drivers/event/dlb/pf/dlb_pf.c                 | 13 ++-
 drivers/event/dlb2/dlb2.c                     |  2 +-
 drivers/event/dlb2/dlb2_priv.h                |  2 -
 drivers/event/dlb2/pf/base/dlb2_osdep.h       |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h             |  5 +-
 drivers/event/dlb2/pf/dlb2_pf.c               | 11 ++-
 drivers/net/bnx2x/ecore_fw_defs.h             | 18 ++--
 drivers/net/cxgbe/base/common.h               | 18 ++--
 drivers/net/igc/igc_flow.c                    |  2 +-
 drivers/net/ionic/ionic_lif.c                 | 25 ++---
 drivers/net/ionic/ionic_main.c                |  3 +-
 drivers/net/ionic/ionic_osdep.h               |  2 +-
 drivers/net/memif/rte_eth_memif.h             |  4 -
 drivers/net/mlx5/linux/mlx5_socket.c          |  4 -
 drivers/net/netvsc/hn_rndis.c                 | 12 +--
 drivers/net/netvsc/hn_rxtx.c                  | 10 +-
 drivers/net/netvsc/hn_var.h                   |  9 +-
 drivers/net/virtio/virtio.h                   |  2 +-
 drivers/net/virtio/virtio_ethdev.c            |  6 +-
 drivers/net/virtio/virtio_ethdev.h            |  4 -
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 17 ++--
 drivers/vdpa/mlx5/mlx5_vdpa_event.c           | 25 ++---
 examples/bbdev_app/main.c                     |  2 +-
 examples/ip_pipeline/Makefile                 |  2 +-
 examples/meson.build                          |  4 +-
 .../performance-thread/l3fwd-thread/main.c    |  4 -
 .../performance-thread/pthread_shim/Makefile  |  1 -
 examples/pipeline/Makefile                    |  2 +-
 examples/vhost_blk/vhost_blk.c                |  4 -
 lib/librte_eal/freebsd/include/rte_os.h       |  5 +-
 lib/librte_eal/linux/include/rte_os.h         |  7 +-
 lib/librte_eal/unix/eal_file.c                |  1 +
 lib/librte_eal/windows/include/rte_os.h       |  5 +-
 63 files changed, 242 insertions(+), 242 deletions(-)
Signature · 1 line
2.30.1
#55 lore raw

PATCH v5 1/17 eal: fix comment of OS-specific header files

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")
---
 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(-)
lib/librte_eal/freebsd/include/rte_os.h +2 -3
index eeb750cd81..c16f2a30e9 100644
@@ -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>
lib/librte_eal/linux/include/rte_os.h +2 -3
index 218d4fa86e..390b87b3a1 100644
@@ -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>
lib/librte_eal/windows/include/rte_os.h +2 -3
index 7ef38ff06c..f0512f20a6 100644
@@ -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>
Signature · 1 line
2.30.1
#56 lore raw

PATCH v5 2/17 buildtools: fix build with busybox

In reply to Thomas Monjalon

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")
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
buildtools/binutils-avx512-check.sh +1 -1
index a7e068140f..2a833b64b7 100755
@@ -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}'
buildtools/check-symbols.sh +1 -1
index e407553a34..6723e38450 100755
@@ -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
 
buildtools/map-list-symbol.sh +1 -1
index 5509b4a7fa..3bf9bd66f8 100755
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
Signature · 1 line
2.30.1
Acked-by on v5 2/17
#57 lore raw

Re: [dpdk-dev] [PATCH v5 02/17] buildtools: fix build with busybox

Quoted 11 lines · Thomas Monjalon

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.

Quoted 7 lines
Fixes 4c82473412e8 ("build: add internal tag check")
Fixes 68b1f1cda5b4 ("build: check AVX512 rather than binutils version")
Fixes 3290ac14eb94 ("buildtools: detect discrepancies for experimental symbols")

---

#58 lore raw

PATCH v5 3/17 build: detect execinfo library on Linux

In reply to Thomas Monjalon

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")
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)
app/meson.build +0 -4
index 87fc195dbf..50a53dbde8 100644
@@ -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'
app/test/meson.build +0 -1
index 561e493a29..099895fc87 100644
@@ -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'
config/meson.build +6 -3
index 3cf560b8a3..66a2edcc47 100644
@@ -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()
examples/meson.build +1 -3
index b9ab24223f..ab06e2da33 100644
@@ -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)
Signature · 1 line
2.30.1
Acked-by on v5 3/17
#59 lore raw

Re: [dpdk-dev] [PATCH v5 03/17] build: detect execinfo library on Linux

Quoted 6 lines · Thomas Monjalon

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.

Quoted 8 lines

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")

---

#60 lore raw

PATCH v5 4/17 build: define _GNU_SOURCE globally

In reply to Thomas Monjalon

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")
---
 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(-)
app/test/meson.build +0 -2
index 099895fc87..76eaaea457 100644
@@ -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'
 
buildtools/pkg-config/meson.build +1 -0
index 39a8fd1c8e..d3f3edaa2f 100644
@@ -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
drivers/bus/fslmc/qbman/include/compat.h +0 -3
index 1ddd69e127..a4471a80af 100644
@@ -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>
drivers/common/dpaax/compat.h +0 -4
index 1a5f36e99e..c69e76ab96 100644
@@ -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>
drivers/common/dpaax/meson.build +0 -1
index 4535482701..b7f177a62e 100644
@@ -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
drivers/net/memif/rte_eth_memif.h +0 -4
index 24321d3a39..2038bda742 100644
@@ -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>
drivers/net/mlx5/linux/mlx5_socket.c +0 -4
index 1938453980..b1f41bc102 100644
@@ -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>
examples/ip_pipeline/Makefile +1 -1
index 96f492a5ea..7933ad7519 100644
@@ -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))
 
examples/performance-thread/l3fwd-thread/main.c +0 -4
index 4d82fb82ef..10bd33d767 100644
@@ -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>
examples/performance-thread/pthread_shim/Makefile +0 -1
index 5aa401dc49..a1f4557cd4 100644
@@ -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
examples/pipeline/Makefile +1 -1
index fcba51fd4d..92caf4aeb2 100644
@@ -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))
 
examples/vhost_blk/vhost_blk.c +0 -4
index 7ea60863da..e9361267a6 100644
@@ -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>
Signature · 1 line
2.30.1
#61 lore raw

Re: [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally

Quoted 3 lines · Thomas Monjalon

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.

#62 lore raw

Re: [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally

26/02/2021 10:08, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 3 lines

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.

#63 lore raw

Re: [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally

Quoted 20 lines · Thomas Monjalon

26/02/2021 10:08, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 3 lines

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:

Quoted 3 lines
	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?

#64 lore raw

Re: [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally

26/02/2021 10:46, Bruce Richardson:

Quoted 24 lines · Thomas Monjalon
Quoted 20 lines

26/02/2021 10:08, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 3 lines

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:

Quoted 3 lines
	typedef void rte_cpuset_t;

so it allows including files, but not using above functions of course.

Quoted 1 line

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?

#65 lore raw

Re: [dpdk-dev] [PATCH v5 04/17] build: define _GNU_SOURCE globally

26/02/2021 11:04, Thomas Monjalon:

Quoted 32 lines

26/02/2021 10:46, Bruce Richardson:

Quoted 24 lines · Thomas Monjalon
Quoted 20 lines

26/02/2021 10:08, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 3 lines

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:

Quoted 3 lines
	typedef void rte_cpuset_t;

so it allows including files, but not using above functions of course.

Quoted 1 line

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.

Quoted 8 lines

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.

#66 lore raw

PATCH v5 5/17 eal/linux: fix build with musl

In reply to Thomas Monjalon

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")
---
 lib/librte_eal/linux/include/rte_os.h | 2 ++
 lib/librte_eal/unix/eal_file.c        | 1 +
 2 files changed, 3 insertions(+)
lib/librte_eal/linux/include/rte_os.h +2 -0
index 390b87b3a1..f3f9982f40 100644
@@ -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_ */
lib/librte_eal/unix/eal_file.c +1 -0
index 1b26475ba4..ec554e0096 100644
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
Signature · 1 line
2.30.1
#67 lore raw

PATCH v5 6/17 drivers: fix header includes for musl

In reply to Thomas Monjalon

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")
---
 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(-)
drivers/bus/dpaa/include/netcfg.h +0 -1
index d7d1befd24..bb18a34e3d 100644
@@ -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 {
drivers/common/dpaax/compat.h +0 -1
index c69e76ab96..7166f8cceb 100644
@@ -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>
drivers/event/dlb/dlb.c +1 -1
index 8b26d1d2d2..2fbfc6aed4 100644
@@ -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>
 
drivers/event/dlb/pf/dlb_pf.c +2 -1
index 3aeef6f91d..876c68e51d 100644
@@ -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>
drivers/event/dlb2/dlb2.c +1 -1
index b28ec58bfb..fb5ff012a4 100644
@@ -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>
drivers/event/dlb2/pf/dlb2_pf.c +2 -1
index 1a7d8fc294..b85fd3ec56 100644
@@ -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>
Signature · 1 line
2.30.1
#68 lore raw

PATCH v5 7/17 drivers: replace page size definitions with function

In reply to Thomas Monjalon

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---
 drivers/bus/pci/linux/pci_vfio.c        |  9 ++-------
 drivers/bus/vmbus/linux/vmbus_uio.c     |  4 ++--
 drivers/bus/vmbus/private.h             |  5 +----
 drivers/bus/vmbus/rte_vmbus_reg.h       |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c    |  4 ++--
 drivers/crypto/virtio/virtio_pci.h      |  3 ++-
 drivers/event/dlb/dlb.c                 |  7 +++++--
 drivers/event/dlb/dlb_priv.h            |  2 --
 drivers/event/dlb/pf/base/dlb_osdep.h   |  2 +-
 drivers/event/dlb/pf/dlb_main.h         |  5 +----
 drivers/event/dlb/pf/dlb_pf.c           | 10 ++++++----
 drivers/event/dlb2/dlb2_priv.h          |  2 --
 drivers/event/dlb2/pf/base/dlb2_osdep.h |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h       |  5 +----
 drivers/event/dlb2/pf/dlb2_pf.c         |  8 ++++----
 drivers/net/bnx2x/ecore_fw_defs.h       | 18 ++++++++++++------
 drivers/net/ionic/ionic_lif.c           | 25 ++++++++++++++-----------
 drivers/net/ionic/ionic_main.c          |  3 ++-
 drivers/net/ionic/ionic_osdep.h         |  2 +-
 drivers/net/netvsc/hn_rndis.c           | 12 ++++++------
 drivers/net/netvsc/hn_rxtx.c            | 10 ++++++----
 drivers/net/netvsc/hn_var.h             |  9 +++------
 drivers/net/virtio/virtio.h             |  2 +-
 drivers/net/virtio/virtio_ethdev.c      |  6 +++---
 drivers/net/virtio/virtio_ethdev.h      |  4 ----
 drivers/vdpa/ifc/ifcvf_vdpa.c           | 17 +++++++----------
 26 files changed, 84 insertions(+), 94 deletions(-)
drivers/bus/pci/linux/pci_vfio.c +2 -7
index e3f7b6abeb..9d689d6fd9 100644
@@ -38,11 +38,6 @@
 
 #ifdef VFIO_PRESENT
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
-#endif
-#define PAGE_MASK   (~(PAGE_SIZE - 1))
-
 static struct rte_tailq_elem rte_vfio_tailq = {
 	.name = "VFIO_RESOURCE_LIST",
 };
@@ -507,8 +502,8 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
 		 */
 		uint32_t table_start = msix_table->offset;
 		uint32_t table_end = table_start + msix_table->size;
-		table_end = RTE_ALIGN(table_end, PAGE_SIZE);
-		table_start = RTE_ALIGN_FLOOR(table_start, PAGE_SIZE);
+		table_end = RTE_ALIGN(table_end, rte_mem_page_size());
+		table_start = RTE_ALIGN_FLOOR(table_start, rte_mem_page_size());
 
 		/* If page-aligned start of MSI-X table is less than the
 		 * actual MSI-X table start address, reassign to the actual
drivers/bus/vmbus/linux/vmbus_uio.c +2 -2
index 5dc0c47de6..b52ca5bf1d 100644
@@ -154,7 +154,7 @@ vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx,
 		vmbus_map_addr = vmbus_find_max_end_va();
 
 	/* offset is special in uio it indicates which resource */
-	offset = idx * PAGE_SIZE;
+	offset = idx * rte_mem_page_size();
 
 	mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags);
 	close(fd);
@@ -224,7 +224,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
 	}
 	file_size = sb.st_size;
 
-	if (file_size == 0 || (file_size & (PAGE_SIZE - 1))) {
+	if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) {
 		VMBUS_LOG(ERR, "incorrect size %s: %zu",
 			  ring_path, file_size);
 
drivers/bus/vmbus/private.h +1 -4
index f19b14e4a6..528d60a42f 100644
@@ -9,13 +9,10 @@
 #include <stdbool.h>
 #include <sys/uio.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_vmbus_reg.h>
 #include <rte_bus_vmbus.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE	4096
-#endif
-
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 extern int vmbus_logtype_bus;
drivers/bus/vmbus/rte_vmbus_reg.h +1 -1
index f5a0693dcb..8562672979 100644
@@ -100,7 +100,7 @@ struct vmbus_bufring {
 		uint32_t value;
 	} feature_bits;
 
-	/* Pad it to PAGE_SIZE so that data starts on page boundary */
+	/* Pad it to rte_mem_page_size() so that data starts on page boundary */
 	uint8_t	reserved2[4028];
 
 	/*
drivers/bus/vmbus/vmbus_common_uio.c +2 -2
index a689bf11b3..8582e32c1d 100644
@@ -63,7 +63,7 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev)
 
 	for (i = 0; i != uio_res->nb_maps; i++) {
 		void *mapaddr;
-		off_t offset = i * PAGE_SIZE;
+		off_t offset = i * rte_mem_page_size();
 
 		mapaddr = vmbus_map_resource(uio_res->maps[i].addr,
 					     fd, offset,
@@ -175,7 +175,7 @@ vmbus_uio_map_resource(struct rte_vmbus_device *dev)
 	}
 
 	dev->int_page = (uint32_t *)((char *)uio_res->maps[HV_INT_PAGE_MAP].addr
-				     + (PAGE_SIZE >> 1));
+				     + (rte_mem_page_size() >> 1));
 	dev->monitor_page = uio_res->maps[HV_MON_PAGE_MAP].addr;
 	return 0;
 }
drivers/crypto/virtio/virtio_pci.h +2 -1
index d9a214dfd0..0a7ea1bb64 100644
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#include <rte_eal_paging.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_cryptodev.h>
@@ -67,7 +68,7 @@ struct virtqueue;
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int) (rte_mem_page_size() / 16))
 
 /* Do we get callbacks when the ring is completely used, even if we've
  * suppressed them?
drivers/event/dlb/dlb.c +5 -2
index 2fbfc6aed4..60084ced3b 100644
@@ -23,6 +23,7 @@
 #include <rte_io.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_power_intrinsics.h>
@@ -991,7 +992,8 @@ dlb_hw_create_ldb_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_LDB_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_LDB_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
@@ -1181,7 +1183,8 @@ dlb_hw_create_dir_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_DIR_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_DIR_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
drivers/event/dlb/dlb_priv.h +0 -2
index 272e17482f..ca4d6a84cf 100644
@@ -76,8 +76,6 @@
 
 #define PP_BASE(is_dir) ((is_dir) ? DLB_DIR_PP_BASE : DLB_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb/pf/base/dlb_osdep.h +1 -1
index 0c119b759a..dee20660ed 100644
@@ -92,7 +92,7 @@ static inline void *os_map_producer_port(struct dlb_hw *hw,
 
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 
drivers/event/dlb/pf/dlb_main.h +1 -4
index 22e215223d..e66ba228d1 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb_hw_types.h"
 #include "../dlb_user.h"
drivers/event/dlb/pf/dlb_pf.c +6 -4
index 876c68e51d..5445c2d57d 100644
@@ -304,7 +304,7 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -329,7 +329,8 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_LDB].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_LDB].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
@@ -382,7 +383,7 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -407,7 +408,8 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_DIR].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_DIR].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
drivers/event/dlb2/dlb2_priv.h +0 -2
index b73cf3ff14..eb1a932399 100644
@@ -78,8 +78,6 @@
 				    DLB2_LDB_CQ_MAX_SIZE)
 #define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB2_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB2_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb2/pf/base/dlb2_osdep.h +1 -1
index c4c34eba5f..aa101a49a3 100644
@@ -89,7 +89,7 @@ static inline void *os_map_producer_port(struct dlb2_hw *hw,
 	uint64_t pp_dma_base;
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 }
drivers/event/dlb2/pf/dlb2_main.h +1 -4
index f3bee71fb6..9eeda482a3 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb2_hw_types.h"
 #include "../dlb2_user.h"
drivers/event/dlb2/pf/dlb2_pf.c +4 -4
index b85fd3ec56..cfb22efe8a 100644
@@ -285,7 +285,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -308,7 +308,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void *)(port_base);
 	memset(&port_memory, 0, sizeof(port_memory));
@@ -360,7 +360,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -383,7 +383,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
 		(void *)(port_base);
drivers/net/bnx2x/ecore_fw_defs.h +12 -6
index 5397a701aa..93bca8ad33 100644
@@ -13,6 +13,8 @@
 #ifndef ECORE_FW_DEFS_H
 #define ECORE_FW_DEFS_H
 
+#include <rte_eal_paging.h>
+
 #define CSTORM_ASSERT_LIST_INDEX_OFFSET	(IRO[152].base)
 #define CSTORM_ASSERT_LIST_OFFSET(assertListEntry) \
 	(IRO[151].base + ((assertListEntry) * IRO[151].m1))
@@ -252,7 +254,8 @@
 #define X_ETH_LOCAL_RING_SIZE 13
 #define FIRST_BD_IN_PKT	0
 #define PARSE_BD_INDEX 1
-#define NUM_OF_ETH_BDS_IN_PAGE ((PAGE_SIZE)/(STRUCT_SIZE(eth_tx_bd)/8))
+#define NUM_OF_ETH_BDS_IN_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_tx_bd) / 8))
 #define U_ETH_NUM_OF_SGES_TO_FETCH 8
 #define U_ETH_MAX_SGES_FOR_PACKET 3
 
@@ -265,11 +268,14 @@
 #define IP_HEADER_ALIGNMENT_PADDING 2
 
 #define U_ETH_SGES_PER_PAGE_INVERSE_MASK \
-	(0xFFFF - ((PAGE_SIZE/((STRUCT_SIZE(eth_rx_sge))/8))-1))
+	(0xFFFF - ((rte_mem_page_size() / ((STRUCT_SIZE(eth_rx_sge)) / 8)) - 1))
 
-#define TU_ETH_CQES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_cqe)/8))
-#define U_ETH_BDS_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_bd)/8))
-#define U_ETH_SGES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_sge)/8))
+#define TU_ETH_CQES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_cqe) / 8))
+#define U_ETH_BDS_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_bd) / 8))
+#define U_ETH_SGES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_sge) / 8))
 
 #define U_ETH_BDS_PER_PAGE_MASK	(U_ETH_BDS_PER_PAGE-1)
 #define U_ETH_CQE_PER_PAGE_MASK	(TU_ETH_CQES_PER_PAGE-1)
@@ -396,7 +402,7 @@
 
 /* Event Ring definitions */
 #define C_ERES_PER_PAGE \
-	(PAGE_SIZE / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
+	(rte_mem_page_size() / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
 #define C_ERE_PER_PAGE_MASK (C_ERES_PER_PAGE - 1)
 
 /* number of statistic command */
drivers/net/ionic/ionic_lif.c +14 -11
index e083f92417..395e5acc8b 100644
@@ -617,18 +617,18 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	cq_size = num_descs * cq_desc_size;
 	sg_size = num_descs * sg_desc_size;
 
-	total_size = RTE_ALIGN(q_size, PAGE_SIZE) +
-		RTE_ALIGN(cq_size, PAGE_SIZE);
+	total_size = RTE_ALIGN(q_size, rte_mem_page_size()) +
+			RTE_ALIGN(cq_size, rte_mem_page_size());
 	/*
 	 * Note: aligning q_size/cq_size is not enough due to cq_base address
 	 * aligning as q_base could be not aligned to the page.
-	 * Adding PAGE_SIZE.
+	 * Adding rte_mem_page_size().
 	 */
-	total_size += PAGE_SIZE;
+	total_size += rte_mem_page_size();
 
 	if (flags & IONIC_QCQ_F_SG) {
-		total_size += RTE_ALIGN(sg_size, PAGE_SIZE);
-		total_size += PAGE_SIZE;
+		total_size += RTE_ALIGN(sg_size, rte_mem_page_size());
+		total_size += rte_mem_page_size();
 	}
 
 	new = rte_zmalloc("ionic", sizeof(*new), 0);
@@ -679,13 +679,16 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	q_base = new->base;
 	q_base_pa = new->base_pa;
 
-	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size, PAGE_SIZE);
-	cq_base_pa = RTE_ALIGN(q_base_pa + q_size, PAGE_SIZE);
+	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size,
+			rte_mem_page_size());
+	cq_base_pa = RTE_ALIGN(q_base_pa + q_size,
+			rte_mem_page_size());
 
 	if (flags & IONIC_QCQ_F_SG) {
 		sg_base = (void *)RTE_ALIGN((uintptr_t)cq_base + cq_size,
-			PAGE_SIZE);
-		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size, PAGE_SIZE);
+				rte_mem_page_size());
+		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size,
+				rte_mem_page_size());
 		ionic_q_sg_map(&new->q, sg_base, sg_base_pa);
 	}
 
@@ -975,7 +978,7 @@ ionic_lif_alloc(struct ionic_lif *lif)
 
 	IONIC_PRINT(DEBUG, "Allocating Lif Info");
 
-	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
+	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), rte_mem_page_size());
 
 	lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
 		"lif_info", 0 /* queue_idx*/,
drivers/net/ionic/ionic_main.c +2 -1
index 3f1a764888..3ee4999fa5 100644
@@ -375,7 +375,8 @@ ionic_port_init(struct ionic_adapter *adapter)
 	if (idev->port_info)
 		return 0;
 
-	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
+	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info),
+			rte_mem_page_size());
 
 	snprintf(z_name, sizeof(z_name), "%s_port_%s_info",
 		IONIC_DRV_NAME, adapter->name);
drivers/net/ionic/ionic_osdep.h +1 -1
index a6575c36b5..89ed106d11 100644
@@ -17,6 +17,7 @@
 #include <rte_byteorder.h>
 #include <rte_io.h>
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 
 #include "ionic_logs.h"
 
@@ -25,7 +26,6 @@
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT      12
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
 #endif
 
 #define __iomem
drivers/net/netvsc/hn_rndis.c +6 -6
index e317539de7..e3f7e636d7 100644
@@ -67,7 +67,7 @@ hn_rndis_rid(struct hn_data *hv)
 
 static void *hn_rndis_alloc(size_t size)
 {
-	return rte_zmalloc("RNDIS", size, PAGE_SIZE);
+	return rte_zmalloc("RNDIS", size, rte_mem_page_size());
 }
 
 #ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP
@@ -265,17 +265,17 @@ static int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
 		return -EINVAL;
 	}
 
-	if (unlikely(reqlen > PAGE_SIZE)) {
+	if (unlikely(reqlen > rte_mem_page_size())) {
 		PMD_DRV_LOG(ERR, "RNDIS request %u greater than page size",
 			    reqlen);
 		return -EINVAL;
 	}
 
-	sg.page = addr / PAGE_SIZE;
+	sg.page = addr / rte_mem_page_size();
 	sg.ofs  = addr & PAGE_MASK;
 	sg.len  = reqlen;
 
-	if (sg.ofs + reqlen >  PAGE_SIZE) {
+	if (sg.ofs + reqlen >  rte_mem_page_size()) {
 		PMD_DRV_LOG(ERR, "RNDIS request crosses page boundary");
 		return -EINVAL;
 	}
@@ -479,7 +479,7 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
 		return -ENOMEM;
 
 	comp_len = sizeof(*comp) + odlen;
-	comp = rte_zmalloc("QUERY", comp_len, PAGE_SIZE);
+	comp = rte_zmalloc("QUERY", comp_len, rte_mem_page_size());
 	if (!comp) {
 		error = -ENOMEM;
 		goto done;
@@ -736,7 +736,7 @@ hn_rndis_set(struct hn_data *hv, uint32_t oid, const void *data, uint32_t dlen)
 	int error;
 
 	reqlen = sizeof(*req) + dlen;
-	req = rte_zmalloc("RNDIS_SET", reqlen, PAGE_SIZE);
+	req = rte_zmalloc("RNDIS_SET", reqlen, rte_mem_page_size());
 	if (!req)
 		return -ENOMEM;
 
drivers/net/netvsc/hn_rxtx.c +6 -4
index 0f4ef0100b..c6bf7cc132 100644
@@ -1387,7 +1387,8 @@ static unsigned int hn_get_slots(const struct rte_mbuf *m)
 		unsigned int size = rte_pktmbuf_data_len(m);
 		unsigned int offs = rte_mbuf_data_iova(m) & PAGE_MASK;
 
-		slots += (offs + size + PAGE_SIZE - 1) / PAGE_SIZE;
+		slots += (offs + size + rte_mem_page_size() - 1) /
+				rte_mem_page_size();
 		m = m->next;
 	}
 
@@ -1402,12 +1403,13 @@ static unsigned int hn_fill_sg(struct vmbus_gpa *sg,
 
 	while (m) {
 		rte_iova_t addr = rte_mbuf_data_iova(m);
-		unsigned int page = addr / PAGE_SIZE;
+		unsigned int page = addr / rte_mem_page_size();
 		unsigned int offset = addr & PAGE_MASK;
 		unsigned int len = rte_pktmbuf_data_len(m);
 
 		while (len > 0) {
-			unsigned int bytes = RTE_MIN(len, PAGE_SIZE - offset);
+			unsigned int bytes = RTE_MIN(len,
+					rte_mem_page_size() - offset);
 
 			sg[segs].page = page;
 			sg[segs].ofs = offset;
@@ -1450,7 +1452,7 @@ static int hn_xmit_sg(struct hn_tx_queue *txq,
 	addr = txq->tx_rndis_iova +
 		((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
 
-	sg[0].page = addr / PAGE_SIZE;
+	sg[0].page = addr / rte_mem_page_size();
 	sg[0].ofs = addr & PAGE_MASK;
 	sg[0].len = RNDIS_PACKET_MSG_OFFSET_ABS(hn_rndis_pktlen(txd->rndis_pkt));
 	segs = 1;
drivers/net/netvsc/hn_var.h +3 -6
index b7405ca726..43642408bc 100644
@@ -6,6 +6,8 @@
  * All rights reserved.
  */
 
+#include <rte_eal_paging.h>
+
 /*
  * Tunable ethdev params
  */
@@ -28,13 +30,8 @@
 
 #define HN_RX_EXTMBUF_ENABLE	0
 
-/* Buffers need to be aligned */
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #ifndef PAGE_MASK
-#define PAGE_MASK (PAGE_SIZE - 1)
+#define PAGE_MASK (rte_mem_page_size() - 1)
 #endif
 
 struct hn_data;
drivers/net/virtio/virtio.h +1 -1
index 21d54904e7..2c987d19ab 100644
@@ -98,7 +98,7 @@
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int)(PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int)(rte_mem_page_size() / 16))
 
 /*
  * Maximum number of virtqueues per device.
drivers/net/virtio/virtio_ethdev.c +3 -3
index 333a5243a9..289b240c4e 100644
@@ -21,8 +21,8 @@
 #include <rte_errno.h>
 #include <rte_cpuflags.h>
 #include <rte_vect.h>
-
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <rte_cycles.h>
@@ -469,7 +469,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		sz_hdr_mz = vq_size * sizeof(struct virtio_tx_region);
 	} else if (queue_type == VTNET_CQ) {
 		/* Allocate a page for control vq command, data and status */
-		sz_hdr_mz = PAGE_SIZE;
+		sz_hdr_mz = rte_mem_page_size();
 	}
 
 	vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
@@ -568,7 +568,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		cvq->mz = mz;
 		cvq->virtio_net_hdr_mz = hdr_mz;
 		cvq->virtio_net_hdr_mem = hdr_mz->iova;
-		memset(cvq->virtio_net_hdr_mz->addr, 0, PAGE_SIZE);
+		memset(cvq->virtio_net_hdr_mz->addr, 0, rte_mem_page_size());
 
 		hw->cvq = cvq;
 	}
drivers/net/virtio/virtio_ethdev.h +0 -4
index 873327d989..5a501e7890 100644
@@ -11,10 +11,6 @@
 
 #include "virtio.h"
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define VIRTIO_MAX_RX_QUEUES 128U
 #define VIRTIO_MAX_TX_QUEUES 128U
 #define VIRTIO_MAX_MAC_ADDRS 64
drivers/vdpa/ifc/ifcvf_vdpa.c +7 -10
index 6a1b44bc77..39237aecf7 100644
@@ -11,6 +11,7 @@
 #include <linux/virtio_net.h>
 #include <stdbool.h>
 
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_bus_pci.h>
@@ -30,10 +31,6 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define IFCVF_USED_RING_LEN(size) \
 	((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3)
 
@@ -600,11 +597,11 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 	for (i = 0; i < nr_vring; i++) {
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
-		vring_buf = rte_zmalloc("ifcvf", size, PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
+		vring_buf = rte_zmalloc("ifcvf", size, rte_mem_page_size());
 		vring_init(&internal->m_vring[i], vq.size, vring_buf,
-				PAGE_SIZE);
+				rte_mem_page_size());
 
 		ret = rte_vfio_container_dma_map(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)vring_buf, m_vring_iova, size);
@@ -686,8 +683,8 @@ m_ifcvf_stop(struct ifcvf_internal *internal)
 		len = IFCVF_USED_RING_LEN(vq.size);
 		rte_vhost_log_used_vring(vid, i, 0, len);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
 		rte_vfio_container_dma_unmap(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)internal->m_vring[i].desc,
 			m_vring_iova, size);
Signature · 1 line
2.30.1
#69 lore raw

PATCH v5 8/17 bus/pci: support I/O port operations with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/bus/pci/linux/pci_uio.c | 91 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 30 deletions(-)
drivers/bus/pci/linux/pci_uio.c +61 -30
index f3305a2f28..1294f505be 100644
@@ -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);
 		}
 	}
 }
Signature · 1 line
2.30.1
#70 lore raw

PATCH v5 9/17 bus/dpaa: fix 64-bit arch detection

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/dpaa/include/fsl_qman.h +1 -1
index 10212f0fd5..7ef2f3b2e3 100644
@@ -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.
Signature · 1 line
2.30.1
#71 lore raw

PATCH v5 10/17 bus/dpaa: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index b7009f2299..bcedbaf68f 100644
@@ -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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +9 -4
index 750b756b93..c0b9e3da77 100644
@@ -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;
 }
 
drivers/bus/dpaa/base/qbman/qman_driver.c +12 -5
index 6d9aaff164..93375d1ea8 100644
@@ -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;
 	}
Signature · 1 line
2.30.1
#72 lore raw

PATCH v5 11/17 common/dpaax/caamflib: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/dpaax/caamflib/compat.h +6 -6
index 36ee4b5335..c1a693498d 100644
@@ -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)
Signature · 1 line
2.30.1
#73 lore raw

PATCH v5 12/17 common/dpaax/caamflib: simplify log macros

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

Simplify pr_debug, pr_err and pr_warn macros by adding an intermediate pr_msg macro. This way we only need to test for SUPPRESS_PRINTS once.

---
 drivers/common/dpaax/caamflib/compat.h | 28 +++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/common/dpaax/caamflib/compat.h +12 -16
index c1a693498d..9776eed437 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __rte_unused
 #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0)
+#else
+#define pr_msg(l, fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
Signature · 1 line
2.30.1
#74 lore raw

PATCH v5 13/17 net/cxgbe: remove use of uint type

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +9 -9
index 202a2f4baf..ab100d784c 100644
@@ -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;
 };
Signature · 1 line
2.30.1
#75 lore raw

PATCH v5 14/17 net/igc: remove use of uint type

In reply to Thomas Monjalon

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

Fixes 746664d546fb ("net/igc: support flow API")
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/igc/igc_flow.c +1 -1
index 1bb64d323c..66053060af 100644
@@ -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",
Signature · 1 line
2.30.1
Acked-by on v5 14/17
#76 lore raw

Re: [dpdk-dev] [PATCH v5 14/17] net/igc: remove use of uint type

Quoted 12 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, February 26, 2021 02:23
To: [email protected]
Cc: [email protected]; [email protected]; David Marchand <[email protected]>; Guo, Jia <[email protected]>; Wang, Haiyue <[email protected]>; Yigit, Ferruh <[email protected]>; Zhang, AlvinX <[email protected]>
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'.

Quoted 9 lines
Fixes 746664d546fb ("net/igc: support flow API")
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line

2.30.1

#77 lore raw

PATCH v5 15/17 vdpa/mlx5: replace pthread functions unavailable in musl

In reply to 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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +13 -12
index 86adc864f5..49632dfaa7 100644
@@ -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) {
Signature · 1 line
2.30.1
Acked-by on v5 15/17
#78 lore raw

Re: [dpdk-dev] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl

From: Thomas Monjalon

Quoted 6 lines

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().

Quoted 6 lines
Fixes b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling")
Fixes 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling

thread")
Cc: [email protected]

#79 lore raw

PATCH v5 16/17 app/testpmd: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
app/test-pmd/bpf_cmd.c +1 -1
index 066619e115..6980291f07 100644
@@ -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),
app/test-pmd/config.c +1 -1
index dab8afe5dd..9ca03c236e 100644
@@ -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;
app/test-pmd/testpmd.h +1 -1
index 4aca522859..5437b6229e 100644
@@ -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);
Signature · 1 line
2.30.1
#80 lore raw

PATCH v5 17/17 examples/bbdev: fix header include for musl

In reply to Thomas Monjalon

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")
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/bbdev_app/main.c +1 -1
index 2e170caf84..20cfd327fb 100644
@@ -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>
Signature · 1 line
2.30.1
#81 lore raw

v6 cover Alpine/musl build support

In reply to Natanael Copa

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

The goal is to run a container with the following Dockerfile:
8< ------------
FROM alpine

# DPDK prerequisites

RUN apk --no-cache add \
    gcc libc-dev bsd-compat-headers linux-headers \
    python3 py3-elftools meson ninja \
    libexecinfo-dev numactl-dev zlib-dev libpcap-dev libbpf-dev openssl-dev
# mlx prerequisites
RUN apk --no-cache add \
    git cmake libnl3-dev
RUN git clone https://github.com/linux-rdma/rdma-core.git
WORKDIR /rdma-core/build
RUN cmake -DNO_MAN_PAGES=1 -DNO_PYVERBS=1 -GNinja ..
RUN ninja install
WORKDIR /
# download
ARG version
RUN if [ "$version" = git ] ; then \
        git clone http://dpdk.org/git/dpdk dpdk-$version ;\
    else \
        wget http://fast.dpdk.org/rel/dpdk-$version.tar.xz && \
        tar xf dpdk-$version.tar.xz ;\
    fi
# build
WORKDIR dpdk-$version/build
RUN meson ..
RUN ninja install
8< ------------

v6: do not set _GNU_SOURCE in pkg-config

Natanael Copa (7):
bus/pci: support I/O port operations with musl
bus/dpaa: fix 64-bit arch detection
bus/dpaa: fix build with musl
common/dpaax/caamflib: fix build with musl
common/dpaax/caamflib: simplify log macros
net/cxgbe: remove use of uint type
app/testpmd: fix build with musl

Thomas Monjalon (10):
eal: fix comment of OS-specific header files
buildtools: fix build with busybox
build: detect execinfo library on Linux
build: remove redundant _GNU_SOURCE definitions
eal: fix build with musl
drivers: fix header includes for musl
drivers: replace page size definitions with function net/igc: remove use of uint type
vdpa/mlx5: replace pthread functions unavailable in musl examples/bbdev: fix header include for musl

 app/meson.build                           |  4 -
 app/test-pmd/bpf_cmd.c                    |  2 +-
 app/test-pmd/config.c                     |  2 +-
 app/test-pmd/testpmd.h                    |  2 +-
 app/test/meson.build                      |  3 -
 buildtools/binutils-avx512-check.sh       |  2 +-
 buildtools/check-symbols.sh               |  2 +-
 buildtools/map-list-symbol.sh             |  2 +-
 config/meson.build                        |  9 ++-
 doc/api/doxy-api.conf.in                  |  3 +-
 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/fsl_qman.h       |  2 +-
 drivers/bus/dpaa/include/netcfg.h         |  1 -
 drivers/bus/fslmc/qbman/include/compat.h  |  3 -
 drivers/bus/pci/linux/pci_uio.c           | 91 +++++++++++++++--------
 drivers/bus/pci/linux/pci_vfio.c          |  9 +--
 drivers/bus/vmbus/linux/vmbus_uio.c       |  4 +-
 drivers/bus/vmbus/private.h               |  5 +-
 drivers/bus/vmbus/rte_vmbus_reg.h         |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c      |  4 +-
 drivers/common/dpaax/caamflib/compat.h    | 40 +++++-----
 drivers/common/dpaax/compat.h             |  5 --
 drivers/common/dpaax/meson.build          |  1 -
 drivers/crypto/virtio/virtio_pci.h        |  3 +-
 drivers/event/dlb/dlb.c                   |  9 ++-
 drivers/event/dlb/dlb_priv.h              |  2 -
 drivers/event/dlb/pf/base/dlb_osdep.h     |  2 +-
 drivers/event/dlb/pf/dlb_main.h           |  5 +-
 drivers/event/dlb/pf/dlb_pf.c             | 13 ++--
 drivers/event/dlb2/dlb2.c                 |  2 +-
 drivers/event/dlb2/dlb2_priv.h            |  2 -
 drivers/event/dlb2/pf/base/dlb2_osdep.h   |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h         |  5 +-
 drivers/event/dlb2/pf/dlb2_pf.c           | 11 +--
 drivers/net/bnx2x/ecore_fw_defs.h         | 18 +++--
 drivers/net/cxgbe/base/common.h           | 18 ++---
 drivers/net/igc/igc_flow.c                |  2 +-
 drivers/net/ionic/ionic_lif.c             | 25 ++++---
 drivers/net/ionic/ionic_main.c            |  3 +-
 drivers/net/ionic/ionic_osdep.h           |  2 +-
 drivers/net/memif/rte_eth_memif.h         |  4 -
 drivers/net/mlx5/linux/mlx5_socket.c      |  4 -
 drivers/net/netvsc/hn_rndis.c             | 12 +--
 drivers/net/netvsc/hn_rxtx.c              | 10 ++-
 drivers/net/netvsc/hn_var.h               |  9 +--
 drivers/net/virtio/virtio.h               |  2 +-
 drivers/net/virtio/virtio_ethdev.c        |  6 +-
 drivers/net/virtio/virtio_ethdev.h        |  4 -
 drivers/vdpa/ifc/ifcvf_vdpa.c             | 17 ++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c       | 25 ++++---
 examples/bbdev_app/main.c                 |  2 +-
 examples/meson.build                      |  4 +-
 lib/librte_eal/freebsd/include/rte_os.h   |  6 +-
 lib/librte_eal/include/rte_lcore.h        |  4 +
 lib/librte_eal/include/rte_thread.h       |  4 +
 lib/librte_eal/linux/include/rte_os.h     |  8 +-
 lib/librte_eal/unix/eal_file.c            |  1 +
 lib/librte_eal/windows/include/rte_os.h   |  5 +-
 lib/librte_eal/windows/include/sched.h    |  1 +
 lib/librte_telemetry/rte_telemetry.h      |  4 +
 62 files changed, 256 insertions(+), 232 deletions(-)
Signature · 1 line
2.30.1
#82 lore raw

PATCH v6 1/17 eal: fix comment of OS-specific header files

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")
---
 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(-)
lib/librte_eal/freebsd/include/rte_os.h +2 -3
index eeb750cd81..c16f2a30e9 100644
@@ -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>
lib/librte_eal/linux/include/rte_os.h +2 -3
index 218d4fa86e..390b87b3a1 100644
@@ -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>
lib/librte_eal/windows/include/rte_os.h +2 -3
index 7ef38ff06c..f0512f20a6 100644
@@ -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>
Signature · 1 line
2.30.1
#83 lore raw

PATCH v6 2/17 buildtools: fix build with busybox

In reply to Thomas Monjalon

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")
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
buildtools/binutils-avx512-check.sh +1 -1
index a7e068140f..2a833b64b7 100755
@@ -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}'
buildtools/check-symbols.sh +1 -1
index e407553a34..6723e38450 100755
@@ -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
 
buildtools/map-list-symbol.sh +1 -1
index 5509b4a7fa..3bf9bd66f8 100755
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
Signature · 1 line
2.30.1
#84 lore raw

PATCH v6 3/17 build: detect execinfo library on Linux

In reply to Thomas Monjalon

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")
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)
app/meson.build +0 -4
index 87fc195dbf..50a53dbde8 100644
@@ -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'
app/test/meson.build +0 -1
index 561e493a29..099895fc87 100644
@@ -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'
config/meson.build +6 -3
index 3cf560b8a3..66a2edcc47 100644
@@ -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()
examples/meson.build +1 -3
index b9ab24223f..ab06e2da33 100644
@@ -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)
Signature · 1 line
2.30.1
#85 lore raw

PATCH v6 4/17 build: remove redundant _GNU_SOURCE definitions

In reply to Thomas Monjalon

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")
---
 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(-)
app/test/meson.build +0 -2
index 099895fc87..76eaaea457 100644
@@ -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'
 
drivers/bus/fslmc/qbman/include/compat.h +0 -3
index 1ddd69e127..a4471a80af 100644
@@ -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>
drivers/common/dpaax/compat.h +0 -4
index 1a5f36e99e..c69e76ab96 100644
@@ -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>
drivers/common/dpaax/meson.build +0 -1
index 4535482701..b7f177a62e 100644
@@ -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
drivers/net/memif/rte_eth_memif.h +0 -4
index 24321d3a39..2038bda742 100644
@@ -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>
drivers/net/mlx5/linux/mlx5_socket.c +0 -4
index 1938453980..b1f41bc102 100644
@@ -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>
Signature · 1 line
2.30.1
#86 lore raw

PATCH v6 5/17 eal: fix build with musl

In reply to Thomas Monjalon

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")
---
 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(-)
doc/api/doxy-api.conf.in +2 -1
index 5c883b613b..a536bcb493 100644
@@ -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
lib/librte_eal/freebsd/include/rte_os.h +1 -0
index c16f2a30e9..627f0483ab 100644
@@ -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; \
lib/librte_eal/include/rte_lcore.h +4 -0
index 0fe0bd839c..1550b75da0 100644
@@ -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.
  *
lib/librte_eal/include/rte_thread.h +4 -0
index e640ea1857..ac5a89b1ad 100644
@@ -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.
lib/librte_eal/linux/include/rte_os.h +3 -0
index 390b87b3a1..1618b4df22 100644
@@ -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_ */
lib/librte_eal/unix/eal_file.c +1 -0
index 1b26475ba4..ec554e0096 100644
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
lib/librte_eal/windows/include/sched.h +1 -0
index fbe07f742c..ff572b5dcb 100644
@@ -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)))
 
lib/librte_telemetry/rte_telemetry.h +4 -0
index f8e54dc68e..3ff3a42d78 100644
@@ -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.
Signature · 1 line
2.30.1
#87 lore raw

PATCH v6 6/17 drivers: fix header includes for musl

In reply to Thomas Monjalon

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")
---
 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(-)
drivers/bus/dpaa/include/netcfg.h +0 -1
index d7d1befd24..bb18a34e3d 100644
@@ -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 {
drivers/common/dpaax/compat.h +0 -1
index c69e76ab96..7166f8cceb 100644
@@ -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>
drivers/event/dlb/dlb.c +1 -1
index 8b26d1d2d2..2fbfc6aed4 100644
@@ -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>
 
drivers/event/dlb/pf/dlb_pf.c +2 -1
index 3aeef6f91d..876c68e51d 100644
@@ -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>
drivers/event/dlb2/dlb2.c +1 -1
index b28ec58bfb..fb5ff012a4 100644
@@ -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>
drivers/event/dlb2/pf/dlb2_pf.c +2 -1
index 1a7d8fc294..b85fd3ec56 100644
@@ -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>
Signature · 1 line
2.30.1
#88 lore raw

PATCH v6 7/17 drivers: replace page size definitions with function

In reply to Thomas Monjalon

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---
 drivers/bus/pci/linux/pci_vfio.c        |  9 ++-------
 drivers/bus/vmbus/linux/vmbus_uio.c     |  4 ++--
 drivers/bus/vmbus/private.h             |  5 +----
 drivers/bus/vmbus/rte_vmbus_reg.h       |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c    |  4 ++--
 drivers/crypto/virtio/virtio_pci.h      |  3 ++-
 drivers/event/dlb/dlb.c                 |  7 +++++--
 drivers/event/dlb/dlb_priv.h            |  2 --
 drivers/event/dlb/pf/base/dlb_osdep.h   |  2 +-
 drivers/event/dlb/pf/dlb_main.h         |  5 +----
 drivers/event/dlb/pf/dlb_pf.c           | 10 ++++++----
 drivers/event/dlb2/dlb2_priv.h          |  2 --
 drivers/event/dlb2/pf/base/dlb2_osdep.h |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h       |  5 +----
 drivers/event/dlb2/pf/dlb2_pf.c         |  8 ++++----
 drivers/net/bnx2x/ecore_fw_defs.h       | 18 ++++++++++++------
 drivers/net/ionic/ionic_lif.c           | 25 ++++++++++++++-----------
 drivers/net/ionic/ionic_main.c          |  3 ++-
 drivers/net/ionic/ionic_osdep.h         |  2 +-
 drivers/net/netvsc/hn_rndis.c           | 12 ++++++------
 drivers/net/netvsc/hn_rxtx.c            | 10 ++++++----
 drivers/net/netvsc/hn_var.h             |  9 +++------
 drivers/net/virtio/virtio.h             |  2 +-
 drivers/net/virtio/virtio_ethdev.c      |  6 +++---
 drivers/net/virtio/virtio_ethdev.h      |  4 ----
 drivers/vdpa/ifc/ifcvf_vdpa.c           | 17 +++++++----------
 26 files changed, 84 insertions(+), 94 deletions(-)
drivers/bus/pci/linux/pci_vfio.c +2 -7
index e3f7b6abeb..9d689d6fd9 100644
@@ -38,11 +38,6 @@
 
 #ifdef VFIO_PRESENT
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
-#endif
-#define PAGE_MASK   (~(PAGE_SIZE - 1))
-
 static struct rte_tailq_elem rte_vfio_tailq = {
 	.name = "VFIO_RESOURCE_LIST",
 };
@@ -507,8 +502,8 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
 		 */
 		uint32_t table_start = msix_table->offset;
 		uint32_t table_end = table_start + msix_table->size;
-		table_end = RTE_ALIGN(table_end, PAGE_SIZE);
-		table_start = RTE_ALIGN_FLOOR(table_start, PAGE_SIZE);
+		table_end = RTE_ALIGN(table_end, rte_mem_page_size());
+		table_start = RTE_ALIGN_FLOOR(table_start, rte_mem_page_size());
 
 		/* If page-aligned start of MSI-X table is less than the
 		 * actual MSI-X table start address, reassign to the actual
drivers/bus/vmbus/linux/vmbus_uio.c +2 -2
index 5dc0c47de6..b52ca5bf1d 100644
@@ -154,7 +154,7 @@ vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx,
 		vmbus_map_addr = vmbus_find_max_end_va();
 
 	/* offset is special in uio it indicates which resource */
-	offset = idx * PAGE_SIZE;
+	offset = idx * rte_mem_page_size();
 
 	mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags);
 	close(fd);
@@ -224,7 +224,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
 	}
 	file_size = sb.st_size;
 
-	if (file_size == 0 || (file_size & (PAGE_SIZE - 1))) {
+	if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) {
 		VMBUS_LOG(ERR, "incorrect size %s: %zu",
 			  ring_path, file_size);
 
drivers/bus/vmbus/private.h +1 -4
index f19b14e4a6..528d60a42f 100644
@@ -9,13 +9,10 @@
 #include <stdbool.h>
 #include <sys/uio.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_vmbus_reg.h>
 #include <rte_bus_vmbus.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE	4096
-#endif
-
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 extern int vmbus_logtype_bus;
drivers/bus/vmbus/rte_vmbus_reg.h +1 -1
index f5a0693dcb..8562672979 100644
@@ -100,7 +100,7 @@ struct vmbus_bufring {
 		uint32_t value;
 	} feature_bits;
 
-	/* Pad it to PAGE_SIZE so that data starts on page boundary */
+	/* Pad it to rte_mem_page_size() so that data starts on page boundary */
 	uint8_t	reserved2[4028];
 
 	/*
drivers/bus/vmbus/vmbus_common_uio.c +2 -2
index a689bf11b3..8582e32c1d 100644
@@ -63,7 +63,7 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev)
 
 	for (i = 0; i != uio_res->nb_maps; i++) {
 		void *mapaddr;
-		off_t offset = i * PAGE_SIZE;
+		off_t offset = i * rte_mem_page_size();
 
 		mapaddr = vmbus_map_resource(uio_res->maps[i].addr,
 					     fd, offset,
@@ -175,7 +175,7 @@ vmbus_uio_map_resource(struct rte_vmbus_device *dev)
 	}
 
 	dev->int_page = (uint32_t *)((char *)uio_res->maps[HV_INT_PAGE_MAP].addr
-				     + (PAGE_SIZE >> 1));
+				     + (rte_mem_page_size() >> 1));
 	dev->monitor_page = uio_res->maps[HV_MON_PAGE_MAP].addr;
 	return 0;
 }
drivers/crypto/virtio/virtio_pci.h +2 -1
index d9a214dfd0..0a7ea1bb64 100644
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#include <rte_eal_paging.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_cryptodev.h>
@@ -67,7 +68,7 @@ struct virtqueue;
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int) (rte_mem_page_size() / 16))
 
 /* Do we get callbacks when the ring is completely used, even if we've
  * suppressed them?
drivers/event/dlb/dlb.c +5 -2
index 2fbfc6aed4..60084ced3b 100644
@@ -23,6 +23,7 @@
 #include <rte_io.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_power_intrinsics.h>
@@ -991,7 +992,8 @@ dlb_hw_create_ldb_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_LDB_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_LDB_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
@@ -1181,7 +1183,8 @@ dlb_hw_create_dir_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_DIR_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_DIR_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
drivers/event/dlb/dlb_priv.h +0 -2
index 272e17482f..ca4d6a84cf 100644
@@ -76,8 +76,6 @@
 
 #define PP_BASE(is_dir) ((is_dir) ? DLB_DIR_PP_BASE : DLB_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb/pf/base/dlb_osdep.h +1 -1
index 0c119b759a..dee20660ed 100644
@@ -92,7 +92,7 @@ static inline void *os_map_producer_port(struct dlb_hw *hw,
 
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 
drivers/event/dlb/pf/dlb_main.h +1 -4
index 22e215223d..e66ba228d1 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb_hw_types.h"
 #include "../dlb_user.h"
drivers/event/dlb/pf/dlb_pf.c +6 -4
index 876c68e51d..5445c2d57d 100644
@@ -304,7 +304,7 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -329,7 +329,8 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_LDB].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_LDB].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
@@ -382,7 +383,7 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -407,7 +408,8 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_DIR].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_DIR].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
drivers/event/dlb2/dlb2_priv.h +0 -2
index b73cf3ff14..eb1a932399 100644
@@ -78,8 +78,6 @@
 				    DLB2_LDB_CQ_MAX_SIZE)
 #define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB2_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB2_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb2/pf/base/dlb2_osdep.h +1 -1
index c4c34eba5f..aa101a49a3 100644
@@ -89,7 +89,7 @@ static inline void *os_map_producer_port(struct dlb2_hw *hw,
 	uint64_t pp_dma_base;
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 }
drivers/event/dlb2/pf/dlb2_main.h +1 -4
index f3bee71fb6..9eeda482a3 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb2_hw_types.h"
 #include "../dlb2_user.h"
drivers/event/dlb2/pf/dlb2_pf.c +4 -4
index b85fd3ec56..cfb22efe8a 100644
@@ -285,7 +285,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -308,7 +308,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void *)(port_base);
 	memset(&port_memory, 0, sizeof(port_memory));
@@ -360,7 +360,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -383,7 +383,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
 		(void *)(port_base);
drivers/net/bnx2x/ecore_fw_defs.h +12 -6
index 5397a701aa..93bca8ad33 100644
@@ -13,6 +13,8 @@
 #ifndef ECORE_FW_DEFS_H
 #define ECORE_FW_DEFS_H
 
+#include <rte_eal_paging.h>
+
 #define CSTORM_ASSERT_LIST_INDEX_OFFSET	(IRO[152].base)
 #define CSTORM_ASSERT_LIST_OFFSET(assertListEntry) \
 	(IRO[151].base + ((assertListEntry) * IRO[151].m1))
@@ -252,7 +254,8 @@
 #define X_ETH_LOCAL_RING_SIZE 13
 #define FIRST_BD_IN_PKT	0
 #define PARSE_BD_INDEX 1
-#define NUM_OF_ETH_BDS_IN_PAGE ((PAGE_SIZE)/(STRUCT_SIZE(eth_tx_bd)/8))
+#define NUM_OF_ETH_BDS_IN_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_tx_bd) / 8))
 #define U_ETH_NUM_OF_SGES_TO_FETCH 8
 #define U_ETH_MAX_SGES_FOR_PACKET 3
 
@@ -265,11 +268,14 @@
 #define IP_HEADER_ALIGNMENT_PADDING 2
 
 #define U_ETH_SGES_PER_PAGE_INVERSE_MASK \
-	(0xFFFF - ((PAGE_SIZE/((STRUCT_SIZE(eth_rx_sge))/8))-1))
+	(0xFFFF - ((rte_mem_page_size() / ((STRUCT_SIZE(eth_rx_sge)) / 8)) - 1))
 
-#define TU_ETH_CQES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_cqe)/8))
-#define U_ETH_BDS_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_bd)/8))
-#define U_ETH_SGES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_sge)/8))
+#define TU_ETH_CQES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_cqe) / 8))
+#define U_ETH_BDS_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_bd) / 8))
+#define U_ETH_SGES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_sge) / 8))
 
 #define U_ETH_BDS_PER_PAGE_MASK	(U_ETH_BDS_PER_PAGE-1)
 #define U_ETH_CQE_PER_PAGE_MASK	(TU_ETH_CQES_PER_PAGE-1)
@@ -396,7 +402,7 @@
 
 /* Event Ring definitions */
 #define C_ERES_PER_PAGE \
-	(PAGE_SIZE / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
+	(rte_mem_page_size() / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
 #define C_ERE_PER_PAGE_MASK (C_ERES_PER_PAGE - 1)
 
 /* number of statistic command */
drivers/net/ionic/ionic_lif.c +14 -11
index e083f92417..395e5acc8b 100644
@@ -617,18 +617,18 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	cq_size = num_descs * cq_desc_size;
 	sg_size = num_descs * sg_desc_size;
 
-	total_size = RTE_ALIGN(q_size, PAGE_SIZE) +
-		RTE_ALIGN(cq_size, PAGE_SIZE);
+	total_size = RTE_ALIGN(q_size, rte_mem_page_size()) +
+			RTE_ALIGN(cq_size, rte_mem_page_size());
 	/*
 	 * Note: aligning q_size/cq_size is not enough due to cq_base address
 	 * aligning as q_base could be not aligned to the page.
-	 * Adding PAGE_SIZE.
+	 * Adding rte_mem_page_size().
 	 */
-	total_size += PAGE_SIZE;
+	total_size += rte_mem_page_size();
 
 	if (flags & IONIC_QCQ_F_SG) {
-		total_size += RTE_ALIGN(sg_size, PAGE_SIZE);
-		total_size += PAGE_SIZE;
+		total_size += RTE_ALIGN(sg_size, rte_mem_page_size());
+		total_size += rte_mem_page_size();
 	}
 
 	new = rte_zmalloc("ionic", sizeof(*new), 0);
@@ -679,13 +679,16 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	q_base = new->base;
 	q_base_pa = new->base_pa;
 
-	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size, PAGE_SIZE);
-	cq_base_pa = RTE_ALIGN(q_base_pa + q_size, PAGE_SIZE);
+	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size,
+			rte_mem_page_size());
+	cq_base_pa = RTE_ALIGN(q_base_pa + q_size,
+			rte_mem_page_size());
 
 	if (flags & IONIC_QCQ_F_SG) {
 		sg_base = (void *)RTE_ALIGN((uintptr_t)cq_base + cq_size,
-			PAGE_SIZE);
-		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size, PAGE_SIZE);
+				rte_mem_page_size());
+		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size,
+				rte_mem_page_size());
 		ionic_q_sg_map(&new->q, sg_base, sg_base_pa);
 	}
 
@@ -975,7 +978,7 @@ ionic_lif_alloc(struct ionic_lif *lif)
 
 	IONIC_PRINT(DEBUG, "Allocating Lif Info");
 
-	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
+	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), rte_mem_page_size());
 
 	lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
 		"lif_info", 0 /* queue_idx*/,
drivers/net/ionic/ionic_main.c +2 -1
index 3f1a764888..3ee4999fa5 100644
@@ -375,7 +375,8 @@ ionic_port_init(struct ionic_adapter *adapter)
 	if (idev->port_info)
 		return 0;
 
-	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
+	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info),
+			rte_mem_page_size());
 
 	snprintf(z_name, sizeof(z_name), "%s_port_%s_info",
 		IONIC_DRV_NAME, adapter->name);
drivers/net/ionic/ionic_osdep.h +1 -1
index a6575c36b5..89ed106d11 100644
@@ -17,6 +17,7 @@
 #include <rte_byteorder.h>
 #include <rte_io.h>
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 
 #include "ionic_logs.h"
 
@@ -25,7 +26,6 @@
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT      12
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
 #endif
 
 #define __iomem
drivers/net/netvsc/hn_rndis.c +6 -6
index e317539de7..e3f7e636d7 100644
@@ -67,7 +67,7 @@ hn_rndis_rid(struct hn_data *hv)
 
 static void *hn_rndis_alloc(size_t size)
 {
-	return rte_zmalloc("RNDIS", size, PAGE_SIZE);
+	return rte_zmalloc("RNDIS", size, rte_mem_page_size());
 }
 
 #ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP
@@ -265,17 +265,17 @@ static int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
 		return -EINVAL;
 	}
 
-	if (unlikely(reqlen > PAGE_SIZE)) {
+	if (unlikely(reqlen > rte_mem_page_size())) {
 		PMD_DRV_LOG(ERR, "RNDIS request %u greater than page size",
 			    reqlen);
 		return -EINVAL;
 	}
 
-	sg.page = addr / PAGE_SIZE;
+	sg.page = addr / rte_mem_page_size();
 	sg.ofs  = addr & PAGE_MASK;
 	sg.len  = reqlen;
 
-	if (sg.ofs + reqlen >  PAGE_SIZE) {
+	if (sg.ofs + reqlen >  rte_mem_page_size()) {
 		PMD_DRV_LOG(ERR, "RNDIS request crosses page boundary");
 		return -EINVAL;
 	}
@@ -479,7 +479,7 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
 		return -ENOMEM;
 
 	comp_len = sizeof(*comp) + odlen;
-	comp = rte_zmalloc("QUERY", comp_len, PAGE_SIZE);
+	comp = rte_zmalloc("QUERY", comp_len, rte_mem_page_size());
 	if (!comp) {
 		error = -ENOMEM;
 		goto done;
@@ -736,7 +736,7 @@ hn_rndis_set(struct hn_data *hv, uint32_t oid, const void *data, uint32_t dlen)
 	int error;
 
 	reqlen = sizeof(*req) + dlen;
-	req = rte_zmalloc("RNDIS_SET", reqlen, PAGE_SIZE);
+	req = rte_zmalloc("RNDIS_SET", reqlen, rte_mem_page_size());
 	if (!req)
 		return -ENOMEM;
 
drivers/net/netvsc/hn_rxtx.c +6 -4
index 0f4ef0100b..c6bf7cc132 100644
@@ -1387,7 +1387,8 @@ static unsigned int hn_get_slots(const struct rte_mbuf *m)
 		unsigned int size = rte_pktmbuf_data_len(m);
 		unsigned int offs = rte_mbuf_data_iova(m) & PAGE_MASK;
 
-		slots += (offs + size + PAGE_SIZE - 1) / PAGE_SIZE;
+		slots += (offs + size + rte_mem_page_size() - 1) /
+				rte_mem_page_size();
 		m = m->next;
 	}
 
@@ -1402,12 +1403,13 @@ static unsigned int hn_fill_sg(struct vmbus_gpa *sg,
 
 	while (m) {
 		rte_iova_t addr = rte_mbuf_data_iova(m);
-		unsigned int page = addr / PAGE_SIZE;
+		unsigned int page = addr / rte_mem_page_size();
 		unsigned int offset = addr & PAGE_MASK;
 		unsigned int len = rte_pktmbuf_data_len(m);
 
 		while (len > 0) {
-			unsigned int bytes = RTE_MIN(len, PAGE_SIZE - offset);
+			unsigned int bytes = RTE_MIN(len,
+					rte_mem_page_size() - offset);
 
 			sg[segs].page = page;
 			sg[segs].ofs = offset;
@@ -1450,7 +1452,7 @@ static int hn_xmit_sg(struct hn_tx_queue *txq,
 	addr = txq->tx_rndis_iova +
 		((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
 
-	sg[0].page = addr / PAGE_SIZE;
+	sg[0].page = addr / rte_mem_page_size();
 	sg[0].ofs = addr & PAGE_MASK;
 	sg[0].len = RNDIS_PACKET_MSG_OFFSET_ABS(hn_rndis_pktlen(txd->rndis_pkt));
 	segs = 1;
drivers/net/netvsc/hn_var.h +3 -6
index b7405ca726..43642408bc 100644
@@ -6,6 +6,8 @@
  * All rights reserved.
  */
 
+#include <rte_eal_paging.h>
+
 /*
  * Tunable ethdev params
  */
@@ -28,13 +30,8 @@
 
 #define HN_RX_EXTMBUF_ENABLE	0
 
-/* Buffers need to be aligned */
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #ifndef PAGE_MASK
-#define PAGE_MASK (PAGE_SIZE - 1)
+#define PAGE_MASK (rte_mem_page_size() - 1)
 #endif
 
 struct hn_data;
drivers/net/virtio/virtio.h +1 -1
index 21d54904e7..2c987d19ab 100644
@@ -98,7 +98,7 @@
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int)(PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int)(rte_mem_page_size() / 16))
 
 /*
  * Maximum number of virtqueues per device.
drivers/net/virtio/virtio_ethdev.c +3 -3
index 333a5243a9..289b240c4e 100644
@@ -21,8 +21,8 @@
 #include <rte_errno.h>
 #include <rte_cpuflags.h>
 #include <rte_vect.h>
-
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <rte_cycles.h>
@@ -469,7 +469,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		sz_hdr_mz = vq_size * sizeof(struct virtio_tx_region);
 	} else if (queue_type == VTNET_CQ) {
 		/* Allocate a page for control vq command, data and status */
-		sz_hdr_mz = PAGE_SIZE;
+		sz_hdr_mz = rte_mem_page_size();
 	}
 
 	vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
@@ -568,7 +568,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		cvq->mz = mz;
 		cvq->virtio_net_hdr_mz = hdr_mz;
 		cvq->virtio_net_hdr_mem = hdr_mz->iova;
-		memset(cvq->virtio_net_hdr_mz->addr, 0, PAGE_SIZE);
+		memset(cvq->virtio_net_hdr_mz->addr, 0, rte_mem_page_size());
 
 		hw->cvq = cvq;
 	}
drivers/net/virtio/virtio_ethdev.h +0 -4
index 873327d989..5a501e7890 100644
@@ -11,10 +11,6 @@
 
 #include "virtio.h"
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define VIRTIO_MAX_RX_QUEUES 128U
 #define VIRTIO_MAX_TX_QUEUES 128U
 #define VIRTIO_MAX_MAC_ADDRS 64
drivers/vdpa/ifc/ifcvf_vdpa.c +7 -10
index 6a1b44bc77..39237aecf7 100644
@@ -11,6 +11,7 @@
 #include <linux/virtio_net.h>
 #include <stdbool.h>
 
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_bus_pci.h>
@@ -30,10 +31,6 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define IFCVF_USED_RING_LEN(size) \
 	((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3)
 
@@ -600,11 +597,11 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 	for (i = 0; i < nr_vring; i++) {
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
-		vring_buf = rte_zmalloc("ifcvf", size, PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
+		vring_buf = rte_zmalloc("ifcvf", size, rte_mem_page_size());
 		vring_init(&internal->m_vring[i], vq.size, vring_buf,
-				PAGE_SIZE);
+				rte_mem_page_size());
 
 		ret = rte_vfio_container_dma_map(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)vring_buf, m_vring_iova, size);
@@ -686,8 +683,8 @@ m_ifcvf_stop(struct ifcvf_internal *internal)
 		len = IFCVF_USED_RING_LEN(vq.size);
 		rte_vhost_log_used_vring(vid, i, 0, len);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
 		rte_vfio_container_dma_unmap(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)internal->m_vring[i].desc,
 			m_vring_iova, size);
Signature · 1 line
2.30.1
#89 lore raw

Re: [dpdk-dev] [PATCH v6 07/17] drivers: replace page size definitions with function

Quoted 4 lines · Thomas Monjalon

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Quoted 8 lines

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---

Is the header file with the rte_mem_page_size() function missing from this patch?
Also, rather than a function for this, would it not be better to keep it as a macro as RTE_PAGE_SIZE, to keep it more in line with the macro people expect to have available?

#90 lore raw

Re: [dpdk-dev] [PATCH v6 07/17] drivers: replace page size definitions with function

01/03/2021 10:41, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 7 lines

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Quoted 7 lines
Quoted 5 lines

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---

Is the header file with the rte_mem_page_size() function missing from this patch?

No, the function exists since DPDK 20.08.

Quoted 3 lines

Also, rather than a function for this, would it not be better to keep it as a macro as RTE_PAGE_SIZE, to keep it more in line with the macro people expect to have available?

No because the size is not always known at compilation time. See the implementation:

	https://git.dpdk.org/dpdk/commit/?id=c4b89ecb64eae
#91 lore raw

Re: [dpdk-dev] [PATCH v6 07/17] drivers: replace page size definitions with function

Quoted 19 lines · Thomas Monjalon

01/03/2021 10:41, Bruce Richardson:

Quoted 8 lines · Thomas Monjalon
Quoted 7 lines

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Quoted 7 lines
Quoted 5 lines

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---

Is the header file with the rte_mem_page_size() function missing from this patch?

No, the function exists since DPDK 20.08.

Quoted 8 lines
Quoted 3 lines

Also, rather than a function for this, would it not be better to keep it as a macro as RTE_PAGE_SIZE, to keep it more in line with the macro people expect to have available?

No because the size is not always known at compilation time. See the implementation:

	https://git.dpdk.org/dpdk/commit/?id=c4b89ecb64eae

Ok, thanks for the explanation.

Acked-by on v6 7/17
#92 lore raw

Re: [dpdk-dev] [PATCH v6 07/17] drivers: replace page size definitions with function

In reply to Thomas Monjalon
Quoted 34 lines · Thomas Monjalon

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---

drivers/bus/pci/linux/pci_vfio.c        |  9 ++-------
drivers/bus/vmbus/linux/vmbus_uio.c     |  4 ++--
drivers/bus/vmbus/private.h             |  5 +----
drivers/bus/vmbus/rte_vmbus_reg.h       |  2 +-
drivers/bus/vmbus/vmbus_common_uio.c    |  4 ++--
drivers/crypto/virtio/virtio_pci.h      |  3 ++-
drivers/event/dlb/dlb.c                 |  7 +++++--
drivers/event/dlb/dlb_priv.h            |  2 --
drivers/event/dlb/pf/base/dlb_osdep.h   |  2 +-
drivers/event/dlb/pf/dlb_main.h         |  5 +----
drivers/event/dlb/pf/dlb_pf.c           | 10 ++++++----
drivers/event/dlb2/dlb2_priv.h          |  2 --
drivers/event/dlb2/pf/base/dlb2_osdep.h |  2 +-
drivers/event/dlb2/pf/dlb2_main.h       |  5 +----
drivers/event/dlb2/pf/dlb2_pf.c         |  8 ++++----
drivers/net/bnx2x/ecore_fw_defs.h       | 18 ++++++++++++------
drivers/net/ionic/ionic_lif.c           | 25 ++++++++++++++-----------
drivers/net/ionic/ionic_main.c          |  3 ++-
drivers/net/ionic/ionic_osdep.h         |  2 +-
Quoted 9 lines
drivers/net/netvsc/hn_rndis.c           | 12 ++++++------
drivers/net/netvsc/hn_rxtx.c            | 10 ++++++----
drivers/net/netvsc/hn_var.h             |  9 +++------
drivers/net/virtio/virtio.h             |  2 +-
drivers/net/virtio/virtio_ethdev.c      |  6 +++---
drivers/net/virtio/virtio_ethdev.h      |  4 ----
drivers/vdpa/ifc/ifcvf_vdpa.c           | 17 +++++++----------
26 files changed, 84 insertions(+), 94 deletions(-)

OK for net/ionic

#93 lore raw

PATCH v6 8/17 bus/pci: support I/O port operations with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/bus/pci/linux/pci_uio.c | 91 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 30 deletions(-)
drivers/bus/pci/linux/pci_uio.c +61 -30
index f3305a2f28..1294f505be 100644
@@ -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);
 		}
 	}
 }
Signature · 1 line
2.30.1
#94 lore raw

PATCH v6 9/17 bus/dpaa: fix 64-bit arch detection

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/dpaa/include/fsl_qman.h +1 -1
index 10212f0fd5..7ef2f3b2e3 100644
@@ -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.
Signature · 1 line
2.30.1
#95 lore raw

PATCH v6 10/17 bus/dpaa: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index b7009f2299..bcedbaf68f 100644
@@ -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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +9 -4
index 750b756b93..c0b9e3da77 100644
@@ -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;
 }
 
drivers/bus/dpaa/base/qbman/qman_driver.c +12 -5
index 6d9aaff164..93375d1ea8 100644
@@ -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;
 	}
Signature · 1 line
2.30.1
#96 lore raw

PATCH v6 11/17 common/dpaax/caamflib: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/dpaax/caamflib/compat.h +6 -6
index 36ee4b5335..c1a693498d 100644
@@ -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)
Signature · 1 line
2.30.1
#97 lore raw

PATCH v6 12/17 common/dpaax/caamflib: simplify log macros

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

Simplify pr_debug, pr_err and pr_warn macros by adding an intermediate pr_msg macro. This way we only need to test for SUPPRESS_PRINTS once.

---
 drivers/common/dpaax/caamflib/compat.h | 28 +++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/common/dpaax/caamflib/compat.h +12 -16
index c1a693498d..9776eed437 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __rte_unused
 #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0)
+#else
+#define pr_msg(l, fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
Signature · 1 line
2.30.1
#98 lore raw

PATCH v6 13/17 net/cxgbe: remove use of uint type

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +9 -9
index 202a2f4baf..ab100d784c 100644
@@ -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;
 };
Signature · 1 line
2.30.1
#99 lore raw

PATCH v6 14/17 net/igc: remove use of uint type

In reply to Thomas Monjalon

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

Fixes 746664d546fb ("net/igc: support flow API")
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/igc/igc_flow.c +1 -1
index 1bb64d323c..66053060af 100644
@@ -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",
Signature · 1 line
2.30.1
#100 lore raw

PATCH v6 15/17 vdpa/mlx5: replace pthread functions unavailable in musl

In reply to 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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +13 -12
index 86adc864f5..49632dfaa7 100644
@@ -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) {
Signature · 1 line
2.30.1
#101 lore raw

PATCH v6 16/17 app/testpmd: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
app/test-pmd/bpf_cmd.c +1 -1
index 066619e115..6980291f07 100644
@@ -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),
app/test-pmd/config.c +1 -1
index dab8afe5dd..9ca03c236e 100644
@@ -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;
app/test-pmd/testpmd.h +1 -1
index 4aca522859..5437b6229e 100644
@@ -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);
Signature · 1 line
2.30.1
#102 lore raw

PATCH v6 17/17 examples/bbdev: fix header include for musl

In reply to Thomas Monjalon

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")
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/bbdev_app/main.c +1 -1
index 2e170caf84..20cfd327fb 100644
@@ -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>
Signature · 1 line
2.30.1
#103 lore raw

Re: [dpdk-dev] [PATCH v6 00/17] Alpine/musl build support

In reply to Thomas Monjalon

28/02/2021 13:53, Thomas Monjalon:

Quoted 3 lines

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

No more comment on this series? Ready to merge?

#104 lore raw

Re: [dpdk-dev] [PATCH v6 00/17] Alpine/musl build support

Quoted 6 lines · Thomas Monjalon

28/02/2021 13:53, Thomas Monjalon:

Quoted 3 lines

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

No more comment on this series? Ready to merge?

#105 lore raw

Re: [dpdk-dev] [PATCH v6 00/17] Alpine/musl build support

In reply to Thomas Monjalon
Quoted 7 lines · Thomas Monjalon

28/02/2021 13:53, Thomas Monjalon:

Quoted 3 lines

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

No more comment on this series? Ready to merge?

This will probably need some rebase on the ioport changes. I did not find the time to look at busybox, but I still think there is something funny about awk :-).

For the rest, it looks good to me.

Signature · 1 line
David Marchand
#106 lore raw

v7 cover Alpine/musl build support

In reply to Natanael Copa

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

The goal is to run a container with the following Dockerfile:
8< ------------
FROM alpine

# DPDK prerequisites

RUN apk --no-cache add \
    gcc libc-dev bsd-compat-headers linux-headers \
    python3 py3-elftools meson ninja \
    libexecinfo-dev numactl-dev zlib-dev libpcap-dev libbpf-dev openssl-dev
# mlx prerequisites
RUN apk --no-cache add \
    git cmake libnl3-dev
RUN git clone https://github.com/linux-rdma/rdma-core.git
WORKDIR /rdma-core/build
RUN cmake -DNO_MAN_PAGES=1 -DNO_PYVERBS=1 -GNinja ..
RUN ninja install
WORKDIR /
# download
ARG version
RUN if [ "$version" = git ] ; then \
        git clone http://dpdk.org/git/dpdk dpdk-$version ;\
    else \
        wget http://fast.dpdk.org/rel/dpdk-$version.tar.xz && \
        tar xf dpdk-$version.tar.xz ;\
    fi
# build
WORKDIR dpdk-$version/build
RUN meson ..
RUN ninja install
8< ------------

v7:
- rework port I/O fix after rebase and without asm
- fix patch order for compilation
- fix DPAA error with err instead of warn

v6: do not set _GNU_SOURCE in pkg-config

Natanael Copa (6):
common/dpaax/caamflib: fix build with musl
common/dpaax/caamflib: simplify log macros
bus/dpaa: fix 64-bit arch detection
bus/dpaa: fix build with musl
net/cxgbe: remove use of uint type
app/testpmd: fix build with musl

Thomas Monjalon (11):
eal: fix comment of OS-specific header files
buildtools: fix build with busybox
build: detect execinfo library on Linux
build: remove redundant _GNU_SOURCE definitions
eal: fix build with musl
drivers: replace page size definitions with function bus/pci: support I/O port operations with musl net/igc: remove use of uint type
vdpa/mlx5: replace pthread functions unavailable in musl event/dlb: fix header includes for musl examples/bbdev: fix header include for musl

 app/meson.build                           |  4 ---
 app/test-pmd/bpf_cmd.c                    |  2 +-
 app/test-pmd/config.c                     |  2 +-
 app/test-pmd/testpmd.h                    |  2 +-
 app/test/meson.build                      |  3 --
 buildtools/binutils-avx512-check.sh       |  2 +-
 buildtools/check-symbols.sh               |  2 +-
 buildtools/map-list-symbol.sh             |  2 +-
 config/meson.build                        |  9 +++--
 doc/api/doxy-api.conf.in                  |  3 +-
 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/fsl_qman.h       |  2 +-
 drivers/bus/dpaa/include/netcfg.h         |  1 -
 drivers/bus/fslmc/qbman/include/compat.h  |  3 --
 drivers/bus/pci/linux/pci_uio.c           | 32 ++++++++++++++++--
 drivers/bus/pci/linux/pci_vfio.c          |  9 ++---
 drivers/bus/vmbus/linux/vmbus_uio.c       |  4 +--
 drivers/bus/vmbus/private.h               |  5 +--
 drivers/bus/vmbus/rte_vmbus_reg.h         |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c      |  4 +--
 drivers/common/dpaax/caamflib/compat.h    | 40 ++++++++++-------------
 drivers/common/dpaax/compat.h             |  5 ---
 drivers/common/dpaax/meson.build          |  1 -
 drivers/crypto/virtio/virtio_pci.h        |  3 +-
 drivers/event/dlb/dlb.c                   |  9 +++--
 drivers/event/dlb/dlb_priv.h              |  2 --
 drivers/event/dlb/pf/base/dlb_osdep.h     |  2 +-
 drivers/event/dlb/pf/dlb_main.h           |  5 +--
 drivers/event/dlb/pf/dlb_pf.c             | 13 +++++---
 drivers/event/dlb2/dlb2.c                 |  2 +-
 drivers/event/dlb2/dlb2_priv.h            |  2 --
 drivers/event/dlb2/pf/base/dlb2_osdep.h   |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h         |  5 +--
 drivers/event/dlb2/pf/dlb2_pf.c           | 11 ++++---
 drivers/net/bnx2x/ecore_fw_defs.h         | 18 ++++++----
 drivers/net/cxgbe/base/common.h           | 18 +++++-----
 drivers/net/igc/igc_flow.c                |  2 +-
 drivers/net/ionic/ionic_lif.c             | 27 ++++++++-------
 drivers/net/ionic/ionic_main.c            |  3 +-
 drivers/net/ionic/ionic_osdep.h           |  2 +-
 drivers/net/memif/rte_eth_memif.h         |  4 ---
 drivers/net/mlx5/linux/mlx5_socket.c      |  4 ---
 drivers/net/netvsc/hn_rndis.c             | 12 +++----
 drivers/net/netvsc/hn_rxtx.c              | 10 +++---
 drivers/net/netvsc/hn_var.h               |  9 ++---
 drivers/net/virtio/virtio.h               |  2 +-
 drivers/net/virtio/virtio_ethdev.c        |  6 ++--
 drivers/net/virtio/virtio_ethdev.h        |  4 ---
 drivers/vdpa/ifc/ifcvf_vdpa.c             | 17 ++++------
 drivers/vdpa/mlx5/mlx5_vdpa_event.c       | 25 +++++++-------
 examples/bbdev_app/main.c                 |  2 +-
 examples/meson.build                      |  4 +--
 lib/librte_eal/freebsd/include/rte_os.h   |  6 ++--
 lib/librte_eal/include/rte_lcore.h        |  4 +++
 lib/librte_eal/include/rte_thread.h       |  4 +++
 lib/librte_eal/linux/include/rte_os.h     |  8 +++--
 lib/librte_eal/unix/eal_file.c            |  1 +
 lib/librte_eal/windows/include/rte_os.h   |  5 ++-
 lib/librte_eal/windows/include/sched.h    |  1 +
 lib/librte_telemetry/rte_telemetry.h      |  4 +++
 62 files changed, 226 insertions(+), 205 deletions(-)
Signature · 1 line
2.30.1
#107 lore raw

PATCH v7 1/17 eal: fix comment of OS-specific header files

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")
---
 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(-)
lib/librte_eal/freebsd/include/rte_os.h +2 -3
index eeb750cd81..c16f2a30e9 100644
@@ -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>
lib/librte_eal/linux/include/rte_os.h +2 -3
index 218d4fa86e..390b87b3a1 100644
@@ -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>
lib/librte_eal/windows/include/rte_os.h +2 -3
index 7ef38ff06c..f0512f20a6 100644
@@ -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>
Signature · 1 line
2.30.1
#108 lore raw

PATCH v7 2/17 buildtools: fix build with busybox

In reply to Thomas Monjalon

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")
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
buildtools/binutils-avx512-check.sh +1 -1
index a7e068140f..2a833b64b7 100755
@@ -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}'
buildtools/check-symbols.sh +1 -1
index e407553a34..6723e38450 100755
@@ -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
 
buildtools/map-list-symbol.sh +1 -1
index 5509b4a7fa..3bf9bd66f8 100755
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
Signature · 1 line
2.30.1
#109 lore raw

Re: [dpdk-dev] [PATCH v7 02/17] buildtools: fix build with busybox

Quoted 44 lines · Thomas Monjalon

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")
---
 buildtools/binutils-avx512-check.sh | 2 +-
 buildtools/check-symbols.sh         | 2 +-
 buildtools/map-list-symbol.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
buildtools/binutils-avx512-check.sh +1 -1
index a7e068140f..2a833b64b7 100755
@@ -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}'
buildtools/check-symbols.sh +0 -0
index e407553a34..6723e38450 100755

buildtools/check-symbols.sh then · line 21

Quoted 5 lines
buildtools/check-symbols.sh +1 -1
@@ -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?

Quoted 17 lines
buildtools/check-symbols.sh +0 -0
 trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
buildtools/map-list-symbol.sh +1 -1
index 5509b4a7fa..3bf9bd66f8 100755
@@ -44,7 +44,7 @@ for file in $@; do
 			ret = 1;
 		}
 	}
-	/^.*{/ {
+	/^.*\{/ {
 		if ("'$section'" == "all" || $1 == "'$section'") {
 			current_section = $1;
 		}
#110 lore raw

Re: [dpdk-dev] [PATCH v7 02/17] buildtools: fix build with busybox

22/03/2021 09:52, Kinsella, Ray:

Quoted 11 lines · Thomas Monjalon

buildtools/check-symbols.sh then · line 21

Quoted 4 lines
buildtools/check-symbols.sh +1 -1
-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.

#111 lore raw

Re: [dpdk-dev] [PATCH v7 02/17] buildtools: fix build with busybox

Quoted 11 lines · Thomas Monjalon

22/03/2021 09:52, Kinsella, Ray:

Quoted 10 lines · Thomas Monjalon

buildtools/check-symbols.sh then · line 21

Quoted 4 lines
buildtools/check-symbols.sh +1 -1
-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)

Quoted 8 lines
Quoted 1 line

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 ...

#112 lore raw

PATCH v7 3/17 build: detect execinfo library on Linux

In reply to Thomas Monjalon

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")
---
 app/meson.build      | 4 ----
 app/test/meson.build | 1 -
 config/meson.build   | 9 ++++++---
 examples/meson.build | 4 +---
 4 files changed, 7 insertions(+), 11 deletions(-)
app/meson.build +0 -4
index 87fc195dbf..50a53dbde8 100644
@@ -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'
app/test/meson.build +0 -1
index 561e493a29..099895fc87 100644
@@ -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'
config/meson.build +6 -3
index 3cf560b8a3..66a2edcc47 100644
@@ -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()
examples/meson.build +1 -3
index 3fe08d4ca5..d065a6a08b 100644
@@ -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)
Signature · 1 line
2.30.1
#113 lore raw

PATCH v7 4/17 build: remove redundant _GNU_SOURCE definitions

In reply to Thomas Monjalon

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")
---
 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(-)
app/test/meson.build +0 -2
index 099895fc87..76eaaea457 100644
@@ -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'
 
drivers/bus/fslmc/qbman/include/compat.h +0 -3
index 1ddd69e127..a4471a80af 100644
@@ -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>
drivers/common/dpaax/compat.h +0 -4
index 1a5f36e99e..c69e76ab96 100644
@@ -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>
drivers/common/dpaax/meson.build +0 -1
index 4535482701..b7f177a62e 100644
@@ -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
drivers/net/memif/rte_eth_memif.h +0 -4
index 24321d3a39..2038bda742 100644
@@ -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>
drivers/net/mlx5/linux/mlx5_socket.c +0 -4
index 1938453980..b1f41bc102 100644
@@ -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>
Signature · 1 line
2.30.1
#114 lore raw

PATCH v7 5/17 eal: fix build with musl

In reply to Thomas Monjalon

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")
---
 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(-)
doc/api/doxy-api.conf.in +2 -1
index 5eb31508fd..b3c5cdfeca 100644
@@ -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
lib/librte_eal/freebsd/include/rte_os.h +1 -0
index c16f2a30e9..627f0483ab 100644
@@ -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; \
lib/librte_eal/include/rte_lcore.h +4 -0
index 0fe0bd839c..1550b75da0 100644
@@ -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.
  *
lib/librte_eal/include/rte_thread.h +4 -0
index e640ea1857..ac5a89b1ad 100644
@@ -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.
lib/librte_eal/linux/include/rte_os.h +3 -0
index 390b87b3a1..1618b4df22 100644
@@ -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_ */
lib/librte_eal/unix/eal_file.c +1 -0
index 1b26475ba4..ec554e0096 100644
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
lib/librte_eal/windows/include/sched.h +1 -0
index fbe07f742c..ff572b5dcb 100644
@@ -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)))
 
lib/librte_telemetry/rte_telemetry.h +4 -0
index f7c8534b82..027b048d78 100644
@@ -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.
Signature · 1 line
2.30.1
#115 lore raw

PATCH v7 6/17 drivers: replace page size definitions with function

In reply to Thomas Monjalon

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---
 drivers/bus/pci/linux/pci_vfio.c        |  9 ++-------
 drivers/bus/vmbus/linux/vmbus_uio.c     |  4 ++--
 drivers/bus/vmbus/private.h             |  5 +----
 drivers/bus/vmbus/rte_vmbus_reg.h       |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c    |  4 ++--
 drivers/crypto/virtio/virtio_pci.h      |  3 ++-
 drivers/event/dlb/dlb.c                 |  7 +++++--
 drivers/event/dlb/dlb_priv.h            |  2 --
 drivers/event/dlb/pf/base/dlb_osdep.h   |  2 +-
 drivers/event/dlb/pf/dlb_main.h         |  5 +----
 drivers/event/dlb/pf/dlb_pf.c           | 10 +++++----
 drivers/event/dlb2/dlb2_priv.h          |  2 --
 drivers/event/dlb2/pf/base/dlb2_osdep.h |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h       |  5 +----
 drivers/event/dlb2/pf/dlb2_pf.c         |  8 ++++----
 drivers/net/bnx2x/ecore_fw_defs.h       | 18 +++++++++++------
 drivers/net/ionic/ionic_lif.c           | 27 ++++++++++++++-----------
 drivers/net/ionic/ionic_main.c          |  3 ++-
 drivers/net/ionic/ionic_osdep.h         |  2 +-
 drivers/net/netvsc/hn_rndis.c           | 12 +++++------
 drivers/net/netvsc/hn_rxtx.c            | 10 +++++----
 drivers/net/netvsc/hn_var.h             |  9 +++------
 drivers/net/virtio/virtio.h             |  2 +-
 drivers/net/virtio/virtio_ethdev.c      |  6 +++---
 drivers/net/virtio/virtio_ethdev.h      |  4 ----
 drivers/vdpa/ifc/ifcvf_vdpa.c           | 17 +++++++---------
 26 files changed, 85 insertions(+), 95 deletions(-)
drivers/bus/pci/linux/pci_vfio.c +2 -7
index e3f7b6abeb..9d689d6fd9 100644
@@ -38,11 +38,6 @@
 
 #ifdef VFIO_PRESENT
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
-#endif
-#define PAGE_MASK   (~(PAGE_SIZE - 1))
-
 static struct rte_tailq_elem rte_vfio_tailq = {
 	.name = "VFIO_RESOURCE_LIST",
 };
@@ -507,8 +502,8 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
 		 */
 		uint32_t table_start = msix_table->offset;
 		uint32_t table_end = table_start + msix_table->size;
-		table_end = RTE_ALIGN(table_end, PAGE_SIZE);
-		table_start = RTE_ALIGN_FLOOR(table_start, PAGE_SIZE);
+		table_end = RTE_ALIGN(table_end, rte_mem_page_size());
+		table_start = RTE_ALIGN_FLOOR(table_start, rte_mem_page_size());
 
 		/* If page-aligned start of MSI-X table is less than the
 		 * actual MSI-X table start address, reassign to the actual
drivers/bus/vmbus/linux/vmbus_uio.c +2 -2
index 5dc0c47de6..b52ca5bf1d 100644
@@ -154,7 +154,7 @@ vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx,
 		vmbus_map_addr = vmbus_find_max_end_va();
 
 	/* offset is special in uio it indicates which resource */
-	offset = idx * PAGE_SIZE;
+	offset = idx * rte_mem_page_size();
 
 	mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags);
 	close(fd);
@@ -224,7 +224,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
 	}
 	file_size = sb.st_size;
 
-	if (file_size == 0 || (file_size & (PAGE_SIZE - 1))) {
+	if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) {
 		VMBUS_LOG(ERR, "incorrect size %s: %zu",
 			  ring_path, file_size);
 
drivers/bus/vmbus/private.h +1 -4
index f19b14e4a6..528d60a42f 100644
@@ -9,13 +9,10 @@
 #include <stdbool.h>
 #include <sys/uio.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_vmbus_reg.h>
 #include <rte_bus_vmbus.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE	4096
-#endif
-
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 extern int vmbus_logtype_bus;
drivers/bus/vmbus/rte_vmbus_reg.h +1 -1
index f5a0693dcb..8562672979 100644
@@ -100,7 +100,7 @@ struct vmbus_bufring {
 		uint32_t value;
 	} feature_bits;
 
-	/* Pad it to PAGE_SIZE so that data starts on page boundary */
+	/* Pad it to rte_mem_page_size() so that data starts on page boundary */
 	uint8_t	reserved2[4028];
 
 	/*
drivers/bus/vmbus/vmbus_common_uio.c +2 -2
index a689bf11b3..8582e32c1d 100644
@@ -63,7 +63,7 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev)
 
 	for (i = 0; i != uio_res->nb_maps; i++) {
 		void *mapaddr;
-		off_t offset = i * PAGE_SIZE;
+		off_t offset = i * rte_mem_page_size();
 
 		mapaddr = vmbus_map_resource(uio_res->maps[i].addr,
 					     fd, offset,
@@ -175,7 +175,7 @@ vmbus_uio_map_resource(struct rte_vmbus_device *dev)
 	}
 
 	dev->int_page = (uint32_t *)((char *)uio_res->maps[HV_INT_PAGE_MAP].addr
-				     + (PAGE_SIZE >> 1));
+				     + (rte_mem_page_size() >> 1));
 	dev->monitor_page = uio_res->maps[HV_MON_PAGE_MAP].addr;
 	return 0;
 }
drivers/crypto/virtio/virtio_pci.h +2 -1
index d9a214dfd0..0a7ea1bb64 100644
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#include <rte_eal_paging.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_cryptodev.h>
@@ -67,7 +68,7 @@ struct virtqueue;
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int) (rte_mem_page_size() / 16))
 
 /* Do we get callbacks when the ring is completely used, even if we've
  * suppressed them?
drivers/event/dlb/dlb.c +5 -2
index 8b26d1d2d2..1174ab3d2b 100644
@@ -23,6 +23,7 @@
 #include <rte_io.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_power_intrinsics.h>
@@ -991,7 +992,8 @@ dlb_hw_create_ldb_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_LDB_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_LDB_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
@@ -1181,7 +1183,8 @@ dlb_hw_create_dir_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_DIR_PP_BASE + PAGE_SIZE * qm_port_id;
+	qm_port->pp_mmio_base = DLB_DIR_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
 	/* The credit window is one high water mark of QEs */
drivers/event/dlb/dlb_priv.h +0 -2
index 272e17482f..ca4d6a84cf 100644
@@ -76,8 +76,6 @@
 
 #define PP_BASE(is_dir) ((is_dir) ? DLB_DIR_PP_BASE : DLB_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb/pf/base/dlb_osdep.h +1 -1
index 0c119b759a..dee20660ed 100644
@@ -92,7 +92,7 @@ static inline void *os_map_producer_port(struct dlb_hw *hw,
 
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 
drivers/event/dlb/pf/dlb_main.h +1 -4
index 22e215223d..e66ba228d1 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb_hw_types.h"
 #include "../dlb_user.h"
drivers/event/dlb/pf/dlb_pf.c +6 -4
index 3aeef6f91d..2f7e30abbd 100644
@@ -303,7 +303,7 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -328,7 +328,8 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_LDB].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_LDB].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
@@ -381,7 +382,7 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -406,7 +407,8 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_DIR].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_DIR].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
drivers/event/dlb2/dlb2_priv.h +0 -2
index b73cf3ff14..eb1a932399 100644
@@ -78,8 +78,6 @@
 				    DLB2_LDB_CQ_MAX_SIZE)
 #define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB2_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB2_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb2/pf/base/dlb2_osdep.h +1 -1
index c4c34eba5f..aa101a49a3 100644
@@ -89,7 +89,7 @@ static inline void *os_map_producer_port(struct dlb2_hw *hw,
 	uint64_t pp_dma_base;
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
 }
drivers/event/dlb2/pf/dlb2_main.h +1 -4
index f3bee71fb6..9eeda482a3 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb2_hw_types.h"
 #include "../dlb2_user.h"
drivers/event/dlb2/pf/dlb2_pf.c +4 -4
index 1a7d8fc294..1142da5b25 100644
@@ -284,7 +284,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -307,7 +307,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void *)(port_base);
 	memset(&port_memory, 0, sizeof(port_memory));
@@ -359,7 +359,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -382,7 +382,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
 		(void *)(port_base);
drivers/net/bnx2x/ecore_fw_defs.h +12 -6
index 5397a701aa..93bca8ad33 100644
@@ -13,6 +13,8 @@
 #ifndef ECORE_FW_DEFS_H
 #define ECORE_FW_DEFS_H
 
+#include <rte_eal_paging.h>
+
 #define CSTORM_ASSERT_LIST_INDEX_OFFSET	(IRO[152].base)
 #define CSTORM_ASSERT_LIST_OFFSET(assertListEntry) \
 	(IRO[151].base + ((assertListEntry) * IRO[151].m1))
@@ -252,7 +254,8 @@
 #define X_ETH_LOCAL_RING_SIZE 13
 #define FIRST_BD_IN_PKT	0
 #define PARSE_BD_INDEX 1
-#define NUM_OF_ETH_BDS_IN_PAGE ((PAGE_SIZE)/(STRUCT_SIZE(eth_tx_bd)/8))
+#define NUM_OF_ETH_BDS_IN_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_tx_bd) / 8))
 #define U_ETH_NUM_OF_SGES_TO_FETCH 8
 #define U_ETH_MAX_SGES_FOR_PACKET 3
 
@@ -265,11 +268,14 @@
 #define IP_HEADER_ALIGNMENT_PADDING 2
 
 #define U_ETH_SGES_PER_PAGE_INVERSE_MASK \
-	(0xFFFF - ((PAGE_SIZE/((STRUCT_SIZE(eth_rx_sge))/8))-1))
+	(0xFFFF - ((rte_mem_page_size() / ((STRUCT_SIZE(eth_rx_sge)) / 8)) - 1))
 
-#define TU_ETH_CQES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_cqe)/8))
-#define U_ETH_BDS_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_bd)/8))
-#define U_ETH_SGES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_sge)/8))
+#define TU_ETH_CQES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_cqe) / 8))
+#define U_ETH_BDS_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_bd) / 8))
+#define U_ETH_SGES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_sge) / 8))
 
 #define U_ETH_BDS_PER_PAGE_MASK	(U_ETH_BDS_PER_PAGE-1)
 #define U_ETH_CQE_PER_PAGE_MASK	(TU_ETH_CQES_PER_PAGE-1)
@@ -396,7 +402,7 @@
 
 /* Event Ring definitions */
 #define C_ERES_PER_PAGE \
-	(PAGE_SIZE / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
+	(rte_mem_page_size() / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
 #define C_ERE_PER_PAGE_MASK (C_ERES_PER_PAGE - 1)
 
 /* number of statistic command */
drivers/net/ionic/ionic_lif.c +15 -12
index cd220abee2..431eda777b 100644
@@ -612,18 +612,18 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 	cq_size = num_descs * cq_desc_size;
 	sg_size = num_descs * sg_desc_size;
 
-	total_size = RTE_ALIGN(q_size, PAGE_SIZE) +
-		RTE_ALIGN(cq_size, PAGE_SIZE);
+	total_size = RTE_ALIGN(q_size, rte_mem_page_size()) +
+			RTE_ALIGN(cq_size, rte_mem_page_size());
 	/*
 	 * Note: aligning q_size/cq_size is not enough due to cq_base address
 	 * aligning as q_base could be not aligned to the page.
-	 * Adding PAGE_SIZE.
+	 * Adding rte_mem_page_size().
 	 */
-	total_size += PAGE_SIZE;
+	total_size += rte_mem_page_size();
 
 	if (flags & IONIC_QCQ_F_SG) {
-		total_size += RTE_ALIGN(sg_size, PAGE_SIZE);
-		total_size += PAGE_SIZE;
+		total_size += RTE_ALIGN(sg_size, rte_mem_page_size());
+		total_size += rte_mem_page_size();
 	}
 
 	new = rte_zmalloc("ionic", struct_size, 0);
@@ -636,7 +636,7 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 
 	new->q.info = rte_calloc_socket("ionic",
 				num_descs, sizeof(void *),
-				PAGE_SIZE, socket_id);
+				rte_mem_page_size(), socket_id);
 	if (!new->q.info) {
 		IONIC_PRINT(ERR, "Cannot allocate queue info");
 		err = -ENOMEM;
@@ -673,13 +673,16 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 	q_base = new->base;
 	q_base_pa = new->base_pa;
 
-	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size, PAGE_SIZE);
-	cq_base_pa = RTE_ALIGN(q_base_pa + q_size, PAGE_SIZE);
+	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size,
+			rte_mem_page_size());
+	cq_base_pa = RTE_ALIGN(q_base_pa + q_size,
+			rte_mem_page_size());
 
 	if (flags & IONIC_QCQ_F_SG) {
 		sg_base = (void *)RTE_ALIGN((uintptr_t)cq_base + cq_size,
-			PAGE_SIZE);
-		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size, PAGE_SIZE);
+				rte_mem_page_size());
+		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size,
+				rte_mem_page_size());
 		ionic_q_sg_map(&new->q, sg_base, sg_base_pa);
 	}
 
@@ -1002,7 +1005,7 @@ ionic_lif_alloc(struct ionic_lif *lif)
 
 	IONIC_PRINT(DEBUG, "Allocating Lif Info");
 
-	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
+	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), rte_mem_page_size());
 
 	lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
 		"lif_info", 0 /* queue_idx*/,
drivers/net/ionic/ionic_main.c +2 -1
index 9aa7b2e96c..7301f53342 100644
@@ -456,7 +456,8 @@ ionic_port_init(struct ionic_adapter *adapter)
 	if (idev->port_info)
 		return 0;
 
-	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
+	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info),
+			rte_mem_page_size());
 
 	snprintf(z_name, sizeof(z_name), "%s_port_%s_info",
 		IONIC_DRV_NAME, adapter->name);
drivers/net/ionic/ionic_osdep.h +1 -1
index a6575c36b5..89ed106d11 100644
@@ -17,6 +17,7 @@
 #include <rte_byteorder.h>
 #include <rte_io.h>
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 
 #include "ionic_logs.h"
 
@@ -25,7 +26,6 @@
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT      12
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
 #endif
 
 #define __iomem
drivers/net/netvsc/hn_rndis.c +6 -6
index e317539de7..e3f7e636d7 100644
@@ -67,7 +67,7 @@ hn_rndis_rid(struct hn_data *hv)
 
 static void *hn_rndis_alloc(size_t size)
 {
-	return rte_zmalloc("RNDIS", size, PAGE_SIZE);
+	return rte_zmalloc("RNDIS", size, rte_mem_page_size());
 }
 
 #ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP
@@ -265,17 +265,17 @@ static int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
 		return -EINVAL;
 	}
 
-	if (unlikely(reqlen > PAGE_SIZE)) {
+	if (unlikely(reqlen > rte_mem_page_size())) {
 		PMD_DRV_LOG(ERR, "RNDIS request %u greater than page size",
 			    reqlen);
 		return -EINVAL;
 	}
 
-	sg.page = addr / PAGE_SIZE;
+	sg.page = addr / rte_mem_page_size();
 	sg.ofs  = addr & PAGE_MASK;
 	sg.len  = reqlen;
 
-	if (sg.ofs + reqlen >  PAGE_SIZE) {
+	if (sg.ofs + reqlen >  rte_mem_page_size()) {
 		PMD_DRV_LOG(ERR, "RNDIS request crosses page boundary");
 		return -EINVAL;
 	}
@@ -479,7 +479,7 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
 		return -ENOMEM;
 
 	comp_len = sizeof(*comp) + odlen;
-	comp = rte_zmalloc("QUERY", comp_len, PAGE_SIZE);
+	comp = rte_zmalloc("QUERY", comp_len, rte_mem_page_size());
 	if (!comp) {
 		error = -ENOMEM;
 		goto done;
@@ -736,7 +736,7 @@ hn_rndis_set(struct hn_data *hv, uint32_t oid, const void *data, uint32_t dlen)
 	int error;
 
 	reqlen = sizeof(*req) + dlen;
-	req = rte_zmalloc("RNDIS_SET", reqlen, PAGE_SIZE);
+	req = rte_zmalloc("RNDIS_SET", reqlen, rte_mem_page_size());
 	if (!req)
 		return -ENOMEM;
 
drivers/net/netvsc/hn_rxtx.c +6 -4
index 0f4ef0100b..c6bf7cc132 100644
@@ -1387,7 +1387,8 @@ static unsigned int hn_get_slots(const struct rte_mbuf *m)
 		unsigned int size = rte_pktmbuf_data_len(m);
 		unsigned int offs = rte_mbuf_data_iova(m) & PAGE_MASK;
 
-		slots += (offs + size + PAGE_SIZE - 1) / PAGE_SIZE;
+		slots += (offs + size + rte_mem_page_size() - 1) /
+				rte_mem_page_size();
 		m = m->next;
 	}
 
@@ -1402,12 +1403,13 @@ static unsigned int hn_fill_sg(struct vmbus_gpa *sg,
 
 	while (m) {
 		rte_iova_t addr = rte_mbuf_data_iova(m);
-		unsigned int page = addr / PAGE_SIZE;
+		unsigned int page = addr / rte_mem_page_size();
 		unsigned int offset = addr & PAGE_MASK;
 		unsigned int len = rte_pktmbuf_data_len(m);
 
 		while (len > 0) {
-			unsigned int bytes = RTE_MIN(len, PAGE_SIZE - offset);
+			unsigned int bytes = RTE_MIN(len,
+					rte_mem_page_size() - offset);
 
 			sg[segs].page = page;
 			sg[segs].ofs = offset;
@@ -1450,7 +1452,7 @@ static int hn_xmit_sg(struct hn_tx_queue *txq,
 	addr = txq->tx_rndis_iova +
 		((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
 
-	sg[0].page = addr / PAGE_SIZE;
+	sg[0].page = addr / rte_mem_page_size();
 	sg[0].ofs = addr & PAGE_MASK;
 	sg[0].len = RNDIS_PACKET_MSG_OFFSET_ABS(hn_rndis_pktlen(txd->rndis_pkt));
 	segs = 1;
drivers/net/netvsc/hn_var.h +3 -6
index b7405ca726..43642408bc 100644
@@ -6,6 +6,8 @@
  * All rights reserved.
  */
 
+#include <rte_eal_paging.h>
+
 /*
  * Tunable ethdev params
  */
@@ -28,13 +30,8 @@
 
 #define HN_RX_EXTMBUF_ENABLE	0
 
-/* Buffers need to be aligned */
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #ifndef PAGE_MASK
-#define PAGE_MASK (PAGE_SIZE - 1)
+#define PAGE_MASK (rte_mem_page_size() - 1)
 #endif
 
 struct hn_data;
drivers/net/virtio/virtio.h +1 -1
index 21d54904e7..2c987d19ab 100644
@@ -98,7 +98,7 @@
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int)(PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int)(rte_mem_page_size() / 16))
 
 /*
  * Maximum number of virtqueues per device.
drivers/net/virtio/virtio_ethdev.c +3 -3
index 333a5243a9..289b240c4e 100644
@@ -21,8 +21,8 @@
 #include <rte_errno.h>
 #include <rte_cpuflags.h>
 #include <rte_vect.h>
-
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <rte_cycles.h>
@@ -469,7 +469,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		sz_hdr_mz = vq_size * sizeof(struct virtio_tx_region);
 	} else if (queue_type == VTNET_CQ) {
 		/* Allocate a page for control vq command, data and status */
-		sz_hdr_mz = PAGE_SIZE;
+		sz_hdr_mz = rte_mem_page_size();
 	}
 
 	vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
@@ -568,7 +568,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 		cvq->mz = mz;
 		cvq->virtio_net_hdr_mz = hdr_mz;
 		cvq->virtio_net_hdr_mem = hdr_mz->iova;
-		memset(cvq->virtio_net_hdr_mz->addr, 0, PAGE_SIZE);
+		memset(cvq->virtio_net_hdr_mz->addr, 0, rte_mem_page_size());
 
 		hw->cvq = cvq;
 	}
drivers/net/virtio/virtio_ethdev.h +0 -4
index 873327d989..5a501e7890 100644
@@ -11,10 +11,6 @@
 
 #include "virtio.h"
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define VIRTIO_MAX_RX_QUEUES 128U
 #define VIRTIO_MAX_TX_QUEUES 128U
 #define VIRTIO_MAX_MAC_ADDRS 64
drivers/vdpa/ifc/ifcvf_vdpa.c +7 -10
index 6a1b44bc77..39237aecf7 100644
@@ -11,6 +11,7 @@
 #include <linux/virtio_net.h>
 #include <stdbool.h>
 
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_bus_pci.h>
@@ -30,10 +31,6 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define IFCVF_USED_RING_LEN(size) \
 	((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3)
 
@@ -600,11 +597,11 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 	for (i = 0; i < nr_vring; i++) {
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
-		vring_buf = rte_zmalloc("ifcvf", size, PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
+		vring_buf = rte_zmalloc("ifcvf", size, rte_mem_page_size());
 		vring_init(&internal->m_vring[i], vq.size, vring_buf,
-				PAGE_SIZE);
+				rte_mem_page_size());
 
 		ret = rte_vfio_container_dma_map(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)vring_buf, m_vring_iova, size);
@@ -686,8 +683,8 @@ m_ifcvf_stop(struct ifcvf_internal *internal)
 		len = IFCVF_USED_RING_LEN(vq.size);
 		rte_vhost_log_used_vring(vid, i, 0, len);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size, rte_mem_page_size()),
+				rte_mem_page_size());
 		rte_vfio_container_dma_unmap(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)internal->m_vring[i].desc,
 			m_vring_iova, size);
Signature · 1 line
2.30.1
#116 lore raw

Re: [dpdk-dev] [PATCH v7 06/17] drivers: replace page size definitions with function

Quoted 799 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, March 19, 2021 9:57 AM
To: [email protected]
Cc: [email protected]; Andrew Boyer <[email protected]>; Andrew Rybchenko <[email protected]>; David Marchand <[email protected]>; Burakov, Anatoly <[email protected]>; Stephen Hemminger <[email protected]>; Long Li <[email protected]>; Jay Zhou <[email protected]>; McDaniel, Timothy <[email protected]>; Rasesh Mody <[email protected]>; Shahed Shaikh <[email protected]>; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v7 06/17] drivers: replace page size definitions with function

The page size is often retrieved from the macro PAGE_SIZE. If PAGE_SIZE is not defined, it is either using hard coded default, or getting the system value from the UNIX-only function sysconf().

Such definitions are replaced with the generic function rte_mem_page_size() defined for each supported OS.

Removing PAGE_SIZE definitions will fix dlb drivers for musl libc, because #ifdef checks were missing, causing redefinition errors.

---
 drivers/bus/pci/linux/pci_vfio.c        |  9 ++-------
 drivers/bus/vmbus/linux/vmbus_uio.c     |  4 ++--
 drivers/bus/vmbus/private.h             |  5 +----
 drivers/bus/vmbus/rte_vmbus_reg.h       |  2 +-
 drivers/bus/vmbus/vmbus_common_uio.c    |  4 ++--
 drivers/crypto/virtio/virtio_pci.h      |  3 ++-
 drivers/event/dlb/dlb.c                 |  7 +++++--
 drivers/event/dlb/dlb_priv.h            |  2 --
 drivers/event/dlb/pf/base/dlb_osdep.h   |  2 +-
 drivers/event/dlb/pf/dlb_main.h         |  5 +----
 drivers/event/dlb/pf/dlb_pf.c           | 10 +++++----
 drivers/event/dlb2/dlb2_priv.h          |  2 --
 drivers/event/dlb2/pf/base/dlb2_osdep.h |  2 +-
 drivers/event/dlb2/pf/dlb2_main.h       |  5 +----
 drivers/event/dlb2/pf/dlb2_pf.c         |  8 ++++----
 drivers/net/bnx2x/ecore_fw_defs.h       | 18 +++++++++++------
 drivers/net/ionic/ionic_lif.c           | 27 ++++++++++++++-----------
 drivers/net/ionic/ionic_main.c          |  3 ++-
 drivers/net/ionic/ionic_osdep.h         |  2 +-
 drivers/net/netvsc/hn_rndis.c           | 12 +++++------
 drivers/net/netvsc/hn_rxtx.c            | 10 +++++----
 drivers/net/netvsc/hn_var.h             |  9 +++------
 drivers/net/virtio/virtio.h             |  2 +-
 drivers/net/virtio/virtio_ethdev.c      |  6 +++---
 drivers/net/virtio/virtio_ethdev.h      |  4 ----
 drivers/vdpa/ifc/ifcvf_vdpa.c           | 17 +++++++---------
 26 files changed, 85 insertions(+), 95 deletions(-)
drivers/bus/pci/linux/pci_vfio.c +2 -7
index e3f7b6abeb..9d689d6fd9 100644
@@ -38,11 +38,6 @@
 
 #ifdef VFIO_PRESENT
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
-#endif
-#define PAGE_MASK   (~(PAGE_SIZE - 1))
-
 static struct rte_tailq_elem rte_vfio_tailq = {
 	.name = "VFIO_RESOURCE_LIST",
 };
@@ -507,8 +502,8 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct
 mapped_pci_resource *vfio_res,
 		 */
 		uint32_t table_start = msix_table->offset;
 		uint32_t table_end = table_start + msix_table->size;
-		table_end = RTE_ALIGN(table_end, PAGE_SIZE);
-		table_start = RTE_ALIGN_FLOOR(table_start, PAGE_SIZE);
+		table_end = RTE_ALIGN(table_end, rte_mem_page_size());
+		table_start = RTE_ALIGN_FLOOR(table_start,
 rte_mem_page_size());
 
drivers/bus/pci/linux/pci_vfio.c +0 -0
 		/* If page-aligned start of MSI-X table is less than the
 		 * actual MSI-X table start address, reassign to the actual
drivers/bus/vmbus/linux/vmbus_uio.c +1 -1
index 5dc0c47de6..b52ca5bf1d 100644
@@ -154,7 +154,7 @@ vmbus_uio_map_resource_by_index(struct
 rte_vmbus_device *dev, int idx,
 		vmbus_map_addr = vmbus_find_max_end_va();
 
 	/* offset is special in uio it indicates which resource */
-	offset = idx * PAGE_SIZE;
+	offset = idx * rte_mem_page_size();
 
 	mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size,

flags);

drivers/bus/vmbus/linux/vmbus_uio.c +1 -1
 	close(fd);
@@ -224,7 +224,7 @@ static int vmbus_uio_map_subchan(const struct
 rte_vmbus_device *dev,
 	}
 	file_size = sb.st_size;
 
-	if (file_size == 0 || (file_size & (PAGE_SIZE - 1))) {
+	if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) {
 		VMBUS_LOG(ERR, "incorrect size %s: %zu",
 			  ring_path, file_size);
drivers/bus/vmbus/private.h +1 -4
index f19b14e4a6..528d60a42f 100644
@@ -9,13 +9,10 @@
 #include <stdbool.h>
 #include <sys/uio.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_vmbus_reg.h>
 #include <rte_bus_vmbus.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE	4096
-#endif
-
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 extern int vmbus_logtype_bus;
drivers/bus/vmbus/rte_vmbus_reg.h +1 -1
index f5a0693dcb..8562672979 100644
@@ -100,7 +100,7 @@ struct vmbus_bufring {
 		uint32_t value;
 	} feature_bits;
 
-	/* Pad it to PAGE_SIZE so that data starts on page boundary */
+	/* Pad it to rte_mem_page_size() so that data starts on page boundary
 */
 	uint8_t	reserved2[4028];
 
drivers/bus/vmbus/rte_vmbus_reg.h +0 -0
 	/*
drivers/bus/vmbus/vmbus_common_uio.c +1 -1
index a689bf11b3..8582e32c1d 100644
@@ -63,7 +63,7 @@ vmbus_uio_map_secondary(struct rte_vmbus_device
 *dev)
 
 	for (i = 0; i != uio_res->nb_maps; i++) {
 		void *mapaddr;
-		off_t offset = i * PAGE_SIZE;
+		off_t offset = i * rte_mem_page_size();
 
 		mapaddr = vmbus_map_resource(uio_res->maps[i].addr,
drivers/bus/vmbus/vmbus_common_uio.c +0 -0
 					     fd, offset,
@@ -175,7 +175,7 @@ vmbus_uio_map_resource(struct rte_vmbus_device
 *dev)
 	}
 
 	dev->int_page = (uint32_t *)((char *)uio_res-
Quoted 1 line

maps[HV_INT_PAGE_MAP].addr

drivers/bus/vmbus/vmbus_common_uio.c +1 -1
-				     + (PAGE_SIZE >> 1));
+				     + (rte_mem_page_size() >> 1));
 	dev->monitor_page = uio_res->maps[HV_MON_PAGE_MAP].addr;
 	return 0;
 }
drivers/crypto/virtio/virtio_pci.h +2 -1
index d9a214dfd0..0a7ea1bb64 100644
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#include <rte_eal_paging.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_cryptodev.h>
@@ -67,7 +68,7 @@ struct virtqueue;
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int) (rte_mem_page_size() / 16))
 
 /* Do we get callbacks when the ring is completely used, even if we've
  * suppressed them?
drivers/event/dlb/dlb.c +3 -1
index 8b26d1d2d2..1174ab3d2b 100644
@@ -23,6 +23,7 @@
 #include <rte_io.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_power_intrinsics.h>
@@ -991,7 +992,8 @@ dlb_hw_create_ldb_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_LDB_PP_BASE + PAGE_SIZE *
 qm_port_id;
+	qm_port->pp_mmio_base = DLB_LDB_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
drivers/event/dlb/dlb.c +2 -1
 	/* The credit window is one high water mark of QEs */
@@ -1181,7 +1183,8 @@ dlb_hw_create_dir_port(struct dlb_eventdev *dlb,
 		goto error_exit;
 	}
 
-	qm_port->pp_mmio_base = DLB_DIR_PP_BASE + PAGE_SIZE *
 qm_port_id;
+	qm_port->pp_mmio_base = DLB_DIR_PP_BASE +
+			rte_mem_page_size() * qm_port_id;
 	qm_port->id = qm_port_id;
 
drivers/event/dlb/dlb.c +0 -0
 	/* The credit window is one high water mark of QEs */
drivers/event/dlb/dlb_priv.h +0 -2
index 272e17482f..ca4d6a84cf 100644
@@ -76,8 +76,6 @@
 
 #define PP_BASE(is_dir) ((is_dir) ? DLB_DIR_PP_BASE : DLB_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb/pf/base/dlb_osdep.h +1 -1
index 0c119b759a..dee20660ed 100644
@@ -92,7 +92,7 @@ static inline void *os_map_producer_port(struct dlb_hw
 *hw,
 
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;
drivers/event/dlb/pf/dlb_main.h +1 -4
index 22e215223d..e66ba228d1 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb_hw_types.h"
 #include "../dlb_user.h"
drivers/event/dlb/pf/dlb_pf.c +6 -4
index 3aeef6f91d..2f7e30abbd 100644
@@ -303,7 +303,7 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -328,7 +328,8 @@ dlb_pf_ldb_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_LDB].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_LDB].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
@@ -381,7 +382,7 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb_alloc_coherent_aligned(&mz, &pc_dma_base,
-					       alloc_sz, PAGE_SIZE);
+					       alloc_sz, rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -406,7 +407,8 @@ dlb_pf_dir_port_create(struct dlb_hw_dev *handle,
 
 	pp_dma_base = (uintptr_t)dlb_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb_port[response.id][DLB_DIR].pp_addr =
-		(void *)(uintptr_t)(pp_dma_base + (PAGE_SIZE * response.id));
+			(void *)(uintptr_t)(pp_dma_base +
+			(rte_mem_page_size() * response.id));
 
 	dlb_port[response.id][DLB_DIR].cq_base =
 		(void *)(uintptr_t)(port_base + (2 * RTE_CACHE_LINE_SIZE));
drivers/event/dlb2/dlb2_priv.h +0 -2
index b73cf3ff14..eb1a932399 100644
@@ -78,8 +78,6 @@
 				    DLB2_LDB_CQ_MAX_SIZE)
 #define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
 
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-
 #define DLB2_NUM_QES_PER_CACHE_LINE 4
 
 #define DLB2_MAX_ENQUEUE_DEPTH 64
drivers/event/dlb2/pf/base/dlb2_osdep.h +1 -1
index c4c34eba5f..aa101a49a3 100644
@@ -89,7 +89,7 @@ static inline void *os_map_producer_port(struct dlb2_hw
 *hw,
 	uint64_t pp_dma_base;
 
 	pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);
-	addr = (pp_dma_base + (PAGE_SIZE * port_id));
+	addr = (pp_dma_base + (rte_mem_page_size() * port_id));
 
 	return (void *)(uintptr_t)addr;

}

drivers/event/dlb2/pf/dlb2_main.h +1 -4
index f3bee71fb6..9eeda482a3 100644
@@ -10,10 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
-#endif
+#include <rte_eal_paging.h>
 
 #include "base/dlb2_hw_types.h"
 #include "../dlb2_user.h"
drivers/event/dlb2/pf/dlb2_pf.c +2 -2
index 1a7d8fc294..1142da5b25 100644
@@ -284,7 +284,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -307,7 +307,7 @@ dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void
 *)(port_base);
drivers/event/dlb2/pf/dlb2_pf.c +2 -2
 	memset(&port_memory, 0, sizeof(port_memory));
@@ -359,7 +359,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
 
 	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
-						PAGE_SIZE);
+						rte_mem_page_size());
 	if (port_base == NULL)
 		return -ENOMEM;
 
@@ -382,7 +382,7 @@ dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
 
 	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
 	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
-		(void *)(pp_base + (PAGE_SIZE * response.id));
+		(void *)(pp_base + (rte_mem_page_size() * response.id));
 
 	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
 		(void *)(port_base);
drivers/net/bnx2x/ecore_fw_defs.h +12 -6
index 5397a701aa..93bca8ad33 100644
@@ -13,6 +13,8 @@
 #ifndef ECORE_FW_DEFS_H
 #define ECORE_FW_DEFS_H
 
+#include <rte_eal_paging.h>
+
 #define CSTORM_ASSERT_LIST_INDEX_OFFSET	(IRO[152].base)
 #define CSTORM_ASSERT_LIST_OFFSET(assertListEntry) \
 	(IRO[151].base + ((assertListEntry) * IRO[151].m1))
@@ -252,7 +254,8 @@
 #define X_ETH_LOCAL_RING_SIZE 13
 #define FIRST_BD_IN_PKT	0
 #define PARSE_BD_INDEX 1
-#define NUM_OF_ETH_BDS_IN_PAGE
 ((PAGE_SIZE)/(STRUCT_SIZE(eth_tx_bd)/8))
+#define NUM_OF_ETH_BDS_IN_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_tx_bd) / 8))
 #define U_ETH_NUM_OF_SGES_TO_FETCH 8
 #define U_ETH_MAX_SGES_FOR_PACKET 3
@@ -265,11 +268,14 @@
 #define IP_HEADER_ALIGNMENT_PADDING 2
 
 #define U_ETH_SGES_PER_PAGE_INVERSE_MASK \
-	(0xFFFF - ((PAGE_SIZE/((STRUCT_SIZE(eth_rx_sge))/8))-1))
+	(0xFFFF - ((rte_mem_page_size() / ((STRUCT_SIZE(eth_rx_sge)) / 8)) - 1))
 
-#define TU_ETH_CQES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_cqe)/8))
-#define U_ETH_BDS_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_bd)/8))
-#define U_ETH_SGES_PER_PAGE (PAGE_SIZE/(STRUCT_SIZE(eth_rx_sge)/8))
+#define TU_ETH_CQES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_cqe) / 8))
+#define U_ETH_BDS_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_bd) / 8))
+#define U_ETH_SGES_PER_PAGE \
+	(rte_mem_page_size() / (STRUCT_SIZE(eth_rx_sge) / 8))
 
 #define U_ETH_BDS_PER_PAGE_MASK	(U_ETH_BDS_PER_PAGE-1)
 #define U_ETH_CQE_PER_PAGE_MASK	(TU_ETH_CQES_PER_PAGE-1)
@@ -396,7 +402,7 @@
 
 /* Event Ring definitions */
 #define C_ERES_PER_PAGE \
-	(PAGE_SIZE / BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
+	(rte_mem_page_size() /
 BITS_TO_BYTES(STRUCT_SIZE(event_ring_elem)))
 #define C_ERE_PER_PAGE_MASK (C_ERES_PER_PAGE - 1)
 

/* number of statistic command */

drivers/net/ionic/ionic_lif.c +15 -12
index cd220abee2..431eda777b 100644
@@ -612,18 +612,18 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 	cq_size = num_descs * cq_desc_size;
 	sg_size = num_descs * sg_desc_size;
 
-	total_size = RTE_ALIGN(q_size, PAGE_SIZE) +
-		RTE_ALIGN(cq_size, PAGE_SIZE);
+	total_size = RTE_ALIGN(q_size, rte_mem_page_size()) +
+			RTE_ALIGN(cq_size, rte_mem_page_size());
 	/*
 	 * Note: aligning q_size/cq_size is not enough due to cq_base address
 	 * aligning as q_base could be not aligned to the page.
-	 * Adding PAGE_SIZE.
+	 * Adding rte_mem_page_size().
 	 */
-	total_size += PAGE_SIZE;
+	total_size += rte_mem_page_size();
 
 	if (flags & IONIC_QCQ_F_SG) {
-		total_size += RTE_ALIGN(sg_size, PAGE_SIZE);
-		total_size += PAGE_SIZE;
+		total_size += RTE_ALIGN(sg_size, rte_mem_page_size());
+		total_size += rte_mem_page_size();
 	}
 
 	new = rte_zmalloc("ionic", struct_size, 0);
@@ -636,7 +636,7 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 
 	new->q.info = rte_calloc_socket("ionic",
 				num_descs, sizeof(void *),
-				PAGE_SIZE, socket_id);
+				rte_mem_page_size(), socket_id);
 	if (!new->q.info) {
 		IONIC_PRINT(ERR, "Cannot allocate queue info");
 		err = -ENOMEM;
@@ -673,13 +673,16 @@ ionic_qcq_alloc(struct ionic_lif *lif,
 	q_base = new->base;
 	q_base_pa = new->base_pa;
 
-	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size, PAGE_SIZE);
-	cq_base_pa = RTE_ALIGN(q_base_pa + q_size, PAGE_SIZE);
+	cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size,
+			rte_mem_page_size());
+	cq_base_pa = RTE_ALIGN(q_base_pa + q_size,
+			rte_mem_page_size());
 
 	if (flags & IONIC_QCQ_F_SG) {
 		sg_base = (void *)RTE_ALIGN((uintptr_t)cq_base + cq_size,
-			PAGE_SIZE);
-		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size, PAGE_SIZE);
+				rte_mem_page_size());
+		sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size,
+				rte_mem_page_size());
 		ionic_q_sg_map(&new->q, sg_base, sg_base_pa);
 	}
 
@@ -1002,7 +1005,7 @@ ionic_lif_alloc(struct ionic_lif *lif)
 
 	IONIC_PRINT(DEBUG, "Allocating Lif Info");
 
-	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
+	lif->info_sz = RTE_ALIGN(sizeof(*lif->info), rte_mem_page_size());
 
 	lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
 		"lif_info", 0 /* queue_idx*/,
drivers/net/ionic/ionic_main.c +2 -1
index 9aa7b2e96c..7301f53342 100644
@@ -456,7 +456,8 @@ ionic_port_init(struct ionic_adapter *adapter)
 	if (idev->port_info)
 		return 0;
 
-	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
+	idev->port_info_sz = RTE_ALIGN(sizeof(*idev->port_info),
+			rte_mem_page_size());
 
 	snprintf(z_name, sizeof(z_name), "%s_port_%s_info",
 		IONIC_DRV_NAME, adapter->name);
drivers/net/ionic/ionic_osdep.h +1 -1
index a6575c36b5..89ed106d11 100644
@@ -17,6 +17,7 @@
 #include <rte_byteorder.h>
 #include <rte_io.h>
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 
 #include "ionic_logs.h"
 
@@ -25,7 +26,6 @@
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT      12
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
 #endif
 
 #define __iomem
drivers/net/netvsc/hn_rndis.c +4 -4
index e317539de7..e3f7e636d7 100644
@@ -67,7 +67,7 @@ hn_rndis_rid(struct hn_data *hv)
 
 static void *hn_rndis_alloc(size_t size)
 {
-	return rte_zmalloc("RNDIS", size, PAGE_SIZE);
+	return rte_zmalloc("RNDIS", size, rte_mem_page_size());
 }
 
 #ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP
@@ -265,17 +265,17 @@ static int hn_nvs_send_rndis_ctrl(struct
 vmbus_channel *chan,
 		return -EINVAL;
 	}
 
-	if (unlikely(reqlen > PAGE_SIZE)) {
+	if (unlikely(reqlen > rte_mem_page_size())) {
 		PMD_DRV_LOG(ERR, "RNDIS request %u greater than page
 size",
 			    reqlen);
 		return -EINVAL;
 	}
 
-	sg.page = addr / PAGE_SIZE;
+	sg.page = addr / rte_mem_page_size();
 	sg.ofs  = addr & PAGE_MASK;
 	sg.len  = reqlen;
 
-	if (sg.ofs + reqlen >  PAGE_SIZE) {
+	if (sg.ofs + reqlen >  rte_mem_page_size()) {
 		PMD_DRV_LOG(ERR, "RNDIS request crosses page boundary");
drivers/net/netvsc/hn_rndis.c +2 -2
 		return -EINVAL;
 	}
@@ -479,7 +479,7 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
 		return -ENOMEM;
 
 	comp_len = sizeof(*comp) + odlen;
-	comp = rte_zmalloc("QUERY", comp_len, PAGE_SIZE);
+	comp = rte_zmalloc("QUERY", comp_len, rte_mem_page_size());
 	if (!comp) {
 		error = -ENOMEM;
 		goto done;
@@ -736,7 +736,7 @@ hn_rndis_set(struct hn_data *hv, uint32_t oid, const
 void *data, uint32_t dlen)
 	int error;
 
 	reqlen = sizeof(*req) + dlen;
-	req = rte_zmalloc("RNDIS_SET", reqlen, PAGE_SIZE);
+	req = rte_zmalloc("RNDIS_SET", reqlen, rte_mem_page_size());
 	if (!req)
 		return -ENOMEM;
drivers/net/netvsc/hn_rxtx.c +6 -4
index 0f4ef0100b..c6bf7cc132 100644
@@ -1387,7 +1387,8 @@ static unsigned int hn_get_slots(const struct rte_mbuf
 *m)
 		unsigned int size = rte_pktmbuf_data_len(m);
 		unsigned int offs = rte_mbuf_data_iova(m) & PAGE_MASK;
 
-		slots += (offs + size + PAGE_SIZE - 1) / PAGE_SIZE;
+		slots += (offs + size + rte_mem_page_size() - 1) /
+				rte_mem_page_size();
 		m = m->next;
 	}
@@ -1402,12 +1403,13 @@ static unsigned int hn_fill_sg(struct vmbus_gpa *sg,
 
 	while (m) {
 		rte_iova_t addr = rte_mbuf_data_iova(m);
-		unsigned int page = addr / PAGE_SIZE;
+		unsigned int page = addr / rte_mem_page_size();
 		unsigned int offset = addr & PAGE_MASK;
 		unsigned int len = rte_pktmbuf_data_len(m);
 
 		while (len > 0) {
-			unsigned int bytes = RTE_MIN(len, PAGE_SIZE - offset);
+			unsigned int bytes = RTE_MIN(len,
+					rte_mem_page_size() - offset);
 
 			sg[segs].page = page;
 			sg[segs].ofs = offset;
@@ -1450,7 +1452,7 @@ static int hn_xmit_sg(struct hn_tx_queue *txq,
 	addr = txq->tx_rndis_iova +
 		((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
 
-	sg[0].page = addr / PAGE_SIZE;
+	sg[0].page = addr / rte_mem_page_size();
 	sg[0].ofs = addr & PAGE_MASK;
 	sg[0].len = RNDIS_PACKET_MSG_OFFSET_ABS(hn_rndis_pktlen(txd-
 >rndis_pkt));
drivers/net/netvsc/hn_rxtx.c +0 -0
 	segs = 1;
drivers/net/netvsc/hn_var.h +3 -6
index b7405ca726..43642408bc 100644
@@ -6,6 +6,8 @@
  * All rights reserved.
  */
 
+#include <rte_eal_paging.h>
+
 /*
  * Tunable ethdev params
  */
@@ -28,13 +30,8 @@
 
 #define HN_RX_EXTMBUF_ENABLE	0
 
-/* Buffers need to be aligned */
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #ifndef PAGE_MASK
-#define PAGE_MASK (PAGE_SIZE - 1)
+#define PAGE_MASK (rte_mem_page_size() - 1)
 #endif
 
 struct hn_data;
drivers/net/virtio/virtio.h +1 -1
index 21d54904e7..2c987d19ab 100644
@@ -98,7 +98,7 @@
  *
  * Note the sizeof(struct vring_desc) is 16 bytes.
  */
-#define VIRTIO_MAX_INDIRECT ((int)(PAGE_SIZE / 16))
+#define VIRTIO_MAX_INDIRECT ((int)(rte_mem_page_size() / 16))
 
 /*
  * Maximum number of virtqueues per device.
drivers/net/virtio/virtio_ethdev.c +2 -2
index 333a5243a9..289b240c4e 100644
@@ -21,8 +21,8 @@
 #include <rte_errno.h>
 #include <rte_cpuflags.h>
 #include <rte_vect.h>
-
 #include <rte_memory.h>
+#include <rte_eal_paging.h>
 #include <rte_eal.h>
 #include <rte_dev.h>
 #include <rte_cycles.h>
@@ -469,7 +469,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t
 queue_idx)
 		sz_hdr_mz = vq_size * sizeof(struct virtio_tx_region);
 	} else if (queue_type == VTNET_CQ) {
 		/* Allocate a page for control vq command, data and status */
-		sz_hdr_mz = PAGE_SIZE;
+		sz_hdr_mz = rte_mem_page_size();
 	}
 
drivers/net/virtio/virtio_ethdev.c +1 -1
 	vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
@@ -568,7 +568,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t
 queue_idx)
 		cvq->mz = mz;
 		cvq->virtio_net_hdr_mz = hdr_mz;
 		cvq->virtio_net_hdr_mem = hdr_mz->iova;
-		memset(cvq->virtio_net_hdr_mz->addr, 0, PAGE_SIZE);
+		memset(cvq->virtio_net_hdr_mz->addr, 0,
 rte_mem_page_size());
 
drivers/net/virtio/virtio_ethdev.c +0 -0
 		hw->cvq = cvq;
 	}
drivers/net/virtio/virtio_ethdev.h +0 -4
index 873327d989..5a501e7890 100644
@@ -11,10 +11,6 @@
 
 #include "virtio.h"
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define VIRTIO_MAX_RX_QUEUES 128U
 #define VIRTIO_MAX_TX_QUEUES 128U
 #define VIRTIO_MAX_MAC_ADDRS 64
drivers/vdpa/ifc/ifcvf_vdpa.c +5 -8
index 6a1b44bc77..39237aecf7 100644
@@ -11,6 +11,7 @@
 #include <linux/virtio_net.h>
 #include <stdbool.h>
 
+#include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_bus_pci.h>
@@ -30,10 +31,6 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype,
 pmd.net.ifcvf_vdpa, NOTICE);
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
 #define IFCVF_USED_RING_LEN(size) \
 	((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3)
@@ -600,11 +597,11 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 	for (i = 0; i < nr_vring; i++) {
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
-		vring_buf = rte_zmalloc("ifcvf", size, PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size,
 rte_mem_page_size()),
+				rte_mem_page_size());
+		vring_buf = rte_zmalloc("ifcvf", size, rte_mem_page_size());
 		vring_init(&internal->m_vring[i], vq.size, vring_buf,
-				PAGE_SIZE);
+				rte_mem_page_size());
 
 		ret = rte_vfio_container_dma_map(internal-
Quoted 1 line

vfio_container_fd,

drivers/vdpa/ifc/ifcvf_vdpa.c +2 -2
 			(uint64_t)(uintptr_t)vring_buf, m_vring_iova, size);
@@ -686,8 +683,8 @@ m_ifcvf_stop(struct ifcvf_internal *internal)
 		len = IFCVF_USED_RING_LEN(vq.size);
 		rte_vhost_log_used_vring(vid, i, 0, len);
 
-		size = RTE_ALIGN_CEIL(vring_size(vq.size, PAGE_SIZE),
-				PAGE_SIZE);
+		size = RTE_ALIGN_CEIL(vring_size(vq.size,
 rte_mem_page_size()),
+				rte_mem_page_size());
 		rte_vfio_container_dma_unmap(internal->vfio_container_fd,
 			(uint64_t)(uintptr_t)internal->m_vring[i].desc,
Quoted 3 lines

m_vring_iova, size);
--
2.30.1

ack

#117 lore raw

PATCH v7 7/17 common/dpaax/caamflib: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/common/dpaax/caamflib/compat.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/dpaax/caamflib/compat.h +6 -6
index 36ee4b5335..c1a693498d 100644
@@ -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)
Signature · 1 line
2.30.1
#118 lore raw

PATCH v7 8/17 common/dpaax/caamflib: simplify log macros

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

Simplify pr_debug, pr_err and pr_warn macros by adding an intermediate pr_msg macro. This way we only need to test for SUPPRESS_PRINTS once.

---
 drivers/common/dpaax/caamflib/compat.h | 28 +++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/common/dpaax/caamflib/compat.h +12 -16
index c1a693498d..9776eed437 100644
@@ -40,31 +40,27 @@
 #define __maybe_unused __rte_unused
 #endif
 
+#if defined(SUPPRESS_PRINTS)
+#define pr_msg(l, fmt, ...) do { } while (0)
+#else
+#define pr_msg(l, fmt, ...) \
+	RTE_LOG(l, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#endif
+
 #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__)
+#if defined(RTA_DEBUG)
+#define pr_debug(fmt, ...) pr_msg(DEBUG, fmt, ##__VA_ARGS__)
 #else
-#define pr_debug(fmt, ...)     do { } while (0)
+#define pr_debug(fmt, ...) do { } while (0)
 #endif
 #endif /* pr_debug */
 
 #if !defined(pr_err)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_err(fmt, ...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_err(fmt, ...)    do { } while (0)
-#endif
+#define pr_err(fmt, ...) pr_msg(ERR, fmt, ##__VA_ARGS__)
 #endif /* pr_err */
 
 #if !defined(pr_warn)
-#if !defined(SUPPRESS_PRINTS)
-#define pr_warn(fmt, ...) \
-	RTE_LOG(WARNING, PMD, "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
-#else
-#define pr_warn(fmt, ...)    do { } while (0)
-#endif
+#define pr_warn(fmt, ...) pr_msg(WARNING, fmt, ##__VA_ARGS__)
 #endif /* pr_warn */
 
 /**
Signature · 1 line
2.30.1
#119 lore raw

PATCH v7 9/17 bus/dpaa: fix 64-bit arch detection

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/bus/dpaa/include/fsl_qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/dpaa/include/fsl_qman.h +1 -1
index 10212f0fd5..7ef2f3b2e3 100644
@@ -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.
Signature · 1 line
2.30.1
#120 lore raw

PATCH v7 10/17 bus/dpaa: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
drivers/bus/dpaa/base/fman/netcfg_layer.c +2 -2
index b7009f2299..120deb0bb6 100644
@@ -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;
 	}
 
drivers/bus/dpaa/base/qbman/bman_driver.c +9 -4
index 750b756b93..ee35e03da1 100644
@@ -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;
 }
 
drivers/bus/dpaa/base/qbman/qman_driver.c +12 -5
index 6d9aaff164..dfbafe581a 100644
@@ -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;
 	}
drivers/bus/dpaa/include/netcfg.h +0 -1
index d7d1befd24..bb18a34e3d 100644
@@ -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 {
drivers/common/dpaax/compat.h +0 -1
index c69e76ab96..7166f8cceb 100644
@@ -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>
Signature · 1 line
2.30.1
#121 lore raw

PATCH v7 11/17 bus/pci: support I/O port operations with musl

In reply to Thomas Monjalon

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")
---
 drivers/bus/pci/linux/pci_uio.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
drivers/bus/pci/linux/pci_uio.c +30 -2
index 0907051e04..39ebeac2a0 100644
@@ -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,
Signature · 1 line
2.30.1
#122 lore raw

PATCH v7 12/17 net/cxgbe: remove use of uint type

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 drivers/net/cxgbe/base/common.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/cxgbe/base/common.h +9 -9
index 202a2f4baf..ab100d784c 100644
@@ -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;
 };
Signature · 1 line
2.30.1
#123 lore raw

PATCH v7 13/17 net/igc: remove use of uint type

In reply to Thomas Monjalon

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

Fixes 746664d546fb ("net/igc: support flow API")
---
 drivers/net/igc/igc_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/igc/igc_flow.c +1 -1
index 1bb64d323c..66053060af 100644
@@ -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",
Signature · 1 line
2.30.1
#124 lore raw

PATCH v7 14/17 vdpa/mlx5: replace pthread functions unavailable in musl

In reply to 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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +13 -12
index 86adc864f5..49632dfaa7 100644
@@ -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) {
Signature · 1 line
2.30.1
#125 lore raw

PATCH v7 15/17 event/dlb: fix header includes for musl

In reply to Thomas Monjalon

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")
---
 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(-)
drivers/event/dlb/dlb.c +1 -1
index 1174ab3d2b..60084ced3b 100644
@@ -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>
 
drivers/event/dlb/pf/dlb_pf.c +2 -1
index 2f7e30abbd..5445c2d57d 100644
@@ -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>
drivers/event/dlb2/dlb2.c +1 -1
index b28ec58bfb..fb5ff012a4 100644
@@ -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>
drivers/event/dlb2/pf/dlb2_pf.c +2 -1
index 1142da5b25..cfb22efe8a 100644
@@ -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>
Signature · 1 line
2.30.1
#126 lore raw

Re: [dpdk-dev] [PATCH v7 15/17] event/dlb: fix header includes for musl

Quoted 94 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, March 19, 2021 9:57 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrew Rybchenko <[email protected]>; David Marchand <[email protected]>; McDaniel, Timothy <[email protected]>; Gage Eads <[email protected]>
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")
---
 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(-)
drivers/event/dlb/dlb.c +1 -1
index 1174ab3d2b..60084ced3b 100644
@@ -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>
 
drivers/event/dlb/pf/dlb_pf.c +2 -1
index 2f7e30abbd..5445c2d57d 100644
@@ -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>
drivers/event/dlb2/dlb2.c +1 -1
index b28ec58bfb..fb5ff012a4 100644
@@ -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>
drivers/event/dlb2/pf/dlb2_pf.c +2 -2
index 1142da5b25..cfb22efe8a 100644
@@ -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>
--
Quoted 1 line

2.30.1

ack

#127 lore raw

PATCH v7 16/17 app/testpmd: fix build with musl

In reply to Thomas Monjalon

From: Natanael Copa <[email protected]>

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")
---
 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(-)
app/test-pmd/bpf_cmd.c +1 -1
index 066619e115..6980291f07 100644
@@ -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),
app/test-pmd/config.c +1 -1
index 576d5acab5..e865de10a4 100644
@@ -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;
app/test-pmd/testpmd.h +1 -1
index af40859170..a87ccb0f0f 100644
@@ -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);
Signature · 1 line
2.30.1
#128 lore raw

PATCH v7 17/17 examples/bbdev: fix header include for musl

In reply to Thomas Monjalon

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")
---
 examples/bbdev_app/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/bbdev_app/main.c +1 -1
index 2e170caf84..20cfd327fb 100644
@@ -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>
Signature · 1 line
2.30.1
#129 lore raw

Re: [dpdk-dev] [PATCH v7 00/17] Alpine/musl build support

In reply to Thomas Monjalon

19/03/2021 15:57, Thomas Monjalon:

Quoted 3 lines

These patches fix some build errors/warning for Alpine Linux, using musl and busybox.
Few improvements are added on the way.

Applied with a small last minute change in a script as discussed. Alpine is now supported in DPDK.
Next step: add a test in our CI.