|
|
@@ -174,7 +174,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
|
|
|
}
|
|
|
|
|
|
/* clamp new_tx to sane values */
|
|
|
- min = CDC_NCM_MIN_HDR_SIZE + ctx->max_datagram_size;
|
|
|
+ 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));
|
|
|
|
|
|
/* some devices set dwNtbOutMaxSize too low for the above default */
|
|
|
@@ -318,6 +318,9 @@ static int cdc_ncm_init(struct usbnet *dev)
|
|
|
(ctx->tx_max_datagrams > CDC_NCM_DPT_DATAGRAMS_MAX))
|
|
|
ctx->tx_max_datagrams = CDC_NCM_DPT_DATAGRAMS_MAX;
|
|
|
|
|
|
+ /* set up maximum NDP size */
|
|
|
+ ctx->max_ndp_size = sizeof(struct usb_cdc_ncm_ndp16) + (ctx->tx_max_datagrams + 1) * sizeof(struct usb_cdc_ncm_dpe16);
|
|
|
+
|
|
|
/* initial coalescing timer interval */
|
|
|
ctx->timer_interval = CDC_NCM_TIMER_INTERVAL_USEC * NSEC_PER_USEC;
|
|
|
|
|
|
@@ -800,7 +803,7 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
|
|
|
cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
|
|
|
|
|
|
/* verify that there is room for the NDP and the datagram (reserve) */
|
|
|
- if ((ctx->tx_max - skb->len - reserve) < CDC_NCM_NDP_SIZE)
|
|
|
+ if ((ctx->tx_max - skb->len - reserve) < ctx->max_ndp_size)
|
|
|
return NULL;
|
|
|
|
|
|
/* link to it */
|
|
|
@@ -810,7 +813,7 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
|
|
|
nth16->wNdpIndex = cpu_to_le16(skb->len);
|
|
|
|
|
|
/* push a new empty NDP */
|
|
|
- ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, CDC_NCM_NDP_SIZE), 0, CDC_NCM_NDP_SIZE);
|
|
|
+ ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size);
|
|
|
ndp16->dwSignature = sign;
|
|
|
ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16));
|
|
|
return ndp16;
|