aboutsummaryrefslogtreecommitdiff
path: root/sys/net80211
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2020-06-13 00:59:36 +0000
committerConrad Meyer <cem@FreeBSD.org>2020-06-13 00:59:36 +0000
commit479ab044c1cf84069f66449f10cc0ea3d3acc3f0 (patch)
treeff3357a794046fdb965b28d79f919c19d42574f4 /sys/net80211
parentd93010c598d49aefc8a0d9f4a243981c3a3d3c4f (diff)
downloadsrc-479ab044c1cf84069f66449f10cc0ea3d3acc3f0.tar.gz
src-479ab044c1cf84069f66449f10cc0ea3d3acc3f0.zip
net80211: Add framework for debugnet(4) support
Allow net80211 drivers to register a small vtable of debugnet-related methods. This is not a functional change. Driver support is needed, similar to debugnet(4) for wired NICs. Reviewed by: adrian, markj (earlier version both) Differential Revision: https://reviews.freebsd.org/D17308
Notes
Notes: svn path=/head/; revision=362138
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_freebsd.c58
-rw-r--r--sys/net80211/ieee80211_freebsd.h34
-rw-r--r--sys/net80211/ieee80211_var.h3
3 files changed, 94 insertions, 1 deletions
diff --git a/sys/net80211/ieee80211_freebsd.c b/sys/net80211/ieee80211_freebsd.c
index 8802c6fb41d9..a8482ab0930e 100644
--- a/sys/net80211/ieee80211_freebsd.c
+++ b/sys/net80211/ieee80211_freebsd.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_input.h>
+DEBUGNET_DEFINE(ieee80211);
SYSCTL_NODE(_net, OID_AUTO, wlan, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"IEEE 80211 parameters");
@@ -111,7 +112,14 @@ wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
cp.icp_flags & IEEE80211_CLONE_MACADDR ?
cp.icp_macaddr : ic->ic_macaddr);
- return (vap == NULL ? EIO : 0);
+ if (vap == NULL)
+ return (EIO);
+
+#ifdef DEBUGNET
+ if (ic->ic_debugnet_meth != NULL)
+ DEBUGNET_SET(vap->iv_ifp, ieee80211);
+#endif
+ return (0);
}
static void
@@ -1047,6 +1055,54 @@ ieee80211_get_vap_ifname(struct ieee80211vap *vap)
return vap->iv_ifp->if_xname;
}
+#ifdef DEBUGNET
+static void
+ieee80211_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+{
+ struct ieee80211vap *vap;
+ struct ieee80211com *ic;
+
+ vap = if_getsoftc(ifp);
+ ic = vap->iv_ic;
+
+ IEEE80211_LOCK(ic);
+ ic->ic_debugnet_meth->dn8_init(ic, nrxr, ncl, clsize);
+ IEEE80211_UNLOCK(ic);
+}
+
+static void
+ieee80211_debugnet_event(struct ifnet *ifp, enum debugnet_ev ev)
+{
+ struct ieee80211vap *vap;
+ struct ieee80211com *ic;
+
+ vap = if_getsoftc(ifp);
+ ic = vap->iv_ic;
+
+ IEEE80211_LOCK(ic);
+ ic->ic_debugnet_meth->dn8_event(ic, ev);
+ IEEE80211_UNLOCK(ic);
+}
+
+static int
+ieee80211_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
+{
+ return (ieee80211_vap_transmit(ifp, m));
+}
+
+static int
+ieee80211_debugnet_poll(struct ifnet *ifp, int count)
+{
+ struct ieee80211vap *vap;
+ struct ieee80211com *ic;
+
+ vap = if_getsoftc(ifp);
+ ic = vap->iv_ic;
+
+ return (ic->ic_debugnet_meth->dn8_poll(ic, count));
+}
+#endif
+
/*
* Module glue.
*
diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h
index 19a8e45672a9..ac4f96a753f0 100644
--- a/sys/net80211/ieee80211_freebsd.h
+++ b/sys/net80211/ieee80211_freebsd.h
@@ -40,6 +40,10 @@
#include <sys/taskqueue.h>
#include <sys/time.h>
+#ifdef DEBUGNET
+#include <net/debugnet.h>
+#endif
+
/*
* Common state locking definitions.
*/
@@ -492,6 +496,36 @@ typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
struct ieee80211req *);
SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
#define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
+
+#ifdef DEBUGNET
+typedef void debugnet80211_init_t(struct ieee80211com *, int *nrxr, int *ncl,
+ int *clsize);
+typedef void debugnet80211_event_t(struct ieee80211com *, enum debugnet_ev);
+typedef int debugnet80211_poll_t(struct ieee80211com *, int);
+
+struct debugnet80211_methods {
+ debugnet80211_init_t *dn8_init;
+ debugnet80211_event_t *dn8_event;
+ debugnet80211_poll_t *dn8_poll;
+};
+
+#define DEBUGNET80211_DEFINE(driver) \
+ static debugnet80211_init_t driver##_debugnet80211_init; \
+ static debugnet80211_event_t driver##_debugnet80211_event; \
+ static debugnet80211_poll_t driver##_debugnet80211_poll; \
+ \
+ static struct debugnet80211_methods driver##_debugnet80211_methods = { \
+ .dn8_init = driver##_debugnet80211_init, \
+ .dn8_event = driver##_debugnet80211_event, \
+ .dn8_poll = driver##_debugnet80211_poll, \
+ }
+#define DEBUGNET80211_SET(ic, driver) \
+ (ic)->ic_debugnet_meth = &driver##_debugnet80211_methods
+#else
+#define DEBUGNET80211_DEFINE(driver)
+#define DEBUGNET80211_SET(ic, driver)
+#endif /* DEBUGNET */
+
#endif /* _KERNEL */
/* XXX this stuff belongs elsewhere */
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 1fa596b2391d..6af94ed343c8 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -132,6 +132,8 @@ struct ieee80211_rx_ampdu;
struct ieee80211_superg;
struct ieee80211_frame;
+struct net80211dump_methods;
+
struct ieee80211com {
void *ic_softc; /* driver softc */
const char *ic_name; /* usually device name */
@@ -370,6 +372,7 @@ struct ieee80211com {
/* The channel width has changed (20<->2040) */
void (*ic_update_chw)(struct ieee80211com *);
+ const struct debugnet80211_methods *ic_debugnet_meth;
uint64_t ic_spare[7];
};