FreeBSD/sys/dev/vxge/vxge.c
/*
 * Creates DMA tags for both Tx and Rx
 */
Creates DMA tags for both Tx and Rx
Creates DMA tags for both Tx and Rx
int
vxge_dma_tags_create(vxge_vpath_t *vpath)
{
	int err = 0;
	bus_size_t max_size, boundary;
	vxge_dev_t *vdev = vpath->vdev;
	ifnet_t ifp = vdev->ifp;
	max_size = ifp->if_mtu +
	    VXGE_HAL_MAC_HEADER_MAX_SIZE +
	    VXGE_HAL_HEADER_ETHERNET_II_802_3_ALIGN;
	VXGE_BUFFER_ALIGN(max_size, 128)
	if (max_size <= MCLBYTES)
		vdev->rx_mbuf_sz = MCLBYTES;
	else
		vdev->rx_mbuf_sz =
		    (max_size > MJUMPAGESIZE) ? MJUM9BYTES : MJUMPAGESIZE;
	boundary = (max_size > PAGE_SIZE) ? 0 : PAGE_SIZE;
	err = bus_dma_tag_create(
	    bus_get_dma_tag(vdev->ndev),
	    1,
	    PAGE_SIZE,
	    BUS_SPACE_MAXADDR,
	    BUS_SPACE_MAXADDR,
	    NULL,
	    NULL,
	    VXGE_TSO_SIZE,
	    VXGE_MAX_SEGS,
	    PAGE_SIZE,
	    BUS_DMA_ALLOCNOW,
	    NULL,
	    NULL,
	    &(vpath->dma_tag_tx));
	if (err != 0)
		goto _exit0;
	err = bus_dma_tag_create(
	    bus_get_dma_tag(vdev->ndev),
	    1,
	    boundary,
	    BUS_SPACE_MAXADDR,
	    BUS_SPACE_MAXADDR,
	    NULL,
	    NULL,
	    vdev->rx_mbuf_sz,
	    1,
	    vdev->rx_mbuf_sz,
	    BUS_DMA_ALLOCNOW,
	    NULL,
	    NULL,
	    &(vpath->dma_tag_rx));
	if (err != 0)
		goto _exit1;
	err = bus_dmamap_create(vpath->dma_tag_rx, BUS_DMA_NOWAIT,
	    &vpath->extra_dma_map);
	if (err == 0)
		goto _exit0;
	bus_dma_tag_destroy(vpath->dma_tag_rx);
_exit1:
	bus_dma_tag_destroy(vpath->dma_tag_tx);
_exit0:
	return (err);
}
int vxge_dma_tags_create ( vxge_vpath_t * vpath ) { int err = 0 ; bus_size_t max_size , boundary ; vxge_dev_t * vdev = vpath -> vdev ; ifnet_t ifp = vdev -> ifp ; max_size = ifp -> if_mtu + VXGE_HAL_MAC_HEADER_MAX_SIZE + VXGE_HAL_HEADER_ETHERNET_II_802_3_ALIGN ; VXGE_BUFFER_ALIGN ( max_size , 128 ) if ( max_size <= MCLBYTES ) vdev -> rx_mbuf_sz = MCLBYTES ; else vdev -> rx_mbuf_sz = ( max_size > MJUMPAGESIZE ) ? MJUM9BYTES : MJUMPAGESIZE ; boundary = ( max_size > PAGE_SIZE ) ? 0 : PAGE_SIZE ; err = bus_dma_tag_create ( bus_get_dma_tag ( vdev -> ndev ) , 1 , PAGE_SIZE , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , VXGE_TSO_SIZE , VXGE_MAX_SEGS , PAGE_SIZE , BUS_DMA_ALLOCNOW , NULL , NULL , & ( vpath -> dma_tag_tx ) ) ; if ( err != 0 ) goto _exit0 ; err = bus_dma_tag_create ( bus_get_dma_tag ( vdev -> ndev ) , 1 , boundary , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , vdev -> rx_mbuf_sz , 1 , vdev -> rx_mbuf_sz , BUS_DMA_ALLOCNOW , NULL , NULL , & ( vpath -> dma_tag_rx ) ) ; if ( err != 0 ) goto _exit1 ; err = bus_dmamap_create ( vpath -> dma_tag_rx , BUS_DMA_NOWAIT , & vpath -> extra_dma_map ) ; if ( err == 0 ) goto _exit0 ; bus_dma_tag_destroy ( vpath -> dma_tag_rx ) ; _exit1 : bus_dma_tag_destroy ( vpath -> dma_tag_tx ) ; _exit0 : return ( err ) ; }
Creates DMA tags for both Tx and Rx
Creates DMA tags for both Tx and Rx
/* DMA tag for Tx */ /* DMA tag for Rx */ /* Create DMA map for this descriptor */