FreeBSD/sys/dev/ixl/ixl_pf_qmgr.c
/*
 * NB: indices is u16 because this is the queue index width used in the Add VSI AQ command
 */
indices is u16 because this is the queue index width used in the Add VSI AQ command
indices is u16 because this is the queue index width used in the Add VSI AQ command
int
ixl_pf_qmgr_alloc_scattered(struct ixl_pf_qmgr *qmgr, u16 num, struct ixl_pf_qtag *qtag)
{
	int i;
	int avail, count = 0;
	u16 alloc_size;
	if (qtag == NULL || num < 1 || num > 16)
		return (EINVAL);
	alloc_size = (u16)next_power_of_two(num);
	avail = ixl_pf_qmgr_get_num_free(qmgr);
	if (avail < alloc_size)
		return (ENOSPC);
	bzero(qtag, sizeof(*qtag));
	qtag->qmgr = qmgr;
	qtag->type = IXL_PF_QALLOC_SCATTERED;
	qtag->num_active = num;
	qtag->num_allocated = alloc_size;
	for (i = 0; i < qmgr->num_queues; i++) {
		if (!qmgr->qinfo[i].allocated) {
			qtag->qidx[count] = i;
			count++;
			qmgr->qinfo[i].allocated = true;
			if (count == alloc_size)
				return (0);
		}
	}
	return (EDOOFUS);
}
int ixl_pf_qmgr_alloc_scattered ( struct ixl_pf_qmgr * qmgr , u16 num , struct ixl_pf_qtag * qtag ) { int i ; int avail , count = 0 ; u16 alloc_size ; if ( qtag == NULL || num < 1 || num > 16 ) return ( EINVAL ) ; alloc_size = ( u16 ) next_power_of_two ( num ) ; avail = ixl_pf_qmgr_get_num_free ( qmgr ) ; if ( avail < alloc_size ) return ( ENOSPC ) ; bzero ( qtag , sizeof ( * qtag ) ) ; qtag -> qmgr = qmgr ; qtag -> type = IXL_PF_QALLOC_SCATTERED ; qtag -> num_active = num ; qtag -> num_allocated = alloc_size ; for ( i = 0 ; i < qmgr -> num_queues ; i ++ ) { if ( ! qmgr -> qinfo [ i ] . allocated ) { qtag -> qidx [ count ] = i ; count ++ ; qmgr -> qinfo [ i ] . allocated = true ; if ( count == alloc_size ) return ( 0 ) ; } } return ( EDOOFUS ) ; }
NB: indices is u16 because this is the queue index width used in the Add VSI AQ command
NB : indices is u16 because this is the queue index width used in the Add VSI AQ command
/* We have to allocate in power-of-two chunks, so get next power of two */ // Shouldn't get here