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
This commit is contained in:
Conrad Meyer 2020-06-13 00:59:36 +00:00
parent d93010c598
commit 479ab044c1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362138
3 changed files with 94 additions and 1 deletions

View File

@ -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.
*

View File

@ -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 */

View File

@ -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];
};