2004-12-08 17:26:47 +00:00
|
|
|
/*-
|
2009-01-08 17:12:47 +00:00
|
|
|
* Copyright (c) 2003-2009 Sam Leffler, Errno Consulting
|
2004-12-08 17:26:47 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IEEE 802.11 support (FreeBSD-specific code)
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
#include "opt_wlan.h"
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2016-01-09 09:34:39 +00:00
|
|
|
#include <sys/eventhandler.h>
|
2016-02-01 17:41:21 +00:00
|
|
|
#include <sys/kernel.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <sys/linker.h>
|
2016-02-01 17:41:21 +00:00
|
|
|
#include <sys/malloc.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
#include <net/bpf.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2009-03-29 17:59:14 +00:00
|
|
|
#include <net/if_dl.h>
|
2008-04-20 20:35:46 +00:00
|
|
|
#include <net/if_clone.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <net/if_media.h>
|
2008-04-20 20:35:46 +00:00
|
|
|
#include <net/if_types.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/route.h>
|
2009-08-01 19:26:27 +00:00
|
|
|
#include <net/vnet.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
2009-07-18 20:19:53 +00:00
|
|
|
#include <net80211/ieee80211_input.h>
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
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
|
2008-04-20 20:35:46 +00:00
|
|
|
|
2011-11-07 06:44:47 +00:00
|
|
|
static MALLOC_DEFINE(M_80211_COM, "80211com", "802.11 com state");
|
2008-04-20 20:35:46 +00:00
|
|
|
|
2012-10-16 13:37:54 +00:00
|
|
|
static const char wlanname[] = "wlan";
|
|
|
|
static struct if_clone *wlan_cloner;
|
|
|
|
|
2007-11-02 05:22:25 +00:00
|
|
|
static int
|
2008-04-20 20:35:46 +00:00
|
|
|
wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
|
2007-11-02 05:22:25 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211_clone_params cp;
|
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ieee80211com *ic;
|
2007-11-02 05:22:25 +00:00
|
|
|
int error;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
error = copyin(params, &cp, sizeof(cp));
|
|
|
|
if (error)
|
|
|
|
return error;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ic = ieee80211_find_com(cp.icp_parent);
|
|
|
|
if (ic == NULL)
|
2008-04-20 20:35:46 +00:00
|
|
|
return ENXIO;
|
2008-05-12 00:15:30 +00:00
|
|
|
if (cp.icp_opmode >= IEEE80211_OPMODE_MAX) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ic_printf(ic, "%s: invalid opmode %d\n", __func__,
|
|
|
|
cp.icp_opmode);
|
2008-04-20 20:35:46 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
2008-05-12 00:15:30 +00:00
|
|
|
if ((ic->ic_caps & ieee80211_opcap[cp.icp_opmode]) == 0) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ic_printf(ic, "%s mode not supported\n",
|
2008-05-12 00:15:30 +00:00
|
|
|
ieee80211_opmode_name[cp.icp_opmode]);
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
2009-01-08 17:12:47 +00:00
|
|
|
if ((cp.icp_flags & IEEE80211_CLONE_TDMA) &&
|
|
|
|
#ifdef IEEE80211_SUPPORT_TDMA
|
|
|
|
(ic->ic_caps & IEEE80211_C_TDMA) == 0
|
|
|
|
#else
|
|
|
|
(1)
|
|
|
|
#endif
|
|
|
|
) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ic_printf(ic, "TDMA not supported\n");
|
2009-01-08 17:12:47 +00:00
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
2012-10-16 13:37:54 +00:00
|
|
|
vap = ic->ic_vap_create(ic, wlanname, unit,
|
2008-04-20 20:35:46 +00:00
|
|
|
cp.icp_opmode, cp.icp_flags, cp.icp_bssid,
|
|
|
|
cp.icp_flags & IEEE80211_CLONE_MACADDR ?
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
cp.icp_macaddr : ic->ic_macaddr);
|
2012-10-26 19:06:24 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
return (vap == NULL ? EIO : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wlan_clone_destroy(struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ifp->if_softc;
|
|
|
|
struct ieee80211com *ic = vap->iv_ic;
|
|
|
|
|
|
|
|
ic->ic_vap_delete(vap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_vap_destroy(struct ieee80211vap *vap)
|
|
|
|
{
|
2012-10-26 16:56:55 +00:00
|
|
|
CURVNET_SET(vap->iv_ifp->if_vnet);
|
2012-10-16 13:37:54 +00:00
|
|
|
if_clone_destroyif(wlan_cloner, vap->iv_ifp);
|
2012-10-26 16:56:55 +00:00
|
|
|
CURVNET_RESTORE();
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 20:18:01 +00:00
|
|
|
int
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
int msecs = ticks_to_msecs(*(int *)arg1);
|
|
|
|
int error, t;
|
|
|
|
|
|
|
|
error = sysctl_handle_int(oidp, &msecs, 0, req);
|
2007-11-02 05:22:25 +00:00
|
|
|
if (error || !req->newptr)
|
|
|
|
return error;
|
2008-04-20 20:35:46 +00:00
|
|
|
t = msecs_to_ticks(msecs);
|
|
|
|
*(int *)arg1 = (t < 1) ? 1 : t;
|
2007-11-02 05:22:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ieee80211_sysctl_parent(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = arg1;
|
|
|
|
|
2015-05-25 14:30:44 +00:00
|
|
|
return SYSCTL_OUT_STR(req, ic->ic_name);
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
2008-08-02 18:00:33 +00:00
|
|
|
static int
|
|
|
|
ieee80211_sysctl_radar(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = arg1;
|
|
|
|
int t = 0, error;
|
|
|
|
|
|
|
|
error = sysctl_handle_int(oidp, &t, 0, req);
|
|
|
|
if (error || !req->newptr)
|
|
|
|
return error;
|
|
|
|
IEEE80211_LOCK(ic);
|
|
|
|
ieee80211_dfs_notify_radar(ic, ic->ic_curchan);
|
|
|
|
IEEE80211_UNLOCK(ic);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
void
|
|
|
|
ieee80211_sysctl_attach(struct ieee80211com *ic)
|
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_sysctl_detach(struct ieee80211com *ic)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_sysctl_vattach(struct ieee80211vap *vap)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
2004-12-08 17:26:47 +00:00
|
|
|
struct sysctl_ctx_list *ctx;
|
|
|
|
struct sysctl_oid *oid;
|
|
|
|
char num[14]; /* sufficient for 32 bits */
|
|
|
|
|
2015-05-25 19:18:16 +00:00
|
|
|
ctx = (struct sysctl_ctx_list *) IEEE80211_MALLOC(sizeof(struct sysctl_ctx_list),
|
|
|
|
M_DEVBUF, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
|
2004-12-08 17:26:47 +00:00
|
|
|
if (ctx == NULL) {
|
2008-04-20 20:35:46 +00:00
|
|
|
if_printf(ifp, "%s: cannot allocate sysctl context!\n",
|
2004-12-08 17:26:47 +00:00
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sysctl_ctx_init(ctx);
|
2008-04-20 20:35:46 +00:00
|
|
|
snprintf(num, sizeof(num), "%u", ifp->if_dunit);
|
2004-12-08 17:26:47 +00:00
|
|
|
oid = SYSCTL_ADD_NODE(ctx, &SYSCTL_NODE_CHILDREN(_net, wlan),
|
|
|
|
OID_AUTO, num, CTLFLAG_RD, NULL, "");
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2011-01-18 21:14:13 +00:00
|
|
|
"%parent", CTLTYPE_STRING | CTLFLAG_RD, vap->iv_ic, 0,
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_sysctl_parent, "A", "parent device");
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"driver_caps", CTLFLAG_RW, &vap->iv_caps, 0,
|
|
|
|
"driver capabilities");
|
2004-12-08 17:26:47 +00:00
|
|
|
#ifdef IEEE80211_DEBUG
|
2008-04-20 20:35:46 +00:00
|
|
|
vap->iv_debug = ieee80211_debug;
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"debug", CTLFLAG_RW, &vap->iv_debug, 0,
|
2004-12-08 17:26:47 +00:00
|
|
|
"control debugging printfs");
|
|
|
|
#endif
|
2008-04-20 20:35:46 +00:00
|
|
|
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
|
|
|
"bmiss_max", CTLFLAG_RW, &vap->iv_bmiss_max, 0,
|
|
|
|
"consecutive beacon misses before scanning");
|
2004-12-08 17:26:47 +00:00
|
|
|
/* XXX inherit from tunables */
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"inact_run", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_run, 0,
|
2004-12-08 17:26:47 +00:00
|
|
|
ieee80211_sysctl_inact, "I",
|
|
|
|
"station inactivity timeout (sec)");
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"inact_probe", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_probe, 0,
|
2004-12-08 17:26:47 +00:00
|
|
|
ieee80211_sysctl_inact, "I",
|
|
|
|
"station inactivity probe timeout (sec)");
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"inact_auth", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_auth, 0,
|
2004-12-08 17:26:47 +00:00
|
|
|
ieee80211_sysctl_inact, "I",
|
|
|
|
"station authentication timeout (sec)");
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"inact_init", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_init, 0,
|
2004-12-08 17:26:47 +00:00
|
|
|
ieee80211_sysctl_inact, "I",
|
|
|
|
"station initial state timeout (sec)");
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_htcaps & IEEE80211_HTC_HT) {
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"ampdu_mintraffic_bk", CTLFLAG_RW,
|
|
|
|
&vap->iv_ampdu_mintraffic[WME_AC_BK], 0,
|
|
|
|
"BK traffic tx aggr threshold (pps)");
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"ampdu_mintraffic_be", CTLFLAG_RW,
|
|
|
|
&vap->iv_ampdu_mintraffic[WME_AC_BE], 0,
|
|
|
|
"BE traffic tx aggr threshold (pps)");
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"ampdu_mintraffic_vo", CTLFLAG_RW,
|
|
|
|
&vap->iv_ampdu_mintraffic[WME_AC_VO], 0,
|
|
|
|
"VO traffic tx aggr threshold (pps)");
|
2011-01-12 19:53:50 +00:00
|
|
|
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
2008-04-20 20:35:46 +00:00
|
|
|
"ampdu_mintraffic_vi", CTLFLAG_RW,
|
|
|
|
&vap->iv_ampdu_mintraffic[WME_AC_VI], 0,
|
|
|
|
"VI traffic tx aggr threshold (pps)");
|
|
|
|
}
|
2008-08-02 18:00:33 +00:00
|
|
|
if (vap->iv_caps & IEEE80211_C_DFS) {
|
|
|
|
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
|
|
|
|
"radar", CTLTYPE_INT | CTLFLAG_RW, vap->iv_ic, 0,
|
2009-05-30 20:11:23 +00:00
|
|
|
ieee80211_sysctl_radar, "I", "simulate radar event");
|
2008-08-02 18:00:33 +00:00
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
vap->iv_sysctl = ctx;
|
|
|
|
vap->iv_oid = oid;
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_sysctl_vdetach(struct ieee80211vap *vap)
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_sysctl != NULL) {
|
|
|
|
sysctl_ctx_free(vap->iv_sysctl);
|
2015-05-25 19:18:16 +00:00
|
|
|
IEEE80211_FREE(vap->iv_sysctl, M_DEVBUF);
|
2008-04-20 20:35:46 +00:00
|
|
|
vap->iv_sysctl = NULL;
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_node_dectestref(struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
/* XXX need equivalent of atomic_dec_and_test */
|
|
|
|
atomic_subtract_int(&ni->ni_refcnt, 1);
|
|
|
|
return atomic_cmpset_int(&ni->ni_refcnt, 0, 1);
|
|
|
|
}
|
|
|
|
|
2007-01-08 18:23:43 +00:00
|
|
|
void
|
|
|
|
ieee80211_drain_ifq(struct ifqueue *ifq)
|
|
|
|
{
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct mbuf *m;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
IF_DEQUEUE(ifq, m);
|
|
|
|
if (m == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
|
|
|
KASSERT(ni != NULL, ("frame w/o node"));
|
|
|
|
ieee80211_free_node(ni);
|
|
|
|
m->m_pkthdr.rcvif = NULL;
|
|
|
|
|
|
|
|
m_freem(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
void
|
|
|
|
ieee80211_flush_ifq(struct ifqueue *ifq, struct ieee80211vap *vap)
|
|
|
|
{
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct mbuf *m, **mprev;
|
|
|
|
|
|
|
|
IF_LOCK(ifq);
|
|
|
|
mprev = &ifq->ifq_head;
|
|
|
|
while ((m = *mprev) != NULL) {
|
|
|
|
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
|
|
|
if (ni != NULL && ni->ni_vap == vap) {
|
|
|
|
*mprev = m->m_nextpkt; /* remove from list */
|
|
|
|
ifq->ifq_len--;
|
|
|
|
|
|
|
|
m_freem(m);
|
|
|
|
ieee80211_free_node(ni); /* reclaim ref */
|
|
|
|
} else
|
|
|
|
mprev = &m->m_nextpkt;
|
|
|
|
}
|
|
|
|
/* recalculate tail ptr */
|
|
|
|
m = ifq->ifq_head;
|
|
|
|
for (; m != NULL && m->m_nextpkt != NULL; m = m->m_nextpkt)
|
|
|
|
;
|
|
|
|
ifq->ifq_tail = m;
|
|
|
|
IF_UNLOCK(ifq);
|
|
|
|
}
|
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
/*
|
|
|
|
* As above, for mbufs allocated with m_gethdr/MGETHDR
|
|
|
|
* or initialized by M_COPY_PKTHDR.
|
|
|
|
*/
|
|
|
|
#define MC_ALIGN(m, len) \
|
|
|
|
do { \
|
|
|
|
(m)->m_data += (MCLBYTES - (len)) &~ (sizeof(long) - 1); \
|
|
|
|
} while (/* CONSTCOND */ 0)
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
/*
|
|
|
|
* Allocate and setup a management frame of the specified
|
|
|
|
* size. We return the mbuf and a pointer to the start
|
|
|
|
* of the contiguous data area that's been reserved based
|
|
|
|
* on the packet length. The data area is forced to 32-bit
|
|
|
|
* alignment and the buffer length to a multiple of 4 bytes.
|
|
|
|
* This is done mainly so beacon frames (that require this)
|
|
|
|
* can use this interface too.
|
|
|
|
*/
|
|
|
|
struct mbuf *
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen)
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
u_int len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: we know the mbuf routines will align the data area
|
|
|
|
* so we don't need to do anything special.
|
|
|
|
*/
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
len = roundup2(headroom + pktlen, 4);
|
2004-12-08 17:26:47 +00:00
|
|
|
KASSERT(len <= MCLBYTES, ("802.11 mgt frame too large: %u", len));
|
|
|
|
if (len < MINCLSIZE) {
|
2005-11-02 13:46:32 +00:00
|
|
|
m = m_gethdr(M_NOWAIT, MT_DATA);
|
2004-12-08 17:26:47 +00:00
|
|
|
/*
|
|
|
|
* Align the data in case additional headers are added.
|
|
|
|
* This should only happen when a WEP header is added
|
|
|
|
* which only happens for shared key authentication mgt
|
|
|
|
* frames which all fit in MHLEN.
|
|
|
|
*/
|
|
|
|
if (m != NULL)
|
To ease changes to underlying mbuf structure and the mbuf allocator, reduce
the knowledge of mbuf layout, and in particular constants such as M_EXT,
MLEN, MHLEN, and so on, in mbuf consumers by unifying various alignment
utility functions (M_ALIGN(), MH_ALIGN(), MEXT_ALIGN() in a single
M_ALIGN() macro, implemented by a now-inlined m_align() function:
- Move m_align() from uipc_mbuf.c to mbuf.h; mark as __inline.
- Reimplement M_ALIGN(), MH_ALIGN(), and MEXT_ALIGN() using m_align().
- Update consumers around the tree to simply use M_ALIGN().
This change eliminates a number of cases where mbuf consumers must be aware
of whether or not mbufs returned by the allocator use external storage, but
also assumptions about the size of the returned mbuf. This will make it
easier to introduce changes in how we use external storage, as well as
features such as variable-size mbufs.
Differential Revision: https://reviews.freebsd.org/D1436
Reviewed by: glebius, trasz, gnn, bz
Sponsored by: EMC / Isilon Storage Division
2015-01-05 09:58:32 +00:00
|
|
|
M_ALIGN(m, len);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
} else {
|
2005-11-02 13:46:32 +00:00
|
|
|
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
if (m != NULL)
|
|
|
|
MC_ALIGN(m, len);
|
|
|
|
}
|
2004-12-08 17:26:47 +00:00
|
|
|
if (m != NULL) {
|
2007-08-26 11:32:56 +00:00
|
|
|
m->m_data += headroom;
|
2004-12-08 17:26:47 +00:00
|
|
|
*frm = m->m_data;
|
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2013-02-12 11:24:37 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
2009-07-18 20:19:53 +00:00
|
|
|
/*
|
|
|
|
* Re-align the payload in the mbuf. This is mainly used (right now)
|
|
|
|
* to handle IP header alignment requirements on certain architectures.
|
|
|
|
*/
|
|
|
|
struct mbuf *
|
|
|
|
ieee80211_realign(struct ieee80211vap *vap, struct mbuf *m, size_t align)
|
|
|
|
{
|
|
|
|
int pktlen, space;
|
|
|
|
struct mbuf *n;
|
|
|
|
|
|
|
|
pktlen = m->m_pkthdr.len;
|
|
|
|
space = pktlen + align;
|
|
|
|
if (space < MINCLSIZE)
|
2012-12-05 08:04:20 +00:00
|
|
|
n = m_gethdr(M_NOWAIT, MT_DATA);
|
2009-07-18 20:19:53 +00:00
|
|
|
else {
|
2012-12-05 08:04:20 +00:00
|
|
|
n = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR,
|
2009-07-18 20:19:53 +00:00
|
|
|
space <= MCLBYTES ? MCLBYTES :
|
|
|
|
#if MJUMPAGESIZE != MCLBYTES
|
|
|
|
space <= MJUMPAGESIZE ? MJUMPAGESIZE :
|
|
|
|
#endif
|
|
|
|
space <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
|
|
|
|
}
|
|
|
|
if (__predict_true(n != NULL)) {
|
|
|
|
m_move_pkthdr(n, m);
|
|
|
|
n->m_data = (caddr_t)(ALIGN(n->m_data + align) - align);
|
|
|
|
m_copydata(m, 0, pktlen, mtod(n, caddr_t));
|
|
|
|
n->m_len = pktlen;
|
|
|
|
} else {
|
|
|
|
IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY,
|
|
|
|
mtod(m, const struct ieee80211_frame *), NULL,
|
|
|
|
"%s", "no mbuf to realign");
|
|
|
|
vap->iv_stats.is_rx_badalign++;
|
|
|
|
}
|
|
|
|
m_freem(m);
|
|
|
|
return n;
|
|
|
|
}
|
2013-02-12 11:24:37 +00:00
|
|
|
#endif /* !__NO_STRICT_ALIGNMENT */
|
2009-07-18 20:19:53 +00:00
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
int
|
|
|
|
ieee80211_add_callback(struct mbuf *m,
|
|
|
|
void (*func)(struct ieee80211_node *, void *, int), void *arg)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
struct ieee80211_cb *cb;
|
|
|
|
|
|
|
|
mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_CALLBACK,
|
|
|
|
sizeof(struct ieee80211_cb), M_NOWAIT);
|
|
|
|
if (mtag == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cb = (struct ieee80211_cb *)(mtag+1);
|
|
|
|
cb->func = func;
|
|
|
|
cb->arg = arg;
|
|
|
|
m_tag_prepend(m, mtag);
|
|
|
|
m->m_flags |= M_TXCB;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
First pass of adding transmit parameters as an option for outbound
802.11 mbufs.
The raw transmit path currently doesn't make it easy to queue
these frames:
* there's no node reference stored in the mbuf, like for the normal
path, and
* the bpf supplied raw transmit parameters (rate, rts/cts, etc)
are passed in as an argument, not as an mbuf tag.
In order to support driver queuing of these frames, we need to
be able to put the above into the mbuf before the driver gets it,
so the driver /can/ put it into a queue if needed.
Use an mbuf tag and for now just verbatim copy the bpf parameters
into it. Later on it may grow to include more options but this
will do for now.
Why would you want to queue raw frames? Well, in the case of
iwn(4), we can't send the firmware frames to transmit before
we hear a beacon - the firmware will consider passive channels
as unavailable until it hears a beacon. The firmware "passive"
channel state is cleared upon each RXON command, which is sent to
update association status. So, when we attempt association and
authorisation, the RXON command causes the firmware to clear out
what it's already seen, and so we have to wait for a beacon before
we can transmit.
Before people get overly excited - this alone doesn't "fix" 5GHz
operation - it just makes it (more) possible.
The aim here is to convert all the drivers over to use a raw_xmit()
API that doesn't include the node and params - instead they'd get
those from the mbuf. Then raw_xmit() becomes just a side-channel
version of the normal transmit path for management traffic.
MFC after: 2 weeks
Sponsored by: Norse Corp, Inc.
2015-06-04 06:30:39 +00:00
|
|
|
int
|
|
|
|
ieee80211_add_xmit_params(struct mbuf *m,
|
|
|
|
const struct ieee80211_bpf_params *params)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
struct ieee80211_tx_params *tx;
|
|
|
|
|
|
|
|
mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_XMIT_PARAMS,
|
|
|
|
sizeof(struct ieee80211_tx_params), M_NOWAIT);
|
|
|
|
if (mtag == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
tx = (struct ieee80211_tx_params *)(mtag+1);
|
|
|
|
memcpy(&tx->params, params, sizeof(struct ieee80211_bpf_params));
|
|
|
|
m_tag_prepend(m, mtag);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_get_xmit_params(struct mbuf *m,
|
|
|
|
struct ieee80211_bpf_params *params)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
struct ieee80211_tx_params *tx;
|
|
|
|
|
|
|
|
mtag = m_tag_locate(m, MTAG_ABI_NET80211, NET80211_TAG_XMIT_PARAMS,
|
|
|
|
NULL);
|
|
|
|
if (mtag == NULL)
|
|
|
|
return (-1);
|
|
|
|
tx = (struct ieee80211_tx_params *)(mtag + 1);
|
|
|
|
memcpy(params, &tx->params, sizeof(struct ieee80211_bpf_params));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
void
|
|
|
|
ieee80211_process_callback(struct ieee80211_node *ni,
|
|
|
|
struct mbuf *m, int status)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
|
|
|
|
mtag = m_tag_locate(m, MTAG_ABI_NET80211, NET80211_TAG_CALLBACK, NULL);
|
|
|
|
if (mtag != NULL) {
|
|
|
|
struct ieee80211_cb *cb = (struct ieee80211_cb *)(mtag+1);
|
|
|
|
cb->func(ni, cb->arg, status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-26 00:53:37 +00:00
|
|
|
/*
|
|
|
|
* Add RX parameters to the given mbuf.
|
|
|
|
*
|
|
|
|
* Returns 1 if OK, 0 on error.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ieee80211_add_rx_params(struct mbuf *m, const struct ieee80211_rx_stats *rxs)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
struct ieee80211_rx_params *rx;
|
|
|
|
|
|
|
|
mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_RECV_PARAMS,
|
|
|
|
sizeof(struct ieee80211_rx_stats), M_NOWAIT);
|
|
|
|
if (mtag == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
rx = (struct ieee80211_rx_params *)(mtag + 1);
|
|
|
|
memcpy(&rx->params, rxs, sizeof(*rxs));
|
|
|
|
m_tag_prepend(m, mtag);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_get_rx_params(struct mbuf *m, struct ieee80211_rx_stats *rxs)
|
|
|
|
{
|
|
|
|
struct m_tag *mtag;
|
|
|
|
struct ieee80211_rx_params *rx;
|
|
|
|
|
|
|
|
mtag = m_tag_locate(m, MTAG_ABI_NET80211, NET80211_TAG_RECV_PARAMS,
|
|
|
|
NULL);
|
|
|
|
if (mtag == NULL)
|
|
|
|
return (-1);
|
|
|
|
rx = (struct ieee80211_rx_params *)(mtag + 1);
|
|
|
|
memcpy(rxs, &rx->params, sizeof(*rxs));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
Bring over my initial work from the net80211 TX locking branch.
This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.
This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.
There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.
The specifics:
* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.
This lock is specifically non-recursive.
* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.
* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.
* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().
Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.
* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.
* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.
* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.
* Add locking around the WDS handoff.
* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)
Why not a per-VAP or per-node lock?
Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:
* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.
* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.
* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.
So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.
So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.
General outstanding net80211 TX path issues / TODO:
* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.
* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.
* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.
* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.
* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.
Tested:
* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.
2013-03-08 20:23:55 +00:00
|
|
|
/*
|
|
|
|
* Transmit a frame to the parent interface.
|
|
|
|
*/
|
|
|
|
int
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m)
|
Bring over my initial work from the net80211 TX locking branch.
This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.
This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.
There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.
The specifics:
* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.
This lock is specifically non-recursive.
* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.
* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.
* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().
Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.
* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.
* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.
* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.
* Add locking around the WDS handoff.
* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)
Why not a per-VAP or per-node lock?
Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:
* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.
* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.
* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.
So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.
So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.
General outstanding net80211 TX path issues / TODO:
* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.
* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.
* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.
* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.
* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.
Tested:
* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.
2013-03-08 20:23:55 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
int error;
|
|
|
|
|
Bring over my initial work from the net80211 TX locking branch.
This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.
This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.
There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.
The specifics:
* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.
This lock is specifically non-recursive.
* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.
* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.
* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().
Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.
* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.
* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.
* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.
* Add locking around the WDS handoff.
* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)
Why not a per-VAP or per-node lock?
Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:
* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.
* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.
* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.
So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.
So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.
General outstanding net80211 TX path issues / TODO:
* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.
* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.
* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.
* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.
* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.
Tested:
* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.
2013-03-08 20:23:55 +00:00
|
|
|
/*
|
|
|
|
* Assert the IC TX lock is held - this enforces the
|
|
|
|
* processing -> queuing order is maintained
|
|
|
|
*/
|
|
|
|
IEEE80211_TX_LOCK_ASSERT(ic);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
error = ic->ic_transmit(ic, m);
|
2015-10-12 04:30:38 +00:00
|
|
|
if (error) {
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
|
|
|
|
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
|
|
|
|
|
|
|
/* XXX number of fragments */
|
|
|
|
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
|
|
|
|
ieee80211_free_node(ni);
|
2015-10-12 03:27:08 +00:00
|
|
|
ieee80211_free_mbuf(m);
|
2015-10-12 04:30:38 +00:00
|
|
|
}
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
return (error);
|
Bring over my initial work from the net80211 TX locking branch.
This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.
This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.
There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.
The specifics:
* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.
This lock is specifically non-recursive.
* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.
* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.
* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().
Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.
* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.
* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.
* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.
* Add locking around the WDS handoff.
* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)
Why not a per-VAP or per-node lock?
Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:
* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.
* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.
* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.
So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.
So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.
General outstanding net80211 TX path issues / TODO:
* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.
* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.
* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.
* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.
* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.
Tested:
* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.
2013-03-08 20:23:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Transmit a frame to the VAP interface.
|
|
|
|
*/
|
|
|
|
int
|
2013-08-08 05:09:35 +00:00
|
|
|
ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m)
|
Bring over my initial work from the net80211 TX locking branch.
This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.
This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.
There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.
The specifics:
* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.
This lock is specifically non-recursive.
* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.
* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.
* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().
Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.
* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.
* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.
* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.
* Add locking around the WDS handoff.
* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)
Why not a per-VAP or per-node lock?
Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:
* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.
* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.
* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.
So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.
So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.
General outstanding net80211 TX path issues / TODO:
* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.
* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.
* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.
* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.
* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.
Tested:
* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.
2013-03-08 20:23:55 +00:00
|
|
|
{
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When transmitting via the VAP, we shouldn't hold
|
|
|
|
* any IC TX lock as the VAP TX path will acquire it.
|
|
|
|
*/
|
|
|
|
IEEE80211_TX_UNLOCK_ASSERT(vap->iv_ic);
|
|
|
|
|
|
|
|
return (ifp->if_transmit(ifp, m));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
#include <sys/libkern.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
get_random_bytes(void *p, size_t n)
|
|
|
|
{
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
uint8_t *dp = p;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
while (n > 0) {
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
uint32_t v = arc4random();
|
|
|
|
size_t nb = n > sizeof(uint32_t) ? sizeof(uint32_t) : n;
|
|
|
|
bcopy(&v, dp, n > sizeof(uint32_t) ? sizeof(uint32_t) : n);
|
|
|
|
dp += sizeof(uint32_t), n -= nb;
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/*
|
|
|
|
* Helper function for events that pass just a single mac address.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
notify_macaddr(struct ifnet *ifp, int op, const uint8_t mac[IEEE80211_ADDR_LEN])
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_join_event iev;
|
|
|
|
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET(ifp->if_vnet);
|
2005-03-29 19:36:42 +00:00
|
|
|
memset(&iev, 0, sizeof(iev));
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_ADDR_COPY(iev.iev_addr, mac);
|
|
|
|
rt_ieee80211msg(ifp, op, &iev, sizeof(iev));
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_node_join(struct ieee80211_node *ni, int newassoc)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET_QUIET(ifp->if_vnet);
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%snode join",
|
|
|
|
(ni == vap->iv_bss) ? "bss " : "");
|
|
|
|
|
|
|
|
if (ni == vap->iv_bss) {
|
|
|
|
notify_macaddr(ifp, newassoc ?
|
|
|
|
RTM_IEEE80211_ASSOC : RTM_IEEE80211_REASSOC, ni->ni_bssid);
|
2004-12-08 17:26:47 +00:00
|
|
|
if_link_state_change(ifp, LINK_STATE_UP);
|
2005-03-29 19:36:42 +00:00
|
|
|
} else {
|
2008-04-20 20:35:46 +00:00
|
|
|
notify_macaddr(ifp, newassoc ?
|
|
|
|
RTM_IEEE80211_JOIN : RTM_IEEE80211_REJOIN, ni->ni_macaddr);
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_notify_node_leave(struct ieee80211_node *ni)
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET_QUIET(ifp->if_vnet);
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%snode leave",
|
|
|
|
(ni == vap->iv_bss) ? "bss " : "");
|
|
|
|
|
|
|
|
if (ni == vap->iv_bss) {
|
2004-12-08 17:26:47 +00:00
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_DISASSOC, NULL, 0);
|
|
|
|
if_link_state_change(ifp, LINK_STATE_DOWN);
|
|
|
|
} else {
|
|
|
|
/* fire off wireless event station leaving */
|
2008-04-20 20:35:46 +00:00
|
|
|
notify_macaddr(ifp, RTM_IEEE80211_LEAVE, ni->ni_macaddr);
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_notify_scan_done(struct ieee80211vap *vap)
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s\n", "notify scan done");
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
/* dispatch wireless event indicating scan completed */
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET(ifp->if_vnet);
|
2004-12-08 17:26:47 +00:00
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_SCAN, NULL, 0);
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_notify_replay_failure(struct ieee80211vap *vap,
|
2004-12-08 17:26:47 +00:00
|
|
|
const struct ieee80211_frame *wh, const struct ieee80211_key *k,
|
2009-06-05 23:10:30 +00:00
|
|
|
u_int64_t rsc, int tid)
|
2004-12-08 17:26:47 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
|
2011-10-28 15:47:14 +00:00
|
|
|
"%s replay detected tid %d <rsc %ju, csc %ju, keyix %u rxkeyix %u>",
|
2012-03-27 04:15:38 +00:00
|
|
|
k->wk_cipher->ic_name, tid, (intmax_t) rsc,
|
2009-06-05 23:10:30 +00:00
|
|
|
(intmax_t) k->wk_keyrsc[tid],
|
2005-08-08 18:46:36 +00:00
|
|
|
k->wk_keyix, k->wk_rxkeyix);
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
if (ifp != NULL) { /* NB: for cipher test modules */
|
|
|
|
struct ieee80211_replay_event iev;
|
|
|
|
|
|
|
|
IEEE80211_ADDR_COPY(iev.iev_dst, wh->i_addr1);
|
|
|
|
IEEE80211_ADDR_COPY(iev.iev_src, wh->i_addr2);
|
|
|
|
iev.iev_cipher = k->wk_cipher->ic_cipher;
|
2005-08-08 18:46:36 +00:00
|
|
|
if (k->wk_rxkeyix != IEEE80211_KEYIX_NONE)
|
|
|
|
iev.iev_keyix = k->wk_rxkeyix;
|
|
|
|
else
|
|
|
|
iev.iev_keyix = k->wk_keyix;
|
2009-06-05 23:10:30 +00:00
|
|
|
iev.iev_keyrsc = k->wk_keyrsc[tid];
|
2004-12-08 17:26:47 +00:00
|
|
|
iev.iev_rsc = rsc;
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET(ifp->if_vnet);
|
2004-12-08 17:26:47 +00:00
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_REPLAY, &iev, sizeof(iev));
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_notify_michael_failure(struct ieee80211vap *vap,
|
2004-12-08 17:26:47 +00:00
|
|
|
const struct ieee80211_frame *wh, u_int keyix)
|
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
|
|
|
|
"michael MIC verification failed <keyix %u>", keyix);
|
|
|
|
vap->iv_stats.is_rx_tkipmic++;
|
2004-12-08 17:26:47 +00:00
|
|
|
|
|
|
|
if (ifp != NULL) { /* NB: for cipher test modules */
|
|
|
|
struct ieee80211_michael_event iev;
|
|
|
|
|
|
|
|
IEEE80211_ADDR_COPY(iev.iev_dst, wh->i_addr1);
|
|
|
|
IEEE80211_ADDR_COPY(iev.iev_src, wh->i_addr2);
|
|
|
|
iev.iev_cipher = IEEE80211_CIPHER_TKIP;
|
|
|
|
iev.iev_keyix = keyix;
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_SET(ifp->if_vnet);
|
2004-12-08 17:26:47 +00:00
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_MICHAEL, &iev, sizeof(iev));
|
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.
This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.
The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.
The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.
This change also introduces a DDB subcommand to show the list of all
vnet instances.
Approved by: julian (mentor)
2009-05-05 10:56:12 +00:00
|
|
|
CURVNET_RESTORE();
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
void
|
|
|
|
ieee80211_notify_wds_discover(struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
|
|
|
notify_macaddr(ifp, RTM_IEEE80211_WDS, ni->ni_macaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_csa(struct ieee80211com *ic,
|
|
|
|
const struct ieee80211_channel *c, int mode, int count)
|
|
|
|
{
|
|
|
|
struct ieee80211_csa_event iev;
|
2015-05-25 19:48:48 +00:00
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ifnet *ifp;
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
memset(&iev, 0, sizeof(iev));
|
|
|
|
iev.iev_flags = c->ic_flags;
|
|
|
|
iev.iev_freq = c->ic_freq;
|
|
|
|
iev.iev_ieee = c->ic_ieee;
|
|
|
|
iev.iev_mode = mode;
|
|
|
|
iev.iev_count = count;
|
2015-05-25 19:48:48 +00:00
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
CURVNET_SET(ifp->if_vnet);
|
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_CSA, &iev, sizeof(iev));
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_radar(struct ieee80211com *ic,
|
|
|
|
const struct ieee80211_channel *c)
|
|
|
|
{
|
|
|
|
struct ieee80211_radar_event iev;
|
2015-05-25 19:48:48 +00:00
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ifnet *ifp;
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
memset(&iev, 0, sizeof(iev));
|
|
|
|
iev.iev_flags = c->ic_flags;
|
|
|
|
iev.iev_freq = c->ic_freq;
|
|
|
|
iev.iev_ieee = c->ic_ieee;
|
2015-05-25 19:48:48 +00:00
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
CURVNET_SET(ifp->if_vnet);
|
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_RADAR, &iev, sizeof(iev));
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_cac(struct ieee80211com *ic,
|
|
|
|
const struct ieee80211_channel *c, enum ieee80211_notify_cac_event type)
|
|
|
|
{
|
|
|
|
struct ieee80211_cac_event iev;
|
2015-05-25 19:48:48 +00:00
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ifnet *ifp;
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
memset(&iev, 0, sizeof(iev));
|
|
|
|
iev.iev_flags = c->ic_flags;
|
|
|
|
iev.iev_freq = c->ic_freq;
|
|
|
|
iev.iev_ieee = c->ic_ieee;
|
|
|
|
iev.iev_type = type;
|
2015-05-25 19:48:48 +00:00
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
CURVNET_SET(ifp->if_vnet);
|
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_CAC, &iev, sizeof(iev));
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_node_deauth(struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
|
|
|
IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%s", "node deauth");
|
|
|
|
|
|
|
|
notify_macaddr(ifp, RTM_IEEE80211_DEAUTH, ni->ni_macaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_node_auth(struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
|
|
|
IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%s", "node auth");
|
|
|
|
|
|
|
|
notify_macaddr(ifp, RTM_IEEE80211_AUTH, ni->ni_macaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_country(struct ieee80211vap *vap,
|
|
|
|
const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t cc[2])
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
struct ieee80211_country_event iev;
|
|
|
|
|
|
|
|
memset(&iev, 0, sizeof(iev));
|
|
|
|
IEEE80211_ADDR_COPY(iev.iev_addr, bssid);
|
|
|
|
iev.iev_cc[0] = cc[0];
|
|
|
|
iev.iev_cc[1] = cc[1];
|
2013-03-20 02:42:52 +00:00
|
|
|
CURVNET_SET(ifp->if_vnet);
|
2008-04-20 20:35:46 +00:00
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_COUNTRY, &iev, sizeof(iev));
|
2013-03-20 02:42:52 +00:00
|
|
|
CURVNET_RESTORE();
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_notify_radio(struct ieee80211com *ic, int state)
|
|
|
|
{
|
|
|
|
struct ieee80211_radio_event iev;
|
2015-05-25 19:48:48 +00:00
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ifnet *ifp;
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
memset(&iev, 0, sizeof(iev));
|
|
|
|
iev.iev_state = state;
|
2015-05-25 19:48:48 +00:00
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
CURVNET_SET(ifp->if_vnet);
|
|
|
|
rt_ieee80211msg(ifp, RTM_IEEE80211_RADIO, &iev, sizeof(iev));
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
void
|
|
|
|
ieee80211_load_module(const char *modname)
|
|
|
|
{
|
|
|
|
|
2006-06-13 21:36:23 +00:00
|
|
|
#ifdef notyet
|
|
|
|
(void)kern_kldload(curthread, modname, NULL);
|
2004-12-13 04:26:36 +00:00
|
|
|
#else
|
|
|
|
printf("%s: load the %s module by hand for now.\n", __func__, modname);
|
|
|
|
#endif
|
2004-12-08 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
static eventhandler_tag wlan_bpfevent;
|
|
|
|
|
|
|
|
static void
|
2009-05-25 16:35:31 +00:00
|
|
|
bpf_track(void *arg, struct ifnet *ifp, int dlt, int attach)
|
2009-05-20 20:00:40 +00:00
|
|
|
{
|
2013-10-10 19:56:31 +00:00
|
|
|
/* NB: identify vap's by if_init */
|
2013-08-08 05:09:35 +00:00
|
|
|
if (dlt == DLT_IEEE802_11_RADIO &&
|
2013-10-10 19:56:31 +00:00
|
|
|
ifp->if_init == ieee80211_init) {
|
2009-05-20 20:00:40 +00:00
|
|
|
struct ieee80211vap *vap = ifp->if_softc;
|
|
|
|
/*
|
|
|
|
* Track bpf radiotap listener state. We mark the vap
|
|
|
|
* to indicate if any listener is present and the com
|
|
|
|
* to indicate if any listener exists on any associated
|
|
|
|
* vap. This flag is used by drivers to prepare radiotap
|
|
|
|
* state only when needed.
|
|
|
|
*/
|
2009-06-02 00:33:28 +00:00
|
|
|
if (attach) {
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_syncflag_ext(vap, IEEE80211_FEXT_BPF);
|
2009-06-02 00:33:28 +00:00
|
|
|
if (vap->iv_opmode == IEEE80211_M_MONITOR)
|
|
|
|
atomic_add_int(&vap->iv_ic->ic_montaps, 1);
|
2009-06-02 16:57:27 +00:00
|
|
|
} else if (!bpf_peers_present(vap->iv_rawbpf)) {
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_syncflag_ext(vap, -IEEE80211_FEXT_BPF);
|
2009-06-02 00:33:28 +00:00
|
|
|
if (vap->iv_opmode == IEEE80211_M_MONITOR)
|
|
|
|
atomic_subtract_int(&vap->iv_ic->ic_montaps, 1);
|
|
|
|
}
|
2009-05-20 20:00:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-08 17:26:47 +00:00
|
|
|
/*
|
|
|
|
* Module glue.
|
|
|
|
*
|
|
|
|
* NB: the module name is "wlan" for compatibility with NetBSD.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
wlan_modevent(module_t mod, int type, void *unused)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
if (bootverbose)
|
|
|
|
printf("wlan: <802.11 Link Layer>\n");
|
2009-05-20 20:00:40 +00:00
|
|
|
wlan_bpfevent = EVENTHANDLER_REGISTER(bpf_track,
|
|
|
|
bpf_track, 0, EVENTHANDLER_PRI_ANY);
|
2012-10-16 13:37:54 +00:00
|
|
|
wlan_cloner = if_clone_simple(wlanname, wlan_clone_create,
|
|
|
|
wlan_clone_destroy, 0);
|
2004-12-08 17:26:47 +00:00
|
|
|
return 0;
|
|
|
|
case MOD_UNLOAD:
|
2012-10-16 13:37:54 +00:00
|
|
|
if_clone_detach(wlan_cloner);
|
2009-05-20 20:00:40 +00:00
|
|
|
EVENTHANDLER_DEREGISTER(bpf_track, wlan_bpfevent);
|
2004-12-08 17:26:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static moduledata_t wlan_mod = {
|
2012-10-16 13:37:54 +00:00
|
|
|
wlanname,
|
2004-12-08 17:26:47 +00:00
|
|
|
wlan_modevent,
|
2012-10-10 08:36:38 +00:00
|
|
|
0
|
2004-12-08 17:26:47 +00:00
|
|
|
};
|
|
|
|
DECLARE_MODULE(wlan, wlan_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
|
|
|
|
MODULE_VERSION(wlan, 1);
|
|
|
|
MODULE_DEPEND(wlan, ether, 1, 1, 1);
|
2012-03-16 23:08:13 +00:00
|
|
|
#ifdef IEEE80211_ALQ
|
|
|
|
MODULE_DEPEND(wlan, alq, 1, 1, 1);
|
|
|
|
#endif /* IEEE80211_ALQ */
|
|
|
|
|