summaryrefslogtreecommitdiffstats
path: root/src/vnet/mfib
diff options
context:
space:
mode:
authorSirshak Das <sirshak.das@arm.com>2018-10-03 22:53:51 +0000
committerDamjan Marion <dmarion@me.com>2018-10-19 07:10:47 +0000
commit2f6d7bb93c157b874efb79a2d1583a4c368bf89a (patch)
tree05dc2867c598cbb8d711f074b4b0eb62dd464f41 /src/vnet/mfib
parentbf3443b0f852f5a4c551d12f926defbd047f2161 (diff)
vppinfra: add atomic macros for __sync builtins
This is first part of addition of atomic macros with only macros for __sync builtins. - Based on earlier patch by Damjan (https://gerrit.fd.io/r/#/c/10729/) Additionally - clib_atomic_release macro added and used in the absence of any memory barrier. - clib_atomic_bool_cmp_and_swap added Change-Id: Ie4e48c1e184a652018d1d0d87c4be80ddd180a3b Original-patch-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Sirshak Das <sirshak.das@arm.com> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com> Reviewed-by: Steve Capper <steve.capper@arm.com>
Diffstat (limited to 'src/vnet/mfib')
-rw-r--r--src/vnet/mfib/mfib_forward.c4
-rw-r--r--src/vnet/mfib/mfib_signal.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/vnet/mfib/mfib_forward.c b/src/vnet/mfib/mfib_forward.c
index 3d0e0d47996..4b121324fb6 100644
--- a/src/vnet/mfib/mfib_forward.c
+++ b/src/vnet/mfib/mfib_forward.c
@@ -300,8 +300,8 @@ mfib_forward_itf_signal (vlib_main_t *vm,
{
mfib_itf_flags_t old_flags;
- old_flags = __sync_fetch_and_or(&mfi->mfi_flags,
- MFIB_ITF_FLAG_SIGNAL_PRESENT);
+ old_flags = clib_atomic_fetch_or(&mfi->mfi_flags,
+ MFIB_ITF_FLAG_SIGNAL_PRESENT);
if (!(old_flags & MFIB_ITF_FLAG_SIGNAL_PRESENT))
{
diff --git a/src/vnet/mfib/mfib_signal.c b/src/vnet/mfib/mfib_signal.c
index ce9a664c548..176e8ec9114 100644
--- a/src/vnet/mfib/mfib_signal.c
+++ b/src/vnet/mfib/mfib_signal.c
@@ -71,14 +71,14 @@ mfib_signal_module_init (void)
static inline void
mfib_signal_lock_aquire (void)
{
- while (__sync_lock_test_and_set (&mfib_signal_pending.mip_lock, 1))
+ while (clib_atomic_test_and_set (&mfib_signal_pending.mip_lock))
;
}
static inline void
mfib_signal_lock_release (void)
{
- mfib_signal_pending.mip_lock = 0;
+ clib_atomic_release(&mfib_signal_pending.mip_lock);
}
#define MFIB_SIGNAL_CRITICAL_SECTION(_body) \
@@ -117,8 +117,8 @@ mfib_signal_send_one (struct vl_api_registration_ *reg,
mfs = pool_elt_at_index(mfib_signal_pool, si);
mfi = mfib_itf_get(mfs->mfs_itf);
mfi->mfi_si = INDEX_INVALID;
- __sync_fetch_and_and(&mfi->mfi_flags,
- ~MFIB_ITF_FLAG_SIGNAL_PRESENT);
+ clib_atomic_fetch_and(&mfi->mfi_flags,
+ ~MFIB_ITF_FLAG_SIGNAL_PRESENT);
vl_mfib_signal_send_one(reg, context, mfs);