1014 rx_msg_p, hxge_mblks_pending));
1015
1016 if (ring == NULL)
1017 return;
1018
1019 /*
1020 * This is to prevent posting activities while we are recovering
1021 * from fatal errors. This should not be a performance drag since
1022 * ref_cnt != 0 most times.
1023 */
1024 if (ring->rbr_state == RBR_POSTING)
1025 MUTEX_ENTER(&ring->post_lock);
1026
1027 /*
1028 * First we need to get the free state, then
1029 * atomic decrement the reference count to prevent
1030 * the race condition with the interrupt thread that
1031 * is processing a loaned up buffer block.
1032 */
1033 free_state = rx_msg_p->free;
1034 ref_cnt = atomic_add_32_nv(&rx_msg_p->ref_cnt, -1);
1035 if (!ref_cnt) {
1036 atomic_dec_32(&hxge_mblks_pending);
1037
1038 buffer = rx_msg_p->buffer;
1039 size = rx_msg_p->block_size;
1040
1041 HXGE_DEBUG_MSG((NULL, MEM2_CTL, "hxge_freeb: "
1042 "will free: rx_msg_p = $%p (block pending %d)",
1043 rx_msg_p, hxge_mblks_pending));
1044
1045 if (!rx_msg_p->use_buf_pool) {
1046 KMEM_FREE(buffer, size);
1047 }
1048
1049 KMEM_FREE(rx_msg_p, sizeof (rx_msg_t));
1050 /*
1051 * Decrement the receive buffer ring's reference
1052 * count, too.
1053 */
1054 atomic_dec_32(&ring->rbr_ref_cnt);
|
1014 rx_msg_p, hxge_mblks_pending));
1015
1016 if (ring == NULL)
1017 return;
1018
1019 /*
1020 * This is to prevent posting activities while we are recovering
1021 * from fatal errors. This should not be a performance drag since
1022 * ref_cnt != 0 most times.
1023 */
1024 if (ring->rbr_state == RBR_POSTING)
1025 MUTEX_ENTER(&ring->post_lock);
1026
1027 /*
1028 * First we need to get the free state, then
1029 * atomic decrement the reference count to prevent
1030 * the race condition with the interrupt thread that
1031 * is processing a loaned up buffer block.
1032 */
1033 free_state = rx_msg_p->free;
1034 ref_cnt = atomic_dec_32_nv(&rx_msg_p->ref_cnt);
1035 if (!ref_cnt) {
1036 atomic_dec_32(&hxge_mblks_pending);
1037
1038 buffer = rx_msg_p->buffer;
1039 size = rx_msg_p->block_size;
1040
1041 HXGE_DEBUG_MSG((NULL, MEM2_CTL, "hxge_freeb: "
1042 "will free: rx_msg_p = $%p (block pending %d)",
1043 rx_msg_p, hxge_mblks_pending));
1044
1045 if (!rx_msg_p->use_buf_pool) {
1046 KMEM_FREE(buffer, size);
1047 }
1048
1049 KMEM_FREE(rx_msg_p, sizeof (rx_msg_t));
1050 /*
1051 * Decrement the receive buffer ring's reference
1052 * count, too.
1053 */
1054 atomic_dec_32(&ring->rbr_ref_cnt);
|