aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-30 03:31:05 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-02 19:01:30 -0400
commitf42763dbdf043c9996dfabf6d167eab28e016eb8 (patch)
tree87ac340cfb756e9b725f18f2d7b99be3414e68fd
parent1ba5d0ff36f765a571c83b55b13ec44f4050fb5b (diff)
net: cdc_ncm: inform usbnet when rx buffers are reduced
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. Fixes: 68864abf08f0 ("net: cdc_ncm: support rx_max/tx_max updates when running") Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/cdc_ncm.c14
1 files 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)
215 min, max, val); 215 min, max, val);
216 } 216 }
217 217
218 /* usbnet use these values for sizing rx queues */
219 dev->rx_urb_size = val;
220
221 /* inform device about NTB input size changes */ 218 /* inform device about NTB input size changes */
222 if (val != ctx->rx_max) { 219 if (val != ctx->rx_max) {
223 __le32 dwNtbInMaxSize = cpu_to_le32(val); 220 __le32 dwNtbInMaxSize = cpu_to_le32(val);
224 221
225 dev_info(&dev->intf->dev, "setting rx_max = %u\n", val); 222 dev_info(&dev->intf->dev, "setting rx_max = %u\n", val);
226 223
227 /* need to unlink rx urbs before increasing buffer size */
228 if (netif_running(dev->net) && dev->rx_urb_size > ctx->rx_max)
229 usbnet_unlink_rx_urbs(dev);
230
231 /* tell device to use new size */ 224 /* tell device to use new size */
232 if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE, 225 if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE,
233 USB_TYPE_CLASS | USB_DIR_OUT 226 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)
238 ctx->rx_max = val; 231 ctx->rx_max = val;
239 } 232 }
240 233
234 /* usbnet use these values for sizing rx queues */
235 if (dev->rx_urb_size != ctx->rx_max) {
236 dev->rx_urb_size = ctx->rx_max;
237 if (netif_running(dev->net))
238 usbnet_unlink_rx_urbs(dev);
239 }
240
241 /* clamp new_tx to sane values */ 241 /* clamp new_tx to sane values */
242 min = ctx->max_datagram_size + ctx->max_ndp_size + sizeof(struct usb_cdc_ncm_nth16); 242 min = ctx->max_datagram_size + ctx->max_ndp_size + sizeof(struct usb_cdc_ncm_nth16);
243 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize)); 243 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));