From: "Bjørn Mork" <bjorn-yOkvZcmFvRU@public.gmane.org>
To: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Alexey Orishko
<alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Enrico Mioso <mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
David Laight
<David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>
Subject: Re: [PATCH net-next 01/11] net: cdc_ncm: split out rx_max/tx_max update of setup
Date: Tue, 13 May 2014 11:25:28 +0200 [thread overview]
Message-ID: <87sioe114n.fsf@nemi.mork.no> (raw)
In-Reply-To: <1399972165.8278.11.camel-B2T3B9s34ElbnMAlSieJcQ@public.gmane.org> (Oliver Neukum's message of "Tue, 13 May 2014 11:09:25 +0200")
Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org> writes:
>> The reason I put that min_t() there instead was an attempt to deal with
>> the (not unlikely) event that some buggy device set dwNtbInMaxSize lower
>> than this required minimum value. We then have the choices:
>>
>> a) fail to support the buggy device
>> b) attempt to set a larger buffer size than the device supports
>> c) accept the lower size
>
> My preference would be b) > a) > c)
> It seems to me that would should respect the spec and if the spec sets
> a lower limit then we don't go lower.
>
>> So I chose c) in an attempt to be as gentle as possible. But I am open
>> to go for a) instead if you think that is better. After all
>> USB_CDC_NCM_NTB_MIN_IN_SIZE is as low as 2048, so it doesn't fit much
>> more than the headers and a single full size ethernet frame. And I see
>> now that we fail to do further sanity checking after this. What if
>> dwNtbInMaxSize is 0? Or smaller than the necessary headers?
>
> Exactly. Some fool may simply overlook setting it at all.
>
>> Should I rewrite the above to do a) instead? I.e.
>>
>> min = USB_CDC_NCM_NTB_MIN_IN_SIZE;
>> max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_RX, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize));
>> if (min > max)
>> fail;
>>
>> I don't think b) is a good idea. It might work, but it might also fail
>> in surprising ways making it hard to debug.
>
> Users may prefer working devices to clean failures, but
> I primarily care about conforming to spec. We just shouldn't
> do such violations in a general case.
Yes, I agree. Will change this. Let's try to go for b) then. I.e.
min = USB_CDC_NCM_NTB_MIN_IN_SIZE;
max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_RX, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize));
if (max < min)
max = min;
Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-05-13 9:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-10 15:41 [PATCH net-next 00/11] cdc_ncm: add buffer tuning and stats using ethtool Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 02/11] net: cdc_ncm: factor out one-time device initialization Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 03/11] net: cdc_ncm: split .bind " Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 05/11] net: cdc_ncm: use ethtool to tune coalescing settings Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 06/11] net: cdc_ncm: use true max dgram count for header estimates Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 07/11] net: cdc_ncm: set reasonable padding limits Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 08/11] net: cdc_ncm/cdc_mbim: adding NCM protocol statiscics Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 09/11] net: cdc_ncm: use sane defaults for rx/tx buffers Bjørn Mork
[not found] ` <1399736509-1159-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2014-05-10 15:41 ` [PATCH net-next 01/11] net: cdc_ncm: split out rx_max/tx_max update of setup Bjørn Mork
2014-05-13 8:09 ` Oliver Neukum
2014-05-13 8:49 ` Bjørn Mork
2014-05-13 9:09 ` Oliver Neukum
[not found] ` <1399972165.8278.11.camel-B2T3B9s34ElbnMAlSieJcQ@public.gmane.org>
2014-05-13 9:25 ` Bjørn Mork [this message]
2014-05-13 11:07 ` Oliver Neukum
2014-05-10 15:41 ` [PATCH net-next 04/11] net: cdc_ncm: support rx_max/tx_max updates when running Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 10/11] net: cdc_ncm: fix argument alignment Bjørn Mork
2014-05-10 15:41 ` [PATCH net-next 11/11] net: cdc_ncm: remove redundant "disconnected" flag Bjørn Mork
2014-05-11 9:14 ` Enrico Mioso (@atlantide)
-- strict thread matches above, loose matches on Subject: below --
2014-05-13 9:40 [PATCH net-next 01/11] net: cdc_ncm: split out rx_max/tx_max update of setup Enrico Mioso
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=87sioe114n.fsf@nemi.mork.no \
--to=bjorn-yokvzcmfvru@public.gmane.org \
--cc=David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org \
--cc=alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=oneukum-l3A5Bk7waGM@public.gmane.org \
/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).