This patch cleans up the code to use pthreads and rte_thread APIs. Signed-off-by: Serhii Iliushyk <sil-...@napatech.com> --- drivers/net/ntnic/adapter/nt4ga_adapter.c | 2 -- drivers/net/ntnic/include/nt4ga_adapter.h | 1 - drivers/net/ntnic/include/ntdrv_4ga.h | 1 - drivers/net/ntnic/nthw/core/nthw_pca9532.c | 2 -- drivers/net/ntnic/nthw/core/nthw_pcal6416a.c | 1 - .../net/ntnic/nthw/core/nthw_si5332_si5156.c | 1 - .../profile_inline/flow_api_profile_inline.c | 2 +- drivers/net/ntnic/ntnic_ethdev.c | 22 +++++-------------- drivers/net/ntnic/ntutil/nt_util.c | 2 +- 9 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c index 363874c85f..de4e8707bf 100644 --- a/drivers/net/ntnic/adapter/nt4ga_adapter.c +++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c @@ -3,8 +3,6 @@ * Copyright(c) 2023 Napatech A/S */ -#include <rte_thread.h> - #include "nt_service.h" #include "ntlog.h" #include "nthw_fpga.h" diff --git a/drivers/net/ntnic/include/nt4ga_adapter.h b/drivers/net/ntnic/include/nt4ga_adapter.h index 6c701b601f..0598e62b7b 100644 --- a/drivers/net/ntnic/include/nt4ga_adapter.h +++ b/drivers/net/ntnic/include/nt4ga_adapter.h @@ -40,7 +40,6 @@ typedef struct adapter_info_s { char *mp_port_id_str[NUM_ADAPTER_PORTS_MAX]; char *mp_adapter_id_str; char *p_dev_name; - volatile bool *pb_shutdown; int adapter_no; int n_rx_host_buffers; diff --git a/drivers/net/ntnic/include/ntdrv_4ga.h b/drivers/net/ntnic/include/ntdrv_4ga.h index ee0e66c4d4..4ff1f115f4 100644 --- a/drivers/net/ntnic/include/ntdrv_4ga.h +++ b/drivers/net/ntnic/include/ntdrv_4ga.h @@ -14,7 +14,6 @@ typedef struct ntdrv_4ga_s { struct adapter_info_s adapter_info; char *p_drv_name; - volatile bool b_shutdown; rte_spinlock_t stat_lck; } ntdrv_4ga_t; diff --git a/drivers/net/ntnic/nthw/core/nthw_pca9532.c b/drivers/net/ntnic/nthw/core/nthw_pca9532.c index af14cd6d06..805e0275e8 100644 --- a/drivers/net/ntnic/nthw/core/nthw_pca9532.c +++ b/drivers/net/ntnic/nthw/core/nthw_pca9532.c @@ -3,8 +3,6 @@ * Copyright(c) 2023 Napatech A/S */ -#include <pthread.h> - #include "nt_util.h" #include "ntlog.h" diff --git a/drivers/net/ntnic/nthw/core/nthw_pcal6416a.c b/drivers/net/ntnic/nthw/core/nthw_pcal6416a.c index 2fca469497..f7efc196f4 100644 --- a/drivers/net/ntnic/nthw/core/nthw_pcal6416a.c +++ b/drivers/net/ntnic/nthw/core/nthw_pcal6416a.c @@ -2,7 +2,6 @@ * SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2023 Napatech A/S */ -#include <pthread.h> #include "nt_util.h" #include "ntlog.h" diff --git a/drivers/net/ntnic/nthw/core/nthw_si5332_si5156.c b/drivers/net/ntnic/nthw/core/nthw_si5332_si5156.c index eb11ebc67a..537d58afb7 100644 --- a/drivers/net/ntnic/nthw/core/nthw_si5332_si5156.c +++ b/drivers/net/ntnic/nthw/core/nthw_si5332_si5156.c @@ -3,7 +3,6 @@ * Copyright(c) 2023 Napatech A/S */ -#include <pthread.h> #include "generic/rte_spinlock.h" #include "nt_util.h" #include "ntlog.h" diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index eaaf681ac6..2291642ca9 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -5276,7 +5276,7 @@ struct flow_handle *flow_async_create_profile_inline(struct flow_eth_dev *dev, } while (status == CELL_STATUS_INITIALIZING); /* error handling in case that create_flow_filter() will fail in the other - * thread + * service */ if (status == CELL_STATUS_UNINITIALIZED) goto err_exit; diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 664112f67e..0f70462f3d 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -6,8 +6,6 @@ #include <stdint.h> #include <stdarg.h> -#include <signal.h> - #include <rte_eal.h> #include <rte_dev.h> #include <rte_vfio.h> @@ -33,12 +31,6 @@ #include "rte_pmd_ntnic.h" #include "nt_service.h" -const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL }; -#define THREAD_CREATE(a, b, c) rte_thread_create(a, &thread_attr, b, c) -#define THREAD_CTRL_CREATE(a, b, c, d) rte_thread_create_internal_control(a, b, c, d) -#define THREAD_JOIN(a) rte_thread_join(a, NULL) -#define THREAD_FUNC static uint32_t -#define THREAD_RETURN (0) #define HW_MAX_PKT_LEN (10000) #define MAX_MTU (HW_MAX_PKT_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN) #define MIN_MTU_INLINE 512 @@ -1536,14 +1528,13 @@ drv_deinit(struct drv_s *p_drv) fpga_info_t *fpga_info = &p_nt_drv->adapter_info.fpga_info; /* - * Mark the global pdrv for cleared. Used by some threads to terminate. - * 1 second to give the threads a chance to see the termonation. + * Mark the global pdrv for cleared. Used by some services to terminate. + * 1 second to give the services a chance to see the termonation. */ clear_pdrv(p_drv); nt_os_wait_usec(1000000); /* stop statistics service */ - p_drv->ntdrv.b_shutdown = true; nthw_service_del(RTE_NTNIC_SERVICE_STAT); if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { @@ -2323,9 +2314,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) p_nt_drv->adapter_info.hw_info.pci_sub_vendor_id, p_nt_drv->adapter_info.hw_info.pci_sub_device_id); - p_nt_drv->b_shutdown = false; - p_nt_drv->adapter_info.pb_shutdown = &p_nt_drv->b_shutdown; - /* store context */ store_pdrv(p_drv); @@ -2366,7 +2354,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized"); } - /* Start ctrl, monitor, stat thread only for primary process. */ + /* Start ctrl, monitor, stat service only for primary process. */ if (err == 0) { /* mp_adapter_id_str is initialized after nt4ga_adapter_init(p_nt_drv) */ const char *const p_adapter_id_str = p_nt_drv->adapter_info.mp_adapter_id_str; @@ -2631,7 +2619,7 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) fpga_info_t *fpga_info = &p_ntdrv->adapter_info.fpga_info; const int n_phy_ports = fpga_info->n_phy_ports; - /* let running threads end Rx and Tx activity */ + /* let running services end Rx and Tx activity */ if (sg_ops != NULL) { nt_os_wait_usec(1 * 1000 * 1000); @@ -2706,7 +2694,7 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, /* * 1 time calculation of 1 sec stat update rtc cycles to prevent stat poll - * flooding by OVS from multiple virtual port threads - no need to be precise + * flooding by OVS from multiple virtual port services - no need to be precise */ uint64_t now_rtc = rte_get_tsc_cycles(); nt_os_wait_usec(10 * 1000); diff --git a/drivers/net/ntnic/ntutil/nt_util.c b/drivers/net/ntnic/ntutil/nt_util.c index df382e7a24..a4d30d8ca4 100644 --- a/drivers/net/ntnic/ntutil/nt_util.c +++ b/drivers/net/ntnic/ntutil/nt_util.c @@ -16,7 +16,7 @@ static struct nt_util_vfio_impl vfio_cb; -/* uses usleep which schedules out the calling thread */ +/* uses usleep which schedules out the calling service */ void nt_os_wait_usec(int val) { rte_delay_us_sleep(val); -- 2.45.0