Subject: [PATCH 23/26] rt2x00: Fix USB packet length and block promisc mode

From: Ivo van Doorn <[email-masked]>
Date: Sun, 3 Dec 2006 19:18:56 +0100

The length of a packet that needs to be send over a USB device,
needs to have an even length. odd lengths will cause problems.
At the moment there is no solution for the enabling of promisc
mode on usb devices. The function is called from interrupt
context which means the driver cannot access a register.
Scheduling the request is required, but a clean solution
needs to be found.

Signed-off-by Ivo van Doorn <[email-masked]>

---

diff -rU3 wireless-dev-init/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-usb/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
--- wireless-dev-init/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-12-03 15:21:33.000000000 +0100
+++ wireless-dev-usb/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-12-03 15:28:17.000000000 +0100
@@ -1846,6 +1846,7 @@
 	struct sk_buff *skb_rts;
 	u16 frame_control;
 	int res;
+	int length;
 
 	/*
 	 * Determine which ring to put packet on.
@@ -1903,13 +1904,21 @@
 		SET_FLAG(entry, ENTRY_RTS_FRAME);
 	entry->skb = skb;
 
+	/*
+	 * Length passed to usb_fill_urb cannot be an odd number,
+	 * so add 1 byte to make it even.
+	 */
+	length = skb->len + ring->desc_size;
+	if (length % 2)
+		length++;
+
 	SET_FLAG(entry, ENTRY_OWNER_NIC);
 	usb_fill_bulk_urb(
 		rt2x00_urb(entry),
 		usb_dev,
 		usb_sndbulkpipe(usb_dev, 1),
 		entry->data_addr,
-		skb->len + ring->desc_size,
+		length,
 		rt2500usb_interrupt,
 		entry);
 	usb_submit_urb(rt2x00_urb(entry), GFP_ATOMIC);
@@ -2138,9 +2147,11 @@
 	 * Monitor mode works with PROMISC mode forced on,
 	 * so there is nothing to be done here.
 	 */
-	if (update && !GET_FLAG(rt2x00dev, INTERFACE_INITIALIZED_MONITOR))
-		queue_work(rt2x00dev->workqueue,
-			&rt2x00dev->interface.work);
+	if (update && !GET_FLAG(rt2x00dev, INTERFACE_INITIALIZED_MONITOR)) {
+		NOTICE("For the moment promisc mode is ignored");
+	/*	queue_work(rt2x00dev->workqueue,
+			&rt2x00dev->interface.work);*/
+	}
 }
 
 static void rt2500usb_scan(void *data)
diff -rU3 wireless-dev-init/drivers/net/wireless/d80211/rt2x00/rt73usb.c wireless-dev-usb/drivers/net/wireless/d80211/rt2x00/rt73usb.c
--- wireless-dev-init/drivers/net/wireless/d80211/rt2x00/rt73usb.c	2006-12-03 15:21:44.000000000 +0100
+++ wireless-dev-usb/drivers/net/wireless/d80211/rt2x00/rt73usb.c	2006-12-03 15:27:24.000000000 +0100
@@ -2118,6 +2118,7 @@
 	struct sk_buff *skb_rts;
 	u16 frame_control;
 	int res;
+	int length;
 
 	/*
 	 * Determine which ring to put packet on.
@@ -2175,13 +2176,21 @@
 		SET_FLAG(entry, ENTRY_RTS_FRAME);
 	entry->skb = skb;
 
+	/*
+	 * Length passed to usb_fill_urb cannot be an odd number,
+	 * so add 1 byte to make it even.
+	 */
+	length = skb->len + ring->desc_size;
+	if (length % 2)
+		length++;
+
 	SET_FLAG(entry, ENTRY_OWNER_NIC);
 	usb_fill_bulk_urb(
 		rt2x00_urb(entry),
 		usb_dev,
 		usb_sndbulkpipe(usb_dev, 1),
 		entry->data_addr,
-		skb->len + ring->desc_size,
+		length,
 		rt73usb_interrupt,
 		entry);
 	usb_submit_urb(rt2x00_urb(entry), GFP_ATOMIC);
@@ -2410,9 +2419,11 @@
 	 * Monitor mode works with PROMISC mode forced on,
 	 * so there is nothing to be done here.
 	 */
-	if (update && !GET_FLAG(rt2x00dev, INTERFACE_INITIALIZED_MONITOR))
-		queue_work(rt2x00dev->workqueue,
-			&rt2x00dev->interface.work);
+	if (update && !GET_FLAG(rt2x00dev, INTERFACE_INITIALIZED_MONITOR)) {
+		NOTICE("For the moment promisc mode is ignored");
+	/*	queue_work(rt2x00dev->workqueue,
+			&rt2x00dev->interface.work);*/
+	}
 }
 
 static void rt73usb_scan(void *data)