2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2017-11-18 14:26:50 +00:00
|
|
|
* SPDX-License-Identifier: BSD-4-Clause
|
|
|
|
*
|
2002-04-02 02:38:35 +00:00
|
|
|
* Copyright (c) 1997, 1998, 1999
|
|
|
|
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Bill Paul.
|
|
|
|
* 4. Neither the name of the author nor the names of any co-contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
|
|
|
|
*
|
|
|
|
* Written by Bill Paul <wpaul@ctr.columbia.edu>
|
|
|
|
* Electrical Engineering Department
|
|
|
|
* Columbia University, New York City
|
|
|
|
*/
|
|
|
|
|
2003-04-03 21:36:33 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2002-04-02 02:38:35 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <sys/malloc.h>
|
2002-04-02 02:38:35 +00:00
|
|
|
#include <sys/socket.h>
|
2002-04-26 23:11:23 +00:00
|
|
|
#include <sys/systm.h>
|
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
|
|
|
#include <sys/mbuf.h>
|
2002-04-02 02:38:35 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_types.h>
|
2003-06-28 06:17:26 +00:00
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
2003-09-05 22:29:30 +00:00
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
#include <dev/pccard/pccardvar.h>
|
2004-06-09 06:31:40 +00:00
|
|
|
#include <dev/pccard/pccard_cis.h>
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
#include <dev/wi/if_wavelan_ieee.h>
|
|
|
|
#include <dev/wi/if_wireg.h>
|
2003-09-05 22:29:30 +00:00
|
|
|
#include <dev/wi/if_wivar.h>
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
#include "card_if.h"
|
2004-05-27 03:49:45 +00:00
|
|
|
#include "pccarddevs.h"
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
static int wi_pccard_probe(device_t);
|
|
|
|
static int wi_pccard_attach(device_t);
|
|
|
|
|
|
|
|
static device_method_t wi_pccard_methods[] = {
|
|
|
|
/* Device interface */
|
2005-09-22 05:11:50 +00:00
|
|
|
DEVMETHOD(device_probe, wi_pccard_probe),
|
|
|
|
DEVMETHOD(device_attach, wi_pccard_attach),
|
2003-01-15 20:11:31 +00:00
|
|
|
DEVMETHOD(device_detach, wi_detach),
|
2002-04-02 02:38:35 +00:00
|
|
|
DEVMETHOD(device_shutdown, wi_shutdown),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t wi_pccard_driver = {
|
|
|
|
"wi",
|
|
|
|
wi_pccard_methods,
|
|
|
|
sizeof(struct wi_softc)
|
|
|
|
};
|
|
|
|
|
2003-04-15 06:37:30 +00:00
|
|
|
DRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
|
|
|
|
MODULE_DEPEND(wi, wlan, 1, 1, 1);
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
static const struct pccard_product wi_pccard_products[] = {
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(3COM, 3CRWE737A),
|
|
|
|
PCMCIA_CARD(3COM, 3CRWE777A),
|
|
|
|
PCMCIA_CARD(ACTIONTEC, PRISM),
|
2005-07-10 02:00:35 +00:00
|
|
|
PCMCIA_CARD(ADAPTEC2, ANW8030),
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(ADDTRON, AWP100),
|
2005-10-14 15:06:16 +00:00
|
|
|
PCMCIA_CARD(AIRVAST, WN_100B),
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(AIRVAST, WN_100),
|
|
|
|
PCMCIA_CARD(ALLIEDTELESIS, WR211PCM),
|
|
|
|
PCMCIA_CARD(ARTEM, ONAIR),
|
|
|
|
PCMCIA_CARD(ASUS, WL100),
|
|
|
|
PCMCIA_CARD(BAY, EMOBILITY_11B),
|
|
|
|
PCMCIA_CARD(BROMAX, IWN),
|
|
|
|
PCMCIA_CARD(BROMAX, IWN3),
|
|
|
|
PCMCIA_CARD(BROMAX, WCF11),
|
|
|
|
PCMCIA_CARD(BUFFALO, WLI_CF_S11G),
|
|
|
|
PCMCIA_CARD(BUFFALO, WLI_PCM_S11),
|
|
|
|
PCMCIA_CARD(COMPAQ, NC5004),
|
|
|
|
PCMCIA_CARD(CONTEC, FX_DS110_PCC),
|
|
|
|
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11),
|
|
|
|
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11),
|
|
|
|
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11),
|
|
|
|
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCL_11),
|
|
|
|
PCMCIA_CARD(DLINK, DWL650H),
|
|
|
|
PCMCIA_CARD(ELSA, XI300_IEEE),
|
|
|
|
PCMCIA_CARD(ELSA, XI325_IEEE),
|
2008-08-27 04:52:27 +00:00
|
|
|
PCMCIA_CARD(ELSA, APDL325_IEEE),
|
2005-10-14 15:06:16 +00:00
|
|
|
PCMCIA_CARD(ELSA, XI330_IEEE),
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(ELSA, XI800_IEEE),
|
|
|
|
PCMCIA_CARD(ELSA, WIFI_FLASH),
|
|
|
|
PCMCIA_CARD(EMTAC, WLAN),
|
|
|
|
PCMCIA_CARD(ERICSSON, WIRELESSLAN),
|
|
|
|
PCMCIA_CARD(GEMTEK, WLAN),
|
|
|
|
PCMCIA_CARD(HWN, AIRWAY80211),
|
|
|
|
PCMCIA_CARD(INTEL, PRO_WLAN_2011),
|
|
|
|
PCMCIA_CARD(INTERSIL, ISL37100P),
|
|
|
|
PCMCIA_CARD(INTERSIL, ISL37110P),
|
|
|
|
PCMCIA_CARD(INTERSIL, ISL37300P),
|
|
|
|
PCMCIA_CARD(INTERSIL2, PRISM2),
|
|
|
|
PCMCIA_CARD(IODATA2, WCF12),
|
|
|
|
PCMCIA_CARD(IODATA2, WNB11PCM),
|
|
|
|
PCMCIA_CARD(FUJITSU, WL110),
|
|
|
|
PCMCIA_CARD(LUCENT, WAVELAN_IEEE),
|
|
|
|
PCMCIA_CARD(MICROSOFT, MN_520),
|
|
|
|
PCMCIA_CARD(NOKIA, C020_WLAN),
|
|
|
|
PCMCIA_CARD(NOKIA, C110_WLAN),
|
|
|
|
PCMCIA_CARD(PLANEX, GWNS11H),
|
|
|
|
PCMCIA_CARD(PROXIM, HARMONY),
|
|
|
|
PCMCIA_CARD(PROXIM, RANGELANDS_8430),
|
|
|
|
PCMCIA_CARD(SAMSUNG, SWL_2000N),
|
|
|
|
PCMCIA_CARD(SIEMENS, SS1021),
|
2008-08-02 20:50:13 +00:00
|
|
|
PCMCIA_CARD(SIEMENS, SS1021A),
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT),
|
|
|
|
PCMCIA_CARD(SOCKET, LP_WLAN_CF),
|
|
|
|
PCMCIA_CARD(TDK, LAK_CD011WL),
|
2002-04-02 02:38:35 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
2015-12-11 05:27:56 +00:00
|
|
|
PCCARD_PNP_INFO(wi_pccard_products);
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
static int
|
2005-09-22 05:11:50 +00:00
|
|
|
wi_pccard_probe(device_t dev)
|
2002-04-02 02:38:35 +00:00
|
|
|
{
|
|
|
|
const struct pccard_product *pp;
|
2004-06-09 06:31:40 +00:00
|
|
|
u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Make sure we're a network driver */
|
|
|
|
error = pccard_get_function(dev, &fcn);
|
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
return error;
|
2004-06-09 06:31:40 +00:00
|
|
|
if (fcn != PCCARD_FUNCTION_NETWORK)
|
2008-04-20 20:35:46 +00:00
|
|
|
return ENXIO;
|
2002-04-02 02:38:35 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
pp = pccard_product_lookup(dev, wi_pccard_products,
|
|
|
|
sizeof(wi_pccard_products[0]), NULL);
|
|
|
|
if (pp != NULL) {
|
2003-04-10 04:36:02 +00:00
|
|
|
if (pp->pp_name != NULL)
|
2003-04-08 15:36:43 +00:00
|
|
|
device_set_desc(dev, pp->pp_name);
|
2008-04-20 20:35:46 +00:00
|
|
|
return 0;
|
2003-04-08 15:36:43 +00:00
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
return ENXIO;
|
2002-04-02 02:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-09-22 05:11:50 +00:00
|
|
|
wi_pccard_attach(device_t dev)
|
2002-04-02 02:38:35 +00:00
|
|
|
{
|
|
|
|
struct wi_softc *sc;
|
2008-04-20 20:35:46 +00:00
|
|
|
int error;
|
2002-04-02 02:38:35 +00:00
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
sc->wi_gone = 0;
|
|
|
|
sc->wi_bus_type = WI_BUS_PCCARD;
|
|
|
|
|
|
|
|
error = wi_alloc(dev, 0);
|
2008-04-20 20:35:46 +00:00
|
|
|
if (error == 0) {
|
|
|
|
/* Make sure interrupts are disabled. */
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
|
|
|
|
|
|
|
|
error = wi_attach(dev);
|
|
|
|
if (error != 0)
|
|
|
|
wi_free(dev);
|
2002-08-03 00:19:58 +00:00
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
return error;
|
2002-04-02 02:38:35 +00:00
|
|
|
}
|