PERFORCE change 34763 for review

Marcel Moolenaar marcel at FreeBSD.org
Sun Jul 20 21:24:37 PDT 2003


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

Change 34763 by marcel at marcel_nfs on 2003/07/20 21:24:03

	IFC @34761

Affected files ...

.. //depot/projects/uart/dev/acpica/acpi_ec.c#5 integrate
.. //depot/projects/uart/dev/ath/if_ath.c#4 integrate
.. //depot/projects/uart/dev/ath/if_athvar.h#3 integrate
.. //depot/projects/uart/dev/usb/usb_mem.c#2 integrate
.. //depot/projects/uart/dev/wi/if_wi.c#5 integrate
.. //depot/projects/uart/dev/wi/if_wivar.h#2 integrate
.. //depot/projects/uart/kern/kern_sig.c#5 integrate
.. //depot/projects/uart/net/if_media.h#2 integrate
.. //depot/projects/uart/net80211/ieee80211.c#3 integrate
.. //depot/projects/uart/net80211/ieee80211_input.c#2 integrate
.. //depot/projects/uart/net80211/ieee80211_ioctl.c#3 integrate
.. //depot/projects/uart/net80211/ieee80211_node.c#3 integrate
.. //depot/projects/uart/net80211/ieee80211_node.h#2 integrate
.. //depot/projects/uart/net80211/ieee80211_output.c#2 integrate
.. //depot/projects/uart/net80211/ieee80211_proto.c#2 integrate
.. //depot/projects/uart/net80211/ieee80211_proto.h#2 integrate
.. //depot/projects/uart/net80211/ieee80211_var.h#2 integrate

Differences ...

==== //depot/projects/uart/dev/acpica/acpi_ec.c#5 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.34 2003/07/20 00:48:38 njl Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.36 2003/07/20 21:12:21 njl Exp $
  */
 /******************************************************************************
  *
@@ -232,7 +232,7 @@
 } ACPI_TABLE_ECDT;
 
 /* Indicate that this device has already been probed via ECDT. */
-#define DEV_ECDT_FLAG		0x80000000
+#define DEV_ECDT(x)		(acpi_get_private(x) == &acpi_ec_devclass)
 
 /* Indicate that this device should use the global lock. */
 #define DEV_GLK_FLAG		0x40000000
@@ -247,7 +247,8 @@
 struct acpi_ec_softc {
     device_t		ec_dev;
     ACPI_HANDLE		ec_handle;
-    UINT32		ec_gpebit;
+    UINT8		ec_gpebit;
+    UINT8		ec_csrvalue;
     
     int			ec_data_rid;
     struct resource	*ec_data_res;
@@ -262,7 +263,7 @@
     int			ec_glk;
     int			ec_glkhandle;
     struct mtx		ec_mtx;
-    UINT32		ec_polldelay;
+    int			ec_polldelay;
 };
 
 /*
@@ -321,7 +322,6 @@
 				UINT32 width, ACPI_INTEGER *Value,
 				void *Context, void *RegionContext);
 static ACPI_STATUS	EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event);
-static ACPI_STATUS	EcQuery(struct acpi_ec_softc *sc, UINT8 *Data);
 static ACPI_STATUS	EcCommand(struct acpi_ec_softc *sc, EC_COMMAND cmd);
 static ACPI_STATUS	EcRead(struct acpi_ec_softc *sc, UINT8 Address,
 				UINT8 *Data);
@@ -401,7 +401,8 @@
      * We'll determine whether we really want to use the global lock
      * in a later call to attach.
      */
-    magic = DEV_ECDT_FLAG | DEV_GLK_FLAG;
+    acpi_set_private(child, &acpi_ec_devclass);
+    magic = DEV_GLK_FLAG;
     DEV_SET_GPEBIT(magic, ecdt->gpe_bit);
     acpi_set_magic(child, magic);
 
@@ -419,11 +420,9 @@
     char	desc[64];
     int		magic, uid, glk, gpebit, ret = ENXIO;
 
-    /* Check that this is an EC device and it's not disabled. */
-    if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("ec") ||
-	!acpi_MatchHid(dev, "PNP0C09")) {
+    /* Check that this is a device and that EC is not disabled. */
+    if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("ec"))
 	return (ENXIO);
-    }
 
     /*
      * If probed via ECDT, set description and continue.  Otherwise,
@@ -431,12 +430,12 @@
      * duplicate probe.
      */
     magic = acpi_get_magic(dev);
