PERFORCE change 157536 for review

Hans Petter Selasky hselasky at FreeBSD.org
Wed Feb 11 04:33:08 PST 2009


http://perforce.freebsd.org/chv.cgi?CH=157536

Change 157536 by hselasky at hselasky_laptop001 on 2009/02/11 12:33:01

	
	USB WLAN patches - more patches taken from the "HPS" version
	of the USB WLAN drivers.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/wlan/if_rum2.c#35 edit
.. //depot/projects/usb/src/sys/dev/usb2/wlan/if_ural2.c#34 edit
.. //depot/projects/usb/src/sys/dev/usb2/wlan/if_zyd2.c#36 edit
.. //depot/projects/usb/src/sys/dev/usb2/wlan/if_zydreg.h#8 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/wlan/if_rum2.c#35 (text+ko) ====

@@ -54,9 +54,6 @@
     "Debug level");
 #endif
 
-#define	rum_do_request(sc,req,data) \
-  usb2_do_request_proc((sc)->sc_udev, &(sc)->sc_tq, req, data, 0, NULL, 5000)
-
 static const struct usb2_device_id rum_devs[] = {
     { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_HWU54DM) },
     { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_RT2573_2) },
@@ -128,6 +125,8 @@
 static usb2_proc_callback_t rum_stop_task;
 static usb2_proc_callback_t rum_flush_task;
 
+static void		rum_do_request(struct rum_softc *sc,
+			    struct usb2_device_request *req, void *data);
 static struct ieee80211vap *rum_vap_create(struct ieee80211com *,
 			    const char name[IFNAMSIZ], int unit, int opmode,
 			    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
@@ -173,6 +172,8 @@
 static void		rum_update_slot(struct ifnet *);
 static void		rum_set_bssid(struct rum_softc *, const uint8_t *);
 static void		rum_set_macaddr(struct rum_softc *, const uint8_t *);
+static void		rum_update_mcast(struct ifnet *);
+static void		rum_update_promisc(struct ifnet *);
 static const char	*rum_get_rf(int);
 static void		rum_read_eeprom(struct rum_softc *);
 static int		rum_bbp_init(struct rum_softc *);
@@ -515,6 +516,8 @@
 	ieee80211_init_channels(ic, NULL, &bands);
 
 	ieee80211_ifattach(ic);
+	ic->ic_update_mcast = rum_update_mcast;
+	ic->ic_update_promisc = rum_update_promisc;
 	ic->ic_newassoc = rum_newassoc;
 	ic->ic_raw_xmit = rum_raw_xmit;
 	ic->ic_node_alloc = rum_node_alloc;
@@ -575,6 +578,31 @@
 	return (0);
 }
 
+static void
+rum_do_request(struct rum_softc *sc,
+    struct usb2_device_request *req, void *data)
+{
+	usb2_error_t err;
+
+	/*
+	 * Occasionally the RUM chip will just generate control
+	 * request timeouts. Probably a USB driver bug in the
+	 * firmware! Try to workaround the problem.
+	 */
+ retry:
+	err = usb2_do_request_proc(sc->sc_udev, &sc->sc_tq, 
+	   req, data, 0, NULL, 250 /* ms */);
+
+	if (err) {
+		if (!usb2_proc_is_gone(&sc->sc_tq)) {
+			DPRINTFN(1, "Control request failed! (ignored)\n");
+			rum_pause(sc, hz / 100);
+			goto retry;
+		}
+	}
+	return;
+}
+
 static struct ieee80211vap *
 rum_vap_create(struct ieee80211com *ic,
 	const char name[IFNAMSIZ], int unit, int opmode, int flags,
@@ -1403,7 +1431,6 @@
 rum_eeprom_read(struct rum_softc *sc, uint16_t addr, void *buf, int len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = RT2573_READ_EEPROM;
@@ -1411,11 +1438,7 @@
 	USETW(req.wIndex, addr);
 	USETW(req.wLength, len);
 
-	error = rum_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not read EEPROM: %s\n",
-		    usb2_errstr(error));
-	}
+	rum_do_request(sc, &req, buf);
 }
 
 static uint32_t
@@ -1432,7 +1455,6 @@
 rum_read_multi(struct rum_softc *sc, uint16_t reg, void *buf, int len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = RT2573_READ_MULTI_MAC;
@@ -1440,12 +1462,7 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, len);
 
-	error = rum_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "could not multi read MAC register(0x%04x): %s\n",
-		    reg, usb2_errstr(error));
-	}
+	rum_do_request(sc, &req, buf);
 }
 
 static void
@@ -1460,7 +1477,6 @@
 rum_write_multi(struct rum_softc *sc, uint16_t reg, void *buf, size_t len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = RT2573_WRITE_MULTI_MAC;
@@ -1468,12 +1484,7 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, len);
 
