Example #1
0
void
nl7c_http_init(void)
{
	int	n;

	http_kmc = kmem_cache_create("NL7C_http_kmc",
	    sizeof (http_t), 0, NULL, NULL, NULL, NULL, NULL, 0);

	req_tree = ttree_build(tokreq, tokreq_cnt - 1);
	res_tree = ttree_build(tokres, tokres_cnt - 1);

	n = sizeof (Shttp_conn_cl) - 1;
	http_conn_cl = allocb_wait(n, BPRI_HI, STR_NOSIG, NULL);
	bcopy(Shttp_conn_cl, http_conn_cl->b_rptr, n);
	http_conn_cl->b_wptr += n;

	n = sizeof (Shttp_conn_ka) - 1;
	http_conn_ka = allocb_wait(n, BPRI_HI, STR_NOSIG, NULL);
	bcopy(Shttp_conn_ka, http_conn_ka->b_rptr, n);
	http_conn_ka->b_wptr += n;
}
/*
 * scsa2usb_handle_status_start:
 *	Receive status data
 */
static int
scsa2usb_handle_status_start(scsa2usb_state_t *scsa2usbp,
    usb_bulk_req_t *req)
{
	int rval;

	USB_DPRINTF_L4(DPRINT_MASK_SCSA, scsa2usbp->scsa2usb_log_handle,
	    "scsa2usb_handle_status_start: req = 0x%p", (void *)req);

	ASSERT(mutex_owned(&scsa2usbp->scsa2usb_mutex));

	/* setup up for receiving CSW */
#ifdef	SCSA2USB_BULK_ONLY_TEST
	req->bulk_attributes = 0;
#else
	req->bulk_attributes = USB_ATTRS_SHORT_XFER_OK;
#endif	/* SCSA2USB_BULK_ONLY_TEST */
	req->bulk_len = CSW_LEN;

	SCSA2USB_FREE_MSG(req->bulk_data);
	req->bulk_data = allocb_wait(req->bulk_len,
	    BPRI_LO, STR_NOSIG, NULL);

	/* Issue the request */
	mutex_exit(&scsa2usbp->scsa2usb_mutex);

	ASSERT(req->bulk_timeout);
	rval = usb_pipe_bulk_xfer(scsa2usbp->scsa2usb_bulkin_pipe, req,
	    USB_FLAGS_SLEEP);
	mutex_enter(&scsa2usbp->scsa2usb_mutex);

	USB_DPRINTF_L3(DPRINT_MASK_SCSA, scsa2usbp->scsa2usb_log_handle,
	    "scsa2usb_handle_status_start: END rval = 0x%x", rval);

	if (rval != USB_SUCCESS) {
		if (scsa2usbp->scsa2usb_pkt_state == SCSA2USB_PKT_PROCESS_CSW) {
			scsa2usb_bulk_only_reset_recovery(scsa2usbp);

			return (rval);
		}

		if (req->bulk_completion_reason == USB_CR_STALL) {
			(void) scsa2usb_clear_ept_stall(scsa2usbp,
			    scsa2usbp->scsa2usb_bulkin_ept.bEndpointAddress,
			    scsa2usbp->scsa2usb_bulkin_pipe, "bulk-in");
		}
	}

	return (rval);
}