Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Mar 2008 02:40:42 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 138957 for review
Message-ID:  <200803300240.m2U2egoV016952@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=138957

Change 138957 by sam@sam_ebb on 2008/03/30 02:39:42

	o the WPA ie rid requires a 16-bit length at the front; add
	  a routine to do this (could optimize out copy probably but
	  it's hardly worth it)
	o we're doing all crypto on the host, so fixup the rx path
	  to match (makes dhclient get a lease over wpa)
	o add some noinline to routines to simplify debugging
	o nuke packet dumping stuff; use tcpdump to get the same info

Affected files ...

.. //depot/projects/vap/sys/dev/wi/if_wi.c#19 edit

Differences ...

==== //depot/projects/vap/sys/dev/wi/if_wi.c#19 (text+ko) ====

@@ -153,8 +153,7 @@
 static int  wi_mwrite_bap(struct wi_softc *, int, int, struct mbuf *, int);
 static int  wi_read_rid(struct wi_softc *, int, void *, int *);
 static int  wi_write_rid(struct wi_softc *, int, void *, int);
-
-static void wi_dump_pkt(struct wi_frame *, struct ieee80211_node *, int rssi);
+static int  wi_write_appie(struct wi_softc *, int, const struct ieee80211_appie *);
 
 static void wi_scan_start(struct ieee80211com *);
 static void wi_scan_end(struct ieee80211com *);
@@ -183,11 +182,8 @@
 	    0, "control debugging printfs");
 
 #define	DPRINTF(X)	if (wi_debug) printf X
-#define	IFF_DUMPPKTS(_ifp) \
-	(((_ifp)->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
 #else
 #define	DPRINTF(X)
-#define	IFF_DUMPPKTS(_ifp)	0
 #endif
 
 #define WI_INTRS	(WI_EV_RX | WI_EV_ALLOC | WI_EV_INFO)
@@ -852,12 +848,9 @@
 		if ((sc->sc_flags & WI_FLAGS_HAS_WPASUPPORT) &&
 		    (vap->iv_flags & IEEE80211_F_WPA)) {
 			wi_write_val(sc, WI_RID_WPA_HANDLING, 1);
-			if (vap->iv_appie_wpa != NULL) {
-printf("%s: wpa ie %p %d\n", __func__, vap->iv_appie_wpa->ie_data, vap->iv_appie_wpa->ie_len); 
-				wi_write_rid(sc, WI_RID_WPA_DATA,
-				    vap->iv_appie_wpa->ie_data, 
-				    vap->iv_appie_wpa->ie_len); 
-			}
+			if (vap->iv_appie_wpa != NULL)
+				wi_write_appie(sc, WI_RID_WPA_DATA,
+				    vap->iv_appie_wpa);
 		}
 
 		wi_enable(sc);		/* enable port */
@@ -929,6 +922,11 @@
 			wi_write_val(sc, WI_RID_ENH_SECURITY, 0x3);
 		}
 
+		if ((sc->sc_flags & WI_FLAGS_HAS_WPASUPPORT) &&
+		    (vap->iv_flags & IEEE80211_F_WPA) && 
+		    vap->iv_appie_wpa != NULL)
+			wi_write_appie(sc, WI_RID_WPA_DATA, vap->iv_appie_wpa);
+
 		wi_write_val(sc, WI_RID_PROMISC, 0);
 
 		/* Configure WEP. */
@@ -1006,8 +1004,6 @@
 		    (caddr_t)&frmhdr.wi_whdr);
 		m_adj(m0, sizeof(struct ieee80211_frame));
 		frmhdr.wi_dat_len = htole16(m0->m_pkthdr.len);
-		if (IFF_DUMPPKTS(ifp))
-			wi_dump_pkt(&frmhdr, NULL, -1);
 		ieee80211_free_node(ni);
 		if (wi_start_tx(ifp, &frmhdr, m0))
 			continue;
@@ -1115,8 +1111,6 @@
 	    (caddr_t)&frmhdr.wi_whdr);
 	m_adj(m0, sizeof(struct ieee80211_frame));
 	frmhdr.wi_dat_len = htole16(m0->m_pkthdr.len);