-	error = rum_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "could not multi write MAC register(0x%04x): %s\n",
-		    reg, usb2_errstr(error));
-	}
+	rum_do_request(sc, &req, buf);
 }
 
 static void
@@ -1849,6 +1860,27 @@
 	    "entering" : "leaving");
 }
 
+static void
+rum_update_mcast(struct ifnet *ifp)
+{
+	/* not supported */
+}
+
+static void
+rum_update_promisc(struct ifnet *ifp)
+{
+	struct rum_softc *sc = ifp->if_softc;
+
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+		return;
+
+	RUM_LOCK(sc);
+	rum_queue_command(sc, rum_promisctask,
+	    &sc->sc_promisctask[0].hdr,
+	    &sc->sc_promisctask[1].hdr);
+	RUM_UNLOCK(sc);
+}
+
 static const char *
 rum_get_rf(int rev)
 {
@@ -2116,7 +2148,6 @@
 {
 	struct usb2_device_request req;
 	uint16_t reg = RT2573_MCU_CODE_BASE;
-	usb2_error_t error;
 
 	/*
 	 * TODO: If the firmware is already loaded,
@@ -2133,12 +2164,8 @@
 	USETW(req.wIndex, 0);
 	USETW(req.wLength, 0);
 
-	error = rum_do_request(sc, &req, NULL);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not run firmware: %s\n",
-		    usb2_errstr(error));
-	}
-	return error;
+	rum_do_request(sc, &req, NULL);
+	return (0);
 }
 
 static int

==== //depot/projects/usb/src/sys/dev/usb2/wlan/if_ural2.c#34 (text+ko) ====

@@ -55,9 +55,6 @@
     "Debug level");
 #endif
 
-#define	ural_do_request(sc,req,data) \
-    usb2_do_request_proc((sc)->sc_udev, &(sc)->sc_tq, req, data, 0, NULL, 5000)
-
 #define URAL_RSSI(rssi)					\
 	((rssi) > (RAL_NOISE_FLOOR + RAL_RSSI_CORR) ?	\
 	 ((rssi) - (RAL_NOISE_FLOOR + RAL_RSSI_CORR)) : 0)
@@ -107,6 +104,8 @@
 static usb2_proc_callback_t ural_stop_task;
 static usb2_proc_callback_t ural_flush_task;
 
+static void		ural_do_request(struct ural_softc *sc,
+			    struct usb2_device_request *req, void *data);
 static struct ieee80211vap *ural_vap_create(struct ieee80211com *,
 			    const char name[IFNAMSIZ], int unit, int opmode,
 			    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
@@ -155,6 +154,8 @@
 			    const struct ieee80211_channel *);
 static void		ural_set_bssid(struct ural_softc *, const uint8_t *);
 static void		ural_set_macaddr(struct ural_softc *, uint8_t *);
+static void		ural_update_mcast(struct ifnet *);
+static void		ural_update_promisc(struct ifnet *);
 static const char	*ural_get_rf(int);
 static void		ural_read_eeprom(struct ural_softc *);
 static int		ural_bbp_init(struct ural_softc *);
@@ -501,6 +502,8 @@
 	ieee80211_init_channels(ic, NULL, &bands);
 
 	ieee80211_ifattach(ic);
+	ic->ic_update_mcast = ural_update_mcast;
+	ic->ic_update_promisc = ural_update_promisc;
 	ic->ic_newassoc = ural_newassoc;
 	ic->ic_raw_xmit = ural_raw_xmit;
 	ic->ic_node_alloc = ural_node_alloc;
@@ -561,6 +564,25 @@
 	return (0);
 }
 
+static void
+ural_do_request(struct ural_softc *sc,
+    struct usb2_device_request *req, void *data)
+{
+	usb2_error_t err;
+
+ retry:
+	err = usb2_do_request_proc(sc->sc_udev, &sc->sc_tq, 
+	   req, data, 0, NULL, 250 /* ms */);
+
+	if (err) {
+		if (!usb2_proc_is_gone(&sc->sc_tq)) {
+			DPRINTFN(1, "Control request failed! (ignored)\n");
+			ural_pause(sc, hz / 100);
+			goto retry;
+		}
+	}
+}
+
 static struct ieee80211vap *
 ural_vap_create(struct ieee80211com *ic,
 	const char name[IFNAMSIZ], int unit, int opmode, int flags,
@@ -1476,7 +1498,6 @@
 ural_set_testmode(struct ural_softc *sc)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = RAL_VENDOR_REQUEST;
@@ -1484,18 +1505,13 @@
 	USETW(req.wIndex, 1);
 	USETW(req.wLength, 0);
 
-	error = ural_do_request(sc, &req, NULL);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not set test mode: %s\n",
-		    usb2_errstr(error));
-	}
+	ural_do_request(sc, &req, NULL);
 }
 
 static void
 ural_eeprom_read(struct ural_softc *sc, uint16_t addr, void *buf, int len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = RAL_READ_EEPROM;
@@ -1503,18 +1519,13 @@
 	USETW(req.wIndex, addr);
 	USETW(req.wLength, len);
 
-	error = ural_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not read EEPROM: %s\n",
-		    usb2_errstr(error));
-	}
+	ural_do_request(sc, &req, buf);
 }
 
 static uint16_t
 ural_read(struct ural_softc *sc, uint16_t reg)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 	uint16_t val;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