-    if ((magic & DEV_ECDT_FLAG) != 0) {
+    if (DEV_ECDT(dev)) {
 	snprintf(desc, sizeof(desc), "embedded controller: ECDT, GPE %#x, GLK",
 		 DEV_GET_GPEBIT(magic));
 	device_set_desc_copy(dev, desc);
 	ret = 0;
-    } else {
+    } else if (acpi_MatchHid(dev, "PNP0C09")) {
 	h = acpi_get_handle(dev);
 
 	/*
@@ -590,29 +589,6 @@
     return (errval);
 }
 
-static ACPI_STATUS
-EcQuery(struct acpi_ec_softc *sc, UINT8 *Data)
-{
-    ACPI_STATUS	Status;
-
-    Status = EcLock(sc);
-    if (ACPI_FAILURE(Status))
-	return (Status);
-
-    /*
-     * Send a query command to the EC to find out which _Qxx call it
-     * wants to make.  This command clears the SCI bit and also the
-     * interrupt source since we are edge-triggered.
-     */
-    Status = EcCommand(sc, EC_COMMAND_QUERY);
-    if (ACPI_SUCCESS(Status))
-	*Data = EC_GET_DATA(sc);
-
-    EcUnlock(sc);
-
-    return (Status);
-}    
-
 static void
 EcGpeQueryHandler(void *Context)
 {
@@ -625,32 +601,39 @@
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
     KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
 
+    Status = EcLock(sc);
+    if (ACPI_FAILURE(Status)) {
+	ACPI_VPRINT(sc->ec_dev, acpi_device_get_parent_softc(sc->ec_dev),
+		    "GpeQuery lock error: %s\n", AcpiFormatException(Status));
+	return;
+    }
+
     /*
-     * Check status for EC_SCI.
-     * 
-     * Bail out if the EC_SCI bit of the status register is not set.
-     * Note that this function should only be called when
-     * this bit is set (polling is used to detect IBE/OBF events).
-     *
-     * We don't acquire the global lock here but do protect against other
-     * running commands (read/write/query) by grabbing ec_mtx.
+     * If the EC_SCI bit of the status register is not set, then pass
+     * it along to any potential waiters as it may be an IBE/OBF event.
      */
-    mtx_lock(&sc->ec_mtx);
     EcStatus = EC_GET_CSR(sc);
-    mtx_unlock(&sc->ec_mtx);
     if ((EcStatus & EC_EVENT_SCI) == 0) {
-	/* If it's not an SCI, wakeup the EcWaitEvent sleep. */
-	wakeup(&sc->ec_polldelay);
+	sc->ec_csrvalue = EcStatus;
+	wakeup(&sc->ec_csrvalue);
+	EcUnlock(sc);
 	goto re_enable;
     }
 
-    /* Find out why the EC is signaling us. */
-    Status = EcQuery(sc, &Data);
+    /*
+     * Send a query command to the EC to find out which _Qxx call it
+     * wants to make.  This command clears the SCI bit and also the
+     * interrupt source since we are edge-triggered.
+     */
+    Status = EcCommand(sc, EC_COMMAND_QUERY);
     if (ACPI_FAILURE(Status)) {
+	EcUnlock(sc);
 	ACPI_VPRINT(sc->ec_dev, acpi_device_get_parent_softc(sc->ec_dev),
 		    "GPE query failed - %s\n", AcpiFormatException(Status));
 	goto re_enable;
     }
+    Data = EC_GET_DATA(sc);
+    EcUnlock(sc);
 
     /* Ignore the value for "no outstanding event". (13.3.5) */
     if (Data == 0)
@@ -770,7 +753,7 @@
 {
     EC_STATUS	EcStatus;
     ACPI_STATUS	Status;
-    UINT32	i, period;
+    int		i, period, retval;
 
     mtx_assert(&sc->ec_mtx, MA_OWNED);
     Status = AE_NO_HARDWARE_RESPONSE;
@@ -812,13 +795,18 @@
      * for completion, sleeping for chunks of 10 ms.
      */
     if (Status != AE_OK) {
+	retval = -1;
 	for (i = 0; i < EC_POLL_TIMEOUT / 10; i++) {
-	    EcStatus = EC_GET_CSR(sc);
+	    if (retval != 0)
+		EcStatus = EC_GET_CSR(sc);
+	    else
+		EcStatus = sc->ec_csrvalue;
 	    if (EVENT_READY(Event, EcStatus)) {
 		Status = AE_OK;
 		break;
 	    }
-	    msleep(&sc->ec_polldelay, &sc->ec_mtx, PZERO, "ecpoll", 10/*ms*/);
+	    retval = msleep(&sc->ec_csrvalue, &sc->ec_mtx, PZERO, "ecpoll",
+			    10/*ms*/);
 	}
     }
 

==== //depot/projects/uart/dev/ath/if_ath.c#4 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.3 2003/07/13 17:07:25 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.4 2003/07/20 21:38:20 sam Exp $");
 
 /*
  * Driver for the Atheros Wireless LAN controller.
@@ -129,7 +129,7 @@
 static int	ath_startrecv(struct ath_softc *);
 static void	ath_next_scan(void *);
 static void	ath_calibrate(void *);
-static int	ath_newstate(void *, enum ieee80211_state);
+static int	ath_newstate(struct ieee80211com *, enum ieee80211_state, int);
 static void	ath_newassoc(struct ieee80211com *,
 			struct ieee80211_node *, int);
 static int	ath_getchannels(struct ath_softc *, u_int cc, HAL_BOOL outdoor);
@@ -281,7 +281,6 @@
 	ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
 
 	ic->ic_softc = sc;
-	ic->ic_newstate = ath_newstate;
 	ic->ic_newassoc = ath_newassoc;
 	/* XXX not right but it's not used anywhere important */
 	ic->ic_phytype = IEEE80211_T_OFDM;
@@ -300,7 +299,9 @@
 	ic->ic_node_alloc = ath_node_alloc;
 	ic->ic_node_free = ath_node_free;
 	ic->ic_node_copy = ath_node_copy;
-
+	sc->sc_newstate = ic->ic_newstate;
+	ic->ic_newstate = ath_newstate;
+	/* complete initialization */
 	ieee80211_media_init(ifp, ath_media_change, ieee80211_media_status);
 
 	if_printf(ifp, "802.11 address: %s\n", ether_sprintf(ic->ic_myaddr));
@@ -453,13 +454,12 @@
 {
 	struct ath_softc *sc = arg;
 	struct ieee80211com *ic = &sc->sc_ic;
-	struct ifnet *ifp = &ic->ic_if;
 
 	DPRINTF(("ath_bmiss_proc: pending %u\n", pending));
 	KASSERT(ic->ic_opmode == IEEE80211_M_STA,
 		("unexpect operating mode %u", ic->ic_opmode));
 	if (ic->ic_state == IEEE80211_S_RUN)
-		ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+		ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 }
 
 static u_int
@@ -546,7 +546,7 @@
 	mode = ieee80211_chan2mode(ic, ni->ni_chan);
 	if (mode != sc->sc_curmode)
 		ath_setcurmode(sc, mode);
-	ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+	ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 done:
 	mtx_unlock(&sc->sc_mtx);
 }
@@ -554,6 +554,7 @@
 static void
 ath_stop(struct ifnet *ifp)
 {
+	struct ieee80211com *ic = (struct ieee80211com *) ifp;
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 
@@ -587,7 +588,7 @@
 			sc->sc_rxlink = NULL;
 		IF_DRAIN(&ifp->if_snd);
 		ath_beacon_free(sc);
-		ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+		ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 		if (!sc->sc_invalid)
 			ath_hal_setpower(ah, HAL_PM_FULL_SLEEP, 0);
 	}
@@ -2156,21 +2157,15 @@
 }
 
 static int
-ath_newstate(void *arg, enum ieee80211_state nstate)
+ath_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
 {
-	struct ath_softc *sc = arg;
+	struct ifnet *ifp = &ic->ic_if;
+	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
-	struct ieee80211com *ic = &sc->sc_ic;
-	struct ifnet *ifp = &ic->ic_if;
 	struct ieee80211_node *ni;
 	int i, error;
 	u_int8_t *bssid;
 	u_int32_t rfilt;
-	enum ieee80211_state ostate;
-#ifdef AR_DEBUG
-	static const char *stname[] =
-	    { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
-#endif /* AR_DEBUG */
 	static const HAL_LED_STATE leds[] = {
 	    HAL_LED_INIT,	/* IEEE80211_S_INIT */
 	    HAL_LED_SCAN,	/* IEEE80211_S_SCAN */
@@ -2179,17 +2174,18 @@
 	    HAL_LED_RUN, 	/* IEEE80211_S_RUN */
 	};
 
-	ostate = ic->ic_state;
-
-	DPRINTF(("%s: %s -> %s\n", __func__, stname[ostate], stname[nstate]));
+	DPRINTF(("%s: %s -> %s\n", __func__,
+		ieee80211_state_name[ic->ic_state],
+		ieee80211_state_name[nstate]));
 
 	ath_hal_setledstate(ah, leds[nstate]);	/* set LED */
 
 	if (nstate == IEEE80211_S_INIT) {
 		sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
 		ath_hal_intrset(ah, sc->sc_imask);
-		error = 0;			/* cheat + use error return */
-		goto bad;
+		callout_stop(&sc->sc_scan_ch);
+		callout_stop(&sc->sc_cal_ch);
+		return (*sc->sc_newstate)(ic, nstate, arg);
 	}
 	ni = ic->ic_bss;
 	error = ath_chan_set(sc, ni->ni_chan);
@@ -2259,10 +2255,14 @@
 	 * Reset the rate control state.
 	 */
 	ath_rate_ctl_reset(sc, nstate);
-	return 0;
+	/*
+	 * Invoke the parent method to complete the work.
+	 */
+	return (*sc->sc_newstate)(ic, nstate, arg);
 bad:
 	callout_stop(&sc->sc_scan_ch);
 	callout_stop(&sc->sc_cal_ch);
+	/* NB: do not invoke the parent */
 	return error;
 }
 

==== //depot/projects/uart/dev/ath/if_athvar.h#3 (text+ko) ====

@@ -33,7 +33,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.2 2003/07/13 17:07:25 sam Exp $
+ * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.3 2003/07/20 21:38:20 sam Exp $
  */
 
 /*
@@ -78,6 +78,8 @@
 
 struct ath_softc {
 	struct ieee80211com	sc_ic;		/* IEEE 802.11 common */
+	int			(*sc_newstate)(struct ieee80211com *,
+					enum ieee80211_state, int);
 	device_t		sc_dev;
 	bus_space_tag_t		sc_st;		/* bus space tag */
 	bus_space_handle_t	sc_sh;		/* bus space handle */

==== //depot/projects/uart/dev/usb/usb_mem.c#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*	$NetBSD: usb_mem.c,v 1.26 2003/02/01 06:23:40 thorpej Exp $	*/
-/*	$FreeBSD: src/sys/dev/usb/usb_mem.c,v 1.1 2003/07/15 22:42:37 jmg Exp $	*/
+/*	$FreeBSD: src/sys/dev/usb/usb_mem.c,v 1.2 2003/07/21 02:41:01 jmg Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/usb_mem.c,v 1.1 2003/07/15 22:42:37 jmg Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/usb_mem.c,v 1.2 2003/07/21 02:41:01 jmg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,7 +84,7 @@
 #endif
 
 #define USB_MEM_SMALL 64
-#define USB_MEM_CHUNKS (PAGE_SIZE / 64)
+#define USB_MEM_CHUNKS (PAGE_SIZE / USB_MEM_SMALL)
 #define USB_MEM_BLOCK (USB_MEM_SMALL * USB_MEM_CHUNKS)
 
 /* This struct is overlayed on free fragments. */
@@ -256,6 +256,10 @@
 			return (err);
 		}
 		b->fullblock = 0;
+		/* XXX - override the tag, ok since we never free it */
+		b->tag = tag;
+		KASSERT(sizeof *f <= USB_MEM_SMALL, ("USB_MEM_SMALL(%d) is too small for struct usb_frag_dma(%d)\n",
+		    USB_MEM_SMALL, sizeof *f));
 		for (i = 0; i < USB_MEM_BLOCK; i += USB_MEM_SMALL) {
 			f = (struct usb_frag_dma *)((char *)b->kaddr + i);
 			f->block = b;

==== //depot/projects/uart/dev/wi/if_wi.c#5 (text+ko) ====

@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.147 2003/07/03 10:16:40 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.148 2003/07/20 21:37:32 sam Exp $");
 
 #define WI_HERMES_AUTOINC_WAR	/* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR	/* Work around stats counter bug. */
@@ -146,7 +146,7 @@
 static int  wi_read_rid(struct wi_softc *, int, void *, int *);
 static int  wi_write_rid(struct wi_softc *, int, void *, int);
 
-static int  wi_newstate(void *, enum ieee80211_state);
+static int  wi_newstate(struct ieee80211com *, enum ieee80211_state, int);
 
 static int  wi_scan_ap(struct wi_softc *, u_int16_t, u_int16_t);
 static void wi_scan_result(struct wi_softc *, int, int);
@@ -312,7 +312,6 @@
 	ic->ic_opmode = IEEE80211_M_STA;
 	ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_AHDEMO;
 	ic->ic_state = IEEE80211_S_INIT;
-	ic->ic_newstate = wi_newstate;
 
 	/*
 	 * Query the card for available channels and setup the
@@ -452,6 +451,9 @@
 	 * Call MI attach routine.
 	 */
 	ieee80211_ifattach(ifp);
+	/* override state transition method */
+	sc->sc_newstate = ic->ic_newstate;
+	ic->ic_newstate = wi_newstate;
 	ieee80211_media_init(ifp, wi_media_change, wi_media_status);
 
 	return (0);
@@ -716,7 +718,7 @@
 	ifp->if_flags &= ~IFF_OACTIVE;
 	if (ic->ic_opmode == IEEE80211_M_AHDEMO ||
 	    ic->ic_opmode == IEEE80211_M_HOSTAP)
-		wi_newstate(sc, IEEE80211_S_RUN);
+		ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 
 	/* Enable interrupts */
 	CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
@@ -758,12 +760,13 @@
 void
 wi_stop(struct ifnet *ifp, int disable)
 {
+	struct ieee80211com *ic = (struct ieee80211com *) ifp;
 	struct wi_softc *sc = ifp->if_softc;
 	WI_LOCK_DECL();
 
 	WI_LOCK(sc);
 
-	ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+	ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 	if (sc->sc_enabled && !sc->wi_gone) {
 		CSR_WRITE_2(sc, WI_INT_EN, 0);
 		wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
@@ -996,10 +999,11 @@
 
 	if (sc->sc_syn_timer) {
 		if (--sc->sc_syn_timer == 0) {
+			struct ieee80211com *ic = (struct ieee80211com *) ifp;
 			DPRINTF2(("wi_watchdog: %d false syns\n",
 			    sc->sc_false_syns));
 			sc->sc_false_syns = 0;
-			ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+			ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 			sc->sc_syn_timer = 5;
 		}
 		ifp->if_timer = 1;
@@ -1244,7 +1248,7 @@
 	    sc->sc_false_syns >= WI_MAX_FALSE_SYNS)
 		return;
 
-	ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+	ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 }
 
 static void
@@ -1547,7 +1551,7 @@
 				break;
 			/* FALLTHROUGH */
 		case WI_INFO_LINK_STAT_AP_CHG:
-			ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+			ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 			break;
 		case WI_INFO_LINK_STAT_AP_INR:
 			sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
@@ -1566,7 +1570,7 @@
 		case WI_INFO_LINK_STAT_DISCONNECTED:
 		case WI_INFO_LINK_STAT_ASSOC_FAILED:
 			if (ic->ic_opmode == IEEE80211_M_STA)
-				ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+				ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 			break;
 		}
 		break;
@@ -2519,30 +2523,25 @@
 }
 
 static int
-wi_newstate(void *arg, enum ieee80211_state nstate)
+wi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
 {
-	struct wi_softc *sc = arg;
-	struct ieee80211com *ic = &sc->sc_ic;
+	struct ifnet *ifp = &ic->ic_if;
+	struct wi_softc *sc = ifp->if_softc;
 	struct ieee80211_node *ni = ic->ic_bss;
 	int buflen;
 	u_int16_t val;
 	struct wi_ssid ssid;
 	u_int8_t old_bssid[IEEE80211_ADDR_LEN];
-	enum ieee80211_state ostate;
-#ifdef WI_DEBUG
-	static const char *stname[] =
-	    { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
-#endif /* WI_DEBUG */
 
-	ostate = ic->ic_state;
-	DPRINTF(("wi_newstate: %s -> %s\n", stname[ostate], stname[nstate]));
+	DPRINTF(("%s: %s -> %s\n", __func__,
+		ieee80211_state_name[ic->ic_state],
+		ieee80211_state_name[nstate]));
 
-	ic->ic_state = nstate;
 	switch (nstate) {
 	case IEEE80211_S_INIT:
 		ic->ic_flags &= ~IEEE80211_F_SIBSS;
 		sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
-		return 0;
+		return (*sc->sc_newstate)(ic, nstate, arg);
 
 	case IEEE80211_S_RUN:
 		sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
@@ -2584,8 +2583,8 @@
 		break;
 	}
 
-	/* skip standard ieee80211 handling */
-	return EINPROGRESS;
+	ic->ic_state = nstate;		/* NB: skip normal ieee80211 handling */
+	return 0;
 }
 
 static int

==== //depot/projects/uart/dev/wi/if_wivar.h#2 (text+ko) ====

@@ -31,7 +31,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/wi/if_wivar.h,v 1.18 2003/06/28 06:17:26 sam Exp $
+ * $FreeBSD: src/sys/dev/wi/if_wivar.h,v 1.19 2003/07/20 21:37:32 sam Exp $
  */
 
 #if 0
@@ -61,6 +61,8 @@
 
 struct wi_softc	{
 	struct ieee80211com	sc_ic;
+	int			(*sc_newstate)(struct ieee80211com *,
+					enum ieee80211_state, int);
 	device_t		sc_dev;
 #if __FreeBSD_version >= 500000
 	struct mtx		sc_mtx;

==== //depot/projects/uart/kern/kern_sig.c#5 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.252 2003/07/17 22:52:55 davidxu Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.253 2003/07/21 00:26:52 davidxu Exp $");
 
 #include "opt_compat.h"
 #include "opt_ktrace.h"
@@ -1515,6 +1515,9 @@
 			if (td->td_upcall)
 				td->td_upcall->ku_flags |= KUF_DOUPCALL;
 			mtx_unlock_spin(&sched_lock);
+		} else {
+			/* UTS caused a sync signal */
+			sigexit(td, SIGILL);
 		}
 	} else {
 		PROC_LOCK(p);
@@ -1540,6 +1543,7 @@
 			error = copyout(&siginfo, &td->td_mailbox->tm_syncsig,
 			    sizeof(siginfo));
 			PROC_LOCK(p);
+			/* UTS memory corrupted */
 			if (error)
 				sigexit(td, SIGILL);
 			SIGADDSET(td->td_sigmask, sig);
@@ -2282,7 +2286,8 @@
 #endif
 	_STOPEVENT(p, S_SIG, sig);
 
-	if (action == SIG_DFL) {
+	if (!(td->td_flags & TDF_SA && td->td_mailbox) &&
+	    action == SIG_DFL) {
 		/*
 		 * Default action, where the default is to kill
 		 * the process.  (Other cases were ignored above.)
@@ -2291,6 +2296,13 @@
 		sigexit(td, sig);
 		/* NOTREACHED */
 	} else {
+		if (td->td_flags & TDF_SA && td->td_mailbox) {
+			if (sig == SIGKILL) {
+				mtx_unlock(&ps->ps_mtx);
+				sigexit(td, sig);
+			}
+		}
+
 		/*
 		 * If we get here, the signal must be caught.
 		 */
@@ -2333,7 +2345,7 @@
 			p->p_code = 0;
 			p->p_sig = 0;
 		}
-		if (td->td_flags & TDF_SA)
+		if (td->td_flags & TDF_SA && td->td_mailbox)
 			thread_signal_add(curthread, sig);
 		else
 			(*p->p_sysent->sv_sendsig)(action, sig,

==== //depot/projects/uart/net/if_media.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*	$NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $	*/
-/* $FreeBSD: src/sys/net/if_media.h,v 1.22 2003/06/25 15:03:05 sam Exp $ */
+/* $FreeBSD: src/sys/net/if_media.h,v 1.23 2003/07/21 02:48:35 sam Exp $ */
 
 /*
  * Copyright (c) 1997
@@ -194,6 +194,7 @@
 #define	IFM_IEEE80211_IBSS	0x00000400	/* Operate in IBSS mode */
 #define	IFM_IEEE80211_IBSSMASTER 0x00000800	/* Operate as an IBSS master */
 #define	IFM_IEEE80211_TURBO	0x00001000	/* Operate in turbo mode */
+#define	IFM_IEEE80211_MONITOR	0x00002000	/* Operate in monitor mode */
 /* operating mode for multi-mode devices */
 #define	IFM_IEEE80211_11A	1	/* 5Ghz, OFDM mode */
 #define	IFM_IEEE80211_11B	2	/* Direct Sequence mode */
@@ -443,6 +444,7 @@
 	{ IFM_IEEE80211_IBSS, "ibss" },					\
 	{ IFM_IEEE80211_IBSSMASTER, "ibss-master" },			\
 	{ IFM_IEEE80211_TURBO, "turbo" },				\
+	{ IFM_IEEE80211_MONITOR, "monitor" },				\
 	{ 0, NULL },							\
 }
 

==== //depot/projects/uart/net80211/ieee80211.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.4 2003/06/29 20:10:54 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.6 2003/07/21 02:49:42 sam Exp $");
 
 /*
  * IEEE 802.11 generic handler
@@ -275,6 +275,8 @@
 			ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_HOSTAP);
 		if (ic->ic_caps & IEEE80211_C_AHDEMO)
 			ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_ADHOC | IFM_FLAG0);
+		if (ic->ic_caps & IEEE80211_C_MONITOR)
+			ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_MONITOR);
 		if (mode == IEEE80211_MODE_AUTO)
 			continue;
 		if_printf(ifp, "%s rates: ", ieee80211_phymode_name[mode]);
@@ -294,6 +296,8 @@
 				ADD(ic, mword, mopt | IFM_IEEE80211_HOSTAP);
 			if (ic->ic_caps & IEEE80211_C_AHDEMO)
 				ADD(ic, mword, mopt | IFM_IEEE80211_ADHOC | IFM_FLAG0);
+			if (ic->ic_caps & IEEE80211_C_MONITOR)
+				ADD(ic, mword, mopt | IFM_IEEE80211_MONITOR);
 			/*
 			 * Add rate to the collection of all rates.
 			 */
@@ -325,6 +329,8 @@
 			ADD(ic, mword, IFM_IEEE80211_HOSTAP);
 		if (ic->ic_caps & IEEE80211_C_AHDEMO)
 			ADD(ic, mword, IFM_IEEE80211_ADHOC | IFM_FLAG0);
+		if (ic->ic_caps & IEEE80211_C_MONITOR)
+			ADD(ic, mword, IFM_IEEE80211_MONITOR);
 	}
 	ieee80211_media_status(ifp, &imr);
 	ifmedia_set(&ic->ic_media, imr.ifm_active);
@@ -441,6 +447,8 @@
 		newopmode = IEEE80211_M_HOSTAP;
 	else if (ime->ifm_media & IFM_IEEE80211_ADHOC)
 		newopmode = IEEE80211_M_IBSS;
+	else if (ime->ifm_media & IFM_IEEE80211_MONITOR)
+		newopmode = IEEE80211_M_MONITOR;
 	else
 		newopmode = IEEE80211_M_STA;
 
@@ -486,6 +494,7 @@
 		case IEEE80211_M_AHDEMO:
 		case IEEE80211_M_HOSTAP:
 		case IEEE80211_M_STA:
+		case IEEE80211_M_MONITOR:
 			ic->ic_flags &= ~IEEE80211_F_IBSSON;
 			break;
 		case IEEE80211_M_IBSS:
@@ -534,6 +543,9 @@
 	case IEEE80211_M_HOSTAP:
 		imr->ifm_active |= IFM_IEEE80211_HOSTAP;
 		break;
+	case IEEE80211_M_MONITOR:
+		imr->ifm_active |= IFM_IEEE80211_MONITOR;
+		break;
 	}
 	switch (ic->ic_curmode) {
 	case IEEE80211_MODE_11A:
@@ -558,7 +570,7 @@
 	struct ieee80211com *ic = (void *)ifp;
 
 	if (ic->ic_mgt_timer && --ic->ic_mgt_timer == 0)
-		ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+		ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 	if (ic->ic_inact_timer && --ic->ic_inact_timer == 0)
 		ieee80211_timeout_nodes(ic);
 

==== //depot/projects/uart/net80211/ieee80211_input.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.4 2003/06/27 05:13:52 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.6 2003/07/21 02:49:42 sam Exp $");
 
 #include "opt_inet.h"
 
@@ -138,6 +138,9 @@
 				ni = ieee80211_ref_node(ic->ic_bss);
 			}
 			break;
+		case IEEE80211_M_MONITOR:
+			/* NB: this should collect everything */
+			goto out;
 		default:
 			/* XXX catch bad values */
 			break;
@@ -212,6 +215,8 @@
 			}
 			ieee80211_unref_node(&ni);
 			break;
