2005-04-18 18:47:38 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2006-03-12 19:01:00 +00:00
|
|
|
* Copyright (c) 2004-2006
|
2005-04-18 18:47:38 +00:00
|
|
|
* Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
|
2007-10-12 05:23:00 +00:00
|
|
|
* Copyright (c) 2006 Sam Leffler, Errno Consulting
|
|
|
|
* Copyright (c) 2007 Andrew Thompson <thompsa@FreeBSD.org>
|
2005-04-18 18:47:38 +00:00
|
|
|
*
|
|
|
|
* 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 unmodified, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$");
|
|
|
|
|
|
|
|
/*-
|
|
|
|
* Intel(R) PRO/Wireless 2100 MiniPCI driver
|
|
|
|
* http://www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
2006-03-12 19:01:00 +00:00
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/taskqueue.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/endian.h>
|
2006-03-12 19:01:00 +00:00
|
|
|
#include <sys/linker.h>
|
|
|
|
#include <sys/firmware.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
|
|
|
|
#include <dev/ipw/if_ipwreg.h>
|
|
|
|
#include <dev/ipw/if_ipwvar.h>
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
#define IPW_DEBUG
|
2005-04-18 18:47:38 +00:00
|
|
|
#ifdef IPW_DEBUG
|
|
|
|
#define DPRINTF(x) do { if (ipw_debug > 0) printf x; } while (0)
|
|
|
|
#define DPRINTFN(n, x) do { if (ipw_debug >= (n)) printf x; } while (0)
|
|
|
|
int ipw_debug = 0;
|
|
|
|
SYSCTL_INT(_debug, OID_AUTO, ipw, CTLFLAG_RW, &ipw_debug, 0, "ipw debug level");
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n, x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MODULE_DEPEND(ipw, pci, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(ipw, wlan, 1, 1, 1);
|
2006-03-12 19:01:00 +00:00
|
|
|
MODULE_DEPEND(ipw, firmware, 1, 1, 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
struct ipw_ident {
|
|
|
|
uint16_t vendor;
|
|
|
|
uint16_t device;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ipw_ident ipw_ident_table[] = {
|
|
|
|
{ 0x8086, 0x1043, "Intel(R) PRO/Wireless 2100 MiniPCI" },
|
|
|
|
|
|
|
|
{ 0, 0, NULL }
|
|
|
|
};
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static struct ieee80211vap *ipw_vap_create(struct ieee80211com *,
|
2011-12-17 10:23:17 +00:00
|
|
|
const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
|
|
|
|
const uint8_t [IEEE80211_ADDR_LEN],
|
|
|
|
const uint8_t [IEEE80211_ADDR_LEN]);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void ipw_vap_delete(struct ieee80211vap *);
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_dma_alloc(struct ipw_softc *);
|
|
|
|
static void ipw_release(struct ipw_softc *);
|
|
|
|
static void ipw_media_status(struct ifnet *, struct ifmediareq *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static int ipw_newstate(struct ieee80211vap *, enum ieee80211_state, int);
|
2005-04-18 18:47:38 +00:00
|
|
|
static uint16_t ipw_read_prom_word(struct ipw_softc *, uint8_t);
|
2016-05-19 22:19:35 +00:00
|
|
|
static uint16_t ipw_read_chanmask(struct ipw_softc *);
|
2007-10-12 05:23:00 +00:00
|
|
|
static void ipw_rx_cmd_intr(struct ipw_softc *, struct ipw_soft_buf *);
|
|
|
|
static void ipw_rx_newstate_intr(struct ipw_softc *, struct ipw_soft_buf *);
|
|
|
|
static void ipw_rx_data_intr(struct ipw_softc *, struct ipw_status *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ipw_soft_bd *, struct ipw_soft_buf *);
|
|
|
|
static void ipw_rx_intr(struct ipw_softc *);
|
|
|
|
static void ipw_release_sbd(struct ipw_softc *, struct ipw_soft_bd *);
|
|
|
|
static void ipw_tx_intr(struct ipw_softc *);
|
|
|
|
static void ipw_intr(void *);
|
|
|
|
static void ipw_dma_map_addr(void *, bus_dma_segment_t *, int, int);
|
2007-10-12 05:23:00 +00:00
|
|
|
static const char * ipw_cmdname(int);
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_cmd(struct ipw_softc *, uint32_t, void *, uint32_t);
|
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
|
|
|
static int ipw_tx_start(struct ipw_softc *, struct mbuf *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_node *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static int ipw_raw_xmit(struct ieee80211_node *, struct mbuf *,
|
|
|
|
const struct ieee80211_bpf_params *);
|
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
|
|
|
static int ipw_transmit(struct ieee80211com *, struct mbuf *);
|
|
|
|
static void ipw_start(struct ipw_softc *);
|
2007-10-12 05:23:00 +00:00
|
|
|
static void ipw_watchdog(void *);
|
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
|
|
|
static void ipw_parent(struct ieee80211com *);
|
2005-04-18 18:47:38 +00:00
|
|
|
static void ipw_stop_master(struct ipw_softc *);
|
2007-10-12 05:23:00 +00:00
|
|
|
static int ipw_enable(struct ipw_softc *);
|
|
|
|
static int ipw_disable(struct ipw_softc *);
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_reset(struct ipw_softc *);
|
2006-03-12 19:01:00 +00:00
|
|
|
static int ipw_load_ucode(struct ipw_softc *, const char *, int);
|
|
|
|
static int ipw_load_firmware(struct ipw_softc *, const char *, int);
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_config(struct ipw_softc *);
|
2009-05-02 15:14:18 +00:00
|
|
|
static void ipw_assoc(struct ieee80211com *, struct ieee80211vap *);
|
|
|
|
static void ipw_disassoc(struct ieee80211com *, struct ieee80211vap *);
|
2006-03-12 19:01:00 +00:00
|
|
|
static void ipw_init_task(void *, int);
|
2005-04-18 18:47:38 +00:00
|
|
|
static void ipw_init(void *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void ipw_init_locked(struct ipw_softc *);
|
2005-04-18 18:47:38 +00:00
|
|
|
static void ipw_stop(void *);
|
2007-10-12 05:23:00 +00:00
|
|
|
static void ipw_stop_locked(struct ipw_softc *);
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_sysctl_stats(SYSCTL_HANDLER_ARGS);
|
|
|
|
static int ipw_sysctl_radio(SYSCTL_HANDLER_ARGS);
|
|
|
|
static uint32_t ipw_read_table1(struct ipw_softc *, uint32_t);
|
|
|
|
static void ipw_write_table1(struct ipw_softc *, uint32_t, uint32_t);
|
2007-10-12 05:23:00 +00:00
|
|
|
#if 0
|
2005-04-18 18:47:38 +00:00
|
|
|
static int ipw_read_table2(struct ipw_softc *, uint32_t, void *,
|
|
|
|
uint32_t *);
|
|
|
|
static void ipw_read_mem_1(struct ipw_softc *, bus_size_t, uint8_t *,
|
|
|
|
bus_size_t);
|
2007-10-12 05:23:00 +00:00
|
|
|
#endif
|
2006-03-12 19:01:00 +00:00
|
|
|
static void ipw_write_mem_1(struct ipw_softc *, bus_size_t,
|
|
|
|
const uint8_t *, bus_size_t);
|
2007-10-12 05:23:00 +00:00
|
|
|
static int ipw_scan(struct ipw_softc *);
|
|
|
|
static void ipw_scan_start(struct ieee80211com *);
|
|
|
|
static void ipw_scan_end(struct ieee80211com *);
|
2016-05-19 22:19:35 +00:00
|
|
|
static void ipw_getradiocaps(struct ieee80211com *, int, int *,
|
|
|
|
struct ieee80211_channel[]);
|
2007-10-12 05:23:00 +00:00
|
|
|
static void ipw_set_channel(struct ieee80211com *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void ipw_scan_curchan(struct ieee80211_scan_state *,
|
|
|
|
unsigned long maxdwell);
|
|
|
|
static void ipw_scan_mindwell(struct ieee80211_scan_state *);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
static int ipw_probe(device_t);
|
|
|
|
static int ipw_attach(device_t);
|
|
|
|
static int ipw_detach(device_t);
|
|
|
|
static int ipw_shutdown(device_t);
|
|
|
|
static int ipw_suspend(device_t);
|
|
|
|
static int ipw_resume(device_t);
|
|
|
|
|
|
|
|
static device_method_t ipw_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, ipw_probe),
|
|
|
|
DEVMETHOD(device_attach, ipw_attach),
|
|
|
|
DEVMETHOD(device_detach, ipw_detach),
|
|
|
|
DEVMETHOD(device_shutdown, ipw_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, ipw_suspend),
|
|
|
|
DEVMETHOD(device_resume, ipw_resume),
|
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
DEVMETHOD_END
|
2005-04-18 18:47:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ipw_driver = {
|
|
|
|
"ipw",
|
|
|
|
ipw_methods,
|
|
|
|
sizeof (struct ipw_softc)
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t ipw_devclass;
|
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
DRIVER_MODULE(ipw, pci, ipw_driver, ipw_devclass, NULL, NULL);
|
2018-07-08 20:40:23 +00:00
|
|
|
MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, ipw, ipw_ident_table,
|
Reapply, with minor tweaks, r338025, from the original commit:
Remove unused and easy to misuse PNP macro parameter
Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely. The 'table' parameter is now required to
have correct pointer (or array) type. Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.
Mostly done with the coccinelle 'spatch' tool:
$ cat modpnpsize0.cocci
@normaltables@
identifier b,c;
expression a,d,e;
declarer MODULE_PNP_INFO;
@@
MODULE_PNP_INFO(a,b,c,d,
-sizeof(d[0]),
e);
@singletons@
identifier b,c,d;
expression a;
declarer MODULE_PNP_INFO;
@@
MODULE_PNP_INFO(a,b,c,&d,
-sizeof(d),
1);
$ rg -l MODULE_PNP_INFO -- sys | \
xargs spatch --in-place --sp-file modpnpsize0.cocci
(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not. So I had to link gdiff into
PATH as diff to use spatch.)
Tinderbox'd (-DMAKE_JUST_KERNELS).
Approved by: re (glen)
2018-09-26 17:12:14 +00:00
|
|
|
nitems(ipw_ident_table) - 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2011-05-31 19:08:25 +00:00
|
|
|
MODULE_VERSION(ipw, 1);
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static int
|
|
|
|
ipw_probe(device_t dev)
|
|
|
|
{
|
|
|
|
const struct ipw_ident *ident;
|
|
|
|
|
|
|
|
for (ident = ipw_ident_table; ident->name != NULL; ident++) {
|
|
|
|
if (pci_get_vendor(dev) == ident->vendor &&
|
|
|
|
pci_get_device(dev) == ident->device) {
|
|
|
|
device_set_desc(dev, ident->name);
|
2013-12-29 22:56:05 +00:00
|
|
|
return (BUS_PROBE_DEFAULT);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Base Address Register */
|
|
|
|
static int
|
|
|
|
ipw_attach(device_t dev)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = device_get_softc(dev);
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t val;
|
|
|
|
int error, i;
|
|
|
|
|
|
|
|
sc->sc_dev = dev;
|
|
|
|
|
|
|
|
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
|
|
|
MTX_DEF | MTX_RECURSE);
|
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
|
|
|
mbufq_init(&sc->sc_snd, ifqmaxlen);
|
2006-03-12 19:01:00 +00:00
|
|
|
TASK_INIT(&sc->sc_init_task, 0, ipw_init_task, sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2005-05-22 18:31:08 +00:00
|
|
|
pci_write_config(dev, 0x41, 0, 1);
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/* enable bus-mastering */
|
|
|
|
pci_enable_busmaster(dev);
|
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
i = PCIR_BAR(0);
|
|
|
|
sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, RF_ACTIVE);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (sc->mem == NULL) {
|
|
|
|
device_printf(dev, "could not allocate memory resource\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_st = rman_get_bustag(sc->mem);
|
|
|
|
sc->sc_sh = rman_get_bushandle(sc->mem);
|
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
i = 0;
|
|
|
|
sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i,
|
2005-04-18 18:47:38 +00:00
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
|
|
|
if (sc->irq == NULL) {
|
|
|
|
device_printf(dev, "could not allocate interrupt resource\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail1;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ipw_reset(sc) != 0) {
|
|
|
|
device_printf(dev, "could not reset adapter\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail2;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ipw_dma_alloc(sc) != 0) {
|
|
|
|
device_printf(dev, "could not allocate DMA resources\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail2;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2005-07-03 15:42:18 +00:00
|
|
|
|
2015-05-25 18:50:26 +00:00
|
|
|
ic->ic_softc = sc;
|
2015-05-25 13:51:13 +00:00
|
|
|
ic->ic_name = device_get_nameunit(dev);
|
2005-04-18 18:47:38 +00:00
|
|
|
ic->ic_opmode = IEEE80211_M_STA;
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_phytype = IEEE80211_T_DS;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* set device capabilities */
|
2008-05-12 00:15:30 +00:00
|
|
|
ic->ic_caps =
|
|
|
|
IEEE80211_C_STA /* station mode supported */
|
|
|
|
| IEEE80211_C_IBSS /* IBSS mode supported */
|
2007-10-12 05:23:00 +00:00
|
|
|
| IEEE80211_C_MONITOR /* monitor mode supported */
|
|
|
|
| IEEE80211_C_PMGT /* power save supported */
|
|
|
|
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
|
|
|
|
| IEEE80211_C_WPA /* 802.11i supported */
|
|
|
|
;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* read MAC address from EEPROM */
|
|
|
|
val = ipw_read_prom_word(sc, IPW_EEPROM_MAC + 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->ic_macaddr[0] = val >> 8;
|
|
|
|
ic->ic_macaddr[1] = val & 0xff;
|
2005-04-18 18:47:38 +00:00
|
|
|
val = ipw_read_prom_word(sc, IPW_EEPROM_MAC + 1);
|
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->ic_macaddr[2] = val >> 8;
|
|
|
|
ic->ic_macaddr[3] = val & 0xff;
|
2005-04-18 18:47:38 +00:00
|
|
|
val = ipw_read_prom_word(sc, IPW_EEPROM_MAC + 2);
|
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->ic_macaddr[4] = val >> 8;
|
|
|
|
ic->ic_macaddr[5] = val & 0xff;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2016-05-19 22:19:35 +00:00
|
|
|
sc->chanmask = ipw_read_chanmask(sc);
|
|
|
|
ipw_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
|
|
|
|
ic->ic_channels);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* check support for radio transmitter switch in EEPROM */
|
|
|
|
if (!(ipw_read_prom_word(sc, IPW_EEPROM_RADIO) & 8))
|
|
|
|
sc->flags |= IPW_FLAG_HAS_RADIO_SWITCH;
|
|
|
|
|
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_ifattach(ic);
|
2007-10-12 05:23:00 +00:00
|
|
|
ic->ic_scan_start = ipw_scan_start;
|
|
|
|
ic->ic_scan_end = ipw_scan_end;
|
2016-05-19 22:19:35 +00:00
|
|
|
ic->ic_getradiocaps = ipw_getradiocaps;
|
2007-10-12 05:23:00 +00:00
|
|
|
ic->ic_set_channel = ipw_set_channel;
|
|
|
|
ic->ic_scan_curchan = ipw_scan_curchan;
|
|
|
|
ic->ic_scan_mindwell = ipw_scan_mindwell;
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_raw_xmit = ipw_raw_xmit;
|
|
|
|
ic->ic_vap_create = ipw_vap_create;
|
|
|
|
ic->ic_vap_delete = ipw_vap_delete;
|
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->ic_transmit = ipw_transmit;
|
|
|
|
ic->ic_parent = ipw_parent;
|
2008-04-20 20:35:46 +00:00
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_attach(ic,
|
|
|
|
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
|
|
|
|
IPW_TX_RADIOTAP_PRESENT,
|
|
|
|
&sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
|
|
|
|
IPW_RX_RADIOTAP_PRESENT);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a few sysctl knobs.
|
|
|
|
*/
|
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "radio",
|
|
|
|
CTLTYPE_INT | CTLFLAG_RD, sc, 0, ipw_sysctl_radio, "I",
|
|
|
|
"radio transmitter switch state (0=off, 1=on)");
|
|
|
|
|
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "stats",
|
|
|
|
CTLTYPE_OPAQUE | CTLFLAG_RD, sc, 0, ipw_sysctl_stats, "S",
|
|
|
|
"statistics");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hook our interrupt after all initialization is complete.
|
|
|
|
*/
|
|
|
|
error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
|
2007-02-23 12:19:07 +00:00
|
|
|
NULL, ipw_intr, sc, &sc->sc_ih);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(dev, "could not set up interrupt\n");
|
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
|
|
|
goto fail3;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
ieee80211_announce(ic);
|
|
|
|
|
|
|
|
return 0;
|
2008-04-20 20:35:46 +00:00
|
|
|
fail3:
|
|
|
|
ipw_release(sc);
|
|
|
|
fail2:
|
2013-12-29 22:56:05 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), sc->irq);
|
2008-04-20 20:35:46 +00:00
|
|
|
fail1:
|
2013-12-29 22:56:05 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->mem),
|
|
|
|
sc->mem);
|
2008-04-20 20:35:46 +00:00
|
|
|
fail:
|
|
|
|
mtx_destroy(&sc->sc_mtx);
|
2005-04-18 18:47:38 +00:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = device_get_softc(dev);
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
bus_teardown_intr(dev, sc->irq, sc->sc_ih);
|
|
|
|
|
2009-05-08 13:44:33 +00:00
|
|
|
ieee80211_draintask(ic, &sc->sc_init_task);
|
2005-04-18 18:47:38 +00:00
|
|
|
ipw_stop(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
ieee80211_ifdetach(ic);
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
callout_drain(&sc->sc_wdtimer);
|
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
|
|
|
mbufq_drain(&sc->sc_snd);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
ipw_release(sc);
|
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), sc->irq);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2013-12-29 22:56:05 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->mem),
|
|
|
|
sc->mem);
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2006-06-10 17:29:40 +00:00
|
|
|
if (sc->sc_firmware != NULL) {
|
|
|
|
firmware_put(sc->sc_firmware, FIRMWARE_UNLOAD);
|
|
|
|
sc->sc_firmware = NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
mtx_destroy(&sc->sc_mtx);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static struct ieee80211vap *
|
2011-12-17 10:23:17 +00:00
|
|
|
ipw_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|
|
|
enum ieee80211_opmode opmode, int flags,
|
|
|
|
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
|
|
|
const uint8_t mac[IEEE80211_ADDR_LEN])
|
2008-04-20 20:35:46 +00:00
|
|
|
{
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ipw_vap *ivp;
|
|
|
|
struct ieee80211vap *vap;
|
|
|
|
const struct firmware *fp;
|
|
|
|
const struct ipw_firmware_hdr *hdr;
|
|
|
|
const char *imagename;
|
|
|
|
|
|
|
|
if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
switch (opmode) {
|
|
|
|
case IEEE80211_M_STA:
|
|
|
|
imagename = "ipw_bss";
|
|
|
|
break;
|
|
|
|
case IEEE80211_M_IBSS:
|
|
|
|
imagename = "ipw_ibss";
|
|
|
|
break;
|
|
|
|
case IEEE80211_M_MONITOR:
|
|
|
|
imagename = "ipw_monitor";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load firmware image using the firmware(9) subsystem. Doing
|
|
|
|
* this unlocked is ok since we're single-threaded by the
|
|
|
|
* 802.11 layer.
|
|
|
|
*/
|
|
|
|
if (sc->sc_firmware == NULL ||
|
|
|
|
strcmp(sc->sc_firmware->name, imagename) != 0) {
|
|
|
|
if (sc->sc_firmware != NULL)
|
|
|
|
firmware_put(sc->sc_firmware, FIRMWARE_UNLOAD);
|
|
|
|
sc->sc_firmware = firmware_get(imagename);
|
|
|
|
}
|
|
|
|
if (sc->sc_firmware == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not load firmware image '%s'\n", imagename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
fp = sc->sc_firmware;
|
|
|
|
if (fp->datasize < sizeof *hdr) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"firmware image too short %zu\n", fp->datasize);
|
|
|
|
firmware_put(sc->sc_firmware, FIRMWARE_UNLOAD);
|
|
|
|
sc->sc_firmware = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
hdr = (const struct ipw_firmware_hdr *)fp->data;
|
|
|
|
if (fp->datasize < sizeof *hdr + le32toh(hdr->mainsz) +
|
|
|
|
le32toh(hdr->ucodesz)) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"firmware image too short %zu\n", fp->datasize);
|
|
|
|
firmware_put(sc->sc_firmware, FIRMWARE_UNLOAD);
|
|
|
|
sc->sc_firmware = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
ivp = malloc(sizeof(struct ipw_vap), M_80211_VAP, M_WAITOK | M_ZERO);
|
2008-04-20 20:35:46 +00:00
|
|
|
vap = &ivp->vap;
|
|
|
|
|
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_vap_setup(ic, vap, name, unit, opmode, flags, bssid);
|
2008-04-20 20:35:46 +00:00
|
|
|
/* override with driver methods */
|
|
|
|
ivp->newstate = vap->iv_newstate;
|
|
|
|
vap->iv_newstate = ipw_newstate;
|
|
|
|
|
|
|
|
/* complete setup */
|
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_vap_attach(vap, ieee80211_media_change, ipw_media_status,
|
|
|
|
mac);
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_opmode = opmode;
|
|
|
|
return vap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_vap_delete(struct ieee80211vap *vap)
|
|
|
|
{
|
|
|
|
struct ipw_vap *ivp = IPW_VAP(vap);
|
|
|
|
|
|
|
|
ieee80211_vap_detach(vap);
|
|
|
|
free(ivp, M_80211_VAP);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static int
|
|
|
|
ipw_dma_alloc(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
struct ipw_soft_bd *sbd;
|
|
|
|
struct ipw_soft_hdr *shdr;
|
|
|
|
struct ipw_soft_buf *sbuf;
|
|
|
|
bus_addr_t physaddr;
|
|
|
|
int error, i;
|
|
|
|
|
2012-03-12 18:15:08 +00:00
|
|
|
/*
|
|
|
|
* Allocate parent DMA tag for subsequent allocations.
|
|
|
|
*/
|
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_UNRESTRICTED,
|
|
|
|
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->parent_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create parent DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/*
|
|
|
|
* Allocate and map tx ring.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 4, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, IPW_TBD_SZ, 1, IPW_TBD_SZ, 0, NULL,
|
|
|
|
NULL, &sc->tbd_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create tx ring DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->tbd_dmat, (void **)&sc->tbd_list,
|
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->tbd_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate tx ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->tbd_dmat, sc->tbd_map, sc->tbd_list,
|
|
|
|
IPW_TBD_SZ, ipw_dma_map_addr, &sc->tbd_phys, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map tx ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and map rx ring.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 4, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, IPW_RBD_SZ, 1, IPW_RBD_SZ, 0, NULL,
|
|
|
|
NULL, &sc->rbd_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create rx ring DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->rbd_dmat, (void **)&sc->rbd_list,
|
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->rbd_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate rx ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->rbd_dmat, sc->rbd_map, sc->rbd_list,
|
|
|
|
IPW_RBD_SZ, ipw_dma_map_addr, &sc->rbd_phys, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map rx ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and map status ring.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 4, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, IPW_STATUS_SZ, 1, IPW_STATUS_SZ, 0,
|
|
|
|
NULL, NULL, &sc->status_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not create status ring DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->status_dmat, (void **)&sc->status_list,
|
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->status_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate status ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->status_dmat, sc->status_map,
|
|
|
|
sc->status_list, IPW_STATUS_SZ, ipw_dma_map_addr, &sc->status_phys,
|
|
|
|
0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not map status ring DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate command DMA map.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, sizeof (struct ipw_cmd), 1,
|
|
|
|
sizeof (struct ipw_cmd), 0, NULL, NULL, &sc->cmd_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create command DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_create(sc->cmd_dmat, 0, &sc->cmd_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not create command DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate headers DMA maps.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, sizeof (struct ipw_hdr), 1,
|
|
|
|
sizeof (struct ipw_hdr), 0, NULL, NULL, &sc->hdr_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create header DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SLIST_INIT(&sc->free_shdr);
|
|
|
|
for (i = 0; i < IPW_NDATA; i++) {
|
|
|
|
shdr = &sc->shdr_list[i];
|
|
|
|
error = bus_dmamap_create(sc->hdr_dmat, 0, &shdr->map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not create header DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
SLIST_INSERT_HEAD(&sc->free_shdr, shdr, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate tx buffers DMA maps.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-04-18 18:47:38 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, IPW_MAX_NSEG, MCLBYTES, 0,
|
|
|
|
NULL, NULL, &sc->txbuf_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create tx DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SLIST_INIT(&sc->free_sbuf);
|
|
|
|
for (i = 0; i < IPW_NDATA; i++) {
|
|
|
|
sbuf = &sc->tx_sbuf_list[i];
|
|
|
|
error = bus_dmamap_create(sc->txbuf_dmat, 0, &sbuf->map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not create tx DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
SLIST_INSERT_HEAD(&sc->free_sbuf, sbuf, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize tx ring.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < IPW_NTBD; i++) {
|
|
|
|
sbd = &sc->stbd_list[i];
|
|
|
|
sbd->bd = &sc->tbd_list[i];
|
|
|
|
sbd->type = IPW_SBD_TYPE_NOASSOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pre-allocate rx buffers and DMA maps.
|
|
|
|
*/
|
2012-03-12 18:15:08 +00:00
|
|
|
error = bus_dma_tag_create(sc->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
2005-07-08 19:30:29 +00:00
|
|
|
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, 0, NULL,
|
|
|
|
NULL, &sc->rxbuf_dmat);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create rx DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < IPW_NRBD; i++) {
|
|
|
|
sbd = &sc->srbd_list[i];
|
|
|
|
sbuf = &sc->rx_sbuf_list[i];
|
|
|
|
sbd->bd = &sc->rbd_list[i];
|
|
|
|
|
2012-12-04 09:32:43 +00:00
|
|
|
sbuf->m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (sbuf->m == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate rx mbuf\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_create(sc->rxbuf_dmat, 0, &sbuf->map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not create rx DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->rxbuf_dmat, sbuf->map,
|
|
|
|
mtod(sbuf->m, void *), MCLBYTES, ipw_dma_map_addr,
|
|
|
|
&physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not map rx DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbd->type = IPW_SBD_TYPE_DATA;
|
|
|
|
sbd->priv = sbuf;
|
|
|
|
sbd->bd->physaddr = htole32(physaddr);
|
|
|
|
sbd->bd->len = htole32(MCLBYTES);
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rbd_dmat, sc->rbd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail: ipw_release(sc);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_release(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
struct ipw_soft_buf *sbuf;
|
|
|
|
int i;
|
|
|
|
|
2012-03-12 18:15:08 +00:00
|
|
|
if (sc->parent_dmat != NULL) {
|
|
|
|
bus_dma_tag_destroy(sc->parent_dmat);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
if (sc->tbd_dmat != NULL) {
|
2015-05-25 14:12:50 +00:00
|
|
|
bus_dmamap_unload(sc->tbd_dmat, sc->tbd_map);
|
|
|
|
bus_dmamem_free(sc->tbd_dmat, sc->tbd_list, sc->tbd_map);
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_dma_tag_destroy(sc->tbd_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->rbd_dmat != NULL) {
|
|
|
|
if (sc->rbd_list != NULL) {
|
|
|
|
bus_dmamap_unload(sc->rbd_dmat, sc->rbd_map);
|
|
|
|
bus_dmamem_free(sc->rbd_dmat, sc->rbd_list,
|
|
|
|
sc->rbd_map);
|
|
|
|
}
|
|
|
|
bus_dma_tag_destroy(sc->rbd_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->status_dmat != NULL) {
|
|
|
|
if (sc->status_list != NULL) {
|
|
|
|
bus_dmamap_unload(sc->status_dmat, sc->status_map);
|
|
|
|
bus_dmamem_free(sc->status_dmat, sc->status_list,
|
|
|
|
sc->status_map);
|
|
|
|
}
|
|
|
|
bus_dma_tag_destroy(sc->status_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < IPW_NTBD; i++)
|
|
|
|
ipw_release_sbd(sc, &sc->stbd_list[i]);
|
|
|
|
|
|
|
|
if (sc->cmd_dmat != NULL) {
|
|
|
|
bus_dmamap_destroy(sc->cmd_dmat, sc->cmd_map);
|
|
|
|
bus_dma_tag_destroy(sc->cmd_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->hdr_dmat != NULL) {
|
|
|
|
for (i = 0; i < IPW_NDATA; i++)
|
|
|
|
bus_dmamap_destroy(sc->hdr_dmat, sc->shdr_list[i].map);
|
|
|
|
bus_dma_tag_destroy(sc->hdr_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->txbuf_dmat != NULL) {
|
|
|
|
for (i = 0; i < IPW_NDATA; i++) {
|
|
|
|
bus_dmamap_destroy(sc->txbuf_dmat,
|
|
|
|
sc->tx_sbuf_list[i].map);
|
|
|
|
}
|
|
|
|
bus_dma_tag_destroy(sc->txbuf_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->rxbuf_dmat != NULL) {
|
|
|
|
for (i = 0; i < IPW_NRBD; i++) {
|
|
|
|
sbuf = &sc->rx_sbuf_list[i];
|
|
|
|
if (sbuf->m != NULL) {
|
|
|
|
bus_dmamap_sync(sc->rxbuf_dmat, sbuf->map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
bus_dmamap_unload(sc->rxbuf_dmat, sbuf->map);
|
|
|
|
m_freem(sbuf->m);
|
|
|
|
}
|
|
|
|
bus_dmamap_destroy(sc->rxbuf_dmat, sbuf->map);
|
|
|
|
}
|
|
|
|
bus_dma_tag_destroy(sc->rxbuf_dmat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_shutdown(device_t dev)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
ipw_stop(sc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = device_get_softc(dev);
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2012-03-23 19:32:30 +00:00
|
|
|
ieee80211_suspend_all(ic);
|
2005-04-18 18:47:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = device_get_softc(dev);
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2005-05-22 18:31:08 +00:00
|
|
|
pci_write_config(dev, 0x41, 0, 1);
|
|
|
|
|
2012-03-23 19:32:30 +00:00
|
|
|
ieee80211_resume_all(ic);
|
2005-04-18 18:47:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
static int
|
|
|
|
ipw_cvtrate(int ipwrate)
|
|
|
|
{
|
|
|
|
switch (ipwrate) {
|
|
|
|
case IPW_RATE_DS1: return 2;
|
|
|
|
case IPW_RATE_DS2: return 4;
|
|
|
|
case IPW_RATE_DS5: return 11;
|
|
|
|
case IPW_RATE_DS11: return 22;
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-03-12 19:01:00 +00:00
|
|
|
* The firmware automatically adapts the transmit speed. We report its current
|
|
|
|
* value here.
|
2005-04-18 18:47:38 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr)
|
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ifp->if_softc;
|
|
|
|
struct ieee80211com *ic = vap->iv_ic;
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* read current transmission rate from adapter */
|
2008-04-20 20:35:46 +00:00
|
|
|
vap->iv_bss->ni_txrate = ipw_cvtrate(
|
|
|
|
ipw_read_table1(sc, IPW_INFO_CURRENT_TX_RATE) & 0xf);
|
|
|
|
ieee80211_media_status(ifp, imr);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-04-20 20:35:46 +00:00
|
|
|
ipw_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ipw_vap *ivp = IPW_VAP(vap);
|
|
|
|
struct ieee80211com *ic = vap->iv_ic;
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2009-05-02 15:14:18 +00:00
|
|
|
enum ieee80211_state ostate;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
DPRINTF(("%s: %s -> %s flags 0x%x\n", __func__,
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_state_name[vap->iv_state],
|
2007-10-12 05:23:00 +00:00
|
|
|
ieee80211_state_name[nstate], sc->flags));
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-05-02 15:14:18 +00:00
|
|
|
ostate = vap->iv_state;
|
|
|
|
IEEE80211_UNLOCK(ic);
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
switch (nstate) {
|
|
|
|
case IEEE80211_S_RUN:
|
2007-10-12 05:23:00 +00:00
|
|
|
if (ic->ic_opmode == IEEE80211_M_IBSS) {
|
|
|
|
/*
|
|
|
|
* XXX when joining an ibss network we are called
|
|
|
|
* with a SCAN -> RUN transition on scan complete.
|
2010-04-17 18:13:52 +00:00
|
|
|
* Use that to call ipw_assoc. On completing the
|
|
|
|
* join we are then called again with an AUTH -> RUN
|
|
|
|
* transition and we want to do nothing. This is
|
|
|
|
* all totally bogus and needs to be redone.
|
2007-10-12 05:23:00 +00:00
|
|
|
*/
|
2009-05-02 15:14:18 +00:00
|
|
|
if (ostate == IEEE80211_S_SCAN)
|
|
|
|
ipw_assoc(ic, vap);
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE80211_S_INIT:
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->flags & IPW_FLAG_ASSOCIATED)
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_disassoc(ic, vap);
|
2007-10-12 05:23:00 +00:00
|
|
|
break;
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
case IEEE80211_S_AUTH:
|
2010-04-17 18:16:14 +00:00
|
|
|
/*
|
|
|
|
* Move to ASSOC state after the ipw_assoc() call. Firmware
|
|
|
|
* takes care of authentication, after the call we'll receive
|
|
|
|
* only an assoc response which would otherwise be discared
|
|
|
|
* if we are still in AUTH state.
|
|
|
|
*/
|
|
|
|
nstate = IEEE80211_S_ASSOC;
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_assoc(ic, vap);
|
|
|
|
break;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
case IEEE80211_S_ASSOC:
|
2007-10-12 05:23:00 +00:00
|
|
|
/*
|
2010-04-17 18:13:52 +00:00
|
|
|
* If we are not transitioning from AUTH then resend the
|
2007-10-12 05:23:00 +00:00
|
|
|
* association request.
|
|
|
|
*/
|
2009-05-02 15:14:18 +00:00
|
|
|
if (ostate != IEEE80211_S_AUTH)
|
|
|
|
ipw_assoc(ic, vap);
|
2007-10-12 05:23:00 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-05 21:31:32 +00:00
|
|
|
default:
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-05-02 15:14:18 +00:00
|
|
|
IEEE80211_LOCK(ic);
|
2008-04-20 20:35:46 +00:00
|
|
|
return ivp->newstate(vap, nstate, arg);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read 16 bits at address 'addr' from the serial EEPROM.
|
|
|
|
*/
|
|
|
|
static uint16_t
|
|
|
|
ipw_read_prom_word(struct ipw_softc *sc, uint8_t addr)
|
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
uint16_t val;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* clock C once before the first command */
|
|
|
|
IPW_EEPROM_CTL(sc, 0);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_C);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
|
|
|
|
/* write start bit (1) */
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_D);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_D | IPW_EEPROM_C);
|
|
|
|
|
|
|
|
/* write READ opcode (10) */
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_D);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_D | IPW_EEPROM_C);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_C);
|
|
|
|
|
|
|
|
/* write address A7-A0 */
|
|
|
|
for (n = 7; n >= 0; n--) {
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S |
|
|
|
|
(((addr >> n) & 1) << IPW_EEPROM_SHIFT_D));
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S |
|
|
|
|
(((addr >> n) & 1) << IPW_EEPROM_SHIFT_D) | IPW_EEPROM_C);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
|
|
|
|
/* read data Q15-Q0 */
|
|
|
|
val = 0;
|
|
|
|
for (n = 15; n >= 0; n--) {
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S | IPW_EEPROM_C);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
tmp = MEM_READ_4(sc, IPW_MEM_EEPROM_CTL);
|
|
|
|
val |= ((tmp & IPW_EEPROM_Q) >> IPW_EEPROM_SHIFT_Q) << n;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPW_EEPROM_CTL(sc, 0);
|
|
|
|
|
|
|
|
/* clear Chip Select and clock C */
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_S);
|
|
|
|
IPW_EEPROM_CTL(sc, 0);
|
|
|
|
IPW_EEPROM_CTL(sc, IPW_EEPROM_C);
|
|
|
|
|
|
|
|
return le16toh(val);
|
|
|
|
}
|
|
|
|
|
2016-05-19 22:19:35 +00:00
|
|
|
static uint16_t
|
|
|
|
ipw_read_chanmask(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
uint16_t val;
|
|
|
|
|
|
|
|
/* set supported .11b channels (read from EEPROM) */
|
|
|
|
if ((val = ipw_read_prom_word(sc, IPW_EEPROM_CHANNEL_LIST)) == 0)
|
|
|
|
val = 0x7ff; /* default to channels 1-11 */
|
|
|
|
val <<= 1;
|
|
|
|
|
|
|
|
return (val);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_cmd_intr(struct ipw_softc *sc, struct ipw_soft_buf *sbuf)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
struct ipw_cmd *cmd;
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxbuf_dmat, sbuf->map, BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
cmd = mtod(sbuf->m, struct ipw_cmd *);
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(9, ("cmd ack'ed %s(%u, %u, %u, %u, %u)\n",
|
|
|
|
ipw_cmdname(le32toh(cmd->type)), le32toh(cmd->type),
|
2005-04-18 18:47:38 +00:00
|
|
|
le32toh(cmd->subtype), le32toh(cmd->seq), le32toh(cmd->len),
|
|
|
|
le32toh(cmd->status)));
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
sc->flags &= ~IPW_FLAG_BUSY;
|
2005-04-18 18:47:38 +00:00
|
|
|
wakeup(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_newstate_intr(struct ipw_softc *sc, struct ipw_soft_buf *sbuf)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
#define IEEESTATE(vap) ieee80211_state_name[vap->iv_state]
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t state;
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxbuf_dmat, sbuf->map, BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
state = le32toh(*mtod(sbuf->m, uint32_t *));
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case IPW_STATE_ASSOCIATED:
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(2, ("Association succeeded (%s flags 0x%x)\n",
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEESTATE(vap), sc->flags));
|
2007-10-12 05:23:00 +00:00
|
|
|
/* XXX suppress state change in case the fw auto-associates */
|
2008-04-20 20:35:46 +00:00
|
|
|
if ((sc->flags & IPW_FLAG_ASSOCIATING) == 0) {
|
|
|
|
DPRINTF(("Unexpected association (%s, flags 0x%x)\n",
|
|
|
|
IEEESTATE(vap), sc->flags));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->flags &= ~IPW_FLAG_ASSOCIATING;
|
|
|
|
sc->flags |= IPW_FLAG_ASSOCIATED;
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATE_SCANNING:
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(3, ("Scanning (%s flags 0x%x)\n",
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEESTATE(vap), sc->flags));
|
2007-10-12 05:23:00 +00:00
|
|
|
/*
|
|
|
|
* NB: Check driver state for association on assoc
|
|
|
|
* loss as the firmware will immediately start to
|
|
|
|
* scan and we would treat it as a beacon miss if
|
|
|
|
* we checked the 802.11 layer state.
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
if (sc->flags & IPW_FLAG_ASSOCIATED) {
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX probably need to issue disassoc to fw */
|
2009-05-02 15:14:18 +00:00
|
|
|
ieee80211_beacon_miss(ic);
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_LOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATE_SCAN_COMPLETE:
|
2007-10-12 05:23:00 +00:00
|
|
|
/*
|
|
|
|
* XXX For some reason scan requests generate scan
|
|
|
|
* started + scan done events before any traffic is
|
|
|
|
* received (e.g. probe response frames). We work
|
|
|
|
* around this by marking the HACK flag and skipping
|
|
|
|
* the first scan complete event.
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(3, ("Scan complete (%s flags 0x%x)\n",
|
|
|
|
IEEESTATE(vap), sc->flags));
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->flags & IPW_FLAG_HACK) {
|
|
|
|
sc->flags &= ~IPW_FLAG_HACK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sc->flags & IPW_FLAG_SCANNING) {
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2009-05-02 15:14:18 +00:00
|
|
|
ieee80211_scan_done(vap);
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_LOCK(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
sc->flags &= ~IPW_FLAG_SCANNING;
|
|
|
|
sc->sc_scan_timer = 0;
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATE_ASSOCIATION_LOST:
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(2, ("Association lost (%s flags 0x%x)\n",
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEESTATE(vap), sc->flags));
|
|
|
|
sc->flags &= ~(IPW_FLAG_ASSOCIATING | IPW_FLAG_ASSOCIATED);
|
2010-04-17 18:18:46 +00:00
|
|
|
if (vap->iv_state == IEEE80211_S_RUN) {
|
|
|
|
IPW_UNLOCK(sc);
|
2009-05-02 15:14:18 +00:00
|
|
|
ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_LOCK(sc);
|
|
|
|
}
|
2007-10-12 05:23:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATE_DISABLED:
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX? is this right? */
|
2010-04-17 18:13:52 +00:00
|
|
|
sc->flags &= ~(IPW_FLAG_HACK | IPW_FLAG_SCANNING |
|
2008-04-20 20:35:46 +00:00
|
|
|
IPW_FLAG_ASSOCIATING | IPW_FLAG_ASSOCIATED);
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(2, ("Firmware disabled (%s flags 0x%x)\n",
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEESTATE(vap), sc->flags));
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATE_RADIO_DISABLED:
|
2008-04-20 20:35:46 +00:00
|
|
|
device_printf(sc->sc_dev, "radio turned off\n");
|
|
|
|
ieee80211_notify_radio(ic, 0);
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_stop_locked(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX start polling thread to detect radio on */
|
2007-10-12 05:23:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DPRINTFN(2, ("%s: unhandled state %u %s flags 0x%x\n",
|
2008-04-20 20:35:46 +00:00
|
|
|
__func__, state, IEEESTATE(vap), sc->flags));
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-10-12 05:23:00 +00:00
|
|
|
#undef IEEESTATE
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set driver state for current channel.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ipw_setcurchan(struct ipw_softc *sc, struct ieee80211_channel *chan)
|
|
|
|
{
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
ic->ic_curchan = chan;
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_chan_change(ic);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: Hack to set the current channel to the value advertised in beacons or
|
|
|
|
* probe responses. Only used during AP detection.
|
|
|
|
*/
|
|
|
|
static void
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_fix_channel(struct ipw_softc *sc, struct mbuf *m)
|
2005-04-18 18:47: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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2007-10-12 05:23:00 +00:00
|
|
|
struct ieee80211_channel *c;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_frame *wh;
|
|
|
|
uint8_t subtype;
|
|
|
|
uint8_t *frm, *efrm;
|
|
|
|
|
|
|
|
wh = mtod(m, struct ieee80211_frame *);
|
|
|
|
|
|
|
|
if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_MGT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
|
|
|
|
|
|
|
|
if (subtype != IEEE80211_FC0_SUBTYPE_BEACON &&
|
|
|
|
subtype != IEEE80211_FC0_SUBTYPE_PROBE_RESP)
|
|
|
|
return;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX use ieee80211_parse_beacon */
|
2005-04-18 18:47:38 +00:00
|
|
|
frm = (uint8_t *)(wh + 1);
|
|
|
|
efrm = mtod(m, uint8_t *) + m->m_len;
|
|
|
|
|
|
|
|
frm += 12; /* skip tstamp, bintval and capinfo fields */
|
|
|
|
while (frm < efrm) {
|
|
|
|
if (*frm == IEEE80211_ELEMID_DSPARMS)
|
|
|
|
#if IEEE80211_CHAN_MAX < 255
|
|
|
|
if (frm[2] <= IEEE80211_CHAN_MAX)
|
|
|
|
#endif
|
2007-10-12 05:23:00 +00:00
|
|
|
{
|
|
|
|
DPRINTF(("Fixing channel to %d\n", frm[2]));
|
|
|
|
c = ieee80211_find_channel(ic,
|
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_ieee2mhz(frm[2], 0),
|
2007-10-12 05:23:00 +00:00
|
|
|
IEEE80211_CHAN_B);
|
|
|
|
if (c == NULL)
|
|
|
|
c = &ic->ic_channels[0];
|
|
|
|
ipw_setcurchan(sc, c);
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
frm += frm[1] + 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_data_intr(struct ipw_softc *sc, struct ipw_status *status,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ipw_soft_bd *sbd, struct ipw_soft_buf *sbuf)
|
|
|
|
{
|
2020-01-30 10:28:01 +00:00
|
|
|
struct epoch_tracker et;
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-11-13 17:17:40 +00:00
|
|
|
struct mbuf *mnew, *m;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_node *ni;
|
|
|
|
bus_addr_t physaddr;
|
|
|
|
int error;
|
2009-05-20 20:00:40 +00:00
|
|
|
int8_t rssi, nf;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2005-11-13 17:17:40 +00:00
|
|
|
DPRINTFN(5, ("received frame len=%u, rssi=%u\n", le32toh(status->len),
|
|
|
|
status->rssi));
|
|
|
|
|
2005-07-03 15:42:18 +00:00
|
|
|
if (le32toh(status->len) < sizeof (struct ieee80211_frame_min) ||
|
|
|
|
le32toh(status->len) > MCLBYTES)
|
|
|
|
return;
|
|
|
|
|
2005-11-13 17:17:40 +00:00
|
|
|
/*
|
|
|
|
* Try to allocate a new mbuf for this ring element and load it before
|
|
|
|
* processing the current mbuf. If the ring element cannot be loaded,
|
|
|
|
* drop the received packet and reuse the old mbuf. In the unlikely
|
|
|
|
* case that the old mbuf can't be reloaded either, explicitly panic.
|
|
|
|
*/
|
2012-12-04 09:32:43 +00:00
|
|
|
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
2005-11-13 17:17:40 +00:00
|
|
|
if (mnew == NULL) {
|
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
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-11-13 17:17:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_dmamap_sync(sc->rxbuf_dmat, sbuf->map, BUS_DMASYNC_POSTREAD);
|
|
|
|
bus_dmamap_unload(sc->rxbuf_dmat, sbuf->map);
|
|
|
|
|
2005-11-13 17:17:40 +00:00
|
|
|
error = bus_dmamap_load(sc->rxbuf_dmat, sbuf->map, mtod(mnew, void *),
|
|
|
|
MCLBYTES, ipw_dma_map_addr, &physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
m_freem(mnew);
|
|
|
|
|
|
|
|
/* try to reload the old mbuf */
|
|
|
|
error = bus_dmamap_load(sc->rxbuf_dmat, sbuf->map,
|
|
|
|
mtod(sbuf->m, void *), MCLBYTES, ipw_dma_map_addr,
|
|
|
|
&physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
/* very unlikely that it will fail... */
|
|
|
|
panic("%s: could not load old rx mbuf",
|
|
|
|
device_get_name(sc->sc_dev));
|
|
|
|
}
|
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
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-11-13 17:17:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New mbuf successfully loaded, update Rx ring and continue
|
|
|
|
* processing.
|
|
|
|
*/
|
2005-04-18 18:47:38 +00:00
|
|
|
m = sbuf->m;
|
2005-11-13 17:17:40 +00:00
|
|
|
sbuf->m = mnew;
|
|
|
|
sbd->bd->physaddr = htole32(physaddr);
|
2005-04-18 18:47:38 +00:00
|
|
|
m->m_pkthdr.len = m->m_len = le32toh(status->len);
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
rssi = status->rssi + IPW_RSSI_TO_DBM;
|
|
|
|
nf = -95;
|
|
|
|
if (ieee80211_radiotap_active(ic)) {
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ipw_rx_radiotap_header *tap = &sc->sc_rxtap;
|
|
|
|
|
|
|
|
tap->wr_flags = 0;
|
2009-05-20 20:00:40 +00:00
|
|
|
tap->wr_antsignal = rssi;
|
|
|
|
tap->wr_antnoise = nf;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->flags & IPW_FLAG_SCANNING)
|
|
|
|
ipw_fix_channel(sc, m);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *));
|
2020-01-30 10:28:01 +00:00
|
|
|
NET_EPOCH_ENTER(et);
|
2008-04-20 20:35:46 +00:00
|
|
|
if (ni != NULL) {
|
2010-04-17 18:14:49 +00:00
|
|
|
(void) ieee80211_input(ni, m, rssi - nf, nf);
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
} else
|
2010-04-17 18:14:49 +00:00
|
|
|
(void) ieee80211_input_all(ic, m, rssi - nf, nf);
|
2020-01-30 10:28:01 +00:00
|
|
|
NET_EPOCH_EXIT(et);
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rbd_dmat, sc->rbd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_rx_intr(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
struct ipw_status *status;
|
|
|
|
struct ipw_soft_bd *sbd;
|
|
|
|
struct ipw_soft_buf *sbuf;
|
|
|
|
uint32_t r, i;
|
|
|
|
|
|
|
|
if (!(sc->flags & IPW_FLAG_FW_INITED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
r = CSR_READ_4(sc, IPW_CSR_RX_READ);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->status_dmat, sc->status_map, BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
for (i = (sc->rxcur + 1) % IPW_NRBD; i != r; i = (i + 1) % IPW_NRBD) {
|
|
|
|
status = &sc->status_list[i];
|
|
|
|
sbd = &sc->srbd_list[i];
|
|
|
|
sbuf = sbd->priv;
|
|
|
|
|
|
|
|
switch (le16toh(status->code) & 0xf) {
|
|
|
|
case IPW_STATUS_CODE_COMMAND:
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_cmd_intr(sc, sbuf);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATUS_CODE_NEWSTATE:
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_newstate_intr(sc, sbuf);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATUS_CODE_DATA_802_3:
|
|
|
|
case IPW_STATUS_CODE_DATA_802_11:
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_rx_data_intr(sc, status, sbd, sbuf);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_STATUS_CODE_NOTIFICATION:
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTFN(2, ("notification status, len %u flags 0x%x\n",
|
|
|
|
le32toh(status->len), status->flags));
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX maybe drive state machine AUTH->ASSOC? */
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-10-12 05:23:00 +00:00
|
|
|
device_printf(sc->sc_dev, "unexpected status code %u\n",
|
2005-04-18 18:47:38 +00:00
|
|
|
le16toh(status->code));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* firmware was killed, stop processing received frames */
|
|
|
|
if (!(sc->flags & IPW_FLAG_FW_INITED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sbd->bd->flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rbd_dmat, sc->rbd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
/* kick the firmware */
|
|
|
|
sc->rxcur = (r == 0) ? IPW_NRBD - 1 : r - 1;
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RX_WRITE, sc->rxcur);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_release_sbd(struct ipw_softc *sc, struct ipw_soft_bd *sbd)
|
|
|
|
{
|
|
|
|
struct ipw_soft_hdr *shdr;
|
|
|
|
struct ipw_soft_buf *sbuf;
|
|
|
|
|
|
|
|
switch (sbd->type) {
|
|
|
|
case IPW_SBD_TYPE_COMMAND:
|
|
|
|
bus_dmamap_sync(sc->cmd_dmat, sc->cmd_map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->cmd_dmat, sc->cmd_map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_SBD_TYPE_HEADER:
|
|
|
|
shdr = sbd->priv;
|
|
|
|
bus_dmamap_sync(sc->hdr_dmat, shdr->map, BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->hdr_dmat, shdr->map);
|
|
|
|
SLIST_INSERT_HEAD(&sc->free_shdr, shdr, next);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IPW_SBD_TYPE_DATA:
|
|
|
|
sbuf = sbd->priv;
|
|
|
|
bus_dmamap_sync(sc->txbuf_dmat, sbuf->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->txbuf_dmat, sbuf->map);
|
|
|
|
SLIST_INSERT_HEAD(&sc->free_sbuf, sbuf, next);
|
|
|
|
|
2019-01-31 10:44:00 +00:00
|
|
|
ieee80211_tx_complete(sbuf->ni, sbuf->m, 0/*XXX*/);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->sc_tx_timer = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbd->type = IPW_SBD_TYPE_NOASSOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_tx_intr(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
struct ipw_soft_bd *sbd;
|
|
|
|
uint32_t r, i;
|
|
|
|
|
|
|
|
if (!(sc->flags & IPW_FLAG_FW_INITED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
r = CSR_READ_4(sc, IPW_CSR_TX_READ);
|
|
|
|
|
|
|
|
for (i = (sc->txold + 1) % IPW_NTBD; i != r; i = (i + 1) % IPW_NTBD) {
|
|
|
|
sbd = &sc->stbd_list[i];
|
|
|
|
ipw_release_sbd(sc, sbd);
|
|
|
|
sc->txfree++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remember what the firmware has processed */
|
|
|
|
sc->txold = (r == 0) ? IPW_NTBD - 1 : r - 1;
|
|
|
|
|
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
|
|
|
ipw_start(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-02 15:14:18 +00:00
|
|
|
static void
|
|
|
|
ipw_fatal_error_intr(struct ipw_softc *sc)
|
|
|
|
{
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2009-05-10 02:44:19 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
2009-05-02 15:14:18 +00:00
|
|
|
|
|
|
|
device_printf(sc->sc_dev, "firmware error\n");
|
2010-04-17 18:18:46 +00:00
|
|
|
if (vap != NULL) {
|
|
|
|
IPW_UNLOCK(sc);
|
2009-05-10 02:44:19 +00:00
|
|
|
ieee80211_cancel_scan(vap);
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_LOCK(sc);
|
|
|
|
}
|
2009-05-02 15:14:18 +00:00
|
|
|
ieee80211_runtask(ic, &sc->sc_init_task);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
|
|
|
ipw_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = arg;
|
|
|
|
uint32_t r;
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-05-02 15:14:18 +00:00
|
|
|
r = CSR_READ_4(sc, IPW_CSR_INTR);
|
|
|
|
if (r == 0 || r == 0xffffffff)
|
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* disable interrupts */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INTR_MASK, 0);
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
/* acknowledge all interrupts */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INTR, r);
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
if (r & (IPW_INTR_FATAL_ERROR | IPW_INTR_PARITY_ERROR)) {
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_fatal_error_intr(sc);
|
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
if (r & IPW_INTR_FW_INIT_DONE)
|
|
|
|
wakeup(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (r & IPW_INTR_RX_TRANSFER)
|
|
|
|
ipw_rx_intr(sc);
|
|
|
|
|
|
|
|
if (r & IPW_INTR_TX_TRANSFER)
|
|
|
|
ipw_tx_intr(sc);
|
|
|
|
|
|
|
|
/* re-enable interrupts */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INTR_MASK, IPW_INTR_MASK);
|
2009-05-02 15:14:18 +00:00
|
|
|
done:
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
|
|
|
if (error != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
|
|
|
|
|
|
|
|
*(bus_addr_t *)arg = segs[0].ds_addr;
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
static const char *
|
|
|
|
ipw_cmdname(int cmd)
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
int cmd;
|
|
|
|
const char *name;
|
|
|
|
} cmds[] = {
|
|
|
|
{ IPW_CMD_ADD_MULTICAST, "ADD_MULTICAST" },
|
|
|
|
{ IPW_CMD_BROADCAST_SCAN, "BROADCAST_SCAN" },
|
|
|
|
{ IPW_CMD_DISABLE, "DISABLE" },
|
|
|
|
{ IPW_CMD_DISABLE_PHY, "DISABLE_PHY" },
|
|
|
|
{ IPW_CMD_ENABLE, "ENABLE" },
|
|
|
|
{ IPW_CMD_PREPARE_POWER_DOWN, "PREPARE_POWER_DOWN" },
|
|
|
|
{ IPW_CMD_SET_BASIC_TX_RATES, "SET_BASIC_TX_RATES" },
|
|
|
|
{ IPW_CMD_SET_BEACON_INTERVAL, "SET_BEACON_INTERVAL" },
|
|
|
|
{ IPW_CMD_SET_CHANNEL, "SET_CHANNEL" },
|
|
|
|
{ IPW_CMD_SET_CONFIGURATION, "SET_CONFIGURATION" },
|
|
|
|
{ IPW_CMD_SET_DESIRED_BSSID, "SET_DESIRED_BSSID" },
|
|
|
|
{ IPW_CMD_SET_ESSID, "SET_ESSID" },
|
|
|
|
{ IPW_CMD_SET_FRAG_THRESHOLD, "SET_FRAG_THRESHOLD" },
|
|
|
|
{ IPW_CMD_SET_MAC_ADDRESS, "SET_MAC_ADDRESS" },
|
|
|
|
{ IPW_CMD_SET_MANDATORY_BSSID, "SET_MANDATORY_BSSID" },
|
|
|
|
{ IPW_CMD_SET_MODE, "SET_MODE" },
|
|
|
|
{ IPW_CMD_SET_MSDU_TX_RATES, "SET_MSDU_TX_RATES" },
|
|
|
|
{ IPW_CMD_SET_POWER_MODE, "SET_POWER_MODE" },
|
|
|
|
{ IPW_CMD_SET_RTS_THRESHOLD, "SET_RTS_THRESHOLD" },
|
|
|
|
{ IPW_CMD_SET_SCAN_OPTIONS, "SET_SCAN_OPTIONS" },
|
|
|
|
{ IPW_CMD_SET_SECURITY_INFO, "SET_SECURITY_INFO" },
|
|
|
|
{ IPW_CMD_SET_TX_POWER_INDEX, "SET_TX_POWER_INDEX" },
|
|
|
|
{ IPW_CMD_SET_TX_RATES, "SET_TX_RATES" },
|
|
|
|
{ IPW_CMD_SET_WEP_FLAGS, "SET_WEP_FLAGS" },
|
|
|
|
{ IPW_CMD_SET_WEP_KEY, "SET_WEP_KEY" },
|
|
|
|
{ IPW_CMD_SET_WEP_KEY_INDEX, "SET_WEP_KEY_INDEX" },
|
|
|
|
{ IPW_CMD_SET_WPA_IE, "SET_WPA_IE" },
|
|
|
|
|
|
|
|
};
|
|
|
|
static char buf[12];
|
|
|
|
int i;
|
|
|
|
|
2015-09-22 02:44:59 +00:00
|
|
|
for (i = 0; i < nitems(cmds); i++)
|
2007-10-12 05:23:00 +00:00
|
|
|
if (cmds[i].cmd == cmd)
|
|
|
|
return cmds[i].name;
|
|
|
|
snprintf(buf, sizeof(buf), "%u", cmd);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/*
|
|
|
|
* Send a command to the firmware and wait for the acknowledgement.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ipw_cmd(struct ipw_softc *sc, uint32_t type, void *data, uint32_t len)
|
|
|
|
{
|
|
|
|
struct ipw_soft_bd *sbd;
|
|
|
|
bus_addr_t physaddr;
|
|
|
|
int error;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IPW_LOCK_ASSERT(sc);
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->flags & IPW_FLAG_BUSY) {
|
|
|
|
device_printf(sc->sc_dev, "%s: %s not sent, busy\n",
|
|
|
|
__func__, ipw_cmdname(type));
|
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
sc->flags |= IPW_FLAG_BUSY;
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
sbd = &sc->stbd_list[sc->txcur];
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->cmd_dmat, sc->cmd_map, &sc->cmd,
|
|
|
|
sizeof (struct ipw_cmd), ipw_dma_map_addr, &physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map command DMA memory\n");
|
2007-10-12 05:23:00 +00:00
|
|
|
sc->flags &= ~IPW_FLAG_BUSY;
|
2005-04-18 18:47:38 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->cmd.type = htole32(type);
|
|
|
|
sc->cmd.subtype = 0;
|
|
|
|
sc->cmd.len = htole32(len);
|
|
|
|
sc->cmd.seq = 0;
|
2005-11-20 16:13:00 +00:00
|
|
|
memcpy(sc->cmd.data, data, len);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sbd->type = IPW_SBD_TYPE_COMMAND;
|
|
|
|
sbd->bd->physaddr = htole32(physaddr);
|
|
|
|
sbd->bd->len = htole32(sizeof (struct ipw_cmd));
|
|
|
|
sbd->bd->nfrag = 1;
|
|
|
|
sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_COMMAND |
|
|
|
|
IPW_BD_FLAG_TX_LAST_FRAGMENT;
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->cmd_dmat, sc->cmd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->tbd_dmat, sc->tbd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
#ifdef IPW_DEBUG
|
|
|
|
if (ipw_debug >= 4) {
|
|
|
|
printf("sending %s(%u, %u, %u, %u)", ipw_cmdname(type), type,
|
|
|
|
0, 0, len);
|
|
|
|
/* Print the data buffer in the higher debug level */
|
|
|
|
if (ipw_debug >= 9 && len > 0) {
|
|
|
|
printf(" data: 0x");
|
|
|
|
for (int i = 1; i <= len; i++)
|
2007-12-04 20:33:58 +00:00
|
|
|
printf("%1D", (u_char *)data + len - i, "");
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* kick firmware */
|
|
|
|
sc->txfree--;
|
|
|
|
sc->txcur = (sc->txcur + 1) % IPW_NTBD;
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_WRITE, sc->txcur);
|
|
|
|
|
|
|
|
/* wait at most one second for command to complete */
|
2007-10-12 05:23:00 +00:00
|
|
|
error = msleep(sc, &sc->sc_mtx, 0, "ipwcmd", hz);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "%s: %s failed, timeout (error %u)\n",
|
|
|
|
__func__, ipw_cmdname(type), error);
|
|
|
|
sc->flags &= ~IPW_FLAG_BUSY;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static 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
|
|
|
ipw_tx_start(struct ipw_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
|
2005-04-18 18:47: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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2009-05-20 20:00:40 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_frame *wh;
|
|
|
|
struct ipw_soft_bd *sbd;
|
|
|
|
struct ipw_soft_hdr *shdr;
|
|
|
|
struct ipw_soft_buf *sbuf;
|
|
|
|
struct ieee80211_key *k;
|
|
|
|
struct mbuf *mnew;
|
|
|
|
bus_dma_segment_t segs[IPW_MAX_NSEG];
|
|
|
|
bus_addr_t physaddr;
|
|
|
|
int nsegs, error, i;
|
|
|
|
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
|
2014-01-08 08:06:56 +00:00
|
|
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
2008-04-20 20:35:46 +00:00
|
|
|
k = ieee80211_crypto_encap(ni, m0);
|
2005-07-07 02:55:04 +00:00
|
|
|
if (k == NULL) {
|
|
|
|
m_freem(m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
return ENOBUFS;
|
2005-07-07 02:55:04 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
/* packet header may have moved, reset our local pointer */
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ipw_tx_radiotap_header *tap = &sc->sc_txtap;
|
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_tx(vap, m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shdr = SLIST_FIRST(&sc->free_shdr);
|
|
|
|
sbuf = SLIST_FIRST(&sc->free_sbuf);
|
|
|
|
KASSERT(shdr != NULL && sbuf != NULL, ("empty sw hdr/buf pool"));
|
|
|
|
|
|
|
|
shdr->hdr.type = htole32(IPW_HDR_TYPE_SEND);
|
|
|
|
shdr->hdr.subtype = 0;
|
2014-01-08 08:06:56 +00:00
|
|
|
shdr->hdr.encrypted = (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) ? 1 : 0;
|
2005-04-18 18:47:38 +00:00
|
|
|
shdr->hdr.encrypt = 0;
|
|
|
|
shdr->hdr.keyidx = 0;
|
|
|
|
shdr->hdr.keysz = 0;
|
|
|
|
shdr->hdr.fragmentsz = 0;
|
|
|
|
IEEE80211_ADDR_COPY(shdr->hdr.src_addr, wh->i_addr2);
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_STA)
|
|
|
|
IEEE80211_ADDR_COPY(shdr->hdr.dst_addr, wh->i_addr3);
|
|
|
|
else
|
|
|
|
IEEE80211_ADDR_COPY(shdr->hdr.dst_addr, wh->i_addr1);
|
|
|
|
|
|
|
|
/* trim IEEE802.11 header */
|
|
|
|
m_adj(m0, sizeof (struct ieee80211_frame));
|
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->txbuf_dmat, sbuf->map, m0, segs,
|
|
|
|
&nsegs, 0);
|
|
|
|
if (error != 0 && error != EFBIG) {
|
|
|
|
device_printf(sc->sc_dev, "could not map mbuf (error %d)\n",
|
|
|
|
error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
if (error != 0) {
|
2012-12-04 09:32:43 +00:00
|
|
|
mnew = m_defrag(m0, M_NOWAIT);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (mnew == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not defragment mbuf\n");
|
|
|
|
m_freem(m0);
|
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
m0 = mnew;
|
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->txbuf_dmat, sbuf->map, m0,
|
|
|
|
segs, &nsegs, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not map mbuf (error %d)\n", error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->hdr_dmat, shdr->map, &shdr->hdr,
|
|
|
|
sizeof (struct ipw_hdr), ipw_dma_map_addr, &physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map header DMA memory\n");
|
|
|
|
bus_dmamap_unload(sc->txbuf_dmat, sbuf->map);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SLIST_REMOVE_HEAD(&sc->free_sbuf, next);
|
|
|
|
SLIST_REMOVE_HEAD(&sc->free_shdr, next);
|
|
|
|
|
|
|
|
sbd = &sc->stbd_list[sc->txcur];
|
|
|
|
sbd->type = IPW_SBD_TYPE_HEADER;
|
|
|
|
sbd->priv = shdr;
|
|
|
|
sbd->bd->physaddr = htole32(physaddr);
|
|
|
|
sbd->bd->len = htole32(sizeof (struct ipw_hdr));
|
|
|
|
sbd->bd->nfrag = 1 + nsegs;
|
|
|
|
sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_802_3 |
|
|
|
|
IPW_BD_FLAG_TX_NOT_LAST_FRAGMENT;
|
|
|
|
|
|
|
|
DPRINTFN(5, ("sending tx hdr (%u, %u, %u, %u, %6D, %6D)\n",
|
|
|
|
shdr->hdr.type, shdr->hdr.subtype, shdr->hdr.encrypted,
|
|
|
|
shdr->hdr.encrypt, shdr->hdr.src_addr, ":", shdr->hdr.dst_addr,
|
|
|
|
":"));
|
|
|
|
|
|
|
|
sc->txfree--;
|
|
|
|
sc->txcur = (sc->txcur + 1) % IPW_NTBD;
|
|
|
|
|
|
|
|
sbuf->m = m0;
|
|
|
|
sbuf->ni = ni;
|
|
|
|
|
|
|
|
for (i = 0; i < nsegs; i++) {
|
|
|
|
sbd = &sc->stbd_list[sc->txcur];
|
|
|
|
|
|
|
|
sbd->bd->physaddr = htole32(segs[i].ds_addr);
|
|
|
|
sbd->bd->len = htole32(segs[i].ds_len);
|
|
|
|
sbd->bd->nfrag = 0;
|
|
|
|
sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_802_3;
|
|
|
|
if (i == nsegs - 1) {
|
|
|
|
sbd->type = IPW_SBD_TYPE_DATA;
|
|
|
|
sbd->priv = sbuf;
|
|
|
|
sbd->bd->flags |= IPW_BD_FLAG_TX_LAST_FRAGMENT;
|
|
|
|
} else {
|
|
|
|
sbd->type = IPW_SBD_TYPE_NOASSOC;
|
|
|
|
sbd->bd->flags |= IPW_BD_FLAG_TX_NOT_LAST_FRAGMENT;
|
|
|
|
}
|
|
|
|
|
2007-10-12 10:00:26 +00:00
|
|
|
DPRINTFN(5, ("sending fragment (%d)\n", i));
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->txfree--;
|
|
|
|
sc->txcur = (sc->txcur + 1) % IPW_NTBD;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->hdr_dmat, shdr->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->txbuf_dmat, sbuf->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->tbd_dmat, sc->tbd_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
/* kick firmware */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_WRITE, sc->txcur);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static int
|
|
|
|
ipw_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|
|
|
const struct ieee80211_bpf_params *params)
|
|
|
|
{
|
|
|
|
/* no support; just discard */
|
|
|
|
m_freem(m);
|
|
|
|
ieee80211_free_node(ni);
|
|
|
|
return 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
|
|
|
static int
|
|
|
|
ipw_transmit(struct ieee80211com *ic, struct mbuf *m)
|
2007-10-12 05:23:00 +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
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
|
|
|
int error;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
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
|
|
|
if ((sc->flags & IPW_FLAG_RUNNING) == 0) {
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
error = mbufq_enqueue(&sc->sc_snd, m);
|
|
|
|
if (error) {
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
ipw_start(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_UNLOCK(sc);
|
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 (0);
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
ipw_start(struct ipw_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_node *ni;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct mbuf *m;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK_ASSERT(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2018-10-23 12:53:09 +00:00
|
|
|
while (sc->txfree >= 1 + IPW_MAX_NSEG &&
|
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
|
|
|
(m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
2008-04-20 20:35:46 +00:00
|
|
|
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
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
|
|
|
if (ipw_tx_start(sc, m, ni) != 0) {
|
|
|
|
if_inc_counter(ni->ni_vap->iv_ifp,
|
|
|
|
IFCOUNTER_OERRORS, 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* start watchdog timer */
|
|
|
|
sc->sc_tx_timer = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_watchdog(void *arg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2007-10-12 05:23:00 +00:00
|
|
|
struct ipw_softc *sc = arg;
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK_ASSERT(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (sc->sc_tx_timer > 0) {
|
|
|
|
if (--sc->sc_tx_timer == 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
|
|
|
device_printf(sc->sc_dev, "device timeout\n");
|
|
|
|
counter_u64_add(ic->ic_oerrors, 1);
|
2008-04-20 20:35:46 +00:00
|
|
|
taskqueue_enqueue(taskqueue_swi, &sc->sc_init_task);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->sc_scan_timer > 0) {
|
|
|
|
if (--sc->sc_scan_timer == 0) {
|
|
|
|
DPRINTFN(3, ("Scan timeout\n"));
|
|
|
|
/* End the scan */
|
|
|
|
if (sc->flags & IPW_FLAG_SCANNING) {
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_scan_done(TAILQ_FIRST(&ic->ic_vaps));
|
2010-04-17 18:18:46 +00:00
|
|
|
IPW_LOCK(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
sc->flags &= ~IPW_FLAG_SCANNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
if (sc->flags & IPW_FLAG_RUNNING)
|
2007-10-12 05:23:00 +00:00
|
|
|
callout_reset(&sc->sc_wdtimer, hz, ipw_watchdog, sc);
|
2005-04-18 18:47: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
|
|
|
static void
|
|
|
|
ipw_parent(struct ieee80211com *ic)
|
2005-04-18 18:47: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
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
|
|
|
int startall = 0;
|
2005-04-18 18:47: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
|
|
|
IPW_LOCK(sc);
|
|
|
|
if (ic->ic_nrunning > 0) {
|
|
|
|
if (!(sc->flags & IPW_FLAG_RUNNING)) {
|
|
|
|
ipw_init_locked(sc);
|
|
|
|
startall = 1;
|
2005-04-18 18:47: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
|
|
|
} else if (sc->flags & IPW_FLAG_RUNNING)
|
|
|
|
ipw_stop_locked(sc);
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
if (startall)
|
|
|
|
ieee80211_start_all(ic);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_stop_master(struct ipw_softc *sc)
|
|
|
|
{
|
2006-03-12 19:01:00 +00:00
|
|
|
uint32_t tmp;
|
2005-04-18 18:47:38 +00:00
|
|
|
int ntries;
|
|
|
|
|
|
|
|
/* disable interrupts */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INTR_MASK, 0);
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, IPW_RST_STOP_MASTER);
|
|
|
|
for (ntries = 0; ntries < 50; ntries++) {
|
|
|
|
if (CSR_READ_4(sc, IPW_CSR_RST) & IPW_RST_MASTER_DISABLED)
|
|
|
|
break;
|
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
if (ntries == 50)
|
|
|
|
device_printf(sc->sc_dev, "timeout waiting for master\n");
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_RST);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, tmp | IPW_RST_PRINCETON_RESET);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
/* Clear all flags except the following */
|
|
|
|
sc->flags &= IPW_FLAG_HAS_RADIO_SWITCH;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_reset(struct ipw_softc *sc)
|
|
|
|
{
|
2006-03-12 19:01:00 +00:00
|
|
|
uint32_t tmp;
|
2005-04-18 18:47:38 +00:00
|
|
|
int ntries;
|
|
|
|
|
|
|
|
ipw_stop_master(sc);
|
|
|
|
|
|
|
|
/* move adapter to D0 state */
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_CTL);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_INIT);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* wait for clock stabilization */
|
|
|
|
for (ntries = 0; ntries < 1000; ntries++) {
|
|
|
|
if (CSR_READ_4(sc, IPW_CSR_CTL) & IPW_CTL_CLOCK_READY)
|
|
|
|
break;
|
|
|
|
DELAY(200);
|
|
|
|
}
|
|
|
|
if (ntries == 1000)
|
|
|
|
return EIO;
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_RST);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, tmp | IPW_RST_SW_RESET);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
DELAY(10);
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_CTL);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_INIT);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
static int
|
|
|
|
ipw_waitfordisable(struct ipw_softc *sc, int waitfor)
|
|
|
|
{
|
|
|
|
int ms = hz < 1000 ? 1 : hz/10;
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
if (ipw_read_table1(sc, IPW_INFO_CARD_DISABLED) == waitfor)
|
|
|
|
return 0;
|
|
|
|
error = msleep(sc, &sc->sc_mtx, PCATCH, __func__, ms);
|
|
|
|
if (error == 0 || error != EWOULDBLOCK)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DPRINTF(("%s: timeout waiting for %s\n",
|
|
|
|
__func__, waitfor ? "disable" : "enable"));
|
|
|
|
return ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_enable(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if ((sc->flags & IPW_FLAG_ENABLED) == 0) {
|
|
|
|
DPRINTF(("Enable adapter\n"));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_ENABLE, NULL, 0);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
error = ipw_waitfordisable(sc, 0);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
sc->flags |= IPW_FLAG_ENABLED;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_disable(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (sc->flags & IPW_FLAG_ENABLED) {
|
|
|
|
DPRINTF(("Disable adapter\n"));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_DISABLE, NULL, 0);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
error = ipw_waitfordisable(sc, 1);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
sc->flags &= ~IPW_FLAG_ENABLED;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/*
|
|
|
|
* Upload the microcode to the device.
|
|
|
|
*/
|
|
|
|
static int
|
2006-03-12 19:01:00 +00:00
|
|
|
ipw_load_ucode(struct ipw_softc *sc, const char *uc, int size)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
MEM_WRITE_4(sc, 0x3000e0, 0x80000000);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, 0);
|
|
|
|
|
|
|
|
MEM_WRITE_2(sc, 0x220000, 0x0703);
|
|
|
|
MEM_WRITE_2(sc, 0x220000, 0x0707);
|
|
|
|
|
|
|
|
MEM_WRITE_1(sc, 0x210014, 0x72);
|
|
|
|
MEM_WRITE_1(sc, 0x210014, 0x72);
|
|
|
|
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x40);
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x00);
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x40);
|
|
|
|
|
|
|
|
MEM_WRITE_MULTI_1(sc, 0x210010, uc, size);
|
|
|
|
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x00);
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x00);
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x80);
|
|
|
|
|
|
|
|
MEM_WRITE_2(sc, 0x220000, 0x0703);
|
|
|
|
MEM_WRITE_2(sc, 0x220000, 0x0707);
|
|
|
|
|
|
|
|
MEM_WRITE_1(sc, 0x210014, 0x72);
|
|
|
|
MEM_WRITE_1(sc, 0x210014, 0x72);
|
|
|
|
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x00);
|
|
|
|
MEM_WRITE_1(sc, 0x210000, 0x80);
|
|
|
|
|
|
|
|
for (ntries = 0; ntries < 10; ntries++) {
|
|
|
|
if (MEM_READ_1(sc, 0x210000) & 1)
|
|
|
|
break;
|
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
if (ntries == 10) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"timeout waiting for ucode to initialize\n");
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_WRITE_4(sc, 0x3000e0, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set of macros to handle unaligned little endian data in firmware image */
|
|
|
|
#define GETLE32(p) ((p)[0] | (p)[1] << 8 | (p)[2] << 16 | (p)[3] << 24)
|
|
|
|
#define GETLE16(p) ((p)[0] | (p)[1] << 8)
|
|
|
|
static int
|
2006-03-12 19:01:00 +00:00
|
|
|
ipw_load_firmware(struct ipw_softc *sc, const char *fw, int size)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-12 19:01:00 +00:00
|
|
|
const uint8_t *p, *end;
|
|
|
|
uint32_t tmp, dst;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t len;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
p = fw;
|
|
|
|
end = fw + size;
|
|
|
|
while (p < end) {
|
|
|
|
dst = GETLE32(p); p += 4;
|
|
|
|
len = GETLE16(p); p += 2;
|
|
|
|
|
|
|
|
ipw_write_mem_1(sc, dst, p, len);
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_IO, IPW_IO_GPIO1_ENABLE | IPW_IO_GPIO3_MASK |
|
|
|
|
IPW_IO_LED_OFF);
|
|
|
|
|
|
|
|
/* enable interrupts */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INTR_MASK, IPW_INTR_MASK);
|
|
|
|
|
|
|
|
/* kick the firmware */
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, 0);
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_CTL);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_ALLOW_STANDBY);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* wait at most one second for firmware initialization to complete */
|
|
|
|
if ((error = msleep(sc, &sc->sc_mtx, 0, "ipwinit", hz)) != 0) {
|
|
|
|
device_printf(sc->sc_dev, "timeout waiting for firmware "
|
|
|
|
"initialization to complete\n");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
tmp = CSR_READ_4(sc, IPW_CSR_IO);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_IO, tmp | IPW_IO_GPIO1_MASK |
|
|
|
|
IPW_IO_GPIO3_MASK);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
static int
|
|
|
|
ipw_setwepkeys(struct ipw_softc *sc)
|
|
|
|
{
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
2007-10-12 05:23:00 +00:00
|
|
|
struct ipw_wep_key wepkey;
|
|
|
|
struct ieee80211_key *wk;
|
|
|
|
int error, i;
|
|
|
|
|
|
|
|
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
2008-04-20 20:35:46 +00:00
|
|
|
wk = &vap->iv_nw_keys[i];
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
if (wk->wk_cipher == NULL ||
|
|
|
|
wk->wk_cipher->ic_cipher != IEEE80211_CIPHER_WEP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wepkey.idx = i;
|
|
|
|
wepkey.len = wk->wk_keylen;
|
|
|
|
memset(wepkey.key, 0, sizeof wepkey.key);
|
|
|
|
memcpy(wepkey.key, wk->wk_key, wk->wk_keylen);
|
|
|
|
DPRINTF(("Setting wep key index %u len %u\n", wepkey.idx,
|
|
|
|
wepkey.len));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY, &wepkey,
|
|
|
|
sizeof wepkey);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_setwpaie(struct ipw_softc *sc, const void *ie, int ielen)
|
|
|
|
{
|
|
|
|
struct ipw_wpa_ie wpaie;
|
|
|
|
|
|
|
|
memset(&wpaie, 0, sizeof(wpaie));
|
|
|
|
wpaie.len = htole32(ielen);
|
|
|
|
/* XXX verify length */
|
|
|
|
memcpy(&wpaie.ie, ie, ielen);
|
|
|
|
DPRINTF(("Setting WPA IE\n"));
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_WPA_IE, &wpaie, sizeof(wpaie));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_setbssid(struct ipw_softc *sc, uint8_t *bssid)
|
|
|
|
{
|
|
|
|
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
|
|
|
|
|
|
|
|
if (bssid == NULL || bcmp(bssid, zerobssid, IEEE80211_ADDR_LEN) == 0) {
|
|
|
|
DPRINTF(("Setting mandatory BSSID to null\n"));
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_MANDATORY_BSSID, NULL, 0);
|
|
|
|
} else {
|
|
|
|
DPRINTF(("Setting mandatory BSSID to %6D\n", bssid, ":"));
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_MANDATORY_BSSID,
|
|
|
|
bssid, IEEE80211_ADDR_LEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_setssid(struct ipw_softc *sc, void *ssid, size_t ssidlen)
|
|
|
|
{
|
|
|
|
if (ssidlen == 0) {
|
|
|
|
/*
|
|
|
|
* A bug in the firmware breaks the ``don't associate''
|
|
|
|
* bit in the scan options command. To compensate for
|
|
|
|
* this install a bogus ssid when no ssid is specified
|
|
|
|
* so the firmware won't try to associate.
|
|
|
|
*/
|
|
|
|
DPRINTF(("Setting bogus ESSID to WAR firmware bug\n"));
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_ESSID,
|
|
|
|
"\x18\x19\x20\x21\x22\x23\x24\x25\x26\x27"
|
|
|
|
"\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31"
|
|
|
|
"\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b"
|
|
|
|
"\x3c\x3d", IEEE80211_NWID_LEN);
|
|
|
|
} else {
|
|
|
|
#ifdef IPW_DEBUG
|
|
|
|
if (ipw_debug > 0) {
|
|
|
|
printf("Setting ESSID to ");
|
|
|
|
ieee80211_print_essid(ssid, ssidlen);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_ESSID, ssid, ssidlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_setscanopts(struct ipw_softc *sc, uint32_t chanmask, uint32_t flags)
|
|
|
|
{
|
|
|
|
struct ipw_scan_options opts;
|
|
|
|
|
|
|
|
DPRINTF(("Scan options: mask 0x%x flags 0x%x\n", chanmask, flags));
|
|
|
|
opts.channels = htole32(chanmask);
|
|
|
|
opts.flags = htole32(flags);
|
|
|
|
return ipw_cmd(sc, IPW_CMD_SET_SCAN_OPTIONS, &opts, sizeof(opts));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_scan(struct ipw_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t params;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
DPRINTF(("%s: flags 0x%x\n", __func__, sc->flags));
|
|
|
|
|
|
|
|
if (sc->flags & IPW_FLAG_SCANNING)
|
|
|
|
return (EBUSY);
|
|
|
|
sc->flags |= IPW_FLAG_SCANNING | IPW_FLAG_HACK;
|
|
|
|
|
|
|
|
/* NB: IPW_SCAN_DO_NOT_ASSOCIATE does not work (we set it anyway) */
|
|
|
|
error = ipw_setscanopts(sc, 0x3fff, IPW_SCAN_DO_NOT_ASSOCIATE);
|
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup null/bogus ssid so firmware doesn't use any previous
|
|
|
|
* ssid to try and associate. This is because the ``don't
|
|
|
|
* associate'' option bit is broken (sigh).
|
|
|
|
*/
|
|
|
|
error = ipw_setssid(sc, NULL, 0);
|
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: the adapter may be disabled on association lost;
|
|
|
|
* if so just re-enable it to kick off scanning.
|
|
|
|
*/
|
|
|
|
DPRINTF(("Starting scan\n"));
|
|
|
|
sc->sc_scan_timer = 3;
|
|
|
|
if (sc->flags & IPW_FLAG_ENABLED) {
|
|
|
|
params = 0; /* XXX? */
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_BROADCAST_SCAN,
|
|
|
|
¶ms, sizeof(params));
|
|
|
|
} else
|
|
|
|
error = ipw_enable(sc);
|
|
|
|
done:
|
|
|
|
if (error != 0) {
|
|
|
|
DPRINTF(("Scan failed\n"));
|
|
|
|
sc->flags &= ~(IPW_FLAG_SCANNING | IPW_FLAG_HACK);
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_setchannel(struct ipw_softc *sc, struct ieee80211_channel *chan)
|
|
|
|
{
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2007-10-12 05:23:00 +00:00
|
|
|
uint32_t data;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
data = htole32(ieee80211_chan2ieee(ic, chan));
|
|
|
|
DPRINTF(("Setting channel to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_CHANNEL, &data, sizeof data);
|
|
|
|
if (error == 0)
|
|
|
|
ipw_setcurchan(sc, chan);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static void
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_assoc(struct ieee80211com *ic, struct ieee80211vap *vap)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211_node *ni = vap->iv_bss;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ipw_security security;
|
|
|
|
uint32_t data;
|
2007-10-12 05:23:00 +00:00
|
|
|
int error;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IPW_LOCK(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
error = ipw_disable(sc);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
memset(&security, 0, sizeof security);
|
|
|
|
security.authmode = (ni->ni_authmode == IEEE80211_AUTH_SHARED) ?
|
|
|
|
IPW_AUTH_SHARED : IPW_AUTH_OPEN;
|
|
|
|
security.ciphers = htole32(IPW_CIPHER_NONE);
|
|
|
|
DPRINTF(("Setting authmode to %u\n", security.authmode));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_SECURITY_INFO, &security,
|
|
|
|
sizeof security);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
data = htole32(vap->iv_rtsthreshold);
|
|
|
|
DPRINTF(("Setting RTS threshold to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_RTS_THRESHOLD, &data, sizeof data);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
data = htole32(vap->iv_fragthreshold);
|
|
|
|
DPRINTF(("Setting frag threshold to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_FRAG_THRESHOLD, &data, sizeof data);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_flags & IEEE80211_F_PRIVACY) {
|
2007-10-12 05:23:00 +00:00
|
|
|
error = ipw_setwepkeys(sc);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_def_txkey != IEEE80211_KEYIX_NONE) {
|
|
|
|
data = htole32(vap->iv_def_txkey);
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTF(("Setting wep tx key index to %u\n",
|
|
|
|
le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY_INDEX, &data,
|
|
|
|
sizeof data);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
data = htole32((vap->iv_flags & IEEE80211_F_PRIVACY) ? IPW_WEPON : 0);
|
2007-10-12 05:23:00 +00:00
|
|
|
DPRINTF(("Setting wep flags to 0x%x\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_WEP_FLAGS, &data, sizeof data);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
error = ipw_setssid(sc, ni->ni_essid, ni->ni_esslen);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
error = ipw_setbssid(sc, ni->ni_bssid);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
2010-04-17 18:17:25 +00:00
|
|
|
if (vap->iv_appie_wpa != NULL) {
|
|
|
|
struct ieee80211_appie *ie = vap->iv_appie_wpa;
|
2008-04-20 20:35:46 +00:00
|
|
|
error = ipw_setwpaie(sc, ie->ie_data, ie->ie_len);
|
2007-10-12 05:23:00 +00:00
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_IBSS) {
|
|
|
|
error = ipw_setchannel(sc, ni->ni_chan);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lock scan to ap's channel and enable associate */
|
|
|
|
error = ipw_setscanopts(sc,
|
2008-04-20 20:35:46 +00:00
|
|
|
1<<(ieee80211_chan2ieee(ic, ni->ni_chan)-1), 0);
|
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
error = ipw_enable(sc); /* finally, enable adapter */
|
|
|
|
if (error == 0)
|
|
|
|
sc->flags |= IPW_FLAG_ASSOCIATING;
|
|
|
|
done:
|
|
|
|
IPW_UNLOCK(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_disassoc(struct ieee80211com *ic, struct ieee80211vap *vap)
|
2007-10-12 05:23:00 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211_node *ni = vap->iv_bss;
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
|
|
|
DPRINTF(("Disassociate from %6D\n", ni->ni_bssid, ":"));
|
|
|
|
/*
|
|
|
|
* NB: don't try to do this if ipw_stop_master has
|
|
|
|
* shutdown the firmware and disabled interrupts.
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
if (sc->flags & IPW_FLAG_FW_INITED) {
|
|
|
|
sc->flags &= ~IPW_FLAG_ASSOCIATED;
|
|
|
|
/*
|
|
|
|
* NB: firmware currently ignores bssid parameter, but
|
|
|
|
* supply it in case this changes (follow linux driver).
|
|
|
|
*/
|
|
|
|
(void) ipw_cmd(sc, IPW_CMD_DISASSOCIATE,
|
|
|
|
ni->ni_bssid, IEEE80211_ADDR_LEN);
|
|
|
|
}
|
|
|
|
IPW_UNLOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
/*
|
|
|
|
* Handler for sc_init_task. This is a simple wrapper around ipw_init().
|
|
|
|
* It is called on firmware panics or on watchdog timeouts.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ipw_init_task(void *context, int pending)
|
|
|
|
{
|
|
|
|
ipw_init(context);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
|
|
|
ipw_init(void *priv)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = priv;
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
ipw_init_locked(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_UNLOCK(sc);
|
2008-04-20 20:35:46 +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
|
|
|
if (sc->flags & IPW_FLAG_RUNNING)
|
2008-05-10 20:25:59 +00:00
|
|
|
ieee80211_start_all(ic); /* start all vap's */
|
2007-10-12 05:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
ipw_init_locked(struct ipw_softc *sc)
|
2007-10-12 05:23:00 +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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
Cleanup and document the implementation of firmware(9) based on
a version that i posted earlier on the -current mailing list,
and subsequent feedback received.
The core of the change is just in sys/firmware.h and kern/subr_firmware.c,
while other files are just adaptation of the clients to the ABI change
(const-ification of some parameters and hiding of internal info,
so this is fully compatible at the binary level).
In detail:
- reduce the amount of information exported to clients in struct firmware,
and constify the pointer;
- internally, document and simplify the implementation of the various
functions, and make sure error conditions are dealt with properly.
The diffs are large, but the code is really straightforward now (i hope).
Note also that there is a subtle issue with the implementation of
firmware_register(): currently, as in the previous version, we just
store a reference to the 'imagename' argument, but we should rather
copy it because there is no guarantee that this is a static string.
I realised this while testing this code, but i prefer to fix it in
a later commit -- there is no regression with respect to the past.
Note, too, that the version in RELENG_6 has various bugs including
missing locks around the module release calls, mishandling of modules
loaded by /boot/loader, and so on, so an MFC is absolutely necessary
there. I was just postponing it until this cleanup to avoid doing
things twice.
MFC after: 1 week
2007-02-15 17:21:31 +00:00
|
|
|
const struct firmware *fp;
|
2006-03-12 19:01:00 +00:00
|
|
|
const struct ipw_firmware_hdr *hdr;
|
2008-04-20 20:35:46 +00:00
|
|
|
const char *fw;
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK_ASSERT(sc);
|
|
|
|
|
|
|
|
DPRINTF(("%s: state %s flags 0x%x\n", __func__,
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_state_name[vap->iv_state], sc->flags));
|
2006-03-12 19:01:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Avoid re-entrant calls. We need to release the mutex in ipw_init()
|
|
|
|
* when loading the firmware and we don't want to be called during this
|
|
|
|
* operation.
|
|
|
|
*/
|
2007-10-12 05:23:00 +00:00
|
|
|
if (sc->flags & IPW_FLAG_INIT_LOCKED)
|
2005-04-18 18:47:38 +00:00
|
|
|
return;
|
2006-03-12 19:01:00 +00:00
|
|
|
sc->flags |= IPW_FLAG_INIT_LOCKED;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_stop_locked(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (ipw_reset(sc) != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not reset adapter\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail;
|
2006-06-10 17:29:40 +00:00
|
|
|
}
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2006-06-10 17:29:40 +00:00
|
|
|
if (sc->sc_firmware == NULL) {
|
2008-04-20 20:35:46 +00:00
|
|
|
device_printf(sc->sc_dev, "no firmware\n");
|
|
|
|
goto fail;
|
2006-03-12 19:01:00 +00:00
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
/* NB: consistency already checked on load */
|
2006-06-10 17:29:40 +00:00
|
|
|
fp = sc->sc_firmware;
|
2006-03-12 19:01:00 +00:00
|
|
|
hdr = (const struct ipw_firmware_hdr *)fp->data;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(("Loading firmware image '%s'\n", fp->name));
|
2006-03-12 19:01:00 +00:00
|
|
|
fw = (const char *)fp->data + sizeof *hdr + le32toh(hdr->mainsz);
|
|
|
|
if (ipw_load_ucode(sc, fw, le32toh(hdr->ucodesz)) != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not load microcode\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipw_stop_master(sc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup tx, rx and status rings.
|
|
|
|
*/
|
|
|
|
sc->txold = IPW_NTBD - 1;
|
|
|
|
sc->txcur = 0;
|
|
|
|
sc->txfree = IPW_NTBD - 2;
|
|
|
|
sc->rxcur = IPW_NRBD - 1;
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_BASE, sc->tbd_phys);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_SIZE, IPW_NTBD);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_READ, 0);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_TX_WRITE, sc->txcur);
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RX_BASE, sc->rbd_phys);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RX_SIZE, IPW_NRBD);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RX_READ, 0);
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RX_WRITE, sc->rxcur);
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_STATUS_BASE, sc->status_phys);
|
|
|
|
|
2006-03-12 19:01:00 +00:00
|
|
|
fw = (const char *)fp->data + sizeof *hdr;
|
|
|
|
if (ipw_load_firmware(sc, fw, le32toh(hdr->mainsz)) != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not load firmware\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->flags |= IPW_FLAG_FW_INITED;
|
|
|
|
|
|
|
|
/* retrieve information tables base addresses */
|
|
|
|
sc->table1_base = CSR_READ_4(sc, IPW_CSR_TABLE1_BASE);
|
|
|
|
sc->table2_base = CSR_READ_4(sc, IPW_CSR_TABLE2_BASE);
|
|
|
|
|
|
|
|
ipw_write_table1(sc, IPW_INFO_LOCK, 0);
|
|
|
|
|
|
|
|
if (ipw_config(sc) != 0) {
|
|
|
|
device_printf(sc->sc_dev, "device configuration failed\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
goto fail;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
callout_reset(&sc->sc_wdtimer, hz, ipw_watchdog, sc);
|
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
|
|
|
sc->flags |= IPW_FLAG_RUNNING;
|
|
|
|
sc->flags &= ~IPW_FLAG_INIT_LOCKED;
|
2005-04-18 18:47:38 +00:00
|
|
|
return;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
fail:
|
2007-10-12 05:23:00 +00:00
|
|
|
ipw_stop_locked(sc);
|
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
|
|
|
sc->flags &= ~IPW_FLAG_INIT_LOCKED;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static int
|
|
|
|
ipw_config(struct ipw_softc *sc)
|
|
|
|
{
|
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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ipw_configuration config;
|
|
|
|
uint32_t data;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = ipw_disable(sc);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
switch (ic->ic_opmode) {
|
|
|
|
case IEEE80211_M_STA:
|
|
|
|
case IEEE80211_M_HOSTAP:
|
|
|
|
case IEEE80211_M_WDS: /* XXX */
|
|
|
|
data = htole32(IPW_MODE_BSS);
|
|
|
|
break;
|
|
|
|
case IEEE80211_M_IBSS:
|
|
|
|
case IEEE80211_M_AHDEMO:
|
|
|
|
data = htole32(IPW_MODE_IBSS);
|
|
|
|
break;
|
|
|
|
case IEEE80211_M_MONITOR:
|
|
|
|
data = htole32(IPW_MODE_MONITOR);
|
|
|
|
break;
|
2009-07-10 15:28:33 +00:00
|
|
|
default:
|
|
|
|
device_printf(sc->sc_dev, "unknown opmode %d\n", ic->ic_opmode);
|
|
|
|
return EINVAL;
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
|
|
|
DPRINTF(("Setting mode to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_MODE, &data, sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_IBSS ||
|
|
|
|
ic->ic_opmode == IEEE80211_M_MONITOR) {
|
|
|
|
error = ipw_setchannel(sc, ic->ic_curchan);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_MONITOR)
|
|
|
|
return ipw_enable(sc);
|
|
|
|
|
|
|
|
config.flags = htole32(IPW_CFG_BSS_MASK | IPW_CFG_IBSS_MASK |
|
|
|
|
IPW_CFG_PREAMBLE_AUTO | IPW_CFG_802_1x_ENABLE);
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_IBSS)
|
|
|
|
config.flags |= htole32(IPW_CFG_IBSS_AUTO_START);
|
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
|
|
|
if (ic->ic_promisc > 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
config.flags |= htole32(IPW_CFG_PROMISCUOUS);
|
|
|
|
config.bss_chan = htole32(0x3fff); /* channels 1-14 */
|
|
|
|
config.ibss_chan = htole32(0x7ff); /* channels 1-11 */
|
|
|
|
DPRINTF(("Setting configuration to 0x%x\n", le32toh(config.flags)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_CONFIGURATION, &config, sizeof config);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
2010-05-11 17:14:17 +00:00
|
|
|
data = htole32(0xf); /* 1, 2, 5.5, 11 */
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(("Setting basic tx rates to 0x%x\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_BASIC_TX_RATES, &data, sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
2010-05-11 17:14:17 +00:00
|
|
|
/* Use the same rate set */
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(("Setting msdu tx rates to 0x%x\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_MSDU_TX_RATES, &data, sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
2010-05-11 17:14:17 +00:00
|
|
|
/* Use the same rate set */
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(("Setting tx rates to 0x%x\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_TX_RATES, &data, sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
data = htole32(IPW_POWER_MODE_CAM);
|
|
|
|
DPRINTF(("Setting power mode to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_POWER_MODE, &data, sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_IBSS) {
|
|
|
|
data = htole32(32); /* default value */
|
|
|
|
DPRINTF(("Setting tx power index to %u\n", le32toh(data)));
|
|
|
|
error = ipw_cmd(sc, IPW_CMD_SET_TX_POWER_INDEX, &data,
|
|
|
|
sizeof data);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
|
|
|
ipw_stop(void *priv)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = priv;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
|
|
|
ipw_stop_locked(sc);
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_stop_locked(struct ipw_softc *sc)
|
|
|
|
{
|
2005-04-18 18:47:38 +00:00
|
|
|
int i;
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_LOCK_ASSERT(sc);
|
2006-03-12 19:01:00 +00:00
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
callout_stop(&sc->sc_wdtimer);
|
2005-04-18 18:47:38 +00:00
|
|
|
ipw_stop_master(sc);
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_RST, IPW_RST_SW_RESET);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release tx buffers.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < IPW_NTBD; i++)
|
|
|
|
ipw_release_sbd(sc, &sc->stbd_list[i]);
|
|
|
|
|
|
|
|
sc->sc_tx_timer = 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
|
|
|
sc->flags &= ~IPW_FLAG_RUNNING;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_sysctl_stats(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = arg1;
|
|
|
|
uint32_t i, size, buf[256];
|
|
|
|
|
2007-12-05 19:32:07 +00:00
|
|
|
memset(buf, 0, sizeof buf);
|
|
|
|
|
|
|
|
if (!(sc->flags & IPW_FLAG_FW_INITED))
|
2005-04-18 18:47:38 +00:00
|
|
|
return SYSCTL_OUT(req, buf, sizeof buf);
|
|
|
|
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_AUTOINC_ADDR, sc->table1_base);
|
|
|
|
|
|
|
|
size = min(CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA), 256);
|
|
|
|
for (i = 1; i < size; i++)
|
|
|
|
buf[i] = MEM_READ_4(sc, CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA));
|
|
|
|
|
2007-12-05 19:32:07 +00:00
|
|
|
return SYSCTL_OUT(req, buf, size);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ipw_sysctl_radio(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = arg1;
|
|
|
|
int val;
|
|
|
|
|
|
|
|
val = !((sc->flags & IPW_FLAG_HAS_RADIO_SWITCH) &&
|
|
|
|
(CSR_READ_4(sc, IPW_CSR_IO) & IPW_IO_RADIO_DISABLED));
|
|
|
|
|
|
|
|
return SYSCTL_OUT(req, &val, sizeof val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
ipw_read_table1(struct ipw_softc *sc, uint32_t off)
|
|
|
|
{
|
|
|
|
return MEM_READ_4(sc, MEM_READ_4(sc, sc->table1_base + off));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_write_table1(struct ipw_softc *sc, uint32_t off, uint32_t info)
|
|
|
|
{
|
|
|
|
MEM_WRITE_4(sc, MEM_READ_4(sc, sc->table1_base + off), info);
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
#if 0
|
2005-04-18 18:47:38 +00:00
|
|
|
static int
|
|
|
|
ipw_read_table2(struct ipw_softc *sc, uint32_t off, void *buf, uint32_t *len)
|
|
|
|
{
|
|
|
|
uint32_t addr, info;
|
|
|
|
uint16_t count, size;
|
|
|
|
uint32_t total;
|
|
|
|
|
|
|
|
/* addr[4] + count[2] + size[2] */
|
|
|
|
addr = MEM_READ_4(sc, sc->table2_base + off);
|
|
|
|
info = MEM_READ_4(sc, sc->table2_base + off + 4);
|
|
|
|
|
|
|
|
count = info >> 16;
|
|
|
|
size = info & 0xffff;
|
|
|
|
total = count * size;
|
|
|
|
|
|
|
|
if (total > *len) {
|
|
|
|
*len = total;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = total;
|
|
|
|
ipw_read_mem_1(sc, addr, buf, total);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_read_mem_1(struct ipw_softc *sc, bus_size_t offset, uint8_t *datap,
|
|
|
|
bus_size_t count)
|
|
|
|
{
|
|
|
|
for (; count > 0; offset++, datap++, count--) {
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INDIRECT_ADDR, offset & ~3);
|
|
|
|
*datap = CSR_READ_1(sc, IPW_CSR_INDIRECT_DATA + (offset & 3));
|
|
|
|
}
|
|
|
|
}
|
2007-10-12 05:23:00 +00:00
|
|
|
#endif
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
static void
|
2006-03-12 19:01:00 +00:00
|
|
|
ipw_write_mem_1(struct ipw_softc *sc, bus_size_t offset, const uint8_t *datap,
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_size_t count)
|
|
|
|
{
|
|
|
|
for (; count > 0; offset++, datap++, count--) {
|
|
|
|
CSR_WRITE_4(sc, IPW_CSR_INDIRECT_ADDR, offset & ~3);
|
|
|
|
CSR_WRITE_1(sc, IPW_CSR_INDIRECT_DATA + (offset & 3), *datap);
|
|
|
|
}
|
|
|
|
}
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_scan_start(struct ieee80211com *ic)
|
|
|
|
{
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
2009-05-02 15:14:18 +00:00
|
|
|
ipw_scan(sc);
|
2007-10-12 05:23:00 +00:00
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
2016-05-19 22:19:35 +00:00
|
|
|
static void
|
|
|
|
ipw_getradiocaps(struct ieee80211com *ic,
|
|
|
|
int maxchans, int *nchans, struct ieee80211_channel chans[])
|
|
|
|
{
|
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
|
|
|
uint8_t bands[IEEE80211_MODE_BYTES];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(bands, 0, sizeof(bands));
|
|
|
|
setbit(bands, IEEE80211_MODE_11B);
|
|
|
|
|
|
|
|
for (i = 1; i < 16; i++) {
|
|
|
|
if (sc->chanmask & (1 << i)) {
|
|
|
|
ieee80211_add_channel(chans, maxchans, nchans,
|
|
|
|
i, 0, 0, 0, bands);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-10-12 05:23:00 +00:00
|
|
|
static void
|
|
|
|
ipw_set_channel(struct ieee80211com *ic)
|
|
|
|
{
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_MONITOR) {
|
|
|
|
ipw_disable(sc);
|
|
|
|
ipw_setchannel(sc, ic->ic_curchan);
|
|
|
|
ipw_enable(sc);
|
|
|
|
}
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
ipw_scan_curchan(struct ieee80211_scan_state *ss, unsigned long maxdwell)
|
2007-10-12 05:23:00 +00:00
|
|
|
{
|
|
|
|
/* NB: all channels are scanned at once */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
ipw_scan_mindwell(struct ieee80211_scan_state *ss)
|
2007-10-12 05:23:00 +00:00
|
|
|
{
|
|
|
|
/* NB: don't try to abort scan; wait for firmware to finish */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipw_scan_end(struct ieee80211com *ic)
|
|
|
|
{
|
2015-08-17 23:44:38 +00:00
|
|
|
struct ipw_softc *sc = ic->ic_softc;
|
2007-10-12 05:23:00 +00:00
|
|
|
|
|
|
|
IPW_LOCK(sc);
|
|
|
|
sc->flags &= ~IPW_FLAG_SCANNING;
|
|
|
|
IPW_UNLOCK(sc);
|
|
|
|
}
|