Skip to contentSkip to conversation

ppc64le: fix build with Clang and without glibc

PATCH In review Piotr Kubaj 5 participants 9 messages Mar 11, 2021 – May 11, 2021 2 messages not in the archive Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc64le: fix build with Clang and without glibc

There are couple of issues when building with Clang:
1. vector is a keyword and should not be used in code. I undefined it, but it would probably be better to just change the variable name.
2. vector long is deprecated by Clang and should not be used. I switched here to vector int.
3. Additionally, sys/platform/ppc.h is glibc-dependant and is not available in other libc's. Use the portable method of reading TBR when glibc is not used. Taken from
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/sys/platform/ppc.h

---
 app/test-bbdev/test_bbdev_vector.h            |  3 +
 .../cperf_test_vector_parsing.h               |  3 +
 app/test-crypto-perf/cperf_test_verify.c      |  3 +
 drivers/net/bnxt/bnxt_irq.h                   |  3 +
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 70 +++++++++----------
 drivers/net/ixgbe/ixgbe_ethdev.c              |  3 +
 drivers/net/ixgbe/ixgbe_rxtx.c                |  3 +
 drivers/net/txgbe/txgbe_ethdev.c              |  3 +
 lib/librte_eal/ppc/include/rte_altivec.h      |  3 +
 lib/librte_eal/ppc/include/rte_cycles.h       |  8 +++
 10 files changed, 67 insertions(+), 35 deletions(-)
app/test-bbdev/test_bbdev_vector.h +3 -0
index 4e5dbf5d5..665443fa8 100644
@@ -71,6 +71,9 @@ struct test_bbdev_vector {
 };
 
 /* fills test vector parameters based on test file */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 int
 test_bbdev_vector_read(const char *filename,
 		struct test_bbdev_vector *vector);
app/test-crypto-perf/cperf_test_vector_parsing.h +3 -0
index 247b14221..76a86cea5 100644
@@ -18,6 +18,9 @@
  * @return
  *   0 on success, (-1) on error.
  */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 int
 free_test_vector(struct cperf_test_vector *vector, struct cperf_options *opts);
 
app/test-crypto-perf/cperf_test_verify.c +3 -0
index 2939aeaa9..14010a5a2 100644
@@ -91,6 +91,9 @@ cperf_verify_test_constructor(struct rte_mempool *sess_mp,
 	return NULL;
 }
 
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 static int
 cperf_verify_op(struct rte_crypto_op *op,
 		const struct cperf_options *options,
drivers/net/bnxt/bnxt_irq.h +3 -0
index 7b02f3097..59a9c4224 100644
@@ -8,6 +8,9 @@
 
 struct bnxt_irq {
 	rte_intr_callback_fn	handler;
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 	unsigned int		vector;
 	uint8_t			requested;
 	char			name[RTE_ETH_NAME_MAX_LEN + 2];
drivers/net/i40e/i40e_rxtx_vec_altivec.c +35 -35

185 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +3 -0
index 761a0f26b..59ffe92ea 100644
@@ -5597,6 +5597,9 @@ ixgbe_vt_check(struct ixgbe_hw *hw)
 static uint32_t
 ixgbe_uta_vector(struct ixgbe_hw *hw, struct rte_ether_addr *uc_addr)
 {
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 	uint32_t vector = 0;
 
 	switch (hw->mac.mc_filter_type) {
drivers/net/ixgbe/ixgbe_rxtx.c +3 -0
index 7d23bab29..88d71131e 100644
@@ -4740,6 +4740,9 @@ ixgbe_get_rscctl_maxdesc(struct rte_mempool *pool)
  * @vector the MSIX vector for this queue
  * @type RX/TX/MISC
  */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 static void
 ixgbe_set_ivar(struct rte_eth_dev *dev, u8 entry, u8 vector, s8 type)
 {
drivers/net/txgbe/txgbe_ethdev.c +3 -0
index 90137d0ce..2747246a1 100644
@@ -3382,6 +3382,9 @@ txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 static uint32_t
 txgbe_uta_vector(struct txgbe_hw *hw, struct rte_ether_addr *uc_addr)
 {
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 	uint32_t vector = 0;
 
 	switch (hw->mac.mc_filter_type) {
lib/librte_eal/ppc/include/rte_altivec.h +3 -0
index 1551a9454..3fcc819c1 100644
@@ -7,6 +7,9 @@
 #define _RTE_ALTIVEC_H_
 
 /* To include altivec.h, GCC version must be >= 4.8 */
+#ifdef __clang__
+#define vector __vector
+#endif
 #include <altivec.h>
 
 /*
lib/librte_eal/ppc/include/rte_cycles.h +8 -0
index 5585f9273..9925d1d0d 100644
@@ -10,7 +10,9 @@
 extern "C" {
 #endif
 
+#ifdef __GLIBC__
 #include <sys/platform/ppc.h>
+#endif
 
 #include "generic/rte_cycles.h"
 
@@ -26,7 +28,13 @@ extern "C" {
 static inline uint64_t
 rte_rdtsc(void)
 {
+#ifdef __GLIBC__
 	return __ppc_get_timebase();
+#else
+	uint64_t __tb;
+	__asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
+	return __tb;
+#endif
 }
 
 static inline uint64_t
Signature · 1 line
2.30.1
#1 lore raw
Quoted 72 lines · Piotr Kubaj

There are couple of issues when building with Clang:
1. vector is a keyword and should not be used in code. I undefined it, but it would probably be better to just change the variable name.
2. vector long is deprecated by Clang and should not be used. I switched here to vector int.
3. Additionally, sys/platform/ppc.h is glibc-dependant and is not available in other libc's. Use the portable method of reading TBR when glibc is not used. Taken from
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/sys/platform/ppc.h

---
 app/test-bbdev/test_bbdev_vector.h            |  3 +
 .../cperf_test_vector_parsing.h               |  3 +
 app/test-crypto-perf/cperf_test_verify.c      |  3 +
 drivers/net/bnxt/bnxt_irq.h                   |  3 +
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 70 +++++++++----------
 drivers/net/ixgbe/ixgbe_ethdev.c              |  3 +
 drivers/net/ixgbe/ixgbe_rxtx.c                |  3 +
 drivers/net/txgbe/txgbe_ethdev.c              |  3 +
 lib/librte_eal/ppc/include/rte_altivec.h      |  3 +
 lib/librte_eal/ppc/include/rte_cycles.h       |  8 +++
 10 files changed, 67 insertions(+), 35 deletions(-)
app/test-bbdev/test_bbdev_vector.h +3 -0
index 4e5dbf5d5..665443fa8 100644
@@ -71,6 +71,9 @@ struct test_bbdev_vector {
 };
 
 /* fills test vector parameters based on test file */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 int
 test_bbdev_vector_read(const char *filename,
                struct test_bbdev_vector *vector);
app/test-crypto-perf/cperf_test_vector_parsing.h +3 -0
index 247b14221..76a86cea5 100644
@@ -18,6 +18,9 @@
  * @return
  *   0 on success, (-1) on error.
  */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 int
 free_test_vector(struct cperf_test_vector *vector, struct cperf_options *opts);
 
app/test-crypto-perf/cperf_test_verify.c +3 -0
index 2939aeaa9..14010a5a2 100644
@@ -91,6 +91,9 @@ cperf_verify_test_constructor(struct rte_mempool *sess_mp,
        return NULL;
 }
 
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 static int
 cperf_verify_op(struct rte_crypto_op *op,
                const struct cperf_options *options,
drivers/net/bnxt/bnxt_irq.h +0 -0
index 7b02f3097..59a9c4224 100644

drivers/net/bnxt/bnxt_irq.h line 13

Quoted 6 lines
drivers/net/bnxt/bnxt_irq.h +3 -0
@@ -8,6 +8,9 @@
 
 struct bnxt_irq {
        rte_intr_callback_fn    handler;
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif

For bnxt PMD, I can submit a patch to rename vector. Thanks for bringing this up.

Quoted 293 lines
drivers/net/bnxt/bnxt_irq.h +0 -0
        unsigned int            vector;
        uint8_t                 requested;
        char                    name[RTE_ETH_NAME_MAX_LEN + 2];
drivers/net/i40e/i40e_rxtx_vec_altivec.c +35 -35
index 1ad74646d..d4230a68b 100644
@@ -27,10 +27,10 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
        struct i40e_rx_entry *rxep = &rxq->sw_ring[rxq->rxrearm_start];
        struct rte_mbuf *mb0, *mb1;
 
-       vector unsigned long hdr_room = (vector unsigned long){
+       vector unsigned int hdr_room = (vector unsigned int){
                                                RTE_PKTMBUF_HEADROOM,
                                                RTE_PKTMBUF_HEADROOM};
-       vector unsigned long dma_addr0, dma_addr1;
+       vector unsigned int dma_addr0, dma_addr1;
 
        rxdp = rxq->rx_ring + rxq->rxrearm_start;
 
@@ -40,11 +40,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
                                 RTE_I40E_RXQ_REARM_THRESH) < 0) {
                if (rxq->rxrearm_nb + RTE_I40E_RXQ_REARM_THRESH >=
                    rxq->nb_rx_desc) {
-                       dma_addr0 = (vector unsigned long){};
+                       dma_addr0 = (vector unsigned int){};
                        for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
                                rxep[i].mbuf = &rxq->fake_mbuf;
                                vec_st(dma_addr0, 0,
-                                      (vector unsigned long *)&rxdp[i].read);
+                                      (vector unsigned int *)&rxdp[i].read);
                        }
                }
                rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -54,7 +54,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 
        /* Initialize the mbufs in vector, process 2 mbufs in one loop */
        for (i = 0; i < RTE_I40E_RXQ_REARM_THRESH; i += 2, rxep += 2) {
-               vector unsigned long vaddr0, vaddr1;
+               vector unsigned int vaddr0, vaddr1;
                uintptr_t p0, p1;
 
                mb0 = rxep[0].mbuf;
@@ -72,8 +72,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
                *(uint64_t *)p1 = rxq->mbuf_initializer;
 
                /* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
-               vaddr0 = vec_ld(0, (vector unsigned long *)&mb0->buf_addr);
-               vaddr1 = vec_ld(0, (vector unsigned long *)&mb1->buf_addr);
+               vaddr0 = vec_ld(0, (vector unsigned int *)&mb0->buf_addr);
+               vaddr1 = vec_ld(0, (vector unsigned int *)&mb1->buf_addr);
 
                /* convert pa to dma_addr hdr/data */
                dma_addr0 = vec_mergel(vaddr0, vaddr0);
@@ -84,8 +84,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
                dma_addr1 = vec_add(dma_addr1, hdr_room);
 
                /* flush desc with pa dma_addr */
-               vec_st(dma_addr0, 0, (vector unsigned long *)&rxdp++->read);
-               vec_st(dma_addr1, 0, (vector unsigned long *)&rxdp++->read);
+               vec_st(dma_addr0, 0, (vector unsigned int *)&rxdp++->read);
+               vec_st(dma_addr1, 0, (vector unsigned int *)&rxdp++->read);
        }
 
        rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -102,7 +102,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 }
 
 static inline void
-desc_to_olflags_v(vector unsigned long descs[4], struct rte_mbuf **rx_pkts)
+desc_to_olflags_v(vector unsigned int descs[4], struct rte_mbuf **rx_pkts)
 {
        vector unsigned int vlan0, vlan1, rss, l3_l4e;
 
@@ -169,14 +169,14 @@ desc_to_olflags_v(vector unsigned long descs[4], struct rte_mbuf **rx_pkts)
 #define PKTLEN_SHIFT     10
 
 static inline void
-desc_to_ptype_v(vector unsigned long descs[4], struct rte_mbuf **rx_pkts,
+desc_to_ptype_v(vector unsigned int descs[4], struct rte_mbuf **rx_pkts,
                uint32_t *ptype_tbl)
 {
-       vector unsigned long ptype0 = vec_mergel(descs[0], descs[1]);
-       vector unsigned long ptype1 = vec_mergel(descs[2], descs[3]);
+       vector unsigned int ptype0 = vec_mergel(descs[0], descs[1]);
+       vector unsigned int ptype1 = vec_mergel(descs[2], descs[3]);
 
-       ptype0 = vec_sr(ptype0, (vector unsigned long){30, 30});
-       ptype1 = vec_sr(ptype1, (vector unsigned long){30, 30});
+       ptype0 = vec_sr(ptype0, (vector unsigned int){30, 30});
+       ptype1 = vec_sr(ptype1, (vector unsigned int){30, 30});
 
        rx_pkts[0]->packet_type =
                ptype_tbl[(*(vector unsigned char *)&ptype0)[0]];
@@ -214,7 +214,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                rxq->crc_len, /* sub crc on data_len */
                0, 0, 0       /* ignore non-length fields */
                };
-       vector unsigned long dd_check, eop_check;
+       vector unsigned int dd_check, eop_check;
 
        /* nb_pkts has to be floor-aligned to RTE_I40E_DESCS_PER_LOOP */
        nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_I40E_DESCS_PER_LOOP);
@@ -240,11 +240,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                return 0;
 
        /* 4 packets DD mask */
-       dd_check = (vector unsigned long){0x0000000100000001ULL,
+       dd_check = (vector unsigned int){0x0000000100000001ULL,
                                          0x0000000100000001ULL};
 
        /* 4 packets EOP mask */
-       eop_check = (vector unsigned long){0x0000000200000002ULL,
+       eop_check = (vector unsigned int){0x0000000200000002ULL,
                                           0x0000000200000002ULL};
 
        /* mask to shuffle from desc. to mbuf */
@@ -274,35 +274,35 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
        for (pos = 0, nb_pkts_recd = 0; pos < nb_pkts;
                        pos += RTE_I40E_DESCS_PER_LOOP,
                        rxdp += RTE_I40E_DESCS_PER_LOOP) {
-               vector unsigned long descs[RTE_I40E_DESCS_PER_LOOP];
+               vector unsigned int descs[RTE_I40E_DESCS_PER_LOOP];
                vector unsigned char pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
                vector unsigned short staterr, sterr_tmp1, sterr_tmp2;
-               vector unsigned long mbp1, mbp2; /* two mbuf pointer
+               vector unsigned int mbp1, mbp2; /* two mbuf pointer
                                                  * in one XMM reg.
                                                  */
 
                /* B.1 load 1 mbuf point */
-               mbp1 = *(vector unsigned long *)&sw_ring[pos];
+               mbp1 = *(vector unsigned int *)&sw_ring[pos];
                /* Read desc statuses backwards to avoid race condition */
                /* A.1 load 4 pkts desc */
-               descs[3] = *(vector unsigned long *)(rxdp + 3);
+               descs[3] = *(vector unsigned int *)(rxdp + 3);
                rte_compiler_barrier();
 
                /* B.2 copy 2 mbuf point into rx_pkts  */
-               *(vector unsigned long *)&rx_pkts[pos] = mbp1;
+               *(vector unsigned int *)&rx_pkts[pos] = mbp1;
 
                /* B.1 load 1 mbuf point */
-               mbp2 = *(vector unsigned long *)&sw_ring[pos + 2];
+               mbp2 = *(vector unsigned int *)&sw_ring[pos + 2];
 
-               descs[2] = *(vector unsigned long *)(rxdp + 2);
+               descs[2] = *(vector unsigned int *)(rxdp + 2);
                rte_compiler_barrier();
                /* B.1 load 2 mbuf point */
-               descs[1] = *(vector unsigned long *)(rxdp + 1);
+               descs[1] = *(vector unsigned int *)(rxdp + 1);
                rte_compiler_barrier();
-               descs[0] = *(vector unsigned long *)(rxdp);
+               descs[0] = *(vector unsigned int *)(rxdp);
 
                /* B.2 copy 2 mbuf point into rx_pkts  */
-               *(vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
+               *(vector unsigned int *)&rx_pkts[pos + 2] =  mbp2;
 
                if (split_packet) {
                        rte_mbuf_prefetch_part2(rx_pkts[pos]);
@@ -324,8 +324,8 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                        (vector unsigned int){0, 0, 0, PKTLEN_SHIFT});
 
                /* merge the now-aligned packet length fields back in */
-               descs[3] = (vector unsigned long)len3;
-               descs[2] = (vector unsigned long)len2;
+               descs[3] = (vector unsigned int)len3;
+               descs[2] = (vector unsigned int)len2;
 
                /* D.1 pkt 3,4 convert format from desc to pktmbuf */
                pkt_mb4 = vec_perm((vector unsigned char)descs[3],
@@ -354,8 +354,8 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                        (vector unsigned int){0, 0, 0, PKTLEN_SHIFT});
 
                /* merge the now-aligned packet length fields back in */
-               descs[1] = (vector unsigned long)len1;
-               descs[0] = (vector unsigned long)len0;
+               descs[1] = (vector unsigned int)len1;
+               descs[0] = (vector unsigned int)len0;
 
                /* D.1 pkt 1,2 convert format from desc to pktmbuf */
                pkt_mb2 = vec_perm((vector unsigned char)descs[1],
@@ -432,7 +432,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 
                /* C.4 calc avaialbe number of desc */
                var = __builtin_popcountll((vec_ld(0,
-                       (vector unsigned long *)&staterr)[0]));
+                       (vector unsigned int *)&staterr)[0]));
                nb_pkts_recd += var;
                if (likely(var != RTE_I40E_DESCS_PER_LOOP))
                        break;
@@ -533,9 +533,9 @@ vtx1(volatile struct i40e_tx_desc *txdp,
                ((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
                ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
 
-       vector unsigned long descriptor = (vector unsigned long){
+       vector unsigned int descriptor = (vector unsigned int){
                pkt->buf_iova + pkt->data_off, high_qw};
-       *(vector unsigned long *)txdp = descriptor;
+       *(vector unsigned int *)txdp = descriptor;
 }
 
 static inline void
drivers/net/ixgbe/ixgbe_ethdev.c +3 -0
index 761a0f26b..59ffe92ea 100644
@@ -5597,6 +5597,9 @@ ixgbe_vt_check(struct ixgbe_hw *hw)
 static uint32_t
 ixgbe_uta_vector(struct ixgbe_hw *hw, struct rte_ether_addr *uc_addr)
 {
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
        uint32_t vector = 0;
 
        switch (hw->mac.mc_filter_type) {
drivers/net/ixgbe/ixgbe_rxtx.c +3 -0
index 7d23bab29..88d71131e 100644
@@ -4740,6 +4740,9 @@ ixgbe_get_rscctl_maxdesc(struct rte_mempool *pool)
  * @vector the MSIX vector for this queue
  * @type RX/TX/MISC
  */
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
 static void
 ixgbe_set_ivar(struct rte_eth_dev *dev, u8 entry, u8 vector, s8 type)
 {
drivers/net/txgbe/txgbe_ethdev.c +3 -0
index 90137d0ce..2747246a1 100644
@@ -3382,6 +3382,9 @@ txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 static uint32_t
 txgbe_uta_vector(struct txgbe_hw *hw, struct rte_ether_addr *uc_addr)
 {
+#if defined(__clang__) && defined(__powerpc64__)
+#undef vector
+#endif
        uint32_t vector = 0;
 
        switch (hw->mac.mc_filter_type) {
lib/librte_eal/ppc/include/rte_altivec.h +3 -0
index 1551a9454..3fcc819c1 100644
@@ -7,6 +7,9 @@
 #define _RTE_ALTIVEC_H_
 
 /* To include altivec.h, GCC version must be >= 4.8 */
+#ifdef __clang__
+#define vector __vector
+#endif
 #include <altivec.h>
 
 /*
lib/librte_eal/ppc/include/rte_cycles.h +8 -1
index 5585f9273..9925d1d0d 100644
@@ -10,7 +10,9 @@
 extern "C" {
 #endif
 
+#ifdef __GLIBC__
 #include <sys/platform/ppc.h>
+#endif
 
 #include "generic/rte_cycles.h"
 
@@ -26,7 +28,13 @@ extern "C" {
 static inline uint64_t
 rte_rdtsc(void)
 {
+#ifdef __GLIBC__
        return __ppc_get_timebase();
+#else
+       uint64_t __tb;
+       __asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
+       return __tb;
+#endif
 }
 
 static inline uint64_t
--

2.30.1

#2 lore raw
In reply to Piotr Kubaj
Quoted 10 lines · Piotr Kubaj

There are couple of issues when building with Clang:
1. vector is a keyword and should not be used in code. I undefined it, but it would probably be better to just change the variable name.
2. vector long is deprecated by Clang and should not be used. I switched here to vector int.
3. Additionally, sys/platform/ppc.h is glibc-dependant and is not available in other libc's. Use the portable method of reading TBR when glibc is not used. Taken from
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/sys/platform/ppc.h

Quoted 2 lines

---

Build with patch on my POWER9 system with RHEL 8.3 (gcc 8.3.1 20191121) generates the following errors:

ninja -C build
ninja: Entering directory `build'
[1221/2455] Compiling C object 'drivers/a715181@@tmp_rte_net_i40e@sta/net_i40e_i40e_rxtx_vec_altivec.c.o'. ../drivers/net/i40e/i40e_rxtx_vec_altivec.c: In function ‘_recv_raw_pkts_vec’:
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:243:35: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘4294967297’ to ‘1’ [-Woverflow]
dd_check = (vector unsigned int){0x0000000100000001ULL,

                                   ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:244:8: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘4294967297’ to ‘1’ [-Woverflow]
        0x0000000100000001ULL};
        ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:247:36: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘8589934594’ to ‘2’ [-Woverflow]
  eop_check = (vector unsigned int){0x0000000200000002ULL,
                                    ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:248:9: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘8589934594’ to ‘2’ [-Woverflow]
         0x0000000200000002ULL};
         ^~~~~~~~~~~~~~~~~~~~~

[1736/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o'.
In file included from ../drivers/event/dsw/dsw_evdev.c:7:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

  return __ppc_get_timebase();
         ^~~~~~~~~~~~~~~~~~
         __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs]
[1862/2455] Compiling C object 'app/a172ced@@dpdk-testpmd@exe/test-pmd_ieee1588fwd.c.o'.
In file included from ../app/test-pmd/ieee1588fwd.c:6:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

  return __ppc_get_timebase();
         ^~~~~~~~~~~~~~~~~~
         __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs]
[2330/2455] Linking target drivers/librte_event_dsw.so.21.2.
FAILED: drivers/librte_event_dsw.so.21.2
cc -o drivers/librte_event_dsw.so.21.2 'drivers/a715181@@rte_event_dsw@sha/meson-generated_.._rte_event_dsw.pmd.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_event.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_xstats.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,librte_event_dsw.so.21 -Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_eventdev.so.21.2 lib/librte_eal.so.21.2 lib/librte_kvargs.so.21.2 lib/librte_telemetry.so.21.2 lib/librte_ring.so.21.2 lib/librte_ethdev.so.21.2 lib/librte_net.so.21.2 lib/librte_mbuf.so.21.2 lib/librte_mempool.so.21.2 lib/librte_meter.so.21.2 lib/librte_hash.so.21.2 lib/librte_rcu.so.21.2 lib/librte_timer.so.21.2 lib/librte_cryptodev.so.21.2 drivers/librte_bus_vdev.so.21.2 -Wl,--end-group -Wl,--version-script=/home/drc/src/dpdk/drivers/event/dsw/version.map '-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/' -Wl,-rpath-link,/home/drc/src/dpdk/build/lib:/home/drc/src/dpdk/build/drivers drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o: In function `dsw_start':
dsw_evdev.c:(.text+0x1078): undefined reference to `__ppc_get_timebase'
collect2: error: ld returned 1 exit status
[2359/2455] Compiling C object 'app/test/3062f5d@@dpdk-test@exe/test_trace_perf.c.o'.
In file included from ../app/test/test_trace_perf.c:5:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

  return __ppc_get_timebase();
         ^~~~~~~~~~~~~~~~~~
         __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs] [2366/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_octeontx2@sta/event_octeontx2_otx2_worker_dual.c.o'.
ninja: build stopped: subcommand failed.

#3 lore raw

Thank you for your input.

I did not have Linux installed on my box previously and assumed __GLIBC__ is always defined when glibc i used.

I just tested that this patch works on both Linux (Fedora 33) and FreeBSD (13.0-RC3 powerpc64le).

Quoted 109 lines · David Christensen
Quoted 10 lines · Piotr Kubaj

There are couple of issues when building with Clang:
1. vector is a keyword and should not be used in code. I undefined it, but it would probably be better to just change the variable name.
2. vector long is deprecated by Clang and should not be used. I switched here to vector int.
3. Additionally, sys/platform/ppc.h is glibc-dependant and is not available in other libc's. Use the portable method of reading TBR when glibc is not used. Taken from
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/sys/platform/ppc.h

Quoted 2 lines

---

Build with patch on my POWER9 system with RHEL 8.3 (gcc 8.3.1 20191121) generates the following errors:

ninja -C build
ninja: Entering directory `build'
[1221/2455] Compiling C object 'drivers/a715181@@tmp_rte_net_i40e@sta/net_i40e_i40e_rxtx_vec_altivec.c.o'. ../drivers/net/i40e/i40e_rxtx_vec_altivec.c: In function ‘_recv_raw_pkts_vec’:
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:243:35: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘4294967297’ to ‘1’ [-Woverflow]
dd_check = (vector unsigned int){0x0000000100000001ULL,

                                    ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:244:8: warning: conversion 
from ‘long long unsigned int’ to ‘unsigned int’ changes value from 
‘4294967297’ to ‘1’ [-Woverflow]
         0x0000000100000001ULL};
         ^~~~~~~~~~~~~~~~~~~~~

../drivers/net/i40e/i40e_rxtx_vec_altivec.c:247:36: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘8589934594’ to ‘2’ [-Woverflow]
eop_check = (vector unsigned int){0x0000000200000002ULL,

                                     ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:248:9: warning: conversion 
from ‘long long unsigned int’ to ‘unsigned int’ changes value from 
‘8589934594’ to ‘2’ [-Woverflow]
          0x0000000200000002ULL};
          ^~~~~~~~~~~~~~~~~~~~~

[1736/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o'. In file included from ../drivers/event/dsw/dsw_evdev.c:7:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs] [1862/2455] Compiling C object 'app/a172ced@@dpdk-testpmd@exe/test-pmd_ieee1588fwd.c.o'.
In file included from ../app/test-pmd/ieee1588fwd.c:6:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs] [2330/2455] Linking target drivers/librte_event_dsw.so.21.2.
FAILED: drivers/librte_event_dsw.so.21.2
cc -o drivers/librte_event_dsw.so.21.2 'drivers/a715181@@rte_event_dsw@sha/meson-generated_.._rte_event_dsw.pmd.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_event.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_xstats.c.o'

(quoted diff) +0 -3
-Wl,--no-undefined -Wl,--as-needed -Wl,-O1 -shared -fPIC 
-Wl,--start-group -Wl,-soname,librte_event_dsw.so.21 -Wl,--no-as-needed 
-pthread -lm -ldl -lnuma lib/librte_eventdev.so.21.2 

lib/librte_eal.so.21.2 lib/librte_kvargs.so.21.2 lib/librte_telemetry.so.21.2 lib/librte_ring.so.21.2 lib/librte_ethdev.so.21.2 lib/librte_net.so.21.2 lib/librte_mbuf.so.21.2 lib/librte_mempool.so.21.2 lib/librte_meter.so.21.2 lib/librte_hash.so.21.2 lib/librte_rcu.so.21.2 lib/librte_timer.so.21.2 lib/librte_cryptodev.so.21.2 drivers/librte_bus_vdev.so.21.2

(quoted diff) +0 -2
-Wl,--end-group 
-Wl,--version-script=/home/drc/src/dpdk/drivers/event/dsw/version.map 

'-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/' -Wl,-rpath-link,/home/drc/src/dpdk/build/lib:/home/drc/src/dpdk/build/drivers drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o: In function `dsw_start':
dsw_evdev.c:(.text+0x1078): undefined reference to `__ppc_get_timebase'
collect2: error: ld returned 1 exit status
[2359/2455] Compiling C object 'app/test/3062f5d@@dpdk-test@exe/test_trace_perf.c.o'.
In file included from ../app/test/test_trace_perf.c:5:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs]
[2366/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_octeontx2@sta/event_octeontx2_otx2_worker_dual.c.o'.
ninja: build stopped: subcommand failed.

#4 lore raw
In reply to David Christensen

Looks like I forgot to commit the change that includes headers for sysctlbyname().

Patch attached.

Quoted 109 lines · David Christensen
Quoted 10 lines · Piotr Kubaj

There are couple of issues when building with Clang:
1. vector is a keyword and should not be used in code. I undefined it, but it would probably be better to just change the variable name.
2. vector long is deprecated by Clang and should not be used. I switched here to vector int.
3. Additionally, sys/platform/ppc.h is glibc-dependant and is not available in other libc's. Use the portable method of reading TBR when glibc is not used. Taken from
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/sys/platform/ppc.h

Quoted 2 lines

---

Build with patch on my POWER9 system with RHEL 8.3 (gcc 8.3.1 20191121) generates the following errors:

ninja -C build
ninja: Entering directory `build'
[1221/2455] Compiling C object 'drivers/a715181@@tmp_rte_net_i40e@sta/net_i40e_i40e_rxtx_vec_altivec.c.o'. ../drivers/net/i40e/i40e_rxtx_vec_altivec.c: In function ‘_recv_raw_pkts_vec’:
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:243:35: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘4294967297’ to ‘1’ [-Woverflow]
dd_check = (vector unsigned int){0x0000000100000001ULL,

                                    ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:244:8: warning: conversion 
from ‘long long unsigned int’ to ‘unsigned int’ changes value from 
‘4294967297’ to ‘1’ [-Woverflow]
         0x0000000100000001ULL};
         ^~~~~~~~~~~~~~~~~~~~~

../drivers/net/i40e/i40e_rxtx_vec_altivec.c:247:36: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘8589934594’ to ‘2’ [-Woverflow]
eop_check = (vector unsigned int){0x0000000200000002ULL,

                                     ^~~~~~~~~~~~~~~~~~~~~
../drivers/net/i40e/i40e_rxtx_vec_altivec.c:248:9: warning: conversion 
from ‘long long unsigned int’ to ‘unsigned int’ changes value from 
‘8589934594’ to ‘2’ [-Woverflow]
          0x0000000200000002ULL};
          ^~~~~~~~~~~~~~~~~~~~~

[1736/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o'. In file included from ../drivers/event/dsw/dsw_evdev.c:7:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs] [1862/2455] Compiling C object 'app/a172ced@@dpdk-testpmd@exe/test-pmd_ieee1588fwd.c.o'.
In file included from ../app/test-pmd/ieee1588fwd.c:6:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs] [2330/2455] Linking target drivers/librte_event_dsw.so.21.2.
FAILED: drivers/librte_event_dsw.so.21.2
cc -o drivers/librte_event_dsw.so.21.2 'drivers/a715181@@rte_event_dsw@sha/meson-generated_.._rte_event_dsw.pmd.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_event.c.o' 'drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_xstats.c.o'

(quoted diff) +0 -3
-Wl,--no-undefined -Wl,--as-needed -Wl,-O1 -shared -fPIC 
-Wl,--start-group -Wl,-soname,librte_event_dsw.so.21 -Wl,--no-as-needed 
-pthread -lm -ldl -lnuma lib/librte_eventdev.so.21.2 

lib/librte_eal.so.21.2 lib/librte_kvargs.so.21.2 lib/librte_telemetry.so.21.2 lib/librte_ring.so.21.2 lib/librte_ethdev.so.21.2 lib/librte_net.so.21.2 lib/librte_mbuf.so.21.2 lib/librte_mempool.so.21.2 lib/librte_meter.so.21.2 lib/librte_hash.so.21.2 lib/librte_rcu.so.21.2 lib/librte_timer.so.21.2 lib/librte_cryptodev.so.21.2 drivers/librte_bus_vdev.so.21.2

(quoted diff) +0 -2
-Wl,--end-group 
-Wl,--version-script=/home/drc/src/dpdk/drivers/event/dsw/version.map 

'-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/' -Wl,-rpath-link,/home/drc/src/dpdk/build/lib:/home/drc/src/dpdk/build/drivers drivers/a715181@@tmp_rte_event_dsw@sta/event_dsw_dsw_evdev.c.o: In function `dsw_start':
dsw_evdev.c:(.text+0x1078): undefined reference to `__ppc_get_timebase'
collect2: error: ld returned 1 exit status
[2359/2455] Compiling C object 'app/test/3062f5d@@dpdk-test@exe/test_trace_perf.c.o'.
In file included from ../app/test/test_trace_perf.c:5:
../lib/librte_eal/ppc/include/rte_cycles.h: In function ‘rte_rdtsc’:
../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: implicit declaration of function ‘__ppc_get_timebase’; did you mean ‘__builtin_ppc_get_timebase’? [-Wimplicit-function-declaration]

   return __ppc_get_timebase();
          ^~~~~~~~~~~~~~~~~~
          __builtin_ppc_get_timebase

../lib/librte_eal/ppc/include/rte_cycles.h:32:9: warning: nested extern declaration of ‘__ppc_get_timebase’ [-Wnested-externs]
[2366/2455] Compiling C object 'drivers/a715181@@tmp_rte_event_octeontx2@sta/event_octeontx2_otx2_worker_dual.c.o'.
ninja: build stopped: subcommand failed.

#5 lore raw
Quoted 4 lines · Piotr Kubaj

Looks like I forgot to commit the change that includes headers for sysctlbyname().

Patch attached.

The mailing list drops attachments.
Please submit a v2.
Thanks.

Signature · 1 line
David Marchand

A message that is not in the archive (sent off-list or not yet received): YJMes69UJORrjT1G@KGPE-D16

Reviewed-by
#7 lore raw
Quoted 80 lines · Piotr Kubaj
lib/librte_eal/ppc/include/rte_altivec.h +3 -0
index 1551a9454..3fcc819c1 100644
@@ -7,6 +7,9 @@
  #define_RTE_ALTIVEC_H_
 
  /* To include altivec.h, GCC version must be >= 4.8 */
+#ifdef __clang__
+#define vector __vector
+#endif
  #include <altivec.h>
 
  /*
lib/librte_eal/ppc/include/rte_cycles.h +12 -0
index 5585f9273..a8307ceaf 100644
@@ -10,7 +10,13 @@
  extern "C" {
  #endif
 
+#ifdef linux
+#include <features.h>
+#endif
+
+#ifdef __GLIBC__
  #include <sys/platform/ppc.h>
+#endif
 
  #include "generic/rte_cycles.h"
 
@@ -26,7 +32,13 @@ extern "C" {
  static inline uint64_t
  rte_rdtsc(void)
  {
+#ifdef __GLIBC__
         return __ppc_get_timebase();
+#else
+       uint64_t __tb;
+       __asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
+       return __tb;
+#endif
  }
 
  static inline uint64_t
lib/librte_eal/ppc/rte_cycles.c +16 -1
index 3180adb0f..48545c4d6 100644
@@ -2,12 +2,28 @@
   * Copyright (C) IBM Corporation 2019.
   */
 
+#ifdef linux
+#include <features.h>
+#elif defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
+#ifdef __GLIBC__
  #include <sys/platform/ppc.h>
+#endif
 
  #include "eal_private.h"
 
  uint64_t
  get_tsc_freq_arch(void)
  {
+#ifdef __GLIBC__
         return __ppc_get_timebase_freq();
+#elif defined(__FreeBSD__)
+       uint64_t freq;
+       size_t length = sizeof(freq);
+       sysctlbyname("kern.timecounter.tc.timebase.frequency", &freq, &length, NULL, 0);
+       return freq;
+#endif
  }
--
Quoted 1 line

2.31.0

#8 lore raw
In reply to a message not in the archive
Quoted 3 lines · Piotr Kubaj
  lib/librte_eal/ppc/include/rte_altivec.h |  3 +++
  lib/librte_eal/ppc/include/rte_cycles.h  | 12 ++++++++++++
  lib/librte_eal/ppc/rte_cycles.c          | 16 ++++++++++++++++

Directory path "librte_eal" has been changed to "eal" so a v3 patch is likely needed.

Dave

A message that is not in the archive (sent off-list or not yet received): YJXae53gvmmXwY4n@KGPE-D16

#10 lore raw
Quoted 10 lines · Piotr Kubaj

Including below.
From 87ad59cc894b227444936fb6a7968932abdc460f Mon Sep 17 00:00:00 2001
From: Piotr Kubaj <[email protected]>
Date: Tue, 23 Mar 2021 00:40:47 +0100
Subject: [PATCH] ppc64le: fix build without glibc

__ppc_get_timebase() is only present when glibc is used.

I can't find this new revision of the patch in patchwork and I am not sure why. Please, send this patch like you did for your v1, but properly versioned v3 (if I counted correctly).
Thanks.

Signature · 1 line
David Marchand