From: Phil Yang Date: Thu, 24 Sep 2020 05:39:26 +0000 (+0800) Subject: bbdev: use C11 atomics for device processing counter X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b5bafde26cca534be643859169b45e8249a39787;p=dpdk.git bbdev: use C11 atomics for device processing counter Since rte_atomicXX APIs are not allowed to be used, use C11 atomic builtins for device processing counter. Signed-off-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli Acked-by: Nicolas Chautru --- diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c index a4fdb6905b..5ba891c232 100644 --- a/lib/librte_bbdev/rte_bbdev.c +++ b/lib/librte_bbdev/rte_bbdev.c @@ -210,7 +210,7 @@ rte_bbdev_allocate(const char *name) return NULL; } - rte_atomic16_inc(&bbdev->data->process_cnt); + __atomic_add_fetch(&bbdev->data->process_cnt, 1, __ATOMIC_RELAXED); bbdev->data->dev_id = dev_id; bbdev->state = RTE_BBDEV_INITIALIZED; @@ -252,7 +252,8 @@ rte_bbdev_release(struct rte_bbdev *bbdev) } /* clear shared BBDev Data if no process is using the device anymore */ - if (rte_atomic16_dec_and_test(&bbdev->data->process_cnt)) + if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1, + __ATOMIC_RELAXED) == 0) memset(bbdev->data, 0, sizeof(*bbdev->data)); memset(bbdev, 0, sizeof(*bbdev)); diff --git a/lib/librte_bbdev/rte_bbdev.h b/lib/librte_bbdev/rte_bbdev.h index 57291373fa..7017124414 100644 --- a/lib/librte_bbdev/rte_bbdev.h +++ b/lib/librte_bbdev/rte_bbdev.h @@ -33,7 +33,6 @@ extern "C" { #include #include -#include #include #include #include @@ -426,8 +425,7 @@ struct rte_bbdev_data { uint16_t dev_id; /**< Device ID */ int socket_id; /**< NUMA socket that device is on */ bool started; /**< Device run-time state */ - /** Counter of processes using the device */ - rte_atomic16_t process_cnt; + uint16_t process_cnt; /** Counter of processes using the device */ }; /* Forward declarations */