From nobody Mon Feb 9 22:04:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188021; cv=none; d=zohomail.com; s=zohoarc; b=M10iV1D3c2Ckh/bHWvmXKgOsOT9e9kD8Ey0YcfZkacNhT+s7c9Oct4/kPPmOBSDjYagOkGT8odz+RgdR2UVg34bJXoZVC/6F0hooM4CaNc9leFAGuPSZStz4a79gGfkOIOf5nm3FUyASx2AydaS3xd0jy03ijJFT1pLN7UJY5PI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188021; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=miPoxn9SrVFyHIf9qzY+z3NhHALNMLDd+UZYl0UJaZwJBm9i29/Kis5nhkj4mDPZa5w2LycE951wNKfnBhKIwTVU/Q+wFqy7g/LR6oNClyiadui49QfecCqKrTVo38snrKjmDPdHQ75oNdr++z+px5C1ijBOAPD28H2G2DDKaTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188021115247.32177031830452; Mon, 26 Sep 2022 03:27:01 -0700 (PDT) Received: from localhost ([::1]:51400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclKD-0008Jq-Tt for importer@patchew.org; Mon, 26 Sep 2022 06:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockps-0005ZH-Oa for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0003o2-2d for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-kMv2CygHNneyVGTGJoIP8Q-1; Mon, 26 Sep 2022 05:55:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94FAD3810780; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D2FFC15BA4; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 19D54180A401; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=JujMGLRo8FK0kNoAkPTPz11Ji5QsfoukmQGuXlpFZZS7x58qZvWcXdDZm0EGafrf39/VEv MvqRKBo3r19MCi5G2xy2GJ21F4PcUb1JwIkM5vhl9PPdmMmAf6VFsl3gINlySShefp8CnN RXOIK641OHOa6wE/VQezjELWwCD41y8= X-MC-Unique: kMv2CygHNneyVGTGJoIP8Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Michael Brown Subject: [PULL 20/25] usbnet: Report link-up via interrupt endpoint in CDC-ECM mode Date: Mon, 26 Sep 2022 11:55:04 +0200 Message-Id: <20220926095509.3759409-21-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188023365100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-5-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- 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 9d83974ec9f0..ac1adca54355 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.37.3