FreeBSD/sys/dev/usb/misc/udbp.c
/*
 * Accept data from the hook and queue it for output.
 */
Accept data from the hook and queue it for output.
Accept data from the hook and queue it for output .
static int
ng_udbp_rcvdata(hook_p hook, item_p item)
{
	struct udbp_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
	struct ng_bt_mbufq *queue_ptr;
	struct mbuf *m;
	struct ng_tag_prio *ptag;
	int error;
	if (sc == NULL) {
		NG_FREE_ITEM(item);
		return (EHOSTDOWN);
	}
	NGI_GET_M(item, m);
	NG_FREE_ITEM(item);
	ptag = (void *)m_tag_locate(m, NGM_GENERIC_COOKIE,
	    NG_TAG_PRIO, NULL);
	if (ptag && (ptag->priority > NG_PRIO_CUTOFF))
		queue_ptr = &sc->sc_xmitq_hipri;
	else
		queue_ptr = &sc->sc_xmitq;
	mtx_lock(&sc->sc_mtx);
	if (NG_BT_MBUFQ_FULL(queue_ptr)) {
		NG_BT_MBUFQ_DROP(queue_ptr);
		NG_FREE_M(m);
		error = ENOBUFS;
	} else {
		NG_BT_MBUFQ_ENQUEUE(queue_ptr, m);
		usbd_transfer_start(sc->sc_xfer[UDBP_T_WR]);
		error = 0;
	}
	mtx_unlock(&sc->sc_mtx);
	return (error);
}
static int ng_udbp_rcvdata ( hook_p hook , item_p item ) { struct udbp_softc * sc = NG_NODE_PRIVATE ( NG_HOOK_NODE ( hook ) ) ; struct ng_bt_mbufq * queue_ptr ; struct mbuf * m ; struct ng_tag_prio * ptag ; int error ; if ( sc == NULL ) { NG_FREE_ITEM ( item ) ; return ( EHOSTDOWN ) ; } NGI_GET_M ( item , m ) ; NG_FREE_ITEM ( item ) ; ptag = ( void * ) m_tag_locate ( m , NGM_GENERIC_COOKIE , NG_TAG_PRIO , NULL ) ; if ( ptag && ( ptag -> priority > NG_PRIO_CUTOFF ) ) queue_ptr = & sc -> sc_xmitq_hipri ; else queue_ptr = & sc -> sc_xmitq ; mtx_lock ( & sc -> sc_mtx ) ; if ( NG_BT_MBUFQ_FULL ( queue_ptr ) ) { NG_BT_MBUFQ_DROP ( queue_ptr ) ; NG_FREE_M ( m ) ; error = ENOBUFS ; } else { NG_BT_MBUFQ_ENQUEUE ( queue_ptr , m ) ; usbd_transfer_start ( sc -> sc_xfer [ UDBP_T_WR ] ) ; error = 0 ; } mtx_unlock ( & sc -> sc_mtx ) ; return ( error ) ; }
Accept data from the hook and queue it for output.
Accept data from the hook and queue it for output .
/*
	 * Now queue the data for when it can be sent
	 */ /*
		 * start bulk-out transfer, if not already started:
		 */