Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


1667 {
1668         size_t size;
1669         uchar_t *buffer = NULL;
1670         int ref_cnt;
1671         boolean_t free_state = B_FALSE;
1672 
1673         rx_rbr_ring_t *ring = rx_msg_p->rx_rbr_p;
1674 
1675         NXGE_DEBUG_MSG((NULL, MEM2_CTL, "==> nxge_freeb"));
1676         NXGE_DEBUG_MSG((NULL, MEM2_CTL,
1677             "nxge_freeb:rx_msg_p = $%p (block pending %d)",
1678             rx_msg_p, nxge_mblks_pending));
1679 
1680         /*
1681          * First we need to get the free state, then
1682          * atomic decrement the reference count to prevent
1683          * the race condition with the interrupt thread that
1684          * is processing a loaned up buffer block.
1685          */
1686         free_state = rx_msg_p->free;
1687         ref_cnt = atomic_add_32_nv(&rx_msg_p->ref_cnt, -1);
1688         if (!ref_cnt) {
1689                 atomic_dec_32(&nxge_mblks_pending);
1690                 buffer = rx_msg_p->buffer;
1691                 size = rx_msg_p->block_size;
1692                 NXGE_DEBUG_MSG((NULL, MEM2_CTL, "nxge_freeb: "
1693                     "will free: rx_msg_p = $%p (block pending %d)",
1694                     rx_msg_p, nxge_mblks_pending));
1695 
1696                 if (!rx_msg_p->use_buf_pool) {
1697                         KMEM_FREE(buffer, size);
1698                 }
1699 
1700                 KMEM_FREE(rx_msg_p, sizeof (rx_msg_t));
1701 
1702                 if (ring) {
1703                         /*
1704                          * Decrement the receive buffer ring's reference
1705                          * count, too.
1706                          */
1707                         atomic_dec_32(&ring->rbr_ref_cnt);




1667 {
1668         size_t size;
1669         uchar_t *buffer = NULL;
1670         int ref_cnt;
1671         boolean_t free_state = B_FALSE;
1672 
1673         rx_rbr_ring_t *ring = rx_msg_p->rx_rbr_p;
1674 
1675         NXGE_DEBUG_MSG((NULL, MEM2_CTL, "==> nxge_freeb"));
1676         NXGE_DEBUG_MSG((NULL, MEM2_CTL,
1677             "nxge_freeb:rx_msg_p = $%p (block pending %d)",
1678             rx_msg_p, nxge_mblks_pending));
1679 
1680         /*
1681          * First we need to get the free state, then
1682          * atomic decrement the reference count to prevent
1683          * the race condition with the interrupt thread that
1684          * is processing a loaned up buffer block.
1685          */
1686         free_state = rx_msg_p->free;
1687         ref_cnt = atomic_dec_32_nv(&rx_msg_p->ref_cnt);
1688         if (!ref_cnt) {
1689                 atomic_dec_32(&nxge_mblks_pending);
1690                 buffer = rx_msg_p->buffer;
1691                 size = rx_msg_p->block_size;
1692                 NXGE_DEBUG_MSG((NULL, MEM2_CTL, "nxge_freeb: "
1693                     "will free: rx_msg_p = $%p (block pending %d)",
1694                     rx_msg_p, nxge_mblks_pending));
1695 
1696                 if (!rx_msg_p->use_buf_pool) {
1697                         KMEM_FREE(buffer, size);
1698                 }
1699 
1700                 KMEM_FREE(rx_msg_p, sizeof (rx_msg_t));
1701 
1702                 if (ring) {
1703                         /*
1704                          * Decrement the receive buffer ring's reference
1705                          * count, too.
1706                          */
1707                         atomic_dec_32(&ring->rbr_ref_cnt);