[qca-nss-drv] stats_drv: Replace spinlocks with atomic operations
When reading or updating stats_drv, we can use atomic operations
instead of spinlocks as it improves performance on the slow path.
Change-Id: I246e3cc965780b631aac72e2ae0cfba845601bac
Signed-off-by: Sundarajan Srinivasan <sundaraj@codeaurora.org>
diff --git a/nss_if.c b/nss_if.c
index 42c4f9d..b64f521 100644
--- a/nss_if.c
+++ b/nss_if.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -153,9 +153,7 @@
nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
if (unlikely(!nbuf)) {
- spin_lock_bh(&nss_ctx->nss_top->stats_lock);
- nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]++;
- spin_unlock_bh(&nss_ctx->nss_top->stats_lock);
+ NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]);
nss_warning("%p: interface %p: command allocation failed", nss_ctx, dev);
return NSS_TX_FAILURE;
}