From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QozZT-0004TF-QF for qemu-devel@nongnu.org; Thu, 04 Aug 2011 11:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QozZN-0007rF-Q1 for qemu-devel@nongnu.org; Thu, 04 Aug 2011 11:10:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QozZN-0007qR-It for qemu-devel@nongnu.org; Thu, 04 Aug 2011 11:10:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p74FAY9f007859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Aug 2011 11:10:34 -0400 From: Gerd Hoffmann Date: Thu, 4 Aug 2011 17:10:17 +0200 Message-Id: <1312470626-25872-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1312470626-25872-1-git-send-email-kraxel@redhat.com> References: <1312470626-25872-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 07/16] usb-host: iovec support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add full support for iovecs to usb-host. The code can split large transfers into smaller ones already, we are using this to also split requests at iovec borders. Signed-off-by: Gerd Hoffmann --- usb-linux.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 184f56f..5562187 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -707,7 +707,7 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); struct usbdevfs_urb *urb; AsyncURB *aurb; - int ret, rem; + int ret, rem, prem, v; uint8_t *pbuf; uint8_t ep; @@ -735,10 +735,18 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN); } - assert(p->iov.niov == 1); /* temporary */ - rem = p->iov.iov[0].iov_len; - pbuf = p->iov.iov[0].iov_base; + v = 0; + prem = p->iov.iov[v].iov_len; + pbuf = p->iov.iov[v].iov_base; + rem = p->iov.size; while (rem) { + if (prem == 0) { + v++; + assert(v < p->iov.niov); + prem = p->iov.iov[v].iov_len; + pbuf = p->iov.iov[v].iov_base; + assert(prem <= rem); + } aurb = async_alloc(s); aurb->packet = p; @@ -747,16 +755,17 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) urb->type = USBDEVFS_URB_TYPE_BULK; urb->usercontext = s; urb->buffer = pbuf; + urb->buffer_length = prem; - if (rem > MAX_USBFS_BUFFER_SIZE) { + if (urb->buffer_length > MAX_USBFS_BUFFER_SIZE) { urb->buffer_length = MAX_USBFS_BUFFER_SIZE; - aurb->more = 1; - } else { - urb->buffer_length = rem; - aurb->more = 0; } pbuf += urb->buffer_length; + prem -= urb->buffer_length; rem -= urb->buffer_length; + if (rem) { + aurb->more = 1; + } ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb); -- 1.7.1