From: Krishna Kurapati PSSNV <quic_kriskura@quicinc.com>
To: "Maciej Żenczykowski" <maze@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
onathan Corbet <corbet@lwn.net>,
Linyu Yuan <quic_linyyuan@quicinc.com>,
<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
Date: Mon, 16 Oct 2023 09:18:13 +0530 [thread overview]
Message-ID: <20632da6-3144-47d3-b1dc-0446e4e55a19@quicinc.com> (raw)
In-Reply-To: <CANP3RGcnpkcLK_CRfSLvxyGM3L0j5R3fybeF_L1bmRV9hNBcuQ@mail.gmail.com>
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,
next prev parent reply other threads:[~2023-10-16 3:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 14:20 [PATCH 1/2] Documentation: usb: Update NCM configfs parameters Krishna Kurapati
2023-10-09 14:20 ` [PATCH 2/2] usb: gadget: ncm: Add support to update wMaxSegmentSize via configfs Krishna Kurapati
2023-10-09 15:08 ` Greg Kroah-Hartman
2023-10-09 15:32 ` Krishna Kurapati PSSNV
2023-10-09 17:54 ` Greg Kroah-Hartman
2023-10-09 18:27 ` Krishna Kurapati PSSNV
2023-10-10 0:17 ` Maciej Żenczykowski
2023-10-10 0:20 ` Maciej Żenczykowski
2023-10-10 0:37 ` Maciej Żenczykowski
2023-10-10 4:38 ` Krishna Kurapati PSSNV
2023-10-12 8:48 ` Krishna Kurapati PSSNV
2023-10-12 12:32 ` Maciej Żenczykowski
2023-10-12 15:40 ` Krishna Kurapati PSSNV
2023-10-13 18:39 ` Maciej Żenczykowski
2023-10-13 18:40 ` Maciej Żenczykowski
2023-10-13 19:58 ` Krishna Kurapati PSSNV
2023-10-13 22:35 ` Maciej Żenczykowski
2023-10-14 7:02 ` Krishna Kurapati PSSNV
2023-10-14 8:23 ` Krishna Kurapati PSSNV
2023-10-16 1:19 ` Maciej Żenczykowski
2023-10-16 3:48 ` Krishna Kurapati PSSNV [this message]
2023-10-10 4:34 ` Krishna Kurapati PSSNV
2023-10-10 4:27 ` Krishna Kurapati PSSNV
2023-10-10 22:26 ` kernel test robot
2023-10-09 15:05 ` [PATCH 1/2] Documentation: usb: Update NCM configfs parameters Greg Kroah-Hartman
2023-10-09 15:10 ` Krishna Kurapati PSSNV
2023-10-09 15:21 ` Greg Kroah-Hartman
2023-10-09 15:33 ` Krishna Kurapati PSSNV
2023-10-09 15:42 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20632da6-3144-47d3-b1dc-0446e4e55a19@quicinc.com \
--to=quic_kriskura@quicinc.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=maze@google.com \
--cc=quic_jackp@quicinc.com \
--cc=quic_linyyuan@quicinc.com \
--cc=quic_ppratap@quicinc.com \
--cc=quic_wcheng@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox