From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 28 02:50:28 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C97D8A3A for ; Tue, 28 Oct 2014 02:50:28 +0000 (UTC) Received: from mail-vc0-x229.google.com (mail-vc0-x229.google.com [IPv6:2607:f8b0:400c:c03::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8AC67CAE for ; Tue, 28 Oct 2014 02:50:28 +0000 (UTC) Received: by mail-vc0-f169.google.com with SMTP id id10so1020936vcb.0 for ; Mon, 27 Oct 2014 19:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=VGXYsdJ2C1LCFctxb3O3jbKTJYEp0h5JIP5CiIWBXTs=; b=r9ihPEZLgWWDwG6KEkNVApsP0d5ANg1EhLW64P7opMYqHBNJtmCCXCc4u6xadc3zbT WpU4+g1kc61VwzP03rQnsbw+mIczFFR5XHduP8VJK69a4oUas/U2dJMiTxX7tF7OBVjh 2Qy+tV5dYkv01zF0IIJ+2LEaA7Wg40x5FOVd73/2KBQ4ypO/2zhHLw06YR2Chp+ddfUr 2iGHKZ49+6KfOEKQLDs70k6E2aMDrB/sIJl20V9TfetmGZQR9MWIJqO6BTghsuvALl7R Vy5iPHrDW4wu3GWGCs0um4AfsiBMG3TL9HN7UpAgdF40J5KWuee/XX9hadPwX8Gtrz2L 0jjQ== MIME-Version: 1.0 X-Received: by 10.220.47.210 with SMTP id o18mr222457vcf.1.1414464627437; Mon, 27 Oct 2014 19:50:27 -0700 (PDT) Received: by 10.220.58.136 with HTTP; Mon, 27 Oct 2014 19:50:27 -0700 (PDT) Date: Mon, 27 Oct 2014 19:50:27 -0700 Message-ID: Subject: USB stack driver options for the receive side question From: Nidal Khalil To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Oct 2014 02:50:28 -0000 Hello All, I am setting up usb to transfer 3 frames on the bulk read desriptor but all I get is one frame transferred? However if I use .short_frames_ok = 1, then the transfer will pend till the three frames are received. This code is part of a network driver I would like to receive the one buffer it i the only one availble and at most three buffers at a time if the transfer is complete. Is this a limitation of FreeBSD. I searched all the drivers in the 9.3 release and I can not find a driver that is setup to recieve multiple buffers? Below is my sample code: BWL_BULK_RD] = { .type = UE_BULK, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, .bufsize = 2000 * HW_IN_PENDING_FRAMES, .flags = { .pipe_bof = 1, .short_xfer_ok = 1, .ext_buffer = 1 }, .callback = dbus_usbos_recv_callback, .timeout = 0, /* no timeout */ .frames = HW_IN_PENDING_FRAMES }, static void dbus_usbos_recv_callback(CALLBACK_ARGS) { usbos_info_t *usbos_info = usbd_xfer_softc(xfer); struct bwl_rx_data *data; int actlen, sumlen, aframes, nframes, datalen, nr_frames; uint8 *buf; struct timespec tp; DBUSTRACE(("%s(): Enter \n", __FUNCTION__)); usbd_xfer_status(xfer, &actlen, &sumlen, &aframes, &nframes); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: for (nr_frames = 0; nr_frames != aframes; nr_frames++) { FETCH_LIST_HEAD_ITEM(rx_q_lock, rx_q); if (!data) { DBUSERR(("got xfer frame but the rx_q till end ?? \n")); ASSERT(0); } usbd_xfer_frame_data(xfer, nr_frames, (void**)&buf, &datalen); kern_clock_gettime(curthread, CLOCK_UPTIME_PRECISE, &tp); mylog(&glog, "T %p: %d-%d:%u\n", buf, datalen, tp.tv_sec, tp.tv_nsec); if ((data->rxirb->buf != buf) || (data->rxirb->buf_len < datalen)) { DBUSERR(("the buff or data length not match ?? \n")); ASSERT(0); } MUTEX_UNLOCK(usbos_info); dbus_usbos_recv_complete(data, datalen, DBUS_OK); MUTEX_LOCK(usbos_info); } __transfered += nr_frames; /* no break, FALLTHROUGH */ case USB_ST_SETUP: SET_UP_XFER: nr_frames = 0; mtx_lock(&usbos_info->rx_q_lock); STAILQ_FOREACH(data, &usbos_info->rx_q, next) { if (data->rxirb == NULL) break; kern_clock_gettime(curthread, CLOCK_UPTIME_PRECISE, &tp); mylog(&glog, "S %p:%d-%d:%u\n", data->rxirb->buf, data->rxirb->buf_len, tp.tv_sec, tp.tv_nsec); usbd_xfer_set_frame_data(xfer, nr_frames, data->rxirb->buf, data->rxirb->buf_len); ++nr_frames; if (nr_frames >= BCMWL_HW_IN_PENDING_FRAMES) break; /* break out from STAILQ_FOREACH */ } mtx_unlock(&usbos_info->rx_q_lock); if (nr_frames) { usbd_xfer_set_frames(xfer, nr_frames); usbd_transfer_submit(xfer); } else { printf("%s(): end of rx_q \n", __FUNCTION__); } __setup += nr_frames; break; default: DBUSERR(("%s(): error = %s with %d bytes transfered\n", __FUNCTION__, usbd_errstr(error), actlen)); if (error == USB_ERR_STALLED || error == USB_ERR_IOERROR) { printf("%s(): calling DBUS_STATE_DOWN for %s\n", __FUNCTION__, usbd_errstr(error)); dbus_usbos_state_change(usbos_info, DBUS_STATE_DOWN); } if ((error != USB_ERR_CANCELLED) && (error != USB_ERR_STALLED)) { usbd_xfer_set_stall(xfer); goto SET_UP_XFER; } else { /* return all rxirb in the queue */ MUTEX_UNLOCK(usbos_info); mtx_lock(&usbos_info->rx_q_lock); while ((data = STAILQ_FIRST(&usbos_info->rx_q)) != NULL) { STAILQ_REMOVE_HEAD(&usbos_info->rx_q, next); dbus_usbos_recv_complete(data, 0, DBUS_ERR_RXFAIL); } STAILQ_INIT(&usbos_info->rx_q); mtx_unlock(&usbos_info->rx_q_lock); MUTEX_LOCK(usbos_info); } break; } }