netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>
To: "'Bjørn Mork'" <bjorn-yOkvZcmFvRU@public.gmane.org>,
	"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Alexey Orishko
	<alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>,
	Enrico Mioso <mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Lars Melin <larsm17-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Peter Stuge <peter-Y+HMSxxDrH8@public.gmane.org>,
	Greg Suarez <gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org>
Subject: RE: [PATCH v2 net-next 3/8] net: cdc_ncm: inform usbnet when rx buffers are reduced
Date: Fri, 30 May 2014 09:18:37 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1725057A@AcuExch.aculab.com> (raw)
In-Reply-To: <1401435070-26721-4-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>

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.
(Or multiples of the USB packet size, and the driver then merge URB
when generating skbs.)

Since you are now copying the data out of the URB's skb before
passing the ethernet packet upstream, is there ever any real
requirement to use a small rx_max? or ever change rx_max?

	David

> Fixes: 68864abf08f0 ("net: cdc_ncm: support rx_max/tx_max updates when running")
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
> ---
>  drivers/net/usb/cdc_ncm.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index ff5b3a854898..5bce86a0d063 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -215,19 +215,12 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
>  			min, max, val);
>  	}
> 
> -	/* usbnet use these values for sizing rx queues */
> -	dev->rx_urb_size = val;
> -
>  	/* inform device about NTB input size changes */
>  	if (val != ctx->rx_max) {
>  		__le32 dwNtbInMaxSize = cpu_to_le32(val);
> 
>  		dev_info(&dev->intf->dev, "setting rx_max = %u\n", val);
> 
> -		/* need to unlink rx urbs before increasing buffer size */
> -		if (netif_running(dev->net) && dev->rx_urb_size > ctx->rx_max)
> -			usbnet_unlink_rx_urbs(dev);
> -
>  		/* tell device to use new size */
>  		if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE,
>  				     USB_TYPE_CLASS | USB_DIR_OUT
> @@ -238,6 +231,13 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
>  			ctx->rx_max = val;
>  	}
> 
> +	/* usbnet use these values for sizing rx queues */
> +	if (dev->rx_urb_size != ctx->rx_max) {
> +		dev->rx_urb_size = ctx->rx_max;
> +		if (netif_running(dev->net))
> +			usbnet_unlink_rx_urbs(dev);
> +	}
> +
>  	/* clamp new_tx to sane values */
>  	min = ctx->max_datagram_size + ctx->max_ndp_size + sizeof(struct usb_cdc_ncm_nth16);
>  	max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
> --
> 2.0.0.rc4


  parent reply	other threads:[~2014-05-30  9:18 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 [this message]
2014-05-30 11:39       ` Bjørn Mork
2014-05-30 12:39         ` David Laight
2014-05-30 13:35           ` Bjørn Mork
     [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=063D6719AE5E284EB5DD2968C1650D6D1725057A@AcuExch.aculab.com \
    --to=david.laight-zs65k/vg3hxxriks9f7cxa@public.gmane.org \
    --cc=alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=bjorn-yOkvZcmFvRU@public.gmane.org \
    --cc=gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org \
    --cc=larsm17-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=oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org \
    --cc=peter-Y+HMSxxDrH8@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).