net/ntnic: prefix global symbols
cover net/ntnic: prefix global symbols
The ntnic driver in next-net is not consitent in prefixing all global symbols.
Stephen Hemminger (3):
net/ntnic: rename nt_log_ types
net/ntnic: rename hwlock
net/ntnic: make flow_lock local
drivers/net/ntnic/include/create_elements.h | 2 -- .../ntnic/include/stream_binary_flow_api.h | 2 +- drivers/net/ntnic/ntlog/ntlog.h | 16 +++++++------- drivers/net/ntnic/ntnic_ethdev.c | 22 +++++++++---------- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 10 ++++----- 5 files changed, 25 insertions(+), 27 deletions(-)
Signature · 1 line
2.47.3
RFC 1/3 net/ntnic: rename nt_log_ types
Use the driver name as prefix as is commmonly done by other drivers.
--- drivers/net/ntnic/ntlog/ntlog.h | 16 ++++++++-------- drivers/net/ntnic/ntnic_ethdev.c | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/ntnic/ntlog/ntlog.h +8 -8
@@ -10,14 +10,14 @@#include <stdint.h> #include <rte_log.h> -extern int nt_log_general; -#define RTE_LOGTYPE_GENERAL nt_log_general -extern int nt_log_nthw; -#define RTE_LOGTYPE_NTHW nt_log_nthw -extern int nt_log_filter; -#define RTE_LOGTYPE_FILTER nt_log_filter -extern int nt_log_ntnic; -#define RTE_LOGTYPE_NTNIC nt_log_ntnic +extern int ntnic_logtype_general; +#define RTE_LOGTYPE_GENERAL ntnic_logtype_general +extern int ntnic_logtype_nthw; +#define RTE_LOGTYPE_NTHW ntnic_logtype_nthw +extern int ntnic_logtype_filter; +#define RTE_LOGTYPE_FILTER ntnic_logtype_filter +extern int ntnic_logtype_ntnic; +#define RTE_LOGTYPE_NTNIC ntnic_logtype_ntnic#define NT_DRIVER_NAME "ntnic"
drivers/net/ntnic/ntnic_ethdev.c +4 -4
@@ -2729,7 +2729,7 @@ RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);RTE_PMD_REGISTER_PCI_TABLE (net_ntnic, nthw_pci_id_map);RTE_PMD_REGISTER_KMOD_DEP (net_ntnic,"* vfio-pci" ); -RTE_LOG_REGISTER_SUFFIX (nt_log_general, general,INFO ); -RTE_LOG_REGISTER_SUFFIX (nt_log_nthw, nthw,INFO ); -RTE_LOG_REGISTER_SUFFIX (nt_log_filter, filter,INFO ); -RTE_LOG_REGISTER_SUFFIX (nt_log_ntnic, ntnic,INFO ); +RTE_LOG_REGISTER_SUFFIX (ntnic_logtype_general, general,INFO ); +RTE_LOG_REGISTER_SUFFIX (ntnic_logtype_nthw, nthw,INFO ); +RTE_LOG_REGISTER_SUFFIX (ntnic_logtype_filter, filter,INFO ); +RTE_LOG_REGISTER_SUFFIX (ntnic_logtype_ntnic, ntnic,INFO );
Signature · 1 line
2.47.3
RFC 2/3 net/ntnic: rename hwlock
In reply to Stephen HemmingerAll global variables in driver should use common prefix. Rename hwlock to ntnic_hwlock.
--- drivers/net/ntnic/include/stream_binary_flow_api.h | 2 +- drivers/net/ntnic/ntnic_ethdev.c | 14 +++++++------- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/ntnic/include/stream_binary_flow_api.h +1 -1
@@ -47,7 +47,7 @@#define RAW_ENCAP_DECAP_ELEMS_MAX 16extern uint64_t rte_tsc_freq; -extern rte_spinlock_t hwlock; +extern rte_spinlock_t ntnic_hwlock;/* * Flow eth dev profile determines how the FPGA module resources are
drivers/net/ntnic/ntnic_ethdev.c +7 -7
@@ -92,7 +92,7 @@ static const struct rte_pci_id nthw_pci_id_map[] = {static const struct sg_ops_s *sg_ops; -rte_spinlock_t hwlock =RTE_SPINLOCK_INITIALIZER ; +rte_spinlock_t ntnic_hwlock =RTE_SPINLOCK_INITIALIZER ;/* * Store and get adapter info
@@ -124,9 +124,9 @@ store_pdrv(struct drv_s *p_drv) PCIIDENT_TO_FUNCNR(p_drv->ntdrv.pciident)); } -rte_spinlock_lock (&hwlock); +rte_spinlock_lock (&ntnic_hwlock); _g_p_drv[p_drv->adapter_no] = p_drv; -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock); }static void clear_pdrv (struct drv_s *p_drv)
@@ -134,9 +134,9 @@ static void clear_pdrv(struct drv_s *p_drv)if (p_drv->adapter_no >=NUM_ADAPTER_MAX )return ; -rte_spinlock_lock (&hwlock); +rte_spinlock_lock (&ntnic_hwlock); _g_p_drv[p_drv->adapter_no] =NULL ; -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock); } static struct drv_s *
@@ -144,7 +144,7 @@ get_pdrv_from_pci(struct rte_pci_addr addr) {int i;struct drv_s *p_drv =NULL ; -rte_spinlock_lock (&hwlock); +rte_spinlock_lock (&ntnic_hwlock);for (i =0 ; i <NUM_ADAPTER_MAX ; i++) {if (_g_p_drv[i]) {
@@ -156,7 +156,7 @@ get_pdrv_from_pci(struct rte_pci_addr addr) } } -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock);return p_drv; }
drivers/net/ntnic/ntnic_filter/ntnic_filter.c +4 -4
@@ -1187,7 +1187,7 @@ static int poll_statistics(struct pmd_internals *internals)RTE_ASSERT (rte_tsc_freq >0 ); -rte_spinlock_lock (&hwlock); +rte_spinlock_lock (&ntnic_hwlock);uint64_t now_rtc =rte_get_tsc_cycles ();
@@ -1196,7 +1196,7 @@ static int poll_statistics(struct pmd_internals *internals)* if more than a second since last stat read, do a new one */ if ((now_rtc - internals->last_stat_rtc) < rte_tsc_freq) { -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock);return 0 ; }
@@ -1242,7 +1242,7 @@ static int poll_statistics(struct pmd_internals *internals)/* Globally only once a second */ if ((now_rtc - last_stat_rtc) < rte_tsc_freq) { -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock);rte_spinlock_unlock (&p_nt_drv->stat_lck);return 0 ; }
@@ -1279,7 +1279,7 @@ static int poll_statistics(struct pmd_internals *internals) } } -rte_spinlock_unlock (&hwlock); +rte_spinlock_unlock (&ntnic_hwlock);rte_spinlock_unlock (&p_nt_drv->stat_lck);return 0 ;
Signature · 1 line
2.47.3
RFC 3/3 net/ntnic: make flow_lock local
In reply to Stephen HemmingerThe variable flow_lock is only used in one file.
--- drivers/net/ntnic/include/create_elements.h | 2 -- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/net/ntnic/include/create_elements.h +0 -2
@@ -58,6 +58,4 @@ enum nt_rte_flow_item_type { NT_RTE_FLOW_ITEM_TYPE_TUNNEL, }; -extern rte_spinlock_t flow_lock; -#endif /* __CREATE_ELEMENTS_H__ */
drivers/net/ntnic/ntnic_filter/ntnic_filter.c +1 -1
@@ -28,7 +28,7 @@static struct rte_flow nt_flows[MAX_RTE_FLOWS ]; -rte_spinlock_t flow_lock =RTE_SPINLOCK_INITIALIZER ; +static rte_spinlock_t flow_lock =RTE_SPINLOCK_INITIALIZER ;static struct rte_flow nt_flows[MAX_RTE_FLOWS ]; static int nthw_interpret_raw_data(uint8_t *data, uint8_t *preserve, int size,
Signature · 1 line
2.47.3
Hi!
The patch series looks good.
Only one thought from my side is about consistency between prefixes for global symbols for variables and functions.
For functions, we use the prefix "nthw_*"; however, the patch series uses the prefix "ntnic_" for global variables. Will it be better to keep the same prefix for functions and variables?
If there is no strict rule, we may keep "ntnic_".
On 26.09.2025, 19:25, "Stephen Hemminger" <[email protected]> wrote:
The ntnic driver in next-net is not consitent in prefixing all global symbols.
Stephen Hemminger (3):
net/ntnic: rename nt_log_ types
net/ntnic: rename hwlock
net/ntnic: make flow_lock local
drivers/net/ntnic/include/create_elements.h | 2 -- .../ntnic/include/stream_binary_flow_api.h | 2 +- drivers/net/ntnic/ntlog/ntlog.h | 16 +++++++------- drivers/net/ntnic/ntnic_ethdev.c | 22 +++++++++---------- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 10 ++++----- 5 files changed, 25 insertions(+), 27 deletions(-)
--
2.47.3
Quoted 26 lines · On Mon, 29 Sep 2025 15:59:36 +0000 Serhii Iliushyk <[email protected]> wrote:
Hi!
The patch series looks good.
Only one thought from my side is about consistency between prefixes for global symbols for variables and functions.For functions, we use the prefix "nthw_*"; however, the patch series uses the prefix "
ntnic_" for global variables. Will it be better to keep the same prefix for functions and variables?
If there is no strict rule, we may keep "ntnic_".On 26.09.2025, 19:25, "Stephen Hemminger" <[email protected]> wrote:
The ntnic driver in next-net is not consitent in prefixing all global symbols.
Stephen Hemminger (3):
net/ntnic: renament_log_types
net/ntnic: rename hwlock
net/ntnic: makeflow_locklocaldrivers/net/ntnic/include/create_elements.h | 2 -- .../ntnic/include/stream_binary_flow_api.h | 2 +- drivers/net/ntnic/ntlog/ntlog.h | 16 +++++++------- drivers/net/ntnic/ntnic_ethdev.c | 22 +++++++++---------- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 10 ++++----- 5 files changed, 25 insertions(+), 27 deletions(-)
Quoted 2 lines
--
2.47.3
Sure ntnic_ and nthw_ are both ok, you choose where needed.
Great. I will add corresponding patch to the next patch series.
On 29.09.2025, 19:33, "Stephen Hemminger" <[email protected]> wrote:
Quoted 26 lines · On Mon, 29 Sep 2025 15:59:36 +0000 Serhii Iliushyk <[email protected]> wrote:
Hi!
The patch series looks good.
Only one thought from my side is about consistency between prefixes for global symbols for variables and functions.For functions, we use the prefix "nthw_*"; however, the patch series uses the prefix "
ntnic_" for global variables. Will it be better to keep the same prefix for functions and variables?
If there is no strict rule, we may keep "ntnic_".On 26.09.2025, 19:25, "Stephen Hemminger" <[email protected]> wrote:
The ntnic driver in next-net is not consitent in prefixing all global symbols.
Stephen Hemminger (3):
net/ntnic: renament_log_types
net/ntnic: rename hwlock
net/ntnic: makeflow_locklocaldrivers/net/ntnic/include/create_elements.h | 2 -- .../ntnic/include/stream_binary_flow_api.h | 2 +- drivers/net/ntnic/ntlog/ntlog.h | 16 +++++++------- drivers/net/ntnic/ntnic_ethdev.c | 22 +++++++++---------- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 10 ++++----- 5 files changed, 25 insertions(+), 27 deletions(-)
Quoted 2 lines
--
2.47.3
Sure ntnic_ and nthw_ are both ok, you choose where needed.