Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Begin synchronization with FreeBSD:
details: https://anonhg.NetBSD.org/src/rev/73824c8e2e00
branches: trunk
changeset: 547106:73824c8e2e00
user: dyoung <dyoung%NetBSD.org@localhost>
date: Tue May 13 08:35:58 2003 +0000
description:
Begin synchronization with FreeBSD:
1 Add channel mask, transmit rate-mask arguments to wi_scan_ap.
2 Adopt the macros WI_LOCK/WI_UNLOCK for synchronization. FreeBSD
uses a different synchronization mechanism.
3 In wi_cmd, adopt constants WI_DELAY/WI_TIMEOUT for timing.
4 Pull debug messages from into wi_read_nicid from FreeBSD.
5 Bug fix: if IFF_ALLMULTI, don't filter any multicasts.
6 Count and report TX exceptions, but don't generate any additional
interrupts.
diffstat:
sys/dev/ic/wi.c | 132 ++++++++++++++++++++++++++++++----------------------
sys/dev/ic/wireg.h | 5 +-
sys/dev/ic/wivar.h | 5 +-
3 files changed, 83 insertions(+), 59 deletions(-)
diffs (truncated from 475 to 300 lines):
diff -r 8114961efd8c -r 73824c8e2e00 sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c Tue May 13 08:33:58 2003 +0000
+++ b/sys/dev/ic/wi.c Tue May 13 08:35:58 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wi.c,v 1.122 2003/05/13 07:17:46 dyoung Exp $ */
+/* $NetBSD: wi.c,v 1.123 2003/05/13 08:35:58 dyoung Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.122 2003/05/13 07:17:46 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.123 2003/05/13 08:35:58 dyoung Exp $");
#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
@@ -139,7 +139,7 @@
static int wi_newstate(void *, enum ieee80211_state);
static int wi_set_tim(struct ieee80211com *, int, int);
-static int wi_scan_ap(struct wi_softc *);
+static int wi_scan_ap(struct wi_softc *, u_int16_t, u_int16_t);
static void wi_scan_result(struct wi_softc *, int, int);
static void wi_dump_pkt(struct wi_frame *, struct ieee80211_node *, int rssi);
@@ -214,9 +214,9 @@
static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- int s;
+ WI_LOCK_DECL();
- s = splnet();
+ WI_LOCK(sc);
/* Make sure interrupts are disabled. */
CSR_WRITE_2(sc, WI_INT_EN, 0);
@@ -224,7 +224,7 @@
/* Reset the NIC. */
if (wi_reset(sc) != 0) {
- splx(s);
+ WI_UNLOCK(s);
return 1;
}
@@ -232,7 +232,7 @@
if (wi_read_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, &buflen) != 0 ||
IEEE80211_ADDR_EQ(ic->ic_myaddr, empty_macaddr)) {
printf(" could not get mac address, attach failed\n");
- splx(s);
+ WI_UNLOCK(sc);
return 1;
}
@@ -399,7 +399,7 @@
/* Attach is successful. */
sc->sc_attached = 1;
- splx(s);
+ WI_UNLOCK(sc);
return 0;
}
@@ -407,12 +407,12 @@
wi_detach(struct wi_softc *sc)
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- int s;
+ WI_LOCK_DECL();
if (!sc->sc_attached)
return 0;
- s = splnet();
+ WI_LOCK(sc);
/* Delete all remaining media. */
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
@@ -424,7 +424,7 @@
(*sc->sc_disable)(sc);
sc->sc_enabled = 0;
}
- splx(s);
+ WI_UNLOCK(sc);
return 0;
}
@@ -433,9 +433,10 @@
wi_activate(struct device *self, enum devact act)
{
struct wi_softc *sc = (struct wi_softc *)self;
- int rv = 0, s;
+ int rv = 0;
+ WI_LOCK_DECL();
- s = splnet();
+ WI_LOCK(sc);
switch (act) {
case DVACT_ACTIVATE:
rv = EOPNOTSUPP;
@@ -445,7 +446,7 @@
if_deactivate(&sc->sc_ic.ic_if);
break;
}
- splx(s);
+ WI_UNLOCK(sc);
return rv;
}
@@ -453,9 +454,9 @@
wi_power(struct wi_softc *sc, int why)
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- int s;
+ WI_LOCK_DECL();
- s = splnet();
+ WI_LOCK(sc);
switch (why) {
case PWR_SUSPEND:
case PWR_STANDBY:
@@ -472,7 +473,7 @@
case PWR_SOFTRESUME:
break;
}
- splx(s);
+ WI_UNLOCK(sc);
}
#endif /* __NetBSD__ */
@@ -549,6 +550,9 @@
struct wi_joinreq join;
int i;
int error = 0, wasenabled;
+ WI_LOCK_DECL();
+
+ WI_LOCK(sc);
DPRINTF(("wi_init: enabled %d\n", sc->sc_enabled));
wasenabled = sc->sc_enabled;
@@ -560,10 +564,9 @@
wi_stop(ifp, 0);
/* Symbol firmware cannot be initialized more than once */
- if (sc->sc_firmware_type != WI_SYMBOL || !wasenabled) {
+ if (sc->sc_firmware_type != WI_SYMBOL || !wasenabled)
if ((error = wi_reset(sc)) != 0)
goto out;
- }
/* common 802.11 configuration */
ic->ic_flags &= ~IEEE80211_F_IBSSON;
@@ -708,6 +711,7 @@
printf("%s: interface not running\n", sc->sc_dev.dv_xname);
wi_stop(ifp, 0);
}
+ WI_UNLOCK(sc);
DPRINTF(("wi_init: return %d\n", error));
return error;
}
@@ -716,9 +720,9 @@
wi_stop(struct ifnet *ifp, int disable)
{
struct wi_softc *sc = ifp->if_softc;
- int s;
+ WI_LOCK_DECL();
- s = splnet();
+ WI_LOCK(sc);
DPRINTF(("wi_stop: disable %d\n", disable));
/* Writing registers of a detached wi provokes an
@@ -747,7 +751,7 @@
ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
ifp->if_timer = 0;
- splx(s);
+ WI_UNLOCK(sc);
}
static void
@@ -755,16 +759,27 @@
{
struct wi_softc *sc = ifp->if_softc;
struct ieee80211com *ic = &sc->sc_ic;
- struct ieee80211_node *ni;
+ struct ieee80211_node *ni = NULL;
struct ieee80211_frame *wh;
struct mbuf *m0;
struct wi_frame frmhdr;
int cur, fid, off;
+ WI_LOCK_DECL();
- if (ifp->if_flags & IFF_OACTIVE)
+ WI_LOCK(sc);
+
+ if (!sc->sc_enabled) {
+ WI_UNLOCK(sc);
return;
- if (sc->sc_flags & WI_FLAGS_OUTRANGE)
+ }
+ if (ifp->if_flags & IFF_OACTIVE) {
+ WI_UNLOCK(sc);
return;
+ }
+ if (sc->sc_flags & WI_FLAGS_OUTRANGE) {
+ WI_UNLOCK(sc);
+ return;
+ }
memset(&frmhdr, 0, sizeof(frmhdr));
cur = sc->sc_txnext;
@@ -850,7 +865,7 @@
if (ic->ic_rawbpf)
bpf_mtap(ic->ic_rawbpf, m0);
#endif
- frmhdr.wi_tx_ctl = htole16(WI_ENC_TX_802_11);
+ frmhdr.wi_tx_ctl = htole16(WI_ENC_TX_802_11|WI_TXCNTL_TX_EX);
if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
(wh->i_fc[1] & IEEE80211_FC1_WEP)) {
if ((m0 = ieee80211_wep_crypt(ifp, m0, 1)) == NULL) {
@@ -899,6 +914,8 @@
}
sc->sc_txnext = cur = (cur + 1) % WI_NTXBUF;
}
+
+ WI_UNLOCK(sc);
}
@@ -980,22 +997,23 @@
struct wi_softc *sc = ifp->if_softc;
struct ieee80211com *ic = &sc->sc_ic;
struct ifreq *ifr = (struct ifreq *)data;
- int s, error = 0;
+ int error = 0;
+ WI_LOCK_DECL();
if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
return ENXIO;
- s = splnet();
+ WI_LOCK(sc);
switch (cmd) {
case SIOCSIFFLAGS:
+ /*
+ * Can't do promisc and hostap at the same time. If all that's
+ * changing is the promisc flag, try to short-circuit a call to
+ * wi_init() by just setting PROMISC in the hardware.
+ */
if (ifp->if_flags & IFF_UP) {
if (sc->sc_enabled) {
- /*
- * To avoid rescanning another access point,
- * do not call wi_init() here. Instead,
- * only reflect promisc mode settings.
- */
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
(ifp->if_flags & IFF_PROMISC) != 0)
wi_write_val(sc, WI_RID_PROMISC, 1);
@@ -1054,7 +1072,7 @@
}
break;
}
- splx(s);
+ WI_UNLOCK(sc);
return error;
}
@@ -1176,8 +1194,7 @@
if (IEEE80211_ADDR_EQ(new_bssid, ni->ni_bssid))
return;
- DPRINTF(("%s: bssid %s -> ", sc->sc_dev.dv_xname,
- ether_sprintf(ni->ni_bssid)));
+ DPRINTF(("wi_sync_bssid: bssid %s -> ", ether_sprintf(ni->ni_bssid)));
DPRINTF(("%s ?\n", ether_sprintf(new_bssid)));
/* In promiscuous mode, the BSSID field is not a reliable
@@ -1280,7 +1297,9 @@
M_COPY_PKTHDR(&mb, m);
mb.m_data = (caddr_t)&frmhdr;
- mb.m_len = sizeof(frmhdr);
+ frmhdr.wi_rx_signal -= sc->sc_dbm_adjust;
+ frmhdr.wi_rx_silence -= sc->sc_dbm_adjust;
+ mb.m_len = (char *)&frmhdr.wi_whdr - (char *)&frmhdr;
mb.m_next = m;
mb.m_pkthdr.len += mb.m_len;
bpf_mtap(sc->sc_drvbpf, &mb);
@@ -1463,20 +1482,16 @@
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
}
-/*
- * Allocate a region of memory inside the NIC and zero
Home |
Main Index |
Thread Index |
Old Index