aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-16 15:48:23 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 22:39:01 -0400
commit70559b8970e52aa9962dc823fd4498af06809544 (patch)
tree830aa1d9187223a54eb91bbe0f904c7cd72c98bd /drivers/net/usb
parent6c4e548ff36672eeb78f8288a2920d66fa4a6a66 (diff)
net: cdc_ncm: use true max dgram count for header estimates
Many newer NCM and MBIM devices will request a maximum tx datagram count which is much smaller than our hard-coded absolute max. We can reduce the overhead without sacrificing any of the simplicity for these devices, by simply using the true negotiated count in when calculated the maximum NTH and NDP header sizes. 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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 141dbec912be..b9b562b9128a 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -174,7 +174,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
174 } 174 }
175 175
176 /* clamp new_tx to sane values */ 176 /* clamp new_tx to sane values */
177 min = CDC_NCM_MIN_HDR_SIZE + ctx->max_datagram_size; 177 min = ctx->max_datagram_size + ctx->max_ndp_size + sizeof(struct usb_cdc_ncm_nth16);
178 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize)); 178 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
179 179
180 /* some devices set dwNtbOutMaxSize too low for the above default */ 180 /* some devices set dwNtbOutMaxSize too low for the above default */
@@ -318,6 +318,9 @@ static int cdc_ncm_init(struct usbnet *dev)
318 (ctx->tx_max_datagrams > CDC_NCM_DPT_DATAGRAMS_MAX)) 318 (ctx->tx_max_datagrams > CDC_NCM_DPT_DATAGRAMS_MAX))
319 ctx->tx_max_datagrams = CDC_NCM_DPT_DATAGRAMS_MAX; 319 ctx->tx_max_datagrams = CDC_NCM_DPT_DATAGRAMS_MAX;
320 320
321 /* set up maximum NDP size */
322 ctx->max_ndp_size = sizeof(struct usb_cdc_ncm_ndp16) + (ctx->tx_max_datagrams + 1) * sizeof(struct usb_cdc_ncm_dpe16);
323
321 /* initial coalescing timer interval */ 324 /* initial coalescing timer interval */
322 ctx->timer_interval = CDC_NCM_TIMER_INTERVAL_USEC * NSEC_PER_USEC; 325 ctx->timer_interval = CDC_NCM_TIMER_INTERVAL_USEC * NSEC_PER_USEC;
323 326
@@ -800,7 +803,7 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
800 cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max); 803 cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
801 804
802 /* verify that there is room for the NDP and the datagram (reserve) */ 805 /* verify that there is room for the NDP and the datagram (reserve) */
803 if ((ctx->tx_max - skb->len - reserve) < CDC_NCM_NDP_SIZE) 806 if ((ctx->tx_max - skb->len - reserve) < ctx->max_ndp_size)
804 return NULL; 807 return NULL;
805 808
806 /* link to it */ 809 /* link to it */
@@ -810,7 +813,7 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
810 nth16->wNdpIndex = cpu_to_le16(skb->len); 813 nth16->wNdpIndex = cpu_to_le16(skb->len);
811 814
812 /* push a new empty NDP */ 815 /* push a new empty NDP */
813 ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, CDC_NCM_NDP_SIZE), 0, CDC_NCM_NDP_SIZE); 816 ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size);
814 ndp16->dwSignature = sign; 817 ndp16->dwSignature = sign;
815 ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16)); 818 ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16));
816 return ndp16; 819 return ndp16;