[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/8] usb-redir: Allow packets to have both data and
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 2/8] usb-redir: Allow packets to have both data and an error-status |
Date: |
Fri, 9 Nov 2012 10:05:45 +0100 |
From: Hans de Goede <address@hidden>
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/redirect.c | 56 ++++++++++++++++++----------------------------------
1 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index cd4388e..be9a232 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -521,22 +521,16 @@ static void usbredir_handle_iso_data(USBRedirDevice *dev,
USBPacket *p,
isop->status, isop->len, dev->endpoint[EP2I(ep)].bufpq_size);
status = isop->status;
- if (status != usb_redir_success) {
- bufp_free(dev, isop, ep);
- p->status = USB_RET_IOERROR;
- return;
- }
-
len = isop->len;
if (len > p->iov.size) {
ERROR("received iso data is larger then packet ep %02X (%d >
%d)\n",
ep, len, (int)p->iov.size);
- bufp_free(dev, isop, ep);
- p->status = USB_RET_BABBLE;
- return;
+ len = p->iov.size;
+ status = usb_redir_babble;
}
usb_packet_copy(p, isop->data, len);
bufp_free(dev, isop, ep);
+ usbredir_handle_status(dev, p, status);
} else {
/* If the stream was not started because of a pending error don't
send the packet to the usb-host */
@@ -656,21 +650,15 @@ static void usbredir_handle_interrupt_data(USBRedirDevice
*dev,
intp->status, intp->len);
status = intp->status;
- if (status != usb_redir_success) {
- bufp_free(dev, intp, ep);
- usbredir_handle_status(dev, p, status);
- return;
- }
-
len = intp->len;
if (len > p->iov.size) {
ERROR("received int data is larger then packet ep %02X\n", ep);
- bufp_free(dev, intp, ep);
- p->status = USB_RET_BABBLE;
- return;
+ len = p->iov.size;
+ status = usb_redir_babble;
}
usb_packet_copy(p, intp->data, len);
bufp_free(dev, intp, ep);
+ usbredir_handle_status(dev, p, status);
} else {
/* Output interrupt endpoint, normal async operation */
struct usb_redir_interrupt_packet_header interrupt_packet;
@@ -1542,16 +1530,15 @@ static void usbredir_control_packet(void *priv,
uint64_t id,
p = usbredir_find_packet_by_id(dev, 0, id);
if (p) {
usbredir_handle_status(dev, p, control_packet->status);
- if (p->status == USB_RET_SUCCESS) {
+ if (data_len > 0) {
usbredir_log_data(dev, "ctrl data in:", data, data_len);
- if (data_len <= sizeof(dev->dev.data_buf)) {
- memcpy(dev->dev.data_buf, data, data_len);
- } else {
+ if (data_len > sizeof(dev->dev.data_buf)) {
ERROR("ctrl buffer too small (%d > %zu)\n",
data_len, sizeof(dev->dev.data_buf));
p->status = USB_RET_STALL;
- len = 0;
+ data_len = len = sizeof(dev->dev.data_buf);
}
+ memcpy(dev->dev.data_buf, data, data_len);
}
p->actual_length = len;
usb_generic_async_ctrl_complete(&dev->dev, p);
@@ -1575,20 +1562,19 @@ static void usbredir_bulk_packet(void *priv, uint64_t
id,
if (p) {
size_t size = (p->combined) ? p->combined->iov.size : p->iov.size;
usbredir_handle_status(dev, p, bulk_packet->status);
- if (p->status == USB_RET_SUCCESS) {
+ if (data_len > 0) {
usbredir_log_data(dev, "bulk data in:", data, data_len);
- if (data_len <= size) {
- if (p->combined) {
- iov_from_buf(p->combined->iov.iov, p->combined->iov.niov,
- 0, data, data_len);
- } else {
- usb_packet_copy(p, data, data_len);
- }
- } else {
+ if (data_len > size) {
ERROR("bulk got more data then requested (%d > %zd)\n",
data_len, p->iov.size);
p->status = USB_RET_BABBLE;
- len = 0;
+ data_len = len = size;
+ }
+ if (p->combined) {
+ iov_from_buf(p->combined->iov.iov, p->combined->iov.niov,
+ 0, data, data_len);
+ } else {
+ usb_packet_copy(p, data, data_len);
}
}
p->actual_length = len;
@@ -1653,12 +1639,10 @@ static void usbredir_interrupt_packet(void *priv,
uint64_t id,
/* bufp_alloc also adds the packet to the ep queue */
bufp_alloc(dev, data, data_len, interrupt_packet->status, ep);
} else {
- int len = interrupt_packet->length;
-
USBPacket *p = usbredir_find_packet_by_id(dev, ep, id);
if (p) {
usbredir_handle_status(dev, p, interrupt_packet->status);
- p->actual_length = len;
+ p->actual_length = interrupt_packet->length;
usb_packet_complete(&dev->dev, p);
}
}
--
1.7.1
- [Qemu-devel] [PULL 0/8] usb patch queue, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 2/8] usb-redir: Allow packets to have both data and an error-status,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 8/8] ehci: fix migration, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 5/8] xhci: Add support for packets with both data and an error status, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 6/8] usb/combined-packet: Move freeing of combined to usb_combined_packet_remove(), Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 4/8] ehci: Add support for packets with both data and an error status, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 7/8] xhci: Fix some DMA host endian bugs, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 3/8] ehci: Get rid of the magical PROC_ERR status, Gerd Hoffmann, 2012/11/09
- [Qemu-devel] [PATCH 1/8] usb: split packet result into actual_length + status, Gerd Hoffmann, 2012/11/09
- Re: [Qemu-devel] [PULL 0/8] usb patch queue, Anthony Liguori, 2012/11/14