aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-16 15:48:21 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 22:39:01 -0400
commit68864abf08f06d7cbbabd03740beb383ccf5e5d5 (patch)
treed1aadb32c48e3af16e28662a6f0a0adaed4fab99 /drivers/net/usb
parent08c74fc901a2e91de762d99ba3d493281862e29a (diff)
net: cdc_ncm: support rx_max/tx_max updates when running
Finish the rx_max/tx_max setup by flushing buffers and informing usbnet about the changes. This way, the settings can be modified while the netdev is up and running. Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/cdc_ncm.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 7a3de73c8ded..2ec3790a4db8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -89,11 +89,20 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
89 min, max, val); 89 min, max, val);
90 } 90 }
91 91
92 /* usbnet use these values for sizing rx queues */
93 dev->rx_urb_size = val;
94
92 /* inform device about NTB input size changes */ 95 /* inform device about NTB input size changes */
93 if (val != ctx->rx_max) { 96 if (val != ctx->rx_max) {
94 __le32 dwNtbInMaxSize = cpu_to_le32(val); 97 __le32 dwNtbInMaxSize = cpu_to_le32(val);
95 98
96 dev_info(&dev->intf->dev, "setting rx_max = %u\n", val); 99 dev_info(&dev->intf->dev, "setting rx_max = %u\n", val);
100
101 /* need to unlink rx urbs before increasing buffer size */
102 if (netif_running(dev->net) && dev->rx_urb_size > ctx->rx_max)
103 usbnet_unlink_rx_urbs(dev);
104
105 /* tell device to use new size */
97 if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE, 106 if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE,
98 USB_TYPE_CLASS | USB_DIR_OUT 107 USB_TYPE_CLASS | USB_DIR_OUT
99 | USB_RECIP_INTERFACE, 108 | USB_RECIP_INTERFACE,
@@ -117,7 +126,6 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
117 } 126 }
118 if (val != ctx->tx_max) 127 if (val != ctx->tx_max)
119 dev_info(&dev->intf->dev, "setting tx_max = %u\n", val); 128 dev_info(&dev->intf->dev, "setting tx_max = %u\n", val);
120 ctx->tx_max = val;
121 129
122 /* Adding a pad byte here if necessary simplifies the handling 130 /* Adding a pad byte here if necessary simplifies the handling
123 * in cdc_ncm_fill_tx_frame, making tx_max always represent 131 * in cdc_ncm_fill_tx_frame, making tx_max always represent
@@ -126,13 +134,24 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
126 * We cannot use dev->maxpacket here because this is called from 134 * We cannot use dev->maxpacket here because this is called from
127 * .bind which is called before usbnet sets up dev->maxpacket 135 * .bind which is called before usbnet sets up dev->maxpacket
128 */ 136 */
129 if (ctx->tx_max != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) && 137 if (val != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) &&
130 ctx->tx_max % usb_maxpacket(dev->udev, dev->out, 1) == 0) 138 val % usb_maxpacket(dev->udev, dev->out, 1) == 0)
131 ctx->tx_max++; 139 val++;
140
141 /* we might need to flush any pending tx buffers if running */
142 if (netif_running(dev->net) && val > ctx->tx_max) {
143 netif_tx_lock_bh(dev->net);
144 usbnet_start_xmit(NULL, dev->net);
145 ctx->tx_max = val;
146 netif_tx_unlock_bh(dev->net);
147 } else {
148 ctx->tx_max = val;
149 }
132 150
133 /* usbnet use these values for sizing tx/rx queues */
134 dev->hard_mtu = ctx->tx_max; 151 dev->hard_mtu = ctx->tx_max;
135 dev->rx_urb_size = ctx->rx_max; 152
153 /* max qlen depend on hard_mtu and rx_urb_size */
154 usbnet_update_max_qlen(dev);
136} 155}
137 156
138/* helpers for NCM and MBIM differences */ 157/* helpers for NCM and MBIM differences */