From: "Bjørn Mork" <bjorn@mork.no>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "netdev\@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-usb\@vger.kernel.org" <linux-usb@vger.kernel.org>,
Alexey Orishko <alexey.orishko@gmail.com>,
Oliver Neukum <oliver@neukum.org>,
Enrico Mioso <mrkiko.rs@gmail.com>,
Lars Melin <larsm17@gmail.com>, Peter Stuge <peter@stuge.se>,
Greg Suarez <gsuarez@smithmicro.com>
Subject: Re: [PATCH v2 net-next 3/8] net: cdc_ncm: inform usbnet when rx buffers are reduced
Date: Fri, 30 May 2014 15:35:43 +0200 [thread overview]
Message-ID: <87r43b8k40.fsf@nemi.mork.no> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D172506D0@AcuExch.aculab.com> (David Laight's message of "Fri, 30 May 2014 12:39:55 +0000")
David Laight <David.Laight@ACULAB.COM> writes:
> From: Bjørn Mork
>> David Laight <David.Laight@ACULAB.COM> writes:
>> > From: Bjørn Mork
>> >> It doesn't matter whether the buffer size goes up or down. We have to
>> >> keep usbnet and device syncronized to be able to split transfers at the
>> >> correct boundaries. The spec allow skipping short packets when using
>> >> max sized transfers. If we don't tell usbnet about our new expected rx
>> >> buffer size, then it will merge and/or split NTBs. The driver does not
>> >> support this, and the result will be lots of framing errors.
>> >>
>> >> Fix by always reallocating usbnet rx buffers when the rx_max value
>> >> changes.
>> >
>> > I'm guessing that the rx_max value is the maximum size of the USB bulk
>> > data 'message' that the device generates?
>> >
>> > As such the URB only need to be longer that it.
>>
>> So did I think too at first. That's how I added the bug fixed by this
>> commit :-)
>>
>> The problem with NCM is that it explicitly allows (and encourage) using
>> transfers which are multiples of the USB packet size, *without* any
>> terminating short packet (0 or 1 byte). This means that the USB core
>> won't know or care about the end of one transfer and the beginning of
>> the next. Which is fine. But the cdc_ncm driver has to know, because
>> it must split the transfers into frames it can decode.
>>
>> Now, the current cdc_ncm implementation has a built-in assumption that
>> the size of the URB == rx_max. This lets it simplify the splitting into
>> frames to nearly nothing: Any received URB contains exactly one frame.
>> Therefore we need to keep the rx URB size strictly syncronized the
>> rx_max.
>
> Hmmm....
> So there is an ethernet packet size somewhere near 500 that exactly fills
> a 512 byte USB2 frame.
> If you receive one of those does the hardware send a 0 length terminating
> fragment?
> If not the then URB won't complete until after the next ethernet frame
> arrives.
> Receive three of them followed by a longer frame and you'll overrun the
> end of the URB.
>
> At least one path through usbnet ensures that the rx buffers aren't
> a multiple of the USB frame size. I'm not sure whether that really helps.
>
> Sounds like the hardware expects you to receive each USB bulk buffer
> separately.
Please, go read the NCM spec.
Bjørn
next prev parent reply other threads:[~2014-05-30 13:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 7:31 [PATCH v2 net-next 0/8] cdc_ncm: fixes and conversion to sysfs API Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 1/8] net: cdc_ncm: reduce skb truesize in rx path Bjørn Mork
[not found] ` <1401435070-26721-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2014-05-30 7:31 ` [PATCH v2 net-next 2/8] net: cdc_ncm: always reallocate tx_curr_skb when tx_max increases Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 4/8] net: cdc_ncm: use sysfs for rx/tx aggregation tuning Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 3/8] net: cdc_ncm: inform usbnet when rx buffers are reduced Bjørn Mork
[not found] ` <1401435070-26721-4-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2014-05-30 9:18 ` David Laight
2014-05-30 11:39 ` Bjørn Mork
2014-05-30 12:39 ` David Laight
2014-05-30 13:35 ` Bjørn Mork [this message]
[not found] ` <87d2eva41t.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2014-05-30 12:42 ` David Laight
2014-05-30 13:39 ` Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 5/8] net: cdc_ncm: drop ethtool coalesce support Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 6/8] net: cdc_ncm: export NCM Transfer Block (NTB) parameters Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 7/8] net: cdc_ncm: allow tuning min_tx_pkt Bjørn Mork
2014-05-30 7:31 ` [PATCH v2 net-next 8/8] net: cdc_ncm: document the sysfs API Bjørn Mork
2014-06-02 23:02 ` [PATCH v2 net-next 0/8] cdc_ncm: fixes and conversion to " David Miller
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=87r43b8k40.fsf@nemi.mork.no \
--to=bjorn@mork.no \
--cc=David.Laight@ACULAB.COM \
--cc=alexey.orishko@gmail.com \
--cc=gsuarez@smithmicro.com \
--cc=larsm17@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mrkiko.rs@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=peter@stuge.se \
/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;
as well as URLs for NNTP newsgroup(s).