FreeBSD/sys/dev/ixl/ixl_txrx.c
/*********************************************************************
 *
 *  Allocate memory for tx_buffer structures. The tx_buffer stores all
 *  the information needed to transmit a packet on the wire. This is
 *  called only once at attach, setup is done every reset.
 *
 **********************************************************************/
Allocate memory for tx_buffer structures. The tx_buffer stores all
the information needed to transmit a packet on the wire. This is
called only once at attach, setup is done every reset.
Allocate memory for tx_buffer structures . The tx_buffer stores all the information needed to transmit a packet on the wire . This is called only once at attach setup is done every reset .
int
ixl_allocate_tx_data(struct ixl_queue *que)
{
	struct tx_ring		*txr = &que->txr;
	struct ixl_vsi		*vsi = que->vsi;
	device_t		dev = vsi->dev;
	struct ixl_tx_buf	*buf;
	int			error = 0;
	if ((error = bus_dma_tag_create(NULL,		
			       1, 0,			
			       BUS_SPACE_MAXADDR,	
			       BUS_SPACE_MAXADDR,	
			       NULL, NULL,		
			       IXL_TSO_SIZE,		
			       IXL_MAX_TX_SEGS,		
			       PAGE_SIZE,		
			       0,			
			       NULL,			
			       NULL,			
			       &txr->tx_tag))) {
		device_printf(dev,"Unable to allocate TX DMA tag\n");
		goto fail;
	}
	if ((error = bus_dma_tag_create(NULL,		
			       1, 0,			
			       BUS_SPACE_MAXADDR,	
			       BUS_SPACE_MAXADDR,	
			       NULL, NULL,		
			       IXL_TSO_SIZE,		
			       IXL_MAX_TSO_SEGS,	
			       PAGE_SIZE,		
			       0,			
			       NULL,			
			       NULL,			
			       &txr->tso_tag))) {
		device_printf(dev,"Unable to allocate TX TSO DMA tag\n");
		goto fail;
	}
	if (!(txr->buffers =
	    (struct ixl_tx_buf *) malloc(sizeof(struct ixl_tx_buf) *
	    que->num_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
		device_printf(dev, "Unable to allocate tx_buffer memory\n");
		error = ENOMEM;
		goto fail;
	}
	buf = txr->buffers;
	for (int i = 0; i < que->num_desc; i++, buf++) {
		buf->tag = txr->tx_tag;
		error = bus_dmamap_create(buf->tag, 0, &buf->map);
		if (error != 0) {
			device_printf(dev, "Unable to create TX DMA map\n");
			goto fail;
		}
	}
fail:
	return (error);
}
int ixl_allocate_tx_data ( struct ixl_queue * que ) { struct tx_ring * txr = & que -> txr ; struct ixl_vsi * vsi = que -> vsi ; device_t dev = vsi -> dev ; struct ixl_tx_buf * buf ; int error = 0 ; if ( ( error = bus_dma_tag_create ( NULL , 1 , 0 , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , IXL_TSO_SIZE , IXL_MAX_TX_SEGS , PAGE_SIZE , 0 , NULL , NULL , & txr -> tx_tag ) ) ) { device_printf ( dev , " \n " ) ; goto fail ; } if ( ( error = bus_dma_tag_create ( NULL , 1 , 0 , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , IXL_TSO_SIZE , IXL_MAX_TSO_SEGS , PAGE_SIZE , 0 , NULL , NULL , & txr -> tso_tag ) ) ) { device_printf ( dev , " \n " ) ; goto fail ; } if ( ! ( txr -> buffers = ( struct ixl_tx_buf * ) malloc ( sizeof ( struct ixl_tx_buf ) * que -> num_desc , M_DEVBUF , M_NOWAIT | M_ZERO ) ) ) { device_printf ( dev , " \n " ) ; error = ENOMEM ; goto fail ; } buf = txr -> buffers ; for ( int i = 0 ; i < que -> num_desc ; i ++ , buf ++ ) { buf -> tag = txr -> tx_tag ; error = bus_dmamap_create ( buf -> tag , 0 , & buf -> map ) ; if ( error != 0 ) { device_printf ( dev , " \n " ) ; goto fail ; } } fail : return ( error ) ; }
Allocate memory for tx_buffer structures.
Allocate memory for tx_buffer structures .
/*
	 * Setup DMA descriptor areas.
	 */ /* parent */ /* alignment, bounds */ /* lowaddr */ /* highaddr */ /* filter, filterarg */ /* maxsize */ /* nsegments */ /* maxsegsize */ /* flags */ /* lockfunc */ /* lockfuncarg */ /* Make a special tag for TSO */ /* parent */ /* alignment, bounds */ /* lowaddr */ /* highaddr */ /* filter, filterarg */ /* maxsize */ /* nsegments */ /* maxsegsize */ /* flags */ /* lockfunc */ /* lockfuncarg */ /* Create the descriptor buffer default dma maps */