Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1252947rdg; Fri, 13 Oct 2023 15:36:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGW2fRS/flKBP+l1TuIpSpeemF3IRe4q5ofRVI/deSqZoYSYDBCpfNnuZbno51aLxD4z+f X-Received: by 2002:a05:6a20:7da0:b0:16b:d3d5:a5c5 with SMTP id v32-20020a056a207da000b0016bd3d5a5c5mr22588028pzj.52.1697236575747; Fri, 13 Oct 2023 15:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697236575; cv=none; d=google.com; s=arc-20160816; b=V97eo+HUcilk5YdrFr7R8zMBljiohcnwdRmSiVMFn0T8RsYEr/OAy84XMc4HEx5C6+ TWd0MrNBsmNB9H1yJee73ezF7bGc0Bdu7BtmgiD1mxJ8KhusrjJfr3DmxYHfFhLC2OGk qlxtK6q97G3PRERlzEwHttm9KENgOgQESocC2JpdL1asB7dB78xg2L4gMvE5+/O2hXby IP4p2C4ar84oMunXBWkUeCeoXk+ciXZw4/U+VOZKd6DY1mvVwZenL/mtA1IYMCxB4ni0 Mm5ruldIpd888Jf+1BQkR89TXWut0mFt7Ly0QlsiixViQ6C1NHQ+7j1rWCGeYxdo3Ovg QwHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FSeOd+rYnOzhF1ReZbddCmvmJexTwHpOy+fpUODbkOA=; fh=sUzFhheJP6ORqa8FeWDqX2SGjTp2rOCbrGgrBhqE6Jk=; b=zPqCYCwxfrT7IheiDIQzW2ae4hFQKwWMufzoz5J8cTQqhqkCg+U2Mc8GFAifyhncWq XfPxnYbjAdv8nPbcLTX5DNr0mYBMb8LSsh8MfHTl72juWXBMDOkWDGzCjaAkia9zQ7eT jTULjTT2kurP5tAfVyciRZATSHzGcRyjbqna0THGzfLTZ/V6CZjqWv9rd+j2xAYKU5pn b2EsnaGhsihEgxL3kkNAh1VNt/DZdFUDSasZzjzG43+r7a1jbCaSm9yZigese99uR5vl ZzIBr7IMg8u4WpzgYgjjTIrTzHKb2UpDDiOPe8aoc0AXdiqD7XNzTkLOO+2YuRgVQvIg kctw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CNJhhVoc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y13-20020a17090322cd00b001bdd35033efsi5978024plg.374.2023.10.13.15.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:36:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CNJhhVoc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D566380CD712; Fri, 13 Oct 2023 15:36:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbjJMWf4 (ORCPT + 99 others); Fri, 13 Oct 2023 18:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbjJMWfz (ORCPT ); Fri, 13 Oct 2023 18:35:55 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775CDC0 for ; Fri, 13 Oct 2023 15:35:51 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-534694a9f26so1646a12.1 for ; Fri, 13 Oct 2023 15:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697236550; x=1697841350; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FSeOd+rYnOzhF1ReZbddCmvmJexTwHpOy+fpUODbkOA=; b=CNJhhVock8IDFK3Wu6SntkES8kAfPX+KDiRD7Au6H+P9EdgUEHMn0G7nUwLl6f3zyQ pAQYQrF5bkso1ka3P72+mmsoQ6P2P1TBTA5SdSTAH8pysOKZZ0Rm2klnu07TRE0Nd28T wIpXbXoGfrug6vz07MEw3KLd9my6geFIiyaeCooyhBotPhBwIpM3RtN3lEYnzGtMTNKn sWtfxCBbeR0/1zdRReII4jHH7lfBPWvCSUDnjDt3B+6z0cCmQCJjMArvtKB7cfhZ8gPh 32MKP6MAAt6pSYiphT8J2Dc6I/39v5uz+7uBORtNiDcSBkUcJUy7DkMbLPayi6urlcOW xsSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697236550; x=1697841350; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FSeOd+rYnOzhF1ReZbddCmvmJexTwHpOy+fpUODbkOA=; b=sc9nhKV6QouqbbACs4aY398xwHT9B+BkfGPMAZ9VNgBxugMLHZ2tZ0t5tGpAAHRuYy QQyHTQIS34kabbcTPk1NUCVuqqJrb7N58V7fTlgmwPr/1YzuqT1OLomg0QUcLmEWMhz7 z9oNaZO4OdOuFwtW6HK/TVlPTYxazLhgJrPCRowS895rChb3c5vFcqSpTtnIDsNI7bXV R4qdemVSC/xoL80k9Gw2F3+rnZjUKFl8oXQdY1EZrmknJ9nDI9fGPNw62HGlx/mPweg7 PlnWAZiHwjtq7dvTysW7SQ3OJOTSYgTcorfcXxcXM+5+88xgmwwS7TLXgJERoH3niOED Y4XA== X-Gm-Message-State: AOJu0YzL6K2pkiA4/xL6NMeJIJeNbUM4FwUvmUDV2PqFKWG/bWrjVSw4 Qx5VQdcbpjQnMbCGdIVmP0AEW9HUyFEiBkZqtftURg== X-Received: by 2002:a50:cdde:0:b0:53d:b53c:946b with SMTP id h30-20020a50cdde000000b0053db53c946bmr42816edj.2.1697236549785; Fri, 13 Oct 2023 15:35:49 -0700 (PDT) MIME-Version: 1.0 References: <20231009142005.21338-1-quic_kriskura@quicinc.com> <20231009142005.21338-2-quic_kriskura@quicinc.com> <8ff92053-52ff-4950-95c8-0e986f6a028a@quicinc.com> In-Reply-To: From: =?UTF-8?Q?Maciej_=C5=BBenczykowski?= Date: Fri, 13 Oct 2023 15:35:32 -0700 Message-ID: Subject: Re: [PATCH 2/2] usb: gadget: ncm: Add support to update wMaxSegmentSize via configfs To: Krishna Kurapati PSSNV Cc: Greg Kroah-Hartman , onathan Corbet , Linyu Yuan , linux-usb@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, quic_ppratap@quicinc.com, quic_wcheng@quicinc.com, quic_jackp@quicinc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 15:36:13 -0700 (PDT) On Fri, Oct 13, 2023 at 12:58=E2=80=AFPM Krishna Kurapati PSSNV wrote: > > > > On 10/14/2023 12:09 AM, Maciej =C5=BBenczykowski wrote: > > On Thu, Oct 12, 2023 at 8:40=E2=80=AFAM Krishna Kurapati PSSNV > > wrote: > >> > >> > >> > >> On 10/12/2023 6:02 PM, Maciej =C5=BBenczykowski wrote: > >>> On Thu, Oct 12, 2023 at 1:48=E2=80=AFAM Krishna Kurapati PSSNV > >>> > >>> Could you paste the full patch? > >>> This is hard to review without looking at much more context then emai= l > >>> is providing > >>> (or, even better, send me a link to a CL in gerrit somewhere - for > >>> example aosp ACK mainline tree) > >> > >> Sure. Will provide a gerrit on ACK for review before posting v2. > >> > >> The intent of posting the diff was two fold: > >> > >> 1. The question Greg asked regarding why the max segment size was > >> limited to 15014 was valid. When I thought about it, I actually wanted > >> to limit the max MTU to 15000, so the max segment size automatically > >> needs to be limited to 15014. > > > > Note that this is a *very* abstract value. > > I get you want L3 MTU of 10 * 1500, but this value is not actually mean= ingful. > > > > IPv4/IPv6 fragmentation and IPv4/IPv6 TCP segmentation > > do not result in a trivial multiplication of the standard 1500 byte > > ethernet L3 MTU. > > Indeed aggregating 2 1500 L3 mtu frames results in *different* sized > > frames depending on which type of aggregation you do. > > (and for tcp it even depends on the number and size of tcp options, > > though it is often assumed that those take up 12 bytes, since that's th= e > > normal for Linux-to-Linux tcp connections) > > > > For example if you aggregate N standard Linux ipv6/tcp L3 1500 mtu fram= es, > > this means you have > > N frames: ethernet (14) + ipv6 (40) + tcp (20) + tcp options (12) + > > payload (1500-12-20-40=3D1500-72=3D1428) > > post aggregation: > > 1 frame: ethernet (14) + ipv6 (40) + tcp (20) + tcp options (12) + > > payload (N*1428) > > > > so N * 1500 =3D=3D N * (72 + 1428) --> 1 * (72 + N * 1428) > > > > That value of 72 is instead 52 for 'standard Linux ipv4/tcp), > > it's 40/60 if there's no tcp options (which I think happens when > > talking to windows) > > it's different still with ipv4 fragmentation... and again different > > with ipv6 fragmentation... > > etc. > > > > ie. 15000 L3 mtu is exactly as meaningless as 14000 L3 mtu. > > Either way you don't get full frames. > > > > As such I'd recommend going with whatever is the largest mtu that can > > be meaningfully made to fit in 16K with all the NCM header overhead. > > That's likely closer to 15500-16000 (though I have *not* checked). > > > >> But my commit text didn't mention this > >> properly which was a mistake on my behalf. But when I looked at the > >> code, limiting the max segment size 15014 would force the practical > >> max_mtu to not cross 15000 although theoretical max_mtu was set to: > >> (GETHER_MAX_MTU_SIZE - 15412) during registration of net device. > >> > >> So my assumption of limiting it to 15000 was wrong. It must be limited > >> to 15412 as mentioned in u_ether.c This inturn means we must limit > >> max_segment_size to: > >> GETHER_MAX_ETH_FRAME_LEN (GETHER_MAX_MTU_SIZE + ETH_HLEN) > >> as mentioned in u_ether.c. > >> > >> I wanted to confirm that setting MAX_DATAGRAM_SIZE to > >> GETHER_MAX_ETH_FRAME_LEN was correct. > >> > >> 2. I am not actually able to test with MTU beyond 15000. When my host > >> device is a linux machine, the cdc_ncm.c limits max_segment_size to: > >> CDC_NCM_MAX_DATAGRAM_SIZE 8192 /* bytes */ > > > > In practice you get 50% of the benefits of infinitely large mtu by > > going from 1500 to ~2980. > > you get 75% of the benefits by going to ~6K > > you get 87.5% of the benefits by going to ~12K > > the benefits of going even higher are smaller and smaller... > > > If the host side is limited to 8192, maybe we should match that here= too? > > Hi Maciej, > > Thanks for the detailed explanation. I agree with you on setting > device side also to 8192 instead of what max_mtu is present in u_ether > or practical max segment size possible. > > > > > But the host side limitation of 8192 doesn't seem particularly sane eit= her... > > Maybe we should relax that instead? > > > I really didn't understand why it was set to 8192 in first place. > > > (especially since for things like tcp zero copy you want an mtu which > > is slighly more then N * 4096, > > ie. around 4.5KB, 8.5KB, 12.5KB or something like that) > > > > I am not sure about host mode completely. If we want to increase though, > just increasing the MAX_DATAGRAM_SIZE to some bigger value help ? (I > don't know the entire code of cdc_ncm, so I might be wrong). > > Regards, > Krishna, Hmm, I'm not sure. I know I've experimented with high mtu ncm in the past (around 2.5 years ago). I got it working between my Linux desktop (host) and a Pixel 6 (device/gadget) with absolutely no problems. I'm pretty sure I didn't change my desktop kernel, so I was probably limited to 8192 there (and I do more or less remember that). From what I vaguely remember, it wasn't difficult (at all) to hit upwards of 7gbps for iperf tests. I don't remember how close to the theoretical USB 10gbps maximum of 9.7gbps I could get... [this was never the real bottleneck / issue, so I didn't ever dig particularly deep] I'm pretty sure my gadget side changes were non-configurable... Probably just bumped one or two constants... I do *very* *vaguely* recall there being some funkiness though, where 8192 = was *less* efficient than some slightly smaller value. If I recall correctly the issue is that 8192 + ethernet overhead + NCM overhead only fits *once* into 16384, which leaves a lot of space wasted. While ~7.5 kb + overhead fits twice and is thus a fair bit better. I don't remember if I found a way to boost the 16384 to double or triple th= at. That should have been a win, I can't remember if we were usb3 spec limitted there.