DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ppc64le: fix build with Clang and without glibc
@ 2021-03-11 16:11 Piotr Kubaj
  2021-03-11 20:58 ` Ajit Khaparde
  2021-03-15 19:48 ` David Christensen
  0 siblings, 2 replies; 9+ messages in thread
From: Piotr Kubaj @ 2021-03-11 16:11 UTC (permalink / raw)
  To: nicolas.chautru, declan.doherty, ajit.khaparde, somnath.kotur,
	beilei.xing, jia.guo, haiyue.wang, jiawenwu, jianwang, drc
  Cc: dev, 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

Signed-off-by: Piotr Kubaj <pkubaj@FreeBSD.org>
---
 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(-)

diff --git a/app/test-bbdev/test_bbdev_vector.h b/app/test-bbdev/test_bbdev_vector.h
index 4e5dbf5d5..665443fa8 100644
--- a/app/test-bbdev/test_bbdev_vector.h
+++ b/app/test-bbdev/test_bbdev_vector.h
@@ -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);
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.h b/app/test-crypto-perf/cperf_test_vector_parsing.h
index 247b14221..76a86cea5 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.h
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.h
@@ -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);
 
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 2939aeaa9..14010a5a2 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -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,
diff --git a/drivers/net/bnxt/bnxt_irq.h b/drivers/net/bnxt/bnxt_irq.h
index 7b02f3097..59a9c4224 100644
--- a/drivers/net/bnxt/bnxt_irq.h
+++ b/drivers/net/bnxt/bnxt_irq.h
@@ -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];
diff --git a/drivers/net/i40e/i40e_rxtx_vec_altivec.c b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
index 1ad74646d..d4230a68b 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_altivec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
@@ -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
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 761a0f26b..59ffe92ea 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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) {
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 7d23bab29..88d71131e 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -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)
 {
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 90137d0ce..2747246a1 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -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) {
diff --git a/lib/librte_eal/ppc/include/rte_altivec.h b/lib/librte_eal/ppc/include/rte_altivec.h
index 1551a9454..3fcc819c1 100644
--- a/lib/librte_eal/ppc/include/rte_altivec.h
+++ b/lib/librte_eal/ppc/include/rte_altivec.h
@@ -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>
 
 /*
diff --git a/lib/librte_eal/ppc/include/rte_cycles.h b/lib/librte_eal/ppc/include/rte_cycles.h
index 5585f9273..9925d1d0d 100644
--- a/lib/librte_eal/ppc/include/rte_cycles.h
+++ b/lib/librte_eal/ppc/include/rte_cycles.h
@@ -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


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

end of thread, other threads:[~2021-05-11 14:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 16:11 [dpdk-dev] [PATCH] ppc64le: fix build with Clang and without glibc Piotr Kubaj
2021-03-11 20:58 ` Ajit Khaparde
2021-03-15 19:48 ` David Christensen
2021-03-22 20:14   ` Piotr Kubaj
2021-03-22 23:42   ` Piotr Kubaj
2021-05-05 14:58     ` David Marchand
     [not found]       ` <YJMes69UJORrjT1G@KGPE-D16>
2021-05-07 20:28         ` David Christensen
2021-05-07 20:30         ` David Christensen
     [not found]           ` <YJXae53gvmmXwY4n@KGPE-D16>
2021-05-11 14:02             ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).