From nobody Mon Feb 9 12:26:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662489436090416.07065605683385; Tue, 6 Sep 2022 11:37:16 -0700 (PDT) Received: from localhost ([::1]:47236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVdRj-0001Fs-29 for importer@patchew.org; Tue, 06 Sep 2022 14:37:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVdMN-0003S5-Lo for qemu-devel@nongnu.org; Tue, 06 Sep 2022 14:31:43 -0400 Received: from blyat.fensystems.co.uk ([54.246.183.96]:56052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVdML-0004t9-4O for qemu-devel@nongnu.org; Tue, 06 Sep 2022 14:31:43 -0400 Received: from dolphin.home (unknown [IPv6:2a00:23c6:5486:8700:72b3:d5ff:feb1:e101]) by blyat.fensystems.co.uk (Postfix) with ESMTPSA id 4DA09442B8; Tue, 6 Sep 2022 18:31:38 +0000 (UTC) From: Michael Brown To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Michael Brown Subject: [PATCH 4/4] usbnet: Report link-up via interrupt endpoint in CDC-ECM mode Date: Tue, 6 Sep 2022 19:30:53 +0100 Message-Id: <20220906183053.3625472-5-mcb30@ipxe.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906183053.3625472-1-mcb30@ipxe.org> References: <20220906183053.3625472-1-mcb30@ipxe.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=54.246.183.96; envelope-from=mcb30@ipxe.org; helo=blyat.fensystems.co.uk X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662489438135100001 Content-Type: text/plain; charset="utf-8" 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 9d83974ec9..ac1adca543 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -91,6 +91,8 @@ enum usbstring_idx { #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 =20 +#define USB_CDC_NETWORK_CONNECTION 0x00 + #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 =3D=3D 32 msec */ #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ =20 @@ -640,6 +642,8 @@ struct USBNetState { uint16_t filter; uint32_t vendorid; =20 + uint16_t connection; + unsigned int out_ptr; uint8_t out_buf[2048]; =20 @@ -1140,18 +1144,28 @@ static void usb_net_handle_control(USBDevice *dev, = USBPacket *p, =20 static void usb_net_handle_statusin(USBNetState *s, USBPacket *p) { - le32 buf[2]; + le32 rbuf[2]; + uint16_t ebuf[4]; =20 if (p->iov.size < 8) { p->status =3D USB_RET_STALL; return; } =20 - buf[0] =3D cpu_to_le32(1); - buf[1] =3D cpu_to_le32(0); - usb_packet_copy(p, buf, 8); - if (!s->rndis_resp.tqh_first) { - p->status =3D USB_RET_NAK; + if (is_rndis(s)) { + rbuf[0] =3D cpu_to_le32(1); + rbuf[1] =3D cpu_to_le32(0); + usb_packet_copy(p, rbuf, 8); + if (!s->rndis_resp.tqh_first) { + p->status =3D USB_RET_NAK; + } + } else { + ebuf[0] =3D + cpu_to_be16(ClassInterfaceRequest | USB_CDC_NETWORK_CONNECTION= ); + ebuf[1] =3D cpu_to_le16(s->connection); + ebuf[2] =3D cpu_to_le16(1); + ebuf[3] =3D cpu_to_le16(0); + usb_packet_copy(p, ebuf, 8); } =20 #ifdef TRAFFIC_DEBUG @@ -1366,6 +1380,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) s->media_state =3D 0; /* NDIS_MEDIA_STATE_CONNECTED */; s->filter =3D 0; s->vendorid =3D 0x1234; + s->connection =3D 1; /* Connected */ s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); s->bulk_in =3D usb_ep_get(dev, USB_TOKEN_IN, 2); =20 --=20 2.35.1