FreeBSD/sys/dev/vnic/nicvf_queues.c
/*
 * Refill receive buffer descriptors with new buffers.
 */
Refill receive buffer descriptors with new buffers.
Refill receive buffer descriptors with new buffers .
static int
nicvf_refill_rbdr(struct rbdr *rbdr, int mflags)
{
	struct nicvf *nic;
	struct queue_set *qs;
	int rbdr_idx;
	int tail, qcount;
	int refill_rb_cnt;
	struct rbdr_entry_t *desc;
	bus_dmamap_t dmap;
	bus_addr_t rbuf;
	boolean_t rb_alloc_fail;
	int new_rb;
	rb_alloc_fail = TRUE;
	new_rb = 0;
	nic = rbdr->nic;
	qs = nic->qs;
	rbdr_idx = rbdr->idx;
	if (!rbdr->enable)
		return (0);
	qcount = nicvf_queue_reg_read(nic, NIC_QSET_RBDR_0_1_STATUS0, rbdr_idx);
	qcount &= 0x7FFFF;
	if (qcount >= (qs->rbdr_len - 1)) {
		rb_alloc_fail = FALSE;
		goto out;
	} else
		refill_rb_cnt = qs->rbdr_len - qcount - 1;
	tail = nicvf_queue_reg_read(nic, NIC_QSET_RBDR_0_1_TAIL, rbdr_idx) >> 3;
	while (refill_rb_cnt) {
		tail++;
		tail &= (rbdr->dmem.q_len - 1);
		dmap = rbdr->rbdr_buff_dmaps[tail];
		if (nicvf_alloc_rcv_buffer(nic, rbdr, dmap, mflags,
		    DMA_BUFFER_LEN, &rbuf)) {
			break;
		}
		desc = GET_RBDR_DESC(rbdr, tail);
		desc->buf_addr = (rbuf >> NICVF_RCV_BUF_ALIGN);
		refill_rb_cnt--;
		new_rb++;
	}
	wmb();
	if (refill_rb_cnt == 0)
		rb_alloc_fail = FALSE;
	nicvf_queue_reg_write(nic, NIC_QSET_RBDR_0_1_DOOR,
			      rbdr_idx, new_rb);
out:
	if (!rb_alloc_fail) {
		nicvf_enable_intr(nic, NICVF_INTR_RBDR, rbdr_idx);
		return (0);
	}
	return (ENOMEM);
}
static int nicvf_refill_rbdr ( struct rbdr * rbdr , int mflags ) { struct nicvf * nic ; struct queue_set * qs ; int rbdr_idx ; int tail , qcount ; int refill_rb_cnt ; struct rbdr_entry_t * desc ; bus_dmamap_t dmap ; bus_addr_t rbuf ; boolean_t rb_alloc_fail ; int new_rb ; rb_alloc_fail = TRUE ; new_rb = 0 ; nic = rbdr -> nic ; qs = nic -> qs ; rbdr_idx = rbdr -> idx ; if ( ! rbdr -> enable ) return ( 0 ) ; qcount = nicvf_queue_reg_read ( nic , NIC_QSET_RBDR_0_1_STATUS0 , rbdr_idx ) ; qcount &= 0x7FFFF ; if ( qcount >= ( qs -> rbdr_len - 1 ) ) { rb_alloc_fail = FALSE ; goto out ; } else refill_rb_cnt = qs -> rbdr_len - qcount - 1 ; tail = nicvf_queue_reg_read ( nic , NIC_QSET_RBDR_0_1_TAIL , rbdr_idx ) >> 3 ; while ( refill_rb_cnt ) { tail ++ ; tail &= ( rbdr -> dmem . q_len - 1 ) ; dmap = rbdr -> rbdr_buff_dmaps [ tail ] ; if ( nicvf_alloc_rcv_buffer ( nic , rbdr , dmap , mflags , DMA_BUFFER_LEN , & rbuf ) ) { break ; } desc = GET_RBDR_DESC ( rbdr , tail ) ; desc -> buf_addr = ( rbuf >> NICVF_RCV_BUF_ALIGN ) ; refill_rb_cnt -- ; new_rb ++ ; } wmb ( ) ; if ( refill_rb_cnt == 0 ) rb_alloc_fail = FALSE ; nicvf_queue_reg_write ( nic , NIC_QSET_RBDR_0_1_DOOR , rbdr_idx , new_rb ) ; out : if ( ! rb_alloc_fail ) { nicvf_enable_intr ( nic , NICVF_INTR_RBDR , rbdr_idx ) ; return ( 0 ) ; } return ( ENOMEM ) ; }
Refill receive buffer descriptors with new buffers.
Refill receive buffer descriptors with new buffers .
/* Check if it's enabled */ /* Get no of desc's to be refilled */ /* Doorbell can be ringed with a max of ring size minus 1 */ /* Start filling descs from tail */ /* Something went wrong. Resign */ /* make sure all memory stores are done before ringing doorbell */ /* Check if buffer allocation failed */ /* Notify HW */ /*
		 * Re-enable RBDR interrupts only
		 * if buffer allocation is success.
		 */