-	if (IFF_DUMPPKTS(ifp))
-		wi_dump_pkt(&frmhdr, NULL, -1);
 	if (wi_start_tx(ifp, &frmhdr, m0) < 0) {
 		m0 = NULL;
 		rc = EIO;
@@ -1294,7 +1288,7 @@
 #endif
 }
 
-static void
+static __noinline void
 wi_rx_intr(struct wi_softc *sc)
 {
 	struct ieee80211com *ic = &sc->sc_ic;
@@ -1318,9 +1312,6 @@
 		return;
 	}
 
-	if (IFF_DUMPPKTS(ifp))
-		wi_dump_pkt(&frmhdr, NULL, frmhdr.wi_rx_signal);
-
 	/*
 	 * Drop undecryptable or packets with receive errors here
 	 */
@@ -1379,16 +1370,6 @@
 
 	CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX);
 
-	wh = mtod(m, struct ieee80211_frame *);
-	if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
-		/*
-		 * WEP is decrypted by hardware and the IV
-		 * is stripped.  Clear WEP bit but mark mbuf.
-		 */
-		wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
-		m->m_flags |= M_WEP;
-	}
-
 #if NBPFILTER > 0
 	if (bpf_peers_present(ifp->if_bpf)) {
 		/* XXX replace divide by table */
@@ -1404,6 +1385,7 @@
 	}
 #endif
 	/* synchronize driver's BSSID with firmware's BSSID */
+	wh = mtod(m, struct ieee80211_frame *);
 	dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
 	if (ic->ic_opmode == IEEE80211_M_IBSS && dir == IEEE80211_FC1_DIR_NODS)
 		wi_sync_bssid(sc, wh->i_addr3);
@@ -1420,7 +1402,7 @@
 	WI_LOCK(sc);
 }
 
-static void
+static __noinline void
 wi_tx_ex_intr(struct wi_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
@@ -1464,7 +1446,7 @@
 	CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX_EXC);
 }
 
-static void
+static __noinline void
 wi_tx_intr(struct wi_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
@@ -1498,7 +1480,7 @@
 	}
 }
 
-static void
+static __noinline void
 wi_info_intr(struct wi_softc *sc)
 {
 	struct ieee80211com *ic = &sc->sc_ic;
@@ -2119,24 +2101,18 @@
 	return wi_cmd(sc, WI_CMD_ACCESS | WI_ACCESS_WRITE, rid, 0, 0);
 }
 
-static void
-wi_dump_pkt(struct wi_frame *wh, struct ieee80211_node *ni, int rssi)
+static int
+wi_write_appie(struct wi_softc *sc, int rid, const struct ieee80211_appie *ie)
 {
-	if (ni != NULL)
-		ieee80211_dump_pkt(ni->ni_ic,
-		    (u_int8_t *) &wh->wi_whdr, sizeof(wh->wi_whdr),
-		    ni->ni_txrate, rssi);
-	printf(" status 0x%x rx_tstamp1 %u rx_tstamp0 0x%u rx_silence %u\n",
-		le16toh(wh->wi_status), le16toh(wh->wi_rx_tstamp1),
-		le16toh(wh->wi_rx_tstamp0), wh->wi_rx_silence);
-	printf(" rx_signal %u rx_rate %u rx_flow %u\n",
-		wh->wi_rx_signal, wh->wi_rx_rate, wh->wi_rx_flow);
-	printf(" tx_rtry %u tx_rate %u tx_ctl 0x%x dat_len %u\n",
-		wh->wi_tx_rtry, wh->wi_tx_rate,
-		le16toh(wh->wi_tx_ctl), le16toh(wh->wi_dat_len));
-	printf(" ehdr dst %6D src %6D type 0x%x\n",
-		wh->wi_ehdr.ether_dhost, ":", wh->wi_ehdr.ether_shost, ":",
-		wh->wi_ehdr.ether_type);
+	/* NB: 42 bytes is probably ok to have on the stack */
+	char buf[sizeof(uint16_t) + 40];
+
+	if (ie->ie_len > 40)
+		return EINVAL;
+	/* NB: firmware requires 16-bit ie length before ie data */
+	*(uint16_t *) buf = htole16(ie->ie_len);
+	memcpy(buf + sizeof(uint16_t), ie->ie_data, ie->ie_len);
+	return wi_write_rid(sc, rid, buf, ie->ie_len + sizeof(uint16_t));
 }
 
 int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803300240.m2U2egoV016952>