From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id EE8601B900 for ; Wed, 19 Dec 2018 17:30:26 +0100 (CET) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id wBJGUNGs024432; Wed, 19 Dec 2018 08:30:24 -0800 From: Rahul Lakkireddy To: dev@dpdk.org Cc: satishr@chelsio.com, indranil@chelsio.com Date: Wed, 19 Dec 2018 21:58:25 +0530 Message-Id: X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 3/4] net/cxgbe: only define symbols when not available X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2018 16:30:27 -0000 Define symbols only when they are not available. This fixes following types of issues reported by Intel C++ compiler in Windows build. C:\> cxgbe_compat.h(154): warning #47: incompatible redefinition of macro "min" #define min(a, b) RTE_MIN(a, b) ^ C:\> t4_hw.c(338): warning #266: function "bzero" declared implicitly bzero(p, 0, size); ^ C:\> t4_hw.c(5337): warning #266: function "htonl" declared implicitly rvc.op_to_viid = htonl(V_FW_CMD_OP(FW_RSS_VI_CONFIG_CMD) | ^ C:\> sge.c(361): error : expected an expression struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, fl); ^ C:\> sge.c(1350): error : identifier "caddr_t" is undefined static void inline_tx_mbuf(const struct sge_txq *q, caddr_t from, ^ [...] Build Environment: 1. Target OS: Microsoft Windows Server 2016 2. Compiler: Intel C++ Compiler from Intel Parallel Studio XE 2019 [1] 3. Development Tools: 3.1 Microsoft Visual Studio 2017 Professional 3.2 Windows Software Development Kit (SDK) v10.0.17763 3.3 Windows Driver Kit (WDK) v10.0.17763 [1] https://software.intel.com/en-us/parallel-studio-xe Signed-off-by: Rahul Lakkireddy --- v2: - Add more info in commit message regarding Windows build. drivers/net/cxgbe/base/t4_hw.c | 4 ++-- drivers/net/cxgbe/base/t4vf_hw.c | 2 +- drivers/net/cxgbe/cxgbe_compat.h | 29 ++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c index 701e0b1fe..796e2f7f8 100644 --- a/drivers/net/cxgbe/base/t4_hw.c +++ b/drivers/net/cxgbe/base/t4_hw.c @@ -246,7 +246,7 @@ static void get_mbox_rpl(struct adapter *adap, __be64 *rpl, int nflit, u32 mbox_addr) { for ( ; nflit; nflit--, mbox_addr += 8) - *rpl++ = htobe64(t4_read_reg64(adap, mbox_addr)); + *rpl++ = cpu_to_be64(t4_read_reg64(adap, mbox_addr)); } /* @@ -335,7 +335,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, return -EINVAL; } - bzero(p, size); + memset(p, 0, size); memcpy(p, (const __be64 *)cmd, size); /* diff --git a/drivers/net/cxgbe/base/t4vf_hw.c b/drivers/net/cxgbe/base/t4vf_hw.c index d96456bbe..649bacfb2 100644 --- a/drivers/net/cxgbe/base/t4vf_hw.c +++ b/drivers/net/cxgbe/base/t4vf_hw.c @@ -44,7 +44,7 @@ static void get_mbox_rpl(struct adapter *adap, __be64 *rpl, int nflit, u32 mbox_addr) { for ( ; nflit; nflit--, mbox_addr += 8) - *rpl++ = htobe64(t4_read_reg64(adap, mbox_addr)); + *rpl++ = cpu_to_be64(t4_read_reg64(adap, mbox_addr)); } /** diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h index ce4662d54..686ca6e0a 100644 --- a/drivers/net/cxgbe/cxgbe_compat.h +++ b/drivers/net/cxgbe/cxgbe_compat.h @@ -18,6 +18,7 @@ #include #include #include +#include #define dev_printf(level, fmt, ...) \ RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ##__VA_ARGS__) @@ -149,18 +150,24 @@ typedef uint64_t dma_addr_t; #define false 0 #define true 1 +#ifndef min #define min(a, b) RTE_MIN(a, b) +#endif + +#ifndef max #define max(a, b) RTE_MAX(a, b) +#endif /* * round up val _p to a power of 2 size _s */ #define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1)) -#undef container_of +#ifndef container_of #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member)(*__mptr) = (ptr); \ (type *)((char *)__mptr - offsetof(type, member)); }) +#endif #define ARRAY_SIZE(arr) RTE_DIM(arr) @@ -173,6 +180,26 @@ typedef uint64_t dma_addr_t; #define be64_to_cpu(o) rte_be_to_cpu_64(o) #define le32_to_cpu(o) rte_le_to_cpu_32(o) +#ifndef ntohs +#define ntohs(o) be16_to_cpu(o) +#endif + +#ifndef ntohl +#define ntohl(o) be32_to_cpu(o) +#endif + +#ifndef htons +#define htons(o) cpu_to_be16(o) +#endif + +#ifndef htonl +#define htonl(o) cpu_to_be32(o) +#endif + +#ifndef caddr_t +typedef char *caddr_t; +#endif + #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define DELAY(x) rte_delay_us(x) #define udelay(x) DELAY(x) -- 2.18.0