PERFORCE change 64838 for review
Sam Leffler
sam at FreeBSD.org
Wed Nov 10 13:14:33 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=64838
Change 64838 by sam at sam_ebb on 2004/11/10 21:13:51
o overhaul sysctl stuff; root everything under net.wlan and
add dynamic mib vars
o fixup debugging msgs to use the per-instance control
o lock virtual ap list and add dumb vap numbering for the
dynamic sysctls (need to fix to reuse previously unallocated
but unused numbers)
o remove inactivity timer ioctls; use sysctls instead
o fix bug reclaiming embryonic node state; don't free directly;
use the refcnt mechanism like everywhere else
Affected files ...
.. //depot/projects/wifi/sys/net80211/ieee80211.c#5 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#3 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_freebsd.h#4 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#12 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.h#6 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_node.c#11 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_var.h#7 edit
Differences ...
==== //depot/projects/wifi/sys/net80211/ieee80211.c#5 (text+ko) ====
@@ -40,7 +40,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/sysctl.h>
#include <sys/socket.h>
@@ -52,12 +51,6 @@
#include <net/bpf.h>
-#ifdef IEEE80211_DEBUG
-int ieee80211_debug = 0;
-SYSCTL_INT(_debug, OID_AUTO, ieee80211, CTLFLAG_RW, &ieee80211_debug,
- 0, "IEEE 802.11 media debugging printfs");
-#endif
-
static void ieee80211_set11gbasicrates(struct ieee80211_rateset *,
enum ieee80211_phymode);
@@ -74,6 +67,9 @@
SLIST_HEAD(ieee80211_list, ieee80211com);
static struct ieee80211_list ieee80211_list =
SLIST_HEAD_INITIALIZER(ieee80211_list);
+static int ieee80211_vap = 0; /* next avail vap number */
+static struct mtx ieee80211_vap_mtx;
+MTX_SYSINIT(ieee80211, &ieee80211_vap_mtx, "net80211 instances", MTX_DEF);
void
ieee80211_ifattach(struct ieee80211com *ic)
@@ -138,8 +134,12 @@
ieee80211_node_attach(ic);
ieee80211_proto_attach(ic);
- /* XXX lock */
+ mtx_lock(&ieee80211_vap_mtx);
+ ic->ic_vap = ieee80211_vap++; /* XXX use bitmap */
SLIST_INSERT_HEAD(&ieee80211_list, ic, ic_next);
+ mtx_unlock(&ieee80211_vap_mtx);
+
+ ieee80211_sysctl_attach(ic); /* NB: requires ic_vap */
}
void
@@ -147,9 +147,11 @@
{
struct ifnet *ifp = ic->ic_ifp;
- /* XXX lock */
+ mtx_lock(&ieee80211_vap_mtx);
SLIST_REMOVE(&ieee80211_list, ic, ieee80211com, ic_next);
+ mtx_unlock(&ieee80211_vap_mtx);
+ ieee80211_sysctl_detach(ic);
ieee80211_proto_detach(ic);
ieee80211_crypto_detach(ic);
ieee80211_node_detach(ic);
==== //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#3 (text+ko) ====
@@ -36,6 +36,7 @@
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/module.h>
+#include <sys/sysctl.h>
#include <sys/socket.h>
@@ -46,6 +47,78 @@
#include <net80211/ieee80211_var.h>
+SYSCTL_NODE(_net, OID_AUTO, wlan, CTLFLAG_RD, 0, "IEEE 80211 parameters");
+
+#ifdef IEEE80211_DEBUG
+int ieee80211_debug = 0;
+SYSCTL_INT(_net_wlan, OID_AUTO, debug, CTLFLAG_RW, &ieee80211_debug,
+ 0, "debugging printfs");
+#endif
+
+static int
+ieee80211_sysctl_inact(SYSCTL_HANDLER_ARGS)
+{
+ int inact = (*(int *)arg1) * IEEE80211_INACT_WAIT;
+ int error;
+
+ error = sysctl_handle_int(oidp, &inact, 0, req);
+ if (error || !req->newptr)
+ return error;
+ *(int *)arg1 = inact / IEEE80211_INACT_WAIT;
+ return 0;
+}
+
+void
+ieee80211_sysctl_attach(struct ieee80211com *ic)
+{
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid *oid;
+ char num[14]; /* sufficient for 32 bits */
+
+ MALLOC(ctx, struct sysctl_ctx_list *, sizeof(struct sysctl_ctx_list),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (ctx == NULL) {
+ if_printf(ic->ic_ifp, "%s: cannot allocate sysctl context!\n",
+ __func__);
+ return;
+ }
+ sysctl_ctx_init(ctx);
+ snprintf(num, sizeof(num), "%u", ic->ic_vap);
+ /* XXX wlan.%d with vap support */
+ oid = SYSCTL_ADD_NODE(ctx, &SYSCTL_NODE_CHILDREN(_net, wlan),
+ OID_AUTO, num, CTLFLAG_RD, NULL, "");
+#ifdef IEEE80211_DEBUG
+ ic->ic_debug = ieee80211_debug;
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+ "debug", CTLFLAG_RW, &ic->ic_debug, 0,
+ "control debugging printfs");
+#endif
+ /* XXX inherit from tunables */
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+ "inact", CTLTYPE_INT | CTLFLAG_RW, &ic->ic_inact_run, 0,
+ ieee80211_sysctl_inact, "I",
+ "station inactivity timeout (sec)");
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+ "inact_auth", CTLTYPE_INT | CTLFLAG_RW, &ic->ic_inact_auth, 0,
+ ieee80211_sysctl_inact, "I",
+ "station authentication timeout (sec)");
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+ "inact_init", CTLTYPE_INT | CTLFLAG_RW, &ic->ic_inact_init, 0,
+ ieee80211_sysctl_inact, "I",
+ "station initial state timeout (sec)");
+ ic->ic_sysctl = ctx;
+}
+
+void
+ieee80211_sysctl_detach(struct ieee80211com *ic)
+{
+
+ if (ic->ic_sysctl != NULL) {
+ sysctl_ctx_free(ic->ic_sysctl);
+ ic->ic_sysctl = NULL;
+ }
+}
+
int
ieee80211_node_dectestref(struct ieee80211_node *ni)
{
==== //depot/projects/wifi/sys/net80211/ieee80211_freebsd.h#4 (text+ko) ====
@@ -94,6 +94,12 @@
extern void get_random_bytes(void *, size_t);
+struct ieee80211com;
+
+void ieee80211_sysctl_attach(struct ieee80211com *);
+void ieee80211_sysctl_detach(struct ieee80211com *);
+
+/* XXX this stuff belongs elsewhere */
/*
* Message formats for messages from the net80211 layer to user
* applications via the routing socket. These messages are appended
==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#12 (text+ko) ====
@@ -1290,15 +1290,6 @@
case IEEE80211_IOC_STA_STATS:
error = ieee80211_ioctl_getstastats(ic, ireq);
break;
- case IEEE80211_IOC_INACT:
- ireq->i_val = ic->ic_inact_run * IEEE80211_INACT_WAIT;
- break;
- case IEEE80211_IOC_INACT_AUTH:
- ireq->i_val = ic->ic_inact_auth * IEEE80211_INACT_WAIT;
- break;
- case IEEE80211_IOC_INACT_INIT:
- ireq->i_val = ic->ic_inact_init * IEEE80211_INACT_WAIT;
- break;
case IEEE80211_IOC_STA_INFO:
error = ieee80211_ioctl_getstainfo(ic, ireq);
break;
@@ -1974,15 +1965,6 @@
case IEEE80211_IOC_MACCMD:
error = ieee80211_ioctl_maccmd(ic, ireq);
break;
- case IEEE80211_IOC_INACT:
- ic->ic_inact_run = ireq->i_val / IEEE80211_INACT_WAIT;
- break;
- case IEEE80211_IOC_INACT_AUTH:
- ic->ic_inact_auth = ireq->i_val / IEEE80211_INACT_WAIT;
- break;
- case IEEE80211_IOC_INACT_INIT:
- ic->ic_inact_init = ireq->i_val / IEEE80211_INACT_WAIT;
- break;
default:
error = EINVAL;
break;
==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.h#6 (text+ko) ====
@@ -377,9 +377,7 @@
#define IEEE80211_IOC_WPAIE 39 /* WPA information element */
#define IEEE80211_IOC_STA_STATS 40 /* per-station statistics */
#define IEEE80211_IOC_MACCMD 41 /* MAC ACL operation */
-#define IEEE80211_IOC_INACT 42 /* station inactivity timeout */
-#define IEEE80211_IOC_INACT_AUTH 43 /* station auth inact timeout */
-#define IEEE80211_IOC_INACT_INIT 44 /* station init inact timeout */
+/* 42-44 available */
#define IEEE80211_IOC_STA_INFO 45 /* station/neighbor info */
#ifndef IEEE80211_CHAN_ANY
==== //depot/projects/wifi/sys/net80211/ieee80211_node.c#11 (text+ko) ====
@@ -163,7 +163,7 @@
{
if (ic->ic_bss != NULL) {
- ic->ic_node_free(ic->ic_bss);
+ ieee80211_free_node(ic->ic_bss);
ic->ic_bss = NULL;
}
ieee80211_node_table_cleanup(&ic->ic_scan);
@@ -1657,7 +1657,7 @@
ieee80211_node_table_reset(struct ieee80211_node_table *nt)
{
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE,
+ IEEE80211_DPRINTF(nt->nt_ic, IEEE80211_MSG_NODE,
"%s %s table\n", __func__, nt->nt_name);
IEEE80211_NODE_LOCK(nt);
@@ -1670,7 +1670,7 @@
ieee80211_node_table_cleanup(struct ieee80211_node_table *nt)
{
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE,
+ IEEE80211_DPRINTF(nt->nt_ic, IEEE80211_MSG_NODE,
"%s %s table\n", __func__, nt->nt_name);
ieee80211_free_allnodes_locked(nt);
@@ -1684,7 +1684,7 @@
ieee80211_node_table_free(struct ieee80211_node_table *nt)
{
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE,
+ IEEE80211_DPRINTF(nt->nt_ic, IEEE80211_MSG_NODE,
"%s %s table\n", __func__, nt->nt_name);
IEEE80211_NODE_LOCK(nt);
==== //depot/projects/wifi/sys/net80211/ieee80211_var.h#7 (text+ko) ====
@@ -187,12 +187,15 @@
#define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */
struct ieee80211_aclator;
+struct sysctl_ctx_list;
struct ieee80211com {
SLIST_ENTRY(ieee80211com) ic_next;
struct ifnet *ic_ifp; /* associated device */
struct ieee80211_stats ic_stats; /* statistics */
+ struct sysctl_ctx_list *ic_sysctl; /* dynamic sysctl context */
u_int32_t ic_debug; /* debug msg flags */
+ int ic_vap; /* virtual AP index */
int (*ic_reset)(struct ifnet *);
void (*ic_recv_mgmt)(struct ieee80211com *,
@@ -257,7 +260,7 @@
* Inactivity timer settings for nodes.
*/
int ic_inact_init; /* initial setting */
- int ic_inact_auth; /* assoc but not auth setting */
+ int ic_inact_auth; /* auth but not assoc setting */
int ic_inact_run; /* authorized setting */
/*
@@ -395,7 +398,6 @@
#define IEEE80211_MSG_ANY 0xffffffff /* anything */
#ifdef IEEE80211_DEBUG
-#ifdef notyet
#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) do { \
if (_ic->ic_debug & (_m)) \
printf(_fmt, __VA_ARGS__); \
@@ -415,27 +417,6 @@
#define ieee80211_msg_scan(_ic) \
((_ic)->ic_debug & IEEE80211_MSG_SCAN)
#else
-extern int ieee80211_debug;
-#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) do { \
- if (ieee80211_debug & (_m)) \
- printf(_fmt, __VA_ARGS__); \
-} while (0)
-#define ieee80211_msg_debug(_ic) \
- (ieee80211_debug & IEEE80211_MSG_DEBUG)
-#define ieee80211_msg_dumppkts(_ic) \
- (ieee80211_debug & IEEE80211_MSG_DUMPPKTS)
-#define ieee80211_msg_input(_ic) \
- (ieee80211_debug & IEEE80211_MSG_INPUT)
-#define ieee80211_msg_radius(_ic) \
- (ieee80211_debug & IEEE80211_MSG_RADIUS)
-#define ieee80211_msg_dumpradius(_ic) \
- (ieee80211_debug & IEEE80211_MSG_RADDUMP)
-#define ieee80211_msg_dumpradkeys(_ic) \
- (ieee80211_debug & IEEE80211_MSG_RADKEYS)
-#define ieee80211_msg_scan(_ic) \
- (ieee80211_debug & IEEE80211_MSG_SCAN)
-#endif
-#else
#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...)
#endif
More information about the p4-projects
mailing list