FreeBSD/sys/dev/ixl/ixl_txrx.c
/*********************************************************************
 *
 *  Allocate memory for rx_buffer structures. Since we use one
 *  rx_buffer per descriptor, the maximum number of rx_buffer's
 *  that we'll need is equal to the number of receive descriptors
 *  that we've defined.
 *
 **********************************************************************/
Allocate memory for rx_buffer structures. Since we use one
rx_buffer per descriptor, the maximum number of rx_buffer's
that we'll need is equal to the number of receive descriptors
that we've defined.
Allocate memory for rx_buffer structures . Since we use one rx_buffer per descriptor the maximum number of rx_buffer ' s that we ' ll need is equal to the number of receive descriptors that we ' ve defined .
int
ixl_allocate_rx_data(struct ixl_queue *que)
{
	struct rx_ring		*rxr = &que->rxr;
	struct ixl_vsi		*vsi = que->vsi;
	device_t 		dev = vsi->dev;
	struct ixl_rx_buf 	*buf;
	int             	i, bsize, error;
	bsize = sizeof(struct ixl_rx_buf) * que->num_desc;
	if (!(rxr->buffers =
	    (struct ixl_rx_buf *) malloc(bsize,
	    M_DEVBUF, M_NOWAIT | M_ZERO))) {
		device_printf(dev, "Unable to allocate rx_buffer memory\n");
		error = ENOMEM;
		return (error);
	}
	if ((error = bus_dma_tag_create(NULL,	
				   1, 0,	
				   BUS_SPACE_MAXADDR,	
				   BUS_SPACE_MAXADDR,	
				   NULL, NULL,		
				   MSIZE,		
				   1,			
				   MSIZE,		
				   0,			
				   NULL,		
				   NULL,		
				   &rxr->htag))) {
		device_printf(dev, "Unable to create RX DMA htag\n");
		return (error);
	}
	if ((error = bus_dma_tag_create(NULL,	
				   1, 0,	
				   BUS_SPACE_MAXADDR,	
				   BUS_SPACE_MAXADDR,	
				   NULL, NULL,		
				   MJUM16BYTES,		
				   1,			
				   MJUM16BYTES,		
				   0,			
				   NULL,		
				   NULL,		
				   &rxr->ptag))) {
		device_printf(dev, "Unable to create RX DMA ptag\n");
		return (error);
	}
	for (i = 0; i < que->num_desc; i++) {
		buf = &rxr->buffers[i];
		error = bus_dmamap_create(rxr->htag,
		    BUS_DMA_NOWAIT, &buf->hmap);
		if (error) {
			device_printf(dev, "Unable to create RX head map\n");
			break;
		}
		error = bus_dmamap_create(rxr->ptag,
		    BUS_DMA_NOWAIT, &buf->pmap);
		if (error) {
			device_printf(dev, "Unable to create RX pkt map\n");
			break;
		}
	}
	return (error);
}
int ixl_allocate_rx_data ( struct ixl_queue * que ) { struct rx_ring * rxr = & que -> rxr ; struct ixl_vsi * vsi = que -> vsi ; device_t dev = vsi -> dev ; struct ixl_rx_buf * buf ; int i , bsize , error ; bsize = sizeof ( struct ixl_rx_buf ) * que -> num_desc ; if ( ! ( rxr -> buffers = ( struct ixl_rx_buf * ) malloc ( bsize , M_DEVBUF , M_NOWAIT | M_ZERO ) ) ) { device_printf ( dev , " \n " ) ; error = ENOMEM ; return ( error ) ; } if ( ( error = bus_dma_tag_create ( NULL , 1 , 0 , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , MSIZE , 1 , MSIZE , 0 , NULL , NULL , & rxr -> htag ) ) ) { device_printf ( dev , " \n " ) ; return ( error ) ; } if ( ( error = bus_dma_tag_create ( NULL , 1 , 0 , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , MJUM16BYTES , 1 , MJUM16BYTES , 0 , NULL , NULL , & rxr -> ptag ) ) ) { device_printf ( dev , " \n " ) ; return ( error ) ; } for ( i = 0 ; i < que -> num_desc ; i ++ ) { buf = & rxr -> buffers [ i ] ; error = bus_dmamap_create ( rxr -> htag , BUS_DMA_NOWAIT , & buf -> hmap ) ; if ( error ) { device_printf ( dev , " \n " ) ; break ; } error = bus_dmamap_create ( rxr -> ptag , BUS_DMA_NOWAIT , & buf -> pmap ) ; if ( error ) { device_printf ( dev , " \n " ) ; break ; } } return ( error ) ; }
Allocate memory for rx_buffer structures.
Allocate memory for rx_buffer structures .
/* parent */ /* alignment, bounds */ /* lowaddr */ /* highaddr */ /* filter, filterarg */ /* maxsize */ /* nsegments */ /* maxsegsize */ /* flags */ /* lockfunc */ /* lockfuncarg */ /* parent */ /* alignment, bounds */ /* lowaddr */ /* highaddr */ /* filter, filterarg */ /* maxsize */ /* nsegments */ /* maxsegsize */ /* flags */ /* lockfunc */ /* lockfuncarg */