From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 05/13] net/nfp: use generic macros for array size and to set bits
Date: Mon, 10 Apr 2023 19:00:07 +0800 [thread overview]
Message-ID: <20230410110015.2973660-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230410110015.2973660-1-chaoyong.he@corigine.com>
Instead of using NFP specific macros for array size and to set bits use
the generic ones provided by DPDK.
By moving some include directives for system header files directly to
the source files that depend on them, the header file nfp_platform.h
defining the NFP specific macros can be removed.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_cpp_bridge.c | 5 +--
drivers/net/nfp/nfp_rxtx.c | 1 -
drivers/net/nfp/nfp_rxtx.h | 10 +++---
.../net/nfp/nfpcore/nfp-common/nfp_platform.h | 29 ----------------
.../net/nfp/nfpcore/nfp-common/nfp_resid.h | 4 ---
drivers/net/nfp/nfpcore/nfp_cpp.h | 1 -
drivers/net/nfp/nfpcore/nfp_cppcore.c | 3 +-
drivers/net/nfp/nfpcore/nfp_hwinfo.h | 2 +-
drivers/net/nfp/nfpcore/nfp_nffw.c | 4 +--
drivers/net/nfp/nfpcore/nfp_nffw.h | 1 -
drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
drivers/net/nfp/nfpcore/nfp_nsp.h | 12 +++----
drivers/net/nfp/nfpcore/nfp_nsp_cmds.c | 2 +-
drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 34 +++++++++----------
drivers/net/nfp/nfpcore/nfp_target.h | 1 -
15 files changed, 38 insertions(+), 73 deletions(-)
delete mode 100644 drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c
index 8e29cfb6d3..78a680453b 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.c
+++ b/drivers/net/nfp/nfp_cpp_bridge.c
@@ -13,6 +13,9 @@
* Netronome vNIC DPDK Poll-Mode Driver: CPP Bridge
*/
+#include <unistd.h>
+#include <sys/ioctl.h>
+
#include <rte_service_component.h>
#include "nfpcore/nfp_cpp.h"
@@ -22,8 +25,6 @@
#include "nfp_logs.h"
#include "nfp_cpp_bridge.h"
-#include <sys/ioctl.h>
-
/* Prototypes */
static int nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp);
static int nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp);
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index bc73026825..16a124fd7d 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -22,7 +22,6 @@
#include "nfp_logs.h"
#include "nfpcore/nfp_mip.h"
#include "nfpcore/nfp_rtsym.h"
-#include "nfpcore/nfp-common/nfp_platform.h"
static int
nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq)
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 5e651518ed..f016bf732c 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -120,11 +120,11 @@ struct nfp_meta_parsed {
#define NFDK_DESC_TX_TYPE_TSO 2
#define NFDK_DESC_TX_TYPE_SIMPLE 8
#define NFDK_DESC_TX_TYPE_GATHER 1
-#define NFDK_DESC_TX_EOP BIT(14)
-#define NFDK_DESC_TX_CHAIN_META BIT(3)
-#define NFDK_DESC_TX_ENCAP BIT(2)
-#define NFDK_DESC_TX_L4_CSUM BIT(1)
-#define NFDK_DESC_TX_L3_CSUM BIT(0)
+#define NFDK_DESC_TX_EOP RTE_BIT32(14)
+#define NFDK_DESC_TX_CHAIN_META RTE_BIT32(3)
+#define NFDK_DESC_TX_ENCAP RTE_BIT32(2)
+#define NFDK_DESC_TX_L4_CSUM RTE_BIT32(1)
+#define NFDK_DESC_TX_L3_CSUM RTE_BIT32(0)
#define NFDK_TX_MAX_DATA_PER_DESC 0x00004000
#define NFDK_TX_DESC_GATHER_MAX 17
diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
deleted file mode 100644
index 9fa52074f0..0000000000
--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Netronome Systems, Inc.
- * All rights reserved.
- */
-
-#ifndef __NFP_PLATFORM_H__
-#define __NFP_PLATFORM_H__
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <inttypes.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <errno.h>
-
-#ifndef BIT_ULL
-#define BIT(x) (1 << (x))
-#define BIT_ULL(x) (1ULL << (x))
-#endif
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) RTE_DIM(x)
-#endif
-
-#endif /* __NFP_PLATFORM_H__ */
diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h
index ac2bf0335d..5445d4dac8 100644
--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h
+++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h
@@ -11,10 +11,6 @@
#define _NFP_RESID_NO_C_FUNC
#endif
-#ifndef _NFP_RESID_NO_C_FUNC
-#include "nfp_platform.h"
-#endif
-
/*
* NFP Chip Architectures
*
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h
index 437dcdf942..d657a7c164 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h
@@ -8,7 +8,6 @@
#include <ethdev_pci.h>
-#include "nfp-common/nfp_platform.h"
#include "nfp-common/nfp_resid.h"
struct nfp_cpp_mutex;
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index 97cf16c801..681ec93b96 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <sys/types.h>
#include <rte_byteorder.h>
@@ -565,7 +566,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)
uint32_t xpbaddr;
size_t tgt;
- for (tgt = 0; tgt < ARRAY_SIZE(cpp->imb_cat_table); tgt++) {
+ for (tgt = 0; tgt < RTE_DIM(cpp->imb_cat_table); tgt++) {
/* Hardcoded XPB IMB Base, island 0 */
xpbaddr = 0x000a0000 + (tgt * 4);
err = nfp_xpb_readl(cpp, xpbaddr,
diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.h b/drivers/net/nfp/nfpcore/nfp_hwinfo.h
index ccc616321f..a3da7512db 100644
--- a/drivers/net/nfp/nfpcore/nfp_hwinfo.h
+++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.h
@@ -63,7 +63,7 @@
#define NFP_HWINFO_VERSION_1 ('H' << 24 | 'I' << 16 | 1 << 8 | 0 << 1 | 0)
#define NFP_HWINFO_VERSION_2 ('H' << 24 | 'I' << 16 | 2 << 8 | 0 << 1 | 0)
-#define NFP_HWINFO_VERSION_UPDATING BIT(0)
+#define NFP_HWINFO_VERSION_UPDATING RTE_BIT32(0)
struct nfp_hwinfo {
uint8_t start[0];
diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.c b/drivers/net/nfp/nfpcore/nfp_nffw.c
index bead4f3341..07d63900dc 100644
--- a/drivers/net/nfp/nfpcore/nfp_nffw.c
+++ b/drivers/net/nfp/nfpcore/nfp_nffw.c
@@ -61,9 +61,9 @@ nffw_fwinfo_mip_offset_get(const struct nffw_fwinfo *fi)
}
#define NFP_IMB_TGTADDRESSMODECFG_MODE_of(_x) (((_x) >> 13) & 0x7)
-#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE BIT(12)
+#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE RTE_BIT32(12)
#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_32_BIT 0
-#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_40_BIT BIT(12)
+#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_40_BIT RTE_BIT32(12)
static int
nfp_mip_mu_locality_lsb(struct nfp_cpp *cpp)
diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.h b/drivers/net/nfp/nfpcore/nfp_nffw.h
index 3bbdf1c138..9f24bd2269 100644
--- a/drivers/net/nfp/nfpcore/nfp_nffw.h
+++ b/drivers/net/nfp/nfpcore/nfp_nffw.h
@@ -6,7 +6,6 @@
#ifndef __NFP_NFFW_H__
#define __NFP_NFFW_H__
-#include "nfp-common/nfp_platform.h"
#include "nfp_cpp.h"
/*
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index d8abaf1d52..1f6b7bd85c 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -61,7 +61,7 @@ nfp_nsp_print_extended_error(uint32_t ret_val)
if (ret_val == 0)
return;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_errors); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_errors); i++)
if (ret_val == (uint32_t)nsp_errors[i].code)
PMD_DRV_LOG(ERR, "err msg: %s", nsp_errors[i].msg);
}
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h
index 2184c15b4c..50cdec3a58 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.h
@@ -40,12 +40,12 @@
#define NSP_STATUS_MINOR GENMASK_ULL(43, 32)
#define NSP_STATUS_CODE GENMASK_ULL(31, 16)
#define NSP_STATUS_RESULT GENMASK_ULL(15, 8)
-#define NSP_STATUS_BUSY BIT_ULL(0)
+#define NSP_STATUS_BUSY RTE_BIT64(0)
#define NSP_COMMAND 0x08
#define NSP_COMMAND_OPTION GENMASK_ULL(63, 32)
#define NSP_COMMAND_CODE GENMASK_ULL(31, 16)
-#define NSP_COMMAND_START BIT_ULL(0)
+#define NSP_COMMAND_START RTE_BIT64(0)
/* CPP address to retrieve the data from */
#define NSP_BUFFER 0x10
@@ -152,10 +152,10 @@ enum nfp_eth_fec {
NFP_FEC_DISABLED_BIT,
};
-#define NFP_FEC_AUTO BIT(NFP_FEC_AUTO_BIT)
-#define NFP_FEC_BASER BIT(NFP_FEC_BASER_BIT)
-#define NFP_FEC_REED_SOLOMON BIT(NFP_FEC_REED_SOLOMON_BIT)
-#define NFP_FEC_DISABLED BIT(NFP_FEC_DISABLED_BIT)
+#define NFP_FEC_AUTO RTE_BIT32(NFP_FEC_AUTO_BIT)
+#define NFP_FEC_BASER RTE_BIT32(NFP_FEC_BASER_BIT)
+#define NFP_FEC_REED_SOLOMON RTE_BIT32(NFP_FEC_REED_SOLOMON_BIT)
+#define NFP_FEC_DISABLED RTE_BIT32(NFP_FEC_DISABLED_BIT)
#define ETH_ALEN 6
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
index 15f6f7002d..21b338461e 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
@@ -83,7 +83,7 @@ nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id, long *val)
if (nsp == NULL)
return -EIO;
- ret = nfp_nsp_read_sensors(nsp, BIT(id), &s, sizeof(s));
+ ret = nfp_nsp_read_sensors(nsp, RTE_BIT32(id), &s, sizeof(s));
nfp_nsp_close(nsp);
if (ret < 0)
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index 578120636d..f8d1416d4b 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -44,30 +44,30 @@
#define NSP_ETH_PORT_INDEX GENMASK_ULL(15, 8)
#define NSP_ETH_PORT_LABEL GENMASK_ULL(53, 48)
#define NSP_ETH_PORT_PHYLABEL GENMASK_ULL(59, 54)
-#define NSP_ETH_PORT_FEC_SUPP_BASER BIT_ULL(60)
-#define NSP_ETH_PORT_FEC_SUPP_RS BIT_ULL(61)
+#define NSP_ETH_PORT_FEC_SUPP_BASER RTE_BIT64(60)
+#define NSP_ETH_PORT_FEC_SUPP_RS RTE_BIT64(61)
#define NSP_ETH_PORT_LANES_MASK rte_cpu_to_le_64(NSP_ETH_PORT_LANES)
-#define NSP_ETH_STATE_CONFIGURED BIT_ULL(0)
-#define NSP_ETH_STATE_ENABLED BIT_ULL(1)
-#define NSP_ETH_STATE_TX_ENABLED BIT_ULL(2)
-#define NSP_ETH_STATE_RX_ENABLED BIT_ULL(3)
+#define NSP_ETH_STATE_CONFIGURED RTE_BIT64(0)
+#define NSP_ETH_STATE_ENABLED RTE_BIT64(1)
+#define NSP_ETH_STATE_TX_ENABLED RTE_BIT64(2)
+#define NSP_ETH_STATE_RX_ENABLED RTE_BIT64(3)
#define NSP_ETH_STATE_RATE GENMASK_ULL(11, 8)
#define NSP_ETH_STATE_INTERFACE GENMASK_ULL(19, 12)
#define NSP_ETH_STATE_MEDIA GENMASK_ULL(21, 20)
-#define NSP_ETH_STATE_OVRD_CHNG BIT_ULL(22)
+#define NSP_ETH_STATE_OVRD_CHNG RTE_BIT64(22)
#define NSP_ETH_STATE_ANEG GENMASK_ULL(25, 23)
#define NSP_ETH_STATE_FEC GENMASK_ULL(27, 26)
-#define NSP_ETH_CTRL_CONFIGURED BIT_ULL(0)
-#define NSP_ETH_CTRL_ENABLED BIT_ULL(1)
-#define NSP_ETH_CTRL_TX_ENABLED BIT_ULL(2)
-#define NSP_ETH_CTRL_RX_ENABLED BIT_ULL(3)
-#define NSP_ETH_CTRL_SET_RATE BIT_ULL(4)
-#define NSP_ETH_CTRL_SET_LANES BIT_ULL(5)
-#define NSP_ETH_CTRL_SET_ANEG BIT_ULL(6)
-#define NSP_ETH_CTRL_SET_FEC BIT_ULL(7)
+#define NSP_ETH_CTRL_CONFIGURED RTE_BIT64(0)
+#define NSP_ETH_CTRL_ENABLED RTE_BIT64(1)
+#define NSP_ETH_CTRL_TX_ENABLED RTE_BIT64(2)
+#define NSP_ETH_CTRL_RX_ENABLED RTE_BIT64(3)
+#define NSP_ETH_CTRL_SET_RATE RTE_BIT64(4)
+#define NSP_ETH_CTRL_SET_LANES RTE_BIT64(5)
+#define NSP_ETH_CTRL_SET_ANEG RTE_BIT64(6)
+#define NSP_ETH_CTRL_SET_FEC RTE_BIT64(7)
/* Which connector port. */
#define PORT_TP 0x00
@@ -139,7 +139,7 @@ nfp_eth_rate2speed(enum nfp_eth_rate rate)
{
int i;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_eth_rate_tbl); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_eth_rate_tbl); i++)
if (nsp_eth_rate_tbl[i].rate == rate)
return nsp_eth_rate_tbl[i].speed;
@@ -151,7 +151,7 @@ nfp_eth_speed2rate(unsigned int speed)
{
int i;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_eth_rate_tbl); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_eth_rate_tbl); i++)
if (nsp_eth_rate_tbl[i].speed == speed)
return nsp_eth_rate_tbl[i].rate;
diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h
index 24417fb315..accedde1f7 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.h
+++ b/drivers/net/nfp/nfpcore/nfp_target.h
@@ -7,7 +7,6 @@
#define NFP_TARGET_H
#include "nfp-common/nfp_resid.h"
-#include "nfp-common/nfp_platform.h"
#include "nfp_cpp.h"
#define P32 1
--
2.39.1
next prev parent reply other threads:[~2023-04-10 11:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 11:00 [PATCH 00/13] Sync the kernel driver logic Chaoyong He
2023-04-10 11:00 ` [PATCH 01/13] net/nfp: define correct size for configuration BAR Chaoyong He
2023-04-10 11:00 ` [PATCH 02/13] net/nfp: move shared target logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 03/13] net/nfp: remove the redundant macro about CPP target Chaoyong He
2023-04-10 11:00 ` [PATCH 04/13] net/nfp: drop usage of return error helpers Chaoyong He
2023-04-10 11:00 ` Chaoyong He [this message]
2023-04-10 11:00 ` [PATCH 06/13] net/nfp: remove dead code related to CPP Chaoyong He
2023-04-10 11:00 ` [PATCH 07/13] net/nfp: remove duplicated nffw defines Chaoyong He
2023-04-10 11:00 ` [PATCH 08/13] net/nfp: move NFD3 logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 09/13] net/nfp: adjust the coding style for NFD3 Chaoyong He
2023-04-10 11:00 ` [PATCH 10/13] net/nfp: rename macro name of NFD3 Tx descriptor Chaoyong He
2023-04-10 11:00 ` [PATCH 11/13] net/nfp: move NFDk logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 12/13] net/nfp: adjust the coding style for NFDk Chaoyong He
2023-04-10 11:00 ` [PATCH 13/13] net/nfp: modify the logic of some NFDk function Chaoyong He
2023-05-11 14:47 ` [PATCH 00/13] Sync the kernel driver logic Niklas Söderlund
2023-05-12 14:37 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230410110015.2973660-6-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).