FreeBSD/sys/dev/cxgb/cxgb_sge.c
/**
 *	free_qset - free the resources of an SGE queue set
 *	@sc: the controller owning the queue set
 *	@q: the queue set
 *
 *	Release the HW and SW resources associated with an SGE queue set, such
 *	as HW contexts, packet buffers, and descriptor rings.  Traffic to the
 *	queue set must be quiesced prior to calling this.
 */
free the resources of an SGE queue set
@sc: the controller owning the queue set
@q: the queue set

Release the HW and SW resources associated with an SGE queue set, such
as HW contexts, packet buffers, and descriptor rings.  Traffic to the
queue set must be quiesced prior to calling this.
free the resources of an SGE queue set @sc : the controller owning the queue set @q : the queue set Release the HW and SW resources associated with an SGE queue set such as HW contexts packet buffers and descriptor rings . Traffic to the queue set must be quiesced prior to calling this .
static void
t3_free_qset(adapter_t *sc, struct sge_qset *q)
{
	int i;
	reclaim_completed_tx(q, 0, TXQ_ETH);
	if (q->txq[TXQ_ETH].txq_mr != NULL) 
		buf_ring_free(q->txq[TXQ_ETH].txq_mr, M_DEVBUF);
	if (q->txq[TXQ_ETH].txq_ifq != NULL) {
		ifq_delete(q->txq[TXQ_ETH].txq_ifq);
		free(q->txq[TXQ_ETH].txq_ifq, M_DEVBUF);
	}
	for (i = 0; i < SGE_RXQ_PER_SET; ++i) {
		if (q->fl[i].desc) {
			mtx_lock_spin(&sc->sge.reg_lock);
			t3_sge_disable_fl(sc, q->fl[i].cntxt_id);
			mtx_unlock_spin(&sc->sge.reg_lock);
			bus_dmamap_unload(q->fl[i].desc_tag, q->fl[i].desc_map);
			bus_dmamem_free(q->fl[i].desc_tag, q->fl[i].desc,
					q->fl[i].desc_map);
			bus_dma_tag_destroy(q->fl[i].desc_tag);
			bus_dma_tag_destroy(q->fl[i].entry_tag);
		}
		if (q->fl[i].sdesc) {
			free_rx_bufs(sc, &q->fl[i]);
			free(q->fl[i].sdesc, M_DEVBUF);
		}
	}
	mtx_unlock(&q->lock);
	MTX_DESTROY(&q->lock);
	for (i = 0; i < SGE_TXQ_PER_SET; i++) {
		if (q->txq[i].desc) {
			mtx_lock_spin(&sc->sge.reg_lock);
			t3_sge_enable_ecntxt(sc, q->txq[i].cntxt_id, 0);
			mtx_unlock_spin(&sc->sge.reg_lock);
			bus_dmamap_unload(q->txq[i].desc_tag,
					q->txq[i].desc_map);
			bus_dmamem_free(q->txq[i].desc_tag, q->txq[i].desc,
					q->txq[i].desc_map);
			bus_dma_tag_destroy(q->txq[i].desc_tag);
			bus_dma_tag_destroy(q->txq[i].entry_tag);
		}
		if (q->txq[i].sdesc) {
			free(q->txq[i].sdesc, M_DEVBUF);
		}
	}
	if (q->rspq.desc) {
		mtx_lock_spin(&sc->sge.reg_lock);
		t3_sge_disable_rspcntxt(sc, q->rspq.cntxt_id);
		mtx_unlock_spin(&sc->sge.reg_lock);
		bus_dmamap_unload(q->rspq.desc_tag, q->rspq.desc_map);
		bus_dmamem_free(q->rspq.desc_tag, q->rspq.desc,
			        q->rspq.desc_map);
		bus_dma_tag_destroy(q->rspq.desc_tag);
		MTX_DESTROY(&q->rspq.lock);
	}
#if defined(INET6) || defined(INET)
	tcp_lro_free(&q->lro.ctrl);
#endif
	bzero(q, sizeof(*q));
}
static void t3_free_qset ( adapter_t * sc , struct sge_qset * q ) { int i ; reclaim_completed_tx ( q , 0 , TXQ_ETH ) ; if ( q -> txq [ TXQ_ETH ] . txq_mr != NULL ) buf_ring_free ( q -> txq [ TXQ_ETH ] . txq_mr , M_DEVBUF ) ; if ( q -> txq [ TXQ_ETH ] . txq_ifq != NULL ) { ifq_delete ( q -> txq [ TXQ_ETH ] . txq_ifq ) ; free ( q -> txq [ TXQ_ETH ] . txq_ifq , M_DEVBUF ) ; } for ( i = 0 ; i < SGE_RXQ_PER_SET ; ++ i ) { if ( q -> fl [ i ] . desc ) { mtx_lock_spin ( & sc -> sge . reg_lock ) ; t3_sge_disable_fl ( sc , q -> fl [ i ] . cntxt_id ) ; mtx_unlock_spin ( & sc -> sge . reg_lock ) ; bus_dmamap_unload ( q -> fl [ i ] . desc_tag , q -> fl [ i ] . desc_map ) ; bus_dmamem_free ( q -> fl [ i ] . desc_tag , q -> fl [ i ] . desc , q -> fl [ i ] . desc_map ) ; bus_dma_tag_destroy ( q -> fl [ i ] . desc_tag ) ; bus_dma_tag_destroy ( q -> fl [ i ] . entry_tag ) ; } if ( q -> fl [ i ] . sdesc ) { free_rx_bufs ( sc , & q -> fl [ i ] ) ; free ( q -> fl [ i ] . sdesc , M_DEVBUF ) ; } } mtx_unlock ( & q -> lock ) ; MTX_DESTROY ( & q -> lock ) ; for ( i = 0 ; i < SGE_TXQ_PER_SET ; i ++ ) { if ( q -> txq [ i ] . desc ) { mtx_lock_spin ( & sc -> sge . reg_lock ) ; t3_sge_enable_ecntxt ( sc , q -> txq [ i ] . cntxt_id , 0 ) ; mtx_unlock_spin ( & sc -> sge . reg_lock ) ; bus_dmamap_unload ( q -> txq [ i ] . desc_tag , q -> txq [ i ] . desc_map ) ; bus_dmamem_free ( q -> txq [ i ] . desc_tag , q -> txq [ i ] . desc , q -> txq [ i ] . desc_map ) ; bus_dma_tag_destroy ( q -> txq [ i ] . desc_tag ) ; bus_dma_tag_destroy ( q -> txq [ i ] . entry_tag ) ; } if ( q -> txq [ i ] . sdesc ) { free ( q -> txq [ i ] . sdesc , M_DEVBUF ) ; } } if ( q -> rspq . desc ) { mtx_lock_spin ( & sc -> sge . reg_lock ) ; t3_sge_disable_rspcntxt ( sc , q -> rspq . cntxt_id ) ; mtx_unlock_spin ( & sc -> sge . reg_lock ) ; bus_dmamap_unload ( q -> rspq . desc_tag , q -> rspq . desc_map ) ; bus_dmamem_free ( q -> rspq . desc_tag , q -> rspq . desc , q -> rspq . desc_map ) ; bus_dma_tag_destroy ( q -> rspq . desc_tag ) ; MTX_DESTROY ( & q -> rspq . lock ) ; } #if defined ( INET6 ) || defined ( INET ) tcp_lro_free ( & q -> lro . ctrl ) ; #endif bzero ( q , sizeof ( * q ) ) ; }
free_qset - free the resources of an SGE queue set
      @sc: the controller owning the queue set
      @q: the queue set
free_qset - free the resources of an SGE queue set @sc : the controller owning the queue set @q : the queue set