From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE2F2A0564; Thu, 11 Mar 2021 21:58:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BFA74014D; Thu, 11 Mar 2021 21:58:23 +0100 (CET) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by mails.dpdk.org (Postfix) with ESMTP id 2B24840141 for ; Thu, 11 Mar 2021 21:58:22 +0100 (CET) Received: by mail-qk1-f172.google.com with SMTP id 130so22126716qkh.11 for ; Thu, 11 Mar 2021 12:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NRDs8NQbzCfdKUsoGExRUI9tdyF+IF6HNWTM18kDWEw=; b=ErhPzqiMdj1tA0qcfV5kUswXc6Z40bH+mtExBtuMNl5ECwefDkaSYyAx0mwBsewvW3 yEYJSJd8Z1qj9tvPWIXLjSkDGyzmVkVadqdevGnaHoCBxIpeOKqvmRfw0q9pKWsRnTvi xZwMlHSXEvDogA692EDaPIA1we2ZGQPuCxSA8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NRDs8NQbzCfdKUsoGExRUI9tdyF+IF6HNWTM18kDWEw=; b=ZPkapNFs4M+F6Lh8sLSRdO7RvIxmCF1zqOnkAOc4n2ofUSNHzOdT93oebb3QOwZRTO Zc1OEQuQrs/bzrkV/MC4Ew83J9OTSaVKYnWBnAliE9D8fBi/twUNLs6fQFkZcar07s38 jRzUNFufvPzvfLgFWV7HZxwY8Sjn0HX7GeZdX7aR2j3KGI69CXS1+7FDpsq3vSOZTeVR NDETSpdpD7s6/9wxtRETHIWlPlJ4oX6rzUfN/LPgdXZQL1hKpojXT2EKGfqeGF70sErU onfHFEwdXjhYr+J35MQS8pPEm6FSbRRcqhql1lQweQKjOpZwx4URPwOCTlEU637tE1Cd FhVQ== X-Gm-Message-State: AOAM530aRTEa444oPBbsGZFY+2aEv+Jsu5jOgxknHOLX/tqY2yiKBkG7 1/EIa7yyJBd/E2lxgE8KbxbEdeb6xiHzZc/tjkHHig== X-Google-Smtp-Source: ABdhPJwEguz5BqfZGNpMXVoJDqO/079UQrNo5NcGgeTLZg3Uc6xMiLTDPAE9BpKmt5n0uXTcRjfrCVe4NNLetsaz8Nk= X-Received: by 2002:a37:7985:: with SMTP id u127mr9633165qkc.333.1615496301161; Thu, 11 Mar 2021 12:58:21 -0800 (PST) MIME-Version: 1.0 References: <20210311161140.70534-1-pkubaj@FreeBSD.org> In-Reply-To: <20210311161140.70534-1-pkubaj@FreeBSD.org> From: Ajit Khaparde Date: Thu, 11 Mar 2021 12:58:04 -0800 Message-ID: To: Piotr Kubaj Cc: Nicolas Chautru , declan.doherty@intel.com, Somnath Kotur , Beilei Xing , Jeff Guo , Haiyue Wang , Jiawen Wu , Jian Wang , David Christensen , dpdk-dev Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000003410da05bd490ba1" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-dev] [PATCH] ppc64le: fix build with Clang and without glibc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" --0000000000003410da05bd490ba1 Content-Type: text/plain; charset="UTF-8" On Thu, Mar 11, 2021 at 8:11 AM Piotr Kubaj wrote: > > 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 > --- > 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 For bnxt PMD, I can submit a patch to rename vector. Thanks for bringing this up. > 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 > > /* > 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 > +#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 > --0000000000003410da05bd490ba1--