* Adds given value to an mbuf's refcnt and returns its new value. * @param m * Mbuf to update * @param value * Value to add/subtract * @return * Updated value */
| 395 | * Updated value |
| 396 | */ |
| 397 | static inline uint16_t |
| 398 | rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) |
| 399 | { |
| 400 | /* |
| 401 | * The atomic_add is an expensive operation, so we don't want to |
| 402 | * call it in the case where we know we are the unique holder of |
| 403 | * this mbuf (i.e. ref_cnt == 1). Otherwise, an atomic |
| 404 | * operation has to be used because concurrent accesses on the |
| 405 | * reference counter can occur. |
| 406 | */ |
| 407 | if (likely(rte_mbuf_refcnt_read(m) == 1)) { |
| 408 | ++value; |
| 409 | rte_mbuf_refcnt_set(m, (uint16_t)value); |
| 410 | return (uint16_t)value; |
| 411 | } |
| 412 | |
| 413 | return __rte_mbuf_refcnt_update(m, value); |
| 414 | } |
| 415 | |
| 416 | #else /* ! RTE_MBUF_REFCNT_ATOMIC */ |
| 417 |
no test coverage detected