FreeBSD/sys/dev/ntb/if_ntb/if_ntb.c
/**
 * ntb_transport_tx_enqueue - Enqueue a new NTB queue entry
 * @qp: NTB transport layer queue the entry is to be enqueued on
 * @cb: per buffer pointer for callback function to use
 * @data: pointer to data buffer that will be sent
 * @len: length of the data buffer
 *
 * Enqueue a new transmit buffer onto the transport queue from which a NTB
 * payload will be transmitted.  This assumes that a lock is being held to
 * serialize access to the qp.
 *
 * RETURNS: An appropriate ERRNO error value on error, or zero for success.
 */
Enqueue a new NTB queue entry
@qp: NTB transport layer queue the entry is to be enqueued on
@cb: per buffer pointer for callback function to use
@data: pointer to data buffer that will be sent
@len: length of the data buffer

Enqueue a new transmit buffer onto the transport queue from which a NTB
payload will be transmitted.  This assumes that a lock is being held to
serialize access to the qp.

An appropriate ERRNO error value on error, or zero for success.
Enqueue a new NTB queue entry @qp : NTB transport layer queue the entry is to be enqueued on @cb : per buffer pointer for callback function to use @data : pointer to data buffer that will be sent @len : length of the data buffer Enqueue a new transmit buffer onto the transport queue from which a NTB payload will be transmitted . This assumes that a lock is being held to serialize access to the qp . An appropriate ERRNO error value on error or zero for success .
static int
ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
    unsigned int len)
{
	struct ntb_queue_entry *entry;
	int rc;
	if (qp == NULL || !qp->link_is_up || len == 0) {
		CTR0(KTR_NTB, "TX: link not up");
		return (EINVAL);
	}
	entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
	if (entry == NULL) {
		CTR0(KTR_NTB, "TX: could not get entry from tx_free_q");
		qp->tx_err_no_buf++;
		return (EBUSY);
	}
	CTR1(KTR_NTB, "TX: got entry %p from tx_free_q", entry);
	entry->cb_data = cb;
	entry->buf = data;
	entry->len = len;
	entry->flags = 0;
	rc = ntb_process_tx(qp, entry);
	if (rc != 0) {
		ntb_list_add(&qp->ntb_tx_free_q_lock, entry, &qp->tx_free_q);
		CTR1(KTR_NTB,
		    "TX: process_tx failed. Returning entry %p to tx_free_q",
		    entry);
	}
	return (rc);
}
static int ntb_transport_tx_enqueue ( struct ntb_transport_qp * qp , void * cb , void * data , unsigned int len ) { struct ntb_queue_entry * entry ; int rc ; if ( qp == NULL || ! qp -> link_is_up || len == 0 ) { CTR0 ( KTR_NTB , " " ) ; return ( EINVAL ) ; } entry = ntb_list_rm ( & qp -> ntb_tx_free_q_lock , & qp -> tx_free_q ) ; if ( entry == NULL ) { CTR0 ( KTR_NTB , " " ) ; qp -> tx_err_no_buf ++ ; return ( EBUSY ) ; } CTR1 ( KTR_NTB , " " , entry ) ; entry -> cb_data = cb ; entry -> buf = data ; entry -> len = len ; entry -> flags = 0 ; rc = ntb_process_tx ( qp , entry ) ; if ( rc != 0 ) { ntb_list_add ( & qp -> ntb_tx_free_q_lock , entry , & qp -> tx_free_q ) ; CTR1 ( KTR_NTB , " " , entry ) ; } return ( rc ) ; }
ntb_transport_tx_enqueue - Enqueue a new NTB queue entry
 @qp: NTB transport layer queue the entry is to be enqueued on
 @cb: per buffer pointer for callback function to use
 @data: pointer to data buffer that will be sent
 @len: length of the data buffer
ntb_transport_tx_enqueue - Enqueue a new NTB queue entry @qp : NTB transport layer queue the entry is to be enqueued on @cb : per buffer pointer for callback function to use @data : pointer to data buffer that will be sent @len : length of the data buffer