+		case IEEE80211_M_MONITOR:
+			break;
 		}
 		if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
 			if (ic->ic_flags & IEEE80211_F_WEPON) {
@@ -592,7 +597,11 @@
 		}
 		IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_SIZE);
 		IEEE80211_VERIFY_ELEMENT(ssid, IEEE80211_NWID_LEN);
-		if (chan > IEEE80211_CHAN_MAX || isclr(ic->ic_chan_active, chan)) {
+		if (
+#if IEEE80211_CHAN_MAX < 255
+		    chan > IEEE80211_CHAN_MAX ||
+#endif
+		    isclr(ic->ic_chan_active, chan)) {
 			IEEE80211_DPRINTF(("%s: ignore %s with invalid channel "
 				"%u\n", __func__,
 				ISPROBE(subtype) ? "probe response" : "beacon",
@@ -775,7 +784,7 @@
 		case IEEE80211_M_IBSS:
 			if (ic->ic_state != IEEE80211_S_RUN || seq != 1)
 				return;
-			ieee80211_new_state(&ic->ic_if, IEEE80211_S_AUTH,
+			ieee80211_new_state(ic, IEEE80211_S_AUTH,
 			    wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
 			break;
 
@@ -822,9 +831,11 @@
 				}
 				return;
 			}
-			ieee80211_new_state(&ic->ic_if, IEEE80211_S_ASSOC,
+			ieee80211_new_state(ic, IEEE80211_S_ASSOC,
 			    wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
 			break;
+		case IEEE80211_M_MONITOR:
+			break;
 		}
 		break;
 	}
@@ -1011,7 +1022,7 @@
 				IEEE80211_F_DOSORT | IEEE80211_F_DOFRATE |
 				IEEE80211_F_DONEGO | IEEE80211_F_DODEL);
 		if (ni->ni_rates.rs_nrates != 0)
-			ieee80211_new_state(ifp, IEEE80211_S_RUN,
+			ieee80211_new_state(ic, IEEE80211_S_RUN,
 				wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
 		break;
 	}
@@ -1026,7 +1037,7 @@
 		reason = le16toh(*(u_int16_t *)frm);
 		switch (ic->ic_opmode) {
 		case IEEE80211_M_STA:
-			ieee80211_new_state(&ic->ic_if, IEEE80211_S_AUTH,
+			ieee80211_new_state(ic, IEEE80211_S_AUTH,
 			    wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
 			break;
 		case IEEE80211_M_HOSTAP:
@@ -1055,7 +1066,7 @@
 		reason = le16toh(*(u_int16_t *)frm);
 		switch (ic->ic_opmode) {
 		case IEEE80211_M_STA:
-			ieee80211_new_state(&ic->ic_if, IEEE80211_S_ASSOC,
+			ieee80211_new_state(ic, IEEE80211_S_ASSOC,
 			    wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
 			break;
 		case IEEE80211_M_HOSTAP:

==== //depot/projects/uart/net80211/ieee80211_ioctl.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.3 2003/06/29 20:12:17 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.4 2003/07/20 21:36:08 sam Exp $");
 
 /*
  * IEEE 802.11 ioctl support (FreeBSD-specific)
@@ -659,7 +659,7 @@
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP)
 			break;
 		/* NB: ignore channel list and tx rate parameters */
-		error = ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+		error = ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 		break;
 	case WI_RID_SCAN_APS:
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP)
@@ -703,7 +703,7 @@
 		if (wreq.wi_type == WI_RID_CHANNEL_LIST)
 			error = ENETRESET;
 		else
-			error = ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+			error = ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 		break;
 	default:
 		error = EINVAL;

==== //depot/projects/uart/net80211/ieee80211_node.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.3 2003/06/29 20:13:38 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.4 2003/07/20 21:36:08 sam Exp $");
 
 #include "opt_inet.h"
 
@@ -110,42 +110,48 @@
  * Initialize the active channel set based on the set
  * of available channels and the current PHY mode.
  */
-void
+static void
 ieee80211_reset_scan(struct ifnet *ifp)
 {
 	struct ieee80211com *ic = (void *)ifp;
 
 	memcpy(ic->ic_chan_scan, ic->ic_chan_active,
 		sizeof(ic->ic_chan_active));
+	/* NB: hack, setup so next_scan starts with the first channel */
+	if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC)
+		ic->ic_bss->ni_chan = &ic->ic_channels[IEEE80211_CHAN_MAX];
 }
 
 /*
  * Begin an active scan.
  */
 void
-ieee80211_begin_scan(struct ifnet *ifp, struct ieee80211_node *ni)
+ieee80211_begin_scan(struct ifnet *ifp)
 {
 	struct ieee80211com *ic = (void *)ifp;
 
+	/*
+	 * In all but hostap mode scanning starts off in
+	 * an active mode before switching to passive.
+	 */
+	if (ic->ic_opmode != IEEE80211_M_HOSTAP)
+		ic->ic_flags |= IEEE80211_F_ASCAN;
 	if (ifp->if_flags & IFF_DEBUG)
 		if_printf(ifp, "begin %s scan\n",
-			ic->ic_opmode != IEEE80211_M_HOSTAP ?
+			(ic->ic_flags & IEEE80211_F_ASCAN) ?
 				"active" : "passive");
-
-	ieee80211_reset_scan(ifp);
 	/*
-	 * Flush any previously seen AP's.  Note that this
-	 * assumes we don't act as both an AP and a station,
-	 * otherwise we'll potentially flush state of stations
-	 * associated with us.
+	 * Clear scan state and flush any previously seen
+	 * AP's.  Note that the latter assumes we don't act
+	 * as both an AP and a station, otherwise we'll
+	 * potentially flush state of stations associated
+	 * with us.
 	 */
+	ieee80211_reset_scan(ifp);
 	ieee80211_free_allnodes(ic);
 
-	clrbit(ic->ic_chan_scan, ieee80211_chan2ieee(ic, ni->ni_chan));
-	if (ic->ic_opmode != IEEE80211_M_HOSTAP) {
-		ic->ic_flags |= IEEE80211_F_ASCAN;
-		IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_PROBE_REQ, 0);
-	}
+	/* Scan the next channel. */
+	ieee80211_next_scan(ifp);
 }
 
 /*
@@ -180,7 +186,7 @@
 	    ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan),
 	    ieee80211_chan2ieee(ic, chan)));
 	ic->ic_bss->ni_chan = chan;
-	ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+	ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 }
 
 void
@@ -213,7 +219,7 @@
 		ni->ni_fhdwell = 200;	/* XXX */
 		ni->ni_fhindex = 1;
 	}
-	ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+	ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 }
 
 /*
@@ -368,10 +374,10 @@
 			goto notfound;
 		}
 		ieee80211_unref_node(&selbs);
-		ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+		ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 	} else {
 		ieee80211_unref_node(&selbs);
-		ieee80211_new_state(ifp, IEEE80211_S_AUTH, -1);
+		ieee80211_new_state(ic, IEEE80211_S_AUTH, -1);
 	}
 }
 

==== //depot/projects/uart/net80211/ieee80211_node.h#2 (text+ko) ====

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list