summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/net80211/ieee80211_tdma.c
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2016-11-14 13:46:13 +0100
committerChristian Mauderer <Christian.Mauderer@embedded-brains.de>2017-01-17 12:50:57 +0100
commita241ea8e924154a217768b6e4910a62e0d25cfe2 (patch)
tree404fef7dab5f6dd06c0c3889dbc96214a5e226d4 /freebsd/sys/net80211/ieee80211_tdma.c
parentUse thread name support (diff)
downloadrtems-libbsd-a241ea8e924154a217768b6e4910a62e0d25cfe2.tar.bz2
Import IEEE 802.11 from FreeBSD.
Diffstat (limited to 'freebsd/sys/net80211/ieee80211_tdma.c')
-rw-r--r--freebsd/sys/net80211/ieee80211_tdma.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/freebsd/sys/net80211/ieee80211_tdma.c b/freebsd/sys/net80211/ieee80211_tdma.c
index 98fdd5e4..c14ccab5 100644
--- a/freebsd/sys/net80211/ieee80211_tdma.c
+++ b/freebsd/sys/net80211/ieee80211_tdma.c
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
#include <rtems/bsd/local/opt_tdma.h>
#include <rtems/bsd/local/opt_wlan.h>
+#ifdef IEEE80211_SUPPORT_TDMA
+
#include <rtems/bsd/sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -115,7 +117,7 @@ static void tdma_vdetach(struct ieee80211vap *vap);
static int tdma_newstate(struct ieee80211vap *, enum ieee80211_state, int);
static void tdma_beacon_miss(struct ieee80211vap *vap);
static void tdma_recv_mgmt(struct ieee80211_node *, struct mbuf *,
- int subtype, int rssi, int nf);
+ int subtype, const struct ieee80211_rx_stats *rxs, int rssi, int nf);
static int tdma_update(struct ieee80211vap *vap,
const struct ieee80211_tdma_param *tdma, struct ieee80211_node *ni,
int pickslot);
@@ -149,8 +151,9 @@ ieee80211_tdma_vattach(struct ieee80211vap *vap)
KASSERT(vap->iv_caps & IEEE80211_C_TDMA,
("not a tdma vap, caps 0x%x", vap->iv_caps));
- ts = (struct ieee80211_tdma_state *) malloc(
- sizeof(struct ieee80211_tdma_state), M_80211_VAP, M_NOWAIT | M_ZERO);
+ ts = (struct ieee80211_tdma_state *) IEEE80211_MALLOC(
+ sizeof(struct ieee80211_tdma_state), M_80211_VAP,
+ IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
if (ts == NULL) {
printf("%s: cannot allocate TDMA state block\n", __func__);
/* NB: fall back to adhdemo mode */
@@ -199,7 +202,7 @@ tdma_vdetach(struct ieee80211vap *vap)
return;
}
ts->tdma_opdetach(vap);
- free(vap->iv_tdma, M_80211_VAP);
+ IEEE80211_FREE(vap->iv_tdma, M_80211_VAP);
vap->iv_tdma = NULL;
setackpolicy(vap->iv_ic, 0); /* enable ACK's */
@@ -208,9 +211,9 @@ tdma_vdetach(struct ieee80211vap *vap)
static void
sta_leave(void *arg, struct ieee80211_node *ni)
{
- struct ieee80211vap *vap = arg;
+ struct ieee80211vap *vap = ni->ni_vap;
- if (ni->ni_vap == vap && ni != vap->iv_bss)
+ if (ni != vap->iv_bss)
ieee80211_node_leave(ni);
}
@@ -245,7 +248,8 @@ tdma_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
ieee80211_cancel_scan(vap); /* background scan */
if (ostate == IEEE80211_S_RUN) {
/* purge station table; entries are stale */
- ieee80211_iterate_nodes(&ic->ic_sta, sta_leave, vap);
+ ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+ sta_leave, NULL);
}
if (vap->iv_flags_ext & IEEE80211_FEXT_SCANREQ) {
ieee80211_check_scan(vap,
@@ -288,6 +292,8 @@ tdma_beacon_miss(struct ieee80211vap *vap)
{
struct ieee80211_tdma_state *ts = vap->iv_tdma;
+ IEEE80211_LOCK_ASSERT(vap->iv_ic);
+
KASSERT((vap->iv_ic->ic_flags & IEEE80211_F_SCAN) == 0, ("scanning"));
KASSERT(vap->iv_state == IEEE80211_S_RUN,
("wrong state %d", vap->iv_state));
@@ -318,7 +324,7 @@ tdma_beacon_miss(struct ieee80211vap *vap)
static void
tdma_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
- int subtype, int rssi, int nf)
+ int subtype, const struct ieee80211_rx_stats *rxs, int rssi, int nf)
{
struct ieee80211com *ic = ni->ni_ic;
struct ieee80211vap *vap = ni->ni_vap;
@@ -329,7 +335,8 @@ tdma_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
struct ieee80211_frame *wh = mtod(m0, struct ieee80211_frame *);
struct ieee80211_scanparams scan;
- if (ieee80211_parse_beacon(ni, m0, &scan) != 0)
+ /* XXX TODO: use rxstatus to determine off-channel beacons */
+ if (ieee80211_parse_beacon(ni, m0, ic->ic_curchan, &scan) != 0)
return;
if (scan.tdma == NULL) {
/*
@@ -339,8 +346,7 @@ tdma_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
*/
IEEE80211_DISCARD(vap,
IEEE80211_MSG_ELEMID | IEEE80211_MSG_INPUT,
- wh, ieee80211_mgt_subtype_name[subtype >>
- IEEE80211_FC0_SUBTYPE_SHIFT],
+ wh, ieee80211_mgt_subtype_name(subtype),
"%s", "no TDMA ie");
vap->iv_stats.is_rx_mgtdiscard++;
return;
@@ -389,7 +395,7 @@ tdma_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
* 2x parsing of the frame but should happen infrequently
*/
}
- ts->tdma_recv_mgmt(ni, m0, subtype, rssi, nf);
+ ts->tdma_recv_mgmt(ni, m0, subtype, rxs, rssi, nf);
}
/*
@@ -742,7 +748,7 @@ tdma_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
struct ieee80211_tdma_state *ts = vap->iv_tdma;
if ((vap->iv_caps & IEEE80211_C_TDMA) == 0)
- return EOPNOTSUPP;
+ return ENOSYS;
switch (ireq->i_type) {
case IEEE80211_IOC_TDMA_SLOT:
@@ -770,7 +776,7 @@ tdma_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
struct ieee80211_tdma_state *ts = vap->iv_tdma;
if ((vap->iv_caps & IEEE80211_C_TDMA) == 0)
- return EOPNOTSUPP;
+ return ENOSYS;
switch (ireq->i_type) {
case IEEE80211_IOC_TDMA_SLOT:
@@ -820,3 +826,5 @@ restart:
return ERESTART;
}
IEEE80211_IOCTL_SET(tdma, tdma_ioctl_set80211);
+
+#endif /* IEEE80211_SUPPORT_TDMA */