@@ -1523,12 +1534,7 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, sizeof (uint16_t));
 
-	error = ural_do_request(sc, &req, &val);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not read MAC register: %s\n",
-		    usb2_errstr(error));
-		return 0;
-	}
+	ural_do_request(sc, &req, &val);
 
 	return le16toh(val);
 }
@@ -1537,7 +1543,6 @@
 ural_read_multi(struct ural_softc *sc, uint16_t reg, void *buf, int len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = RAL_READ_MULTI_MAC;
@@ -1545,18 +1550,13 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, len);
 
-	error = ural_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not read MAC register: %s\n",
-		    usb2_errstr(error));
-	}
+	ural_do_request(sc, &req, buf);
 }
 
 static void
 ural_write(struct ural_softc *sc, uint16_t reg, uint16_t val)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = RAL_WRITE_MAC;
@@ -1564,18 +1564,13 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, 0);
 
-	error = ural_do_request(sc, &req, NULL);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not write MAC register: %s\n",
-		    usb2_errstr(error));
-	}
+	ural_do_request(sc, &req, NULL);
 }
 
 static void
 ural_write_multi(struct ural_softc *sc, uint16_t reg, void *buf, int len)
 {
 	struct usb2_device_request req;
-	usb2_error_t error;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = RAL_WRITE_MULTI_MAC;
@@ -1583,11 +1578,7 @@
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, len);
 
-	error = ural_do_request(sc, &req, buf);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not write MAC register: %s\n",
-		    usb2_errstr(error));
-	}
+	ural_do_request(sc, &req, buf);
 }
 
 static void
@@ -2000,6 +1991,27 @@
 	    "entering" : "leaving");
 }
 
+static void
+ural_update_mcast(struct ifnet *ifp)
+{
+	/* not supported */
+}
+
+static void
+ural_update_promisc(struct ifnet *ifp)
+{
+	struct ural_softc *sc = ifp->if_softc;
+
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+		return;
+
+	RAL_LOCK(sc);
+	ural_queue_command(sc, ural_promisctask,
+	    &sc->sc_promisctask[0].hdr,
+	    &sc->sc_promisctask[1].hdr);
+	RAL_UNLOCK(sc);
+}
+
 static const char *
 ural_get_rf(int rev)
 {

==== //depot/projects/usb/src/sys/dev/usb2/wlan/if_zyd2.c#36 (text+ko) ====

@@ -419,7 +419,12 @@
 
 	ic->ic_vap_create = zyd_vap_create;
 	ic->ic_vap_delete = zyd_vap_delete;
+	/*
+	 * The same callback function is used for multicast a
+	 * promiscious mode:
+	 */
 	ic->ic_update_mcast = zyd_update_mcast;
+	ic->ic_update_promisc = zyd_update_mcast;
 
 	bpfattach(ifp, DLT_IEEE802_11_RADIO,
 	    sizeof(struct ieee80211_frame) + sizeof(sc->sc_txtap));
@@ -2748,9 +2753,9 @@
 		ZYD_LOCK(sc);
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-				if ((ifp->if_flags ^ sc->sc_if_flags) &
-				    (IFF_ALLMULTI | IFF_PROMISC))
-					zyd_set_multi(sc);
+				zyd_queue_command(sc, zyd_multitask,
+				    &sc->sc_mcasttask[0].hdr,
+				    &sc->sc_mcasttask[1].hdr);
 			} else {
 				zyd_queue_command(sc, zyd_init_task,
 				    &sc->sc_synctask[0].hdr,
@@ -2764,7 +2769,6 @@
 				    &sc->sc_synctask[1].hdr);
 			}
 		}
-		sc->sc_if_flags = ifp->if_flags;
 		ZYD_UNLOCK(sc);
 		if (startall)
 			ieee80211_start_all(ic);

==== //depot/projects/usb/src/sys/dev/usb2/wlan/if_zydreg.h#8 (text+ko) ====

@@ -1274,7 +1274,6 @@
 #define	ZYD_FLAG_FWLOADED		(1 << 0)
 #define	ZYD_FLAG_INITONCE		(1 << 1)
 #define	ZYD_FLAG_INITDONE		(1 << 2)
-	int			sc_if_flags;
 
 	struct zyd_task		sc_synctask[2];
 	struct zyd_task		sc_mcasttask[2];


More information about the p4-projects mailing list