From owner-freebsd-usb@freebsd.org Mon Mar 2 21:20:07 2020 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C1A9A25AED1 for ; Mon, 2 Mar 2020 21:20:07 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48WY2F6X3Nz4KvQ for ; Mon, 2 Mar 2020 21:20:05 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 978D875E for ; Mon, 2 Mar 2020 16:20:03 -0500 (EST) Received: from imap35 ([10.202.2.85]) by compute1.internal (MEProxy); Mon, 02 Mar 2020 16:20:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=farhan.codes; h= mime-version:message-id:date:from:to:subject:content-type; s= fm2; bh=H8cYKnbJiCZpeGaex9TW1+dLdf0Kze1c+LjujnWUFEc=; b=jP+hp19G IrazfSqX3SQs2jhEMvOjFpGTSYGXmksaBZ5QOXrzjBY+gu4X2UXg0DK/V5WS6BUb Mp/qW0vJ1M6wPmsberBoidWoPHW+c4xKZn85iYKYCzHuAfpw1Fg3LQDP7spWhmob 6w0NncliZtbxUWyLktCdwSzJwkAU+qfPQ3pnoywg7Fk0BbGuMqku75fv3FgMgs0a ToSsjaYgHhIx7+pZ8beATVgt4c2/daGjuDXNwmp5ePEjBjqN3GaJB19rxXW53g7A 5T+ENKREu3vNsIhEp9TSUtvmQsoQpoeh72SaUmtlIWY/FYG7O4G8a7sbxhX0Vdzn JTOf7OQdSaV4eA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=H8cYKnbJiCZpeGaex9TW1+dLdf0Kz e1c+LjujnWUFEc=; b=ASoKVqDhEA5PEp50sJLrAKBd82dcBRa/TezvggvRoCm+x l4ZrocHCdPCiOKIhIxWv1WbAT1KNh1hBB5UsrztohCOd9k7Y+zFaWB1/+0VqHf9R X8QD4tZ9re65d3q/Ytgi0KyJ2oKMYGSJH3xslGvfIn5uYEVjFzzfwBhgrkqWtWOj Cw6vkrQCgIeKy3P3bPaZRk4ZrTTAqm6hK+Gibp4FJdfdNx+AhT9673fywiQnTwYa cPF7zJ6tVJE0oaBuOauknVF5xYF5vLEzV7vovfmV4zELsZynUy6cPu5PPrv9xBZk SwPYcA/DJzwQP3ROkuhIO7wIIN9Ks+0k8oVlo41kQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtgedgudegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkfffhvffutgesrgdtre erreertdenucfhrhhomhepfdfhrghrhhgrnhcumfhhrghnfdcuoehfrghrhhgrnhesfhgr rhhhrghnrdgtohguvghsqeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepfhgrrhhhrghnsehf rghrhhgrnhdrtghouggvsh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id CBDA614C04BB; Mon, 2 Mar 2020 16:20:02 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-967-g014f925-fmstable-20200226v1 Mime-Version: 1.0 Message-Id: <8d84a572-f70f-4080-bfe2-263b7f97993c@www.fastmail.com> Date: Mon, 02 Mar 2020 16:19:06 -0500 From: "Farhan Khan" To: freebsd-usb@freebsd.org Subject: Understanding how USB transmission works X-Rspamd-Queue-Id: 48WY2F6X3Nz4KvQ X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=farhan.codes header.s=fm2 header.b=jP+hp19G; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=ASoKVqDh; dmarc=none; spf=pass (mx1.freebsd.org: domain of farhan@farhan.codes designates 64.147.123.20 as permitted sender) smtp.mailfrom=farhan@farhan.codes X-Spamd-Result: default: False [-3.99 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.89)[-0.895,0]; R_DKIM_ALLOW(-0.20)[farhan.codes:s=fm2,messagingengine.com:s=fm2]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:64.147.123.20]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; URI_COUNT_ODD(1.00)[9]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[4]; DMARC_NA(0.00)[farhan.codes]; MV_CASE(0.50)[]; DKIM_TRACE(0.00)[farhan.codes:+,messagingengine.com:+]; IP_SCORE(-3.50)[ip: (-9.85), ipnet: 64.147.123.0/24(-4.92), asn: 11403(-2.69), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[20.123.147.64.list.dnswl.org : 127.0.5.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:11403, ipnet:64.147.123.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; MID_RHS_WWW(0.50)[] Content-Type: text/plain X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2020 21:20:07 -0000 Hi all, I am trying to understand how FreeBSD's usb transfers work compared to OpenBSD by using the rum(4) driver. I am a little confused how the FreeBSD side works. On the OpenBSD side, it seems that after allocating the pipes, you use usbd_setup_xfer and usbd_transfer(). As an example, look at OpenBSD's /usr/src/sys/dev/usb/if_rum.c, starting on line 2027-2029, I believe that corresponds to FreeBSD's /usr/src/sys/dev/usb/wlan/if_rum.c, line 2607 (rum_setup_tx_list) which goes to 807. In this function, I see that it adds rum_tx_data (tx_data[i] to the end of tx_free. However, how does it actually send the data? I believe this occurs in the callback functions, specifically with the usbd_transfer_submit function, but I am not certain how that is triggered, especially when it is triggered by the driver, such as in a send function. Please assist. Thank you! Links below to make it easy to follow: OpenBSD: https://github.com/openbsd/src/blob/2e342c845e9966c26657b08851237fc18e7b5ff5/sys/dev/usb/if_rum.c#L2024 FreeBSD: 1. https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L2607 2. https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L807 -- Farhan Khan PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE