From patchwork Mon Feb 8 14:19:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Brown X-Patchwork-Id: 580294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3F45E1402ED for ; Tue, 9 Feb 2016 01:20:33 +1100 (AEDT) Received: from localhost ([::1]:45204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSmg3-000481-8N for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2016 09:20:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSmfQ-0002rr-Ip for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:19:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSmfM-00061w-SY for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:19:52 -0500 Received: from duck.fensystems.co.uk ([2001:ba8:0:1d4::6950:5845]:49679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSmfM-00061U-LJ for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:19:48 -0500 Received: from localhost.localdomain (genkt-056-205.t-mobile.co.uk [149.254.56.205]) by duck.fensystems.co.uk (Postfix) with ESMTPSA id C8C7C107A5; Mon, 8 Feb 2016 14:19:47 +0000 (GMT) From: Michael Brown To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 14:19:34 +0000 Message-Id: <1454941174-25050-5-git-send-email-mcb30@ipxe.org> X-Mailer: git-send-email 2.3.8 In-Reply-To: <1454941174-25050-1-git-send-email-mcb30@ipxe.org> References: <1454941174-25050-1-git-send-email-mcb30@ipxe.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:ba8:0:1d4::6950:5845 Cc: Michael Brown Subject: [Qemu-devel] [PATCH 4/4] usbnet: Report link-up via interrupt endpoint in CDC-ECM mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Michael Brown --- hw/usb/dev-network.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 09312d4..f8e6e57 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -86,6 +86,8 @@ enum usbstring_idx { #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 +#define USB_CDC_NETWORK_CONNECTION 0x00 + #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ @@ -635,6 +637,8 @@ typedef struct USBNetState { uint16_t filter; uint32_t vendorid; + uint16_t connection; + unsigned int out_ptr; uint8_t out_buf[2048]; @@ -1135,18 +1139,28 @@ static void usb_net_handle_control(USBDevice *dev, USBPacket *p, static void usb_net_handle_statusin(USBNetState *s, USBPacket *p) { - le32 buf[2]; + le32 rbuf[2]; + uint16_t ebuf[4]; if (p->iov.size < 8) { p->status = USB_RET_STALL; return; } - buf[0] = cpu_to_le32(1); - buf[1] = cpu_to_le32(0); - usb_packet_copy(p, buf, 8); - if (!s->rndis_resp.tqh_first) { - p->status = USB_RET_NAK; + if (is_rndis(s)) { + rbuf[0] = cpu_to_le32(1); + rbuf[1] = cpu_to_le32(0); + usb_packet_copy(p, rbuf, 8); + if (!s->rndis_resp.tqh_first) { + p->status = USB_RET_NAK; + } + } else { + ebuf[0] = + cpu_to_be16(ClassInterfaceRequest | USB_CDC_NETWORK_CONNECTION); + ebuf[1] = cpu_to_le16(s->connection); + ebuf[2] = cpu_to_le16(1); + ebuf[3] = cpu_to_le16(0); + usb_packet_copy(p, ebuf, 8); } #ifdef TRAFFIC_DEBUG @@ -1360,6 +1374,7 @@ static void usb_net_realize(USBDevice *dev, Error **errrp) s->media_state = 0; /* NDIS_MEDIA_STATE_CONNECTED */; s->filter = 0; s->vendorid = 0x1234; + s->connection = 1; /* Connected */ s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1); s->bulk_in = usb_ep_get(dev, USB_TOKEN_IN, 2);