Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1956894rdb; Mon, 9 Oct 2023 08:08:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDfakZjQORIu8TIhLrIfpcbvWCSj4qshkZGyiP0NAS9OEq+xkLz/Z1mV4/eltLkrHo5AYq X-Received: by 2002:a05:6a20:a11f:b0:16b:b0ea:b0a1 with SMTP id q31-20020a056a20a11f00b0016bb0eab0a1mr8653638pzk.34.1696864129976; Mon, 09 Oct 2023 08:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696864129; cv=none; d=google.com; s=arc-20160816; b=i4NSyzkgg6euZNYcl6+HT07RWYX1Xo+NsUeBFQ2hFCjAuB+1QfD/CLTgfFkC9vHzGg Q4o0Tjz/YZMRCW7+AqiVj4Qnb98y6wJX9qKwEyPUexevQ8VoSlis7+h6CJVFJPp3Bji8 pfDQ6YcKFr5ShbDbEo5O2wEq4bdyUJxrdwbmDSJQnlvzoQHl1CKHtEDKxMRrlsTvBJNU S6Pozaiz+Zn+sEvHr9xAVeaz5lAXXmQYqA+r3cx4fYzpwkitUaZREQpBKvVILxtCktwf mtRSnOy2VIoWued83ErDFZj1dGftdnW8xxU847Du5ejq1WhIWBOUvtMyFPdJW5ufmuWU G5HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EFlrXLHRzz1KVZlTOSdp8FnfdwpgvWcdWmU31PBcCC4=; fh=cnjq7lv9HiTQXIoJmauiXUjbJqX4RtHdqs8ng7Li8YI=; b=bAamYPuRFlkHhJBQGdZUQrK6+sExW4weB+EjAbVPjDht6wEE6WjD4H7UttfBf7TXqO xiTnkEs5CqPgweCwwpqYbKQQ93+Bozwx4wSSrzCjhLWpFlxI+D9FWbkbDFQwBl1uN4rW Txse3ohK+4xkQVFAspQIJu+3eVsin9Dlf/Fc7ANHqSWydzD5cQIbUuHcIAA8TvAkCjBz RQTiJ9XKz9y/p6790uGuY79zXIkjTGEZJBQnTaTepc0/YxxgyxA8/15XjTWG2V46gfSo iS0bOKLf7pdfRwQHeG7BPtsjXZm+2XzP/wyszgTh7kXnKoREJI8P56HnXZszh+rw4FYD OSCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CHwUOMlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id k21-20020a170902f29500b001bd9d2e20absi9383634plc.230.2023.10.09.08.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CHwUOMlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 588D5803DAD4; Mon, 9 Oct 2023 08:08:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376333AbjJIPIh (ORCPT + 99 others); Mon, 9 Oct 2023 11:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346567AbjJIPIf (ORCPT ); Mon, 9 Oct 2023 11:08:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6571B9E; Mon, 9 Oct 2023 08:08:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A55F6C433C7; Mon, 9 Oct 2023 15:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696864114; bh=r36vFBcTVq6uDwqhbi9cOT6hngO8r2QtiwqiCrlmXNc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CHwUOMlGn4ZsfhhY017MjAYjRfs3e+y5m24/Jb/6p+qQ2Atb4GrKwEIhAcDi5mu/5 rFFCn0L34LW8V3B+gRZmtjA7L13IlSLN6OEDOKBiv0aMtl4UxGB/G3myMcfcqJMsu+ VTMbZOuEIuBa+fWi1RqAbA53ZxcEMtHsiK21xTio= Date: Mon, 9 Oct 2023 17:08:31 +0200 From: Greg Kroah-Hartman To: Krishna Kurapati Cc: Maciej =?utf-8?Q?=C5=BBenczykowski?= , 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 Subject: Re: [PATCH 2/2] usb: gadget: ncm: Add support to update wMaxSegmentSize via configfs Message-ID: <2023100931-reward-justice-ed1c@gregkh> References: <20231009142005.21338-1-quic_kriskura@quicinc.com> <20231009142005.21338-2-quic_kriskura@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009142005.21338-2-quic_kriskura@quicinc.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Mon, 09 Oct 2023 08:08:46 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 07:50:05PM +0530, Krishna Kurapati wrote: > Currently the NCM driver restricts wMaxSegmentSize that indicates > the datagram size coming from network layer to 1514. I don't see that restriction in the existing driver, where does that happen? > However the spec doesn't have any limitation. What spec? > For P2P connections over NCM, increasing MTU helps increasing > throughput. While increasing latency, right? > Add support to configure this value before configfs symlink is > created. Also since the NTB Out/In buffer sizes are fixed at 16384 > bytes, limit the segment size to an upper cap of 15014. Set the > default MTU size for the ncm interface during function bind before > network interface is registered allowing MTU to be set in parity > with wMaxSegmentSize. Where does 15014 come from? > > Signed-off-by: Krishna Kurapati > --- > drivers/usb/gadget/function/f_ncm.c | 51 +++++++++++++++++++++++++++++ > drivers/usb/gadget/function/u_ncm.h | 2 ++ > 2 files changed, 53 insertions(+) > > diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c > index feccf4c8cc4f..eab297b22200 100644 > --- a/drivers/usb/gadget/function/f_ncm.c > +++ b/drivers/usb/gadget/function/f_ncm.c > @@ -103,6 +103,8 @@ static inline struct f_ncm *func_to_ncm(struct usb_function *f) > /* Delay for the transmit to wait before sending an unfilled NTB frame. */ > #define TX_TIMEOUT_NSECS 300000 > > +#define MAX_DATAGRAM_SIZE 15014 Where does this magic value come from? Please document it really really well. > + > #define FORMATS_SUPPORTED (USB_CDC_NCM_NTB16_SUPPORTED | \ > USB_CDC_NCM_NTB32_SUPPORTED) > > @@ -1408,6 +1410,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) > ncm_opts = container_of(f->fi, struct f_ncm_opts, func_inst); > > if (cdev->use_os_string) { > + ncm_opts->net->mtu = (ncm_opts->max_segment_size - ETH_HLEN); > f->os_desc_table = kzalloc(sizeof(*f->os_desc_table), > GFP_KERNEL); > if (!f->os_desc_table) > @@ -1469,6 +1472,8 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) > > status = -ENODEV; > > + ecm_desc.wMaxSegmentSize = ncm_opts->max_segment_size; > + > /* allocate instance-specific endpoints */ > ep = usb_ep_autoconfig(cdev->gadget, &fs_ncm_in_desc); > if (!ep) > @@ -1569,11 +1574,56 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm); > /* f_ncm_opts_ifname */ > USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); > > +static ssize_t ncm_opts_max_segment_size_show(struct config_item *item, > + char *page) > +{ > + struct f_ncm_opts *opts = to_f_ncm_opts(item); > + u32 segment_size; > + > + mutex_lock(&opts->lock); > + segment_size = opts->max_segment_size; > + mutex_unlock(&opts->lock); > + > + return sprintf(page, "%u\n", segment_size); sysfs_emit()? thanks, greg k-h