Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2267847rdg; Sun, 15 Oct 2023 20:48:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZjacrThTAKjer6E9IFQcjMTln1iPArsDlbt6T0CoAMifbzIYzRlsS4HFQ+xq5TclLEQdl X-Received: by 2002:a05:6808:1527:b0:3a7:2390:3583 with SMTP id u39-20020a056808152700b003a723903583mr43852862oiw.38.1697428133920; Sun, 15 Oct 2023 20:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697428133; cv=none; d=google.com; s=arc-20160816; b=aYG1+E/7HOTnlfuB9I3UUkFA2xT+CnwPNxc8OL6DVFyIlGWB5bavh4wbJIzgh6mU31 rl1wRSHqs3Lcmav8YFrCmUfDTADHYJtX52tQiwCECLQ0MqngpVi4aQVr1xyelHtbjRq2 z9K5Bgdo4a9sEMHHI5eh46RBXwxe8TWkcVkNGkx1etkAGZjcEy61wgLutEO8Fd4AKvp7 CGG1yP7QUa35XncAJ+tx7XHnhYZJbAVlLKJx2tmaiM6aNCVOFLJlITndu0rKDnrFG6Sk jJFqwqtrTlHy9XM3LczxlGKtVHDjbwisNpiRyOkWBgaeTDX4qtCRwYZEbcM8ueOjLZaT hEZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qNg14GcggDnrj3270YNJfGynOyIYi98iCn9wUS7HdVo=; fh=VJuicnRMTSuSFlbQfrJ+IsdiUvwukDEoxMOocMLNPKU=; b=rVXS2XMLH2pz9tkyVFUF4TR1lBwu5PAsjpdM45NZC2GEEOx9i9ox8dvy3rNKJGZrYj mQ7yynsq5l7OS1hvZGApCwzYuGwKaGuo7dP/qMPrBfhn2yikj/xaRvYmzUQjY4WiUsN6 URdrSqf82xFQ2xTQGuxhAXfjI+xO2QFoJD07XJOyGUttNKuk/Ys7/5BS/pWmGV6fHGwA lGkGuf5aATiz2SUXBFiCKDK5hv3rQd7IvNqo6ymas9nj/IB/5B1IzPbuMTKtjwngTcBr IrcIjjtCLEJkWKzPi4EJ55bOlq2IrTQ6kVT4FQkrCQQZyOqTA3lMD/k6xwclGt324B/Y muIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TMqDbG8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j31-20020a63551f000000b00578bd92e502si9316785pgb.558.2023.10.15.20.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 20:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TMqDbG8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 332688043009; Sun, 15 Oct 2023 20:48:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjJPDsV (ORCPT + 99 others); Sun, 15 Oct 2023 23:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjJPDsU (ORCPT ); Sun, 15 Oct 2023 23:48:20 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF68BAD; Sun, 15 Oct 2023 20:48:18 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39G2qCk4026107; Mon, 16 Oct 2023 03:48:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=qNg14GcggDnrj3270YNJfGynOyIYi98iCn9wUS7HdVo=; b=TMqDbG8MiB/m4qsgHGITwiMljlKkmVjP41DQgGNk1pqZiLAyOGoeZ+d11+p+wgJGpXiR Wb93k0rmrt2+YpCYdjVD5/BMJe77IWOB6NKcBJmLHC5C3+FutoNMdtyNckmvwt3/7p2C +i26HAmWbVsJkkcpqm/KQzyEL3zA/u1fZXhkplE7f+7f2LBI2FZG63A47/9pauZWQgdc zKMnv3HMnFRkQa87VzDF1Qt79bFYRZjzRwb84rDKVxej+lFUnStsPqgh6DuKW3FCqrEa Fh8YMtAmAx9OqO+77MhHTGdf2+bCP/i6FxcMfcZ9B9Kh5hg3fcS1RI41sBFK7U6+3aQJ yA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tqgbt37cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Oct 2023 03:48:15 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39G3mEeA004601 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Oct 2023 03:48:14 GMT Received: from [10.216.5.27] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Sun, 15 Oct 2023 20:48:10 -0700 Message-ID: <20632da6-3144-47d3-b1dc-0446e4e55a19@quicinc.com> Date: Mon, 16 Oct 2023 09:18:13 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] usb: gadget: ncm: Add support to update wMaxSegmentSize via configfs To: =?UTF-8?Q?Maciej_=C5=BBenczykowski?= CC: Greg Kroah-Hartman , onathan Corbet , Linyu Yuan , , , , , , References: <20231009142005.21338-1-quic_kriskura@quicinc.com> <20231009142005.21338-2-quic_kriskura@quicinc.com> <8ff92053-52ff-4950-95c8-0e986f6a028a@quicinc.com> <70c15867-ccce-4788-a0dd-38a73decb785@quicinc.com> Content-Language: en-US From: Krishna Kurapati PSSNV In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 5_5IheJW5851YTctblNiWnZPfBAxQFV3 X-Proofpoint-ORIG-GUID: 5_5IheJW5851YTctblNiWnZPfBAxQFV3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-15_09,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 mlxlogscore=302 adultscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310160032 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sun, 15 Oct 2023 20:48:51 -0700 (PDT) On 10/16/2023 6:49 AM, Maciej Żenczykowski wrote: >>>> >>>> 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... >>>> >>> Could you share what parameters you changed to get this high value of >>> iperf throughput. > > Eh, I really don't remember, but it wasn't anything earth shattering. > From what I recall it was just a matter of bumping mtu, and tweaking > irq pinning to stronger cores. > Indeed I'm not even certain that the mtu was required to be over 5gbps. > Though I may be confusing some things, as at least some of the testing was done > with the kernel's built in packet generator. > >>> >>>> 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. >>> Right, same goes for using 5K vs 5.5K MTU. If MTU is 5K, 3 packets can >>> conveniently fit into an NTB but if its 5.5, at max only two (5.5k) >>> packets can fit in (essentially filling ~11k of the 16384 bytes and >>> wasting the rest) >> >> Formatting gone wrong. So pasting the first paragraph again here: >> >> "Right, same goes for using 5K vs 5.5K MTU. If MTU is 5K, 3 packets can >> conveniently fit into an NTB but if its 5.5, at max only two (5.5k) >> packets can fit in (essentially filling ~11k of the 16384 bytes and >> wasting the rest)" >> >>> >>> And whether its Ipv4/Ipv6 like you mentioned on [1], the MTU is what NCM >>> layer receives and we append the Ethernet header and add NCM headers and >>> send it out after aggregation. Why can't we set the MAX_DATAGRAM_SIZE to >>> ~8050 or ~8100 ? The reason I say this value is, obviously setting it to >>> 8192 would not efficiently use the NTB buffer. We need to fill as much >>> space in buffer as possible and assuming that each packet received on >>> ncm layer is of MTU size set (not less that that), we can assume that >>> even if only 2 packets are aggregated (minimum aggregation possible), we >>> would be filling (2 * (8050 + ETH_HLEN) + (room for NCM headers)) would >>> almost be close to 16384 ep max packet size. I already check 8050 MTU >>> and it works. We can add a comment in code detailing the above >>> explanation and why we chose to use 8050 or 8100 as MAX_DATAGRAM_SIZE. >>> >>> Hope my reasoning of why we can chose 8.1K or 8.05K makes sense. Let me >>> know your thoughts on this. > > Maybe just use an L3 mtu of 8000 then? That's a nice round number... > But I'm also fine with 8050 or 8100.. though 8100 seems 'rounder'. > > I'm not sure what the actual overhead is... I guess we control the > overhead in one direction, but not in the other, and there could be > some slop, so we need to be a little generous? > >>> Hi Maciej, Sure. Let's go with 8000 to leave some space for headers. And would add the following paragraph as comment for readers to understand why this value was set: "Although max mtu as dictated by u_ether is 15412 bytes, setting max_segment_size to 15426 would not be efficient. If user chooses segment size to be (> 8192), then we can't aggregate more than one buffer in each NTB (assuming each packet coming from network layer is > 8192 bytes) as ep maxpacket limit is 16384. So let max_segment_size be limited to 8000 to allow atleast 2 packets to be aggregated reducing wastage of NTB buffer space" Hope that would be fine. Regards, Krishna,