Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c60408e authored by Alexey Orishko's avatar Alexey Orishko Committed by David S. Miller
Browse files

CDC NCM: Add mising short packet in cdc_ncm driver



Changes:
- while making NTB, driver shall check if device dwNtbOutMaxSize is higher than
 host value and shall add a short packet if this is the case
- previous temporary patch for this issue is replaced by this one

Signed-off-by: default avatarAlexey Orishko <alexey.orishko@stericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c92f5ca2
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -54,13 +54,13 @@
#include <linux/usb/usbnet.h>
#include <linux/usb/usbnet.h>
#include <linux/usb/cdc.h>
#include <linux/usb/cdc.h>


#define	DRIVER_VERSION				"23-Apr-2011"
#define	DRIVER_VERSION				"06-May-2011"


/* CDC NCM subclass 3.2.1 */
/* CDC NCM subclass 3.2.1 */
#define USB_CDC_NCM_NDP16_LENGTH_MIN		0x10
#define USB_CDC_NCM_NDP16_LENGTH_MIN		0x10


/* Maximum NTB length */
/* Maximum NTB length */
#define	CDC_NCM_NTB_MAX_SIZE_TX			(16384 + 4) /* bytes, must be short terminated */
#define	CDC_NCM_NTB_MAX_SIZE_TX			16384	/* bytes */
#define	CDC_NCM_NTB_MAX_SIZE_RX			16384	/* bytes */
#define	CDC_NCM_NTB_MAX_SIZE_RX			16384	/* bytes */


/* Minimum value for MaxDatagramSize, ch. 6.2.9 */
/* Minimum value for MaxDatagramSize, ch. 6.2.9 */
@@ -722,7 +722,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)


	} else {
	} else {
		/* reset variables */
		/* reset variables */
		skb_out = alloc_skb(ctx->tx_max, GFP_ATOMIC);
		skb_out = alloc_skb((ctx->tx_max + 1), GFP_ATOMIC);
		if (skb_out == NULL) {
		if (skb_out == NULL) {
			if (skb != NULL) {
			if (skb != NULL) {
				dev_kfree_skb_any(skb);
				dev_kfree_skb_any(skb);
@@ -861,8 +861,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
	/* store last offset */
	/* store last offset */
	last_offset = offset;
	last_offset = offset;


	if ((last_offset < ctx->tx_max) && ((last_offset %
	if (((last_offset < ctx->tx_max) && ((last_offset %
			le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) {
			le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) ||
	    (((last_offset == ctx->tx_max) && ((ctx->tx_max %
		le16_to_cpu(ctx->out_ep->desc.wMaxPacketSize)) == 0)) &&
		(ctx->tx_max < le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize)))) {
		/* force short packet */
		/* force short packet */
		*(((u8 *)skb_out->data) + last_offset) = 0;
		*(((u8 *)skb_out->data) + last_offset) = 0;
		last_offset++;
		last_offset++;