PERFORCE change 136319 for review
Sam Leffler
sam at FreeBSD.org
Wed Feb 27 03:40:04 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=136319
Change 136319 by sam at sam_ebb on 2008/02/27 03:39:17
Add wds support:
o indicate we're capable
o allow multiple vaps (1 ap+any number of wds)
o shuffle newstate so the bss node is setup prior to use
Affected files ...
.. //depot/projects/vap/sys/dev/ral/rt2661.c#15 edit
Differences ...
==== //depot/projects/vap/sys/dev/ral/rt2661.c#15 (text) ====
@@ -307,17 +307,20 @@
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS | /* IBSS mode supported */
- IEEE80211_C_MONITOR | /* monitor mode supported */
- IEEE80211_C_HOSTAP | /* HostAp mode supported */
- IEEE80211_C_TXPMGT | /* tx power management */
- IEEE80211_C_SHPREAMBLE | /* short preamble supported */
- IEEE80211_C_SHSLOT | /* short slot time supported */
+ IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
+ | IEEE80211_C_HOSTAP /* hostap mode */
+ | IEEE80211_C_MONITOR /* monitor mode */
+ | IEEE80211_C_AHDEMO /* adhoc demo mode */
+ | IEEE80211_C_WDS /* 4-address traffic works */
+ | IEEE80211_C_SHPREAMBLE /* short preamble supported */
+ | IEEE80211_C_SHSLOT /* short slot time supported */
+ | IEEE80211_C_WPA /* capable of WPA1+WPA2 */
+ | IEEE80211_C_BGSCAN /* capable of bg scanning */
#ifdef notyet
- IEEE80211_C_WME | /* 802.11e */
+ | IEEE80211_C_TXFRAG /* handle tx frags */
+ | IEEE80211_C_WME /* 802.11e */
#endif
- IEEE80211_C_BGSCAN | /* bg scanning support */
- IEEE80211_C_WPA; /* 802.11i */
+ ;
bands = 0;
setbit(&bands, IEEE80211_MODE_11B);
@@ -329,7 +332,9 @@
ieee80211_ifattach(ic);
ic->ic_newassoc = rt2661_newassoc;
ic->ic_node_alloc = rt2661_node_alloc;
-/* ic->ic_wme.wme_update = rt2661_wme_update;*/
+#if 0
+ ic->ic_wme.wme_update = rt2661_wme_update;
+#endif
ic->ic_scan_start = rt2661_scan_start;
ic->ic_scan_end = rt2661_scan_end;
ic->ic_set_channel = rt2661_set_channel;
@@ -402,19 +407,46 @@
const uint8_t bssid[IEEE80211_ADDR_LEN],
const uint8_t mac[IEEE80211_ADDR_LEN])
{
+ struct ifnet *ifp = ic->ic_ifp;
struct rt2661_vap *rvp;
struct ieee80211vap *vap;
- if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
+ switch (opmode) {
+ case IEEE80211_M_STA:
+ case IEEE80211_M_IBSS:
+ case IEEE80211_M_AHDEMO:
+ case IEEE80211_M_MONITOR:
+ case IEEE80211_M_HOSTAP:
+ if (!TAILQ_EMPTY(&ic->ic_vaps)) {
+ if_printf(ifp, "only 1 vap supported\n");
+ return NULL;
+ }
+ if (opmode == IEEE80211_M_STA)
+ flags |= IEEE80211_CLONE_NOBEACONS;
+ break;
+ case IEEE80211_M_WDS:
+ if (TAILQ_EMPTY(&ic->ic_vaps) ||
+ ic->ic_opmode != IEEE80211_M_HOSTAP) {
+ if_printf(ifp, "wds only supported in ap mode\n");
+ return NULL;
+ }
+ /*
+ * Silently remove any request for a unique
+ * bssid; WDS vap's always share the local
+ * mac address.
+ */
+ flags &= ~IEEE80211_CLONE_BSSID;
+ break;
+ default:
+ if_printf(ifp, "unknown opmode %d\n", opmode);
return NULL;
+ }
rvp = (struct rt2661_vap *) malloc(sizeof(struct rt2661_vap),
M_80211_VAP, M_NOWAIT | M_ZERO);
if (rvp == NULL)
return NULL;
vap = &rvp->ral_vap;
- /* enable s/w bmiss handling for sta mode */
- ieee80211_vap_setup(ic, vap, name, unit, opmode,
- flags | IEEE80211_CLONE_NOBEACONS, bssid, mac);
+ ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
/* override state transition machine */
rvp->ral_newstate = vap->iv_newstate;
@@ -428,7 +460,8 @@
/* complete setup */
ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status);
- ic->ic_opmode = opmode;
+ if (TAILQ_FIRST(&ic->ic_vaps) == vap)
+ ic->ic_opmode = opmode;
return vap;
}
@@ -823,26 +856,23 @@
struct rt2661_vap *rvp = RT2661_VAP(vap);
struct ieee80211com *ic = vap->iv_ic;
struct rt2661_softc *sc = ic->ic_ifp->if_softc;
- const struct ieee80211_txparam *tp;
- enum ieee80211_state ostate;
- struct ieee80211_node *ni;
- uint32_t tmp;
- int error = 0;
+ int error;
+
+ if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
+ uint32_t tmp;
+
+ callout_stop(&rvp->rssadapt_ch);
- ostate = vap->iv_state;
+ /* abort TSF synchronization */
+ tmp = RAL_READ(sc, RT2661_TXRX_CSR9);
+ RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp & ~0x00ffffff);
+ }
- switch (nstate) {
- case IEEE80211_S_INIT:
- if (ostate == IEEE80211_S_RUN) {
- callout_stop(&rvp->rssadapt_ch);
+ error = rvp->ral_newstate(vap, nstate, arg);
- /* abort TSF synchronization */
- tmp = RAL_READ(sc, RT2661_TXRX_CSR9);
- RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp & ~0x00ffffff);
- }
- break;
- case IEEE80211_S_RUN:
- ni = vap->iv_bss;
+ if (error == 0 && nstate == IEEE80211_S_RUN) {
+ struct ieee80211_node *ni = vap->iv_bss;
+ const struct ieee80211_txparam *tp;
if (vap->iv_opmode != IEEE80211_M_MONITOR) {
rt2661_enable_mrr(sc);
@@ -853,16 +883,15 @@
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
vap->iv_opmode == IEEE80211_M_IBSS) {
- if ((error = rt2661_prepare_beacon(sc, vap)) != 0)
- break;
+ error = rt2661_prepare_beacon(sc, vap);
+ if (error != 0)
+ return error;
}
-
if (vap->iv_opmode != IEEE80211_M_MONITOR) {
if (vap->iv_opmode == IEEE80211_M_STA) {
/* fake a join to init the tx rate */
rt2661_newassoc(ni, 1);
}
-
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
callout_reset(&rvp->rssadapt_ch, hz / 10,
@@ -870,12 +899,8 @@
rt2661_enable_tsf_sync(sc);
}
- break;
- default:
- break;
- }
-
- return (error != 0) ? error : rvp->ral_newstate(vap, nstate, arg);
+ }
+ return error;
}
/*
More information about the p4-projects
mailing list