svn commit: r362138 - head/sys/net80211
Conrad Meyer
cem at FreeBSD.org
Sat Jun 13 00:59:38 UTC 2020
Author: cem
Date: Sat Jun 13 00:59:36 2020
New Revision: 362138
URL: https://svnweb.freebsd.org/changeset/base/362138
Log:
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
Modified:
head/sys/net80211/ieee80211_freebsd.c
head/sys/net80211/ieee80211_freebsd.h
head/sys/net80211/ieee80211_var.h
Modified: head/sys/net80211/ieee80211_freebsd.c
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.c Fri Jun 12 23:43:44 2020 (r362137)
+++ head/sys/net80211/ieee80211_freebsd.c Sat Jun 13 00:59:36 2020 (r362138)
@@ -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, cadd
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
@@ -1046,6 +1054,54 @@ ieee80211_get_vap_ifname(struct ieee80211vap *vap)
return "(none)";
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.
Modified: head/sys/net80211/ieee80211_freebsd.h
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.h Fri Jun 12 23:43:44 2020 (r362137)
+++ head/sys/net80211/ieee80211_freebsd.h Sat Jun 13 00:59:36 2020 (r362138)
@@ -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 ieee80211va
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 */
Modified: head/sys/net80211/ieee80211_var.h
==============================================================================
--- head/sys/net80211/ieee80211_var.h Fri Jun 12 23:43:44 2020 (r362137)
+++ head/sys/net80211/ieee80211_var.h Sat Jun 13 00:59:36 2020 (r362138)
@@ -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];
};
More information about the svn-src-all
mailing list