* [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API
@ 2021-06-18 21:54 Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
` (6 more replies)
0 siblings, 7 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
This patchset enables the new EAL thread API.
Rename pthread* with rte_thread* corresponding symbols.
Set thread attributes.
Add option for choosing between internal API or external lib.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Narcisa Vasile (6):
eal: add function that sets thread name
eal: add function for control thread creation
Enable the new EAL thread API in app, drivers and examples
lib: enable the new EAL thread API
eal: set affinity and priority attributes
Allow choice between internal EAL thread API and external lib
app/test/process.h | 8 +-
app/test/test_lcores.c | 18 +-
app/test/test_link_bonding.c | 14 +-
app/test/test_lpm_perf.c | 12 +-
config/meson.build | 1 -
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 +-
drivers/bus/dpaa/base/qbman/process.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 14 +-
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 +-
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 10 +-
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 +-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +-
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 +--
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.h | 8 +-
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +-
drivers/net/axgbe/axgbe_phy_impl.c | 6 +-
drivers/net/bnxt/bnxt.h | 16 +-
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 ++---
drivers/net/bnxt/bnxt_irq.c | 8 +-
drivers/net/bnxt/bnxt_reps.c | 10 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +--
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +-
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +-
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +-
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +-
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 +-
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +-
drivers/net/vhost/rte_eth_vhost.c | 24 +--
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +--
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 +++--
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 +--
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++---
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
lib/eal/common/eal_common_options.c | 6 +-
lib/eal/common/eal_common_thread.c | 105 +++++++++-
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/eal_thread.h | 6 +
lib/eal/common/malloc_mp.c | 2 +
lib/eal/common/rte_thread.c | 17 ++
lib/eal/freebsd/eal.c | 53 +++--
lib/eal/freebsd/eal_alarm.c | 12 +-
lib/eal/freebsd/eal_interrupts.c | 6 +-
lib/eal/freebsd/eal_thread.c | 10 +-
lib/eal/include/rte_lcore.h | 6 +
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/include/rte_thread.h | 45 ++++
lib/eal/linux/eal.c | 55 +++--
lib/eal/linux/eal_alarm.c | 10 +-
lib/eal/linux/eal_interrupts.c | 8 +-
lib/eal/linux/eal_thread.c | 11 +-
lib/eal/linux/eal_timer.c | 6 +-
lib/eal/version.map | 6 +-
lib/eal/windows/eal.c | 44 +++-
lib/eal/windows/eal_interrupts.c | 10 +-
lib/eal/windows/eal_thread.c | 35 +---
lib/eal/windows/eal_windows.h | 10 -
lib/eal/windows/include/pthread.h | 192 ------------------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/meson.build | 7 +-
lib/eal/windows/rte_thread.c | 60 ++++++
lib/ethdev/rte_ethdev.c | 4 +-
lib/ethdev/rte_ethdev_core.h | 4 +-
lib/ethdev/rte_flow.c | 4 +-
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
meson_options.txt | 2 +
95 files changed, 764 insertions(+), 654 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
` (5 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Implement function that sets the name of a thread.
On Windows, SetThreadDescription() is used. Use GetProcAddress()
to obtain the address of the function for MinGW compatibility.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/rte_thread.c | 17 ++++++++++
lib/eal/include/rte_thread.h | 18 +++++++++++
lib/eal/version.map | 1 +
lib/eal/windows/rte_thread.c | 60 ++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+)
diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c
index 3fdb267337..fbff1168e5 100644
--- a/lib/eal/common/rte_thread.c
+++ b/lib/eal/common/rte_thread.c
@@ -373,6 +373,23 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return ret;
}
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+ char truncated[RTE_THREAD_MAX_DESCRIPTION_LENGTH];
+
+ memcpy(truncated, name, sizeof(truncated));
+ ret = pthread_setname_np((pthread_t)thread_id.opaque_id, truncated);
+#endif
+#endif
+ RTE_SET_USED(thread_id);
+ RTE_SET_USED(name);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *))
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 40da83467b..c65cfd8c9e 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -24,6 +24,8 @@ extern "C" {
#include <sched.h>
+#define RTE_THREAD_MAX_DESCRIPTION_LENGTH 16
+
/**
* Thread id descriptor.
*/
@@ -439,6 +441,22 @@ int rte_thread_barrier_wait(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
+/**
+ * Set the name of the thread represented by 'thread_id'.
+ *
+ * @param thread_id
+ * The id of the thread.
+ *
+ * @param name
+ * Thread name to set.
+ *
+ * @return
+ * On success, return 0.
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 6645f60a78..2a566c04af 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -443,6 +443,7 @@ EXPERIMENTAL {
rte_thread_barrier_init;
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
+ rte_thread_name_set;
};
INTERNAL {
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index b2ff16f51f..180ac126af 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -556,6 +556,66 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return 0;
}
+typedef HRESULT
+(*SetThreadDescription_type)(HANDLE thread_handle, PCWSTR thread_descirption);
+
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = 0;
+ size_t count;
+ HRESULT hr;
+ HANDLE thread_handle = NULL;
+ WCHAR w_name[RTE_THREAD_MAX_DESCRIPTION_LENGTH];
+ HMODULE kernel_lib = NULL;
+ SetThreadDescription_type SetThreadDescription_ptr;
+
+ static const char library_name[] = "kernel32.dll";
+ static const char function[] = "SetThreadDescription";
+
+ kernel_lib = LoadLibraryA(library_name);
+ if (kernel_lib == NULL) {
+ ret = thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
+ goto cleanup;
+ }
+
+ SetThreadDescription_ptr = (SetThreadDescription_type)(
+ (void *)GetProcAddress(kernel_lib, function));
+ if (SetThreadDescription_ptr == NULL) {
+ ret = thread_log_last_error("GetProcAddress(\"kernel32.dll\", \"SetThreadDescription\")");
+ goto cleanup;
+ }
+
+ thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE,
+ thread_id.opaque_id);
+ if (thread_handle == NULL) {
+ ret = thread_log_last_error("OpenThread()");
+ goto cleanup;
+ }
+
+ count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
+ if (count < 0) {
+ RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ hr = SetThreadDescription_ptr(thread_handle, w_name);
+ if (FAILED(hr)) {
+ ret = thread_log_last_error("SetThreadDescription()");
+ goto cleanup;
+ }
+
+cleanup:
+ if (kernel_lib != NULL)
+ FreeLibrary(kernel_lib);
+ if (thread_handle != NULL) {
+ CloseHandle(thread_handle);
+ thread_handle = NULL;
+ }
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key,
__rte_unused void (*destructor)(void *))
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 2/6] eal: add function for control thread creation
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
` (4 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The existing rte_ctrl_thread_create() function will be replaced
with rte_thread_ctrl_thread_create() that uses the internal
EAL thread API.
This patch only introduces the new control thread creation
function. Replacing of the old function needs to be done according
to the ABI change procedures, to avoid an ABI break.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 81 ++++++++++++++++++++++++++++++
lib/eal/include/rte_thread.h | 27 ++++++++++
lib/eal/version.map | 1 +
3 files changed, 109 insertions(+)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 1a52f42a2b..79545c67d9 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -259,6 +259,87 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+struct rte_thread_ctrl_ctx {
+ rte_thread_func start_routine;
+ void *arg;
+ const char *name;
+};
+
+static void *ctrl_thread_wrapper(void *arg)
+{
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = arg;
+ rte_thread_func start_routine = ctx->start_routine;
+ void *routine_arg = ctx->arg;
+
+ __rte_thread_init(rte_lcore_id(), cpuset);
+
+ if (ctx->name != NULL) {
+ if (rte_thread_name_set(rte_thread_self(), ctx->name) < 0)
+ RTE_LOG(DEBUG, EAL, "Cannot set name for ctrl thread\n");
+ }
+
+ free(arg);
+
+ return start_routine(routine_arg);
+}
+
+int
+rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg)
+{
+ int ret;
+ rte_thread_attr_t attr;
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = NULL;
+
+ if (start_routine == NULL) {
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL) {
+ ret = ENOMEM;
+ goto cleanup;
+ }
+
+ ctx->start_routine = start_routine;
+ ctx->arg = arg;
+ ctx->name = name;
+
+ ret = rte_thread_attr_init(&attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot init ctrl thread attributes\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_attr_set_affinity(&attr, cpuset);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set afifnity attribute for ctrl thread\n");
+ goto cleanup;
+ }
+ ret = rte_thread_attr_set_priority(&attr, RTE_THREAD_PRIORITY_NORMAL);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set priority attribute for ctrl thread\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_create(thread, &attr, ctrl_thread_wrapper, ctx);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot create ctrl thread\n");
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ free(ctx);
+ return ret;
+}
+
int
rte_thread_register(void)
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index c65cfd8c9e..4da800ae27 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -457,6 +457,33 @@ int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+/**
+ * Create a control thread.
+ *
+ * Set affinity and thread name. The affinity of the new thread is based
+ * on the CPU affinity retrieved at the time rte_eal_init() was called,
+ * the dataplane and service lcores are then excluded.
+ *
+ * @param thread
+ * Filled with the thread id of the new created thread.
+ *
+ * @param name
+ * The name of the control thread (max 16 characters including '\0').
+ *
+ * @param start_routine
+ * Function to be executed by the new thread.
+ *
+ * @param arg
+ * Argument passed to start_routine.
+ *
+ * @return
+ * On success, return 0;
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 2a566c04af..02455a1c8d 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -444,6 +444,7 @@ EXPERIMENTAL {
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
rte_thread_name_set;
+ rte_thread_ctrl_thread_create;
};
INTERNAL {
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 3/6] Enable the new EAL thread API in app, drivers and examples
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
` (3 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
app/test/process.h | 8 +--
app/test/test_lcores.c | 18 +++----
app/test/test_link_bonding.c | 14 ++---
app/test/test_lpm_perf.c | 12 ++---
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 ++---
drivers/bus/dpaa/base/qbman/process.c | 6 +--
drivers/bus/dpaa/dpaa_bus.c | 14 ++---
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 ++++---
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 10 ++--
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 ++-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +++----
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 ++++-----
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.h | 8 +--
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +--
drivers/net/axgbe/axgbe_phy_impl.c | 6 +--
drivers/net/bnxt/bnxt.h | 16 +++---
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 +++++++++----------
drivers/net/bnxt/bnxt_irq.c | 8 +--
drivers/net/bnxt/bnxt_reps.c | 10 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++++++------
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +++++-----
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +++---
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +--
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +++----
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +--
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 ++--
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +--
drivers/net/vhost/rte_eth_vhost.c | 24 ++++-----
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +++++------
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 ++++++++---------
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 ++++-----
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++++++++----------
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
60 files changed, 334 insertions(+), 339 deletions(-)
diff --git a/app/test/process.h b/app/test/process.h
index a09a088477..9e4be17bad 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -26,7 +26,7 @@
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
-#include <pthread.h>
+#include <rte_thread.h>
extern void *send_pkts(void *empty);
extern uint16_t flag_for_send_pkts;
#endif
@@ -47,7 +47,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
char path[32];
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
- pthread_t thread;
+ rte_thread_t thread;
int rc;
#endif
#endif
@@ -128,7 +128,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
- rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+ rc = rte_thread_create(&thread, NULL, &send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
strerror(rc));
@@ -143,7 +143,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
- pthread_join(thread, NULL);
+ rte_thread_join(thread, NULL);
}
#endif
#endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 19a7ab9fce..accdd858a6 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,7 @@
* Copyright (c) 2020 Red Hat, Inc.
*/
-#include <pthread.h>
+#include <rte_thread.h>
#include <string.h>
#include <rte_common.h>
@@ -14,7 +14,7 @@
struct thread_context {
enum { INIT, ERROR, DONE } state;
bool lcore_id_any;
- pthread_t id;
+ rte_thread_t id;
unsigned int *registered_count;
};
@@ -77,7 +77,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
break;
non_eal_threads_count++;
}
@@ -96,7 +96,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) == 0) {
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
non_eal_threads_count++;
printf("non-EAL threads count: %u\n", non_eal_threads_count);
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -110,7 +110,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -262,7 +262,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -285,7 +285,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -309,7 +309,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -330,7 +330,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
__atomic_store_n(®istered_count, 0, __ATOMIC_RELEASE);
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
}
error:
if (handle[1] != NULL)
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c8310a8..a22189a656 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -3,6 +3,7 @@
*/
#include "unistd.h"
+#include <pthread.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
@@ -203,7 +204,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
static int slaves_initialized;
static int mac_slaves_initialized;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(mutex)
static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
@@ -1191,11 +1192,11 @@ test_bonding_lsc_event_callback(uint16_t port_id __rte_unused,
void *param __rte_unused,
void *ret_param __rte_unused)
{
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
test_lsc_interrupt_count++;
pthread_cond_signal(&cvar);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
return 0;
}
@@ -1220,11 +1221,12 @@ lsc_timeout(int wait_us)
ts.tv_sec += 1;
}
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
if (test_lsc_interrupt_count < 1)
- retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+ retval = pthread_cond_timedwait(&cvar,
+ (pthread_mutex_t *)mutex.mutex_id, &ts);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
if (retval == 0 && test_lsc_interrupt_count < 1)
return -1;
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 2bed00d064..e4cfcdb504 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -25,7 +25,7 @@ static volatile uint32_t thr_id;
static uint64_t gwrite_cycles;
static uint32_t num_writers;
/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(lpm_mutex)
/* Report quiescent state interval every 1024 lookups. Larger critical
* sections in reader will result in writer polling multiple times.
@@ -443,7 +443,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
/* Add all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth,
next_hop_add) != 0) {
@@ -452,13 +452,13 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
/* Delete all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth) != 0) {
printf("Failed to delete iteration %d, route# %d\n",
@@ -466,7 +466,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
}
@@ -478,7 +478,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
error:
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
return -1;
}
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index ee35e03da1..25be077c6f 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -38,11 +38,10 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
struct dpaa_ioctl_irq_map irq_map;
/* Verify the thread's cpu-affinity */
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_set_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
errno = ret;
- err(0, "pthread_getaffinity_np()");
+ err(0, "rte_thread_set_affinity_by_id()");
return ret;
}
pcfg.cpu = -1;
diff --git a/drivers/bus/dpaa/base/qbman/dpaa_sys.c b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
index 9d6bfd40a2..14aeb5e07d 100644
--- a/drivers/bus/dpaa/base/qbman/dpaa_sys.c
+++ b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
@@ -18,16 +18,16 @@ struct process_interrupt {
};
static COMPAT_LIST_HEAD(process_irq_list);
-static pthread_mutex_t process_irq_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(process_irq_lock)
static void process_interrupt_install(struct process_interrupt *irq)
{
int ret;
/* Add the irq to the end of the list */
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_add_tail(&irq->node, &process_irq_list);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -35,10 +35,10 @@ static void process_interrupt_remove(struct process_interrupt *irq)
{
int ret;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_del(&irq->node);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -47,14 +47,14 @@ static struct process_interrupt *process_interrupt_find(int irq_num)
int ret;
struct process_interrupt *i = NULL;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_for_each_entry(i, &process_irq_list, node) {
if (i->irq == irq_num)
goto done;
}
done:
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
return i;
}
diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 9bc92681cd..da157b8426 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -21,7 +21,7 @@
* what the lock is for.
*/
static int fd = -1;
-static pthread_mutex_t fd_init_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(fd_init_lock)
static int check_fd(void)
{
@@ -29,12 +29,12 @@ static int check_fd(void)
if (fd >= 0)
return 0;
- ret = pthread_mutex_lock(&fd_init_lock);
+ ret = rte_thread_mutex_lock(&fd_init_lock);
assert(!ret);
/* check again with the lock held */
if (fd < 0)
fd = open(PROCESS_PATH, O_RDWR);
- ret = pthread_mutex_unlock(&fd_init_lock);
+ ret = rte_thread_mutex_unlock(&fd_init_lock);
assert(!ret);
return (fd >= 0) ? 0 : -ENODEV;
}
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 2f48d4036b..bd83cab577 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -10,7 +10,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/eventfd.h>
@@ -48,7 +48,7 @@ static struct rte_dpaa_bus rte_dpaa_bus;
struct netcfg_info *dpaa_netcfg;
/* define a variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa_portal_key;
+static rte_thread_key dpaa_portal_key;
unsigned int dpaa_svr_family;
@@ -316,10 +316,10 @@ int rte_dpaa_portal_init(void *arg)
DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index();
DPAA_PER_LCORE_PORTAL->tid = syscall(SYS_gettid);
- ret = pthread_setspecific(dpaa_portal_key,
+ ret = rte_thread_value_set(dpaa_portal_key,
(void *)DPAA_PER_LCORE_PORTAL);
if (ret) {
- DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
+ DPAA_BUS_LOG(ERR, "rte_thread_value_set failed on core %u"
" (lcore=%u) with ret: %d", cpu, lcore, ret);
dpaa_portal_finish(NULL);
@@ -377,7 +377,7 @@ dpaa_portal_finish(void *arg)
bman_thread_finish();
qman_thread_finish();
- pthread_setspecific(dpaa_portal_key, NULL);
+ rte_thread_value_set(dpaa_portal_key, NULL);
rte_free(dpaa_io_portal);
dpaa_io_portal = NULL;
@@ -453,9 +453,9 @@ rte_dpaa_bus_scan(void)
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
+ ret = rte_thread_key_create(&dpaa_portal_key, dpaa_portal_finish);
if (ret) {
- DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
+ DPAA_BUS_LOG(DEBUG, "Unable to create thread key. (%d)", ret);
dpaa_clean_device_list();
return ret;
}
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index c6f8312a1d..dffbdff666 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
@@ -59,7 +59,7 @@ uint8_t dpaa2_dqrr_size;
uint8_t dpaa2_eqcr_size;
/* Variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa2_portal_key;
+static rte_thread_key dpaa2_portal_key;
/*Stashing Macros default for LS208x*/
static int dpaa2_core_cluster_base = 0x04;
@@ -92,10 +92,9 @@ dpaa2_get_core_id(void)
rte_cpuset_t cpuset;
int i, ret, cpu_id = -1;
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
- DPAA2_BUS_ERR("pthread_getaffinity_np() failed");
+ DPAA2_BUS_ERR("rte_thread_get_affinity_by_id() failed");
return ret;
}
@@ -296,9 +295,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
}
}
- ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
+ ret = rte_thread_value_set(dpaa2_portal_key, (void *)dpio_dev);
if (ret) {
- DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
+ DPAA2_BUS_ERR("rte_thread_value_set failed with ret: %d", ret);
dpaa2_put_qbman_swp(dpio_dev);
return NULL;
}
@@ -357,7 +356,7 @@ static void dpaa2_portal_finish(void *arg)
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
- pthread_setspecific(dpaa2_portal_key, NULL);
+ rte_thread_value_set(dpaa2_portal_key, NULL);
}
static int
@@ -515,10 +514,10 @@ dpaa2_create_dpio_device(int vdev_fd,
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa2_portal_key,
+ ret = rte_thread_key_create(&dpaa2_portal_key,
dpaa2_portal_finish);
if (ret) {
- DPAA2_BUS_DEBUG("Unable to create pthread key (%d)",
+ DPAA2_BUS_DEBUG("Unable to create thread key (%d)",
ret);
goto err;
}
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb..8d53ee4dfc 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <linux/types.h>
#include <stdbool.h>
#include <ctype.h>
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index 3756e1959b..295ef872c0 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <sys/types.h>
+#include <rte_windows.h>
#include <rte_errno.h>
#include "mlx5_autoconf.h"
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 80c564f10b..8f4dbfdbc9 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -72,7 +72,7 @@ struct mlx5_compress_qp {
TAILQ_HEAD(mlx5_compress_privs, mlx5_compress_priv) mlx5_compress_priv_list =
TAILQ_HEAD_INITIALIZER(mlx5_compress_priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
int mlx5_compress_logtype;
@@ -804,9 +804,9 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv,
}
priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr;
priv->mr_scache.dereg_mr_cb = mlx5_common_verbs_dereg_mr;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
}
@@ -826,13 +826,13 @@ mlx5_compress_pci_remove(struct rte_pci_device *pdev)
{
struct mlx5_compress_priv *priv = NULL;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
if (rte_pci_addr_cmp(&priv->pci_dev->addr, &pdev->addr) != 0)
break;
if (priv)
TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (priv) {
mlx5_mr_release_cache(&priv->mr_scache);
mlx5_compress_hw_global_release(priv);
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index eca183753f..bcbf379843 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -5,7 +5,7 @@
#include <assert.h>
#include <errno.h>
#include <nmmintrin.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h b/drivers/event/dlb2/pf/base/dlb2_osdep.h
index cffe22f3c5..82e0c71734 100644
--- a/drivers/event/dlb2/pf/base/dlb2_osdep.h
+++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h
@@ -8,7 +8,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
@@ -194,14 +194,13 @@ static void *dlb2_complete_queue_map_unmap(void *__args)
static inline void os_schedule_work(struct dlb2_hw *hw)
{
struct dlb2_dev *dlb2_dev;
- pthread_t complete_queue_map_unmap_thread;
+ rte_thread_t complete_queue_map_unmap_thread;
int ret;
dlb2_dev = container_of(hw, struct dlb2_dev, hw);
- ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+ ret = rte_thread_ctrl_thread_create(&complete_queue_map_unmap_thread,
"dlb_queue_unmap_waiter",
- NULL,
dlb2_complete_queue_map_unmap,
dlb2_dev);
if (ret)
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index f02056982c..34a1d2b28d 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index eb5660a3dc..0f0837426e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -178,7 +178,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
static inline int
@@ -676,7 +676,7 @@ find_internal_resource(struct pmd_internals *port_int)
if (port_int == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
struct pmd_internals *list_int =
@@ -687,7 +687,7 @@ find_internal_resource(struct pmd_internals *port_int)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -725,7 +725,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
if (mb_pool == NULL)
return ret;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internals = list->eth_dev->data->dev_private;
@@ -751,7 +751,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
}
out:
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return ret;
}
@@ -780,9 +780,9 @@ eth_dev_configure(struct rte_eth_dev *dev)
return -1;
list->eth_dev = dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
}
return 0;
@@ -948,9 +948,9 @@ eth_dev_close(struct rte_eth_dev *dev)
/* Remove ethdev from list used to track and share UMEMs */
list = find_internal_resource(internals);
if (list) {
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 377299b14c..51856f66d1 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -563,12 +563,12 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
ark_pktchkr_run(ark->pc);
if (ark->start_pg && (dev->data->port_id == 0)) {
- pthread_t thread;
+ rte_thread_t thread;
/* Delay packet generatpr start allow the hardware to be ready
* This is only used for sanity checking with internal generator
*/
- if (rte_ctrl_thread_create(&thread, "ark-delay-pg", NULL,
+ if (rte_thread_ctrl_thread_create(&thread, "ark-delay-pg",
ark_pktgen_delay_start, ark->pg)) {
ARK_PMD_LOG(ERR, "Could not create pktgen "
"starter thread\n");
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 515bfe461c..58ff65b5d5 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -3,7 +3,7 @@
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -475,7 +475,7 @@ ark_pktgen_delay_start(void *arg)
* perform a blind sleep here to ensure that the external test
* application has time to setup the test before we generate packets
*/
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
usleep(100000);
ark_pktgen_run(inst);
return NULL;
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 0ce35eb519..2b86f01a25 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -405,7 +405,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
hw->aq_nic_cfg = &adapter->hw_cfg;
- pthread_mutex_init(&hw->mbox_mutex, NULL);
+ rte_thread_mutex_init(&hw->mbox_mutex);
/* disable interrupt */
atl_disable_intr(hw);
@@ -712,7 +712,7 @@ atl_dev_close(struct rte_eth_dev *dev)
rte_intr_callback_unregister(intr_handle,
atl_dev_interrupt_handler, dev);
- pthread_mutex_destroy(&hw->mbox_mutex);
+ rte_thread_mutex_destroy(&hw->mbox_mutex);
return ret;
}
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index e813d9f326..d99aa5fad0 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <netinet/in.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_common.h>
@@ -141,7 +141,7 @@ struct aq_hw_s {
u32 rpc_tid;
struct hw_aq_atl_utils_fw_rpc rpc;
- pthread_mutex_t mbox_mutex;
+ rte_thread_mutex mbox_mutex;
};
struct aq_fw_ops {
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 3a7faf405c..15b80584f8 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -6,7 +6,7 @@
*/
#include <rte_ether.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include "../atl_hw_regs.h"
#include "../atl_types.h"
@@ -218,7 +218,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
u32 mac_addr[2] = { 0 };
u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
if (efuse_addr != 0) {
err = hw_atl_utils_fw_downld_dwords(self,
@@ -257,7 +257,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -269,7 +269,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
u32 orig_stats_val = mpi_opts & BIT(CAPS_HI_STATISTICS);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to update */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_STATISTICS);
@@ -286,7 +286,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
err = hw_atl_utils_update_stats(self);
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
@@ -299,7 +299,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
u32 temp_val = mpi_opts & BIT(CAPS_HI_TEMPERATURE);
u32 temp_res;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_TEMPERATURE);
@@ -317,7 +317,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
sizeof(temp_res) / sizeof(u32));
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
if (err)
return err;
@@ -536,7 +536,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
if ((self->caps_lo & BIT(CAPS_LO_SMBUS_READ)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
request.msg_id = 0;
request.device_id = dev_addr;
@@ -605,7 +605,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -626,7 +626,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
request.address = offset;
request.length = len;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write SMBUS request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -694,7 +694,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -712,7 +712,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
if ((self->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write macsec request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -742,7 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32)));
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
index df0aa21a9b..a7b892b806 100644
--- a/drivers/net/axgbe/axgbe_common.h
+++ b/drivers/net/axgbe/axgbe_common.h
@@ -19,7 +19,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_bitops.h>
#include <rte_byteorder.h>
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 786288a7b0..197c722901 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -167,12 +167,12 @@ static int axgbe_read_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
mmd_data = XPCS16_IOREAD(pdata, offset);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
return mmd_data;
}
@@ -201,12 +201,12 @@ static void axgbe_write_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
XPCS16_IOWRITE(pdata, offset, mmd_data);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
}
static int axgbe_read_mmd_regs(struct axgbe_port *pdata, int prtad,
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 9cb4818af1..caf5a4476f 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -2311,10 +2311,10 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
pdata->tx_desc_count = AXGBE_MAX_RING_DESC;
pdata->rx_desc_count = AXGBE_MAX_RING_DESC;
- pthread_mutex_init(&pdata->xpcs_mutex, NULL);
- pthread_mutex_init(&pdata->i2c_mutex, NULL);
- pthread_mutex_init(&pdata->an_mutex, NULL);
- pthread_mutex_init(&pdata->phy_mutex, NULL);
+ rte_thread_mutex_init(&pdata->xpcs_mutex);
+ rte_thread_mutex_init(&pdata->i2c_mutex);
+ rte_thread_mutex_init(&pdata->an_mutex);
+ rte_thread_mutex_init(&pdata->phy_mutex);
ret = pdata->phy_if.phy_init(pdata);
if (ret) {
diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h
index a6226729fe..f2929d57ab 100644
--- a/drivers/net/axgbe/axgbe_ethdev.h
+++ b/drivers/net/axgbe/axgbe_ethdev.h
@@ -602,10 +602,10 @@ struct axgbe_port {
int phy_link;
int phy_speed;
- pthread_mutex_t xpcs_mutex;
- pthread_mutex_t i2c_mutex;
- pthread_mutex_t an_mutex;
- pthread_mutex_t phy_mutex;
+ rte_thread_mutex xpcs_mutex;
+ rte_thread_mutex i2c_mutex;
+ rte_thread_mutex an_mutex;
+ rte_thread_mutex phy_mutex;
/* Flow control settings */
unsigned int pause_autoneg;
diff --git a/drivers/net/axgbe/axgbe_i2c.c b/drivers/net/axgbe/axgbe_i2c.c
index ab3738a12e..c17f9a8b9e 100644
--- a/drivers/net/axgbe/axgbe_i2c.c
+++ b/drivers/net/axgbe/axgbe_i2c.c
@@ -229,7 +229,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
int ret;
uint64_t timeout;
- pthread_mutex_lock(&pdata->i2c_mutex);
+ rte_thread_mutex_lock(&pdata->i2c_mutex);
ret = axgbe_i2c_disable(pdata);
if (ret) {
PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
@@ -282,7 +282,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
}
unlock:
- pthread_mutex_unlock(&pdata->i2c_mutex);
+ rte_thread_mutex_unlock(&pdata->i2c_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c
index 4f98e695ae..5f3d9b360e 100644
--- a/drivers/net/axgbe/axgbe_mdio.c
+++ b/drivers/net/axgbe/axgbe_mdio.c
@@ -686,9 +686,9 @@ static void axgbe_an73_isr(struct axgbe_port *pdata)
if (pdata->an_int) {
/* Clear the interrupt(s) that fired and process them */
XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, ~pdata->an_int);
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
axgbe_an73_state_machine(pdata);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
} else {
/* Enable AN interrupts */
axgbe_an73_enable_interrupts(pdata);
@@ -977,7 +977,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
{
int ret;
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
ret = __axgbe_phy_config_aneg(pdata);
if (ret)
@@ -985,7 +985,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
else
rte_bit_relaxed_clear32(AXGBE_LINK_ERR, &pdata->dev_state);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 02236ec192..1e1d6358d8 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -403,7 +403,7 @@ static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata)
phy_data->comm_owned = 0;
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
}
static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
@@ -416,7 +416,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
* the driver needs to take the software mutex and then the hardware
* mutexes before being able to use the busses.
*/
- pthread_mutex_lock(&pdata->phy_mutex);
+ rte_thread_mutex_lock(&pdata->phy_mutex);
if (phy_data->comm_owned)
return 0;
@@ -447,7 +447,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
return 0;
}
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
PMD_DRV_LOG(ERR, "unable to obtain hardware mutexes\n");
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index db67bff127..656ee70f66 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -534,8 +534,8 @@ struct bnxt_mark_info {
struct bnxt_rep_info {
struct rte_eth_dev *vfr_eth_dev;
- pthread_mutex_t vfr_lock;
- pthread_mutex_t vfr_start_lock;
+ rte_thread_mutex vfr_lock;
+ rte_thread_mutex vfr_start_lock;
bool conduit_valid;
};
@@ -687,7 +687,7 @@ struct bnxt {
#define BNXT_FW_CAP_ADV_FLOW_COUNTERS BIT(6)
#define BNXT_FW_CAP_LINK_ADMIN BIT(7)
- pthread_mutex_t flow_lock;
+ rte_thread_mutex flow_lock;
uint32_t vnic_cap_flags;
#define BNXT_VNIC_CAP_COS_CLASSIFY BIT(0)
@@ -741,18 +741,18 @@ struct bnxt {
rte_iova_t hwrm_short_cmd_req_dma_addr;
rte_spinlock_t hwrm_lock;
/* synchronize between dev_configure_op and int handler */
- pthread_mutex_t def_cp_lock;
+ rte_thread_mutex def_cp_lock;
/* synchronize between dev_start_op and async evt handler
* Locking sequence in async evt handler will be
* def_cp_lock
* health_check_lock
*/
- pthread_mutex_t health_check_lock;
+ rte_thread_mutex health_check_lock;
/* synchronize between dev_stop/dev_close_op and
* error recovery thread triggered as part of
* HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY
*/
- pthread_mutex_t err_recovery_lock;
+ rte_thread_mutex err_recovery_lock;
uint16_t max_req_len;
uint16_t max_resp_len;
uint16_t hwrm_max_ext_req_len;
@@ -944,10 +944,10 @@ uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
extern const struct rte_flow_ops bnxt_flow_ops;
#define bnxt_acquire_flow_lock(bp) \
- pthread_mutex_lock(&(bp)->flow_lock)
+ rte_thread_mutex_lock(&(bp)->flow_lock)
#define bnxt_release_flow_lock(bp) \
- pthread_mutex_unlock(&(bp)->flow_lock)
+ rte_thread_mutex_unlock(&(bp)->flow_lock)
#define BNXT_VALID_VNIC_OR_RET(bp, vnic_id) do { \
if ((vnic_id) >= (bp)->max_vnics) { \
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 2c7fd78c3d..a50511047c 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -135,7 +135,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
return;
}
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
event_data = rte_le_to_cpu_32(async_cmp->event_data1);
/* timestamp_lo/hi values are in units of 100ms */
bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
@@ -157,7 +157,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
}
bp->flags |= BNXT_FLAG_FW_RESET;
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
(void *)bp);
break;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3778e28cca..ae355f4a36 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1049,7 +1049,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
* are calculated correctly.
*/
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
bnxt_disable_int(bp);
@@ -1059,20 +1059,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return -ENOSPC;
}
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
rc = bnxt_alloc_async_cp_ring(bp);
if (rc) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return rc;
}
bnxt_enable_int(bp);
}
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
/* Inherit new configurations */
@@ -1456,14 +1456,14 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error..Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return bnxt_dev_stop(eth_dev);
}
@@ -1545,13 +1545,13 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
static void
bnxt_uninit_locks(struct bnxt *bp)
{
- pthread_mutex_destroy(&bp->flow_lock);
- pthread_mutex_destroy(&bp->def_cp_lock);
- pthread_mutex_destroy(&bp->health_check_lock);
- pthread_mutex_destroy(&bp->err_recovery_lock);
+ rte_thread_mutex_destroy(&bp->flow_lock);
+ rte_thread_mutex_destroy(&bp->def_cp_lock);
+ rte_thread_mutex_destroy(&bp->health_check_lock);
+ rte_thread_mutex_destroy(&bp->err_recovery_lock);
if (bp->rep_info) {
- pthread_mutex_destroy(&bp->rep_info->vfr_lock);
- pthread_mutex_destroy(&bp->rep_info->vfr_start_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_start_lock);
}
}
@@ -1583,14 +1583,14 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error...Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
/* cancel the recovery handler before remove dev */
rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp);
@@ -4073,7 +4073,7 @@ static void bnxt_dev_recover(void *arg)
struct bnxt *bp = arg;
int rc = 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (!bp->fw_reset_min_msecs) {
rc = bnxt_check_fw_reset_done(bp);
@@ -4108,7 +4108,7 @@ static void bnxt_dev_recover(void *arg)
goto err_start;
PMD_DRV_LOG(INFO, "Recovered from FW reset\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return;
err_start:
@@ -4116,7 +4116,7 @@ static void bnxt_dev_recover(void *arg)
err:
bp->flags |= BNXT_FLAG_FATAL_ERROR;
bnxt_uninit_resources(bp, false);
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
PMD_DRV_LOG(ERR, "Failed to recover from FW reset\n");
}
@@ -4292,7 +4292,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
{
uint32_t polling_freq;
- pthread_mutex_lock(&bp->health_check_lock);
+ rte_thread_mutex_lock(&bp->health_check_lock);
if (!bnxt_is_recovery_enabled(bp))
goto done;
@@ -4307,7 +4307,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
done:
- pthread_mutex_unlock(&bp->health_check_lock);
+ rte_thread_mutex_unlock(&bp->health_check_lock);
}
static void bnxt_cancel_fw_health_check(struct bnxt *bp)
@@ -5093,25 +5093,25 @@ bnxt_init_locks(struct bnxt *bp)
{
int err;
- err = pthread_mutex_init(&bp->flow_lock, NULL);
+ err = rte_thread_mutex_init(&bp->flow_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->def_cp_lock, NULL);
+ err = rte_thread_mutex_init(&bp->def_cp_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->health_check_lock, NULL);
+ err = rte_thread_mutex_init(&bp->health_check_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize health_check_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
+ err = rte_thread_mutex_init(&bp->err_recovery_lock);
if (err)
PMD_DRV_LOG(ERR, "Unable to initialize err_recovery_lock\n");
@@ -5894,14 +5894,14 @@ static int bnxt_init_rep_info(struct bnxt *bp)
for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
- rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_lock\n");
bnxt_free_rep_info(bp);
return rc;
}
- rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_start_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_start_lock\n");
bnxt_free_rep_info(bp);
diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 8abbadb3d1..e1d980cf91 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -30,15 +30,15 @@ void bnxt_int_handler(void *param)
return;
raw_cons = cpr->cp_raw_cons;
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
while (1) {
if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
if (is_bnxt_in_error(bp)) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
@@ -58,7 +58,7 @@ void bnxt_int_handler(void *param)
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
int bnxt_free_int(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index bdbad53b7d..49d3ec66bc 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -120,7 +120,7 @@ bnxt_rep_tx_burst(void *tx_queue,
qid = vfr_txq->txq->queue_id;
vf_rep_bp = vfr_txq->bp;
parent = vf_rep_bp->parent_dev->data->dev_private;
- pthread_mutex_lock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_lock(&parent->rep_info->vfr_lock);
ptxq = parent->tx_queues[qid];
ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
@@ -132,7 +132,7 @@ bnxt_rep_tx_burst(void *tx_queue,
rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
ptxq->vfr_tx_cfa_action = 0;
- pthread_mutex_unlock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_unlock(&parent->rep_info->vfr_lock);
return rc;
}
@@ -407,15 +407,15 @@ int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
rep_info = &parent_bp->rep_info[rep_bp->vf_id];
BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR start\n", eth_dev->data->port_id);
- pthread_mutex_lock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_lock(&rep_info->vfr_start_lock);
if (!rep_info->conduit_valid) {
rc = bnxt_get_dflt_vnic_svif(parent_bp, rep_bp);
if (rc || !rep_info->conduit_valid) {
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
return rc;
}
}
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
rc = bnxt_vfr_alloc(eth_dev);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 5c805eef97..6691fc2fd7 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -28,7 +28,7 @@ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
STAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);
/* Mutex to synchronize bnxt_ulp_session_list operations. */
-static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(bnxt_ulp_global_mutex)
/*
* Allow the deletion of context only for the bnxt device that
@@ -640,7 +640,7 @@ ulp_ctx_detach(struct bnxt *bp)
static void
ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
{
- pthread_mutex_lock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_lock(&session->bnxt_ulp_mutex);
if (!session->bnxt_ulp_init) {
session->bnxt_ulp_init = true;
@@ -649,7 +649,7 @@ ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
*init = true;
}
- pthread_mutex_unlock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_unlock(&session->bnxt_ulp_mutex);
}
/*
@@ -690,7 +690,7 @@ ulp_session_init(struct bnxt *bp,
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
if (!session) {
@@ -701,17 +701,17 @@ ulp_session_init(struct bnxt *bp,
if (!session) {
BNXT_TF_DBG(ERR,
"Allocation failed for bnxt_ulp_session\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
} else {
/* Add it to the queue */
session->pci_info.domain = pci_addr->domain;
session->pci_info.bus = pci_addr->bus;
- rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
+ rc = rte_thread_mutex_init(&session->bnxt_ulp_mutex);
if (rc) {
BNXT_TF_DBG(ERR, "mutex create failed\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
}
STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
@@ -719,7 +719,7 @@ ulp_session_init(struct bnxt *bp,
}
}
ulp_context_initialized(session, init);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return session;
}
@@ -734,12 +734,12 @@ ulp_session_deinit(struct bnxt_ulp_session_state *session)
return;
if (!session->cfg_data) {
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
STAILQ_REMOVE(&bnxt_ulp_session_list, session,
bnxt_ulp_session_state, next);
- pthread_mutex_destroy(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_destroy(&session->bnxt_ulp_mutex);
rte_free(session);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
}
}
@@ -892,7 +892,7 @@ bnxt_ulp_deinit(struct bnxt *bp,
BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0);
/* free the flow db lock */
- pthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
/* Delete the ulp context and tf session and free the ulp context */
ulp_ctx_deinit(bp, session);
@@ -917,7 +917,7 @@ bnxt_ulp_init(struct bnxt *bp,
goto jump_to_error;
}
- rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (rc) {
BNXT_TF_DBG(ERR, "Unable to initialize flow db lock\n");
goto jump_to_error;
@@ -1117,9 +1117,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp)
/* Get the session details */
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
/* session not found then just exit */
if (!session) {
@@ -1451,7 +1451,7 @@ bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return -1;
- if (pthread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
+ if (rte_thread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
BNXT_TF_DBG(ERR, "unable to acquire fdb lock\n");
return -1;
}
@@ -1465,5 +1465,5 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return;
- pthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
}
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 330965061a..86680f2f46 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -49,7 +49,7 @@ struct bnxt_ulp_data {
uint32_t dev_id; /* Hardware device id */
uint32_t ref_cnt;
struct bnxt_ulp_flow_db *flow_db;
- pthread_mutex_t flow_db_lock;
+ rte_thread_mutex flow_db_lock;
void *mapper_data;
struct bnxt_ulp_port_db *port_db;
struct bnxt_ulp_fc_info *fc_info;
@@ -75,7 +75,7 @@ struct bnxt_ulp_pci_info {
struct bnxt_ulp_session_state {
STAILQ_ENTRY(bnxt_ulp_session_state) next;
bool bnxt_ulp_init;
- pthread_mutex_t bnxt_ulp_mutex;
+ rte_thread_mutex bnxt_ulp_mutex;
struct bnxt_ulp_pci_info pci_info;
struct bnxt_ulp_data *cfg_data;
struct tf *g_tfp;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 3eddbd6831..94fe39d7a3 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -3,6 +3,7 @@
* All rights reserved.
*/
+#include <pthread.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
@@ -84,7 +85,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
if (!ulp_fc_info)
goto error;
- rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
+ rc = rte_thread_mutex_init(&ulp_fc_info->fc_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize fc mutex\n");
goto error;
@@ -141,7 +142,7 @@ ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt)
ulp_fc_mgr_thread_cancel(ctxt);
- pthread_mutex_destroy(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_destroy(&ulp_fc_info->fc_lock);
for (i = 0; i < TF_DIR_MAX; i++)
rte_free(ulp_fc_info->sw_acc_tbl[i]);
@@ -379,11 +380,12 @@ ulp_fc_mgr_alarm_cb(void *arg)
* Take the fc_lock to ensure no flow is destroyed
* during the bulk get
*/
- if (pthread_mutex_trylock(&ulp_fc_info->fc_lock))
+ if (pthread_mutex_trylock((pthread_mutex_t *)
+ &ulp_fc_info->fc_lock.mutex_id))
goto out;
if (!ulp_fc_info->num_entries) {
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
ulp_fc_mgr_thread_cancel(ctxt);
return;
}
@@ -414,7 +416,7 @@ ulp_fc_mgr_alarm_cb(void *arg)
}
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
/*
* If cmd fails once, no need of
@@ -503,12 +505,12 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = true;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = hw_cntr_id;
ulp_fc_info->num_entries++;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -535,14 +537,14 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = false;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].pkt_count = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].byte_count = 0;
ulp_fc_info->num_entries--;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -607,7 +609,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
hw_cntr_id = params.resource_hndl;
if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id -
ulp_fc_info->shadow_hw_tbl[dir].start_idx;
sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
@@ -621,7 +623,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
sw_acc_tbl_entry->pkt_count = 0;
sw_acc_tbl_entry->byte_count = 0;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
} else if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT_ACC) {
/* Get stats from the parent child table */
@@ -663,7 +665,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
if (ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid) {
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].parent_flow_id = fid;
@@ -672,7 +674,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
hw_cntr_id, fid);
rc = -ENOENT;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return rc;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index 04cb86bea2..cfc8ea29d8 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -47,7 +47,7 @@ struct bnxt_ulp_fc_info {
struct hw_fc_mem_info shadow_hw_tbl[TF_DIR_MAX];
uint32_t flags;
uint32_t num_entries;
- pthread_mutex_t fc_lock;
+ rte_thread_mutex fc_lock;
};
int32_t
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 27d670f843..0983630f5e 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 423de40e95..55eb14af5f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <limits.h>
#include <sched.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_byteorder.h>
#include <rte_common.h>
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index f66df95591..7ddcbc1ac4 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
@@ -148,14 +149,14 @@ extern int ena_logtype_com;
typedef struct {
pthread_cond_t cond;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
uint8_t flag;
} ena_wait_event_t;
#define ENA_WAIT_EVENT_INIT(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_init(&_we->mutex, NULL); \
+ rte_thread_mutex_init(&_we->mutex); \
pthread_cond_init(&_we->cond, NULL); \
_we->flag = 0; \
} while (0)
@@ -172,10 +173,10 @@ typedef struct {
wait.tv_sec = now.tv_sec + _tmo / 1000000UL; \
timeout_us = _tmo % 1000000UL; \
wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
while (ret == 0 && !_we->flag) { \
ret = pthread_cond_timedwait(&_we->cond, \
- &_we->mutex, &wait); \
+ _we->mutex.mutex_id, &wait); \
} \
/* Asserts only if not working on ena_wait_event_t */ \
if (unlikely(ret != 0 && ret != ETIMEDOUT)) \
@@ -185,15 +186,15 @@ typedef struct {
ena_trc_err(NULL, \
"Timeout waiting for " #waitevent "\n"); \
_we->flag = 0; \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
#define ENA_WAIT_EVENT_SIGNAL(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
_we->flag = 1; \
pthread_cond_signal(&_we->cond); \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
/* pthread condition doesn't need to be rearmed after usage */
#define ENA_WAIT_EVENT_CLEAR(...)
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 47bfdac2cf..db07c589b9 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -107,7 +107,7 @@ struct enic {
int iommu_groupid;
int eventfd;
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
- pthread_t err_intr_thread;
+ rte_thread_t err_intr_thread;
int promisc;
int allmulti;
uint8_t ig_vlan_strip_en;
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index 1d7aa8bc87..5fd769a82d 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -3,7 +3,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <unistd.h>
#include <rte_spinlock.h>
@@ -121,7 +121,7 @@ ice_dcf_vsi_update_service_handler(void *param)
struct ice_dcf_hw *hw = reset_param->dcf_hw;
struct ice_dcf_adapter *adapter;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL);
@@ -156,7 +156,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
#define THREAD_NAME_LEN 16
struct ice_dcf_reset_event_param *param;
char name[THREAD_NAME_LEN];
- pthread_t thread;
+ rte_thread_t thread;
int ret;
param = malloc(sizeof(*param));
@@ -170,7 +170,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
param->vf_id = vf_id;
snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
- ret = rte_ctrl_thread_create(&thread, name, NULL,
+ ret = rte_thread_ctrl_thread_create(&thread, name,
ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b5371568b5..cf7b19edc0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4156,7 +4156,7 @@ ixgbe_dev_setup_link_thread_handler(void *param)
u32 speed;
bool autoneg = false;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
speed = hw->phy.autoneg_advertised;
if (!speed)
ixgbe_get_link_capabilities(hw, &speed, &autoneg);
@@ -4264,9 +4264,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
* when there is no link thread running.
*/
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
- if (rte_ctrl_thread_create(&ad->link_thread_tid,
+ if (rte_thread_ctrl_thread_create
+ (&ad->link_thread_tid,
"ixgbe-link-handler",
- NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index a0ce18ca24..272fdcfb8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -516,7 +516,7 @@ struct ixgbe_adapter {
uint8_t pflink_fullchk;
uint8_t mac_ctrl_frame_fwd;
rte_atomic32_t link_thread_running;
- pthread_t link_thread_tid;
+ rte_thread_t link_thread_tid;
};
struct ixgbe_vf_representor {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 534a56a555..15080bbc1c 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2557,7 +2557,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
sh->numa_node = spawn->pci_dev->device.numa_node;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/*
* Configure environment variable "MLX5_BF_SHUT_UP"
* before the device creation. The rdma_core library
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cf1815cb74..375fcde4df 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -183,7 +183,7 @@ int mlx5_logtype;
static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
LIST_HEAD_INITIALIZER();
-static pthread_mutex_t mlx5_dev_ctx_list_mutex;
+static rte_thread_mutex mlx5_dev_ctx_list_mutex;
static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
[MLX5_IPOOL_DECAP_ENCAP] = {
@@ -1088,7 +1088,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
MLX5_ASSERT(spawn);
/* Secondary process should not create the shared context. */
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
/* Search for IB context by device name. */
LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
if (!strcmp(sh->ibdev_name,
@@ -1215,11 +1215,11 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
LIST_INSERT_HEAD(&mlx5_dev_ctx_list, sh, next);
rte_spinlock_init(&sh->geneve_tlv_opt_sl);
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
return sh;
error:
- pthread_mutex_destroy(&sh->txpp.mutex);
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
MLX5_ASSERT(sh);
if (sh->cnt_id_tbl)
mlx5_l3t_destroy(sh->cnt_id_tbl);
@@ -1251,7 +1251,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
void
mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
{
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Check the object presence in the list. */
struct mlx5_dev_ctx_shared *lctx;
@@ -1282,7 +1282,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
/* Release flow workspaces objects on the last device. */
if (LIST_EMPTY(&mlx5_dev_ctx_list))
mlx5_flow_os_release_workspace();
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.
* Only primary process handles async device events.
@@ -1315,11 +1315,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
if (sh->ctx)
claim_zero(mlx5_glue->close_device(sh->ctx));
MLX5_ASSERT(sh->geneve_tlv_option_resource == NULL);
- pthread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
mlx5_free(sh);
return;
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
}
/**
@@ -2450,7 +2450,7 @@ RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
*/
RTE_INIT(rte_mlx5_pmd_init)
{
- pthread_mutex_init(&mlx5_dev_ctx_list_mutex, NULL);
+ rte_thread_mutex_init(&mlx5_dev_ctx_list_mutex);
mlx5_common_init();
/* Build the static tables for Verbs conversion. */
mlx5_set_ptype_table();
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 32b2817bf2..ecc4ed204a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -949,7 +949,7 @@ struct mlx5_txpp_ts {
/* Tx packet pacing structure. */
struct mlx5_dev_txpp {
- pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
+ rte_thread_mutex mutex; /* Pacing create/destroy mutex. */
uint32_t refcnt; /* Pacing reference counter. */
uint32_t freq; /* Timestamp frequency, Hz. */
uint32_t tick; /* Completion tick duration in nanoseconds. */
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index d90399afb5..e308c5e599 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -905,7 +905,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
if (ret < 0)
return 0;
}
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
if (sh->txpp.refcnt) {
@@ -921,7 +921,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
rte_errno = -err;
}
}
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
return err;
@@ -948,7 +948,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
}
priv->txpp_en = 0;
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
MLX5_ASSERT(sh->txpp.refcnt);
@@ -956,7 +956,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
/* No references any more, do actual destroy. */
mlx5_txpp_destroy(sh);
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
}
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index c4d5790726..ccdb0184a9 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -253,7 +253,7 @@ struct mlx5_workspace_thread {
static struct mlx5_workspace_thread *curr;
static struct mlx5_workspace_thread *first;
rte_thread_key ws_tls_index;
-static pthread_mutex_t lock_thread_list;
+RTE_STATIC_MUTEX(lock_thread_list)
static bool
mlx5_is_thread_alive(HANDLE thread_handle)
@@ -330,7 +330,7 @@ mlx5_flow_os_release_workspace(void)
free(first);
}
rte_thread_key_delete(ws_tls_index);
- pthread_mutex_destroy(&lock_thread_list);
+ rte_thread_mutex_destroy(&lock_thread_list);
}
static int
@@ -352,7 +352,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
}
temp->mlx5_ws = data;
temp->thread_handle = curr_thread;
- pthread_mutex_lock(&lock_thread_list);
+ rte_thread_mutex_lock(&lock_thread_list);
mlx5_clear_thread_list();
if (!first) {
first = temp;
@@ -361,7 +361,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
curr->next = temp;
curr = curr->next;
}
- pthread_mutex_unlock(&lock_thread_list);
+ rte_thread_mutex_unlock(&lock_thread_list);
return 0;
}
@@ -374,7 +374,7 @@ mlx5_flow_os_init_workspace_once(void)
DRV_LOG(ERR, "Can't create flow workspace data thread key.");
return err;
}
- pthread_mutex_init(&lock_thread_list, NULL);
+ rte_thread_mutex_init(&lock_thread_list);
return 0;
}
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 3fe3f55f49..e37e16d70f 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -228,7 +228,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
struct mlx5_context *mlx5_ctx;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/* Set numa node from pci probe */
sh->numa_node = spawn->pci_dev->device.numa_node;
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index c5b5399282..c9011d964b 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -153,10 +153,10 @@ void osal_dma_free_mem(struct ecore_dev *edev, dma_addr_t phys);
/* Mutexes */
-typedef pthread_mutex_t osal_mutex_t;
-#define OSAL_MUTEX_RELEASE(lock) pthread_mutex_unlock(lock)
-#define OSAL_MUTEX_INIT(lock) pthread_mutex_init(lock, NULL)
-#define OSAL_MUTEX_ACQUIRE(lock) pthread_mutex_lock(lock)
+typedef rte_thread_mutex osal_mutex_t;
+#define OSAL_MUTEX_RELEASE(lock) rte_thread_mutex_unlock(lock)
+#define OSAL_MUTEX_INIT(lock) rte_thread_mutex_init(lock)
+#define OSAL_MUTEX_ACQUIRE(lock) rte_thread_mutex_lock(lock)
#define OSAL_MUTEX_ALLOC(hwfn, lock) nothing
#define OSAL_MUTEX_DEALLOC(lock) nothing
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index a202931e9a..484b647a62 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -3,7 +3,7 @@
* Copyright(c) 2016-2018 Intel Corporation
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdbool.h>
#include <sys/epoll.h>
@@ -121,7 +121,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static struct rte_eth_link pmd_link = {
.link_speed = 10000,
@@ -507,7 +507,7 @@ find_internal_resource(char *ifname)
if (ifname == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internal = list->eth_dev->data->dev_private;
@@ -517,7 +517,7 @@ find_internal_resource(char *ifname)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -1001,9 +1001,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
goto free_list;
list->eth_dev = eth_dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_spinlock_init(&vring_state->lock);
vring_states[eth_dev->data->port_id] = vring_state;
@@ -1035,9 +1035,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
rte_vhost_driver_unregister(internal->iface_name);
list_remove:
vring_states[eth_dev->data->port_id] = NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(vring_state);
free_list:
rte_free(list);
@@ -1093,7 +1093,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
if (!rte_eth_dev_is_valid_port(port_id))
return -1;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
eth_dev = list->eth_dev;
@@ -1106,7 +1106,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return vid;
}
@@ -1184,9 +1184,9 @@ eth_dev_close(struct rte_eth_dev *dev)
list = find_internal_resource(internal->iface_name);
if (list) {
rte_vhost_driver_unregister(internal->iface_name);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 364f43e21c..9231da676b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -143,7 +143,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
uint64_t features;
int ret = -1;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 0: tell vhost to create queues */
if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
@@ -161,7 +161,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
goto error;
PMD_DRV_LOG(INFO, "(%s) set features: 0x%" PRIx64, dev->path, features);
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -185,7 +185,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
* memory subsystem in the future.
*/
rte_mcfg_mem_read_lock();
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 2: share memory regions */
ret = dev->ops->set_memory_table(dev);
@@ -206,12 +206,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
dev->started = true;
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
return 0;
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
PMD_INIT_LOG(ERR, "(%s) Failed to start device\n", dev->path);
@@ -226,7 +226,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
uint32_t i;
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (!dev->started)
goto out;
@@ -249,11 +249,11 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
dev->started = false;
out:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return 0;
err:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
PMD_INIT_LOG(ERR, "(%s) Failed to stop device\n", dev->path);
@@ -380,7 +380,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
if (msl->external)
return;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (dev->started == false)
goto exit;
@@ -405,7 +405,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
}
exit:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
if (ret < 0)
PMD_DRV_LOG(ERR, "(%s) Failed to update memory table\n", dev->path);
@@ -491,7 +491,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
uint64_t backend_features;
int i;
- pthread_mutex_init(&dev->mutex, NULL);
+ rte_thread_mutex_init(&dev->mutex);
strlcpy(dev->path, path, PATH_MAX);
for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; i++) {
@@ -796,13 +796,13 @@ virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status)
{
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
dev->status = status;
ret = dev->ops->set_status(dev, status);
if (ret && ret != -ENOTSUP)
PMD_INIT_LOG(ERR, "(%s) Failed to set backend status\n", dev->path);
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -812,7 +812,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
int ret;
uint8_t status;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
ret = dev->ops->get_status(dev, &status);
if (!ret) {
@@ -837,7 +837,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
PMD_INIT_LOG(ERR, "(%s) Failed to get backend status\n", dev->path);
}
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 58ad5198b6..9de8f5e67b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -55,7 +55,7 @@ struct virtio_user_dev {
bool qp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];
struct virtio_user_backend_ops *ops;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
bool started;
void *backend_data;
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 1dc813d0a3..81ff6c2d58 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -23,6 +23,7 @@
#include <rte_log.h>
#include <rte_kvargs.h>
#include <rte_devargs.h>
+#include <rte_thread.h>
#include "base/ifcvf.h"
@@ -52,7 +53,7 @@ struct ifcvf_internal {
int vfio_container_fd;
int vfio_group_fd;
int vfio_dev_fd;
- pthread_t tid; /* thread for notify relay */
+ rte_thread_t tid; /* thread for notify relay */
int epfd;
int vid;
struct rte_vdpa_device *vdev;
@@ -79,7 +80,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static void update_used_ring(struct ifcvf_internal *internal, uint16_t qid);
@@ -89,7 +90,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (vdev == list->internal->vdev) {
@@ -98,7 +99,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -112,7 +113,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (!rte_pci_addr_cmp(&pdev->addr,
@@ -122,7 +123,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -500,10 +501,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, notify_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create notify relay pthread.");
+ DRV_LOG(ERR, "failed to create notify relay thread.");
return -1;
}
@@ -513,13 +514,11 @@ setup_notify_relay(struct ifcvf_internal *internal)
static int
unset_notify_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -806,10 +805,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, vring_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create ring relay pthread.");
+ DRV_LOG(ERR, "failed to create ring relay thread.");
return -1;
}
@@ -819,13 +818,11 @@ setup_vring_relay(struct ifcvf_internal *internal)
static int
unset_vring_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -1253,9 +1250,9 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto error;
}
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_atomic32_set(&internal->started, 1);
update_datapath(internal);
@@ -1293,9 +1290,9 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
rte_vfio_container_destroy(internal->vfio_container_fd);
rte_vdpa_unregister_device(internal->vdev);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
rte_free(internal);
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index e5e03e6582..c7a6fee2c7 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -48,7 +48,7 @@
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
static struct mlx5_vdpa_priv *
mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
@@ -56,14 +56,14 @@ mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
struct mlx5_vdpa_priv *priv;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (vdev == priv->vdev) {
found = 1;
break;
}
}
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (!found) {
DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name);
rte_errno = EINVAL;
@@ -143,9 +143,9 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)
DRV_LOG(ERR, "Too big vring id: %d.", vring);
return -E2BIG;
}
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
ret = mlx5_vdpa_virtq_enable(priv, vring, state);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
return ret;
}
@@ -296,7 +296,7 @@ mlx5_vdpa_dev_close(int vid)
priv->configured = 0;
priv->vid = 0;
/* The mutex may stay locked after event thread cancel - initiate it. */
- pthread_mutex_init(&priv->vq_config_lock, NULL);
+ rte_thread_mutex_init(&priv->vq_config_lock);
DRV_LOG(INFO, "vDPA device %d was closed.", vid);
return ret;
}
@@ -736,10 +736,10 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
mlx5_vdpa_config_get(pci_dev->device.devargs, priv);
SLIST_INIT(&priv->mr_list);
- pthread_mutex_init(&priv->vq_config_lock, NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_init(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
error:
@@ -770,7 +770,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
struct mlx5_vdpa_priv *priv = NULL;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (!rte_pci_addr_cmp(&priv->pci_dev->addr, &pci_dev->addr)) {
found = 1;
@@ -779,7 +779,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
}
if (found)
TAILQ_REMOVE(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (found) {
if (priv->configured)
mlx5_vdpa_dev_close(priv->vid);
@@ -790,7 +790,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
if (priv->vdev)
rte_vdpa_unregister_device(priv->vdev);
mlx5_glue->close_device(priv->ctx);
- pthread_mutex_destroy(&priv->vq_config_lock);
+ rte_thread_mutex_destroy(&priv->vq_config_lock);
rte_free(priv);
}
return 0;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h
index 722c72b65e..e44125ec3f 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.h
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h
@@ -119,9 +119,9 @@ enum {
struct mlx5_vdpa_priv {
TAILQ_ENTRY(mlx5_vdpa_priv) next;
uint8_t configured;
- pthread_mutex_t vq_config_lock;
+ rte_thread_mutex vq_config_lock;
uint64_t no_traffic_counter;
- pthread_t timer_tid;
+ rte_thread_t timer_tid;
int event_mode;
int event_core; /* Event thread cpu affinity core. */
uint32_t event_us;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 88f6a4256d..992dcd9702 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -285,7 +285,7 @@ mlx5_vdpa_event_handle(void *arg)
case MLX5_VDPA_EVENT_MODE_FIXED_TIMER:
priv->timer_delay_us = priv->event_us;
while (1) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
max = mlx5_vdpa_queues_complete(priv);
if (max == 0 && priv->no_traffic_counter++ >=
priv->no_traffic_max) {
@@ -293,10 +293,10 @@ mlx5_vdpa_event_handle(void *arg)
priv->vdev->device->name);
mlx5_vdpa_arm_all_cqs(priv);
do {
- pthread_mutex_unlock
+ rte_thread_mutex_unlock
(&priv->vq_config_lock);
cq = mlx5_vdpa_event_wait(priv);
- pthread_mutex_lock
+ rte_thread_mutex_lock
(&priv->vq_config_lock);
if (cq == NULL ||
mlx5_vdpa_queue_complete(cq) > 0)
@@ -307,7 +307,7 @@ mlx5_vdpa_event_handle(void *arg)
} else if (max != 0) {
priv->no_traffic_counter = 0;
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
mlx5_vdpa_timer_sleep(priv, max);
}
return NULL;
@@ -315,10 +315,10 @@ mlx5_vdpa_event_handle(void *arg)
do {
cq = mlx5_vdpa_event_wait(priv);
if (cq != NULL) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
if (mlx5_vdpa_queue_complete(cq) > 0)
mlx5_vdpa_cq_arm(priv, cq);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
}
} while (1);
return NULL;
@@ -340,7 +340,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
struct mlx5_vdpa_virtq *virtq;
uint64_t sec;
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
while (mlx5_glue->devx_get_event(priv->err_chnl, &out.event_resp,
sizeof(out.buf)) >=
(ssize_t)sizeof(out.event_resp.cookie)) {
@@ -386,7 +386,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
virtq->err_time[i - 1] = virtq->err_time[i];
virtq->err_time[RTE_DIM(virtq->err_time) - 1] = rte_rdtsc();
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
#endif
}
@@ -473,28 +473,23 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
{
int ret;
rte_cpuset_t cpuset;
- pthread_attr_t attr;
+ rte_thread_attr_t attr;
char name[16];
- const struct sched_param sp = {
- .sched_priority = sched_get_priority_max(SCHED_RR),
- };
if (!priv->eventc)
/* All virtqs are in poll mode. */
return 0;
- pthread_attr_init(&attr);
- ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
- if (ret) {
- DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
- return -1;
- }
- ret = pthread_attr_setschedparam(&attr, &sp);
+
+ rte_thread_attr_init(&attr);
+ ret = rte_thread_attr_set_priority(&attr,
+ RTE_THREAD_PRIORITY_REALTIME_CRITICAL);
if (ret) {
DRV_LOG(ERR, "Failed to set thread priority.");
return -1;
}
- ret = pthread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
- (void *)priv);
+
+ ret = rte_thread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
+ (void *)priv);
if (ret) {
DRV_LOG(ERR, "Failed to create timer thread.");
return -1;
@@ -504,13 +499,13 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
CPU_SET(priv->event_core, &cpuset);
else
cpuset = rte_lcore_cpuset(rte_get_main_lcore());
- ret = pthread_setaffinity_np(priv->timer_tid, sizeof(cpuset), &cpuset);
+ ret = rte_thread_set_affinity_by_id(priv->timer_tid, &cpuset);
if (ret) {
DRV_LOG(ERR, "Failed to set thread affinity.");
return -1;
}
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
- ret = rte_thread_setname(priv->timer_tid, name);
+ ret = rte_thread_name_set(priv->timer_tid, name);
if (ret)
DRV_LOG(DEBUG, "Cannot set timer thread name.");
return 0;
@@ -519,13 +514,11 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
void
mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv)
{
- void *status;
-
- if (priv->timer_tid) {
- pthread_cancel(priv->timer_tid);
- pthread_join(priv->timer_tid, &status);
+ if (priv->timer_tid.opaque_id) {
+ pthread_cancel(priv->timer_tid.opaque_id);
+ rte_thread_join(priv->timer_tid, NULL);
}
- priv->timer_tid = 0;
+ priv->timer_tid.opaque_id = 0;
}
void
diff --git a/examples/kni/main.c b/examples/kni/main.c
index beabb3c848..601c9838a2 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -16,6 +16,7 @@
#include <linux/if.h>
#include <linux/if_tun.h>
#include <fcntl.h>
+#include <pthread.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <signal.h>
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h
index e90fb15fc1..9979cc6cdb 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.h
+++ b/examples/performance-thread/pthread_shim/pthread_shim.h
@@ -6,6 +6,7 @@
#define _PTHREAD_SHIM_H_
#include <rte_lcore.h>
+#include <pthread.h>
/*
* This pthread shim is an example that demonstrates how legacy code
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 4/6] lib: enable the new EAL thread API
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (2 preceding siblings ...)
2021-06-18 21:54 ` [dpdk-dev] [PATCH 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
` (2 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_options.c | 6 ++---
lib/eal/common/eal_common_thread.c | 13 +++++----
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/malloc_mp.c | 2 ++
lib/eal/freebsd/eal.c | 18 ++++++-------
lib/eal/freebsd/eal_alarm.c | 12 ++++-----
lib/eal/freebsd/eal_interrupts.c | 6 ++---
lib/eal/freebsd/eal_thread.c | 10 ++++---
lib/eal/include/rte_lcore.h | 6 +++++
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/linux/eal.c | 22 ++++++++--------
lib/eal/linux/eal_alarm.c | 10 ++++---
lib/eal/linux/eal_interrupts.c | 8 +++---
lib/eal/linux/eal_thread.c | 11 +++++---
lib/eal/linux/eal_timer.c | 6 ++---
lib/eal/version.map | 4 +--
lib/eal/windows/eal.c | 4 ++-
lib/eal/windows/eal_interrupts.c | 10 +++----
lib/eal/windows/eal_thread.c | 35 ++++---------------------
lib/eal/windows/eal_windows.h | 10 -------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/rte_thread.c | 2 +-
lib/ethdev/rte_ethdev.c | 4 +--
lib/ethdev/rte_ethdev_core.h | 4 +--
lib/ethdev/rte_flow.c | 4 +--
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
28 files changed, 101 insertions(+), 114 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 9d29696b84..1f6aba498c 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1872,8 +1872,7 @@ eal_auto_detect_cores(struct rte_config *cfg)
unsigned int removed = 0;
rte_cpuset_t affinity_set;
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &affinity_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set))
CPU_ZERO(&affinity_set);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
@@ -1901,8 +1900,7 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
}
RTE_CPU_NOT(cpuset, cpuset);
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &default_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set))
CPU_ZERO(&default_set);
RTE_CPU_AND(cpuset, cpuset, &default_set);
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 79545c67d9..62d28e7b28 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -6,7 +6,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <pthread.h>
+#endif /* RTE_EXEC_ENV_WINDOWS */
+#include <rte_thread.h>
#include <signal.h>
#include <sched.h>
#include <assert.h>
@@ -86,9 +89,8 @@ thread_update_affinity(rte_cpuset_t *cpusetp)
int
rte_thread_set_affinity(rte_cpuset_t *cpusetp)
{
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- cpusetp) != 0) {
- RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+ if (rte_thread_set_affinity_by_id(rte_thread_self(), cpusetp) != 0) {
+ RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
return -1;
}
@@ -166,6 +168,7 @@ __rte_thread_uninit(void)
RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
struct rte_thread_ctrl_params {
void *(*start_routine)(void *);
void *arg;
@@ -258,6 +261,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+#endif
struct rte_thread_ctrl_ctx {
rte_thread_func start_routine;
@@ -357,8 +361,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
- &cpuset) != 0)
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0)
CPU_ZERO(&cpuset);
lcore_id = eal_lcore_non_eal_allocate();
if (lcore_id >= RTE_MAX_LCORE)
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 24e27387b1..ddbc692cf2 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -7,6 +7,7 @@
#include <sys/queue.h>
#include <regex.h>
+#include <pthread.h>
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 64cf4e81c8..4b95001d7d 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -19,7 +19,7 @@
* Structure storing internal configuration (per-lcore)
*/
struct lcore_config {
- pthread_t thread_id; /**< pthread identifier */
+ rte_thread_t thread_id; /**< pthread identifier */
int pipe_main2worker[2]; /**< communication pipe with main */
int pipe_worker2main[2]; /**< communication pipe with main */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2e597a17a2..7f7109d954 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <sys/time.h>
+#include <pthread.h>
+
#include <rte_alarm.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index f4d1676754..b5cf050697 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -667,7 +667,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
@@ -690,7 +690,7 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -854,7 +854,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -866,7 +866,7 @@ rte_eal_init(int argc, char **argv)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- config->main_lcore, thread_id, cpuset,
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -883,7 +883,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -891,10 +891,10 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- rte_thread_setname(lcore_config[i].thread_id, thread_name);
+ rte_thread_name_set(lcore_config[i].thread_id, thread_name);
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index c38b2e04f8..e5d7b130b1 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -37,7 +37,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -156,7 +156,7 @@ eal_alarm_callback(void *arg __rte_unused)
while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -263,8 +263,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
* finish. Otherwise we are trying to cancel
* ourselves - mark it by EINPROGRESS.
*/
- if (pthread_equal(ap->executing_id,
- pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -285,8 +285,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id,
- pthread_self()) == 0) {
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0) {
executing++;
} else {
err = EINPROGRESS;
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 86810845fe..61b6ef1f48 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -628,7 +628,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -737,5 +737,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 1dce9b04f2..8c572c7930 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sched.h>
#include <pthread_np.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <sys/thr.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,7 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (void *)thread_id.opaque_id, cpuset, ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 1550b75da0..8fab21299a 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -362,6 +362,7 @@ __rte_experimental
void
rte_lcore_dump(FILE *f);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Set thread names.
*
@@ -393,6 +394,8 @@ int rte_thread_setname(pthread_t id, const char *name);
__rte_experimental
int rte_thread_getname(pthread_t id, char *name, size_t len);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
/**
* Register current non-EAL thread as a lcore.
*
@@ -417,6 +420,7 @@ __rte_experimental
void
rte_thread_unregister(void);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Create a control thread.
*
@@ -444,6 +448,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0cb37..df1e51dcb8 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#include <pthread.h>
+#include <rte_thread.h>
/**
* Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index ba19fc6347..7060856d84 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -963,7 +963,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
const char *p;
@@ -991,7 +991,7 @@ rte_eal_init(int argc, char **argv)
p = strrchr(argv[0], '/');
strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -1219,7 +1219,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -1229,8 +1229,8 @@ rte_eal_init(int argc, char **argv)
&lcore_config[config->main_lcore].cpuset);
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
- RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->main_lcore, (uintptr_t)thread_id, cpuset,
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -1247,7 +1247,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1255,14 +1255,14 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- ret = rte_thread_setname(lcore_config[i].thread_id,
- thread_name);
+ ret = rte_thread_name_set(lcore_config[i].thread_id,
+ thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 3252c6fa59..fef22a347c 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -48,7 +48,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -86,7 +86,7 @@ eal_alarm_callback(void *arg __rte_unused)
(ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec &&
(ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -207,7 +207,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
/* If calling from other context, mark that alarm is executing
* so loop can spin till it finish. Otherwise we are trying to
* cancel our self - mark it by EINPROGRESS */
- if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -228,7 +229,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 22b3b7bcd9..d8ce854d90 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <unistd.h>
@@ -97,7 +97,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1167,7 +1167,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1570,5 +1570,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index 83c2034b93..91c239a217 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <sched.h>
#include <sys/queue.h>
#include <sys/syscall.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,8 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset,
+ ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 7cf15cabac..dc0308c761 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -12,7 +12,7 @@
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/queue.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <errno.h>
#include <rte_common.h>
@@ -80,7 +80,7 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
@@ -185,7 +185,7 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
+ ret = rte_thread_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc",
hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 02455a1c8d..9d17e45b96 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -21,7 +21,7 @@ DPDK_21 {
rte_cpu_get_flag_enabled;
rte_cpu_get_flag_name;
rte_cpu_is_supported; # WINDOWS_NO_EXPORT
- rte_ctrl_thread_create;
+ rte_ctrl_thread_create; # WINDOWS_NO_EXPORT
rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
rte_delay_us;
rte_delay_us_block;
@@ -193,7 +193,7 @@ DPDK_21 {
rte_sys_gettid;
rte_thread_get_affinity;
rte_thread_set_affinity;
- rte_thread_setname;
+ rte_thread_setname; # WINDOWS_NO_EXPORT
rte_uuid_compare; # WINDOWS_NO_EXPORT
rte_uuid_is_null; # WINDOWS_NO_EXPORT
rte_uuid_parse; # WINDOWS_NO_EXPORT
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 28c787c0b0..65be582b99 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -391,7 +391,9 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- if (eal_thread_create(&lcore_config[i].thread_id) != 0)
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
+ eal_thread_loop, NULL);
+ if (ret != 0)
rte_panic("Cannot create thread\n");
}
diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c
index 1d4cf794df..b95c8f6f93 100644
--- a/lib/eal/windows/eal_interrupts.c
+++ b/lib/eal/windows/eal_interrupts.c
@@ -7,7 +7,7 @@
#include "eal_private.h"
#include "eal_windows.h"
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static HANDLE intr_iocp;
@@ -63,7 +63,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -76,7 +76,7 @@ rte_eal_intr_init(void)
int
rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
int
@@ -92,9 +92,9 @@ eal_intr_thread_schedule(void (*func)(void *arg), void *arg)
{
HANDLE handle;
- handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread);
+ handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread.opaque_id);
if (handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread);
+ RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread.opaque_id);
return -ENOENT;
}
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 9c3f6d69fd..fbdb7dbc76 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -60,15 +60,16 @@ eal_thread_loop(void *arg __rte_unused)
char c;
int n, ret;
unsigned int lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -80,7 +81,7 @@ eal_thread_loop(void *arg __rte_unused)
__rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset);
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset);
/* read on our pipe to get commands */
while (1) {
@@ -122,35 +123,9 @@ eal_thread_loop(void *arg __rte_unused)
}
}
-/* function to create threads */
-int
-eal_thread_create(pthread_t *thread)
-{
- HANDLE th;
-
- th = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
- NULL, 0, (LPDWORD)thread);
- if (!th)
- return -1;
-
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
-
- return 0;
-}
-
/* get current thread ID */
int
rte_sys_gettid(void)
{
return GetCurrentThreadId();
}
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
- /* TODO */
- /* This is a stub, not the expected result */
- return 0;
-}
diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h
index dc5dc8240a..4b92b198c7 100644
--- a/lib/eal/windows/eal_windows.h
+++ b/lib/eal/windows/eal_windows.h
@@ -35,16 +35,6 @@
*/
int eal_create_cpu_map(void);
-/**
- * Create a thread.
- *
- * @param thread
- * The location to store the thread id if successful.
- * @return
- * 0 for success, -1 if the thread is not created.
- */
-int eal_thread_create(pthread_t *thread);
-
/**
* Get system NUMA node number for a socket ID.
*
diff --git a/lib/eal/windows/include/rte_windows.h b/lib/eal/windows/include/rte_windows.h
index 0063b5d78c..d8c4ed10d7 100644
--- a/lib/eal/windows/include/rte_windows.h
+++ b/lib/eal/windows/include/rte_windows.h
@@ -28,6 +28,7 @@
#include <windows.h>
#include <basetsd.h>
+#include <processthreadsapi.h>
#include <psapi.h>
#include <setupapi.h>
#include <winioctl.h>
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 180ac126af..8733a9083e 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -594,7 +594,7 @@ rte_thread_name_set(rte_thread_t thread_id, const char *name)
}
count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
- if (count < 0) {
+ if (count == (size_t) (-1)) {
RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
ret = EINVAL;
goto cleanup;
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c607eabb5b..bc0a4c973a 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -526,7 +526,7 @@ rte_eth_dev_allocate(const char *name)
strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
eth_dev->data->port_id = port_id;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ rte_thread_mutex_init(ð_dev->data->flow_ops_mutex);
unlock:
rte_spinlock_unlock(ð_dev_shared_data->ownership_lock);
@@ -600,7 +600,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data->hash_mac_addrs);
rte_free(eth_dev->data->dev_private);
- pthread_mutex_destroy(ð_dev->data->flow_ops_mutex);
+ rte_thread_mutex_destroy(ð_dev->data->flow_ops_mutex);
memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
}
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d948fa..c4a6ea9774 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -5,7 +5,7 @@
#ifndef _RTE_ETHDEV_CORE_H_
#define _RTE_ETHDEV_CORE_H_
-#include <pthread.h>
+#include <rte_thread.h>
/**
* @file
@@ -182,7 +182,7 @@ struct rte_eth_dev_data {
* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
*/
- pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
+ rte_thread_mutex flow_ops_mutex; /**< rte_flow ops mutex. */
uint64_t reserved_64s[4]; /**< Reserved for future fields */
void *reserved_ptrs[4]; /**< Reserved for future fields */
} __rte_cache_aligned;
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..4f112d1af7 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -226,14 +226,14 @@ static inline void
fts_enter(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_lock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_lock(&dev->data->flow_ops_mutex);
}
static inline void
fts_exit(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_unlock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_unlock(&dev->data->flow_ops_mutex);
}
static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 13dfb28401..47f10cf5a9 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -7,6 +7,7 @@
#endif
#include <unistd.h>
+#include <pthread.h>
#include <rte_cycles.h>
#include <rte_common.h>
#include <rte_dev.h>
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index c96f6335c8..85572354ae 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -12,6 +12,7 @@
#include <numaif.h>
#endif
+#include <pthread.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_log.h>
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 5/6] eal: set affinity and priority attributes
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (3 preceding siblings ...)
2021-06-18 21:54 ` [dpdk-dev] [PATCH 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
If the user doesn't specify the priority through the command
line arguments, initialize the thread priority to 'normal'.
Set thread priority for eal threads.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 11 ++++++++
lib/eal/common/eal_thread.h | 6 ++++
lib/eal/freebsd/eal.c | 41 +++++++++++++++++++++++-----
lib/eal/linux/eal.c | 39 +++++++++++++++++++++-----
lib/eal/windows/eal.c | 44 ++++++++++++++++++++++++++++--
5 files changed, 125 insertions(+), 16 deletions(-)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 62d28e7b28..fa537db7ac 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -388,3 +388,14 @@ rte_thread_unregister(void)
RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n",
lcore_id);
}
+
+void rte_thread_priority_init(void)
+{
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+
+ /* If the user doesn't specify the priority through the command
+ * line arguments, the default 'normal' value will be used.
+ */
+ internal_conf->thread_priority = RTE_THREAD_PRIORITY_NORMAL;
+}
diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h
index 4a49117be8..7b3b884463 100644
--- a/lib/eal/common/eal_thread.h
+++ b/lib/eal/common/eal_thread.h
@@ -58,4 +58,10 @@ eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size);
int
eal_thread_dump_current_affinity(char *str, unsigned int size);
+/**
+ * Set the initial thread priority in the internal configuration
+ * to the default value of RTE_THREAD_PRIORITY_NORMAL.
+ */
+void rte_thread_priority_init(void);
+
#endif /* EAL_THREAD_H */
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index b5cf050697..7303d62afb 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -676,6 +676,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -854,6 +856,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -869,6 +879,22 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -882,9 +908,15 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
+ if (ret != 0)
+ rte_panic("Cannot set affinity\n");
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -892,11 +924,6 @@ rte_eal_init(int argc, char **argv)
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
rte_thread_name_set(lcore_config[i].thread_id, thread_name);
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 7060856d84..7f3d491560 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -975,6 +975,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -1219,6 +1221,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -1233,6 +1243,23 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot initialize thread attributes,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set thread priority attribute,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -1246,9 +1273,12 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1260,11 +1290,6 @@ rte_eal_init(int argc, char **argv)
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 65be582b99..bb9053df84 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -274,6 +274,8 @@ rte_eal_init(int argc, char **argv)
eal_get_internal_configuration();
int ret;
+ rte_thread_priority_init();
+
eal_log_init(NULL, 0);
eal_log_level_parse(argc, argv);
@@ -375,6 +377,36 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
+ &lcore_config[config->main_lcore].cpuset) != 0) {
+ rte_eal_init_alert("Cannot set affinity");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -390,9 +422,17 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread affinity attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
}
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH 6/6] Allow choice between internal EAL thread API and external lib
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (4 preceding siblings ...)
2021-06-18 21:54 ` [dpdk-dev] [PATCH 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
@ 2021-06-18 21:54 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-18 21:54 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The user is offered the option of either using the RTE_THREAD_* API or
a 3rd party thread library, through a meson flag called
"use_external_thread_lib". By default, this flag is set to FALSE,
which means Windows libraries and applications will use the RTE_THREAD_*
API for managing threads.
If compiling on Windows and the "use_external_thread_lib" is *not* set,
the following files will be parsed:
* include/rte_thread.h
* windows/rte_thread.c
In all other cases, the compilation/parsing includes the following files:
* include/rte_thread.h
* common/rte_thread.c
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
config/meson.build | 1 -
lib/eal/windows/include/pthread.h | 192 ------------------------------
lib/eal/windows/meson.build | 7 +-
meson_options.txt | 2 +
4 files changed, 8 insertions(+), 194 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
diff --git a/config/meson.build b/config/meson.build
index 017bb2efbb..9309010f21 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -262,7 +262,6 @@ else # for 32-bit we need smaller reserved memory areas
dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
endif
-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h
deleted file mode 100644
index 27fd2cca52..0000000000
--- a/lib/eal/windows/include/pthread.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019 Intel Corporation
- */
-
-#ifndef _PTHREAD_H_
-#define _PTHREAD_H_
-
-#include <stdint.h>
-#include <sched.h>
-
-/**
- * This file is required to support the common code in eal_common_proc.c,
- * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc
- * does not contain pthread.h. This may be removed in future releases.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_common.h>
-#include <rte_windows.h>
-
-#define PTHREAD_BARRIER_SERIAL_THREAD TRUE
-
-/* defining pthread_t type on Windows since there is no in Microsoft libc*/
-typedef uintptr_t pthread_t;
-
-/* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/
-typedef void *pthread_attr_t;
-
-typedef void *pthread_mutexattr_t;
-
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
-
-#define pthread_barrier_init(barrier, attr, count) \
- !InitializeSynchronizationBarrier(barrier, count, -1)
-#define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
- SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
-#define pthread_barrier_destroy(barrier) \
- !DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
-
-/* pthread function overrides */
-#define pthread_self() \
- ((pthread_t)GetCurrentThreadId())
-
-
-static inline int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- return t1 == t2;
-}
-
-static inline int
-pthread_setaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- DWORD_PTR ret = 0;
- HANDLE thread_handle;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- ret = SetThreadAffinityMask(thread_handle, *cpuset->_bits);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("CloseHandle()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_getaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- /* Workaround for the lack of a GetThreadAffinityMask()
- *API in Windows
- */
- DWORD_PTR prev_affinity_mask;
- HANDLE thread_handle;
- DWORD_PTR ret = 0;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- /* obtain previous mask by setting dummy mask */
- prev_affinity_mask = SetThreadAffinityMask(thread_handle, 0x1);
- if (prev_affinity_mask == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- /* set it back! */
- ret = SetThreadAffinityMask(thread_handle, prev_affinity_mask);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- memset(cpuset, 0, cpuset_size);
- *cpuset->_bits = prev_affinity_mask;
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_create(void *threadid, const void *threadattr, void *threadfunc,
- void *args)
-{
- RTE_SET_USED(threadattr);
- HANDLE hThread;
- hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
- args, 0, (LPDWORD)threadid);
- if (hThread) {
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
- }
- return ((hThread != NULL) ? 0 : E_FAIL);
-}
-
-static inline int
-pthread_detach(__rte_unused pthread_t thread)
-{
- return 0;
-}
-
-static inline int
-pthread_join(__rte_unused pthread_t thread,
- __rte_unused void **value_ptr)
-{
- return 0;
-}
-
-static inline int
-pthread_mutex_init(pthread_mutex_t *mutex,
- __rte_unused pthread_mutexattr_t *attr)
-{
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PTHREAD_H_ */
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index ff9cbec417..4b7db4754b 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -19,7 +19,12 @@ sources += files(
'eal_timer.c',
'fnmatch.c',
'getopt.c',
- 'rte_thread.c',
)
+if get_option('use_external_thread_lib')
+ sources += 'eal/common/rte_thread.c'
+else
+ sources += 'eal/windows/rte_thread.c'
+endif
+
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
diff --git a/meson_options.txt b/meson_options.txt
index 56bdfd0f0a..2606c8b3a4 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -44,3 +44,5 @@ option('tests', type: 'boolean', value: true, description:
'build unit tests')
option('use_hpet', type: 'boolean', value: false, description:
'use HPET timer in EAL')
+option('use_external_thread_lib', type: 'boolean', value: false,
+ description: 'use an external thread library')
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (5 preceding siblings ...)
2021-06-18 21:54 ` [dpdk-dev] [PATCH 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
` (6 more replies)
6 siblings, 7 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
This patchset enables the new EAL thread API.
The newly defined thread attributes, priority and affinity,
are used in eal/windows when creating the threads. Similarly,
some changes have been done in eal/linux/eal.c and eal/freebsd/eal.c
to initialize priority to a default value and set thread attributes.
The user is offered the option of either using the rte_thread_* API or
a 3rd party thread library, through a meson flag
called "use_external_thread_lib".
By default, this flag is set to FALSE, which means Windows libraries
and applications will use the EAL rte_thread_* API
defined in windows/rte_thread.c for managing threads.
When the flag is set to TRUE, the common/rte_thread.c file is compiled
and an external thread library is used.
This patchset adds a new function for creating control threads that
uses the new thread API.
It enables the usage of the new function in Windows code and common code.
The old function is kept to avoid ABI break, however, its definition
is commented away on Windows, since the pthread_t and pthread_attr_t
arguments that it receives have been replaced with the new API on Windows.
This allows testing the "eal: Add EAL API for threading" that this
patchset depends on.
The ethdev lib also contains some changes that break the ABI.
Enabling the new EAL thread API will probably require going through
the proper process of ABI changes.
Depends-on: series-17402 ("eal: Add EAL API for threading")
v2:
- fix typo in SetThreadDescription_type function pointer
- add Depends-on on all patches to fix apply errors.
- modify cover letter
Narcisa Vasile (6):
eal: add function that sets thread name
eal: add function for control thread creation
Enable the new EAL thread API in app, drivers and examples
lib: enable the new EAL thread API
eal: set affinity and priority attributes
Allow choice between internal EAL thread API and external lib
app/test/process.h | 8 +-
app/test/test_lcores.c | 18 +-
app/test/test_link_bonding.c | 14 +-
app/test/test_lpm_perf.c | 12 +-
config/meson.build | 1 -
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 +-
drivers/bus/dpaa/base/qbman/process.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 14 +-
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 +-
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 10 +-
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 +-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +-
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 +--
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.h | 8 +-
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +-
drivers/net/axgbe/axgbe_phy_impl.c | 6 +-
drivers/net/bnxt/bnxt.h | 16 +-
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 ++---
drivers/net/bnxt/bnxt_irq.c | 8 +-
drivers/net/bnxt/bnxt_reps.c | 10 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +--
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +-
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +-
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +-
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +-
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 +-
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +-
drivers/net/vhost/rte_eth_vhost.c | 24 +--
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +--
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 +++--
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 +--
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++---
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
lib/eal/common/eal_common_options.c | 6 +-
lib/eal/common/eal_common_thread.c | 105 +++++++++-
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/eal_thread.h | 6 +
lib/eal/common/malloc_mp.c | 2 +
lib/eal/common/rte_thread.c | 17 ++
lib/eal/freebsd/eal.c | 53 +++--
lib/eal/freebsd/eal_alarm.c | 12 +-
lib/eal/freebsd/eal_interrupts.c | 6 +-
lib/eal/freebsd/eal_thread.c | 10 +-
lib/eal/include/rte_lcore.h | 6 +
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/include/rte_thread.h | 45 ++++
lib/eal/linux/eal.c | 55 +++--
lib/eal/linux/eal_alarm.c | 10 +-
lib/eal/linux/eal_interrupts.c | 8 +-
lib/eal/linux/eal_thread.c | 11 +-
lib/eal/linux/eal_timer.c | 6 +-
lib/eal/version.map | 6 +-
lib/eal/windows/eal.c | 44 +++-
lib/eal/windows/eal_interrupts.c | 10 +-
lib/eal/windows/eal_thread.c | 35 +---
lib/eal/windows/eal_windows.h | 10 -
lib/eal/windows/include/pthread.h | 192 ------------------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/meson.build | 7 +-
lib/eal/windows/rte_thread.c | 60 ++++++
lib/ethdev/rte_ethdev.c | 4 +-
lib/ethdev/rte_ethdev_core.h | 4 +-
lib/ethdev/rte_flow.c | 4 +-
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
meson_options.txt | 2 +
95 files changed, 764 insertions(+), 654 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-20 23:53 ` Dmitry Kozlyuk
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
` (5 subsequent siblings)
6 siblings, 1 reply; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Implement function that sets the name of a thread.
On Windows, SetThreadDescription() is used. Use GetProcAddress()
to obtain the address of the function for MinGW compatibility.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/rte_thread.c | 17 ++++++++++
lib/eal/include/rte_thread.h | 18 +++++++++++
lib/eal/version.map | 1 +
lib/eal/windows/rte_thread.c | 60 ++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+)
diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c
index 3fdb267337..fbff1168e5 100644
--- a/lib/eal/common/rte_thread.c
+++ b/lib/eal/common/rte_thread.c
@@ -373,6 +373,23 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return ret;
}
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+ char truncated[RTE_THREAD_MAX_DESCRIPTION_LENGTH];
+
+ memcpy(truncated, name, sizeof(truncated));
+ ret = pthread_setname_np((pthread_t)thread_id.opaque_id, truncated);
+#endif
+#endif
+ RTE_SET_USED(thread_id);
+ RTE_SET_USED(name);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *))
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 40da83467b..c65cfd8c9e 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -24,6 +24,8 @@ extern "C" {
#include <sched.h>
+#define RTE_THREAD_MAX_DESCRIPTION_LENGTH 16
+
/**
* Thread id descriptor.
*/
@@ -439,6 +441,22 @@ int rte_thread_barrier_wait(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
+/**
+ * Set the name of the thread represented by 'thread_id'.
+ *
+ * @param thread_id
+ * The id of the thread.
+ *
+ * @param name
+ * Thread name to set.
+ *
+ * @return
+ * On success, return 0.
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 6645f60a78..2a566c04af 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -443,6 +443,7 @@ EXPERIMENTAL {
rte_thread_barrier_init;
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
+ rte_thread_name_set;
};
INTERNAL {
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index b2ff16f51f..995ae2491d 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -556,6 +556,66 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return 0;
}
+typedef HRESULT
+(*SetThreadDescription_type)(HANDLE thread_handle, PCWSTR thread_description);
+
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = 0;
+ size_t count;
+ HRESULT hr;
+ HANDLE thread_handle = NULL;
+ WCHAR w_name[RTE_THREAD_MAX_DESCRIPTION_LENGTH];
+ HMODULE kernel_lib = NULL;
+ SetThreadDescription_type SetThreadDescription_ptr;
+
+ static const char library_name[] = "kernel32.dll";
+ static const char function[] = "SetThreadDescription";
+
+ kernel_lib = LoadLibraryA(library_name);
+ if (kernel_lib == NULL) {
+ ret = thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
+ goto cleanup;
+ }
+
+ SetThreadDescription_ptr = (SetThreadDescription_type)(
+ (void *)GetProcAddress(kernel_lib, function));
+ if (SetThreadDescription_ptr == NULL) {
+ ret = thread_log_last_error("GetProcAddress(\"kernel32.dll\", \"SetThreadDescription\")");
+ goto cleanup;
+ }
+
+ thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE,
+ thread_id.opaque_id);
+ if (thread_handle == NULL) {
+ ret = thread_log_last_error("OpenThread()");
+ goto cleanup;
+ }
+
+ count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
+ if (count < 0) {
+ RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ hr = SetThreadDescription_ptr(thread_handle, w_name);
+ if (FAILED(hr)) {
+ ret = thread_log_last_error("SetThreadDescription()");
+ goto cleanup;
+ }
+
+cleanup:
+ if (kernel_lib != NULL)
+ FreeLibrary(kernel_lib);
+ if (thread_handle != NULL) {
+ CloseHandle(thread_handle);
+ thread_handle = NULL;
+ }
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key,
__rte_unused void (*destructor)(void *))
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 2/6] eal: add function for control thread creation
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
` (4 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The existing rte_ctrl_thread_create() function will be replaced
with rte_thread_ctrl_thread_create() that uses the internal
EAL thread API.
This patch only introduces the new control thread creation
function. Replacing of the old function needs to be done according
to the ABI change procedures, to avoid an ABI break.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 81 ++++++++++++++++++++++++++++++
lib/eal/include/rte_thread.h | 27 ++++++++++
lib/eal/version.map | 1 +
3 files changed, 109 insertions(+)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 1a52f42a2b..79545c67d9 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -259,6 +259,87 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+struct rte_thread_ctrl_ctx {
+ rte_thread_func start_routine;
+ void *arg;
+ const char *name;
+};
+
+static void *ctrl_thread_wrapper(void *arg)
+{
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = arg;
+ rte_thread_func start_routine = ctx->start_routine;
+ void *routine_arg = ctx->arg;
+
+ __rte_thread_init(rte_lcore_id(), cpuset);
+
+ if (ctx->name != NULL) {
+ if (rte_thread_name_set(rte_thread_self(), ctx->name) < 0)
+ RTE_LOG(DEBUG, EAL, "Cannot set name for ctrl thread\n");
+ }
+
+ free(arg);
+
+ return start_routine(routine_arg);
+}
+
+int
+rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg)
+{
+ int ret;
+ rte_thread_attr_t attr;
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = NULL;
+
+ if (start_routine == NULL) {
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL) {
+ ret = ENOMEM;
+ goto cleanup;
+ }
+
+ ctx->start_routine = start_routine;
+ ctx->arg = arg;
+ ctx->name = name;
+
+ ret = rte_thread_attr_init(&attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot init ctrl thread attributes\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_attr_set_affinity(&attr, cpuset);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set afifnity attribute for ctrl thread\n");
+ goto cleanup;
+ }
+ ret = rte_thread_attr_set_priority(&attr, RTE_THREAD_PRIORITY_NORMAL);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set priority attribute for ctrl thread\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_create(thread, &attr, ctrl_thread_wrapper, ctx);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot create ctrl thread\n");
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ free(ctx);
+ return ret;
+}
+
int
rte_thread_register(void)
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index c65cfd8c9e..4da800ae27 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -457,6 +457,33 @@ int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+/**
+ * Create a control thread.
+ *
+ * Set affinity and thread name. The affinity of the new thread is based
+ * on the CPU affinity retrieved at the time rte_eal_init() was called,
+ * the dataplane and service lcores are then excluded.
+ *
+ * @param thread
+ * Filled with the thread id of the new created thread.
+ *
+ * @param name
+ * The name of the control thread (max 16 characters including '\0').
+ *
+ * @param start_routine
+ * Function to be executed by the new thread.
+ *
+ * @param arg
+ * Argument passed to start_routine.
+ *
+ * @return
+ * On success, return 0;
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 2a566c04af..02455a1c8d 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -444,6 +444,7 @@ EXPERIMENTAL {
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
rte_thread_name_set;
+ rte_thread_ctrl_thread_create;
};
INTERNAL {
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 3/6] Enable the new EAL thread API in app, drivers and examples
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
` (3 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
app/test/process.h | 8 +--
app/test/test_lcores.c | 18 +++----
app/test/test_link_bonding.c | 14 ++---
app/test/test_lpm_perf.c | 12 ++---
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 ++---
drivers/bus/dpaa/base/qbman/process.c | 6 +--
drivers/bus/dpaa/dpaa_bus.c | 14 ++---
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 ++++---
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 10 ++--
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 ++-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +++----
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 ++++-----
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.h | 8 +--
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +--
drivers/net/axgbe/axgbe_phy_impl.c | 6 +--
drivers/net/bnxt/bnxt.h | 16 +++---
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 +++++++++----------
drivers/net/bnxt/bnxt_irq.c | 8 +--
drivers/net/bnxt/bnxt_reps.c | 10 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++++++------
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +++++-----
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +++---
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +--
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +++----
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +--
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 ++--
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +--
drivers/net/vhost/rte_eth_vhost.c | 24 ++++-----
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +++++------
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 ++++++++---------
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 ++++-----
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++++++++----------
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
60 files changed, 334 insertions(+), 339 deletions(-)
diff --git a/app/test/process.h b/app/test/process.h
index a09a088477..9e4be17bad 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -26,7 +26,7 @@
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
-#include <pthread.h>
+#include <rte_thread.h>
extern void *send_pkts(void *empty);
extern uint16_t flag_for_send_pkts;
#endif
@@ -47,7 +47,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
char path[32];
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
- pthread_t thread;
+ rte_thread_t thread;
int rc;
#endif
#endif
@@ -128,7 +128,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
- rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+ rc = rte_thread_create(&thread, NULL, &send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
strerror(rc));
@@ -143,7 +143,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
- pthread_join(thread, NULL);
+ rte_thread_join(thread, NULL);
}
#endif
#endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 19a7ab9fce..accdd858a6 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,7 @@
* Copyright (c) 2020 Red Hat, Inc.
*/
-#include <pthread.h>
+#include <rte_thread.h>
#include <string.h>
#include <rte_common.h>
@@ -14,7 +14,7 @@
struct thread_context {
enum { INIT, ERROR, DONE } state;
bool lcore_id_any;
- pthread_t id;
+ rte_thread_t id;
unsigned int *registered_count;
};
@@ -77,7 +77,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
break;
non_eal_threads_count++;
}
@@ -96,7 +96,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) == 0) {
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
non_eal_threads_count++;
printf("non-EAL threads count: %u\n", non_eal_threads_count);
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -110,7 +110,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -262,7 +262,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -285,7 +285,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -309,7 +309,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -330,7 +330,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
__atomic_store_n(®istered_count, 0, __ATOMIC_RELEASE);
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
}
error:
if (handle[1] != NULL)
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c8310a8..a22189a656 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -3,6 +3,7 @@
*/
#include "unistd.h"
+#include <pthread.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
@@ -203,7 +204,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
static int slaves_initialized;
static int mac_slaves_initialized;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(mutex)
static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
@@ -1191,11 +1192,11 @@ test_bonding_lsc_event_callback(uint16_t port_id __rte_unused,
void *param __rte_unused,
void *ret_param __rte_unused)
{
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
test_lsc_interrupt_count++;
pthread_cond_signal(&cvar);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
return 0;
}
@@ -1220,11 +1221,12 @@ lsc_timeout(int wait_us)
ts.tv_sec += 1;
}
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
if (test_lsc_interrupt_count < 1)
- retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+ retval = pthread_cond_timedwait(&cvar,
+ (pthread_mutex_t *)mutex.mutex_id, &ts);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
if (retval == 0 && test_lsc_interrupt_count < 1)
return -1;
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 2bed00d064..e4cfcdb504 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -25,7 +25,7 @@ static volatile uint32_t thr_id;
static uint64_t gwrite_cycles;
static uint32_t num_writers;
/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(lpm_mutex)
/* Report quiescent state interval every 1024 lookups. Larger critical
* sections in reader will result in writer polling multiple times.
@@ -443,7 +443,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
/* Add all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth,
next_hop_add) != 0) {
@@ -452,13 +452,13 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
/* Delete all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth) != 0) {
printf("Failed to delete iteration %d, route# %d\n",
@@ -466,7 +466,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
}
@@ -478,7 +478,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
error:
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
return -1;
}
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index ee35e03da1..25be077c6f 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -38,11 +38,10 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
struct dpaa_ioctl_irq_map irq_map;
/* Verify the thread's cpu-affinity */
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_set_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
errno = ret;
- err(0, "pthread_getaffinity_np()");
+ err(0, "rte_thread_set_affinity_by_id()");
return ret;
}
pcfg.cpu = -1;
diff --git a/drivers/bus/dpaa/base/qbman/dpaa_sys.c b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
index 9d6bfd40a2..14aeb5e07d 100644
--- a/drivers/bus/dpaa/base/qbman/dpaa_sys.c
+++ b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
@@ -18,16 +18,16 @@ struct process_interrupt {
};
static COMPAT_LIST_HEAD(process_irq_list);
-static pthread_mutex_t process_irq_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(process_irq_lock)
static void process_interrupt_install(struct process_interrupt *irq)
{
int ret;
/* Add the irq to the end of the list */
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_add_tail(&irq->node, &process_irq_list);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -35,10 +35,10 @@ static void process_interrupt_remove(struct process_interrupt *irq)
{
int ret;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_del(&irq->node);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -47,14 +47,14 @@ static struct process_interrupt *process_interrupt_find(int irq_num)
int ret;
struct process_interrupt *i = NULL;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_for_each_entry(i, &process_irq_list, node) {
if (i->irq == irq_num)
goto done;
}
done:
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
return i;
}
diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 9bc92681cd..da157b8426 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -21,7 +21,7 @@
* what the lock is for.
*/
static int fd = -1;
-static pthread_mutex_t fd_init_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(fd_init_lock)
static int check_fd(void)
{
@@ -29,12 +29,12 @@ static int check_fd(void)
if (fd >= 0)
return 0;
- ret = pthread_mutex_lock(&fd_init_lock);
+ ret = rte_thread_mutex_lock(&fd_init_lock);
assert(!ret);
/* check again with the lock held */
if (fd < 0)
fd = open(PROCESS_PATH, O_RDWR);
- ret = pthread_mutex_unlock(&fd_init_lock);
+ ret = rte_thread_mutex_unlock(&fd_init_lock);
assert(!ret);
return (fd >= 0) ? 0 : -ENODEV;
}
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 2f48d4036b..bd83cab577 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -10,7 +10,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/eventfd.h>
@@ -48,7 +48,7 @@ static struct rte_dpaa_bus rte_dpaa_bus;
struct netcfg_info *dpaa_netcfg;
/* define a variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa_portal_key;
+static rte_thread_key dpaa_portal_key;
unsigned int dpaa_svr_family;
@@ -316,10 +316,10 @@ int rte_dpaa_portal_init(void *arg)
DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index();
DPAA_PER_LCORE_PORTAL->tid = syscall(SYS_gettid);
- ret = pthread_setspecific(dpaa_portal_key,
+ ret = rte_thread_value_set(dpaa_portal_key,
(void *)DPAA_PER_LCORE_PORTAL);
if (ret) {
- DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
+ DPAA_BUS_LOG(ERR, "rte_thread_value_set failed on core %u"
" (lcore=%u) with ret: %d", cpu, lcore, ret);
dpaa_portal_finish(NULL);
@@ -377,7 +377,7 @@ dpaa_portal_finish(void *arg)
bman_thread_finish();
qman_thread_finish();
- pthread_setspecific(dpaa_portal_key, NULL);
+ rte_thread_value_set(dpaa_portal_key, NULL);
rte_free(dpaa_io_portal);
dpaa_io_portal = NULL;
@@ -453,9 +453,9 @@ rte_dpaa_bus_scan(void)
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
+ ret = rte_thread_key_create(&dpaa_portal_key, dpaa_portal_finish);
if (ret) {
- DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
+ DPAA_BUS_LOG(DEBUG, "Unable to create thread key. (%d)", ret);
dpaa_clean_device_list();
return ret;
}
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index c6f8312a1d..dffbdff666 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
@@ -59,7 +59,7 @@ uint8_t dpaa2_dqrr_size;
uint8_t dpaa2_eqcr_size;
/* Variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa2_portal_key;
+static rte_thread_key dpaa2_portal_key;
/*Stashing Macros default for LS208x*/
static int dpaa2_core_cluster_base = 0x04;
@@ -92,10 +92,9 @@ dpaa2_get_core_id(void)
rte_cpuset_t cpuset;
int i, ret, cpu_id = -1;
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
- DPAA2_BUS_ERR("pthread_getaffinity_np() failed");
+ DPAA2_BUS_ERR("rte_thread_get_affinity_by_id() failed");
return ret;
}
@@ -296,9 +295,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
}
}
- ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
+ ret = rte_thread_value_set(dpaa2_portal_key, (void *)dpio_dev);
if (ret) {
- DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
+ DPAA2_BUS_ERR("rte_thread_value_set failed with ret: %d", ret);
dpaa2_put_qbman_swp(dpio_dev);
return NULL;
}
@@ -357,7 +356,7 @@ static void dpaa2_portal_finish(void *arg)
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
- pthread_setspecific(dpaa2_portal_key, NULL);
+ rte_thread_value_set(dpaa2_portal_key, NULL);
}
static int
@@ -515,10 +514,10 @@ dpaa2_create_dpio_device(int vdev_fd,
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa2_portal_key,
+ ret = rte_thread_key_create(&dpaa2_portal_key,
dpaa2_portal_finish);
if (ret) {
- DPAA2_BUS_DEBUG("Unable to create pthread key (%d)",
+ DPAA2_BUS_DEBUG("Unable to create thread key (%d)",
ret);
goto err;
}
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb..8d53ee4dfc 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <linux/types.h>
#include <stdbool.h>
#include <ctype.h>
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index 3756e1959b..295ef872c0 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <sys/types.h>
+#include <rte_windows.h>
#include <rte_errno.h>
#include "mlx5_autoconf.h"
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 80c564f10b..8f4dbfdbc9 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -72,7 +72,7 @@ struct mlx5_compress_qp {
TAILQ_HEAD(mlx5_compress_privs, mlx5_compress_priv) mlx5_compress_priv_list =
TAILQ_HEAD_INITIALIZER(mlx5_compress_priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
int mlx5_compress_logtype;
@@ -804,9 +804,9 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv,
}
priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr;
priv->mr_scache.dereg_mr_cb = mlx5_common_verbs_dereg_mr;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
}
@@ -826,13 +826,13 @@ mlx5_compress_pci_remove(struct rte_pci_device *pdev)
{
struct mlx5_compress_priv *priv = NULL;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
if (rte_pci_addr_cmp(&priv->pci_dev->addr, &pdev->addr) != 0)
break;
if (priv)
TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (priv) {
mlx5_mr_release_cache(&priv->mr_scache);
mlx5_compress_hw_global_release(priv);
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index eca183753f..bcbf379843 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -5,7 +5,7 @@
#include <assert.h>
#include <errno.h>
#include <nmmintrin.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h b/drivers/event/dlb2/pf/base/dlb2_osdep.h
index cffe22f3c5..82e0c71734 100644
--- a/drivers/event/dlb2/pf/base/dlb2_osdep.h
+++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h
@@ -8,7 +8,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
@@ -194,14 +194,13 @@ static void *dlb2_complete_queue_map_unmap(void *__args)
static inline void os_schedule_work(struct dlb2_hw *hw)
{
struct dlb2_dev *dlb2_dev;
- pthread_t complete_queue_map_unmap_thread;
+ rte_thread_t complete_queue_map_unmap_thread;
int ret;
dlb2_dev = container_of(hw, struct dlb2_dev, hw);
- ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+ ret = rte_thread_ctrl_thread_create(&complete_queue_map_unmap_thread,
"dlb_queue_unmap_waiter",
- NULL,
dlb2_complete_queue_map_unmap,
dlb2_dev);
if (ret)
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index f02056982c..34a1d2b28d 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index eb5660a3dc..0f0837426e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -178,7 +178,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
static inline int
@@ -676,7 +676,7 @@ find_internal_resource(struct pmd_internals *port_int)
if (port_int == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
struct pmd_internals *list_int =
@@ -687,7 +687,7 @@ find_internal_resource(struct pmd_internals *port_int)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -725,7 +725,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
if (mb_pool == NULL)
return ret;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internals = list->eth_dev->data->dev_private;
@@ -751,7 +751,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
}
out:
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return ret;
}
@@ -780,9 +780,9 @@ eth_dev_configure(struct rte_eth_dev *dev)
return -1;
list->eth_dev = dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
}
return 0;
@@ -948,9 +948,9 @@ eth_dev_close(struct rte_eth_dev *dev)
/* Remove ethdev from list used to track and share UMEMs */
list = find_internal_resource(internals);
if (list) {
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 377299b14c..51856f66d1 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -563,12 +563,12 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
ark_pktchkr_run(ark->pc);
if (ark->start_pg && (dev->data->port_id == 0)) {
- pthread_t thread;
+ rte_thread_t thread;
/* Delay packet generatpr start allow the hardware to be ready
* This is only used for sanity checking with internal generator
*/
- if (rte_ctrl_thread_create(&thread, "ark-delay-pg", NULL,
+ if (rte_thread_ctrl_thread_create(&thread, "ark-delay-pg",
ark_pktgen_delay_start, ark->pg)) {
ARK_PMD_LOG(ERR, "Could not create pktgen "
"starter thread\n");
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 515bfe461c..58ff65b5d5 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -3,7 +3,7 @@
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -475,7 +475,7 @@ ark_pktgen_delay_start(void *arg)
* perform a blind sleep here to ensure that the external test
* application has time to setup the test before we generate packets
*/
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
usleep(100000);
ark_pktgen_run(inst);
return NULL;
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 0ce35eb519..2b86f01a25 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -405,7 +405,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
hw->aq_nic_cfg = &adapter->hw_cfg;
- pthread_mutex_init(&hw->mbox_mutex, NULL);
+ rte_thread_mutex_init(&hw->mbox_mutex);
/* disable interrupt */
atl_disable_intr(hw);
@@ -712,7 +712,7 @@ atl_dev_close(struct rte_eth_dev *dev)
rte_intr_callback_unregister(intr_handle,
atl_dev_interrupt_handler, dev);
- pthread_mutex_destroy(&hw->mbox_mutex);
+ rte_thread_mutex_destroy(&hw->mbox_mutex);
return ret;
}
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index e813d9f326..d99aa5fad0 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <netinet/in.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_common.h>
@@ -141,7 +141,7 @@ struct aq_hw_s {
u32 rpc_tid;
struct hw_aq_atl_utils_fw_rpc rpc;
- pthread_mutex_t mbox_mutex;
+ rte_thread_mutex mbox_mutex;
};
struct aq_fw_ops {
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 3a7faf405c..15b80584f8 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -6,7 +6,7 @@
*/
#include <rte_ether.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include "../atl_hw_regs.h"
#include "../atl_types.h"
@@ -218,7 +218,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
u32 mac_addr[2] = { 0 };
u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
if (efuse_addr != 0) {
err = hw_atl_utils_fw_downld_dwords(self,
@@ -257,7 +257,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -269,7 +269,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
u32 orig_stats_val = mpi_opts & BIT(CAPS_HI_STATISTICS);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to update */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_STATISTICS);
@@ -286,7 +286,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
err = hw_atl_utils_update_stats(self);
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
@@ -299,7 +299,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
u32 temp_val = mpi_opts & BIT(CAPS_HI_TEMPERATURE);
u32 temp_res;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_TEMPERATURE);
@@ -317,7 +317,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
sizeof(temp_res) / sizeof(u32));
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
if (err)
return err;
@@ -536,7 +536,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
if ((self->caps_lo & BIT(CAPS_LO_SMBUS_READ)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
request.msg_id = 0;
request.device_id = dev_addr;
@@ -605,7 +605,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -626,7 +626,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
request.address = offset;
request.length = len;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write SMBUS request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -694,7 +694,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -712,7 +712,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
if ((self->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write macsec request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -742,7 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32)));
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
index df0aa21a9b..a7b892b806 100644
--- a/drivers/net/axgbe/axgbe_common.h
+++ b/drivers/net/axgbe/axgbe_common.h
@@ -19,7 +19,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_bitops.h>
#include <rte_byteorder.h>
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 786288a7b0..197c722901 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -167,12 +167,12 @@ static int axgbe_read_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
mmd_data = XPCS16_IOREAD(pdata, offset);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
return mmd_data;
}
@@ -201,12 +201,12 @@ static void axgbe_write_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
XPCS16_IOWRITE(pdata, offset, mmd_data);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
}
static int axgbe_read_mmd_regs(struct axgbe_port *pdata, int prtad,
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 9cb4818af1..caf5a4476f 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -2311,10 +2311,10 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
pdata->tx_desc_count = AXGBE_MAX_RING_DESC;
pdata->rx_desc_count = AXGBE_MAX_RING_DESC;
- pthread_mutex_init(&pdata->xpcs_mutex, NULL);
- pthread_mutex_init(&pdata->i2c_mutex, NULL);
- pthread_mutex_init(&pdata->an_mutex, NULL);
- pthread_mutex_init(&pdata->phy_mutex, NULL);
+ rte_thread_mutex_init(&pdata->xpcs_mutex);
+ rte_thread_mutex_init(&pdata->i2c_mutex);
+ rte_thread_mutex_init(&pdata->an_mutex);
+ rte_thread_mutex_init(&pdata->phy_mutex);
ret = pdata->phy_if.phy_init(pdata);
if (ret) {
diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h
index a6226729fe..f2929d57ab 100644
--- a/drivers/net/axgbe/axgbe_ethdev.h
+++ b/drivers/net/axgbe/axgbe_ethdev.h
@@ -602,10 +602,10 @@ struct axgbe_port {
int phy_link;
int phy_speed;
- pthread_mutex_t xpcs_mutex;
- pthread_mutex_t i2c_mutex;
- pthread_mutex_t an_mutex;
- pthread_mutex_t phy_mutex;
+ rte_thread_mutex xpcs_mutex;
+ rte_thread_mutex i2c_mutex;
+ rte_thread_mutex an_mutex;
+ rte_thread_mutex phy_mutex;
/* Flow control settings */
unsigned int pause_autoneg;
diff --git a/drivers/net/axgbe/axgbe_i2c.c b/drivers/net/axgbe/axgbe_i2c.c
index ab3738a12e..c17f9a8b9e 100644
--- a/drivers/net/axgbe/axgbe_i2c.c
+++ b/drivers/net/axgbe/axgbe_i2c.c
@@ -229,7 +229,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
int ret;
uint64_t timeout;
- pthread_mutex_lock(&pdata->i2c_mutex);
+ rte_thread_mutex_lock(&pdata->i2c_mutex);
ret = axgbe_i2c_disable(pdata);
if (ret) {
PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
@@ -282,7 +282,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
}
unlock:
- pthread_mutex_unlock(&pdata->i2c_mutex);
+ rte_thread_mutex_unlock(&pdata->i2c_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c
index 4f98e695ae..5f3d9b360e 100644
--- a/drivers/net/axgbe/axgbe_mdio.c
+++ b/drivers/net/axgbe/axgbe_mdio.c
@@ -686,9 +686,9 @@ static void axgbe_an73_isr(struct axgbe_port *pdata)
if (pdata->an_int) {
/* Clear the interrupt(s) that fired and process them */
XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, ~pdata->an_int);
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
axgbe_an73_state_machine(pdata);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
} else {
/* Enable AN interrupts */
axgbe_an73_enable_interrupts(pdata);
@@ -977,7 +977,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
{
int ret;
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
ret = __axgbe_phy_config_aneg(pdata);
if (ret)
@@ -985,7 +985,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
else
rte_bit_relaxed_clear32(AXGBE_LINK_ERR, &pdata->dev_state);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 02236ec192..1e1d6358d8 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -403,7 +403,7 @@ static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata)
phy_data->comm_owned = 0;
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
}
static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
@@ -416,7 +416,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
* the driver needs to take the software mutex and then the hardware
* mutexes before being able to use the busses.
*/
- pthread_mutex_lock(&pdata->phy_mutex);
+ rte_thread_mutex_lock(&pdata->phy_mutex);
if (phy_data->comm_owned)
return 0;
@@ -447,7 +447,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
return 0;
}
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
PMD_DRV_LOG(ERR, "unable to obtain hardware mutexes\n");
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index db67bff127..656ee70f66 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -534,8 +534,8 @@ struct bnxt_mark_info {
struct bnxt_rep_info {
struct rte_eth_dev *vfr_eth_dev;
- pthread_mutex_t vfr_lock;
- pthread_mutex_t vfr_start_lock;
+ rte_thread_mutex vfr_lock;
+ rte_thread_mutex vfr_start_lock;
bool conduit_valid;
};
@@ -687,7 +687,7 @@ struct bnxt {
#define BNXT_FW_CAP_ADV_FLOW_COUNTERS BIT(6)
#define BNXT_FW_CAP_LINK_ADMIN BIT(7)
- pthread_mutex_t flow_lock;
+ rte_thread_mutex flow_lock;
uint32_t vnic_cap_flags;
#define BNXT_VNIC_CAP_COS_CLASSIFY BIT(0)
@@ -741,18 +741,18 @@ struct bnxt {
rte_iova_t hwrm_short_cmd_req_dma_addr;
rte_spinlock_t hwrm_lock;
/* synchronize between dev_configure_op and int handler */
- pthread_mutex_t def_cp_lock;
+ rte_thread_mutex def_cp_lock;
/* synchronize between dev_start_op and async evt handler
* Locking sequence in async evt handler will be
* def_cp_lock
* health_check_lock
*/
- pthread_mutex_t health_check_lock;
+ rte_thread_mutex health_check_lock;
/* synchronize between dev_stop/dev_close_op and
* error recovery thread triggered as part of
* HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY
*/
- pthread_mutex_t err_recovery_lock;
+ rte_thread_mutex err_recovery_lock;
uint16_t max_req_len;
uint16_t max_resp_len;
uint16_t hwrm_max_ext_req_len;
@@ -944,10 +944,10 @@ uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
extern const struct rte_flow_ops bnxt_flow_ops;
#define bnxt_acquire_flow_lock(bp) \
- pthread_mutex_lock(&(bp)->flow_lock)
+ rte_thread_mutex_lock(&(bp)->flow_lock)
#define bnxt_release_flow_lock(bp) \
- pthread_mutex_unlock(&(bp)->flow_lock)
+ rte_thread_mutex_unlock(&(bp)->flow_lock)
#define BNXT_VALID_VNIC_OR_RET(bp, vnic_id) do { \
if ((vnic_id) >= (bp)->max_vnics) { \
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 2c7fd78c3d..a50511047c 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -135,7 +135,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
return;
}
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
event_data = rte_le_to_cpu_32(async_cmp->event_data1);
/* timestamp_lo/hi values are in units of 100ms */
bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
@@ -157,7 +157,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
}
bp->flags |= BNXT_FLAG_FW_RESET;
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
(void *)bp);
break;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3778e28cca..ae355f4a36 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1049,7 +1049,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
* are calculated correctly.
*/
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
bnxt_disable_int(bp);
@@ -1059,20 +1059,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return -ENOSPC;
}
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
rc = bnxt_alloc_async_cp_ring(bp);
if (rc) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return rc;
}
bnxt_enable_int(bp);
}
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
/* Inherit new configurations */
@@ -1456,14 +1456,14 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error..Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return bnxt_dev_stop(eth_dev);
}
@@ -1545,13 +1545,13 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
static void
bnxt_uninit_locks(struct bnxt *bp)
{
- pthread_mutex_destroy(&bp->flow_lock);
- pthread_mutex_destroy(&bp->def_cp_lock);
- pthread_mutex_destroy(&bp->health_check_lock);
- pthread_mutex_destroy(&bp->err_recovery_lock);
+ rte_thread_mutex_destroy(&bp->flow_lock);
+ rte_thread_mutex_destroy(&bp->def_cp_lock);
+ rte_thread_mutex_destroy(&bp->health_check_lock);
+ rte_thread_mutex_destroy(&bp->err_recovery_lock);
if (bp->rep_info) {
- pthread_mutex_destroy(&bp->rep_info->vfr_lock);
- pthread_mutex_destroy(&bp->rep_info->vfr_start_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_start_lock);
}
}
@@ -1583,14 +1583,14 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error...Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
/* cancel the recovery handler before remove dev */
rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp);
@@ -4073,7 +4073,7 @@ static void bnxt_dev_recover(void *arg)
struct bnxt *bp = arg;
int rc = 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (!bp->fw_reset_min_msecs) {
rc = bnxt_check_fw_reset_done(bp);
@@ -4108,7 +4108,7 @@ static void bnxt_dev_recover(void *arg)
goto err_start;
PMD_DRV_LOG(INFO, "Recovered from FW reset\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return;
err_start:
@@ -4116,7 +4116,7 @@ static void bnxt_dev_recover(void *arg)
err:
bp->flags |= BNXT_FLAG_FATAL_ERROR;
bnxt_uninit_resources(bp, false);
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
PMD_DRV_LOG(ERR, "Failed to recover from FW reset\n");
}
@@ -4292,7 +4292,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
{
uint32_t polling_freq;
- pthread_mutex_lock(&bp->health_check_lock);
+ rte_thread_mutex_lock(&bp->health_check_lock);
if (!bnxt_is_recovery_enabled(bp))
goto done;
@@ -4307,7 +4307,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
done:
- pthread_mutex_unlock(&bp->health_check_lock);
+ rte_thread_mutex_unlock(&bp->health_check_lock);
}
static void bnxt_cancel_fw_health_check(struct bnxt *bp)
@@ -5093,25 +5093,25 @@ bnxt_init_locks(struct bnxt *bp)
{
int err;
- err = pthread_mutex_init(&bp->flow_lock, NULL);
+ err = rte_thread_mutex_init(&bp->flow_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->def_cp_lock, NULL);
+ err = rte_thread_mutex_init(&bp->def_cp_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->health_check_lock, NULL);
+ err = rte_thread_mutex_init(&bp->health_check_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize health_check_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
+ err = rte_thread_mutex_init(&bp->err_recovery_lock);
if (err)
PMD_DRV_LOG(ERR, "Unable to initialize err_recovery_lock\n");
@@ -5894,14 +5894,14 @@ static int bnxt_init_rep_info(struct bnxt *bp)
for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
- rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_lock\n");
bnxt_free_rep_info(bp);
return rc;
}
- rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_start_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_start_lock\n");
bnxt_free_rep_info(bp);
diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 8abbadb3d1..e1d980cf91 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -30,15 +30,15 @@ void bnxt_int_handler(void *param)
return;
raw_cons = cpr->cp_raw_cons;
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
while (1) {
if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
if (is_bnxt_in_error(bp)) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
@@ -58,7 +58,7 @@ void bnxt_int_handler(void *param)
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
int bnxt_free_int(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index bdbad53b7d..49d3ec66bc 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -120,7 +120,7 @@ bnxt_rep_tx_burst(void *tx_queue,
qid = vfr_txq->txq->queue_id;
vf_rep_bp = vfr_txq->bp;
parent = vf_rep_bp->parent_dev->data->dev_private;
- pthread_mutex_lock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_lock(&parent->rep_info->vfr_lock);
ptxq = parent->tx_queues[qid];
ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
@@ -132,7 +132,7 @@ bnxt_rep_tx_burst(void *tx_queue,
rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
ptxq->vfr_tx_cfa_action = 0;
- pthread_mutex_unlock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_unlock(&parent->rep_info->vfr_lock);
return rc;
}
@@ -407,15 +407,15 @@ int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
rep_info = &parent_bp->rep_info[rep_bp->vf_id];
BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR start\n", eth_dev->data->port_id);
- pthread_mutex_lock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_lock(&rep_info->vfr_start_lock);
if (!rep_info->conduit_valid) {
rc = bnxt_get_dflt_vnic_svif(parent_bp, rep_bp);
if (rc || !rep_info->conduit_valid) {
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
return rc;
}
}
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
rc = bnxt_vfr_alloc(eth_dev);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 5c805eef97..6691fc2fd7 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -28,7 +28,7 @@ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
STAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);
/* Mutex to synchronize bnxt_ulp_session_list operations. */
-static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(bnxt_ulp_global_mutex)
/*
* Allow the deletion of context only for the bnxt device that
@@ -640,7 +640,7 @@ ulp_ctx_detach(struct bnxt *bp)
static void
ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
{
- pthread_mutex_lock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_lock(&session->bnxt_ulp_mutex);
if (!session->bnxt_ulp_init) {
session->bnxt_ulp_init = true;
@@ -649,7 +649,7 @@ ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
*init = true;
}
- pthread_mutex_unlock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_unlock(&session->bnxt_ulp_mutex);
}
/*
@@ -690,7 +690,7 @@ ulp_session_init(struct bnxt *bp,
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
if (!session) {
@@ -701,17 +701,17 @@ ulp_session_init(struct bnxt *bp,
if (!session) {
BNXT_TF_DBG(ERR,
"Allocation failed for bnxt_ulp_session\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
} else {
/* Add it to the queue */
session->pci_info.domain = pci_addr->domain;
session->pci_info.bus = pci_addr->bus;
- rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
+ rc = rte_thread_mutex_init(&session->bnxt_ulp_mutex);
if (rc) {
BNXT_TF_DBG(ERR, "mutex create failed\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
}
STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
@@ -719,7 +719,7 @@ ulp_session_init(struct bnxt *bp,
}
}
ulp_context_initialized(session, init);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return session;
}
@@ -734,12 +734,12 @@ ulp_session_deinit(struct bnxt_ulp_session_state *session)
return;
if (!session->cfg_data) {
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
STAILQ_REMOVE(&bnxt_ulp_session_list, session,
bnxt_ulp_session_state, next);
- pthread_mutex_destroy(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_destroy(&session->bnxt_ulp_mutex);
rte_free(session);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
}
}
@@ -892,7 +892,7 @@ bnxt_ulp_deinit(struct bnxt *bp,
BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0);
/* free the flow db lock */
- pthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
/* Delete the ulp context and tf session and free the ulp context */
ulp_ctx_deinit(bp, session);
@@ -917,7 +917,7 @@ bnxt_ulp_init(struct bnxt *bp,
goto jump_to_error;
}
- rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (rc) {
BNXT_TF_DBG(ERR, "Unable to initialize flow db lock\n");
goto jump_to_error;
@@ -1117,9 +1117,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp)
/* Get the session details */
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
/* session not found then just exit */
if (!session) {
@@ -1451,7 +1451,7 @@ bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return -1;
- if (pthread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
+ if (rte_thread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
BNXT_TF_DBG(ERR, "unable to acquire fdb lock\n");
return -1;
}
@@ -1465,5 +1465,5 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return;
- pthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
}
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 330965061a..86680f2f46 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -49,7 +49,7 @@ struct bnxt_ulp_data {
uint32_t dev_id; /* Hardware device id */
uint32_t ref_cnt;
struct bnxt_ulp_flow_db *flow_db;
- pthread_mutex_t flow_db_lock;
+ rte_thread_mutex flow_db_lock;
void *mapper_data;
struct bnxt_ulp_port_db *port_db;
struct bnxt_ulp_fc_info *fc_info;
@@ -75,7 +75,7 @@ struct bnxt_ulp_pci_info {
struct bnxt_ulp_session_state {
STAILQ_ENTRY(bnxt_ulp_session_state) next;
bool bnxt_ulp_init;
- pthread_mutex_t bnxt_ulp_mutex;
+ rte_thread_mutex bnxt_ulp_mutex;
struct bnxt_ulp_pci_info pci_info;
struct bnxt_ulp_data *cfg_data;
struct tf *g_tfp;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 3eddbd6831..94fe39d7a3 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -3,6 +3,7 @@
* All rights reserved.
*/
+#include <pthread.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
@@ -84,7 +85,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
if (!ulp_fc_info)
goto error;
- rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
+ rc = rte_thread_mutex_init(&ulp_fc_info->fc_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize fc mutex\n");
goto error;
@@ -141,7 +142,7 @@ ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt)
ulp_fc_mgr_thread_cancel(ctxt);
- pthread_mutex_destroy(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_destroy(&ulp_fc_info->fc_lock);
for (i = 0; i < TF_DIR_MAX; i++)
rte_free(ulp_fc_info->sw_acc_tbl[i]);
@@ -379,11 +380,12 @@ ulp_fc_mgr_alarm_cb(void *arg)
* Take the fc_lock to ensure no flow is destroyed
* during the bulk get
*/
- if (pthread_mutex_trylock(&ulp_fc_info->fc_lock))
+ if (pthread_mutex_trylock((pthread_mutex_t *)
+ &ulp_fc_info->fc_lock.mutex_id))
goto out;
if (!ulp_fc_info->num_entries) {
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
ulp_fc_mgr_thread_cancel(ctxt);
return;
}
@@ -414,7 +416,7 @@ ulp_fc_mgr_alarm_cb(void *arg)
}
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
/*
* If cmd fails once, no need of
@@ -503,12 +505,12 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = true;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = hw_cntr_id;
ulp_fc_info->num_entries++;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -535,14 +537,14 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = false;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].pkt_count = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].byte_count = 0;
ulp_fc_info->num_entries--;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -607,7 +609,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
hw_cntr_id = params.resource_hndl;
if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id -
ulp_fc_info->shadow_hw_tbl[dir].start_idx;
sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
@@ -621,7 +623,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
sw_acc_tbl_entry->pkt_count = 0;
sw_acc_tbl_entry->byte_count = 0;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
} else if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT_ACC) {
/* Get stats from the parent child table */
@@ -663,7 +665,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
if (ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid) {
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].parent_flow_id = fid;
@@ -672,7 +674,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
hw_cntr_id, fid);
rc = -ENOENT;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return rc;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index 04cb86bea2..cfc8ea29d8 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -47,7 +47,7 @@ struct bnxt_ulp_fc_info {
struct hw_fc_mem_info shadow_hw_tbl[TF_DIR_MAX];
uint32_t flags;
uint32_t num_entries;
- pthread_mutex_t fc_lock;
+ rte_thread_mutex fc_lock;
};
int32_t
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 27d670f843..0983630f5e 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 423de40e95..55eb14af5f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <limits.h>
#include <sched.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_byteorder.h>
#include <rte_common.h>
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index f66df95591..7ddcbc1ac4 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
@@ -148,14 +149,14 @@ extern int ena_logtype_com;
typedef struct {
pthread_cond_t cond;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
uint8_t flag;
} ena_wait_event_t;
#define ENA_WAIT_EVENT_INIT(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_init(&_we->mutex, NULL); \
+ rte_thread_mutex_init(&_we->mutex); \
pthread_cond_init(&_we->cond, NULL); \
_we->flag = 0; \
} while (0)
@@ -172,10 +173,10 @@ typedef struct {
wait.tv_sec = now.tv_sec + _tmo / 1000000UL; \
timeout_us = _tmo % 1000000UL; \
wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
while (ret == 0 && !_we->flag) { \
ret = pthread_cond_timedwait(&_we->cond, \
- &_we->mutex, &wait); \
+ _we->mutex.mutex_id, &wait); \
} \
/* Asserts only if not working on ena_wait_event_t */ \
if (unlikely(ret != 0 && ret != ETIMEDOUT)) \
@@ -185,15 +186,15 @@ typedef struct {
ena_trc_err(NULL, \
"Timeout waiting for " #waitevent "\n"); \
_we->flag = 0; \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
#define ENA_WAIT_EVENT_SIGNAL(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
_we->flag = 1; \
pthread_cond_signal(&_we->cond); \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
/* pthread condition doesn't need to be rearmed after usage */
#define ENA_WAIT_EVENT_CLEAR(...)
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 47bfdac2cf..db07c589b9 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -107,7 +107,7 @@ struct enic {
int iommu_groupid;
int eventfd;
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
- pthread_t err_intr_thread;
+ rte_thread_t err_intr_thread;
int promisc;
int allmulti;
uint8_t ig_vlan_strip_en;
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index 1d7aa8bc87..5fd769a82d 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -3,7 +3,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <unistd.h>
#include <rte_spinlock.h>
@@ -121,7 +121,7 @@ ice_dcf_vsi_update_service_handler(void *param)
struct ice_dcf_hw *hw = reset_param->dcf_hw;
struct ice_dcf_adapter *adapter;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL);
@@ -156,7 +156,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
#define THREAD_NAME_LEN 16
struct ice_dcf_reset_event_param *param;
char name[THREAD_NAME_LEN];
- pthread_t thread;
+ rte_thread_t thread;
int ret;
param = malloc(sizeof(*param));
@@ -170,7 +170,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
param->vf_id = vf_id;
snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
- ret = rte_ctrl_thread_create(&thread, name, NULL,
+ ret = rte_thread_ctrl_thread_create(&thread, name,
ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b5371568b5..cf7b19edc0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4156,7 +4156,7 @@ ixgbe_dev_setup_link_thread_handler(void *param)
u32 speed;
bool autoneg = false;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
speed = hw->phy.autoneg_advertised;
if (!speed)
ixgbe_get_link_capabilities(hw, &speed, &autoneg);
@@ -4264,9 +4264,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
* when there is no link thread running.
*/
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
- if (rte_ctrl_thread_create(&ad->link_thread_tid,
+ if (rte_thread_ctrl_thread_create
+ (&ad->link_thread_tid,
"ixgbe-link-handler",
- NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index a0ce18ca24..272fdcfb8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -516,7 +516,7 @@ struct ixgbe_adapter {
uint8_t pflink_fullchk;
uint8_t mac_ctrl_frame_fwd;
rte_atomic32_t link_thread_running;
- pthread_t link_thread_tid;
+ rte_thread_t link_thread_tid;
};
struct ixgbe_vf_representor {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 534a56a555..15080bbc1c 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2557,7 +2557,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
sh->numa_node = spawn->pci_dev->device.numa_node;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/*
* Configure environment variable "MLX5_BF_SHUT_UP"
* before the device creation. The rdma_core library
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cf1815cb74..375fcde4df 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -183,7 +183,7 @@ int mlx5_logtype;
static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
LIST_HEAD_INITIALIZER();
-static pthread_mutex_t mlx5_dev_ctx_list_mutex;
+static rte_thread_mutex mlx5_dev_ctx_list_mutex;
static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
[MLX5_IPOOL_DECAP_ENCAP] = {
@@ -1088,7 +1088,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
MLX5_ASSERT(spawn);
/* Secondary process should not create the shared context. */
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
/* Search for IB context by device name. */
LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
if (!strcmp(sh->ibdev_name,
@@ -1215,11 +1215,11 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
LIST_INSERT_HEAD(&mlx5_dev_ctx_list, sh, next);
rte_spinlock_init(&sh->geneve_tlv_opt_sl);
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
return sh;
error:
- pthread_mutex_destroy(&sh->txpp.mutex);
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
MLX5_ASSERT(sh);
if (sh->cnt_id_tbl)
mlx5_l3t_destroy(sh->cnt_id_tbl);
@@ -1251,7 +1251,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
void
mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
{
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Check the object presence in the list. */
struct mlx5_dev_ctx_shared *lctx;
@@ -1282,7 +1282,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
/* Release flow workspaces objects on the last device. */
if (LIST_EMPTY(&mlx5_dev_ctx_list))
mlx5_flow_os_release_workspace();
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.
* Only primary process handles async device events.
@@ -1315,11 +1315,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
if (sh->ctx)
claim_zero(mlx5_glue->close_device(sh->ctx));
MLX5_ASSERT(sh->geneve_tlv_option_resource == NULL);
- pthread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
mlx5_free(sh);
return;
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
}
/**
@@ -2450,7 +2450,7 @@ RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
*/
RTE_INIT(rte_mlx5_pmd_init)
{
- pthread_mutex_init(&mlx5_dev_ctx_list_mutex, NULL);
+ rte_thread_mutex_init(&mlx5_dev_ctx_list_mutex);
mlx5_common_init();
/* Build the static tables for Verbs conversion. */
mlx5_set_ptype_table();
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 32b2817bf2..ecc4ed204a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -949,7 +949,7 @@ struct mlx5_txpp_ts {
/* Tx packet pacing structure. */
struct mlx5_dev_txpp {
- pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
+ rte_thread_mutex mutex; /* Pacing create/destroy mutex. */
uint32_t refcnt; /* Pacing reference counter. */
uint32_t freq; /* Timestamp frequency, Hz. */
uint32_t tick; /* Completion tick duration in nanoseconds. */
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index d90399afb5..e308c5e599 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -905,7 +905,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
if (ret < 0)
return 0;
}
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
if (sh->txpp.refcnt) {
@@ -921,7 +921,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
rte_errno = -err;
}
}
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
return err;
@@ -948,7 +948,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
}
priv->txpp_en = 0;
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
MLX5_ASSERT(sh->txpp.refcnt);
@@ -956,7 +956,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
/* No references any more, do actual destroy. */
mlx5_txpp_destroy(sh);
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
}
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index c4d5790726..ccdb0184a9 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -253,7 +253,7 @@ struct mlx5_workspace_thread {
static struct mlx5_workspace_thread *curr;
static struct mlx5_workspace_thread *first;
rte_thread_key ws_tls_index;
-static pthread_mutex_t lock_thread_list;
+RTE_STATIC_MUTEX(lock_thread_list)
static bool
mlx5_is_thread_alive(HANDLE thread_handle)
@@ -330,7 +330,7 @@ mlx5_flow_os_release_workspace(void)
free(first);
}
rte_thread_key_delete(ws_tls_index);
- pthread_mutex_destroy(&lock_thread_list);
+ rte_thread_mutex_destroy(&lock_thread_list);
}
static int
@@ -352,7 +352,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
}
temp->mlx5_ws = data;
temp->thread_handle = curr_thread;
- pthread_mutex_lock(&lock_thread_list);
+ rte_thread_mutex_lock(&lock_thread_list);
mlx5_clear_thread_list();
if (!first) {
first = temp;
@@ -361,7 +361,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
curr->next = temp;
curr = curr->next;
}
- pthread_mutex_unlock(&lock_thread_list);
+ rte_thread_mutex_unlock(&lock_thread_list);
return 0;
}
@@ -374,7 +374,7 @@ mlx5_flow_os_init_workspace_once(void)
DRV_LOG(ERR, "Can't create flow workspace data thread key.");
return err;
}
- pthread_mutex_init(&lock_thread_list, NULL);
+ rte_thread_mutex_init(&lock_thread_list);
return 0;
}
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 3fe3f55f49..e37e16d70f 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -228,7 +228,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
struct mlx5_context *mlx5_ctx;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/* Set numa node from pci probe */
sh->numa_node = spawn->pci_dev->device.numa_node;
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index c5b5399282..c9011d964b 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -153,10 +153,10 @@ void osal_dma_free_mem(struct ecore_dev *edev, dma_addr_t phys);
/* Mutexes */
-typedef pthread_mutex_t osal_mutex_t;
-#define OSAL_MUTEX_RELEASE(lock) pthread_mutex_unlock(lock)
-#define OSAL_MUTEX_INIT(lock) pthread_mutex_init(lock, NULL)
-#define OSAL_MUTEX_ACQUIRE(lock) pthread_mutex_lock(lock)
+typedef rte_thread_mutex osal_mutex_t;
+#define OSAL_MUTEX_RELEASE(lock) rte_thread_mutex_unlock(lock)
+#define OSAL_MUTEX_INIT(lock) rte_thread_mutex_init(lock)
+#define OSAL_MUTEX_ACQUIRE(lock) rte_thread_mutex_lock(lock)
#define OSAL_MUTEX_ALLOC(hwfn, lock) nothing
#define OSAL_MUTEX_DEALLOC(lock) nothing
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index a202931e9a..484b647a62 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -3,7 +3,7 @@
* Copyright(c) 2016-2018 Intel Corporation
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdbool.h>
#include <sys/epoll.h>
@@ -121,7 +121,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static struct rte_eth_link pmd_link = {
.link_speed = 10000,
@@ -507,7 +507,7 @@ find_internal_resource(char *ifname)
if (ifname == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internal = list->eth_dev->data->dev_private;
@@ -517,7 +517,7 @@ find_internal_resource(char *ifname)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -1001,9 +1001,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
goto free_list;
list->eth_dev = eth_dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_spinlock_init(&vring_state->lock);
vring_states[eth_dev->data->port_id] = vring_state;
@@ -1035,9 +1035,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
rte_vhost_driver_unregister(internal->iface_name);
list_remove:
vring_states[eth_dev->data->port_id] = NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(vring_state);
free_list:
rte_free(list);
@@ -1093,7 +1093,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
if (!rte_eth_dev_is_valid_port(port_id))
return -1;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
eth_dev = list->eth_dev;
@@ -1106,7 +1106,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return vid;
}
@@ -1184,9 +1184,9 @@ eth_dev_close(struct rte_eth_dev *dev)
list = find_internal_resource(internal->iface_name);
if (list) {
rte_vhost_driver_unregister(internal->iface_name);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 364f43e21c..9231da676b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -143,7 +143,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
uint64_t features;
int ret = -1;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 0: tell vhost to create queues */
if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
@@ -161,7 +161,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
goto error;
PMD_DRV_LOG(INFO, "(%s) set features: 0x%" PRIx64, dev->path, features);
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -185,7 +185,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
* memory subsystem in the future.
*/
rte_mcfg_mem_read_lock();
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 2: share memory regions */
ret = dev->ops->set_memory_table(dev);
@@ -206,12 +206,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
dev->started = true;
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
return 0;
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
PMD_INIT_LOG(ERR, "(%s) Failed to start device\n", dev->path);
@@ -226,7 +226,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
uint32_t i;
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (!dev->started)
goto out;
@@ -249,11 +249,11 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
dev->started = false;
out:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return 0;
err:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
PMD_INIT_LOG(ERR, "(%s) Failed to stop device\n", dev->path);
@@ -380,7 +380,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
if (msl->external)
return;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (dev->started == false)
goto exit;
@@ -405,7 +405,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
}
exit:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
if (ret < 0)
PMD_DRV_LOG(ERR, "(%s) Failed to update memory table\n", dev->path);
@@ -491,7 +491,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
uint64_t backend_features;
int i;
- pthread_mutex_init(&dev->mutex, NULL);
+ rte_thread_mutex_init(&dev->mutex);
strlcpy(dev->path, path, PATH_MAX);
for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; i++) {
@@ -796,13 +796,13 @@ virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status)
{
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
dev->status = status;
ret = dev->ops->set_status(dev, status);
if (ret && ret != -ENOTSUP)
PMD_INIT_LOG(ERR, "(%s) Failed to set backend status\n", dev->path);
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -812,7 +812,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
int ret;
uint8_t status;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
ret = dev->ops->get_status(dev, &status);
if (!ret) {
@@ -837,7 +837,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
PMD_INIT_LOG(ERR, "(%s) Failed to get backend status\n", dev->path);
}
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 58ad5198b6..9de8f5e67b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -55,7 +55,7 @@ struct virtio_user_dev {
bool qp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];
struct virtio_user_backend_ops *ops;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
bool started;
void *backend_data;
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 1dc813d0a3..81ff6c2d58 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -23,6 +23,7 @@
#include <rte_log.h>
#include <rte_kvargs.h>
#include <rte_devargs.h>
+#include <rte_thread.h>
#include "base/ifcvf.h"
@@ -52,7 +53,7 @@ struct ifcvf_internal {
int vfio_container_fd;
int vfio_group_fd;
int vfio_dev_fd;
- pthread_t tid; /* thread for notify relay */
+ rte_thread_t tid; /* thread for notify relay */
int epfd;
int vid;
struct rte_vdpa_device *vdev;
@@ -79,7 +80,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static void update_used_ring(struct ifcvf_internal *internal, uint16_t qid);
@@ -89,7 +90,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (vdev == list->internal->vdev) {
@@ -98,7 +99,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -112,7 +113,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (!rte_pci_addr_cmp(&pdev->addr,
@@ -122,7 +123,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -500,10 +501,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, notify_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create notify relay pthread.");
+ DRV_LOG(ERR, "failed to create notify relay thread.");
return -1;
}
@@ -513,13 +514,11 @@ setup_notify_relay(struct ifcvf_internal *internal)
static int
unset_notify_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -806,10 +805,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, vring_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create ring relay pthread.");
+ DRV_LOG(ERR, "failed to create ring relay thread.");
return -1;
}
@@ -819,13 +818,11 @@ setup_vring_relay(struct ifcvf_internal *internal)
static int
unset_vring_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -1253,9 +1250,9 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto error;
}
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_atomic32_set(&internal->started, 1);
update_datapath(internal);
@@ -1293,9 +1290,9 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
rte_vfio_container_destroy(internal->vfio_container_fd);
rte_vdpa_unregister_device(internal->vdev);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
rte_free(internal);
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index e5e03e6582..c7a6fee2c7 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -48,7 +48,7 @@
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
static struct mlx5_vdpa_priv *
mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
@@ -56,14 +56,14 @@ mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
struct mlx5_vdpa_priv *priv;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (vdev == priv->vdev) {
found = 1;
break;
}
}
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (!found) {
DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name);
rte_errno = EINVAL;
@@ -143,9 +143,9 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)
DRV_LOG(ERR, "Too big vring id: %d.", vring);
return -E2BIG;
}
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
ret = mlx5_vdpa_virtq_enable(priv, vring, state);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
return ret;
}
@@ -296,7 +296,7 @@ mlx5_vdpa_dev_close(int vid)
priv->configured = 0;
priv->vid = 0;
/* The mutex may stay locked after event thread cancel - initiate it. */
- pthread_mutex_init(&priv->vq_config_lock, NULL);
+ rte_thread_mutex_init(&priv->vq_config_lock);
DRV_LOG(INFO, "vDPA device %d was closed.", vid);
return ret;
}
@@ -736,10 +736,10 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
mlx5_vdpa_config_get(pci_dev->device.devargs, priv);
SLIST_INIT(&priv->mr_list);
- pthread_mutex_init(&priv->vq_config_lock, NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_init(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
error:
@@ -770,7 +770,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
struct mlx5_vdpa_priv *priv = NULL;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (!rte_pci_addr_cmp(&priv->pci_dev->addr, &pci_dev->addr)) {
found = 1;
@@ -779,7 +779,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
}
if (found)
TAILQ_REMOVE(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (found) {
if (priv->configured)
mlx5_vdpa_dev_close(priv->vid);
@@ -790,7 +790,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)
if (priv->vdev)
rte_vdpa_unregister_device(priv->vdev);
mlx5_glue->close_device(priv->ctx);
- pthread_mutex_destroy(&priv->vq_config_lock);
+ rte_thread_mutex_destroy(&priv->vq_config_lock);
rte_free(priv);
}
return 0;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h
index 722c72b65e..e44125ec3f 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.h
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h
@@ -119,9 +119,9 @@ enum {
struct mlx5_vdpa_priv {
TAILQ_ENTRY(mlx5_vdpa_priv) next;
uint8_t configured;
- pthread_mutex_t vq_config_lock;
+ rte_thread_mutex vq_config_lock;
uint64_t no_traffic_counter;
- pthread_t timer_tid;
+ rte_thread_t timer_tid;
int event_mode;
int event_core; /* Event thread cpu affinity core. */
uint32_t event_us;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 88f6a4256d..992dcd9702 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -285,7 +285,7 @@ mlx5_vdpa_event_handle(void *arg)
case MLX5_VDPA_EVENT_MODE_FIXED_TIMER:
priv->timer_delay_us = priv->event_us;
while (1) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
max = mlx5_vdpa_queues_complete(priv);
if (max == 0 && priv->no_traffic_counter++ >=
priv->no_traffic_max) {
@@ -293,10 +293,10 @@ mlx5_vdpa_event_handle(void *arg)
priv->vdev->device->name);
mlx5_vdpa_arm_all_cqs(priv);
do {
- pthread_mutex_unlock
+ rte_thread_mutex_unlock
(&priv->vq_config_lock);
cq = mlx5_vdpa_event_wait(priv);
- pthread_mutex_lock
+ rte_thread_mutex_lock
(&priv->vq_config_lock);
if (cq == NULL ||
mlx5_vdpa_queue_complete(cq) > 0)
@@ -307,7 +307,7 @@ mlx5_vdpa_event_handle(void *arg)
} else if (max != 0) {
priv->no_traffic_counter = 0;
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
mlx5_vdpa_timer_sleep(priv, max);
}
return NULL;
@@ -315,10 +315,10 @@ mlx5_vdpa_event_handle(void *arg)
do {
cq = mlx5_vdpa_event_wait(priv);
if (cq != NULL) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
if (mlx5_vdpa_queue_complete(cq) > 0)
mlx5_vdpa_cq_arm(priv, cq);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
}
} while (1);
return NULL;
@@ -340,7 +340,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
struct mlx5_vdpa_virtq *virtq;
uint64_t sec;
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
while (mlx5_glue->devx_get_event(priv->err_chnl, &out.event_resp,
sizeof(out.buf)) >=
(ssize_t)sizeof(out.event_resp.cookie)) {
@@ -386,7 +386,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
virtq->err_time[i - 1] = virtq->err_time[i];
virtq->err_time[RTE_DIM(virtq->err_time) - 1] = rte_rdtsc();
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
#endif
}
@@ -473,28 +473,23 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
{
int ret;
rte_cpuset_t cpuset;
- pthread_attr_t attr;
+ rte_thread_attr_t attr;
char name[16];
- const struct sched_param sp = {
- .sched_priority = sched_get_priority_max(SCHED_RR),
- };
if (!priv->eventc)
/* All virtqs are in poll mode. */
return 0;
- pthread_attr_init(&attr);
- ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
- if (ret) {
- DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
- return -1;
- }
- ret = pthread_attr_setschedparam(&attr, &sp);
+
+ rte_thread_attr_init(&attr);
+ ret = rte_thread_attr_set_priority(&attr,
+ RTE_THREAD_PRIORITY_REALTIME_CRITICAL);
if (ret) {
DRV_LOG(ERR, "Failed to set thread priority.");
return -1;
}
- ret = pthread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
- (void *)priv);
+
+ ret = rte_thread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
+ (void *)priv);
if (ret) {
DRV_LOG(ERR, "Failed to create timer thread.");
return -1;
@@ -504,13 +499,13 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
CPU_SET(priv->event_core, &cpuset);
else
cpuset = rte_lcore_cpuset(rte_get_main_lcore());
- ret = pthread_setaffinity_np(priv->timer_tid, sizeof(cpuset), &cpuset);
+ ret = rte_thread_set_affinity_by_id(priv->timer_tid, &cpuset);
if (ret) {
DRV_LOG(ERR, "Failed to set thread affinity.");
return -1;
}
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
- ret = rte_thread_setname(priv->timer_tid, name);
+ ret = rte_thread_name_set(priv->timer_tid, name);
if (ret)
DRV_LOG(DEBUG, "Cannot set timer thread name.");
return 0;
@@ -519,13 +514,11 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
void
mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv)
{
- void *status;
-
- if (priv->timer_tid) {
- pthread_cancel(priv->timer_tid);
- pthread_join(priv->timer_tid, &status);
+ if (priv->timer_tid.opaque_id) {
+ pthread_cancel(priv->timer_tid.opaque_id);
+ rte_thread_join(priv->timer_tid, NULL);
}
- priv->timer_tid = 0;
+ priv->timer_tid.opaque_id = 0;
}
void
diff --git a/examples/kni/main.c b/examples/kni/main.c
index beabb3c848..601c9838a2 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -16,6 +16,7 @@
#include <linux/if.h>
#include <linux/if_tun.h>
#include <fcntl.h>
+#include <pthread.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <signal.h>
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h
index e90fb15fc1..9979cc6cdb 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.h
+++ b/examples/performance-thread/pthread_shim/pthread_shim.h
@@ -6,6 +6,7 @@
#define _PTHREAD_SHIM_H_
#include <rte_lcore.h>
+#include <pthread.h>
/*
* This pthread shim is an example that demonstrates how legacy code
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 4/6] lib: enable the new EAL thread API
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (2 preceding siblings ...)
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
` (2 subsequent siblings)
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_options.c | 6 ++---
lib/eal/common/eal_common_thread.c | 13 +++++----
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/malloc_mp.c | 2 ++
lib/eal/freebsd/eal.c | 18 ++++++-------
lib/eal/freebsd/eal_alarm.c | 12 ++++-----
lib/eal/freebsd/eal_interrupts.c | 6 ++---
lib/eal/freebsd/eal_thread.c | 10 ++++---
lib/eal/include/rte_lcore.h | 6 +++++
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/linux/eal.c | 22 ++++++++--------
lib/eal/linux/eal_alarm.c | 10 ++++---
lib/eal/linux/eal_interrupts.c | 8 +++---
lib/eal/linux/eal_thread.c | 11 +++++---
lib/eal/linux/eal_timer.c | 6 ++---
lib/eal/version.map | 4 +--
lib/eal/windows/eal.c | 4 ++-
lib/eal/windows/eal_interrupts.c | 10 +++----
lib/eal/windows/eal_thread.c | 35 ++++---------------------
lib/eal/windows/eal_windows.h | 10 -------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/rte_thread.c | 2 +-
lib/ethdev/rte_ethdev.c | 4 +--
lib/ethdev/rte_ethdev_core.h | 4 +--
lib/ethdev/rte_flow.c | 4 +--
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
28 files changed, 101 insertions(+), 114 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 9d29696b84..1f6aba498c 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1872,8 +1872,7 @@ eal_auto_detect_cores(struct rte_config *cfg)
unsigned int removed = 0;
rte_cpuset_t affinity_set;
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &affinity_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set))
CPU_ZERO(&affinity_set);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
@@ -1901,8 +1900,7 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
}
RTE_CPU_NOT(cpuset, cpuset);
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &default_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set))
CPU_ZERO(&default_set);
RTE_CPU_AND(cpuset, cpuset, &default_set);
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 79545c67d9..62d28e7b28 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -6,7 +6,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <pthread.h>
+#endif /* RTE_EXEC_ENV_WINDOWS */
+#include <rte_thread.h>
#include <signal.h>
#include <sched.h>
#include <assert.h>
@@ -86,9 +89,8 @@ thread_update_affinity(rte_cpuset_t *cpusetp)
int
rte_thread_set_affinity(rte_cpuset_t *cpusetp)
{
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- cpusetp) != 0) {
- RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+ if (rte_thread_set_affinity_by_id(rte_thread_self(), cpusetp) != 0) {
+ RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
return -1;
}
@@ -166,6 +168,7 @@ __rte_thread_uninit(void)
RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
struct rte_thread_ctrl_params {
void *(*start_routine)(void *);
void *arg;
@@ -258,6 +261,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+#endif
struct rte_thread_ctrl_ctx {
rte_thread_func start_routine;
@@ -357,8 +361,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
- &cpuset) != 0)
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0)
CPU_ZERO(&cpuset);
lcore_id = eal_lcore_non_eal_allocate();
if (lcore_id >= RTE_MAX_LCORE)
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 24e27387b1..ddbc692cf2 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -7,6 +7,7 @@
#include <sys/queue.h>
#include <regex.h>
+#include <pthread.h>
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 64cf4e81c8..4b95001d7d 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -19,7 +19,7 @@
* Structure storing internal configuration (per-lcore)
*/
struct lcore_config {
- pthread_t thread_id; /**< pthread identifier */
+ rte_thread_t thread_id; /**< pthread identifier */
int pipe_main2worker[2]; /**< communication pipe with main */
int pipe_worker2main[2]; /**< communication pipe with main */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2e597a17a2..7f7109d954 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <sys/time.h>
+#include <pthread.h>
+
#include <rte_alarm.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index f4d1676754..b5cf050697 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -667,7 +667,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
@@ -690,7 +690,7 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -854,7 +854,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -866,7 +866,7 @@ rte_eal_init(int argc, char **argv)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- config->main_lcore, thread_id, cpuset,
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -883,7 +883,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -891,10 +891,10 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- rte_thread_setname(lcore_config[i].thread_id, thread_name);
+ rte_thread_name_set(lcore_config[i].thread_id, thread_name);
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index c38b2e04f8..e5d7b130b1 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -37,7 +37,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -156,7 +156,7 @@ eal_alarm_callback(void *arg __rte_unused)
while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -263,8 +263,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
* finish. Otherwise we are trying to cancel
* ourselves - mark it by EINPROGRESS.
*/
- if (pthread_equal(ap->executing_id,
- pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -285,8 +285,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id,
- pthread_self()) == 0) {
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0) {
executing++;
} else {
err = EINPROGRESS;
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 86810845fe..61b6ef1f48 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -628,7 +628,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -737,5 +737,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 1dce9b04f2..8c572c7930 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sched.h>
#include <pthread_np.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <sys/thr.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,7 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (void *)thread_id.opaque_id, cpuset, ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 1550b75da0..8fab21299a 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -362,6 +362,7 @@ __rte_experimental
void
rte_lcore_dump(FILE *f);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Set thread names.
*
@@ -393,6 +394,8 @@ int rte_thread_setname(pthread_t id, const char *name);
__rte_experimental
int rte_thread_getname(pthread_t id, char *name, size_t len);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
/**
* Register current non-EAL thread as a lcore.
*
@@ -417,6 +420,7 @@ __rte_experimental
void
rte_thread_unregister(void);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Create a control thread.
*
@@ -444,6 +448,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0cb37..df1e51dcb8 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#include <pthread.h>
+#include <rte_thread.h>
/**
* Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index ba19fc6347..7060856d84 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -963,7 +963,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
const char *p;
@@ -991,7 +991,7 @@ rte_eal_init(int argc, char **argv)
p = strrchr(argv[0], '/');
strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -1219,7 +1219,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -1229,8 +1229,8 @@ rte_eal_init(int argc, char **argv)
&lcore_config[config->main_lcore].cpuset);
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
- RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->main_lcore, (uintptr_t)thread_id, cpuset,
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -1247,7 +1247,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1255,14 +1255,14 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- ret = rte_thread_setname(lcore_config[i].thread_id,
- thread_name);
+ ret = rte_thread_name_set(lcore_config[i].thread_id,
+ thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 3252c6fa59..fef22a347c 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -48,7 +48,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -86,7 +86,7 @@ eal_alarm_callback(void *arg __rte_unused)
(ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec &&
(ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -207,7 +207,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
/* If calling from other context, mark that alarm is executing
* so loop can spin till it finish. Otherwise we are trying to
* cancel our self - mark it by EINPROGRESS */
- if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -228,7 +229,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 22b3b7bcd9..d8ce854d90 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <unistd.h>
@@ -97,7 +97,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1167,7 +1167,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1570,5 +1570,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index 83c2034b93..91c239a217 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <sched.h>
#include <sys/queue.h>
#include <sys/syscall.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,8 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset,
+ ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 7cf15cabac..dc0308c761 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -12,7 +12,7 @@
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/queue.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <errno.h>
#include <rte_common.h>
@@ -80,7 +80,7 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
@@ -185,7 +185,7 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
+ ret = rte_thread_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc",
hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 02455a1c8d..9d17e45b96 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -21,7 +21,7 @@ DPDK_21 {
rte_cpu_get_flag_enabled;
rte_cpu_get_flag_name;
rte_cpu_is_supported; # WINDOWS_NO_EXPORT
- rte_ctrl_thread_create;
+ rte_ctrl_thread_create; # WINDOWS_NO_EXPORT
rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
rte_delay_us;
rte_delay_us_block;
@@ -193,7 +193,7 @@ DPDK_21 {
rte_sys_gettid;
rte_thread_get_affinity;
rte_thread_set_affinity;
- rte_thread_setname;
+ rte_thread_setname; # WINDOWS_NO_EXPORT
rte_uuid_compare; # WINDOWS_NO_EXPORT
rte_uuid_is_null; # WINDOWS_NO_EXPORT
rte_uuid_parse; # WINDOWS_NO_EXPORT
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 28c787c0b0..65be582b99 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -391,7 +391,9 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- if (eal_thread_create(&lcore_config[i].thread_id) != 0)
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
+ eal_thread_loop, NULL);
+ if (ret != 0)
rte_panic("Cannot create thread\n");
}
diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c
index 1d4cf794df..b95c8f6f93 100644
--- a/lib/eal/windows/eal_interrupts.c
+++ b/lib/eal/windows/eal_interrupts.c
@@ -7,7 +7,7 @@
#include "eal_private.h"
#include "eal_windows.h"
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static HANDLE intr_iocp;
@@ -63,7 +63,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -76,7 +76,7 @@ rte_eal_intr_init(void)
int
rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
int
@@ -92,9 +92,9 @@ eal_intr_thread_schedule(void (*func)(void *arg), void *arg)
{
HANDLE handle;
- handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread);
+ handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread.opaque_id);
if (handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread);
+ RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread.opaque_id);
return -ENOENT;
}
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 9c3f6d69fd..fbdb7dbc76 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -60,15 +60,16 @@ eal_thread_loop(void *arg __rte_unused)
char c;
int n, ret;
unsigned int lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -80,7 +81,7 @@ eal_thread_loop(void *arg __rte_unused)
__rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset);
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset);
/* read on our pipe to get commands */
while (1) {
@@ -122,35 +123,9 @@ eal_thread_loop(void *arg __rte_unused)
}
}
-/* function to create threads */
-int
-eal_thread_create(pthread_t *thread)
-{
- HANDLE th;
-
- th = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
- NULL, 0, (LPDWORD)thread);
- if (!th)
- return -1;
-
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
-
- return 0;
-}
-
/* get current thread ID */
int
rte_sys_gettid(void)
{
return GetCurrentThreadId();
}
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
- /* TODO */
- /* This is a stub, not the expected result */
- return 0;
-}
diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h
index dc5dc8240a..4b92b198c7 100644
--- a/lib/eal/windows/eal_windows.h
+++ b/lib/eal/windows/eal_windows.h
@@ -35,16 +35,6 @@
*/
int eal_create_cpu_map(void);
-/**
- * Create a thread.
- *
- * @param thread
- * The location to store the thread id if successful.
- * @return
- * 0 for success, -1 if the thread is not created.
- */
-int eal_thread_create(pthread_t *thread);
-
/**
* Get system NUMA node number for a socket ID.
*
diff --git a/lib/eal/windows/include/rte_windows.h b/lib/eal/windows/include/rte_windows.h
index 0063b5d78c..d8c4ed10d7 100644
--- a/lib/eal/windows/include/rte_windows.h
+++ b/lib/eal/windows/include/rte_windows.h
@@ -28,6 +28,7 @@
#include <windows.h>
#include <basetsd.h>
+#include <processthreadsapi.h>
#include <psapi.h>
#include <setupapi.h>
#include <winioctl.h>
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 995ae2491d..a1d89a8d63 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -594,7 +594,7 @@ rte_thread_name_set(rte_thread_t thread_id, const char *name)
}
count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
- if (count < 0) {
+ if (count == (size_t) (-1)) {
RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
ret = EINVAL;
goto cleanup;
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c607eabb5b..bc0a4c973a 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -526,7 +526,7 @@ rte_eth_dev_allocate(const char *name)
strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
eth_dev->data->port_id = port_id;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ rte_thread_mutex_init(ð_dev->data->flow_ops_mutex);
unlock:
rte_spinlock_unlock(ð_dev_shared_data->ownership_lock);
@@ -600,7 +600,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data->hash_mac_addrs);
rte_free(eth_dev->data->dev_private);
- pthread_mutex_destroy(ð_dev->data->flow_ops_mutex);
+ rte_thread_mutex_destroy(ð_dev->data->flow_ops_mutex);
memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
}
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d948fa..c4a6ea9774 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -5,7 +5,7 @@
#ifndef _RTE_ETHDEV_CORE_H_
#define _RTE_ETHDEV_CORE_H_
-#include <pthread.h>
+#include <rte_thread.h>
/**
* @file
@@ -182,7 +182,7 @@ struct rte_eth_dev_data {
* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
*/
- pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
+ rte_thread_mutex flow_ops_mutex; /**< rte_flow ops mutex. */
uint64_t reserved_64s[4]; /**< Reserved for future fields */
void *reserved_ptrs[4]; /**< Reserved for future fields */
} __rte_cache_aligned;
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..4f112d1af7 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -226,14 +226,14 @@ static inline void
fts_enter(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_lock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_lock(&dev->data->flow_ops_mutex);
}
static inline void
fts_exit(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_unlock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_unlock(&dev->data->flow_ops_mutex);
}
static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 13dfb28401..47f10cf5a9 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -7,6 +7,7 @@
#endif
#include <unistd.h>
+#include <pthread.h>
#include <rte_cycles.h>
#include <rte_common.h>
#include <rte_dev.h>
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index c96f6335c8..85572354ae 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -12,6 +12,7 @@
#include <numaif.h>
#endif
+#include <pthread.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_log.h>
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 5/6] eal: set affinity and priority attributes
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (3 preceding siblings ...)
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
If the user doesn't specify the priority through the command
line arguments, initialize the thread priority to 'normal'.
Set thread priority for eal threads.
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 11 ++++++++
lib/eal/common/eal_thread.h | 6 ++++
lib/eal/freebsd/eal.c | 41 +++++++++++++++++++++++-----
lib/eal/linux/eal.c | 39 +++++++++++++++++++++-----
lib/eal/windows/eal.c | 44 ++++++++++++++++++++++++++++--
5 files changed, 125 insertions(+), 16 deletions(-)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 62d28e7b28..fa537db7ac 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -388,3 +388,14 @@ rte_thread_unregister(void)
RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n",
lcore_id);
}
+
+void rte_thread_priority_init(void)
+{
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+
+ /* If the user doesn't specify the priority through the command
+ * line arguments, the default 'normal' value will be used.
+ */
+ internal_conf->thread_priority = RTE_THREAD_PRIORITY_NORMAL;
+}
diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h
index 4a49117be8..7b3b884463 100644
--- a/lib/eal/common/eal_thread.h
+++ b/lib/eal/common/eal_thread.h
@@ -58,4 +58,10 @@ eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size);
int
eal_thread_dump_current_affinity(char *str, unsigned int size);
+/**
+ * Set the initial thread priority in the internal configuration
+ * to the default value of RTE_THREAD_PRIORITY_NORMAL.
+ */
+void rte_thread_priority_init(void);
+
#endif /* EAL_THREAD_H */
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index b5cf050697..7303d62afb 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -676,6 +676,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -854,6 +856,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -869,6 +879,22 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -882,9 +908,15 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
+ if (ret != 0)
+ rte_panic("Cannot set affinity\n");
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -892,11 +924,6 @@ rte_eal_init(int argc, char **argv)
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
rte_thread_name_set(lcore_config[i].thread_id, thread_name);
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 7060856d84..7f3d491560 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -975,6 +975,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -1219,6 +1221,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -1233,6 +1243,23 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot initialize thread attributes,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set thread priority attribute,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -1246,9 +1273,12 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1260,11 +1290,6 @@ rte_eal_init(int argc, char **argv)
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 65be582b99..bb9053df84 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -274,6 +274,8 @@ rte_eal_init(int argc, char **argv)
eal_get_internal_configuration();
int ret;
+ rte_thread_priority_init();
+
eal_log_init(NULL, 0);
eal_log_level_parse(argc, argv);
@@ -375,6 +377,36 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
+ &lcore_config[config->main_lcore].cpuset) != 0) {
+ rte_eal_init_alert("Cannot set affinity");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -390,9 +422,17 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread affinity attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
}
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v2 6/6] Allow choice between internal EAL thread API and external lib
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (4 preceding siblings ...)
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
@ 2021-06-19 1:57 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
6 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-06-19 1:57 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The user is offered the option of either using the RTE_THREAD_* API or
a 3rd party thread library, through a meson flag called
"use_external_thread_lib". By default, this flag is set to FALSE,
which means Windows libraries and applications will use the RTE_THREAD_*
API for managing threads.
If compiling on Windows and the "use_external_thread_lib" is *not* set,
the following files will be parsed:
* include/rte_thread.h
* windows/rte_thread.c
In all other cases, the compilation/parsing includes the following files:
* include/rte_thread.h
* common/rte_thread.c
Depends-on: series-17402 ("eal: Add EAL API for threading")
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
config/meson.build | 1 -
lib/eal/windows/include/pthread.h | 192 ------------------------------
lib/eal/windows/meson.build | 7 +-
meson_options.txt | 2 +
4 files changed, 8 insertions(+), 194 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
diff --git a/config/meson.build b/config/meson.build
index 017bb2efbb..9309010f21 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -262,7 +262,6 @@ else # for 32-bit we need smaller reserved memory areas
dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
endif
-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h
deleted file mode 100644
index 27fd2cca52..0000000000
--- a/lib/eal/windows/include/pthread.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019 Intel Corporation
- */
-
-#ifndef _PTHREAD_H_
-#define _PTHREAD_H_
-
-#include <stdint.h>
-#include <sched.h>
-
-/**
- * This file is required to support the common code in eal_common_proc.c,
- * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc
- * does not contain pthread.h. This may be removed in future releases.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_common.h>
-#include <rte_windows.h>
-
-#define PTHREAD_BARRIER_SERIAL_THREAD TRUE
-
-/* defining pthread_t type on Windows since there is no in Microsoft libc*/
-typedef uintptr_t pthread_t;
-
-/* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/
-typedef void *pthread_attr_t;
-
-typedef void *pthread_mutexattr_t;
-
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
-
-#define pthread_barrier_init(barrier, attr, count) \
- !InitializeSynchronizationBarrier(barrier, count, -1)
-#define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
- SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
-#define pthread_barrier_destroy(barrier) \
- !DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
-
-/* pthread function overrides */
-#define pthread_self() \
- ((pthread_t)GetCurrentThreadId())
-
-
-static inline int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- return t1 == t2;
-}
-
-static inline int
-pthread_setaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- DWORD_PTR ret = 0;
- HANDLE thread_handle;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- ret = SetThreadAffinityMask(thread_handle, *cpuset->_bits);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("CloseHandle()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_getaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- /* Workaround for the lack of a GetThreadAffinityMask()
- *API in Windows
- */
- DWORD_PTR prev_affinity_mask;
- HANDLE thread_handle;
- DWORD_PTR ret = 0;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- /* obtain previous mask by setting dummy mask */
- prev_affinity_mask = SetThreadAffinityMask(thread_handle, 0x1);
- if (prev_affinity_mask == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- /* set it back! */
- ret = SetThreadAffinityMask(thread_handle, prev_affinity_mask);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- memset(cpuset, 0, cpuset_size);
- *cpuset->_bits = prev_affinity_mask;
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_create(void *threadid, const void *threadattr, void *threadfunc,
- void *args)
-{
- RTE_SET_USED(threadattr);
- HANDLE hThread;
- hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
- args, 0, (LPDWORD)threadid);
- if (hThread) {
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
- }
- return ((hThread != NULL) ? 0 : E_FAIL);
-}
-
-static inline int
-pthread_detach(__rte_unused pthread_t thread)
-{
- return 0;
-}
-
-static inline int
-pthread_join(__rte_unused pthread_t thread,
- __rte_unused void **value_ptr)
-{
- return 0;
-}
-
-static inline int
-pthread_mutex_init(pthread_mutex_t *mutex,
- __rte_unused pthread_mutexattr_t *attr)
-{
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PTHREAD_H_ */
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index ff9cbec417..4b7db4754b 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -19,7 +19,12 @@ sources += files(
'eal_timer.c',
'fnmatch.c',
'getopt.c',
- 'rte_thread.c',
)
+if get_option('use_external_thread_lib')
+ sources += 'eal/common/rte_thread.c'
+else
+ sources += 'eal/windows/rte_thread.c'
+endif
+
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
diff --git a/meson_options.txt b/meson_options.txt
index 56bdfd0f0a..2606c8b3a4 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -44,3 +44,5 @@ option('tests', type: 'boolean', value: true, description:
'build unit tests')
option('use_hpet', type: 'boolean', value: false, description:
'use HPET timer in EAL')
+option('use_external_thread_lib', type: 'boolean', value: false,
+ description: 'use an external thread library')
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-06-20 23:53 ` Dmitry Kozlyuk
0 siblings, 0 replies; 30+ messages in thread
From: Dmitry Kozlyuk @ 2021-06-20 23:53 UTC (permalink / raw)
To: Narcisa Ana Maria Vasile
Cc: dev, thomas, khot, navasile, dmitrym, roretzla, talshn, ocardona,
bruce.richardson, david.marchand, pallavi.kadam
2021-06-18 18:57 (UTC-0700), Narcisa Ana Maria Vasile:
> From: Narcisa Vasile <navasile@microsoft.com>
>
> Implement function that sets the name of a thread.
> On Windows, SetThreadDescription() is used. Use GetProcAddress()
> to obtain the address of the function for MinGW compatibility.
>
> Depends-on: series-17402 ("eal: Add EAL API for threading")
>
> Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
> ---
> lib/eal/common/rte_thread.c | 17 ++++++++++
> lib/eal/include/rte_thread.h | 18 +++++++++++
> lib/eal/version.map | 1 +
> lib/eal/windows/rte_thread.c | 60 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 96 insertions(+)
[...]
> diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
> index 40da83467b..c65cfd8c9e 100644
> --- a/lib/eal/include/rte_thread.h
> +++ b/lib/eal/include/rte_thread.h
> @@ -24,6 +24,8 @@ extern "C" {
>
> #include <sched.h>
>
> +#define RTE_THREAD_MAX_DESCRIPTION_LENGTH 16
> +
Why export this constant?
> /**
> * Thread id descriptor.
> */
> @@ -439,6 +441,22 @@ int rte_thread_barrier_wait(rte_thread_barrier *barrier);
> __rte_experimental
> int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
>
> +/**
> + * Set the name of the thread represented by 'thread_id'.
> + *
> + * @param thread_id
> + * The id of the thread.
> + *
> + * @param name
> + * Thread name to set.
> + *
> + * @return
> + * On success, return 0.
> + * On failure, return a positive errno-style error number.
Typo: extra space.
> + */
> +__rte_experimental
> +int rte_thread_name_set(rte_thread_t thread_id, const char *name);
> +
There is `rte_thread_setname(pthread_t id, const char * name, size_t len)`.
I assume it should be deprecated in favor of this new API
via a notice in `deprecation.rst`.
> /**
> * Create a TLS data key visible to all threads in the process.
> * the created key is later used to get/set a value.
> diff --git a/lib/eal/version.map b/lib/eal/version.map
> index 6645f60a78..2a566c04af 100644
> --- a/lib/eal/version.map
> +++ b/lib/eal/version.map
> @@ -443,6 +443,7 @@ EXPERIMENTAL {
> rte_thread_barrier_init;
> rte_thread_barrier_wait;
> rte_thread_barrier_destroy;
> + rte_thread_name_set;
> };
>
> INTERNAL {
> diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
> index b2ff16f51f..995ae2491d 100644
> --- a/lib/eal/windows/rte_thread.c
> +++ b/lib/eal/windows/rte_thread.c
> @@ -556,6 +556,66 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
> return 0;
> }
>
> +typedef HRESULT
> +(*SetThreadDescription_type)(HANDLE thread_handle, PCWSTR thread_description);
> +
> +int
> +rte_thread_name_set(rte_thread_t thread_id, const char *name)
> +{
> + int ret = 0;
> + size_t count;
> + HRESULT hr;
> + HANDLE thread_handle = NULL;
> + WCHAR w_name[RTE_THREAD_MAX_DESCRIPTION_LENGTH];
> + HMODULE kernel_lib = NULL;
> + SetThreadDescription_type SetThreadDescription_ptr;
> +
> + static const char library_name[] = "kernel32.dll";
> + static const char function[] = "SetThreadDescription";
> +
> + kernel_lib = LoadLibraryA(library_name);
> + if (kernel_lib == NULL) {
> + ret = thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
> + goto cleanup;
> + }
Rather then locate the function every time (kernel32.dll is always loaded),
what do you think of using `RTE_INIT`/`RTE_FINI` for that?
> +
> + SetThreadDescription_ptr = (SetThreadDescription_type)(
> + (void *)GetProcAddress(kernel_lib, function));
> + if (SetThreadDescription_ptr == NULL) {
> + ret = thread_log_last_error("GetProcAddress(\"kernel32.dll\", \"SetThreadDescription\")");
> + goto cleanup;
> + }
> +
> + thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE,
> + thread_id.opaque_id);
> + if (thread_handle == NULL) {
> + ret = thread_log_last_error("OpenThread()");
> + goto cleanup;
> + }
> +
> + count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
It's better to use `RTE_DIM(w_name)`, this way named constant is not needed.
> + if (count < 0) {
> + RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
> + ret = EINVAL;
> + goto cleanup;
> + }
> +
> + hr = SetThreadDescription_ptr(thread_handle, w_name);
> + if (FAILED(hr)) {
> + ret = thread_log_last_error("SetThreadDescription()");
> + goto cleanup;
> + }
> +
> +cleanup:
> + if (kernel_lib != NULL)
> + FreeLibrary(kernel_lib);
> + if (thread_handle != NULL) {
> + CloseHandle(thread_handle);
> + thread_handle = NULL;
Such local variable assignments on cleanup are useless.
> + }
> + return ret;
> +}
> +
> int
> rte_thread_key_create(rte_thread_key *key,
> __rte_unused void (*destructor)(void *))
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (5 preceding siblings ...)
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
` (5 more replies)
6 siblings, 6 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
This patchset enables the new EAL thread API.
The newly defined thread attributes, priority and affinity,
are used in eal/windows when creating the threads. Similarly,
some changes have been done in eal/linux/eal.c and eal/freebsd/eal.c
to initialize priority to a default value and set thread attributes.
The user is offered the option of either using the rte_thread_* API or
a 3rd party thread library, through a meson flag
called "use_external_thread_lib".
By default, this flag is set to FALSE, which means Windows libraries
and applications will use the EAL rte_thread_* API
defined in windows/rte_thread.c for managing threads.
When the flag is set to TRUE, the common/rte_thread.c file is compiled
and an external thread library is used.
This patchset adds a new function for creating control threads that
uses the new thread API.
It enables the usage of the new function in Windows code and common code.
The old function is kept to avoid ABI break, however, its definition
is commented away on Windows, since the pthread_t and pthread_attr_t
arguments that it receives have been replaced with the new API on Windows.
This allows testing the "eal: Add EAL API for threading" that this
patchset depends on.
The ethdev lib also contains some changes that break the ABI.
Enabling the new EAL thread API will probably require going through
the proper process of ABI changes.
Depends-on: series-18172 ("eal: Add EAL API for threading")
v3:
- use RTE_INIT to only load kernel32.dll once and get function
pointer to SetThreadDescription()
- minor fixes
v2:
- fix typo in SetThreadDescription_type function pointer
- add Depends-on on all patches to fix apply errors.
- modify cover letter
Narcisa Vasile (6):
eal: add function that sets thread name
eal: add function for control thread creation
Enable the new EAL thread API in app, drivers and examples
lib: enable the new EAL thread API
eal: set affinity and priority attributes
Allow choice between internal EAL thread API and external lib
app/test/process.h | 8 +-
app/test/test_lcores.c | 18 +-
app/test/test_link_bonding.c | 14 +-
app/test/test_lpm_perf.c | 12 +-
config/meson.build | 1 -
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 +-
drivers/bus/dpaa/base/qbman/process.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 14 +-
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 +-
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 14 +-
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 +-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +-
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 +--
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.h | 8 +-
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +-
drivers/net/axgbe/axgbe_phy_impl.c | 6 +-
drivers/net/bnxt/bnxt.h | 16 +-
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 ++---
drivers/net/bnxt/bnxt_irq.c | 8 +-
drivers/net/bnxt/bnxt_reps.c | 10 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +--
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 8 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 4 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +-
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +-
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +-
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +-
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 +-
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +-
drivers/net/vhost/rte_eth_vhost.c | 24 +--
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +--
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 +++--
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 +--
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++---
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
lib/eal/common/eal_common_options.c | 6 +-
lib/eal/common/eal_common_thread.c | 105 +++++++++-
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/eal_thread.h | 6 +
lib/eal/common/malloc_mp.c | 2 +
lib/eal/common/rte_thread.c | 17 ++
lib/eal/freebsd/eal.c | 53 +++--
lib/eal/freebsd/eal_alarm.c | 12 +-
lib/eal/freebsd/eal_interrupts.c | 6 +-
lib/eal/freebsd/eal_thread.c | 10 +-
lib/eal/include/rte_lcore.h | 6 +
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/include/rte_thread.h | 43 ++++
lib/eal/linux/eal.c | 55 +++--
lib/eal/linux/eal_alarm.c | 10 +-
lib/eal/linux/eal_interrupts.c | 8 +-
lib/eal/linux/eal_thread.c | 11 +-
lib/eal/linux/eal_timer.c | 6 +-
lib/eal/version.map | 6 +-
lib/eal/windows/eal.c | 44 +++-
lib/eal/windows/eal_interrupts.c | 8 +-
lib/eal/windows/eal_thread.c | 35 +---
lib/eal/windows/eal_windows.h | 10 -
lib/eal/windows/include/pthread.h | 192 ------------------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/meson.build | 7 +-
lib/eal/windows/rte_thread.c | 68 +++++++
lib/ethdev/rte_ethdev.c | 4 +-
lib/ethdev/rte_ethdev_core.h | 4 +-
lib/ethdev/rte_flow.c | 4 +-
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
meson_options.txt | 2 +
97 files changed, 777 insertions(+), 661 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 19:42 ` Tal Shnaiderman
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
` (4 subsequent siblings)
5 siblings, 1 reply; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Implement function that sets the name of a thread.
On Windows, SetThreadDescription() is used. Use GetProcAddress()
to obtain the address of the function for MinGW compatibility.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/rte_thread.c | 17 +++++++++
lib/eal/include/rte_thread.h | 16 +++++++++
lib/eal/version.map | 1 +
lib/eal/windows/rte_thread.c | 68 ++++++++++++++++++++++++++++++++++++
4 files changed, 102 insertions(+)
diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c
index 3fdb267337..c91ed3d433 100644
--- a/lib/eal/common/rte_thread.c
+++ b/lib/eal/common/rte_thread.c
@@ -373,6 +373,23 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return ret;
}
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+ char truncated[16];
+
+ memcpy(truncated, name, sizeof(truncated));
+ ret = pthread_setname_np((pthread_t)thread_id.opaque_id, truncated);
+#endif
+#endif
+ RTE_SET_USED(thread_id);
+ RTE_SET_USED(name);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *))
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 40da83467b..2f6258e336 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -439,6 +439,22 @@ int rte_thread_barrier_wait(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
+/**
+ * Set the name of the thread represented by 'thread_id'.
+ *
+ * @param thread_id
+ * The id of the thread.
+ *
+ * @param name
+ * Thread name to set.
+ *
+ * @return
+ * On success, return 0.
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 541dc13053..7ce8dcea07 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -446,6 +446,7 @@ EXPERIMENTAL {
rte_thread_barrier_init;
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
+ rte_thread_name_set;
};
INTERNAL {
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index b2ff16f51f..ba543c4b2a 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -556,6 +556,74 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return 0;
}
+typedef HRESULT
+(*SetThreadDescription_type)(HANDLE thread_handle, PCWSTR thread_description);
+
+static SetThreadDescription_type SetThreadDescription_ptr;
+
+RTE_INIT(rte_thread_description_ptr_init)
+{
+ HMODULE kernel_lib = NULL;
+ static const char library_name[] = "kernel32.dll";
+ static const char function[] = "SetThreadDescription";
+
+ kernel_lib = LoadLibraryA(library_name);
+ if (kernel_lib == NULL) {
+ (void)thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
+ return;
+ }
+
+ SetThreadDescription_ptr = (SetThreadDescription_type)(
+ (void *)GetProcAddress(kernel_lib, function));
+ if (SetThreadDescription_ptr == NULL) {
+ (void)thread_log_last_error("GetProcAddress(\"kernel32.dll\", \"SetThreadDescription\")");
+ return;
+ }
+
+ FreeLibrary(kernel_lib);
+}
+
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = 0;
+ size_t count;
+ HRESULT hr;
+ HANDLE thread_handle = NULL;
+ WCHAR w_name[16];
+
+ thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE,
+ thread_id.opaque_id);
+ if (thread_handle == NULL) {
+ ret = thread_log_last_error("OpenThread()");
+ goto cleanup;
+ }
+
+ count = mbstowcs(w_name, name, RTE_DIM(w_name));
+ if (count == (size_t) (-1)) {
+ RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ if (SetThreadDescription_ptr == NULL) {
+ RTE_LOG(DEBUG, EAL, "Invalid function pointer to SetThreadDescription()!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ hr = SetThreadDescription_ptr(thread_handle, w_name);
+ if (FAILED(hr)) {
+ ret = thread_log_last_error("SetThreadDescription()");
+ goto cleanup;
+ }
+
+cleanup:
+ if (thread_handle != NULL)
+ CloseHandle(thread_handle);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key,
__rte_unused void (*destructor)(void *))
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 2/6] eal: add function for control thread creation
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
` (3 subsequent siblings)
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The existing rte_ctrl_thread_create() function will be replaced
with rte_thread_ctrl_thread_create() that uses the internal
EAL thread API.
This patch only introduces the new control thread creation
function. Replacing of the old function needs to be done according
to the ABI change procedures, to avoid an ABI break.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 81 ++++++++++++++++++++++++++++++
lib/eal/include/rte_thread.h | 27 ++++++++++
lib/eal/version.map | 1 +
3 files changed, 109 insertions(+)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 1a52f42a2b..79545c67d9 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -259,6 +259,87 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+struct rte_thread_ctrl_ctx {
+ rte_thread_func start_routine;
+ void *arg;
+ const char *name;
+};
+
+static void *ctrl_thread_wrapper(void *arg)
+{
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = arg;
+ rte_thread_func start_routine = ctx->start_routine;
+ void *routine_arg = ctx->arg;
+
+ __rte_thread_init(rte_lcore_id(), cpuset);
+
+ if (ctx->name != NULL) {
+ if (rte_thread_name_set(rte_thread_self(), ctx->name) < 0)
+ RTE_LOG(DEBUG, EAL, "Cannot set name for ctrl thread\n");
+ }
+
+ free(arg);
+
+ return start_routine(routine_arg);
+}
+
+int
+rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg)
+{
+ int ret;
+ rte_thread_attr_t attr;
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = NULL;
+
+ if (start_routine == NULL) {
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL) {
+ ret = ENOMEM;
+ goto cleanup;
+ }
+
+ ctx->start_routine = start_routine;
+ ctx->arg = arg;
+ ctx->name = name;
+
+ ret = rte_thread_attr_init(&attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot init ctrl thread attributes\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_attr_set_affinity(&attr, cpuset);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set afifnity attribute for ctrl thread\n");
+ goto cleanup;
+ }
+ ret = rte_thread_attr_set_priority(&attr, RTE_THREAD_PRIORITY_NORMAL);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set priority attribute for ctrl thread\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_create(thread, &attr, ctrl_thread_wrapper, ctx);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot create ctrl thread\n");
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ free(ctx);
+ return ret;
+}
+
int
rte_thread_register(void)
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 2f6258e336..e34101cc98 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -455,6 +455,33 @@ int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+/**
+ * Create a control thread.
+ *
+ * Set affinity and thread name. The affinity of the new thread is based
+ * on the CPU affinity retrieved at the time rte_eal_init() was called,
+ * the dataplane and service lcores are then excluded.
+ *
+ * @param thread
+ * Filled with the thread id of the new created thread.
+ *
+ * @param name
+ * The name of the control thread (max 16 characters including '\0').
+ *
+ * @param start_routine
+ * Function to be executed by the new thread.
+ *
+ * @param arg
+ * Argument passed to start_routine.
+ *
+ * @return
+ * On success, return 0;
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 7ce8dcea07..67569b1bf9 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -447,6 +447,7 @@ EXPERIMENTAL {
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
rte_thread_name_set;
+ rte_thread_ctrl_thread_create;
};
INTERNAL {
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 3/6] Enable the new EAL thread API in app, drivers and examples
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
` (2 subsequent siblings)
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
app/test/process.h | 8 +--
app/test/test_lcores.c | 18 +++----
app/test/test_link_bonding.c | 14 ++---
app/test/test_lpm_perf.c | 12 ++---
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 ++---
drivers/bus/dpaa/base/qbman/process.c | 6 +--
drivers/bus/dpaa/dpaa_bus.c | 14 ++---
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 ++++---
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 14 ++---
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 ++-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +++----
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 ++++-----
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.h | 8 +--
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +--
drivers/net/axgbe/axgbe_phy_impl.c | 6 +--
drivers/net/bnxt/bnxt.h | 16 +++---
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 +++++++++----------
drivers/net/bnxt/bnxt_irq.c | 8 +--
drivers/net/bnxt/bnxt_reps.c | 10 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++++++------
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +++++-----
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 8 +--
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 4 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +++---
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +--
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +++----
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +--
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 ++--
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +--
drivers/net/vhost/rte_eth_vhost.c | 24 ++++-----
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +++++------
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 ++++++++---------
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 ++++-----
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++++++++----------
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
62 files changed, 342 insertions(+), 347 deletions(-)
diff --git a/app/test/process.h b/app/test/process.h
index 5b10cf64df..3ad861cb9a 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -26,7 +26,7 @@
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
-#include <pthread.h>
+#include <rte_thread.h>
extern void *send_pkts(void *empty);
extern uint16_t flag_for_send_pkts;
#endif
@@ -47,7 +47,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
char path[32];
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
- pthread_t thread;
+ rte_thread_t thread;
int rc;
#endif
#endif
@@ -134,7 +134,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
- rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+ rc = rte_thread_create(&thread, NULL, &send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
strerror(rc));
@@ -149,7 +149,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
- pthread_join(thread, NULL);
+ rte_thread_join(thread, NULL);
}
#endif
#endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 19a7ab9fce..accdd858a6 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,7 @@
* Copyright (c) 2020 Red Hat, Inc.
*/
-#include <pthread.h>
+#include <rte_thread.h>
#include <string.h>
#include <rte_common.h>
@@ -14,7 +14,7 @@
struct thread_context {
enum { INIT, ERROR, DONE } state;
bool lcore_id_any;
- pthread_t id;
+ rte_thread_t id;
unsigned int *registered_count;
};
@@ -77,7 +77,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
break;
non_eal_threads_count++;
}
@@ -96,7 +96,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) == 0) {
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
non_eal_threads_count++;
printf("non-EAL threads count: %u\n", non_eal_threads_count);
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -110,7 +110,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -262,7 +262,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -285,7 +285,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -309,7 +309,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -330,7 +330,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
__atomic_store_n(®istered_count, 0, __ATOMIC_RELEASE);
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
}
error:
if (handle[1] != NULL)
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c8310a8..a22189a656 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -3,6 +3,7 @@
*/
#include "unistd.h"
+#include <pthread.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
@@ -203,7 +204,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
static int slaves_initialized;
static int mac_slaves_initialized;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(mutex)
static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
@@ -1191,11 +1192,11 @@ test_bonding_lsc_event_callback(uint16_t port_id __rte_unused,
void *param __rte_unused,
void *ret_param __rte_unused)
{
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
test_lsc_interrupt_count++;
pthread_cond_signal(&cvar);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
return 0;
}
@@ -1220,11 +1221,12 @@ lsc_timeout(int wait_us)
ts.tv_sec += 1;
}
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
if (test_lsc_interrupt_count < 1)
- retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+ retval = pthread_cond_timedwait(&cvar,
+ (pthread_mutex_t *)mutex.mutex_id, &ts);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
if (retval == 0 && test_lsc_interrupt_count < 1)
return -1;
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 2bed00d064..e4cfcdb504 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -25,7 +25,7 @@ static volatile uint32_t thr_id;
static uint64_t gwrite_cycles;
static uint32_t num_writers;
/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(lpm_mutex)
/* Report quiescent state interval every 1024 lookups. Larger critical
* sections in reader will result in writer polling multiple times.
@@ -443,7 +443,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
/* Add all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth,
next_hop_add) != 0) {
@@ -452,13 +452,13 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
/* Delete all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth) != 0) {
printf("Failed to delete iteration %d, route# %d\n",
@@ -466,7 +466,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
}
@@ -478,7 +478,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
error:
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
return -1;
}
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index ee35e03da1..25be077c6f 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -38,11 +38,10 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
struct dpaa_ioctl_irq_map irq_map;
/* Verify the thread's cpu-affinity */
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_set_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
errno = ret;
- err(0, "pthread_getaffinity_np()");
+ err(0, "rte_thread_set_affinity_by_id()");
return ret;
}
pcfg.cpu = -1;
diff --git a/drivers/bus/dpaa/base/qbman/dpaa_sys.c b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
index 9d6bfd40a2..14aeb5e07d 100644
--- a/drivers/bus/dpaa/base/qbman/dpaa_sys.c
+++ b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
@@ -18,16 +18,16 @@ struct process_interrupt {
};
static COMPAT_LIST_HEAD(process_irq_list);
-static pthread_mutex_t process_irq_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(process_irq_lock)
static void process_interrupt_install(struct process_interrupt *irq)
{
int ret;
/* Add the irq to the end of the list */
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_add_tail(&irq->node, &process_irq_list);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -35,10 +35,10 @@ static void process_interrupt_remove(struct process_interrupt *irq)
{
int ret;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_del(&irq->node);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -47,14 +47,14 @@ static struct process_interrupt *process_interrupt_find(int irq_num)
int ret;
struct process_interrupt *i = NULL;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_for_each_entry(i, &process_irq_list, node) {
if (i->irq == irq_num)
goto done;
}
done:
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
return i;
}
diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 9bc92681cd..da157b8426 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -21,7 +21,7 @@
* what the lock is for.
*/
static int fd = -1;
-static pthread_mutex_t fd_init_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(fd_init_lock)
static int check_fd(void)
{
@@ -29,12 +29,12 @@ static int check_fd(void)
if (fd >= 0)
return 0;
- ret = pthread_mutex_lock(&fd_init_lock);
+ ret = rte_thread_mutex_lock(&fd_init_lock);
assert(!ret);
/* check again with the lock held */
if (fd < 0)
fd = open(PROCESS_PATH, O_RDWR);
- ret = pthread_mutex_unlock(&fd_init_lock);
+ ret = rte_thread_mutex_unlock(&fd_init_lock);
assert(!ret);
return (fd >= 0) ? 0 : -ENODEV;
}
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index e499305d85..84deb8f6de 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -10,7 +10,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/eventfd.h>
@@ -47,7 +47,7 @@ static struct rte_dpaa_bus rte_dpaa_bus;
struct netcfg_info *dpaa_netcfg;
/* define a variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa_portal_key;
+static rte_thread_key dpaa_portal_key;
unsigned int dpaa_svr_family;
@@ -315,10 +315,10 @@ int rte_dpaa_portal_init(void *arg)
DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index();
DPAA_PER_LCORE_PORTAL->tid = rte_gettid();
- ret = pthread_setspecific(dpaa_portal_key,
+ ret = rte_thread_value_set(dpaa_portal_key,
(void *)DPAA_PER_LCORE_PORTAL);
if (ret) {
- DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
+ DPAA_BUS_LOG(ERR, "rte_thread_value_set failed on core %u"
" (lcore=%u) with ret: %d", cpu, lcore, ret);
dpaa_portal_finish(NULL);
@@ -376,7 +376,7 @@ dpaa_portal_finish(void *arg)
bman_thread_finish();
qman_thread_finish();
- pthread_setspecific(dpaa_portal_key, NULL);
+ rte_thread_value_set(dpaa_portal_key, NULL);
rte_free(dpaa_io_portal);
dpaa_io_portal = NULL;
@@ -452,9 +452,9 @@ rte_dpaa_bus_scan(void)
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
+ ret = rte_thread_key_create(&dpaa_portal_key, dpaa_portal_finish);
if (ret) {
- DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
+ DPAA_BUS_LOG(DEBUG, "Unable to create thread key. (%d)", ret);
dpaa_clean_device_list();
return ret;
}
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 1a1e437ed1..b6dc40290a 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
@@ -59,7 +59,7 @@ uint8_t dpaa2_dqrr_size;
uint8_t dpaa2_eqcr_size;
/* Variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa2_portal_key;
+static rte_thread_key dpaa2_portal_key;
/*Stashing Macros default for LS208x*/
static int dpaa2_core_cluster_base = 0x04;
@@ -92,10 +92,9 @@ dpaa2_get_core_id(void)
rte_cpuset_t cpuset;
int i, ret, cpu_id = -1;
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
- DPAA2_BUS_ERR("pthread_getaffinity_np() failed");
+ DPAA2_BUS_ERR("rte_thread_get_affinity_by_id() failed");
return ret;
}
@@ -295,9 +294,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
}
}
- ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
+ ret = rte_thread_value_set(dpaa2_portal_key, (void *)dpio_dev);
if (ret) {
- DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
+ DPAA2_BUS_ERR("rte_thread_value_set failed with ret: %d", ret);
dpaa2_put_qbman_swp(dpio_dev);
return NULL;
}
@@ -356,7 +355,7 @@ static void dpaa2_portal_finish(void *arg)
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
- pthread_setspecific(dpaa2_portal_key, NULL);
+ rte_thread_value_set(dpaa2_portal_key, NULL);
}
static int
@@ -514,10 +513,10 @@ dpaa2_create_dpio_device(int vdev_fd,
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa2_portal_key,
+ ret = rte_thread_key_create(&dpaa2_portal_key,
dpaa2_portal_finish);
if (ret) {
- DPAA2_BUS_DEBUG("Unable to create pthread key (%d)",
+ DPAA2_BUS_DEBUG("Unable to create thread key (%d)",
ret);
goto err;
}
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb..8d53ee4dfc 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <linux/types.h>
#include <stdbool.h>
#include <ctype.h>
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index 3756e1959b..295ef872c0 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <sys/types.h>
+#include <rte_windows.h>
#include <rte_errno.h>
#include "mlx5_autoconf.h"
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 883e720ec1..d6b422b4a2 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -70,7 +70,7 @@ struct mlx5_compress_qp {
TAILQ_HEAD(mlx5_compress_privs, mlx5_compress_priv) mlx5_compress_priv_list =
TAILQ_HEAD_INITIALIZER(mlx5_compress_priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
int mlx5_compress_logtype;
@@ -771,13 +771,13 @@ mlx5_compress_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
switch (event_type) {
case RTE_MEM_EVENT_FREE:
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
/* Iterate all the existing mlx5 devices. */
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
mlx5_free_mr_by_addr(&priv->mr_scache,
priv->ctx->device->name,
addr, len);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
break;
case RTE_MEM_EVENT_ALLOC:
default:
@@ -860,9 +860,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
mlx5_compress_mr_mem_event_cb,
NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
}
@@ -871,13 +871,13 @@ mlx5_compress_dev_remove(struct rte_device *dev)
{
struct mlx5_compress_priv *priv = NULL;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
if (priv->cdev->device == dev)
break;
if (priv)
TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (priv) {
if (TAILQ_EMPTY(&mlx5_compress_priv_list))
rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB",
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 252bbd8d5e..4f6d46744e 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -5,7 +5,7 @@
#include <assert.h>
#include <errno.h>
#include <nmmintrin.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h b/drivers/event/dlb2/pf/base/dlb2_osdep.h
index cffe22f3c5..82e0c71734 100644
--- a/drivers/event/dlb2/pf/base/dlb2_osdep.h
+++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h
@@ -8,7 +8,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
@@ -194,14 +194,13 @@ static void *dlb2_complete_queue_map_unmap(void *__args)
static inline void os_schedule_work(struct dlb2_hw *hw)
{
struct dlb2_dev *dlb2_dev;
- pthread_t complete_queue_map_unmap_thread;
+ rte_thread_t complete_queue_map_unmap_thread;
int ret;
dlb2_dev = container_of(hw, struct dlb2_dev, hw);
- ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+ ret = rte_thread_ctrl_thread_create(&complete_queue_map_unmap_thread,
"dlb_queue_unmap_waiter",
- NULL,
dlb2_complete_queue_map_unmap,
dlb2_dev);
if (ret)
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index f02056982c..34a1d2b28d 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 74ffa45112..444ba9f5be 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -179,7 +179,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
static inline int
@@ -677,7 +677,7 @@ find_internal_resource(struct pmd_internals *port_int)
if (port_int == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
struct pmd_internals *list_int =
@@ -688,7 +688,7 @@ find_internal_resource(struct pmd_internals *port_int)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -726,7 +726,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
if (mb_pool == NULL)
return ret;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internals = list->eth_dev->data->dev_private;
@@ -752,7 +752,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
}
out:
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return ret;
}
@@ -781,9 +781,9 @@ eth_dev_configure(struct rte_eth_dev *dev)
return -1;
list->eth_dev = dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
}
return 0;
@@ -981,9 +981,9 @@ eth_dev_close(struct rte_eth_dev *dev)
/* Remove ethdev from list used to track and share UMEMs */
list = find_internal_resource(internals);
if (list) {
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 377299b14c..51856f66d1 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -563,12 +563,12 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
ark_pktchkr_run(ark->pc);
if (ark->start_pg && (dev->data->port_id == 0)) {
- pthread_t thread;
+ rte_thread_t thread;
/* Delay packet generatpr start allow the hardware to be ready
* This is only used for sanity checking with internal generator
*/
- if (rte_ctrl_thread_create(&thread, "ark-delay-pg", NULL,
+ if (rte_thread_ctrl_thread_create(&thread, "ark-delay-pg",
ark_pktgen_delay_start, ark->pg)) {
ARK_PMD_LOG(ERR, "Could not create pktgen "
"starter thread\n");
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 515bfe461c..58ff65b5d5 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -3,7 +3,7 @@
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -475,7 +475,7 @@ ark_pktgen_delay_start(void *arg)
* perform a blind sleep here to ensure that the external test
* application has time to setup the test before we generate packets
*/
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
usleep(100000);
ark_pktgen_run(inst);
return NULL;
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 0ce35eb519..2b86f01a25 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -405,7 +405,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
hw->aq_nic_cfg = &adapter->hw_cfg;
- pthread_mutex_init(&hw->mbox_mutex, NULL);
+ rte_thread_mutex_init(&hw->mbox_mutex);
/* disable interrupt */
atl_disable_intr(hw);
@@ -712,7 +712,7 @@ atl_dev_close(struct rte_eth_dev *dev)
rte_intr_callback_unregister(intr_handle,
atl_dev_interrupt_handler, dev);
- pthread_mutex_destroy(&hw->mbox_mutex);
+ rte_thread_mutex_destroy(&hw->mbox_mutex);
return ret;
}
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index e813d9f326..d99aa5fad0 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <netinet/in.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_common.h>
@@ -141,7 +141,7 @@ struct aq_hw_s {
u32 rpc_tid;
struct hw_aq_atl_utils_fw_rpc rpc;
- pthread_mutex_t mbox_mutex;
+ rte_thread_mutex mbox_mutex;
};
struct aq_fw_ops {
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 3a7faf405c..15b80584f8 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -6,7 +6,7 @@
*/
#include <rte_ether.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include "../atl_hw_regs.h"
#include "../atl_types.h"
@@ -218,7 +218,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
u32 mac_addr[2] = { 0 };
u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
if (efuse_addr != 0) {
err = hw_atl_utils_fw_downld_dwords(self,
@@ -257,7 +257,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -269,7 +269,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
u32 orig_stats_val = mpi_opts & BIT(CAPS_HI_STATISTICS);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to update */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_STATISTICS);
@@ -286,7 +286,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
err = hw_atl_utils_update_stats(self);
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
@@ -299,7 +299,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
u32 temp_val = mpi_opts & BIT(CAPS_HI_TEMPERATURE);
u32 temp_res;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_TEMPERATURE);
@@ -317,7 +317,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
sizeof(temp_res) / sizeof(u32));
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
if (err)
return err;
@@ -536,7 +536,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
if ((self->caps_lo & BIT(CAPS_LO_SMBUS_READ)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
request.msg_id = 0;
request.device_id = dev_addr;
@@ -605,7 +605,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -626,7 +626,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
request.address = offset;
request.length = len;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write SMBUS request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -694,7 +694,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -712,7 +712,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
if ((self->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write macsec request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -742,7 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32)));
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
index df0aa21a9b..a7b892b806 100644
--- a/drivers/net/axgbe/axgbe_common.h
+++ b/drivers/net/axgbe/axgbe_common.h
@@ -19,7 +19,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_bitops.h>
#include <rte_byteorder.h>
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 786288a7b0..197c722901 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -167,12 +167,12 @@ static int axgbe_read_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
mmd_data = XPCS16_IOREAD(pdata, offset);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
return mmd_data;
}
@@ -201,12 +201,12 @@ static void axgbe_write_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
XPCS16_IOWRITE(pdata, offset, mmd_data);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
}
static int axgbe_read_mmd_regs(struct axgbe_port *pdata, int prtad,
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 9cb4818af1..caf5a4476f 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -2311,10 +2311,10 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
pdata->tx_desc_count = AXGBE_MAX_RING_DESC;
pdata->rx_desc_count = AXGBE_MAX_RING_DESC;
- pthread_mutex_init(&pdata->xpcs_mutex, NULL);
- pthread_mutex_init(&pdata->i2c_mutex, NULL);
- pthread_mutex_init(&pdata->an_mutex, NULL);
- pthread_mutex_init(&pdata->phy_mutex, NULL);
+ rte_thread_mutex_init(&pdata->xpcs_mutex);
+ rte_thread_mutex_init(&pdata->i2c_mutex);
+ rte_thread_mutex_init(&pdata->an_mutex);
+ rte_thread_mutex_init(&pdata->phy_mutex);
ret = pdata->phy_if.phy_init(pdata);
if (ret) {
diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h
index a6226729fe..f2929d57ab 100644
--- a/drivers/net/axgbe/axgbe_ethdev.h
+++ b/drivers/net/axgbe/axgbe_ethdev.h
@@ -602,10 +602,10 @@ struct axgbe_port {
int phy_link;
int phy_speed;
- pthread_mutex_t xpcs_mutex;
- pthread_mutex_t i2c_mutex;
- pthread_mutex_t an_mutex;
- pthread_mutex_t phy_mutex;
+ rte_thread_mutex xpcs_mutex;
+ rte_thread_mutex i2c_mutex;
+ rte_thread_mutex an_mutex;
+ rte_thread_mutex phy_mutex;
/* Flow control settings */
unsigned int pause_autoneg;
diff --git a/drivers/net/axgbe/axgbe_i2c.c b/drivers/net/axgbe/axgbe_i2c.c
index ab3738a12e..c17f9a8b9e 100644
--- a/drivers/net/axgbe/axgbe_i2c.c
+++ b/drivers/net/axgbe/axgbe_i2c.c
@@ -229,7 +229,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
int ret;
uint64_t timeout;
- pthread_mutex_lock(&pdata->i2c_mutex);
+ rte_thread_mutex_lock(&pdata->i2c_mutex);
ret = axgbe_i2c_disable(pdata);
if (ret) {
PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
@@ -282,7 +282,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
}
unlock:
- pthread_mutex_unlock(&pdata->i2c_mutex);
+ rte_thread_mutex_unlock(&pdata->i2c_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c
index 4f98e695ae..5f3d9b360e 100644
--- a/drivers/net/axgbe/axgbe_mdio.c
+++ b/drivers/net/axgbe/axgbe_mdio.c
@@ -686,9 +686,9 @@ static void axgbe_an73_isr(struct axgbe_port *pdata)
if (pdata->an_int) {
/* Clear the interrupt(s) that fired and process them */
XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, ~pdata->an_int);
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
axgbe_an73_state_machine(pdata);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
} else {
/* Enable AN interrupts */
axgbe_an73_enable_interrupts(pdata);
@@ -977,7 +977,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
{
int ret;
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
ret = __axgbe_phy_config_aneg(pdata);
if (ret)
@@ -985,7 +985,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
else
rte_bit_relaxed_clear32(AXGBE_LINK_ERR, &pdata->dev_state);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 02236ec192..1e1d6358d8 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -403,7 +403,7 @@ static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata)
phy_data->comm_owned = 0;
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
}
static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
@@ -416,7 +416,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
* the driver needs to take the software mutex and then the hardware
* mutexes before being able to use the busses.
*/
- pthread_mutex_lock(&pdata->phy_mutex);
+ rte_thread_mutex_lock(&pdata->phy_mutex);
if (phy_data->comm_owned)
return 0;
@@ -447,7 +447,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
return 0;
}
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
PMD_DRV_LOG(ERR, "unable to obtain hardware mutexes\n");
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 494a1eff37..f013bb8a79 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -540,8 +540,8 @@ struct bnxt_mark_info {
struct bnxt_rep_info {
struct rte_eth_dev *vfr_eth_dev;
- pthread_mutex_t vfr_lock;
- pthread_mutex_t vfr_start_lock;
+ rte_thread_mutex vfr_lock;
+ rte_thread_mutex vfr_start_lock;
bool conduit_valid;
};
@@ -739,7 +739,7 @@ struct bnxt {
#define BNXT_FW_CAP_TRUFLOW_EN BIT(8)
#define BNXT_TRUFLOW_EN(bp) ((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN)
- pthread_mutex_t flow_lock;
+ rte_thread_mutex flow_lock;
uint32_t vnic_cap_flags;
#define BNXT_VNIC_CAP_COS_CLASSIFY BIT(0)
@@ -793,18 +793,18 @@ struct bnxt {
rte_iova_t hwrm_short_cmd_req_dma_addr;
rte_spinlock_t hwrm_lock;
/* synchronize between dev_configure_op and int handler */
- pthread_mutex_t def_cp_lock;
+ rte_thread_mutex def_cp_lock;
/* synchronize between dev_start_op and async evt handler
* Locking sequence in async evt handler will be
* def_cp_lock
* health_check_lock
*/
- pthread_mutex_t health_check_lock;
+ rte_thread_mutex health_check_lock;
/* synchronize between dev_stop/dev_close_op and
* error recovery thread triggered as part of
* HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY
*/
- pthread_mutex_t err_recovery_lock;
+ rte_thread_mutex err_recovery_lock;
uint16_t max_req_len;
uint16_t max_resp_len;
uint16_t hwrm_max_ext_req_len;
@@ -1014,10 +1014,10 @@ uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
extern const struct rte_flow_ops bnxt_flow_ops;
#define bnxt_acquire_flow_lock(bp) \
- pthread_mutex_lock(&(bp)->flow_lock)
+ rte_thread_mutex_lock(&(bp)->flow_lock)
#define bnxt_release_flow_lock(bp) \
- pthread_mutex_unlock(&(bp)->flow_lock)
+ rte_thread_mutex_unlock(&(bp)->flow_lock)
#define BNXT_VALID_VNIC_OR_RET(bp, vnic_id) do { \
if ((vnic_id) >= (bp)->max_vnics) { \
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 12230dcea4..6c0fc248ab 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -156,7 +156,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
return;
}
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
event_data = data1;
/* timestamp_lo/hi values are in units of 100ms */
bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
@@ -178,7 +178,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
}
bp->flags |= BNXT_FLAG_FW_RESET;
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
(void *)bp);
break;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index de34a2f0bb..6c93bee284 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1087,7 +1087,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
* are calculated correctly.
*/
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
bnxt_disable_int(bp);
@@ -1097,20 +1097,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return -ENOSPC;
}
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
rc = bnxt_alloc_async_cp_ring(bp);
if (rc) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return rc;
}
bnxt_enable_int(bp);
}
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
/* Inherit new configurations */
@@ -1532,14 +1532,14 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error..Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return bnxt_dev_stop(eth_dev);
}
@@ -1625,13 +1625,13 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
static void
bnxt_uninit_locks(struct bnxt *bp)
{
- pthread_mutex_destroy(&bp->flow_lock);
- pthread_mutex_destroy(&bp->def_cp_lock);
- pthread_mutex_destroy(&bp->health_check_lock);
- pthread_mutex_destroy(&bp->err_recovery_lock);
+ rte_thread_mutex_destroy(&bp->flow_lock);
+ rte_thread_mutex_destroy(&bp->def_cp_lock);
+ rte_thread_mutex_destroy(&bp->health_check_lock);
+ rte_thread_mutex_destroy(&bp->err_recovery_lock);
if (bp->rep_info) {
- pthread_mutex_destroy(&bp->rep_info->vfr_lock);
- pthread_mutex_destroy(&bp->rep_info->vfr_start_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_start_lock);
}
}
@@ -1663,14 +1663,14 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error...Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
/* cancel the recovery handler before remove dev */
rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp);
@@ -4312,7 +4312,7 @@ static void bnxt_dev_recover(void *arg)
struct bnxt *bp = arg;
int rc = 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (!bp->fw_reset_min_msecs) {
rc = bnxt_check_fw_reset_done(bp);
@@ -4347,7 +4347,7 @@ static void bnxt_dev_recover(void *arg)
goto err_start;
PMD_DRV_LOG(INFO, "Recovered from FW reset\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return;
err_start:
@@ -4359,7 +4359,7 @@ static void bnxt_dev_recover(void *arg)
rte_eth_dev_callback_process(bp->eth_dev,
RTE_ETH_EVENT_INTR_RMV,
NULL);
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
PMD_DRV_LOG(ERR, "Failed to recover from FW reset\n");
}
@@ -4535,7 +4535,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
{
uint32_t polling_freq;
- pthread_mutex_lock(&bp->health_check_lock);
+ rte_thread_mutex_lock(&bp->health_check_lock);
if (!bnxt_is_recovery_enabled(bp))
goto done;
@@ -4550,7 +4550,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
done:
- pthread_mutex_unlock(&bp->health_check_lock);
+ rte_thread_mutex_unlock(&bp->health_check_lock);
}
static void bnxt_cancel_fw_health_check(struct bnxt *bp)
@@ -5395,25 +5395,25 @@ bnxt_init_locks(struct bnxt *bp)
{
int err;
- err = pthread_mutex_init(&bp->flow_lock, NULL);
+ err = rte_thread_mutex_init(&bp->flow_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->def_cp_lock, NULL);
+ err = rte_thread_mutex_init(&bp->def_cp_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->health_check_lock, NULL);
+ err = rte_thread_mutex_init(&bp->health_check_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize health_check_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
+ err = rte_thread_mutex_init(&bp->err_recovery_lock);
if (err)
PMD_DRV_LOG(ERR, "Unable to initialize err_recovery_lock\n");
@@ -6237,14 +6237,14 @@ static int bnxt_init_rep_info(struct bnxt *bp)
for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
- rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_lock\n");
bnxt_free_rep_info(bp);
return rc;
}
- rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_start_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_start_lock\n");
bnxt_free_rep_info(bp);
diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 122a1f9908..7f5203aea3 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -33,15 +33,15 @@ void bnxt_int_handler(void *param)
return;
raw_cons = cpr->cp_raw_cons;
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
while (1) {
if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
if (is_bnxt_in_error(bp)) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
@@ -62,7 +62,7 @@ void bnxt_int_handler(void *param)
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
int bnxt_free_int(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index bdbad53b7d..49d3ec66bc 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -120,7 +120,7 @@ bnxt_rep_tx_burst(void *tx_queue,
qid = vfr_txq->txq->queue_id;
vf_rep_bp = vfr_txq->bp;
parent = vf_rep_bp->parent_dev->data->dev_private;
- pthread_mutex_lock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_lock(&parent->rep_info->vfr_lock);
ptxq = parent->tx_queues[qid];
ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
@@ -132,7 +132,7 @@ bnxt_rep_tx_burst(void *tx_queue,
rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
ptxq->vfr_tx_cfa_action = 0;
- pthread_mutex_unlock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_unlock(&parent->rep_info->vfr_lock);
return rc;
}
@@ -407,15 +407,15 @@ int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
rep_info = &parent_bp->rep_info[rep_bp->vf_id];
BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR start\n", eth_dev->data->port_id);
- pthread_mutex_lock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_lock(&rep_info->vfr_start_lock);
if (!rep_info->conduit_valid) {
rc = bnxt_get_dflt_vnic_svif(parent_bp, rep_bp);
if (rc || !rep_info->conduit_valid) {
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
return rc;
}
}
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
rc = bnxt_vfr_alloc(eth_dev);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index dbf85e4eda..6af529b4ff 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -32,7 +32,7 @@ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
STAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);
/* Mutex to synchronize bnxt_ulp_session_list operations. */
-static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(bnxt_ulp_global_mutex)
/* Spin lock to protect context global list */
rte_spinlock_t bnxt_ulp_ctxt_lock;
@@ -975,7 +975,7 @@ ulp_ctx_detach(struct bnxt *bp)
static void
ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
{
- pthread_mutex_lock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_lock(&session->bnxt_ulp_mutex);
if (!session->bnxt_ulp_init) {
session->bnxt_ulp_init = true;
@@ -984,7 +984,7 @@ ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
*init = true;
}
- pthread_mutex_unlock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_unlock(&session->bnxt_ulp_mutex);
}
/*
@@ -1025,7 +1025,7 @@ ulp_session_init(struct bnxt *bp,
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
if (!session) {
@@ -1036,17 +1036,17 @@ ulp_session_init(struct bnxt *bp,
if (!session) {
BNXT_TF_DBG(ERR,
"Allocation failed for bnxt_ulp_session\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
} else {
/* Add it to the queue */
session->pci_info.domain = pci_addr->domain;
session->pci_info.bus = pci_addr->bus;
- rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
+ rc = rte_thread_mutex_init(&session->bnxt_ulp_mutex);
if (rc) {
BNXT_TF_DBG(ERR, "mutex create failed\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
}
STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
@@ -1054,7 +1054,7 @@ ulp_session_init(struct bnxt *bp,
}
}
ulp_context_initialized(session, init);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return session;
}
@@ -1069,12 +1069,12 @@ ulp_session_deinit(struct bnxt_ulp_session_state *session)
return;
if (!session->cfg_data) {
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
STAILQ_REMOVE(&bnxt_ulp_session_list, session,
bnxt_ulp_session_state, next);
- pthread_mutex_destroy(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_destroy(&session->bnxt_ulp_mutex);
rte_free(session);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
}
}
@@ -1235,7 +1235,7 @@ bnxt_ulp_deinit(struct bnxt *bp,
BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0);
/* free the flow db lock */
- pthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (ha_enabled)
ulp_ha_mgr_deinit(bp->ulp_ctx);
@@ -1263,7 +1263,7 @@ bnxt_ulp_init(struct bnxt *bp,
goto jump_to_error;
}
- rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (rc) {
BNXT_TF_DBG(ERR, "Unable to initialize flow db lock\n");
goto jump_to_error;
@@ -1529,9 +1529,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp)
/* Get the session details */
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
/* session not found then just exit */
if (!session) {
@@ -1938,7 +1938,7 @@ bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return -1;
- if (pthread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
+ if (rte_thread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
BNXT_TF_DBG(ERR, "unable to acquire fdb lock\n");
return -1;
}
@@ -1952,7 +1952,7 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return;
- pthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
}
/* Function to set the ha info into the context */
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 082ca501b6..b33e035637 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -64,7 +64,7 @@ struct bnxt_ulp_data {
uint32_t dev_id; /* Hardware device id */
uint32_t ref_cnt;
struct bnxt_ulp_flow_db *flow_db;
- pthread_mutex_t flow_db_lock;
+ rte_thread_mutex flow_db_lock;
void *mapper_data;
struct bnxt_ulp_port_db *port_db;
struct bnxt_ulp_fc_info *fc_info;
@@ -95,7 +95,7 @@ struct bnxt_ulp_pci_info {
struct bnxt_ulp_session_state {
STAILQ_ENTRY(bnxt_ulp_session_state) next;
bool bnxt_ulp_init;
- pthread_mutex_t bnxt_ulp_mutex;
+ rte_thread_mutex bnxt_ulp_mutex;
struct bnxt_ulp_pci_info pci_info;
struct bnxt_ulp_data *cfg_data;
struct tf *g_tfp;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 13f71ed83b..2e99b4d79e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -3,6 +3,7 @@
* All rights reserved.
*/
+#include <pthread.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
@@ -84,7 +85,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
if (!ulp_fc_info)
goto error;
- rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
+ rc = rte_thread_mutex_init(&ulp_fc_info->fc_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize fc mutex\n");
goto error;
@@ -149,7 +150,7 @@ ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt)
ulp_fc_mgr_thread_cancel(ctxt);
- pthread_mutex_destroy(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_destroy(&ulp_fc_info->fc_lock);
if (ulp_fc_info->num_counters) {
for (i = 0; i < TF_DIR_MAX; i++)
@@ -485,11 +486,12 @@ ulp_fc_mgr_alarm_cb(void *arg __rte_unused)
* Take the fc_lock to ensure no flow is destroyed
* during the bulk get
*/
- if (pthread_mutex_trylock(&ulp_fc_info->fc_lock))
+ if (pthread_mutex_trylock((pthread_mutex_t *)
+ &ulp_fc_info->fc_lock.mutex_id))
goto out;
if (!ulp_fc_info->num_entries) {
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
ulp_fc_mgr_thread_cancel(ctxt);
bnxt_ulp_cntxt_entry_release();
return;
@@ -521,7 +523,7 @@ ulp_fc_mgr_alarm_cb(void *arg __rte_unused)
}
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
/*
* If cmd fails once, no need of
@@ -617,12 +619,12 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info->num_counters)
return 0;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = true;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = hw_cntr_id;
ulp_fc_info->num_entries++;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -652,14 +654,14 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info->num_counters)
return 0;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = false;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].pkt_count = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].byte_count = 0;
ulp_fc_info->num_entries--;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -730,7 +732,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
/* TODO:
* Think about optimizing with try_lock later
*/
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id -
ulp_fc_info->shadow_hw_tbl[dir].start_idx;
sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
@@ -744,7 +746,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
sw_acc_tbl_entry->pkt_count = 0;
sw_acc_tbl_entry->byte_count = 0;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
} else if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT_ACC) {
/* Get stats from the parent child table */
@@ -786,7 +788,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
if (ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid) {
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].parent_flow_id = fid;
@@ -795,7 +797,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
hw_cntr_id, fid);
rc = -ENOENT;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return rc;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index 448d05c118..a44dcaf047 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -45,10 +45,10 @@ struct hw_fc_mem_info {
struct bnxt_ulp_fc_info {
struct sw_acc_counter *sw_acc_tbl[TF_DIR_MAX];
struct hw_fc_mem_info shadow_hw_tbl[TF_DIR_MAX];
- uint32_t flags;
- uint32_t num_entries;
- pthread_mutex_t fc_lock;
- uint32_t num_counters;
+ uint32_t flags;
+ uint32_t num_entries;
+ rte_thread_mutex fc_lock;
+ uint32_t num_counters;
};
int32_t
diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
index 5f5b5d639e..c540cb8436 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
@@ -328,7 +328,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
/* Add the HA info tbl to the ulp context. */
bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
- rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
+ rc = rte_thread_mutex_init(&ha_info->ha_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize ha mutex\n");
goto cleanup;
@@ -359,7 +359,7 @@ ulp_ha_mgr_deinit(struct bnxt_ulp_context *ulp_ctx)
return;
}
- pthread_mutex_destroy(&ha_info->ha_lock);
+ rte_thread_mutex_destroy(&ha_info->ha_lock);
rte_free(ha_info);
bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, NULL);
diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
index 793511564a..8b006f6c99 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
@@ -31,7 +31,7 @@ struct bnxt_ulp_ha_mgr_info {
enum ulp_ha_mgr_app_type app_type;
enum ulp_ha_mgr_region region;
uint32_t flags;
- pthread_mutex_t ha_lock;
+ rte_thread_mutex ha_lock;
};
bool
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 27d670f843..0983630f5e 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 423de40e95..55eb14af5f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <limits.h>
#include <sched.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_byteorder.h>
#include <rte_common.h>
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 4e7f52881a..6fe3824758 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
@@ -141,14 +142,14 @@ extern int ena_logtype_com;
typedef struct {
pthread_cond_t cond;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
uint8_t flag;
} ena_wait_event_t;
#define ENA_WAIT_EVENT_INIT(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_init(&_we->mutex, NULL); \
+ rte_thread_mutex_init(&_we->mutex); \
pthread_cond_init(&_we->cond, NULL); \
_we->flag = 0; \
} while (0)
@@ -165,10 +166,10 @@ typedef struct {
wait.tv_sec = now.tv_sec + _tmo / 1000000UL; \
timeout_us = _tmo % 1000000UL; \
wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
while (ret == 0 && !_we->flag) { \
ret = pthread_cond_timedwait(&_we->cond, \
- &_we->mutex, &wait); \
+ _we->mutex.mutex_id, &wait); \
} \
/* Asserts only if not working on ena_wait_event_t */ \
if (unlikely(ret != 0 && ret != ETIMEDOUT)) \
@@ -178,15 +179,15 @@ typedef struct {
ena_trc_err(NULL, \
"Timeout waiting for " #waitevent "\n"); \
_we->flag = 0; \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
#define ENA_WAIT_EVENT_SIGNAL(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
_we->flag = 1; \
pthread_cond_signal(&_we->cond); \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
/* pthread condition doesn't need to be rearmed after usage */
#define ENA_WAIT_EVENT_CLEAR(...)
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 47bfdac2cf..db07c589b9 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -107,7 +107,7 @@ struct enic {
int iommu_groupid;
int eventfd;
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
- pthread_t err_intr_thread;
+ rte_thread_t err_intr_thread;
int promisc;
int allmulti;
uint8_t ig_vlan_strip_en;
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index f461318f96..3d4fe47489 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -3,7 +3,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <unistd.h>
#include <rte_spinlock.h>
@@ -121,7 +121,7 @@ ice_dcf_vsi_update_service_handler(void *param)
struct ice_dcf_hw *hw = reset_param->dcf_hw;
struct ice_dcf_adapter *adapter;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL);
@@ -159,7 +159,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
#define THREAD_NAME_LEN 16
struct ice_dcf_reset_event_param *param;
char name[THREAD_NAME_LEN];
- pthread_t thread;
+ rte_thread_t thread;
int ret;
param = malloc(sizeof(*param));
@@ -173,7 +173,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
param->vf_id = vf_id;
snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
- ret = rte_ctrl_thread_create(&thread, name, NULL,
+ ret = rte_thread_ctrl_thread_create(&thread, name,
ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b5371568b5..cf7b19edc0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4156,7 +4156,7 @@ ixgbe_dev_setup_link_thread_handler(void *param)
u32 speed;
bool autoneg = false;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
speed = hw->phy.autoneg_advertised;
if (!speed)
ixgbe_get_link_capabilities(hw, &speed, &autoneg);
@@ -4264,9 +4264,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
* when there is no link thread running.
*/
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
- if (rte_ctrl_thread_create(&ad->link_thread_tid,
+ if (rte_thread_ctrl_thread_create
+ (&ad->link_thread_tid,
"ixgbe-link-handler",
- NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index a0ce18ca24..272fdcfb8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -516,7 +516,7 @@ struct ixgbe_adapter {
uint8_t pflink_fullchk;
uint8_t mac_ctrl_frame_fwd;
rte_atomic32_t link_thread_running;
- pthread_t link_thread_tid;
+ rte_thread_t link_thread_tid;
};
struct ixgbe_vf_representor {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 5f8766aa48..85b92b5ee5 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2872,7 +2872,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int dbmap_env;
int err = 0;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/*
* Configure environment variable "MLX5_BF_SHUT_UP"
* before the device creation. The rdma_core library
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f84e061fe7..71c2918bed 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -186,7 +186,7 @@ int mlx5_logtype;
static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
LIST_HEAD_INITIALIZER();
-static pthread_mutex_t mlx5_dev_ctx_list_mutex;
+static rte_thread_mutex mlx5_dev_ctx_list_mutex;
static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
[MLX5_IPOOL_DECAP_ENCAP] = {
@@ -1117,7 +1117,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
MLX5_ASSERT(spawn);
/* Secondary process should not create the shared context. */
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
/* Search for IB context by device name. */
LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
if (!strcmp(sh->ibdev_name,
@@ -1246,11 +1246,11 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
LIST_INSERT_HEAD(&mlx5_dev_ctx_list, sh, next);
rte_spinlock_init(&sh->geneve_tlv_opt_sl);
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
return sh;
error:
- pthread_mutex_destroy(&sh->txpp.mutex);
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
MLX5_ASSERT(sh);
if (sh->cnt_id_tbl)
mlx5_l3t_destroy(sh->cnt_id_tbl);
@@ -1282,7 +1282,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
void
mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
{
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Check the object presence in the list. */
struct mlx5_dev_ctx_shared *lctx;
@@ -1313,7 +1313,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
/* Release flow workspaces objects on the last device. */
if (LIST_EMPTY(&mlx5_dev_ctx_list))
mlx5_flow_os_release_workspace();
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.
* Only primary process handles async device events.
@@ -1346,11 +1346,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
if (sh->ctx)
claim_zero(mlx5_glue->close_device(sh->ctx));
MLX5_ASSERT(sh->geneve_tlv_option_resource == NULL);
- pthread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
mlx5_free(sh);
return;
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
}
/**
@@ -2502,7 +2502,7 @@ RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
*/
RTE_INIT(rte_mlx5_pmd_init)
{
- pthread_mutex_init(&mlx5_dev_ctx_list_mutex, NULL);
+ rte_thread_mutex_init(&mlx5_dev_ctx_list_mutex);
mlx5_common_init();
/* Build the static tables for Verbs conversion. */
mlx5_set_ptype_table();
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e02714e231..d8726d115a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1010,7 +1010,7 @@ struct mlx5_txpp_ts {
/* Tx packet pacing structure. */
struct mlx5_dev_txpp {
- pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
+ rte_thread_mutex mutex; /* Pacing create/destroy mutex. */
uint32_t refcnt; /* Pacing reference counter. */
uint32_t freq; /* Timestamp frequency, Hz. */
uint32_t tick; /* Completion tick duration in nanoseconds. */
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 4f6da9f2d1..83c4743faf 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -914,7 +914,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
if (ret < 0)
return 0;
}
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
if (sh->txpp.refcnt) {
@@ -930,7 +930,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
rte_errno = -err;
}
}
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
return err;
@@ -957,7 +957,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
}
priv->txpp_en = 0;
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
MLX5_ASSERT(sh->txpp.refcnt);
@@ -965,7 +965,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
/* No references any more, do actual destroy. */
mlx5_txpp_destroy(sh);
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
}
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index c4d5790726..ccdb0184a9 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -253,7 +253,7 @@ struct mlx5_workspace_thread {
static struct mlx5_workspace_thread *curr;
static struct mlx5_workspace_thread *first;
rte_thread_key ws_tls_index;
-static pthread_mutex_t lock_thread_list;
+RTE_STATIC_MUTEX(lock_thread_list)
static bool
mlx5_is_thread_alive(HANDLE thread_handle)
@@ -330,7 +330,7 @@ mlx5_flow_os_release_workspace(void)
free(first);
}
rte_thread_key_delete(ws_tls_index);
- pthread_mutex_destroy(&lock_thread_list);
+ rte_thread_mutex_destroy(&lock_thread_list);
}
static int
@@ -352,7 +352,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
}
temp->mlx5_ws = data;
temp->thread_handle = curr_thread;
- pthread_mutex_lock(&lock_thread_list);
+ rte_thread_mutex_lock(&lock_thread_list);
mlx5_clear_thread_list();
if (!first) {
first = temp;
@@ -361,7 +361,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
curr->next = temp;
curr = curr->next;
}
- pthread_mutex_unlock(&lock_thread_list);
+ rte_thread_mutex_unlock(&lock_thread_list);
return 0;
}
@@ -374,7 +374,7 @@ mlx5_flow_os_init_workspace_once(void)
DRV_LOG(ERR, "Can't create flow workspace data thread key.");
return err;
}
- pthread_mutex_init(&lock_thread_list, NULL);
+ rte_thread_mutex_init(&lock_thread_list);
return 0;
}
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 7e1df1c751..99876f227b 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -264,7 +264,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
struct mlx5_context *mlx5_ctx;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/* Set numa node from pci probe */
sh->numa_node = spawn->pci_dev->device.numa_node;
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index c5b5399282..c9011d964b 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -153,10 +153,10 @@ void osal_dma_free_mem(struct ecore_dev *edev, dma_addr_t phys);
/* Mutexes */
-typedef pthread_mutex_t osal_mutex_t;
-#define OSAL_MUTEX_RELEASE(lock) pthread_mutex_unlock(lock)
-#define OSAL_MUTEX_INIT(lock) pthread_mutex_init(lock, NULL)
-#define OSAL_MUTEX_ACQUIRE(lock) pthread_mutex_lock(lock)
+typedef rte_thread_mutex osal_mutex_t;
+#define OSAL_MUTEX_RELEASE(lock) rte_thread_mutex_unlock(lock)
+#define OSAL_MUTEX_INIT(lock) rte_thread_mutex_init(lock)
+#define OSAL_MUTEX_ACQUIRE(lock) rte_thread_mutex_lock(lock)
#define OSAL_MUTEX_ALLOC(hwfn, lock) nothing
#define OSAL_MUTEX_DEALLOC(lock) nothing
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index a202931e9a..484b647a62 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -3,7 +3,7 @@
* Copyright(c) 2016-2018 Intel Corporation
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdbool.h>
#include <sys/epoll.h>
@@ -121,7 +121,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static struct rte_eth_link pmd_link = {
.link_speed = 10000,
@@ -507,7 +507,7 @@ find_internal_resource(char *ifname)
if (ifname == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internal = list->eth_dev->data->dev_private;
@@ -517,7 +517,7 @@ find_internal_resource(char *ifname)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -1001,9 +1001,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
goto free_list;
list->eth_dev = eth_dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_spinlock_init(&vring_state->lock);
vring_states[eth_dev->data->port_id] = vring_state;
@@ -1035,9 +1035,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
rte_vhost_driver_unregister(internal->iface_name);
list_remove:
vring_states[eth_dev->data->port_id] = NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(vring_state);
free_list:
rte_free(list);
@@ -1093,7 +1093,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
if (!rte_eth_dev_is_valid_port(port_id))
return -1;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
eth_dev = list->eth_dev;
@@ -1106,7 +1106,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return vid;
}
@@ -1184,9 +1184,9 @@ eth_dev_close(struct rte_eth_dev *dev)
list = find_internal_resource(internal->iface_name);
if (list) {
rte_vhost_driver_unregister(internal->iface_name);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 16c58710d7..df2200d8cc 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -143,7 +143,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
uint64_t features;
int ret = -1;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 0: tell vhost to create queues */
if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
@@ -161,7 +161,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
goto error;
PMD_DRV_LOG(INFO, "(%s) set features: 0x%" PRIx64, dev->path, features);
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -185,7 +185,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
* memory subsystem in the future.
*/
rte_mcfg_mem_read_lock();
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 2: share memory regions */
ret = dev->ops->set_memory_table(dev);
@@ -206,12 +206,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
dev->started = true;
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
return 0;
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
PMD_INIT_LOG(ERR, "(%s) Failed to start device\n", dev->path);
@@ -226,7 +226,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
uint32_t i;
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (!dev->started)
goto out;
@@ -249,11 +249,11 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
dev->started = false;
out:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return 0;
err:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
PMD_INIT_LOG(ERR, "(%s) Failed to stop device\n", dev->path);
@@ -443,7 +443,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
if (msl->external)
return;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (dev->started == false)
goto exit;
@@ -468,7 +468,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
}
exit:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
if (ret < 0)
PMD_DRV_LOG(ERR, "(%s) Failed to update memory table\n", dev->path);
@@ -554,7 +554,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
uint64_t backend_features;
int i;
- pthread_mutex_init(&dev->mutex, NULL);
+ rte_thread_mutex_init(&dev->mutex);
strlcpy(dev->path, path, PATH_MAX);
for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; i++) {
@@ -862,13 +862,13 @@ virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status)
{
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
dev->status = status;
ret = dev->ops->set_status(dev, status);
if (ret && ret != -ENOTSUP)
PMD_INIT_LOG(ERR, "(%s) Failed to set backend status\n", dev->path);
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -878,7 +878,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
int ret;
uint8_t status;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
ret = dev->ops->get_status(dev, &status);
if (!ret) {
@@ -903,7 +903,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
PMD_INIT_LOG(ERR, "(%s) Failed to get backend status\n", dev->path);
}
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 819f6463ba..1df8d80f90 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -55,7 +55,7 @@ struct virtio_user_dev {
bool qp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];
struct virtio_user_backend_ops *ops;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
bool started;
void *backend_data;
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 1dc813d0a3..81ff6c2d58 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -23,6 +23,7 @@
#include <rte_log.h>
#include <rte_kvargs.h>
#include <rte_devargs.h>
+#include <rte_thread.h>
#include "base/ifcvf.h"
@@ -52,7 +53,7 @@ struct ifcvf_internal {
int vfio_container_fd;
int vfio_group_fd;
int vfio_dev_fd;
- pthread_t tid; /* thread for notify relay */
+ rte_thread_t tid; /* thread for notify relay */
int epfd;
int vid;
struct rte_vdpa_device *vdev;
@@ -79,7 +80,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static void update_used_ring(struct ifcvf_internal *internal, uint16_t qid);
@@ -89,7 +90,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (vdev == list->internal->vdev) {
@@ -98,7 +99,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -112,7 +113,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (!rte_pci_addr_cmp(&pdev->addr,
@@ -122,7 +123,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -500,10 +501,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, notify_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create notify relay pthread.");
+ DRV_LOG(ERR, "failed to create notify relay thread.");
return -1;
}
@@ -513,13 +514,11 @@ setup_notify_relay(struct ifcvf_internal *internal)
static int
unset_notify_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -806,10 +805,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, vring_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create ring relay pthread.");
+ DRV_LOG(ERR, "failed to create ring relay thread.");
return -1;
}
@@ -819,13 +818,11 @@ setup_vring_relay(struct ifcvf_internal *internal)
static int
unset_vring_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -1253,9 +1250,9 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto error;
}
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_atomic32_set(&internal->started, 1);
update_datapath(internal);
@@ -1293,9 +1290,9 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
rte_vfio_container_destroy(internal->vfio_container_fd);
rte_vdpa_unregister_device(internal->vdev);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
rte_free(internal);
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 6d17d7a6f3..cd9cb9fca3 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -48,7 +48,7 @@
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
static struct mlx5_vdpa_priv *
mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
@@ -56,14 +56,14 @@ mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
struct mlx5_vdpa_priv *priv;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (vdev == priv->vdev) {
found = 1;
break;
}
}
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (!found) {
DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name);
rte_errno = EINVAL;
@@ -143,9 +143,9 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)
DRV_LOG(ERR, "Too big vring id: %d.", vring);
return -E2BIG;
}
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
ret = mlx5_vdpa_virtq_enable(priv, vring, state);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
return ret;
}
@@ -296,7 +296,7 @@ mlx5_vdpa_dev_close(int vid)
priv->configured = 0;
priv->vid = 0;
/* The mutex may stay locked after event thread cancel - initiate it. */
- pthread_mutex_init(&priv->vq_config_lock, NULL);
+ rte_thread_mutex_init(&priv->vq_config_lock);
DRV_LOG(INFO, "vDPA device %d was closed.", vid);
return ret;
}
@@ -706,10 +706,10 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
}
mlx5_vdpa_config_get(dev->devargs, priv);
SLIST_INIT(&priv->mr_list);
- pthread_mutex_init(&priv->vq_config_lock, NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_init(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
error:
@@ -729,7 +729,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
struct mlx5_vdpa_priv *priv = NULL;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (priv->vdev->device == dev) {
found = 1;
@@ -738,7 +738,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
}
if (found)
TAILQ_REMOVE(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (found) {
if (priv->configured)
mlx5_vdpa_dev_close(priv->vid);
@@ -749,7 +749,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
if (priv->vdev)
rte_vdpa_unregister_device(priv->vdev);
mlx5_glue->close_device(priv->ctx);
- pthread_mutex_destroy(&priv->vq_config_lock);
+ rte_thread_mutex_destroy(&priv->vq_config_lock);
rte_free(priv);
}
return 0;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h
index 2a04e36607..f22f66230a 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.h
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h
@@ -119,9 +119,9 @@ enum {
struct mlx5_vdpa_priv {
TAILQ_ENTRY(mlx5_vdpa_priv) next;
uint8_t configured;
- pthread_mutex_t vq_config_lock;
+ rte_thread_mutex vq_config_lock;
uint64_t no_traffic_counter;
- pthread_t timer_tid;
+ rte_thread_t timer_tid;
int event_mode;
int event_core; /* Event thread cpu affinity core. */
uint32_t event_us;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 3541c652ce..41c1f54447 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -285,7 +285,7 @@ mlx5_vdpa_event_handle(void *arg)
case MLX5_VDPA_EVENT_MODE_FIXED_TIMER:
priv->timer_delay_us = priv->event_us;
while (1) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
max = mlx5_vdpa_queues_complete(priv);
if (max == 0 && priv->no_traffic_counter++ >=
priv->no_traffic_max) {
@@ -293,10 +293,10 @@ mlx5_vdpa_event_handle(void *arg)
priv->vdev->device->name);
mlx5_vdpa_arm_all_cqs(priv);
do {
- pthread_mutex_unlock
+ rte_thread_mutex_unlock
(&priv->vq_config_lock);
cq = mlx5_vdpa_event_wait(priv);
- pthread_mutex_lock
+ rte_thread_mutex_lock
(&priv->vq_config_lock);
if (cq == NULL ||
mlx5_vdpa_queue_complete(cq) > 0)
@@ -307,7 +307,7 @@ mlx5_vdpa_event_handle(void *arg)
} else if (max != 0) {
priv->no_traffic_counter = 0;
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
mlx5_vdpa_timer_sleep(priv, max);
}
return NULL;
@@ -315,10 +315,10 @@ mlx5_vdpa_event_handle(void *arg)
do {
cq = mlx5_vdpa_event_wait(priv);
if (cq != NULL) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
if (mlx5_vdpa_queue_complete(cq) > 0)
mlx5_vdpa_cq_arm(priv, cq);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
}
} while (1);
return NULL;
@@ -340,7 +340,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
struct mlx5_vdpa_virtq *virtq;
uint64_t sec;
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
while (mlx5_glue->devx_get_event(priv->err_chnl, &out.event_resp,
sizeof(out.buf)) >=
(ssize_t)sizeof(out.event_resp.cookie)) {
@@ -386,7 +386,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
virtq->err_time[i - 1] = virtq->err_time[i];
virtq->err_time[RTE_DIM(virtq->err_time) - 1] = rte_rdtsc();
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
#endif
}
@@ -473,28 +473,23 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
{
int ret;
rte_cpuset_t cpuset;
- pthread_attr_t attr;
+ rte_thread_attr_t attr;
char name[16];
- const struct sched_param sp = {
- .sched_priority = sched_get_priority_max(SCHED_RR),
- };
if (!priv->eventc)
/* All virtqs are in poll mode. */
return 0;
- pthread_attr_init(&attr);
- ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
- if (ret) {
- DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
- return -1;
- }
- ret = pthread_attr_setschedparam(&attr, &sp);
+
+ rte_thread_attr_init(&attr);
+ ret = rte_thread_attr_set_priority(&attr,
+ RTE_THREAD_PRIORITY_REALTIME_CRITICAL);
if (ret) {
DRV_LOG(ERR, "Failed to set thread priority.");
return -1;
}
- ret = pthread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
- (void *)priv);
+
+ ret = rte_thread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
+ (void *)priv);
if (ret) {
DRV_LOG(ERR, "Failed to create timer thread.");
return -1;
@@ -504,13 +499,13 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
CPU_SET(priv->event_core, &cpuset);
else
cpuset = rte_lcore_cpuset(rte_get_main_lcore());
- ret = pthread_setaffinity_np(priv->timer_tid, sizeof(cpuset), &cpuset);
+ ret = rte_thread_set_affinity_by_id(priv->timer_tid, &cpuset);
if (ret) {
DRV_LOG(ERR, "Failed to set thread affinity.");
return -1;
}
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
- ret = rte_thread_setname(priv->timer_tid, name);
+ ret = rte_thread_name_set(priv->timer_tid, name);
if (ret)
DRV_LOG(DEBUG, "Cannot set timer thread name.");
return 0;
@@ -519,13 +514,11 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
void
mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv)
{
- void *status;
-
- if (priv->timer_tid) {
- pthread_cancel(priv->timer_tid);
- pthread_join(priv->timer_tid, &status);
+ if (priv->timer_tid.opaque_id) {
+ pthread_cancel(priv->timer_tid.opaque_id);
+ rte_thread_join(priv->timer_tid, NULL);
}
- priv->timer_tid = 0;
+ priv->timer_tid.opaque_id = 0;
}
void
diff --git a/examples/kni/main.c b/examples/kni/main.c
index beabb3c848..601c9838a2 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -16,6 +16,7 @@
#include <linux/if.h>
#include <linux/if_tun.h>
#include <fcntl.h>
+#include <pthread.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <signal.h>
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h
index e90fb15fc1..9979cc6cdb 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.h
+++ b/examples/performance-thread/pthread_shim/pthread_shim.h
@@ -6,6 +6,7 @@
#define _PTHREAD_SHIM_H_
#include <rte_lcore.h>
+#include <pthread.h>
/*
* This pthread shim is an example that demonstrates how legacy code
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 4/6] lib: enable the new EAL thread API
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (2 preceding siblings ...)
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_options.c | 6 ++---
lib/eal/common/eal_common_thread.c | 13 +++++----
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/malloc_mp.c | 2 ++
lib/eal/freebsd/eal.c | 18 ++++++-------
lib/eal/freebsd/eal_alarm.c | 12 ++++-----
lib/eal/freebsd/eal_interrupts.c | 6 ++---
lib/eal/freebsd/eal_thread.c | 10 ++++---
lib/eal/include/rte_lcore.h | 6 +++++
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/linux/eal.c | 22 ++++++++--------
lib/eal/linux/eal_alarm.c | 10 ++++---
lib/eal/linux/eal_interrupts.c | 8 +++---
lib/eal/linux/eal_thread.c | 11 +++++---
lib/eal/linux/eal_timer.c | 6 ++---
lib/eal/version.map | 4 +--
lib/eal/windows/eal.c | 4 ++-
lib/eal/windows/eal_interrupts.c | 8 +++---
lib/eal/windows/eal_thread.c | 35 ++++---------------------
lib/eal/windows/eal_windows.h | 10 -------
lib/eal/windows/include/rte_windows.h | 1 +
lib/ethdev/rte_ethdev.c | 4 +--
lib/ethdev/rte_ethdev_core.h | 4 +--
lib/ethdev/rte_flow.c | 4 +--
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
27 files changed, 99 insertions(+), 112 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 9d29696b84..1f6aba498c 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1872,8 +1872,7 @@ eal_auto_detect_cores(struct rte_config *cfg)
unsigned int removed = 0;
rte_cpuset_t affinity_set;
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &affinity_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set))
CPU_ZERO(&affinity_set);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
@@ -1901,8 +1900,7 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
}
RTE_CPU_NOT(cpuset, cpuset);
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &default_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set))
CPU_ZERO(&default_set);
RTE_CPU_AND(cpuset, cpuset, &default_set);
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 79545c67d9..62d28e7b28 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -6,7 +6,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <pthread.h>
+#endif /* RTE_EXEC_ENV_WINDOWS */
+#include <rte_thread.h>
#include <signal.h>
#include <sched.h>
#include <assert.h>
@@ -86,9 +89,8 @@ thread_update_affinity(rte_cpuset_t *cpusetp)
int
rte_thread_set_affinity(rte_cpuset_t *cpusetp)
{
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- cpusetp) != 0) {
- RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+ if (rte_thread_set_affinity_by_id(rte_thread_self(), cpusetp) != 0) {
+ RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
return -1;
}
@@ -166,6 +168,7 @@ __rte_thread_uninit(void)
RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
struct rte_thread_ctrl_params {
void *(*start_routine)(void *);
void *arg;
@@ -258,6 +261,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+#endif
struct rte_thread_ctrl_ctx {
rte_thread_func start_routine;
@@ -357,8 +361,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
- &cpuset) != 0)
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0)
CPU_ZERO(&cpuset);
lcore_id = eal_lcore_non_eal_allocate();
if (lcore_id >= RTE_MAX_LCORE)
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 7bff1cd2ce..94323e2c28 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -7,6 +7,7 @@
#include <sys/queue.h>
#include <regex.h>
+#include <pthread.h>
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 64cf4e81c8..4b95001d7d 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -19,7 +19,7 @@
* Structure storing internal configuration (per-lcore)
*/
struct lcore_config {
- pthread_t thread_id; /**< pthread identifier */
+ rte_thread_t thread_id; /**< pthread identifier */
int pipe_main2worker[2]; /**< communication pipe with main */
int pipe_worker2main[2]; /**< communication pipe with main */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2e597a17a2..7f7109d954 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <sys/time.h>
+#include <pthread.h>
+
#include <rte_alarm.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 6cee5ae369..c92fdaa598 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -669,7 +669,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
@@ -692,7 +692,7 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -856,7 +856,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -868,7 +868,7 @@ rte_eal_init(int argc, char **argv)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- config->main_lcore, thread_id, cpuset,
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -885,7 +885,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -893,10 +893,10 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- rte_thread_setname(lcore_config[i].thread_id, thread_name);
+ rte_thread_name_set(lcore_config[i].thread_id, thread_name);
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index c38b2e04f8..e5d7b130b1 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -37,7 +37,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -156,7 +156,7 @@ eal_alarm_callback(void *arg __rte_unused)
while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -263,8 +263,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
* finish. Otherwise we are trying to cancel
* ourselves - mark it by EINPROGRESS.
*/
- if (pthread_equal(ap->executing_id,
- pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -285,8 +285,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id,
- pthread_self()) == 0) {
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0) {
executing++;
} else {
err = EINPROGRESS;
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 86810845fe..61b6ef1f48 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -628,7 +628,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -737,5 +737,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 1dce9b04f2..8c572c7930 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sched.h>
#include <pthread_np.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <sys/thr.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,7 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (void *)thread_id.opaque_id, cpuset, ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 1550b75da0..8fab21299a 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -362,6 +362,7 @@ __rte_experimental
void
rte_lcore_dump(FILE *f);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Set thread names.
*
@@ -393,6 +394,8 @@ int rte_thread_setname(pthread_t id, const char *name);
__rte_experimental
int rte_thread_getname(pthread_t id, char *name, size_t len);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
/**
* Register current non-EAL thread as a lcore.
*
@@ -417,6 +420,7 @@ __rte_experimental
void
rte_thread_unregister(void);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Create a control thread.
*
@@ -444,6 +448,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0cb37..df1e51dcb8 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#include <pthread.h>
+#include <rte_thread.h>
/**
* Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 3577eaeaa4..cd5e9953d0 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -965,7 +965,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
const char *p;
@@ -993,7 +993,7 @@ rte_eal_init(int argc, char **argv)
p = strrchr(argv[0], '/');
strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -1221,7 +1221,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -1231,8 +1231,8 @@ rte_eal_init(int argc, char **argv)
&lcore_config[config->main_lcore].cpuset);
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
- RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->main_lcore, (uintptr_t)thread_id, cpuset,
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -1249,7 +1249,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1257,14 +1257,14 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- ret = rte_thread_setname(lcore_config[i].thread_id,
- thread_name);
+ ret = rte_thread_name_set(lcore_config[i].thread_id,
+ thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 3252c6fa59..fef22a347c 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -48,7 +48,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -86,7 +86,7 @@ eal_alarm_callback(void *arg __rte_unused)
(ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec &&
(ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -207,7 +207,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
/* If calling from other context, mark that alarm is executing
* so loop can spin till it finish. Otherwise we are trying to
* cancel our self - mark it by EINPROGRESS */
- if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -228,7 +229,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 22b3b7bcd9..d8ce854d90 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <unistd.h>
@@ -97,7 +97,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1167,7 +1167,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1570,5 +1570,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index 83c2034b93..91c239a217 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <sched.h>
#include <sys/queue.h>
#include <sys/syscall.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,8 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset,
+ ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 7cf15cabac..dc0308c761 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -12,7 +12,7 @@
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/queue.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <errno.h>
#include <rte_common.h>
@@ -80,7 +80,7 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
@@ -185,7 +185,7 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
+ ret = rte_thread_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc",
hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 67569b1bf9..9a130120e7 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -21,7 +21,7 @@ DPDK_22 {
rte_cpu_get_flag_enabled;
rte_cpu_get_flag_name;
rte_cpu_is_supported; # WINDOWS_NO_EXPORT
- rte_ctrl_thread_create;
+ rte_ctrl_thread_create; # WINDOWS_NO_EXPORT
rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
rte_delay_us;
rte_delay_us_block;
@@ -193,7 +193,7 @@ DPDK_22 {
rte_sys_gettid;
rte_thread_get_affinity;
rte_thread_set_affinity;
- rte_thread_setname;
+ rte_thread_setname; # WINDOWS_NO_EXPORT
rte_uuid_compare; # WINDOWS_NO_EXPORT
rte_uuid_is_null; # WINDOWS_NO_EXPORT
rte_uuid_parse; # WINDOWS_NO_EXPORT
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 3d8c520412..d90c635ddc 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -395,7 +395,9 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- if (eal_thread_create(&lcore_config[i].thread_id) != 0)
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
+ eal_thread_loop, NULL);
+ if (ret != 0)
rte_panic("Cannot create thread\n");
}
diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c
index bb0585cb34..43b0071da0 100644
--- a/lib/eal/windows/eal_interrupts.c
+++ b/lib/eal/windows/eal_interrupts.c
@@ -9,7 +9,7 @@
#define IOCP_KEY_SHUTDOWN UINT32_MAX
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static HANDLE intr_iocp;
static HANDLE intr_thread_handle;
@@ -78,7 +78,7 @@ eal_intr_thread_main(LPVOID arg __rte_unused)
intr_thread_handle = NULL;
cleanup:
- intr_thread = 0;
+ intr_thread.opaque_id = 0;
CloseHandle(intr_iocp);
intr_iocp = NULL;
@@ -98,7 +98,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -111,7 +111,7 @@ rte_eal_intr_init(void)
int
rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
int
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 9c3f6d69fd..fbdb7dbc76 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -60,15 +60,16 @@ eal_thread_loop(void *arg __rte_unused)
char c;
int n, ret;
unsigned int lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -80,7 +81,7 @@ eal_thread_loop(void *arg __rte_unused)
__rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset);
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset);
/* read on our pipe to get commands */
while (1) {
@@ -122,35 +123,9 @@ eal_thread_loop(void *arg __rte_unused)
}
}
-/* function to create threads */
-int
-eal_thread_create(pthread_t *thread)
-{
- HANDLE th;
-
- th = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
- NULL, 0, (LPDWORD)thread);
- if (!th)
- return -1;
-
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
-
- return 0;
-}
-
/* get current thread ID */
int
rte_sys_gettid(void)
{
return GetCurrentThreadId();
}
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
- /* TODO */
- /* This is a stub, not the expected result */
- return 0;
-}
diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h
index 355ef181a5..4ace532aac 100644
--- a/lib/eal/windows/eal_windows.h
+++ b/lib/eal/windows/eal_windows.h
@@ -35,16 +35,6 @@
*/
int eal_create_cpu_map(void);
-/**
- * Create a thread.
- *
- * @param thread
- * The location to store the thread id if successful.
- * @return
- * 0 for success, -1 if the thread is not created.
- */
-int eal_thread_create(pthread_t *thread);
-
/**
* Get system NUMA node number for a socket ID.
*
diff --git a/lib/eal/windows/include/rte_windows.h b/lib/eal/windows/include/rte_windows.h
index 0063b5d78c..d8c4ed10d7 100644
--- a/lib/eal/windows/include/rte_windows.h
+++ b/lib/eal/windows/include/rte_windows.h
@@ -28,6 +28,7 @@
#include <windows.h>
#include <basetsd.h>
+#include <processthreadsapi.h>
#include <psapi.h>
#include <setupapi.h>
#include <winioctl.h>
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 9d95cd11e1..e44e5bb6af 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -526,7 +526,7 @@ rte_eth_dev_allocate(const char *name)
strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
eth_dev->data->port_id = port_id;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ rte_thread_mutex_init(ð_dev->data->flow_ops_mutex);
unlock:
rte_spinlock_unlock(ð_dev_shared_data->ownership_lock);
@@ -600,7 +600,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data->hash_mac_addrs);
rte_free(eth_dev->data->dev_private);
- pthread_mutex_destroy(ð_dev->data->flow_ops_mutex);
+ rte_thread_mutex_destroy(ð_dev->data->flow_ops_mutex);
memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
}
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index edf96de2dc..8c8f83f9e3 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -5,7 +5,7 @@
#ifndef _RTE_ETHDEV_CORE_H_
#define _RTE_ETHDEV_CORE_H_
-#include <pthread.h>
+#include <rte_thread.h>
/**
* @file
@@ -186,7 +186,7 @@ struct rte_eth_dev_data {
* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
*/
- pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
+ rte_thread_mutex flow_ops_mutex; /**< rte_flow ops mutex. */
uint64_t reserved_64s[4]; /**< Reserved for future fields */
void *reserved_ptrs[4]; /**< Reserved for future fields */
} __rte_cache_aligned;
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..4f112d1af7 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -226,14 +226,14 @@ static inline void
fts_enter(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_lock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_lock(&dev->data->flow_ops_mutex);
}
static inline void
fts_exit(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_unlock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_unlock(&dev->data->flow_ops_mutex);
}
static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 13dfb28401..47f10cf5a9 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -7,6 +7,7 @@
#endif
#include <unistd.h>
+#include <pthread.h>
#include <rte_cycles.h>
#include <rte_common.h>
#include <rte_dev.h>
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 355ff37651..a788fb0ed8 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -12,6 +12,7 @@
#include <numaif.h>
#endif
+#include <pthread.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_log.h>
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 5/6] eal: set affinity and priority attributes
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (3 preceding siblings ...)
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
If the user doesn't specify the priority through the command
line arguments, initialize the thread priority to 'normal'.
Set thread priority for eal threads.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 11 ++++++++
lib/eal/common/eal_thread.h | 6 ++++
lib/eal/freebsd/eal.c | 41 +++++++++++++++++++++++-----
lib/eal/linux/eal.c | 39 +++++++++++++++++++++-----
lib/eal/windows/eal.c | 44 ++++++++++++++++++++++++++++--
5 files changed, 125 insertions(+), 16 deletions(-)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 62d28e7b28..fa537db7ac 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -388,3 +388,14 @@ rte_thread_unregister(void)
RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n",
lcore_id);
}
+
+void rte_thread_priority_init(void)
+{
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+
+ /* If the user doesn't specify the priority through the command
+ * line arguments, the default 'normal' value will be used.
+ */
+ internal_conf->thread_priority = RTE_THREAD_PRIORITY_NORMAL;
+}
diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h
index 4a49117be8..7b3b884463 100644
--- a/lib/eal/common/eal_thread.h
+++ b/lib/eal/common/eal_thread.h
@@ -58,4 +58,10 @@ eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size);
int
eal_thread_dump_current_affinity(char *str, unsigned int size);
+/**
+ * Set the initial thread priority in the internal configuration
+ * to the default value of RTE_THREAD_PRIORITY_NORMAL.
+ */
+void rte_thread_priority_init(void);
+
#endif /* EAL_THREAD_H */
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index c92fdaa598..1570da2a36 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -678,6 +678,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -856,6 +858,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -871,6 +881,22 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -884,9 +910,15 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
+ if (ret != 0)
+ rte_panic("Cannot set affinity\n");
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -894,11 +926,6 @@ rte_eal_init(int argc, char **argv)
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
rte_thread_name_set(lcore_config[i].thread_id, thread_name);
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index cd5e9953d0..c02390ed58 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -977,6 +977,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -1221,6 +1223,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -1235,6 +1245,23 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot initialize thread attributes,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set thread priority attribute,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -1248,9 +1275,12 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1262,11 +1292,6 @@ rte_eal_init(int argc, char **argv)
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index d90c635ddc..4eca6a3ab6 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -278,6 +278,8 @@ rte_eal_init(int argc, char **argv)
eal_get_internal_configuration();
int ret;
+ rte_thread_priority_init();
+
eal_log_init(NULL, 0);
eal_log_level_parse(argc, argv);
@@ -379,6 +381,36 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
+ &lcore_config[config->main_lcore].cpuset) != 0) {
+ rte_eal_init_alert("Cannot set affinity");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -394,9 +426,17 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread affinity attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
}
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (4 preceding siblings ...)
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
@ 2021-08-18 13:44 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
5 siblings, 1 reply; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 13:44 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The user is offered the option of either using the RTE_THREAD_* API or
a 3rd party thread library, through a meson flag called
"use_external_thread_lib". By default, this flag is set to FALSE,
which means Windows libraries and applications will use the RTE_THREAD_*
API for managing threads.
If compiling on Windows and the "use_external_thread_lib" is *not* set,
the following files will be parsed:
* include/rte_thread.h
* windows/rte_thread.c
In all other cases, the compilation/parsing includes the following files:
* include/rte_thread.h
* common/rte_thread.c
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
config/meson.build | 1 -
lib/eal/windows/include/pthread.h | 192 ------------------------------
lib/eal/windows/meson.build | 7 +-
meson_options.txt | 2 +
4 files changed, 8 insertions(+), 194 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
diff --git a/config/meson.build b/config/meson.build
index e80421003b..912d51582c 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -301,7 +301,6 @@ else # for 32-bit we need smaller reserved memory areas
dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
endif
-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h
deleted file mode 100644
index 27fd2cca52..0000000000
--- a/lib/eal/windows/include/pthread.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019 Intel Corporation
- */
-
-#ifndef _PTHREAD_H_
-#define _PTHREAD_H_
-
-#include <stdint.h>
-#include <sched.h>
-
-/**
- * This file is required to support the common code in eal_common_proc.c,
- * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc
- * does not contain pthread.h. This may be removed in future releases.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_common.h>
-#include <rte_windows.h>
-
-#define PTHREAD_BARRIER_SERIAL_THREAD TRUE
-
-/* defining pthread_t type on Windows since there is no in Microsoft libc*/
-typedef uintptr_t pthread_t;
-
-/* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/
-typedef void *pthread_attr_t;
-
-typedef void *pthread_mutexattr_t;
-
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
-
-#define pthread_barrier_init(barrier, attr, count) \
- !InitializeSynchronizationBarrier(barrier, count, -1)
-#define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
- SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
-#define pthread_barrier_destroy(barrier) \
- !DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
-
-/* pthread function overrides */
-#define pthread_self() \
- ((pthread_t)GetCurrentThreadId())
-
-
-static inline int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- return t1 == t2;
-}
-
-static inline int
-pthread_setaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- DWORD_PTR ret = 0;
- HANDLE thread_handle;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- ret = SetThreadAffinityMask(thread_handle, *cpuset->_bits);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("CloseHandle()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_getaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- /* Workaround for the lack of a GetThreadAffinityMask()
- *API in Windows
- */
- DWORD_PTR prev_affinity_mask;
- HANDLE thread_handle;
- DWORD_PTR ret = 0;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- /* obtain previous mask by setting dummy mask */
- prev_affinity_mask = SetThreadAffinityMask(thread_handle, 0x1);
- if (prev_affinity_mask == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- /* set it back! */
- ret = SetThreadAffinityMask(thread_handle, prev_affinity_mask);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- memset(cpuset, 0, cpuset_size);
- *cpuset->_bits = prev_affinity_mask;
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_create(void *threadid, const void *threadattr, void *threadfunc,
- void *args)
-{
- RTE_SET_USED(threadattr);
- HANDLE hThread;
- hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
- args, 0, (LPDWORD)threadid);
- if (hThread) {
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
- }
- return ((hThread != NULL) ? 0 : E_FAIL);
-}
-
-static inline int
-pthread_detach(__rte_unused pthread_t thread)
-{
- return 0;
-}
-
-static inline int
-pthread_join(__rte_unused pthread_t thread,
- __rte_unused void **value_ptr)
-{
- return 0;
-}
-
-static inline int
-pthread_mutex_init(pthread_mutex_t *mutex,
- __rte_unused pthread_mutexattr_t *attr)
-{
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PTHREAD_H_ */
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index fc12fefd0d..22c00c3dc8 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -20,7 +20,12 @@ sources += files(
'eal_timer.c',
'fnmatch.c',
'getopt.c',
- 'rte_thread.c',
)
+if get_option('use_external_thread_lib')
+ sources += 'eal/common/rte_thread.c'
+else
+ sources += 'eal/windows/rte_thread.c'
+endif
+
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
diff --git a/meson_options.txt b/meson_options.txt
index 0e92734c49..71f38bf16b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -46,3 +46,5 @@ option('tests', type: 'boolean', value: true, description:
'build unit tests')
option('use_hpet', type: 'boolean', value: false, description:
'use HPET timer in EAL')
+option('use_external_thread_lib', type: 'boolean', value: false,
+ description: 'use an external thread library')
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-08-18 19:42 ` Tal Shnaiderman
0 siblings, 0 replies; 30+ messages in thread
From: Tal Shnaiderman @ 2021-08-18 19:42 UTC (permalink / raw)
To: Narcisa Ana Maria Vasile, dev, NBU-Contact-Thomas Monjalon,
dmitry.kozliuk, Khoa To, navasile, dmitrym, roretzla, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
> Subject: [PATCH v3 1/6] eal: add function that sets thread name
>
> External email: Use caution opening links or attachments
>
>
> From: Narcisa Vasile <navasile@microsoft.com>
>
> Implement function that sets the name of a thread.
> On Windows, SetThreadDescription() is used. Use GetProcAddress() to obtain
> the address of the function for MinGW compatibility.
>
> Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
> ---
> lib/eal/common/rte_thread.c | 17 +++++++++ lib/eal/include/rte_thread.h |
> 16 +++++++++
> lib/eal/version.map | 1 +
> lib/eal/windows/rte_thread.c | 68
> ++++++++++++++++++++++++++++++++++++
> 4 files changed, 102 insertions(+)
<snip>
> +RTE_INIT(rte_thread_description_ptr_init)
> +{
> + HMODULE kernel_lib = NULL;
> + static const char library_name[] = "kernel32.dll";
> + static const char function[] = "SetThreadDescription";
> +
> + kernel_lib = LoadLibraryA(library_name);
> + if (kernel_lib == NULL) {
> + (void)thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
> + return;
> + }
> +
> + SetThreadDescription_ptr = (SetThreadDescription_type)(
> + (void *)GetProcAddress(kernel_lib, function));
> + if (SetThreadDescription_ptr == NULL) {
> + (void)thread_log_last_error("GetProcAddress(\"kernel32.dll\",
> \"SetThreadDescription\")");
> + return;
You need to remove the return above to also free kernel32.dll in error flow.
> + }
> +
> + FreeLibrary(kernel_lib);
> +}
> +
> +int
> +rte_thread_name_set(rte_thread_t thread_id, const char *name) {
> + int ret = 0;
> + size_t count;
> + HRESULT hr;
> + HANDLE thread_handle = NULL;
> + WCHAR w_name[16];
> +
> + thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION,
> FALSE,
> + thread_id.opaque_id);
> + if (thread_handle == NULL) {
> + ret = thread_log_last_error("OpenThread()");
> + goto cleanup;
> + }
> +
> + count = mbstowcs(w_name, name, RTE_DIM(w_name));
> + if (count == (size_t) (-1)) {
> + RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
> + ret = EINVAL;
> + goto cleanup;
> + }
> +
> + if (SetThreadDescription_ptr == NULL) {
> + RTE_LOG(DEBUG, EAL, "Invalid function pointer to
> SetThreadDescription()!\n");
> + ret = EINVAL;
> + goto cleanup;
> + }
> +
> + hr = SetThreadDescription_ptr(thread_handle, w_name);
> + if (FAILED(hr)) {
> + ret = thread_log_last_error("SetThreadDescription()");
> + goto cleanup;
> + }
> +
> +cleanup:
> + if (thread_handle != NULL)
> + CloseHandle(thread_handle);
> + return ret;
> +}
> +
> int
> rte_thread_key_create(rte_thread_key *key,
> __rte_unused void (*destructor)(void *))
> --
> 2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
` (5 more replies)
0 siblings, 6 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
This patchset enables the new EAL thread API.
The newly defined thread attributes, priority and affinity,
are used in eal/windows when creating the threads. Similarly,
some changes have been done in eal/linux/eal.c and eal/freebsd/eal.c
to initialize priority to a default value and set thread attributes.
The user is offered the option of either using the rte_thread_* API or
a 3rd party thread library, through a meson flag
called "use_external_thread_lib".
By default, this flag is set to FALSE, which means Windows libraries
and applications will use the EAL rte_thread_* API
defined in windows/rte_thread.c for managing threads.
When the flag is set to TRUE, the common/rte_thread.c file is compiled
and an external thread library is used.
This patchset adds a new function for creating control threads that
uses the new thread API.
It enables the usage of the new function in Windows code and common code.
The old function is kept to avoid ABI break, however, its definition
is commented away on Windows, since the pthread_t and pthread_attr_t
arguments that it receives have been replaced with the new API on Windows.
This allows testing the "eal: Add EAL API for threading" that this
patchset depends on.
The ethdev lib also contains some changes that break the ABI.
Enabling the new EAL thread API will probably require going through
the proper process of ABI changes.
Depends-on: series-18172 ("eal: Add EAL API for threading")
v4:
- Free resources on error path
- Use RTE_FINI to unload kernel32.dll
v3:
- use RTE_INIT to only load kernel32.dll once and get function
pointer to SetThreadDescription()
- minor fixes
v2:
- fix typo in SetThreadDescription_type function pointer
- add Depends-on on all patches to fix apply errors.
- modify cover letter
Narcisa Vasile (6):
eal: add function that sets thread name
eal: add function for control thread creation
Enable the new EAL thread API in app, drivers and examples
lib: enable the new EAL thread API
eal: set affinity and priority attributes
Allow choice between internal EAL thread API and external lib
app/test/process.h | 8 +-
app/test/test_lcores.c | 18 +-
app/test/test_link_bonding.c | 14 +-
app/test/test_lpm_perf.c | 12 +-
config/meson.build | 1 -
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 +-
drivers/bus/dpaa/base/qbman/process.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 14 +-
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 +-
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 14 +-
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 +-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +-
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 +--
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.c | 8 +-
drivers/net/axgbe/axgbe_ethdev.h | 8 +-
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +-
drivers/net/axgbe/axgbe_phy_impl.c | 6 +-
drivers/net/bnxt/bnxt.h | 16 +-
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 ++---
drivers/net/bnxt/bnxt_irq.c | 8 +-
drivers/net/bnxt/bnxt_reps.c | 10 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +--
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 8 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 4 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +-
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +-
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +-
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +-
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 +-
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +-
drivers/net/vhost/rte_eth_vhost.c | 24 +--
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +--
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 +++--
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 +--
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++---
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
lib/eal/common/eal_common_options.c | 6 +-
lib/eal/common/eal_common_thread.c | 105 +++++++++-
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/eal_thread.h | 6 +
lib/eal/common/malloc_mp.c | 2 +
lib/eal/common/rte_thread.c | 17 ++
lib/eal/freebsd/eal.c | 53 +++--
lib/eal/freebsd/eal_alarm.c | 12 +-
lib/eal/freebsd/eal_interrupts.c | 6 +-
lib/eal/freebsd/eal_thread.c | 10 +-
lib/eal/include/rte_lcore.h | 6 +
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/include/rte_thread.h | 43 ++++
lib/eal/linux/eal.c | 55 +++--
lib/eal/linux/eal_alarm.c | 10 +-
lib/eal/linux/eal_interrupts.c | 8 +-
lib/eal/linux/eal_thread.c | 11 +-
lib/eal/linux/eal_timer.c | 6 +-
lib/eal/version.map | 6 +-
lib/eal/windows/eal.c | 44 +++-
lib/eal/windows/eal_interrupts.c | 8 +-
lib/eal/windows/eal_thread.c | 35 +---
lib/eal/windows/eal_windows.h | 10 -
lib/eal/windows/include/pthread.h | 192 ------------------
lib/eal/windows/include/rte_windows.h | 1 +
lib/eal/windows/meson.build | 7 +-
lib/eal/windows/rte_thread.c | 76 +++++++
lib/ethdev/rte_ethdev.c | 4 +-
lib/ethdev/rte_ethdev_core.h | 4 +-
lib/ethdev/rte_flow.c | 4 +-
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
meson_options.txt | 2 +
97 files changed, 785 insertions(+), 661 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
` (4 subsequent siblings)
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Implement function that sets the name of a thread.
On Windows, SetThreadDescription() is used. Use GetProcAddress()
to obtain the address of the function for MinGW compatibility.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/rte_thread.c | 17 ++++++++
lib/eal/include/rte_thread.h | 16 ++++++++
lib/eal/version.map | 1 +
lib/eal/windows/rte_thread.c | 76 ++++++++++++++++++++++++++++++++++++
4 files changed, 110 insertions(+)
diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c
index 3fdb267337..c91ed3d433 100644
--- a/lib/eal/common/rte_thread.c
+++ b/lib/eal/common/rte_thread.c
@@ -373,6 +373,23 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return ret;
}
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+ char truncated[16];
+
+ memcpy(truncated, name, sizeof(truncated));
+ ret = pthread_setname_np((pthread_t)thread_id.opaque_id, truncated);
+#endif
+#endif
+ RTE_SET_USED(thread_id);
+ RTE_SET_USED(name);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *))
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 40da83467b..2f6258e336 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -439,6 +439,22 @@ int rte_thread_barrier_wait(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
+/**
+ * Set the name of the thread represented by 'thread_id'.
+ *
+ * @param thread_id
+ * The id of the thread.
+ *
+ * @param name
+ * Thread name to set.
+ *
+ * @return
+ * On success, return 0.
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 541dc13053..7ce8dcea07 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -446,6 +446,7 @@ EXPERIMENTAL {
rte_thread_barrier_init;
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
+ rte_thread_name_set;
};
INTERNAL {
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index b2ff16f51f..f30c5f0f57 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -556,6 +556,82 @@ rte_thread_barrier_destroy(rte_thread_barrier *barrier)
return 0;
}
+typedef HRESULT
+(*SetThreadDescription_type)(HANDLE thread_handle, PCWSTR thread_description);
+
+static SetThreadDescription_type SetThreadDescription_ptr;
+HMODULE kernel32_handle;
+
+RTE_INIT(rte_thread_description_ptr_init)
+{
+ static const char library_name[] = "kernel32.dll";
+ static const char function[] = "SetThreadDescription";
+
+ kernel32_handle = LoadLibraryA(library_name);
+ if (kernel32_handle == NULL) {
+ (void)thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
+ return;
+ }
+
+ SetThreadDescription_ptr = (SetThreadDescription_type)(
+ (void *)GetProcAddress(kernel32_handle, function));
+ if (SetThreadDescription_ptr == NULL) {
+ (void)thread_log_last_error("GetProcAddress(\"kernel32.dll\", \"SetThreadDescription\")");
+ FreeLibrary(kernel32_handle);
+ kernel32_handle = NULL;
+ return;
+ }
+}
+
+RTE_FINI(rte_thread_description_ptr_free)
+{
+ if (kernel32_handle != NULL)
+ FreeLibrary(kernel32_handle);
+ kernel32_handle = NULL;
+ SetThreadDescription_ptr = NULL;
+}
+
+int
+rte_thread_name_set(rte_thread_t thread_id, const char *name)
+{
+ int ret = 0;
+ size_t count;
+ HRESULT hr;
+ HANDLE thread_handle = NULL;
+ WCHAR w_name[16];
+
+ thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE,
+ thread_id.opaque_id);
+ if (thread_handle == NULL) {
+ ret = thread_log_last_error("OpenThread()");
+ goto cleanup;
+ }
+
+ count = mbstowcs(w_name, name, RTE_DIM(w_name));
+ if (count == (size_t) (-1)) {
+ RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ if (SetThreadDescription_ptr == NULL) {
+ RTE_LOG(DEBUG, EAL, "Invalid function pointer to SetThreadDescription()!\n");
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ hr = SetThreadDescription_ptr(thread_handle, w_name);
+ if (FAILED(hr)) {
+ ret = thread_log_last_error("SetThreadDescription()");
+ goto cleanup;
+ }
+
+cleanup:
+ if (thread_handle != NULL)
+ CloseHandle(thread_handle);
+ return ret;
+}
+
int
rte_thread_key_create(rte_thread_key *key,
__rte_unused void (*destructor)(void *))
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 2/6] eal: add function for control thread creation
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
` (3 subsequent siblings)
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The existing rte_ctrl_thread_create() function will be replaced
with rte_thread_ctrl_thread_create() that uses the internal
EAL thread API.
This patch only introduces the new control thread creation
function. Replacing of the old function needs to be done according
to the ABI change procedures, to avoid an ABI break.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 81 ++++++++++++++++++++++++++++++
lib/eal/include/rte_thread.h | 27 ++++++++++
lib/eal/version.map | 1 +
3 files changed, 109 insertions(+)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 1a52f42a2b..79545c67d9 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -259,6 +259,87 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+struct rte_thread_ctrl_ctx {
+ rte_thread_func start_routine;
+ void *arg;
+ const char *name;
+};
+
+static void *ctrl_thread_wrapper(void *arg)
+{
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = arg;
+ rte_thread_func start_routine = ctx->start_routine;
+ void *routine_arg = ctx->arg;
+
+ __rte_thread_init(rte_lcore_id(), cpuset);
+
+ if (ctx->name != NULL) {
+ if (rte_thread_name_set(rte_thread_self(), ctx->name) < 0)
+ RTE_LOG(DEBUG, EAL, "Cannot set name for ctrl thread\n");
+ }
+
+ free(arg);
+
+ return start_routine(routine_arg);
+}
+
+int
+rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg)
+{
+ int ret;
+ rte_thread_attr_t attr;
+ struct internal_config *conf = eal_get_internal_configuration();
+ rte_cpuset_t *cpuset = &conf->ctrl_cpuset;
+ struct rte_thread_ctrl_ctx *ctx = NULL;
+
+ if (start_routine == NULL) {
+ ret = EINVAL;
+ goto cleanup;
+ }
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL) {
+ ret = ENOMEM;
+ goto cleanup;
+ }
+
+ ctx->start_routine = start_routine;
+ ctx->arg = arg;
+ ctx->name = name;
+
+ ret = rte_thread_attr_init(&attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot init ctrl thread attributes\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_attr_set_affinity(&attr, cpuset);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set afifnity attribute for ctrl thread\n");
+ goto cleanup;
+ }
+ ret = rte_thread_attr_set_priority(&attr, RTE_THREAD_PRIORITY_NORMAL);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set priority attribute for ctrl thread\n");
+ goto cleanup;
+ }
+
+ ret = rte_thread_create(thread, &attr, ctrl_thread_wrapper, ctx);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot create ctrl thread\n");
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ free(ctx);
+ return ret;
+}
+
int
rte_thread_register(void)
{
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 2f6258e336..e34101cc98 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -455,6 +455,33 @@ int rte_thread_barrier_destroy(rte_thread_barrier *barrier);
__rte_experimental
int rte_thread_name_set(rte_thread_t thread_id, const char *name);
+/**
+ * Create a control thread.
+ *
+ * Set affinity and thread name. The affinity of the new thread is based
+ * on the CPU affinity retrieved at the time rte_eal_init() was called,
+ * the dataplane and service lcores are then excluded.
+ *
+ * @param thread
+ * Filled with the thread id of the new created thread.
+ *
+ * @param name
+ * The name of the control thread (max 16 characters including '\0').
+ *
+ * @param start_routine
+ * Function to be executed by the new thread.
+ *
+ * @param arg
+ * Argument passed to start_routine.
+ *
+ * @return
+ * On success, return 0;
+ * On failure, return a positive errno-style error number.
+ */
+__rte_experimental
+int rte_thread_ctrl_thread_create(rte_thread_t *thread, const char *name,
+ rte_thread_func start_routine, void *arg);
+
/**
* Create a TLS data key visible to all threads in the process.
* the created key is later used to get/set a value.
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 7ce8dcea07..67569b1bf9 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -447,6 +447,7 @@ EXPERIMENTAL {
rte_thread_barrier_wait;
rte_thread_barrier_destroy;
rte_thread_name_set;
+ rte_thread_ctrl_thread_create;
};
INTERNAL {
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 3/6] Enable the new EAL thread API in app, drivers and examples
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
` (2 subsequent siblings)
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
app/test/process.h | 8 +--
app/test/test_lcores.c | 18 +++----
app/test/test_link_bonding.c | 14 ++---
app/test/test_lpm_perf.c | 12 ++---
drivers/bus/dpaa/base/qbman/bman_driver.c | 5 +-
drivers/bus/dpaa/base/qbman/dpaa_sys.c | 14 ++---
drivers/bus/dpaa/base/qbman/process.c | 6 +--
drivers/bus/dpaa/dpaa_bus.c | 14 ++---
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 19 ++++---
drivers/common/dpaax/compat.h | 2 +-
drivers/common/mlx5/windows/mlx5_common_os.h | 1 +
drivers/compress/mlx5/mlx5_compress.c | 14 ++---
drivers/event/dlb2/dlb2.c | 2 +-
drivers/event/dlb2/pf/base/dlb2_osdep.h | 7 ++-
drivers/mempool/dpaa/dpaa_mempool.c | 2 +-
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 +++----
drivers/net/ark/ark_ethdev.c | 4 +-
drivers/net/ark/ark_pktgen.c | 4 +-
drivers/net/atlantic/atl_ethdev.c | 4 +-
drivers/net/atlantic/atl_types.h | 4 +-
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 26 ++++-----
drivers/net/axgbe/axgbe_common.h | 2 +-
drivers/net/axgbe/axgbe_dev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.c | 8 +--
drivers/net/axgbe/axgbe_ethdev.h | 8 +--
drivers/net/axgbe/axgbe_i2c.c | 4 +-
drivers/net/axgbe/axgbe_mdio.c | 8 +--
drivers/net/axgbe/axgbe_phy_impl.c | 6 +--
drivers/net/bnxt/bnxt.h | 16 +++---
drivers/net/bnxt/bnxt_cpr.c | 4 +-
drivers/net/bnxt/bnxt_ethdev.c | 54 +++++++++----------
drivers/net/bnxt/bnxt_irq.c | 8 +--
drivers/net/bnxt/bnxt_reps.c | 10 ++--
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 34 ++++++------
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 +-
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 28 +++++-----
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 8 +--
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 4 +-
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h | 2 +-
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
drivers/net/dpaa/dpaa_rxtx.c | 2 +-
drivers/net/ena/base/ena_plat_dpdk.h | 15 +++---
drivers/net/enic/enic.h | 2 +-
drivers/net/ice/ice_dcf_parent.c | 8 +--
drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
drivers/net/mlx5/mlx5.c | 20 +++----
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_txpp.c | 8 +--
drivers/net/mlx5/windows/mlx5_flow_os.c | 10 ++--
drivers/net/mlx5/windows/mlx5_os.c | 2 +-
drivers/net/qede/base/bcm_osal.h | 8 +--
drivers/net/vhost/rte_eth_vhost.c | 24 ++++-----
.../net/virtio/virtio_user/virtio_user_dev.c | 30 +++++------
.../net/virtio/virtio_user/virtio_user_dev.h | 2 +-
drivers/vdpa/ifc/ifcvf_vdpa.c | 49 ++++++++---------
drivers/vdpa/mlx5/mlx5_vdpa.c | 24 ++++-----
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 +-
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 51 ++++++++----------
examples/kni/main.c | 1 +
.../pthread_shim/pthread_shim.h | 1 +
62 files changed, 342 insertions(+), 347 deletions(-)
diff --git a/app/test/process.h b/app/test/process.h
index 5b10cf64df..3ad861cb9a 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -26,7 +26,7 @@
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
-#include <pthread.h>
+#include <rte_thread.h>
extern void *send_pkts(void *empty);
extern uint16_t flag_for_send_pkts;
#endif
@@ -47,7 +47,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
char path[32];
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
- pthread_t thread;
+ rte_thread_t thread;
int rc;
#endif
#endif
@@ -134,7 +134,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_LIB_PDUMP
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
- rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+ rc = rte_thread_create(&thread, NULL, &send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
strerror(rc));
@@ -149,7 +149,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
#ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
- pthread_join(thread, NULL);
+ rte_thread_join(thread, NULL);
}
#endif
#endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 19a7ab9fce..accdd858a6 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,7 @@
* Copyright (c) 2020 Red Hat, Inc.
*/
-#include <pthread.h>
+#include <rte_thread.h>
#include <string.h>
#include <rte_common.h>
@@ -14,7 +14,7 @@
struct thread_context {
enum { INIT, ERROR, DONE } state;
bool lcore_id_any;
- pthread_t id;
+ rte_thread_t id;
unsigned int *registered_count;
};
@@ -77,7 +77,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
break;
non_eal_threads_count++;
}
@@ -96,7 +96,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) == 0) {
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
non_eal_threads_count++;
printf("non-EAL threads count: %u\n", non_eal_threads_count);
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -110,7 +110,7 @@ test_non_eal_lcores(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -262,7 +262,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -285,7 +285,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
t->state = INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -309,7 +309,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != DONE)
ret = -1;
}
@@ -330,7 +330,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
__atomic_store_n(®istered_count, 0, __ATOMIC_RELEASE);
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
}
error:
if (handle[1] != NULL)
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c8310a8..a22189a656 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -3,6 +3,7 @@
*/
#include "unistd.h"
+#include <pthread.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
@@ -203,7 +204,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
static int slaves_initialized;
static int mac_slaves_initialized;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(mutex)
static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
@@ -1191,11 +1192,11 @@ test_bonding_lsc_event_callback(uint16_t port_id __rte_unused,
void *param __rte_unused,
void *ret_param __rte_unused)
{
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
test_lsc_interrupt_count++;
pthread_cond_signal(&cvar);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
return 0;
}
@@ -1220,11 +1221,12 @@ lsc_timeout(int wait_us)
ts.tv_sec += 1;
}
- pthread_mutex_lock(&mutex);
+ rte_thread_mutex_lock(&mutex);
if (test_lsc_interrupt_count < 1)
- retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+ retval = pthread_cond_timedwait(&cvar,
+ (pthread_mutex_t *)mutex.mutex_id, &ts);
- pthread_mutex_unlock(&mutex);
+ rte_thread_mutex_unlock(&mutex);
if (retval == 0 && test_lsc_interrupt_count < 1)
return -1;
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 2bed00d064..e4cfcdb504 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -25,7 +25,7 @@ static volatile uint32_t thr_id;
static uint64_t gwrite_cycles;
static uint32_t num_writers;
/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(lpm_mutex)
/* Report quiescent state interval every 1024 lookups. Larger critical
* sections in reader will result in writer polling multiple times.
@@ -443,7 +443,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
/* Add all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth,
next_hop_add) != 0) {
@@ -452,13 +452,13 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
/* Delete all the entries */
for (j = si; j < ei; j++) {
if (num_writers > 1)
- pthread_mutex_lock(&lpm_mutex);
+ rte_thread_mutex_lock(&lpm_mutex);
if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
large_ldepth_route_table[j].depth) != 0) {
printf("Failed to delete iteration %d, route# %d\n",
@@ -466,7 +466,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
goto error;
}
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
}
}
@@ -478,7 +478,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
error:
if (num_writers > 1)
- pthread_mutex_unlock(&lpm_mutex);
+ rte_thread_mutex_unlock(&lpm_mutex);
return -1;
}
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index ee35e03da1..25be077c6f 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -38,11 +38,10 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
struct dpaa_ioctl_irq_map irq_map;
/* Verify the thread's cpu-affinity */
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_set_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
errno = ret;
- err(0, "pthread_getaffinity_np()");
+ err(0, "rte_thread_set_affinity_by_id()");
return ret;
}
pcfg.cpu = -1;
diff --git a/drivers/bus/dpaa/base/qbman/dpaa_sys.c b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
index 9d6bfd40a2..14aeb5e07d 100644
--- a/drivers/bus/dpaa/base/qbman/dpaa_sys.c
+++ b/drivers/bus/dpaa/base/qbman/dpaa_sys.c
@@ -18,16 +18,16 @@ struct process_interrupt {
};
static COMPAT_LIST_HEAD(process_irq_list);
-static pthread_mutex_t process_irq_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(process_irq_lock)
static void process_interrupt_install(struct process_interrupt *irq)
{
int ret;
/* Add the irq to the end of the list */
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_add_tail(&irq->node, &process_irq_list);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -35,10 +35,10 @@ static void process_interrupt_remove(struct process_interrupt *irq)
{
int ret;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_del(&irq->node);
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
}
@@ -47,14 +47,14 @@ static struct process_interrupt *process_interrupt_find(int irq_num)
int ret;
struct process_interrupt *i = NULL;
- ret = pthread_mutex_lock(&process_irq_lock);
+ ret = rte_thread_mutex_lock(&process_irq_lock);
assert(!ret);
list_for_each_entry(i, &process_irq_list, node) {
if (i->irq == irq_num)
goto done;
}
done:
- ret = pthread_mutex_unlock(&process_irq_lock);
+ ret = rte_thread_mutex_unlock(&process_irq_lock);
assert(!ret);
return i;
}
diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 9bc92681cd..da157b8426 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -21,7 +21,7 @@
* what the lock is for.
*/
static int fd = -1;
-static pthread_mutex_t fd_init_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(fd_init_lock)
static int check_fd(void)
{
@@ -29,12 +29,12 @@ static int check_fd(void)
if (fd >= 0)
return 0;
- ret = pthread_mutex_lock(&fd_init_lock);
+ ret = rte_thread_mutex_lock(&fd_init_lock);
assert(!ret);
/* check again with the lock held */
if (fd < 0)
fd = open(PROCESS_PATH, O_RDWR);
- ret = pthread_mutex_unlock(&fd_init_lock);
+ ret = rte_thread_mutex_unlock(&fd_init_lock);
assert(!ret);
return (fd >= 0) ? 0 : -ENODEV;
}
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index e499305d85..84deb8f6de 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -10,7 +10,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/eventfd.h>
@@ -47,7 +47,7 @@ static struct rte_dpaa_bus rte_dpaa_bus;
struct netcfg_info *dpaa_netcfg;
/* define a variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa_portal_key;
+static rte_thread_key dpaa_portal_key;
unsigned int dpaa_svr_family;
@@ -315,10 +315,10 @@ int rte_dpaa_portal_init(void *arg)
DPAA_PER_LCORE_PORTAL->bman_idx = bman_get_portal_index();
DPAA_PER_LCORE_PORTAL->tid = rte_gettid();
- ret = pthread_setspecific(dpaa_portal_key,
+ ret = rte_thread_value_set(dpaa_portal_key,
(void *)DPAA_PER_LCORE_PORTAL);
if (ret) {
- DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u"
+ DPAA_BUS_LOG(ERR, "rte_thread_value_set failed on core %u"
" (lcore=%u) with ret: %d", cpu, lcore, ret);
dpaa_portal_finish(NULL);
@@ -376,7 +376,7 @@ dpaa_portal_finish(void *arg)
bman_thread_finish();
qman_thread_finish();
- pthread_setspecific(dpaa_portal_key, NULL);
+ rte_thread_value_set(dpaa_portal_key, NULL);
rte_free(dpaa_io_portal);
dpaa_io_portal = NULL;
@@ -452,9 +452,9 @@ rte_dpaa_bus_scan(void)
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa_portal_key, dpaa_portal_finish);
+ ret = rte_thread_key_create(&dpaa_portal_key, dpaa_portal_finish);
if (ret) {
- DPAA_BUS_LOG(DEBUG, "Unable to create pthread key. (%d)", ret);
+ DPAA_BUS_LOG(DEBUG, "Unable to create thread key. (%d)", ret);
dpaa_clean_device_list();
return ret;
}
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 1a1e437ed1..b6dc40290a 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
@@ -59,7 +59,7 @@ uint8_t dpaa2_dqrr_size;
uint8_t dpaa2_eqcr_size;
/* Variable to hold the portal_key, once created.*/
-static pthread_key_t dpaa2_portal_key;
+static rte_thread_key dpaa2_portal_key;
/*Stashing Macros default for LS208x*/
static int dpaa2_core_cluster_base = 0x04;
@@ -92,10 +92,9 @@ dpaa2_get_core_id(void)
rte_cpuset_t cpuset;
int i, ret, cpu_id = -1;
- ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
- &cpuset);
+ ret = rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset);
if (ret) {
- DPAA2_BUS_ERR("pthread_getaffinity_np() failed");
+ DPAA2_BUS_ERR("rte_thread_get_affinity_by_id() failed");
return ret;
}
@@ -295,9 +294,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
}
}
- ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
+ ret = rte_thread_value_set(dpaa2_portal_key, (void *)dpio_dev);
if (ret) {
- DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
+ DPAA2_BUS_ERR("rte_thread_value_set failed with ret: %d", ret);
dpaa2_put_qbman_swp(dpio_dev);
return NULL;
}
@@ -356,7 +355,7 @@ static void dpaa2_portal_finish(void *arg)
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
- pthread_setspecific(dpaa2_portal_key, NULL);
+ rte_thread_value_set(dpaa2_portal_key, NULL);
}
static int
@@ -514,10 +513,10 @@ dpaa2_create_dpio_device(int vdev_fd,
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
*/
- ret = pthread_key_create(&dpaa2_portal_key,
+ ret = rte_thread_key_create(&dpaa2_portal_key,
dpaa2_portal_finish);
if (ret) {
- DPAA2_BUS_DEBUG("Unable to create pthread key (%d)",
+ DPAA2_BUS_DEBUG("Unable to create thread key (%d)",
ret);
goto err;
}
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb..8d53ee4dfc 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <linux/types.h>
#include <stdbool.h>
#include <ctype.h>
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index 3756e1959b..295ef872c0 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <sys/types.h>
+#include <rte_windows.h>
#include <rte_errno.h>
#include "mlx5_autoconf.h"
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 883e720ec1..d6b422b4a2 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -70,7 +70,7 @@ struct mlx5_compress_qp {
TAILQ_HEAD(mlx5_compress_privs, mlx5_compress_priv) mlx5_compress_priv_list =
TAILQ_HEAD_INITIALIZER(mlx5_compress_priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
int mlx5_compress_logtype;
@@ -771,13 +771,13 @@ mlx5_compress_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
switch (event_type) {
case RTE_MEM_EVENT_FREE:
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
/* Iterate all the existing mlx5 devices. */
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
mlx5_free_mr_by_addr(&priv->mr_scache,
priv->ctx->device->name,
addr, len);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
break;
case RTE_MEM_EVENT_ALLOC:
default:
@@ -860,9 +860,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
mlx5_compress_mr_mem_event_cb,
NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
}
@@ -871,13 +871,13 @@ mlx5_compress_dev_remove(struct rte_device *dev)
{
struct mlx5_compress_priv *priv = NULL;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
if (priv->cdev->device == dev)
break;
if (priv)
TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (priv) {
if (TAILQ_EMPTY(&mlx5_compress_priv_list))
rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB",
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 252bbd8d5e..4f6d46744e 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -5,7 +5,7 @@
#include <assert.h>
#include <errno.h>
#include <nmmintrin.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h b/drivers/event/dlb2/pf/base/dlb2_osdep.h
index cffe22f3c5..82e0c71734 100644
--- a/drivers/event/dlb2/pf/base/dlb2_osdep.h
+++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h
@@ -8,7 +8,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
@@ -194,14 +194,13 @@ static void *dlb2_complete_queue_map_unmap(void *__args)
static inline void os_schedule_work(struct dlb2_hw *hw)
{
struct dlb2_dev *dlb2_dev;
- pthread_t complete_queue_map_unmap_thread;
+ rte_thread_t complete_queue_map_unmap_thread;
int ret;
dlb2_dev = container_of(hw, struct dlb2_dev, hw);
- ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+ ret = rte_thread_ctrl_thread_create(&complete_queue_map_unmap_thread,
"dlb_queue_unmap_waiter",
- NULL,
dlb2_complete_queue_map_unmap,
dlb2_dev);
if (ret)
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index f02056982c..34a1d2b28d 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 74ffa45112..444ba9f5be 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -179,7 +179,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
static inline int
@@ -677,7 +677,7 @@ find_internal_resource(struct pmd_internals *port_int)
if (port_int == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
struct pmd_internals *list_int =
@@ -688,7 +688,7 @@ find_internal_resource(struct pmd_internals *port_int)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -726,7 +726,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
if (mb_pool == NULL)
return ret;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internals = list->eth_dev->data->dev_private;
@@ -752,7 +752,7 @@ get_shared_umem(struct pkt_rx_queue *rxq, const char *ifname,
}
out:
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return ret;
}
@@ -781,9 +781,9 @@ eth_dev_configure(struct rte_eth_dev *dev)
return -1;
list->eth_dev = dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
}
return 0;
@@ -981,9 +981,9 @@ eth_dev_close(struct rte_eth_dev *dev)
/* Remove ethdev from list used to track and share UMEMs */
list = find_internal_resource(internals);
if (list) {
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 377299b14c..51856f66d1 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -563,12 +563,12 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
ark_pktchkr_run(ark->pc);
if (ark->start_pg && (dev->data->port_id == 0)) {
- pthread_t thread;
+ rte_thread_t thread;
/* Delay packet generatpr start allow the hardware to be ready
* This is only used for sanity checking with internal generator
*/
- if (rte_ctrl_thread_create(&thread, "ark-delay-pg", NULL,
+ if (rte_thread_ctrl_thread_create(&thread, "ark-delay-pg",
ark_pktgen_delay_start, ark->pg)) {
ARK_PMD_LOG(ERR, "Could not create pktgen "
"starter thread\n");
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 515bfe461c..58ff65b5d5 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -3,7 +3,7 @@
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -475,7 +475,7 @@ ark_pktgen_delay_start(void *arg)
* perform a blind sleep here to ensure that the external test
* application has time to setup the test before we generate packets
*/
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
usleep(100000);
ark_pktgen_run(inst);
return NULL;
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 0ce35eb519..2b86f01a25 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -405,7 +405,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
hw->aq_nic_cfg = &adapter->hw_cfg;
- pthread_mutex_init(&hw->mbox_mutex, NULL);
+ rte_thread_mutex_init(&hw->mbox_mutex);
/* disable interrupt */
atl_disable_intr(hw);
@@ -712,7 +712,7 @@ atl_dev_close(struct rte_eth_dev *dev)
rte_intr_callback_unregister(intr_handle,
atl_dev_interrupt_handler, dev);
- pthread_mutex_destroy(&hw->mbox_mutex);
+ rte_thread_mutex_destroy(&hw->mbox_mutex);
return ret;
}
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index e813d9f326..d99aa5fad0 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <netinet/in.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_common.h>
@@ -141,7 +141,7 @@ struct aq_hw_s {
u32 rpc_tid;
struct hw_aq_atl_utils_fw_rpc rpc;
- pthread_mutex_t mbox_mutex;
+ rte_thread_mutex mbox_mutex;
};
struct aq_fw_ops {
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 3a7faf405c..15b80584f8 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -6,7 +6,7 @@
*/
#include <rte_ether.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include "../atl_hw_regs.h"
#include "../atl_types.h"
@@ -218,7 +218,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
u32 mac_addr[2] = { 0 };
u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
if (efuse_addr != 0) {
err = hw_atl_utils_fw_downld_dwords(self,
@@ -257,7 +257,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -269,7 +269,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
u32 orig_stats_val = mpi_opts & BIT(CAPS_HI_STATISTICS);
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to update */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_STATISTICS);
@@ -286,7 +286,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
err = hw_atl_utils_update_stats(self);
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
@@ -299,7 +299,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
u32 temp_val = mpi_opts & BIT(CAPS_HI_TEMPERATURE);
u32 temp_res;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */
mpi_opts = mpi_opts ^ BIT(CAPS_HI_TEMPERATURE);
@@ -317,7 +317,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
sizeof(temp_res) / sizeof(u32));
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
if (err)
return err;
@@ -536,7 +536,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
if ((self->caps_lo & BIT(CAPS_LO_SMBUS_READ)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
request.msg_id = 0;
request.device_id = dev_addr;
@@ -605,7 +605,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -626,7 +626,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
request.address = offset;
request.length = len;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write SMBUS request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -694,7 +694,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
}
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
@@ -712,7 +712,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
if ((self->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)
return -EOPNOTSUPP;
- pthread_mutex_lock(&self->mbox_mutex);
+ rte_thread_mutex_lock(&self->mbox_mutex);
/* Write macsec request to cfg memory */
err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
@@ -742,7 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32)));
exit:
- pthread_mutex_unlock(&self->mbox_mutex);
+ rte_thread_mutex_unlock(&self->mbox_mutex);
return err;
}
diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
index df0aa21a9b..a7b892b806 100644
--- a/drivers/net/axgbe/axgbe_common.h
+++ b/drivers/net/axgbe/axgbe_common.h
@@ -19,7 +19,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_bitops.h>
#include <rte_byteorder.h>
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 786288a7b0..197c722901 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -167,12 +167,12 @@ static int axgbe_read_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
mmd_data = XPCS16_IOREAD(pdata, offset);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
return mmd_data;
}
@@ -201,12 +201,12 @@ static void axgbe_write_mmd_regs_v2(struct axgbe_port *pdata,
index = mmd_address & ~pdata->xpcs_window_mask;
offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
- pthread_mutex_lock(&pdata->xpcs_mutex);
+ rte_thread_mutex_lock(&pdata->xpcs_mutex);
XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
XPCS16_IOWRITE(pdata, offset, mmd_data);
- pthread_mutex_unlock(&pdata->xpcs_mutex);
+ rte_thread_mutex_unlock(&pdata->xpcs_mutex);
}
static int axgbe_read_mmd_regs(struct axgbe_port *pdata, int prtad,
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 9cb4818af1..caf5a4476f 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -2311,10 +2311,10 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
pdata->tx_desc_count = AXGBE_MAX_RING_DESC;
pdata->rx_desc_count = AXGBE_MAX_RING_DESC;
- pthread_mutex_init(&pdata->xpcs_mutex, NULL);
- pthread_mutex_init(&pdata->i2c_mutex, NULL);
- pthread_mutex_init(&pdata->an_mutex, NULL);
- pthread_mutex_init(&pdata->phy_mutex, NULL);
+ rte_thread_mutex_init(&pdata->xpcs_mutex);
+ rte_thread_mutex_init(&pdata->i2c_mutex);
+ rte_thread_mutex_init(&pdata->an_mutex);
+ rte_thread_mutex_init(&pdata->phy_mutex);
ret = pdata->phy_if.phy_init(pdata);
if (ret) {
diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h
index a6226729fe..f2929d57ab 100644
--- a/drivers/net/axgbe/axgbe_ethdev.h
+++ b/drivers/net/axgbe/axgbe_ethdev.h
@@ -602,10 +602,10 @@ struct axgbe_port {
int phy_link;
int phy_speed;
- pthread_mutex_t xpcs_mutex;
- pthread_mutex_t i2c_mutex;
- pthread_mutex_t an_mutex;
- pthread_mutex_t phy_mutex;
+ rte_thread_mutex xpcs_mutex;
+ rte_thread_mutex i2c_mutex;
+ rte_thread_mutex an_mutex;
+ rte_thread_mutex phy_mutex;
/* Flow control settings */
unsigned int pause_autoneg;
diff --git a/drivers/net/axgbe/axgbe_i2c.c b/drivers/net/axgbe/axgbe_i2c.c
index ab3738a12e..c17f9a8b9e 100644
--- a/drivers/net/axgbe/axgbe_i2c.c
+++ b/drivers/net/axgbe/axgbe_i2c.c
@@ -229,7 +229,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
int ret;
uint64_t timeout;
- pthread_mutex_lock(&pdata->i2c_mutex);
+ rte_thread_mutex_lock(&pdata->i2c_mutex);
ret = axgbe_i2c_disable(pdata);
if (ret) {
PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
@@ -282,7 +282,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
}
unlock:
- pthread_mutex_unlock(&pdata->i2c_mutex);
+ rte_thread_mutex_unlock(&pdata->i2c_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c
index 4f98e695ae..5f3d9b360e 100644
--- a/drivers/net/axgbe/axgbe_mdio.c
+++ b/drivers/net/axgbe/axgbe_mdio.c
@@ -686,9 +686,9 @@ static void axgbe_an73_isr(struct axgbe_port *pdata)
if (pdata->an_int) {
/* Clear the interrupt(s) that fired and process them */
XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, ~pdata->an_int);
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
axgbe_an73_state_machine(pdata);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
} else {
/* Enable AN interrupts */
axgbe_an73_enable_interrupts(pdata);
@@ -977,7 +977,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
{
int ret;
- pthread_mutex_lock(&pdata->an_mutex);
+ rte_thread_mutex_lock(&pdata->an_mutex);
ret = __axgbe_phy_config_aneg(pdata);
if (ret)
@@ -985,7 +985,7 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
else
rte_bit_relaxed_clear32(AXGBE_LINK_ERR, &pdata->dev_state);
- pthread_mutex_unlock(&pdata->an_mutex);
+ rte_thread_mutex_unlock(&pdata->an_mutex);
return ret;
}
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 02236ec192..1e1d6358d8 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -403,7 +403,7 @@ static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata)
phy_data->comm_owned = 0;
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
}
static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
@@ -416,7 +416,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
* the driver needs to take the software mutex and then the hardware
* mutexes before being able to use the busses.
*/
- pthread_mutex_lock(&pdata->phy_mutex);
+ rte_thread_mutex_lock(&pdata->phy_mutex);
if (phy_data->comm_owned)
return 0;
@@ -447,7 +447,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
return 0;
}
- pthread_mutex_unlock(&pdata->phy_mutex);
+ rte_thread_mutex_unlock(&pdata->phy_mutex);
PMD_DRV_LOG(ERR, "unable to obtain hardware mutexes\n");
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 494a1eff37..f013bb8a79 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -540,8 +540,8 @@ struct bnxt_mark_info {
struct bnxt_rep_info {
struct rte_eth_dev *vfr_eth_dev;
- pthread_mutex_t vfr_lock;
- pthread_mutex_t vfr_start_lock;
+ rte_thread_mutex vfr_lock;
+ rte_thread_mutex vfr_start_lock;
bool conduit_valid;
};
@@ -739,7 +739,7 @@ struct bnxt {
#define BNXT_FW_CAP_TRUFLOW_EN BIT(8)
#define BNXT_TRUFLOW_EN(bp) ((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN)
- pthread_mutex_t flow_lock;
+ rte_thread_mutex flow_lock;
uint32_t vnic_cap_flags;
#define BNXT_VNIC_CAP_COS_CLASSIFY BIT(0)
@@ -793,18 +793,18 @@ struct bnxt {
rte_iova_t hwrm_short_cmd_req_dma_addr;
rte_spinlock_t hwrm_lock;
/* synchronize between dev_configure_op and int handler */
- pthread_mutex_t def_cp_lock;
+ rte_thread_mutex def_cp_lock;
/* synchronize between dev_start_op and async evt handler
* Locking sequence in async evt handler will be
* def_cp_lock
* health_check_lock
*/
- pthread_mutex_t health_check_lock;
+ rte_thread_mutex health_check_lock;
/* synchronize between dev_stop/dev_close_op and
* error recovery thread triggered as part of
* HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY
*/
- pthread_mutex_t err_recovery_lock;
+ rte_thread_mutex err_recovery_lock;
uint16_t max_req_len;
uint16_t max_resp_len;
uint16_t hwrm_max_ext_req_len;
@@ -1014,10 +1014,10 @@ uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
extern const struct rte_flow_ops bnxt_flow_ops;
#define bnxt_acquire_flow_lock(bp) \
- pthread_mutex_lock(&(bp)->flow_lock)
+ rte_thread_mutex_lock(&(bp)->flow_lock)
#define bnxt_release_flow_lock(bp) \
- pthread_mutex_unlock(&(bp)->flow_lock)
+ rte_thread_mutex_unlock(&(bp)->flow_lock)
#define BNXT_VALID_VNIC_OR_RET(bp, vnic_id) do { \
if ((vnic_id) >= (bp)->max_vnics) { \
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 12230dcea4..6c0fc248ab 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -156,7 +156,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
return;
}
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
event_data = data1;
/* timestamp_lo/hi values are in units of 100ms */
bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
@@ -178,7 +178,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
}
bp->flags |= BNXT_FLAG_FW_RESET;
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
(void *)bp);
break;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index de34a2f0bb..6c93bee284 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1087,7 +1087,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
* are calculated correctly.
*/
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
bnxt_disable_int(bp);
@@ -1097,20 +1097,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return -ENOSPC;
}
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
rc = bnxt_alloc_async_cp_ring(bp);
if (rc) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return rc;
}
bnxt_enable_int(bp);
}
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
/* Inherit new configurations */
@@ -1532,14 +1532,14 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error..Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return bnxt_dev_stop(eth_dev);
}
@@ -1625,13 +1625,13 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
static void
bnxt_uninit_locks(struct bnxt *bp)
{
- pthread_mutex_destroy(&bp->flow_lock);
- pthread_mutex_destroy(&bp->def_cp_lock);
- pthread_mutex_destroy(&bp->health_check_lock);
- pthread_mutex_destroy(&bp->err_recovery_lock);
+ rte_thread_mutex_destroy(&bp->flow_lock);
+ rte_thread_mutex_destroy(&bp->def_cp_lock);
+ rte_thread_mutex_destroy(&bp->health_check_lock);
+ rte_thread_mutex_destroy(&bp->err_recovery_lock);
if (bp->rep_info) {
- pthread_mutex_destroy(&bp->rep_info->vfr_lock);
- pthread_mutex_destroy(&bp->rep_info->vfr_start_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_lock);
+ rte_thread_mutex_destroy(&bp->rep_info->vfr_start_lock);
}
}
@@ -1663,14 +1663,14 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (bp->flags & BNXT_FLAG_FW_RESET) {
PMD_DRV_LOG(ERR,
"Adapter recovering from error...Please retry\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return -EAGAIN;
}
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
/* cancel the recovery handler before remove dev */
rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp);
@@ -4312,7 +4312,7 @@ static void bnxt_dev_recover(void *arg)
struct bnxt *bp = arg;
int rc = 0;
- pthread_mutex_lock(&bp->err_recovery_lock);
+ rte_thread_mutex_lock(&bp->err_recovery_lock);
if (!bp->fw_reset_min_msecs) {
rc = bnxt_check_fw_reset_done(bp);
@@ -4347,7 +4347,7 @@ static void bnxt_dev_recover(void *arg)
goto err_start;
PMD_DRV_LOG(INFO, "Recovered from FW reset\n");
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
return;
err_start:
@@ -4359,7 +4359,7 @@ static void bnxt_dev_recover(void *arg)
rte_eth_dev_callback_process(bp->eth_dev,
RTE_ETH_EVENT_INTR_RMV,
NULL);
- pthread_mutex_unlock(&bp->err_recovery_lock);
+ rte_thread_mutex_unlock(&bp->err_recovery_lock);
PMD_DRV_LOG(ERR, "Failed to recover from FW reset\n");
}
@@ -4535,7 +4535,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
{
uint32_t polling_freq;
- pthread_mutex_lock(&bp->health_check_lock);
+ rte_thread_mutex_lock(&bp->health_check_lock);
if (!bnxt_is_recovery_enabled(bp))
goto done;
@@ -4550,7 +4550,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
done:
- pthread_mutex_unlock(&bp->health_check_lock);
+ rte_thread_mutex_unlock(&bp->health_check_lock);
}
static void bnxt_cancel_fw_health_check(struct bnxt *bp)
@@ -5395,25 +5395,25 @@ bnxt_init_locks(struct bnxt *bp)
{
int err;
- err = pthread_mutex_init(&bp->flow_lock, NULL);
+ err = rte_thread_mutex_init(&bp->flow_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->def_cp_lock, NULL);
+ err = rte_thread_mutex_init(&bp->def_cp_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->health_check_lock, NULL);
+ err = rte_thread_mutex_init(&bp->health_check_lock);
if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize health_check_lock\n");
return err;
}
- err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
+ err = rte_thread_mutex_init(&bp->err_recovery_lock);
if (err)
PMD_DRV_LOG(ERR, "Unable to initialize err_recovery_lock\n");
@@ -6237,14 +6237,14 @@ static int bnxt_init_rep_info(struct bnxt *bp)
for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
- rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_lock\n");
bnxt_free_rep_info(bp);
return rc;
}
- rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->rep_info->vfr_start_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Unable to initialize vfr_start_lock\n");
bnxt_free_rep_info(bp);
diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 122a1f9908..7f5203aea3 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -33,15 +33,15 @@ void bnxt_int_handler(void *param)
return;
raw_cons = cpr->cp_raw_cons;
- pthread_mutex_lock(&bp->def_cp_lock);
+ rte_thread_mutex_lock(&bp->def_cp_lock);
while (1) {
if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
if (is_bnxt_in_error(bp)) {
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
return;
}
@@ -62,7 +62,7 @@ void bnxt_int_handler(void *param)
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
- pthread_mutex_unlock(&bp->def_cp_lock);
+ rte_thread_mutex_unlock(&bp->def_cp_lock);
}
int bnxt_free_int(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index bdbad53b7d..49d3ec66bc 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -120,7 +120,7 @@ bnxt_rep_tx_burst(void *tx_queue,
qid = vfr_txq->txq->queue_id;
vf_rep_bp = vfr_txq->bp;
parent = vf_rep_bp->parent_dev->data->dev_private;
- pthread_mutex_lock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_lock(&parent->rep_info->vfr_lock);
ptxq = parent->tx_queues[qid];
ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
@@ -132,7 +132,7 @@ bnxt_rep_tx_burst(void *tx_queue,
rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
ptxq->vfr_tx_cfa_action = 0;
- pthread_mutex_unlock(&parent->rep_info->vfr_lock);
+ rte_thread_mutex_unlock(&parent->rep_info->vfr_lock);
return rc;
}
@@ -407,15 +407,15 @@ int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
rep_info = &parent_bp->rep_info[rep_bp->vf_id];
BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR start\n", eth_dev->data->port_id);
- pthread_mutex_lock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_lock(&rep_info->vfr_start_lock);
if (!rep_info->conduit_valid) {
rc = bnxt_get_dflt_vnic_svif(parent_bp, rep_bp);
if (rc || !rep_info->conduit_valid) {
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
return rc;
}
}
- pthread_mutex_unlock(&rep_info->vfr_start_lock);
+ rte_thread_mutex_unlock(&rep_info->vfr_start_lock);
rc = bnxt_vfr_alloc(eth_dev);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index dbf85e4eda..6af529b4ff 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -32,7 +32,7 @@ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
STAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);
/* Mutex to synchronize bnxt_ulp_session_list operations. */
-static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(bnxt_ulp_global_mutex)
/* Spin lock to protect context global list */
rte_spinlock_t bnxt_ulp_ctxt_lock;
@@ -975,7 +975,7 @@ ulp_ctx_detach(struct bnxt *bp)
static void
ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
{
- pthread_mutex_lock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_lock(&session->bnxt_ulp_mutex);
if (!session->bnxt_ulp_init) {
session->bnxt_ulp_init = true;
@@ -984,7 +984,7 @@ ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)
*init = true;
}
- pthread_mutex_unlock(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_unlock(&session->bnxt_ulp_mutex);
}
/*
@@ -1025,7 +1025,7 @@ ulp_session_init(struct bnxt *bp,
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
if (!session) {
@@ -1036,17 +1036,17 @@ ulp_session_init(struct bnxt *bp,
if (!session) {
BNXT_TF_DBG(ERR,
"Allocation failed for bnxt_ulp_session\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
} else {
/* Add it to the queue */
session->pci_info.domain = pci_addr->domain;
session->pci_info.bus = pci_addr->bus;
- rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
+ rc = rte_thread_mutex_init(&session->bnxt_ulp_mutex);
if (rc) {
BNXT_TF_DBG(ERR, "mutex create failed\n");
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return NULL;
}
STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
@@ -1054,7 +1054,7 @@ ulp_session_init(struct bnxt *bp,
}
}
ulp_context_initialized(session, init);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
return session;
}
@@ -1069,12 +1069,12 @@ ulp_session_deinit(struct bnxt_ulp_session_state *session)
return;
if (!session->cfg_data) {
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
STAILQ_REMOVE(&bnxt_ulp_session_list, session,
bnxt_ulp_session_state, next);
- pthread_mutex_destroy(&session->bnxt_ulp_mutex);
+ rte_thread_mutex_destroy(&session->bnxt_ulp_mutex);
rte_free(session);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
}
}
@@ -1235,7 +1235,7 @@ bnxt_ulp_deinit(struct bnxt *bp,
BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0);
/* free the flow db lock */
- pthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (ha_enabled)
ulp_ha_mgr_deinit(bp->ulp_ctx);
@@ -1263,7 +1263,7 @@ bnxt_ulp_init(struct bnxt *bp,
goto jump_to_error;
}
- rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ rc = rte_thread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock);
if (rc) {
BNXT_TF_DBG(ERR, "Unable to initialize flow db lock\n");
goto jump_to_error;
@@ -1529,9 +1529,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp)
/* Get the session details */
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
- pthread_mutex_lock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_lock(&bnxt_ulp_global_mutex);
session = ulp_get_session(pci_addr);
- pthread_mutex_unlock(&bnxt_ulp_global_mutex);
+ rte_thread_mutex_unlock(&bnxt_ulp_global_mutex);
/* session not found then just exit */
if (!session) {
@@ -1938,7 +1938,7 @@ bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return -1;
- if (pthread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
+ if (rte_thread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {
BNXT_TF_DBG(ERR, "unable to acquire fdb lock\n");
return -1;
}
@@ -1952,7 +1952,7 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx || !ulp_ctx->cfg_data)
return;
- pthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
+ rte_thread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);
}
/* Function to set the ha info into the context */
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 082ca501b6..b33e035637 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -64,7 +64,7 @@ struct bnxt_ulp_data {
uint32_t dev_id; /* Hardware device id */
uint32_t ref_cnt;
struct bnxt_ulp_flow_db *flow_db;
- pthread_mutex_t flow_db_lock;
+ rte_thread_mutex flow_db_lock;
void *mapper_data;
struct bnxt_ulp_port_db *port_db;
struct bnxt_ulp_fc_info *fc_info;
@@ -95,7 +95,7 @@ struct bnxt_ulp_pci_info {
struct bnxt_ulp_session_state {
STAILQ_ENTRY(bnxt_ulp_session_state) next;
bool bnxt_ulp_init;
- pthread_mutex_t bnxt_ulp_mutex;
+ rte_thread_mutex bnxt_ulp_mutex;
struct bnxt_ulp_pci_info pci_info;
struct bnxt_ulp_data *cfg_data;
struct tf *g_tfp;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 13f71ed83b..2e99b4d79e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -3,6 +3,7 @@
* All rights reserved.
*/
+#include <pthread.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
@@ -84,7 +85,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
if (!ulp_fc_info)
goto error;
- rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
+ rc = rte_thread_mutex_init(&ulp_fc_info->fc_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize fc mutex\n");
goto error;
@@ -149,7 +150,7 @@ ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt)
ulp_fc_mgr_thread_cancel(ctxt);
- pthread_mutex_destroy(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_destroy(&ulp_fc_info->fc_lock);
if (ulp_fc_info->num_counters) {
for (i = 0; i < TF_DIR_MAX; i++)
@@ -485,11 +486,12 @@ ulp_fc_mgr_alarm_cb(void *arg __rte_unused)
* Take the fc_lock to ensure no flow is destroyed
* during the bulk get
*/
- if (pthread_mutex_trylock(&ulp_fc_info->fc_lock))
+ if (pthread_mutex_trylock((pthread_mutex_t *)
+ &ulp_fc_info->fc_lock.mutex_id))
goto out;
if (!ulp_fc_info->num_entries) {
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
ulp_fc_mgr_thread_cancel(ctxt);
bnxt_ulp_cntxt_entry_release();
return;
@@ -521,7 +523,7 @@ ulp_fc_mgr_alarm_cb(void *arg __rte_unused)
}
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
/*
* If cmd fails once, no need of
@@ -617,12 +619,12 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info->num_counters)
return 0;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = true;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = hw_cntr_id;
ulp_fc_info->num_entries++;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -652,14 +654,14 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
if (!ulp_fc_info->num_counters)
return 0;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = false;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].hw_cntr_id = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].pkt_count = 0;
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].byte_count = 0;
ulp_fc_info->num_entries--;
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return 0;
}
@@ -730,7 +732,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
/* TODO:
* Think about optimizing with try_lock later
*/
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id -
ulp_fc_info->shadow_hw_tbl[dir].start_idx;
sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
@@ -744,7 +746,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
sw_acc_tbl_entry->pkt_count = 0;
sw_acc_tbl_entry->byte_count = 0;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
} else if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT_ACC) {
/* Get stats from the parent child table */
@@ -786,7 +788,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
if (!ulp_fc_info)
return -EIO;
- pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_lock(&ulp_fc_info->fc_lock);
sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
if (ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid) {
ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].parent_flow_id = fid;
@@ -795,7 +797,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
hw_cntr_id, fid);
rc = -ENOENT;
}
- pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ rte_thread_mutex_unlock(&ulp_fc_info->fc_lock);
return rc;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index 448d05c118..a44dcaf047 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -45,10 +45,10 @@ struct hw_fc_mem_info {
struct bnxt_ulp_fc_info {
struct sw_acc_counter *sw_acc_tbl[TF_DIR_MAX];
struct hw_fc_mem_info shadow_hw_tbl[TF_DIR_MAX];
- uint32_t flags;
- uint32_t num_entries;
- pthread_mutex_t fc_lock;
- uint32_t num_counters;
+ uint32_t flags;
+ uint32_t num_entries;
+ rte_thread_mutex fc_lock;
+ uint32_t num_counters;
};
int32_t
diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
index 5f5b5d639e..c540cb8436 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
@@ -328,7 +328,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
/* Add the HA info tbl to the ulp context. */
bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
- rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
+ rc = rte_thread_mutex_init(&ha_info->ha_lock);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to initialize ha mutex\n");
goto cleanup;
@@ -359,7 +359,7 @@ ulp_ha_mgr_deinit(struct bnxt_ulp_context *ulp_ctx)
return;
}
- pthread_mutex_destroy(&ha_info->ha_lock);
+ rte_thread_mutex_destroy(&ha_info->ha_lock);
rte_free(ha_info);
bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, NULL);
diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
index 793511564a..8b006f6c99 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
@@ -31,7 +31,7 @@ struct bnxt_ulp_ha_mgr_info {
enum ulp_ha_mgr_app_type app_type;
enum ulp_ha_mgr_region region;
uint32_t flags;
- pthread_mutex_t ha_lock;
+ rte_thread_mutex ha_lock;
};
bool
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 27d670f843..0983630f5e 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -11,7 +11,7 @@
#include <limits.h>
#include <sched.h>
#include <signal.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 423de40e95..55eb14af5f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <limits.h>
#include <sched.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_byteorder.h>
#include <rte_common.h>
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 4e7f52881a..6fe3824758 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
@@ -141,14 +142,14 @@ extern int ena_logtype_com;
typedef struct {
pthread_cond_t cond;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
uint8_t flag;
} ena_wait_event_t;
#define ENA_WAIT_EVENT_INIT(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_init(&_we->mutex, NULL); \
+ rte_thread_mutex_init(&_we->mutex); \
pthread_cond_init(&_we->cond, NULL); \
_we->flag = 0; \
} while (0)
@@ -165,10 +166,10 @@ typedef struct {
wait.tv_sec = now.tv_sec + _tmo / 1000000UL; \
timeout_us = _tmo % 1000000UL; \
wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
while (ret == 0 && !_we->flag) { \
ret = pthread_cond_timedwait(&_we->cond, \
- &_we->mutex, &wait); \
+ _we->mutex.mutex_id, &wait); \
} \
/* Asserts only if not working on ena_wait_event_t */ \
if (unlikely(ret != 0 && ret != ETIMEDOUT)) \
@@ -178,15 +179,15 @@ typedef struct {
ena_trc_err(NULL, \
"Timeout waiting for " #waitevent "\n"); \
_we->flag = 0; \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
#define ENA_WAIT_EVENT_SIGNAL(waitevent) \
do { \
ena_wait_event_t *_we = &(waitevent); \
- pthread_mutex_lock(&_we->mutex); \
+ rte_thread_mutex_lock(&_we->mutex); \
_we->flag = 1; \
pthread_cond_signal(&_we->cond); \
- pthread_mutex_unlock(&_we->mutex); \
+ rte_thread_mutex_unlock(&_we->mutex); \
} while (0)
/* pthread condition doesn't need to be rearmed after usage */
#define ENA_WAIT_EVENT_CLEAR(...)
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 47bfdac2cf..db07c589b9 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -107,7 +107,7 @@ struct enic {
int iommu_groupid;
int eventfd;
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
- pthread_t err_intr_thread;
+ rte_thread_t err_intr_thread;
int promisc;
int allmulti;
uint8_t ig_vlan_strip_en;
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index f461318f96..3d4fe47489 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -3,7 +3,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <unistd.h>
#include <rte_spinlock.h>
@@ -121,7 +121,7 @@ ice_dcf_vsi_update_service_handler(void *param)
struct ice_dcf_hw *hw = reset_param->dcf_hw;
struct ice_dcf_adapter *adapter;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL);
@@ -159,7 +159,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
#define THREAD_NAME_LEN 16
struct ice_dcf_reset_event_param *param;
char name[THREAD_NAME_LEN];
- pthread_t thread;
+ rte_thread_t thread;
int ret;
param = malloc(sizeof(*param));
@@ -173,7 +173,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
param->vf_id = vf_id;
snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
- ret = rte_ctrl_thread_create(&thread, name, NULL,
+ ret = rte_thread_ctrl_thread_create(&thread, name,
ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b5371568b5..cf7b19edc0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4156,7 +4156,7 @@ ixgbe_dev_setup_link_thread_handler(void *param)
u32 speed;
bool autoneg = false;
- pthread_detach(pthread_self());
+ rte_thread_detach(rte_thread_self());
speed = hw->phy.autoneg_advertised;
if (!speed)
ixgbe_get_link_capabilities(hw, &speed, &autoneg);
@@ -4264,9 +4264,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
* when there is no link thread running.
*/
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
- if (rte_ctrl_thread_create(&ad->link_thread_tid,
+ if (rte_thread_ctrl_thread_create
+ (&ad->link_thread_tid,
"ixgbe-link-handler",
- NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index a0ce18ca24..272fdcfb8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -516,7 +516,7 @@ struct ixgbe_adapter {
uint8_t pflink_fullchk;
uint8_t mac_ctrl_frame_fwd;
rte_atomic32_t link_thread_running;
- pthread_t link_thread_tid;
+ rte_thread_t link_thread_tid;
};
struct ixgbe_vf_representor {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 5f8766aa48..85b92b5ee5 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2872,7 +2872,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int dbmap_env;
int err = 0;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/*
* Configure environment variable "MLX5_BF_SHUT_UP"
* before the device creation. The rdma_core library
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f84e061fe7..71c2918bed 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -186,7 +186,7 @@ int mlx5_logtype;
static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
LIST_HEAD_INITIALIZER();
-static pthread_mutex_t mlx5_dev_ctx_list_mutex;
+static rte_thread_mutex mlx5_dev_ctx_list_mutex;
static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
[MLX5_IPOOL_DECAP_ENCAP] = {
@@ -1117,7 +1117,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
MLX5_ASSERT(spawn);
/* Secondary process should not create the shared context. */
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
/* Search for IB context by device name. */
LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
if (!strcmp(sh->ibdev_name,
@@ -1246,11 +1246,11 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
LIST_INSERT_HEAD(&mlx5_dev_ctx_list, sh, next);
rte_spinlock_init(&sh->geneve_tlv_opt_sl);
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
return sh;
error:
- pthread_mutex_destroy(&sh->txpp.mutex);
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
MLX5_ASSERT(sh);
if (sh->cnt_id_tbl)
mlx5_l3t_destroy(sh->cnt_id_tbl);
@@ -1282,7 +1282,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
void
mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
{
- pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_lock(&mlx5_dev_ctx_list_mutex);
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Check the object presence in the list. */
struct mlx5_dev_ctx_shared *lctx;
@@ -1313,7 +1313,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
/* Release flow workspaces objects on the last device. */
if (LIST_EMPTY(&mlx5_dev_ctx_list))
mlx5_flow_os_release_workspace();
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.
* Only primary process handles async device events.
@@ -1346,11 +1346,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
if (sh->ctx)
claim_zero(mlx5_glue->close_device(sh->ctx));
MLX5_ASSERT(sh->geneve_tlv_option_resource == NULL);
- pthread_mutex_destroy(&sh->txpp.mutex);
+ rte_thread_mutex_destroy(&sh->txpp.mutex);
mlx5_free(sh);
return;
exit:
- pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
+ rte_thread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
}
/**
@@ -2502,7 +2502,7 @@ RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
*/
RTE_INIT(rte_mlx5_pmd_init)
{
- pthread_mutex_init(&mlx5_dev_ctx_list_mutex, NULL);
+ rte_thread_mutex_init(&mlx5_dev_ctx_list_mutex);
mlx5_common_init();
/* Build the static tables for Verbs conversion. */
mlx5_set_ptype_table();
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e02714e231..d8726d115a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1010,7 +1010,7 @@ struct mlx5_txpp_ts {
/* Tx packet pacing structure. */
struct mlx5_dev_txpp {
- pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
+ rte_thread_mutex mutex; /* Pacing create/destroy mutex. */
uint32_t refcnt; /* Pacing reference counter. */
uint32_t freq; /* Timestamp frequency, Hz. */
uint32_t tick; /* Completion tick duration in nanoseconds. */
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 4f6da9f2d1..83c4743faf 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -914,7 +914,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
if (ret < 0)
return 0;
}
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
if (sh->txpp.refcnt) {
@@ -930,7 +930,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
rte_errno = -err;
}
}
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
return err;
@@ -957,7 +957,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
}
priv->txpp_en = 0;
- ret = pthread_mutex_lock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_lock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
MLX5_ASSERT(sh->txpp.refcnt);
@@ -965,7 +965,7 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
return;
/* No references any more, do actual destroy. */
mlx5_txpp_destroy(sh);
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
+ ret = rte_thread_mutex_unlock(&sh->txpp.mutex);
MLX5_ASSERT(!ret);
RTE_SET_USED(ret);
}
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index c4d5790726..ccdb0184a9 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -253,7 +253,7 @@ struct mlx5_workspace_thread {
static struct mlx5_workspace_thread *curr;
static struct mlx5_workspace_thread *first;
rte_thread_key ws_tls_index;
-static pthread_mutex_t lock_thread_list;
+RTE_STATIC_MUTEX(lock_thread_list)
static bool
mlx5_is_thread_alive(HANDLE thread_handle)
@@ -330,7 +330,7 @@ mlx5_flow_os_release_workspace(void)
free(first);
}
rte_thread_key_delete(ws_tls_index);
- pthread_mutex_destroy(&lock_thread_list);
+ rte_thread_mutex_destroy(&lock_thread_list);
}
static int
@@ -352,7 +352,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
}
temp->mlx5_ws = data;
temp->thread_handle = curr_thread;
- pthread_mutex_lock(&lock_thread_list);
+ rte_thread_mutex_lock(&lock_thread_list);
mlx5_clear_thread_list();
if (!first) {
first = temp;
@@ -361,7 +361,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data)
curr->next = temp;
curr = curr->next;
}
- pthread_mutex_unlock(&lock_thread_list);
+ rte_thread_mutex_unlock(&lock_thread_list);
return 0;
}
@@ -374,7 +374,7 @@ mlx5_flow_os_init_workspace_once(void)
DRV_LOG(ERR, "Can't create flow workspace data thread key.");
return err;
}
- pthread_mutex_init(&lock_thread_list, NULL);
+ rte_thread_mutex_init(&lock_thread_list);
return 0;
}
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 7e1df1c751..99876f227b 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -264,7 +264,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
int err = 0;
struct mlx5_context *mlx5_ctx;
- pthread_mutex_init(&sh->txpp.mutex, NULL);
+ rte_thread_mutex_init(&sh->txpp.mutex);
/* Set numa node from pci probe */
sh->numa_node = spawn->pci_dev->device.numa_node;
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index c5b5399282..c9011d964b 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -153,10 +153,10 @@ void osal_dma_free_mem(struct ecore_dev *edev, dma_addr_t phys);
/* Mutexes */
-typedef pthread_mutex_t osal_mutex_t;
-#define OSAL_MUTEX_RELEASE(lock) pthread_mutex_unlock(lock)
-#define OSAL_MUTEX_INIT(lock) pthread_mutex_init(lock, NULL)
-#define OSAL_MUTEX_ACQUIRE(lock) pthread_mutex_lock(lock)
+typedef rte_thread_mutex osal_mutex_t;
+#define OSAL_MUTEX_RELEASE(lock) rte_thread_mutex_unlock(lock)
+#define OSAL_MUTEX_INIT(lock) rte_thread_mutex_init(lock)
+#define OSAL_MUTEX_ACQUIRE(lock) rte_thread_mutex_lock(lock)
#define OSAL_MUTEX_ALLOC(hwfn, lock) nothing
#define OSAL_MUTEX_DEALLOC(lock) nothing
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index a202931e9a..484b647a62 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -3,7 +3,7 @@
* Copyright(c) 2016-2018 Intel Corporation
*/
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <stdbool.h>
#include <sys/epoll.h>
@@ -121,7 +121,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static struct rte_eth_link pmd_link = {
.link_speed = 10000,
@@ -507,7 +507,7 @@ find_internal_resource(char *ifname)
if (ifname == NULL)
return NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
internal = list->eth_dev->data->dev_private;
@@ -517,7 +517,7 @@ find_internal_resource(char *ifname)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -1001,9 +1001,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
goto free_list;
list->eth_dev = eth_dev;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_spinlock_init(&vring_state->lock);
vring_states[eth_dev->data->port_id] = vring_state;
@@ -1035,9 +1035,9 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
rte_vhost_driver_unregister(internal->iface_name);
list_remove:
vring_states[eth_dev->data->port_id] = NULL;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(vring_state);
free_list:
rte_free(list);
@@ -1093,7 +1093,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
if (!rte_eth_dev_is_valid_port(port_id))
return -1;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
eth_dev = list->eth_dev;
@@ -1106,7 +1106,7 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
return vid;
}
@@ -1184,9 +1184,9 @@ eth_dev_close(struct rte_eth_dev *dev)
list = find_internal_resource(internal->iface_name);
if (list) {
rte_vhost_driver_unregister(internal->iface_name);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 16c58710d7..df2200d8cc 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -143,7 +143,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
uint64_t features;
int ret = -1;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 0: tell vhost to create queues */
if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
@@ -161,7 +161,7 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
goto error;
PMD_DRV_LOG(INFO, "(%s) set features: 0x%" PRIx64, dev->path, features);
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -185,7 +185,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
* memory subsystem in the future.
*/
rte_mcfg_mem_read_lock();
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
/* Step 2: share memory regions */
ret = dev->ops->set_memory_table(dev);
@@ -206,12 +206,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
dev->started = true;
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
return 0;
error:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
rte_mcfg_mem_read_unlock();
PMD_INIT_LOG(ERR, "(%s) Failed to start device\n", dev->path);
@@ -226,7 +226,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
uint32_t i;
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (!dev->started)
goto out;
@@ -249,11 +249,11 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
dev->started = false;
out:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return 0;
err:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
PMD_INIT_LOG(ERR, "(%s) Failed to stop device\n", dev->path);
@@ -443,7 +443,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
if (msl->external)
return;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
if (dev->started == false)
goto exit;
@@ -468,7 +468,7 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
}
exit:
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
if (ret < 0)
PMD_DRV_LOG(ERR, "(%s) Failed to update memory table\n", dev->path);
@@ -554,7 +554,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
uint64_t backend_features;
int i;
- pthread_mutex_init(&dev->mutex, NULL);
+ rte_thread_mutex_init(&dev->mutex);
strlcpy(dev->path, path, PATH_MAX);
for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; i++) {
@@ -862,13 +862,13 @@ virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status)
{
int ret;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
dev->status = status;
ret = dev->ops->set_status(dev, status);
if (ret && ret != -ENOTSUP)
PMD_INIT_LOG(ERR, "(%s) Failed to set backend status\n", dev->path);
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
@@ -878,7 +878,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
int ret;
uint8_t status;
- pthread_mutex_lock(&dev->mutex);
+ rte_thread_mutex_lock(&dev->mutex);
ret = dev->ops->get_status(dev, &status);
if (!ret) {
@@ -903,7 +903,7 @@ virtio_user_dev_update_status(struct virtio_user_dev *dev)
PMD_INIT_LOG(ERR, "(%s) Failed to get backend status\n", dev->path);
}
- pthread_mutex_unlock(&dev->mutex);
+ rte_thread_mutex_unlock(&dev->mutex);
return ret;
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 819f6463ba..1df8d80f90 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -55,7 +55,7 @@ struct virtio_user_dev {
bool qp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];
struct virtio_user_backend_ops *ops;
- pthread_mutex_t mutex;
+ rte_thread_mutex mutex;
bool started;
void *backend_data;
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 1dc813d0a3..81ff6c2d58 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -23,6 +23,7 @@
#include <rte_log.h>
#include <rte_kvargs.h>
#include <rte_devargs.h>
+#include <rte_thread.h>
#include "base/ifcvf.h"
@@ -52,7 +53,7 @@ struct ifcvf_internal {
int vfio_container_fd;
int vfio_group_fd;
int vfio_dev_fd;
- pthread_t tid; /* thread for notify relay */
+ rte_thread_t tid; /* thread for notify relay */
int epfd;
int vid;
struct rte_vdpa_device *vdev;
@@ -79,7 +80,7 @@ TAILQ_HEAD(internal_list_head, internal_list);
static struct internal_list_head internal_list =
TAILQ_HEAD_INITIALIZER(internal_list);
-static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(internal_list_lock)
static void update_used_ring(struct ifcvf_internal *internal, uint16_t qid);
@@ -89,7 +90,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (vdev == list->internal->vdev) {
@@ -98,7 +99,7 @@ find_internal_resource_by_vdev(struct rte_vdpa_device *vdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -112,7 +113,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
int found = 0;
struct internal_list *list;
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_FOREACH(list, &internal_list, next) {
if (!rte_pci_addr_cmp(&pdev->addr,
@@ -122,7 +123,7 @@ find_internal_resource_by_dev(struct rte_pci_device *pdev)
}
}
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
if (!found)
return NULL;
@@ -500,10 +501,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, notify_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create notify relay pthread.");
+ DRV_LOG(ERR, "failed to create notify relay thread.");
return -1;
}
@@ -513,13 +514,11 @@ setup_notify_relay(struct ifcvf_internal *internal)
static int
unset_notify_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -806,10 +805,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
int ret;
snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
- ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay,
+ ret = rte_thread_ctrl_thread_create(&internal->tid, name, vring_relay,
(void *)internal);
if (ret != 0) {
- DRV_LOG(ERR, "failed to create ring relay pthread.");
+ DRV_LOG(ERR, "failed to create ring relay thread.");
return -1;
}
@@ -819,13 +818,11 @@ setup_vring_relay(struct ifcvf_internal *internal)
static int
unset_vring_relay(struct ifcvf_internal *internal)
{
- void *status;
-
- if (internal->tid) {
- pthread_cancel(internal->tid);
- pthread_join(internal->tid, &status);
+ if (internal->tid.opaque_id) {
+ pthread_cancel(internal->tid.opaque_id);
+ rte_thread_join(internal->tid, NULL);
}
- internal->tid = 0;
+ internal->tid.opaque_id = 0;
if (internal->epfd >= 0)
close(internal->epfd);
@@ -1253,9 +1250,9 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto error;
}
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_INSERT_TAIL(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_atomic32_set(&internal->started, 1);
update_datapath(internal);
@@ -1293,9 +1290,9 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
rte_vfio_container_destroy(internal->vfio_container_fd);
rte_vdpa_unregister_device(internal->vdev);
- pthread_mutex_lock(&internal_list_lock);
+ rte_thread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
+ rte_thread_mutex_unlock(&internal_list_lock);
rte_free(list);
rte_free(internal);
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 6d17d7a6f3..cd9cb9fca3 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -48,7 +48,7 @@
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+RTE_STATIC_MUTEX(priv_list_lock)
static struct mlx5_vdpa_priv *
mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
@@ -56,14 +56,14 @@ mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
struct mlx5_vdpa_priv *priv;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (vdev == priv->vdev) {
found = 1;
break;
}
}
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (!found) {
DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name);
rte_errno = EINVAL;
@@ -143,9 +143,9 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)
DRV_LOG(ERR, "Too big vring id: %d.", vring);
return -E2BIG;
}
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
ret = mlx5_vdpa_virtq_enable(priv, vring, state);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
return ret;
}
@@ -296,7 +296,7 @@ mlx5_vdpa_dev_close(int vid)
priv->configured = 0;
priv->vid = 0;
/* The mutex may stay locked after event thread cancel - initiate it. */
- pthread_mutex_init(&priv->vq_config_lock, NULL);
+ rte_thread_mutex_init(&priv->vq_config_lock);
DRV_LOG(INFO, "vDPA device %d was closed.", vid);
return ret;
}
@@ -706,10 +706,10 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
}
mlx5_vdpa_config_get(dev->devargs, priv);
SLIST_INIT(&priv->mr_list);
- pthread_mutex_init(&priv->vq_config_lock, NULL);
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_init(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_INSERT_TAIL(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
return 0;
error:
@@ -729,7 +729,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
struct mlx5_vdpa_priv *priv = NULL;
int found = 0;
- pthread_mutex_lock(&priv_list_lock);
+ rte_thread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) {
if (priv->vdev->device == dev) {
found = 1;
@@ -738,7 +738,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
}
if (found)
TAILQ_REMOVE(&priv_list, priv, next);
- pthread_mutex_unlock(&priv_list_lock);
+ rte_thread_mutex_unlock(&priv_list_lock);
if (found) {
if (priv->configured)
mlx5_vdpa_dev_close(priv->vid);
@@ -749,7 +749,7 @@ mlx5_vdpa_dev_remove(struct rte_device *dev)
if (priv->vdev)
rte_vdpa_unregister_device(priv->vdev);
mlx5_glue->close_device(priv->ctx);
- pthread_mutex_destroy(&priv->vq_config_lock);
+ rte_thread_mutex_destroy(&priv->vq_config_lock);
rte_free(priv);
}
return 0;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h
index 2a04e36607..f22f66230a 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.h
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h
@@ -119,9 +119,9 @@ enum {
struct mlx5_vdpa_priv {
TAILQ_ENTRY(mlx5_vdpa_priv) next;
uint8_t configured;
- pthread_mutex_t vq_config_lock;
+ rte_thread_mutex vq_config_lock;
uint64_t no_traffic_counter;
- pthread_t timer_tid;
+ rte_thread_t timer_tid;
int event_mode;
int event_core; /* Event thread cpu affinity core. */
uint32_t event_us;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 3541c652ce..41c1f54447 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -285,7 +285,7 @@ mlx5_vdpa_event_handle(void *arg)
case MLX5_VDPA_EVENT_MODE_FIXED_TIMER:
priv->timer_delay_us = priv->event_us;
while (1) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
max = mlx5_vdpa_queues_complete(priv);
if (max == 0 && priv->no_traffic_counter++ >=
priv->no_traffic_max) {
@@ -293,10 +293,10 @@ mlx5_vdpa_event_handle(void *arg)
priv->vdev->device->name);
mlx5_vdpa_arm_all_cqs(priv);
do {
- pthread_mutex_unlock
+ rte_thread_mutex_unlock
(&priv->vq_config_lock);
cq = mlx5_vdpa_event_wait(priv);
- pthread_mutex_lock
+ rte_thread_mutex_lock
(&priv->vq_config_lock);
if (cq == NULL ||
mlx5_vdpa_queue_complete(cq) > 0)
@@ -307,7 +307,7 @@ mlx5_vdpa_event_handle(void *arg)
} else if (max != 0) {
priv->no_traffic_counter = 0;
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
mlx5_vdpa_timer_sleep(priv, max);
}
return NULL;
@@ -315,10 +315,10 @@ mlx5_vdpa_event_handle(void *arg)
do {
cq = mlx5_vdpa_event_wait(priv);
if (cq != NULL) {
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
if (mlx5_vdpa_queue_complete(cq) > 0)
mlx5_vdpa_cq_arm(priv, cq);
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
}
} while (1);
return NULL;
@@ -340,7 +340,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
struct mlx5_vdpa_virtq *virtq;
uint64_t sec;
- pthread_mutex_lock(&priv->vq_config_lock);
+ rte_thread_mutex_lock(&priv->vq_config_lock);
while (mlx5_glue->devx_get_event(priv->err_chnl, &out.event_resp,
sizeof(out.buf)) >=
(ssize_t)sizeof(out.event_resp.cookie)) {
@@ -386,7 +386,7 @@ mlx5_vdpa_err_interrupt_handler(void *cb_arg __rte_unused)
virtq->err_time[i - 1] = virtq->err_time[i];
virtq->err_time[RTE_DIM(virtq->err_time) - 1] = rte_rdtsc();
}
- pthread_mutex_unlock(&priv->vq_config_lock);
+ rte_thread_mutex_unlock(&priv->vq_config_lock);
#endif
}
@@ -473,28 +473,23 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
{
int ret;
rte_cpuset_t cpuset;
- pthread_attr_t attr;
+ rte_thread_attr_t attr;
char name[16];
- const struct sched_param sp = {
- .sched_priority = sched_get_priority_max(SCHED_RR),
- };
if (!priv->eventc)
/* All virtqs are in poll mode. */
return 0;
- pthread_attr_init(&attr);
- ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
- if (ret) {
- DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
- return -1;
- }
- ret = pthread_attr_setschedparam(&attr, &sp);
+
+ rte_thread_attr_init(&attr);
+ ret = rte_thread_attr_set_priority(&attr,
+ RTE_THREAD_PRIORITY_REALTIME_CRITICAL);
if (ret) {
DRV_LOG(ERR, "Failed to set thread priority.");
return -1;
}
- ret = pthread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
- (void *)priv);
+
+ ret = rte_thread_create(&priv->timer_tid, &attr, mlx5_vdpa_event_handle,
+ (void *)priv);
if (ret) {
DRV_LOG(ERR, "Failed to create timer thread.");
return -1;
@@ -504,13 +499,13 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
CPU_SET(priv->event_core, &cpuset);
else
cpuset = rte_lcore_cpuset(rte_get_main_lcore());
- ret = pthread_setaffinity_np(priv->timer_tid, sizeof(cpuset), &cpuset);
+ ret = rte_thread_set_affinity_by_id(priv->timer_tid, &cpuset);
if (ret) {
DRV_LOG(ERR, "Failed to set thread affinity.");
return -1;
}
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
- ret = rte_thread_setname(priv->timer_tid, name);
+ ret = rte_thread_name_set(priv->timer_tid, name);
if (ret)
DRV_LOG(DEBUG, "Cannot set timer thread name.");
return 0;
@@ -519,13 +514,11 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
void
mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv)
{
- void *status;
-
- if (priv->timer_tid) {
- pthread_cancel(priv->timer_tid);
- pthread_join(priv->timer_tid, &status);
+ if (priv->timer_tid.opaque_id) {
+ pthread_cancel(priv->timer_tid.opaque_id);
+ rte_thread_join(priv->timer_tid, NULL);
}
- priv->timer_tid = 0;
+ priv->timer_tid.opaque_id = 0;
}
void
diff --git a/examples/kni/main.c b/examples/kni/main.c
index beabb3c848..601c9838a2 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -16,6 +16,7 @@
#include <linux/if.h>
#include <linux/if_tun.h>
#include <fcntl.h>
+#include <pthread.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <signal.h>
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h
index e90fb15fc1..9979cc6cdb 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.h
+++ b/examples/performance-thread/pthread_shim/pthread_shim.h
@@ -6,6 +6,7 @@
#define _PTHREAD_SHIM_H_
#include <rte_lcore.h>
+#include <pthread.h>
/*
* This pthread shim is an example that demonstrates how legacy code
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 4/6] lib: enable the new EAL thread API
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (2 preceding siblings ...)
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
Rename pthread* with the new rte_thread* API.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_options.c | 6 ++---
lib/eal/common/eal_common_thread.c | 13 +++++----
lib/eal/common/eal_common_trace.c | 1 +
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/malloc_mp.c | 2 ++
lib/eal/freebsd/eal.c | 18 ++++++-------
lib/eal/freebsd/eal_alarm.c | 12 ++++-----
lib/eal/freebsd/eal_interrupts.c | 6 ++---
lib/eal/freebsd/eal_thread.c | 10 ++++---
lib/eal/include/rte_lcore.h | 6 +++++
lib/eal/include/rte_per_lcore.h | 2 +-
lib/eal/linux/eal.c | 22 ++++++++--------
lib/eal/linux/eal_alarm.c | 10 ++++---
lib/eal/linux/eal_interrupts.c | 8 +++---
lib/eal/linux/eal_thread.c | 11 +++++---
lib/eal/linux/eal_timer.c | 6 ++---
lib/eal/version.map | 4 +--
lib/eal/windows/eal.c | 4 ++-
lib/eal/windows/eal_interrupts.c | 8 +++---
lib/eal/windows/eal_thread.c | 35 ++++---------------------
lib/eal/windows/eal_windows.h | 10 -------
lib/eal/windows/include/rte_windows.h | 1 +
lib/ethdev/rte_ethdev.c | 4 +--
lib/ethdev/rte_ethdev_core.h | 4 +--
lib/ethdev/rte_flow.c | 4 +--
lib/eventdev/rte_event_eth_rx_adapter.c | 1 +
lib/vhost/vhost.c | 1 +
27 files changed, 99 insertions(+), 112 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 9d29696b84..1f6aba498c 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1872,8 +1872,7 @@ eal_auto_detect_cores(struct rte_config *cfg)
unsigned int removed = 0;
rte_cpuset_t affinity_set;
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &affinity_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set))
CPU_ZERO(&affinity_set);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
@@ -1901,8 +1900,7 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
}
RTE_CPU_NOT(cpuset, cpuset);
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &default_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set))
CPU_ZERO(&default_set);
RTE_CPU_AND(cpuset, cpuset, &default_set);
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 79545c67d9..62d28e7b28 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -6,7 +6,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <pthread.h>
+#endif /* RTE_EXEC_ENV_WINDOWS */
+#include <rte_thread.h>
#include <signal.h>
#include <sched.h>
#include <assert.h>
@@ -86,9 +89,8 @@ thread_update_affinity(rte_cpuset_t *cpusetp)
int
rte_thread_set_affinity(rte_cpuset_t *cpusetp)
{
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- cpusetp) != 0) {
- RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+ if (rte_thread_set_affinity_by_id(rte_thread_self(), cpusetp) != 0) {
+ RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
return -1;
}
@@ -166,6 +168,7 @@ __rte_thread_uninit(void)
RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
struct rte_thread_ctrl_params {
void *(*start_routine)(void *);
void *arg;
@@ -258,6 +261,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+#endif
struct rte_thread_ctrl_ctx {
rte_thread_func start_routine;
@@ -357,8 +361,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
- &cpuset) != 0)
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0)
CPU_ZERO(&cpuset);
lcore_id = eal_lcore_non_eal_allocate();
if (lcore_id >= RTE_MAX_LCORE)
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 7bff1cd2ce..94323e2c28 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -7,6 +7,7 @@
#include <sys/queue.h>
#include <regex.h>
+#include <pthread.h>
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 64cf4e81c8..4b95001d7d 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -19,7 +19,7 @@
* Structure storing internal configuration (per-lcore)
*/
struct lcore_config {
- pthread_t thread_id; /**< pthread identifier */
+ rte_thread_t thread_id; /**< pthread identifier */
int pipe_main2worker[2]; /**< communication pipe with main */
int pipe_worker2main[2]; /**< communication pipe with main */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2e597a17a2..7f7109d954 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <sys/time.h>
+#include <pthread.h>
+
#include <rte_alarm.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 6cee5ae369..c92fdaa598 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -669,7 +669,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
@@ -692,7 +692,7 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -856,7 +856,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -868,7 +868,7 @@ rte_eal_init(int argc, char **argv)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- config->main_lcore, thread_id, cpuset,
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -885,7 +885,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -893,10 +893,10 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- rte_thread_setname(lcore_config[i].thread_id, thread_name);
+ rte_thread_name_set(lcore_config[i].thread_id, thread_name);
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index c38b2e04f8..e5d7b130b1 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -37,7 +37,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -156,7 +156,7 @@ eal_alarm_callback(void *arg __rte_unused)
while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -263,8 +263,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
* finish. Otherwise we are trying to cancel
* ourselves - mark it by EINPROGRESS.
*/
- if (pthread_equal(ap->executing_id,
- pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -285,8 +285,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id,
- pthread_self()) == 0) {
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0) {
executing++;
} else {
err = EINPROGRESS;
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 86810845fe..61b6ef1f48 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -628,7 +628,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -737,5 +737,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 1dce9b04f2..8c572c7930 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sched.h>
#include <pthread_np.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <sys/thr.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,7 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (void *)thread_id.opaque_id, cpuset, ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 1550b75da0..8fab21299a 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -362,6 +362,7 @@ __rte_experimental
void
rte_lcore_dump(FILE *f);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Set thread names.
*
@@ -393,6 +394,8 @@ int rte_thread_setname(pthread_t id, const char *name);
__rte_experimental
int rte_thread_getname(pthread_t id, char *name, size_t len);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
/**
* Register current non-EAL thread as a lcore.
*
@@ -417,6 +420,7 @@ __rte_experimental
void
rte_thread_unregister(void);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Create a control thread.
*
@@ -444,6 +448,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index eaedf0cb37..df1e51dcb8 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#include <pthread.h>
+#include <rte_thread.h>
/**
* Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 3577eaeaa4..cd5e9953d0 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -965,7 +965,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
const char *p;
@@ -993,7 +993,7 @@ rte_eal_init(int argc, char **argv)
p = strrchr(argv[0], '/');
strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -1221,7 +1221,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -1231,8 +1231,8 @@ rte_eal_init(int argc, char **argv)
&lcore_config[config->main_lcore].cpuset);
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
- RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->main_lcore, (uintptr_t)thread_id, cpuset,
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -1249,7 +1249,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1257,14 +1257,14 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- ret = rte_thread_setname(lcore_config[i].thread_id,
- thread_name);
+ ret = rte_thread_name_set(lcore_config[i].thread_id,
+ thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 3252c6fa59..fef22a347c 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -48,7 +48,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -86,7 +86,7 @@ eal_alarm_callback(void *arg __rte_unused)
(ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec &&
(ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -207,7 +207,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
/* If calling from other context, mark that alarm is executing
* so loop can spin till it finish. Otherwise we are trying to
* cancel our self - mark it by EINPROGRESS */
- if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -228,7 +229,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 22b3b7bcd9..d8ce854d90 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <unistd.h>
@@ -97,7 +97,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1167,7 +1167,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1570,5 +1570,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index 83c2034b93..91c239a217 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <sched.h>
#include <sys/queue.h>
#include <sys/syscall.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,8 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset,
+ ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 7cf15cabac..dc0308c761 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -12,7 +12,7 @@
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/queue.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <errno.h>
#include <rte_common.h>
@@ -80,7 +80,7 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
@@ -185,7 +185,7 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
+ ret = rte_thread_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc",
hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 67569b1bf9..9a130120e7 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -21,7 +21,7 @@ DPDK_22 {
rte_cpu_get_flag_enabled;
rte_cpu_get_flag_name;
rte_cpu_is_supported; # WINDOWS_NO_EXPORT
- rte_ctrl_thread_create;
+ rte_ctrl_thread_create; # WINDOWS_NO_EXPORT
rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
rte_delay_us;
rte_delay_us_block;
@@ -193,7 +193,7 @@ DPDK_22 {
rte_sys_gettid;
rte_thread_get_affinity;
rte_thread_set_affinity;
- rte_thread_setname;
+ rte_thread_setname; # WINDOWS_NO_EXPORT
rte_uuid_compare; # WINDOWS_NO_EXPORT
rte_uuid_is_null; # WINDOWS_NO_EXPORT
rte_uuid_parse; # WINDOWS_NO_EXPORT
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 3d8c520412..d90c635ddc 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -395,7 +395,9 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- if (eal_thread_create(&lcore_config[i].thread_id) != 0)
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
+ eal_thread_loop, NULL);
+ if (ret != 0)
rte_panic("Cannot create thread\n");
}
diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c
index bb0585cb34..43b0071da0 100644
--- a/lib/eal/windows/eal_interrupts.c
+++ b/lib/eal/windows/eal_interrupts.c
@@ -9,7 +9,7 @@
#define IOCP_KEY_SHUTDOWN UINT32_MAX
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static HANDLE intr_iocp;
static HANDLE intr_thread_handle;
@@ -78,7 +78,7 @@ eal_intr_thread_main(LPVOID arg __rte_unused)
intr_thread_handle = NULL;
cleanup:
- intr_thread = 0;
+ intr_thread.opaque_id = 0;
CloseHandle(intr_iocp);
intr_iocp = NULL;
@@ -98,7 +98,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -111,7 +111,7 @@ rte_eal_intr_init(void)
int
rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
int
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 9c3f6d69fd..fbdb7dbc76 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -60,15 +60,16 @@ eal_thread_loop(void *arg __rte_unused)
char c;
int n, ret;
unsigned int lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -80,7 +81,7 @@ eal_thread_loop(void *arg __rte_unused)
__rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset);
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset);
/* read on our pipe to get commands */
while (1) {
@@ -122,35 +123,9 @@ eal_thread_loop(void *arg __rte_unused)
}
}
-/* function to create threads */
-int
-eal_thread_create(pthread_t *thread)
-{
- HANDLE th;
-
- th = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
- NULL, 0, (LPDWORD)thread);
- if (!th)
- return -1;
-
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
-
- return 0;
-}
-
/* get current thread ID */
int
rte_sys_gettid(void)
{
return GetCurrentThreadId();
}
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
- /* TODO */
- /* This is a stub, not the expected result */
- return 0;
-}
diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h
index 355ef181a5..4ace532aac 100644
--- a/lib/eal/windows/eal_windows.h
+++ b/lib/eal/windows/eal_windows.h
@@ -35,16 +35,6 @@
*/
int eal_create_cpu_map(void);
-/**
- * Create a thread.
- *
- * @param thread
- * The location to store the thread id if successful.
- * @return
- * 0 for success, -1 if the thread is not created.
- */
-int eal_thread_create(pthread_t *thread);
-
/**
* Get system NUMA node number for a socket ID.
*
diff --git a/lib/eal/windows/include/rte_windows.h b/lib/eal/windows/include/rte_windows.h
index 0063b5d78c..d8c4ed10d7 100644
--- a/lib/eal/windows/include/rte_windows.h
+++ b/lib/eal/windows/include/rte_windows.h
@@ -28,6 +28,7 @@
#include <windows.h>
#include <basetsd.h>
+#include <processthreadsapi.h>
#include <psapi.h>
#include <setupapi.h>
#include <winioctl.h>
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 9d95cd11e1..e44e5bb6af 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -526,7 +526,7 @@ rte_eth_dev_allocate(const char *name)
strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
eth_dev->data->port_id = port_id;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ rte_thread_mutex_init(ð_dev->data->flow_ops_mutex);
unlock:
rte_spinlock_unlock(ð_dev_shared_data->ownership_lock);
@@ -600,7 +600,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data->hash_mac_addrs);
rte_free(eth_dev->data->dev_private);
- pthread_mutex_destroy(ð_dev->data->flow_ops_mutex);
+ rte_thread_mutex_destroy(ð_dev->data->flow_ops_mutex);
memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
}
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index edf96de2dc..8c8f83f9e3 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -5,7 +5,7 @@
#ifndef _RTE_ETHDEV_CORE_H_
#define _RTE_ETHDEV_CORE_H_
-#include <pthread.h>
+#include <rte_thread.h>
/**
* @file
@@ -186,7 +186,7 @@ struct rte_eth_dev_data {
* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
*/
- pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
+ rte_thread_mutex flow_ops_mutex; /**< rte_flow ops mutex. */
uint64_t reserved_64s[4]; /**< Reserved for future fields */
void *reserved_ptrs[4]; /**< Reserved for future fields */
} __rte_cache_aligned;
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..4f112d1af7 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -226,14 +226,14 @@ static inline void
fts_enter(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_lock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_lock(&dev->data->flow_ops_mutex);
}
static inline void
fts_exit(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_unlock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_unlock(&dev->data->flow_ops_mutex);
}
static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 13dfb28401..47f10cf5a9 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -7,6 +7,7 @@
#endif
#include <unistd.h>
+#include <pthread.h>
#include <rte_cycles.h>
#include <rte_common.h>
#include <rte_dev.h>
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 355ff37651..a788fb0ed8 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -12,6 +12,7 @@
#include <numaif.h>
#endif
+#include <pthread.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_log.h>
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 5/6] eal: set affinity and priority attributes
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (3 preceding siblings ...)
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
If the user doesn't specify the priority through the command
line arguments, initialize the thread priority to 'normal'.
Set thread priority for eal threads.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
lib/eal/common/eal_common_thread.c | 11 ++++++++
lib/eal/common/eal_thread.h | 6 ++++
lib/eal/freebsd/eal.c | 41 +++++++++++++++++++++++-----
lib/eal/linux/eal.c | 39 +++++++++++++++++++++-----
lib/eal/windows/eal.c | 44 ++++++++++++++++++++++++++++--
5 files changed, 125 insertions(+), 16 deletions(-)
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 62d28e7b28..fa537db7ac 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -388,3 +388,14 @@ rte_thread_unregister(void)
RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n",
lcore_id);
}
+
+void rte_thread_priority_init(void)
+{
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+
+ /* If the user doesn't specify the priority through the command
+ * line arguments, the default 'normal' value will be used.
+ */
+ internal_conf->thread_priority = RTE_THREAD_PRIORITY_NORMAL;
+}
diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h
index 4a49117be8..7b3b884463 100644
--- a/lib/eal/common/eal_thread.h
+++ b/lib/eal/common/eal_thread.h
@@ -58,4 +58,10 @@ eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size);
int
eal_thread_dump_current_affinity(char *str, unsigned int size);
+/**
+ * Set the initial thread priority in the internal configuration
+ * to the default value of RTE_THREAD_PRIORITY_NORMAL.
+ */
+void rte_thread_priority_init(void);
+
#endif /* EAL_THREAD_H */
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index c92fdaa598..1570da2a36 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -678,6 +678,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -856,6 +858,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -871,6 +881,22 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -884,9 +910,15 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
+ if (ret != 0)
+ rte_panic("Cannot set affinity\n");
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -894,11 +926,6 @@ rte_eal_init(int argc, char **argv)
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
rte_thread_name_set(lcore_config[i].thread_id, thread_name);
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index cd5e9953d0..c02390ed58 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -977,6 +977,8 @@ rte_eal_init(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ rte_thread_priority_init();
+
/* checks if the machine is adequate */
if (!rte_cpu_is_supported()) {
rte_eal_init_alert("unsupported cpu type.");
@@ -1221,6 +1223,14 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
@@ -1235,6 +1245,23 @@ rte_eal_init(int argc, char **argv)
config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot initialize thread attributes,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL, "Cannot set thread priority attribute,"
+ "ret = %d\n", ret);
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -1248,9 +1275,12 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1262,11 +1292,6 @@ rte_eal_init(int argc, char **argv)
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
-
- ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
- &lcore_config[i].cpuset);
- if (ret != 0)
- rte_panic("Cannot set affinity\n");
}
/*
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index d90c635ddc..4eca6a3ab6 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -278,6 +278,8 @@ rte_eal_init(int argc, char **argv)
eal_get_internal_configuration();
int ret;
+ rte_thread_priority_init();
+
eal_log_init(NULL, 0);
eal_log_level_parse(argc, argv);
@@ -379,6 +381,36 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
+ &lcore_config[config->main_lcore].cpuset) != 0) {
+ rte_eal_init_alert("Cannot set affinity");
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ ret = rte_thread_set_priority(rte_thread_self(),
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority");
+ rte_errno = ret;
+ return -1;
+ }
+
+ rte_thread_attr_t thread_attr;
+ ret = rte_thread_attr_init(&thread_attr);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot initialize thread attributes");
+ rte_errno = ret;
+ return -1;
+ }
+ ret = rte_thread_attr_set_priority(&thread_attr,
+ internal_conf->thread_priority);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread priority attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
RTE_LCORE_FOREACH_WORKER(i) {
/*
@@ -394,9 +426,17 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
+ ret = rte_thread_attr_set_affinity(&thread_attr,
+ &lcore_config[i].cpuset);
+ if (ret != 0) {
+ rte_eal_init_alert("Cannot set thread affinity attribute");
+ rte_errno = ret;
+ return -1;
+ }
+
/* create a thread for each lcore */
- ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
- eal_thread_loop, NULL);
+ ret = rte_thread_create(&lcore_config[i].thread_id,
+ &thread_attr, eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
}
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 6/6] Allow choice between internal EAL thread API and external lib
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
` (4 preceding siblings ...)
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
@ 2021-08-18 21:19 ` Narcisa Ana Maria Vasile
5 siblings, 0 replies; 30+ messages in thread
From: Narcisa Ana Maria Vasile @ 2021-08-18 21:19 UTC (permalink / raw)
To: dev, thomas, dmitry.kozliuk, khot, navasile, dmitrym, roretzla,
talshn, ocardona
Cc: bruce.richardson, david.marchand, pallavi.kadam
From: Narcisa Vasile <navasile@microsoft.com>
The user is offered the option of either using the RTE_THREAD_* API or
a 3rd party thread library, through a meson flag called
"use_external_thread_lib". By default, this flag is set to FALSE,
which means Windows libraries and applications will use the RTE_THREAD_*
API for managing threads.
If compiling on Windows and the "use_external_thread_lib" is *not* set,
the following files will be parsed:
* include/rte_thread.h
* windows/rte_thread.c
In all other cases, the compilation/parsing includes the following files:
* include/rte_thread.h
* common/rte_thread.c
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
---
config/meson.build | 1 -
lib/eal/windows/include/pthread.h | 192 ------------------------------
lib/eal/windows/meson.build | 7 +-
meson_options.txt | 2 +
4 files changed, 8 insertions(+), 194 deletions(-)
delete mode 100644 lib/eal/windows/include/pthread.h
diff --git a/config/meson.build b/config/meson.build
index e80421003b..912d51582c 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -301,7 +301,6 @@ else # for 32-bit we need smaller reserved memory areas
dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
endif
-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h
deleted file mode 100644
index 27fd2cca52..0000000000
--- a/lib/eal/windows/include/pthread.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019 Intel Corporation
- */
-
-#ifndef _PTHREAD_H_
-#define _PTHREAD_H_
-
-#include <stdint.h>
-#include <sched.h>
-
-/**
- * This file is required to support the common code in eal_common_proc.c,
- * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc
- * does not contain pthread.h. This may be removed in future releases.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_common.h>
-#include <rte_windows.h>
-
-#define PTHREAD_BARRIER_SERIAL_THREAD TRUE
-
-/* defining pthread_t type on Windows since there is no in Microsoft libc*/
-typedef uintptr_t pthread_t;
-
-/* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/
-typedef void *pthread_attr_t;
-
-typedef void *pthread_mutexattr_t;
-
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
-
-#define pthread_barrier_init(barrier, attr, count) \
- !InitializeSynchronizationBarrier(barrier, count, -1)
-#define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
- SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
-#define pthread_barrier_destroy(barrier) \
- !DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
-
-/* pthread function overrides */
-#define pthread_self() \
- ((pthread_t)GetCurrentThreadId())
-
-
-static inline int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- return t1 == t2;
-}
-
-static inline int
-pthread_setaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- DWORD_PTR ret = 0;
- HANDLE thread_handle;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- ret = SetThreadAffinityMask(thread_handle, *cpuset->_bits);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("CloseHandle()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_getaffinity_np(pthread_t threadid, size_t cpuset_size,
- rte_cpuset_t *cpuset)
-{
- /* Workaround for the lack of a GetThreadAffinityMask()
- *API in Windows
- */
- DWORD_PTR prev_affinity_mask;
- HANDLE thread_handle;
- DWORD_PTR ret = 0;
-
- if (cpuset == NULL || cpuset_size == 0)
- return -1;
-
- thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid);
- if (thread_handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread()");
- return -1;
- }
-
- /* obtain previous mask by setting dummy mask */
- prev_affinity_mask = SetThreadAffinityMask(thread_handle, 0x1);
- if (prev_affinity_mask == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- /* set it back! */
- ret = SetThreadAffinityMask(thread_handle, prev_affinity_mask);
- if (ret == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- goto close_handle;
- }
-
- memset(cpuset, 0, cpuset_size);
- *cpuset->_bits = prev_affinity_mask;
-
-close_handle:
- if (CloseHandle(thread_handle) == 0) {
- RTE_LOG_WIN32_ERR("SetThreadAffinityMask()");
- return -1;
- }
- return (ret == 0) ? -1 : 0;
-}
-
-static inline int
-pthread_create(void *threadid, const void *threadattr, void *threadfunc,
- void *args)
-{
- RTE_SET_USED(threadattr);
- HANDLE hThread;
- hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
- args, 0, (LPDWORD)threadid);
- if (hThread) {
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
- }
- return ((hThread != NULL) ? 0 : E_FAIL);
-}
-
-static inline int
-pthread_detach(__rte_unused pthread_t thread)
-{
- return 0;
-}
-
-static inline int
-pthread_join(__rte_unused pthread_t thread,
- __rte_unused void **value_ptr)
-{
- return 0;
-}
-
-static inline int
-pthread_mutex_init(pthread_mutex_t *mutex,
- __rte_unused pthread_mutexattr_t *attr)
-{
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static inline int
-pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PTHREAD_H_ */
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index fc12fefd0d..22c00c3dc8 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -20,7 +20,12 @@ sources += files(
'eal_timer.c',
'fnmatch.c',
'getopt.c',
- 'rte_thread.c',
)
+if get_option('use_external_thread_lib')
+ sources += 'eal/common/rte_thread.c'
+else
+ sources += 'eal/windows/rte_thread.c'
+endif
+
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
diff --git a/meson_options.txt b/meson_options.txt
index 0e92734c49..71f38bf16b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -46,3 +46,5 @@ option('tests', type: 'boolean', value: true, description:
'build unit tests')
option('use_hpet', type: 'boolean', value: false, description:
'use HPET timer in EAL')
+option('use_external_thread_lib', type: 'boolean', value: false,
+ description: 'use an external thread library')
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2021-08-18 21:20 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-20 23:53 ` Dmitry Kozlyuk
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 19:42 ` Tal Shnaiderman
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
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).