mbuf: use C11 atomic builtins for refcnt
[dpdk.git] / lib / librte_mbuf / rte_mbuf.c
index 56a1a98..8a456e5 100644 (file)
@@ -22,7 +22,6 @@
 #include <rte_eal.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
-#include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
@@ -77,9 +76,9 @@ rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg)
  */
 void
 rte_pktmbuf_init(struct rte_mempool *mp,
-                __attribute__((unused)) void *opaque_arg,
+                __rte_unused void *opaque_arg,
                 void *_m,
-                __attribute__((unused)) unsigned i)
+                __rte_unused unsigned i)
 {
        struct rte_mbuf *m = _m;
        uint32_t mbuf_size, buf_len, priv_size;
@@ -118,7 +117,8 @@ rte_pktmbuf_init(struct rte_mempool *mp,
  * indirect buffer) mbufs on detaching from the mbuf with pinned external
  * buffer.
  */
-static void rte_pktmbuf_free_pinned_extmem(void *addr, void *opaque)
+static void
+rte_pktmbuf_free_pinned_extmem(void *addr, void *opaque)
 {
        struct rte_mbuf *m = opaque;
 
@@ -166,7 +166,7 @@ static void
 __rte_pktmbuf_init_extmem(struct rte_mempool *mp,
                          void *opaque_arg,
                          void *_m,
-                         __attribute__((unused)) unsigned int i)
+                         __rte_unused unsigned int i)
 {
        struct rte_mbuf *m = _m;
        struct rte_pktmbuf_extmem_init_ctx *ctx = opaque_arg;
@@ -190,14 +190,14 @@ __rte_pktmbuf_init_extmem(struct rte_mempool *mp,
        ext_mem = ctx->ext_mem + ctx->ext;
 
        RTE_ASSERT(ctx->ext < ctx->ext_num);
-       RTE_ASSERT(ctx->off < ext_mem->buf_len);
+       RTE_ASSERT(ctx->off + ext_mem->elt_size <= ext_mem->buf_len);
 
        m->buf_addr = RTE_PTR_ADD(ext_mem->buf_ptr, ctx->off);
        m->buf_iova = ext_mem->buf_iova == RTE_BAD_IOVA ?
                      RTE_BAD_IOVA : (ext_mem->buf_iova + ctx->off);
 
        ctx->off += ext_mem->elt_size;
-       if (ctx->off >= ext_mem->buf_len) {
+       if (ctx->off + ext_mem->elt_size > ext_mem->buf_len) {
                ctx->off = 0;
                ++ctx->ext;
        }