2000-12-30 10:57:52 +03:00
|
|
|
/* $NetBSD: if_wi.c,v 1.48 2000/12/30 07:57:52 castor Exp $ */
|
1999-07-15 02:24:07 +04: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 NetBSD.
|
|
|
|
*
|
|
|
|
* Original FreeBSD driver written by Bill Paul <wpaul@ctr.columbia.edu>
|
|
|
|
* Electrical Engineering Department
|
|
|
|
* Columbia University, New York City
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The WaveLAN/IEEE adapter is the second generation of the WaveLAN
|
|
|
|
* from Lucent. Unlike the older cards, the new ones are programmed
|
|
|
|
* entirely via a firmware-driven controller called the Hermes.
|
|
|
|
* Unfortunately, Lucent will not release the Hermes programming manual
|
|
|
|
* without an NDA (if at all). What they do release is an API library
|
|
|
|
* called the HCF (Hardware Control Functions) which is supposed to
|
|
|
|
* do the device-specific operations of a device driver for you. The
|
|
|
|
* publically available version of the HCF library (the 'HCF Light') is
|
|
|
|
* a) extremely gross, b) lacks certain features, particularly support
|
|
|
|
* for 802.11 frames, and c) is contaminated by the GNU Public License.
|
|
|
|
*
|
|
|
|
* This driver does not use the HCF or HCF Light at all. Instead, it
|
|
|
|
* programs the Hermes controller directly, using information gleaned
|
|
|
|
* from the HCF Light code and corresponding documentation.
|
|
|
|
*
|
|
|
|
* This driver supports both the PCMCIA and ISA versions of the
|
|
|
|
* WaveLAN/IEEE cards. Note however that the ISA card isn't really
|
|
|
|
* anything of the sort: it's actually a PCMCIA bridge adapter
|
|
|
|
* that fits into an ISA slot, into which a PCMCIA WaveLAN card is
|
|
|
|
* inserted. Consequently, you need to use the pccard support for
|
|
|
|
* both the ISA and PCMCIA adapters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the
|
|
|
|
* Oslo IETF plenary meeting.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
|
|
|
|
#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
|
|
|
|
|
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "bpfilter.h"
|
2000-08-28 17:25:22 +04:00
|
|
|
#include "rnd.h"
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-03-23 10:01:25 +03:00
|
|
|
#include <sys/callout.h>
|
1999-07-15 02:24:07 +04:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/kernel.h> /* for hz */
|
2000-02-04 10:48:29 +03:00
|
|
|
#include <sys/proc.h>
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-08-28 17:25:22 +04:00
|
|
|
#if NRND > 0
|
|
|
|
#include <sys/rnd.h>
|
|
|
|
#endif
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_ether.h>
|
2000-03-02 08:00:47 +03:00
|
|
|
#include <net/if_ieee80211.h>
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_inarp.h>
|
|
|
|
#endif
|
|
|
|
|
1999-07-15 03:07:29 +04:00
|
|
|
#if NBPFILTER > 0
|
1999-07-15 02:24:07 +04:00
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dev/pcmcia/if_wireg.h>
|
|
|
|
|
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
|
|
|
#include <dev/pcmcia/pcmciadevs.h>
|
|
|
|
|
|
|
|
#include <dev/pcmcia/if_wi_ieee.h>
|
2000-02-04 10:48:29 +03:00
|
|
|
#include <dev/pcmcia/if_wivar.h>
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
#ifdef foo
|
|
|
|
static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 };
|
|
|
|
#endif
|
|
|
|
|
2000-07-18 18:53:26 +04:00
|
|
|
struct wi_pcmcia_product {
|
|
|
|
u_int32_t pp_vendor; /* vendor ID */
|
|
|
|
u_int32_t pp_product; /* product ID */
|
|
|
|
const char *pp_cisinfo[4]; /* CIS information */
|
|
|
|
const char *pp_name; /* product name */
|
|
|
|
int pp_prism2; /* prism2 chipset */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct wi_pcmcia_product *wi_lookup __P((struct pcmcia_attach_args *pa));
|
1999-07-15 02:24:07 +04:00
|
|
|
static int wi_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void wi_attach __P((struct device *, struct device *, void *));
|
2000-02-12 19:08:04 +03:00
|
|
|
static int wi_detach __P((struct device *, int));
|
|
|
|
static int wi_activate __P((struct device *, enum devact));
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
static int wi_intr __P((void *arg));
|
|
|
|
|
|
|
|
static void wi_reset __P((struct wi_softc *));
|
|
|
|
static int wi_ioctl __P((struct ifnet *, u_long, caddr_t));
|
|
|
|
static void wi_start __P((struct ifnet *));
|
|
|
|
static void wi_watchdog __P((struct ifnet *));
|
2000-10-12 06:24:08 +04:00
|
|
|
static int wi_init __P((struct ifnet *));
|
|
|
|
static void wi_stop __P((struct ifnet *, int));
|
1999-07-15 02:24:07 +04:00
|
|
|
static void wi_rxeof __P((struct wi_softc *));
|
|
|
|
static void wi_txeof __P((struct wi_softc *, int));
|
|
|
|
static void wi_update_stats __P((struct wi_softc *));
|
|
|
|
static void wi_setmulti __P((struct wi_softc *));
|
|
|
|
|
|
|
|
static int wi_cmd __P((struct wi_softc *, int, int));
|
|
|
|
static int wi_read_record __P((struct wi_softc *, struct wi_ltv_gen *));
|
|
|
|
static int wi_write_record __P((struct wi_softc *, struct wi_ltv_gen *));
|
|
|
|
static int wi_read_data __P((struct wi_softc *, int,
|
|
|
|
int, caddr_t, int));
|
|
|
|
static int wi_write_data __P((struct wi_softc *, int,
|
|
|
|
int, caddr_t, int));
|
|
|
|
static int wi_seek __P((struct wi_softc *, int, int, int));
|
|
|
|
static int wi_alloc_nicmem __P((struct wi_softc *, int, int *));
|
|
|
|
static void wi_inquire __P((void *));
|
2000-02-28 02:10:51 +03:00
|
|
|
static int wi_setdef __P((struct wi_softc *, struct wi_req *));
|
|
|
|
static int wi_getdef __P((struct wi_softc *, struct wi_req *));
|
1999-07-15 02:24:07 +04:00
|
|
|
static int wi_mgmt_xmit __P((struct wi_softc *, caddr_t, int));
|
1999-07-15 03:07:29 +04:00
|
|
|
static void wi_shutdown __P((void *));
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
static int wi_enable __P((struct wi_softc *));
|
2000-02-28 02:10:51 +03:00
|
|
|
static void wi_disable __P((struct wi_softc *));
|
2000-03-02 08:00:47 +03:00
|
|
|
static int wi_media_change __P((struct ifnet *));
|
|
|
|
static void wi_media_status __P((struct ifnet *, struct ifmediareq *));
|
|
|
|
|
2000-07-05 06:35:53 +04:00
|
|
|
static int wi_set_ssid __P((struct ieee80211_nwid *, u_int8_t *, int));
|
|
|
|
static void wi_request_fill_ssid __P((struct wi_req *,
|
|
|
|
struct ieee80211_nwid *));
|
2000-03-02 08:00:47 +03:00
|
|
|
static int wi_write_ssid __P((struct wi_softc *, int, struct wi_req *,
|
2000-07-05 06:35:53 +04:00
|
|
|
struct ieee80211_nwid *));
|
2000-07-21 08:48:55 +04:00
|
|
|
static int wi_set_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
|
|
|
|
static int wi_get_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
|
2000-07-31 07:25:11 +04:00
|
|
|
static int wi_sync_media __P((struct wi_softc *, int, int));
|
2000-12-12 07:04:29 +03:00
|
|
|
static int wi_set_pm(struct wi_softc *, struct ieee80211_power *);
|
|
|
|
static int wi_get_pm(struct wi_softc *, struct ieee80211_power *);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
struct cfattach wi_ca = {
|
2000-02-12 19:08:04 +03:00
|
|
|
sizeof(struct wi_softc), wi_match, wi_attach, wi_detach, wi_activate
|
1999-07-15 02:24:07 +04:00
|
|
|
};
|
|
|
|
|
2000-07-18 18:53:26 +04:00
|
|
|
static struct wi_pcmcia_product wi_pcmcia_products[] = {
|
|
|
|
{ PCMCIA_VENDOR_LUCENT,
|
|
|
|
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
|
|
|
PCMCIA_CIS_LUCENT_WAVELAN_IEEE,
|
|
|
|
PCMCIA_STR_LUCENT_WAVELAN_IEEE,
|
|
|
|
0 },
|
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3CRWE737A,
|
|
|
|
PCMCIA_CIS_3COM_3CRWE737A,
|
|
|
|
PCMCIA_STR_3COM_3CRWE737A,
|
|
|
|
1 },
|
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_COREGA,
|
|
|
|
PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11,
|
|
|
|
PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11,
|
|
|
|
PCMCIA_STR_COREGA_WIRELESS_LAN_PCC_11,
|
|
|
|
1 },
|
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_INTERSIL,
|
|
|
|
PCMCIA_PRODUCT_INTERSIL_PRISM2,
|
|
|
|
PCMCIA_CIS_INTERSIL_PRISM2,
|
|
|
|
PCMCIA_STR_INTERSIL_PRISM2,
|
|
|
|
1 },
|
|
|
|
|
2000-07-26 11:28:56 +04:00
|
|
|
{ PCMCIA_VENDOR_SAMSUNG,
|
|
|
|
PCMCIA_PRODUCT_SAMSUNG_SWL_2000N,
|
|
|
|
PCMCIA_CIS_SAMSUNG_SWL_2000N,
|
|
|
|
PCMCIA_STR_SAMSUNG_SWL_2000N,
|
|
|
|
1 },
|
|
|
|
|
2000-12-19 19:55:57 +03:00
|
|
|
{ PCMCIA_VENDOR_LUCENT,
|
|
|
|
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
|
|
|
PCMCIA_CIS_SMC_2632W,
|
|
|
|
PCMCIA_STR_SMC_2632W,
|
|
|
|
1 },
|
|
|
|
|
2000-07-18 18:53:26 +04:00
|
|
|
{ 0,
|
|
|
|
0,
|
|
|
|
{ NULL, NULL, NULL, NULL },
|
|
|
|
NULL,
|
|
|
|
0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct wi_pcmcia_product *
|
|
|
|
wi_lookup(pa)
|
|
|
|
struct pcmcia_attach_args *pa;
|
|
|
|
{
|
|
|
|
struct wi_pcmcia_product *pp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* match by CIS information first
|
|
|
|
* XXX: Farallon SkyLINE 11mb uses PRISM II but vendor ID
|
|
|
|
* and product ID is the same as Lucent WaveLAN
|
|
|
|
*/
|
|
|
|
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
|
|
|
if (pa->card->cis1_info[0] != NULL &&
|
|
|
|
pp->pp_cisinfo[0] != NULL &&
|
|
|
|
strcmp(pa->card->cis1_info[0], pp->pp_cisinfo[0]) == 0 &&
|
|
|
|
pa->card->cis1_info[1] != NULL &&
|
|
|
|
pp->pp_cisinfo[1] != NULL &&
|
|
|
|
strcmp(pa->card->cis1_info[1], pp->pp_cisinfo[1]) == 0)
|
|
|
|
return pp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match by vendor/product id */
|
|
|
|
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
|
|
|
if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
|
|
|
|
pa->manufacturer == pp->pp_vendor &&
|
|
|
|
pa->product != PCMCIA_PRODUCT_INVALID &&
|
|
|
|
pa->product == pp->pp_product)
|
|
|
|
return pp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
static int
|
|
|
|
wi_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
|
2000-07-18 18:53:26 +04:00
|
|
|
if (wi_lookup(pa) != NULL)
|
|
|
|
return 1;
|
2000-06-30 20:40:31 +04:00
|
|
|
return 0;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
wi_enable(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
2000-02-28 02:10:51 +03:00
|
|
|
|
|
|
|
if (sc->sc_enabled != 0)
|
|
|
|
return (0);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, wi_intr, sc);
|
|
|
|
if (sc->sc_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt handler\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
if (pcmcia_function_enable(sc->sc_pf) != 0) {
|
|
|
|
printf("%s: couldn't enable card\n", sc->sc_dev.dv_xname);
|
2000-02-28 02:10:51 +03:00
|
|
|
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
1999-07-15 02:24:07 +04:00
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
sc->sc_enabled = 1;
|
|
|
|
return (0);
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
void
|
1999-07-15 02:24:07 +04:00
|
|
|
wi_disable(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
if (sc->sc_enabled == 0)
|
|
|
|
return;
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
pcmcia_function_disable(sc->sc_pf);
|
|
|
|
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
|
|
|
sc->sc_enabled = 0;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach the card.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wi_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = (void *) self;
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
2000-07-18 18:53:26 +04:00
|
|
|
struct wi_pcmcia_product *pp;
|
1999-07-15 02:24:07 +04:00
|
|
|
struct wi_ltv_macaddr mac;
|
|
|
|
struct wi_ltv_gen gen;
|
2000-11-02 21:55:46 +03:00
|
|
|
char devinfo[256];
|
2000-03-06 13:31:27 +03:00
|
|
|
static const u_int8_t empty_macaddr[ETHER_ADDR_LEN] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
};
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-11-02 21:55:46 +03:00
|
|
|
/* Print out what we are. */
|
|
|
|
pcmcia_devinfo(&pa->pf->sc->card, 0, devinfo, sizeof(devinfo));
|
|
|
|
printf(": %s\n", devinfo);
|
|
|
|
|
2000-03-06 13:31:27 +03:00
|
|
|
/* Enable the card. */
|
1999-07-15 02:24:07 +04:00
|
|
|
sc->sc_pf = pa->pf;
|
|
|
|
pcmcia_function_init(sc->sc_pf, sc->sc_pf->cfe_head.sqh_first);
|
|
|
|
if (pcmcia_function_enable(sc->sc_pf)) {
|
2000-11-02 21:55:46 +03:00
|
|
|
printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
|
2000-03-06 13:31:27 +03:00
|
|
|
goto enable_failed;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
2000-03-06 13:31:27 +03:00
|
|
|
/* Allocate/map I/O space. */
|
1999-07-15 02:24:07 +04:00
|
|
|
if (pcmcia_io_alloc(sc->sc_pf, 0, WI_IOSIZ, WI_IOSIZ,
|
|
|
|
&sc->sc_pcioh) != 0) {
|
2000-11-02 21:55:46 +03:00
|
|
|
printf("%s: can't allocate i/o space\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-03-06 13:31:27 +03:00
|
|
|
goto ioalloc_failed;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO16, 0,
|
|
|
|
WI_IOSIZ, &sc->sc_pcioh, &sc->sc_iowin) != 0) {
|
2000-11-02 21:55:46 +03:00
|
|
|
printf("%s: can't map i/o space\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-03-06 13:31:27 +03:00
|
|
|
goto iomap_failed;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
sc->wi_btag = sc->sc_pcioh.iot;
|
|
|
|
sc->wi_bhandle = sc->sc_pcioh.ioh;
|
|
|
|
|
2000-07-18 18:53:26 +04:00
|
|
|
pp = wi_lookup(pa);
|
|
|
|
if (pp == NULL) {
|
|
|
|
/* should not happen */
|
|
|
|
sc->sc_prism2 = 0;
|
|
|
|
} else
|
|
|
|
sc->sc_prism2 = pp->pp_prism2;
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_init(&sc->wi_inquire_ch);
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
/* Make sure interrupts are disabled. */
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
|
|
|
|
|
|
|
|
/* Reset the NIC. */
|
|
|
|
wi_reset(sc);
|
|
|
|
|
|
|
|
memset(&mac, 0, sizeof(mac));
|
|
|
|
/* Read the station address. */
|
|
|
|
mac.wi_type = WI_RID_MAC_NODE;
|
|
|
|
mac.wi_len = 4;
|
|
|
|
wi_read_record(sc, (struct wi_ltv_gen *)&mac);
|
|
|
|
memcpy(sc->sc_macaddr, mac.wi_mac_addr, ETHER_ADDR_LEN);
|
|
|
|
|
2000-03-06 13:31:27 +03:00
|
|
|
/*
|
|
|
|
* Check if we got anything meaningful.
|
|
|
|
*
|
|
|
|
* Is it really enough just checking against null ethernet address?
|
|
|
|
* Or, check against possible vendor? XXX.
|
|
|
|
*/
|
2000-02-13 09:17:58 +03:00
|
|
|
if (bcmp(sc->sc_macaddr, empty_macaddr, ETHER_ADDR_LEN) == 0) {
|
2000-11-02 21:55:46 +03:00
|
|
|
printf("%s: could not get mac address, attach failed\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-03-06 13:31:27 +03:00
|
|
|
goto bad_enaddr;
|
2000-02-13 09:17:58 +03:00
|
|
|
}
|
|
|
|
|
2000-11-02 21:55:46 +03:00
|
|
|
printf("%s: 802.11 address %s\n", sc->sc_dev.dv_xname,
|
1999-07-15 02:24:07 +04:00
|
|
|
ether_sprintf(sc->sc_macaddr));
|
|
|
|
|
|
|
|
memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
|
|
|
|
ifp->if_softc = sc;
|
|
|
|
ifp->if_start = wi_start;
|
|
|
|
ifp->if_ioctl = wi_ioctl;
|
|
|
|
ifp->if_watchdog = wi_watchdog;
|
2000-10-12 06:24:08 +04:00
|
|
|
ifp->if_init = wi_init;
|
|
|
|
ifp->if_stop = wi_stop;
|
1999-07-15 02:24:07 +04:00
|
|
|
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
2000-12-14 09:27:23 +03:00
|
|
|
IFQ_SET_READY(&ifp->if_snd);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-03-02 08:00:47 +03:00
|
|
|
(void)wi_set_ssid(&sc->wi_nodeid, WI_DEFAULT_NODENAME,
|
1999-07-15 02:24:07 +04:00
|
|
|
sizeof(WI_DEFAULT_NODENAME) - 1);
|
2000-03-02 08:00:47 +03:00
|
|
|
(void)wi_set_ssid(&sc->wi_netid, WI_DEFAULT_NETNAME,
|
1999-07-15 02:24:07 +04:00
|
|
|
sizeof(WI_DEFAULT_NETNAME) - 1);
|
2000-03-02 08:00:47 +03:00
|
|
|
(void)wi_set_ssid(&sc->wi_ibssid, WI_DEFAULT_IBSS,
|
1999-07-15 02:24:07 +04:00
|
|
|
sizeof(WI_DEFAULT_IBSS) - 1);
|
|
|
|
|
|
|
|
sc->wi_portnum = WI_DEFAULT_PORT;
|
|
|
|
sc->wi_ptype = WI_PORTTYPE_ADHOC;
|
|
|
|
sc->wi_ap_density = WI_DEFAULT_AP_DENSITY;
|
|
|
|
sc->wi_rts_thresh = WI_DEFAULT_RTS_THRESH;
|
|
|
|
sc->wi_tx_rate = WI_DEFAULT_TX_RATE;
|
|
|
|
sc->wi_max_data_len = WI_DEFAULT_DATALEN;
|
|
|
|
sc->wi_create_ibss = WI_DEFAULT_CREATE_IBSS;
|
|
|
|
sc->wi_pm_enabled = WI_DEFAULT_PM_ENABLED;
|
|
|
|
sc->wi_max_sleep = WI_DEFAULT_MAX_SLEEP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the default channel from the NIC. This may vary
|
|
|
|
* depending on the country where the NIC was purchased, so
|
|
|
|
* we can't hard-code a default and expect it to work for
|
|
|
|
* everyone.
|
|
|
|
*/
|
|
|
|
gen.wi_type = WI_RID_OWN_CHNL;
|
|
|
|
gen.wi_len = 2;
|
|
|
|
wi_read_record(sc, &gen);
|
|
|
|
sc->wi_channel = gen.wi_val;
|
|
|
|
|
|
|
|
bzero((char *)&sc->wi_stats, sizeof(sc->wi_stats));
|
|
|
|
|
2000-02-04 10:48:29 +03:00
|
|
|
/*
|
|
|
|
* Find out if we support WEP on this card.
|
|
|
|
*/
|
|
|
|
gen.wi_type = WI_RID_WEP_AVAIL;
|
|
|
|
gen.wi_len = 2;
|
|
|
|
wi_read_record(sc, &gen);
|
|
|
|
sc->wi_has_wep = gen.wi_val;
|
|
|
|
|
2000-03-02 08:00:47 +03:00
|
|
|
ifmedia_init(&sc->sc_media, 0, wi_media_change, wi_media_status);
|
|
|
|
#define IFM_AUTOADHOC \
|
|
|
|
IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, IFM_IEEE80211_ADHOC, 0)
|
|
|
|
#define ADD(m, c) ifmedia_add(&sc->sc_media, (m), (c), NULL)
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0);
|
|
|
|
ADD(IFM_AUTOADHOC, 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1,
|
|
|
|
IFM_IEEE80211_ADHOC, 0), 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2,
|
|
|
|
IFM_IEEE80211_ADHOC, 0), 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
|
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
|
|
|
|
IFM_IEEE80211_ADHOC, 0), 0);
|
2000-07-31 07:25:11 +04:00
|
|
|
ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_MANUAL, 0, 0), 0);
|
2000-03-02 08:00:47 +03:00
|
|
|
#undef ADD
|
|
|
|
ifmedia_set(&sc->sc_media, IFM_AUTOADHOC);
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
/*
|
|
|
|
* Call MI attach routines.
|
|
|
|
*/
|
|
|
|
if_attach(ifp);
|
|
|
|
ether_ifattach(ifp, mac.wi_mac_addr);
|
|
|
|
|
2000-03-07 00:02:37 +03:00
|
|
|
ifp->if_baudrate = IF_Mbps(2);
|
|
|
|
|
2000-08-28 17:25:22 +04:00
|
|
|
#if NRND > 0
|
|
|
|
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
|
|
|
|
RND_TYPE_NET, 0);
|
|
|
|
#endif
|
1999-07-15 02:24:07 +04:00
|
|
|
|
1999-07-15 03:07:29 +04:00
|
|
|
sc->sc_sdhook = shutdownhook_establish(wi_shutdown, sc);
|
2000-02-12 19:08:04 +03:00
|
|
|
|
|
|
|
/* Disable the card now, and turn it on when the interface goes up */
|
|
|
|
pcmcia_function_disable(sc->sc_pf);
|
2000-03-06 13:31:27 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
bad_enaddr:
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
|
|
|
|
iomap_failed:
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
|
|
|
|
ioalloc_failed:
|
|
|
|
pcmcia_function_disable(sc->sc_pf);
|
|
|
|
enable_failed:
|
|
|
|
sc->sc_iowin = -1;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_rxeof(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ether_header *eh;
|
|
|
|
struct wi_frame rx_frame;
|
|
|
|
struct mbuf *m;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
id = CSR_READ_2(sc, WI_RX_FID);
|
|
|
|
|
|
|
|
/* First read in the frame header */
|
|
|
|
if (wi_read_data(sc, id, 0, (caddr_t)&rx_frame, sizeof(rx_frame))) {
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rx_frame.wi_status & WI_STAT_ERRSTAT) {
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == NULL) {
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MCLGET(m, M_DONTWAIT);
|
|
|
|
if (!(m->m_flags & M_EXT)) {
|
|
|
|
m_freem(m);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-12-30 10:57:52 +03:00
|
|
|
/* Align the data after the ethernet header */
|
|
|
|
m->m_data = (caddr_t) ALIGN(m->m_data + sizeof(struct ether_header))
|
|
|
|
- sizeof(struct ether_header);
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
eh = mtod(m, struct ether_header *);
|
|
|
|
m->m_pkthdr.rcvif = ifp;
|
|
|
|
|
|
|
|
if (rx_frame.wi_status == WI_STAT_1042 ||
|
|
|
|
rx_frame.wi_status == WI_STAT_TUNNEL ||
|
|
|
|
rx_frame.wi_status == WI_STAT_WMP_MSG) {
|
|
|
|
if((rx_frame.wi_dat_len + WI_SNAPHDR_LEN) > MCLBYTES) {
|
|
|
|
printf("%s: oversized packet received "
|
|
|
|
"(wi_dat_len=%d, wi_status=0x%x)\n",
|
|
|
|
sc->sc_dev.dv_xname,
|
|
|
|
rx_frame.wi_dat_len, rx_frame.wi_status);
|
|
|
|
m_freem(m);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m->m_pkthdr.len = m->m_len =
|
|
|
|
rx_frame.wi_dat_len + WI_SNAPHDR_LEN;
|
|
|
|
|
2000-08-18 08:11:48 +04:00
|
|
|
bcopy((char *)&rx_frame.wi_dst_addr,
|
1999-07-15 02:24:07 +04:00
|
|
|
(char *)&eh->ether_dhost, ETHER_ADDR_LEN);
|
2000-08-18 08:11:48 +04:00
|
|
|
bcopy((char *)&rx_frame.wi_src_addr,
|
1999-07-15 02:24:07 +04:00
|
|
|
(char *)&eh->ether_shost, ETHER_ADDR_LEN);
|
|
|
|
bcopy((char *)&rx_frame.wi_type,
|
|
|
|
(char *)&eh->ether_type, sizeof(u_int16_t));
|
|
|
|
|
|
|
|
if (wi_read_data(sc, id, WI_802_11_OFFSET,
|
|
|
|
mtod(m, caddr_t) + sizeof(struct ether_header),
|
|
|
|
m->m_len + 2)) {
|
|
|
|
m_freem(m);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if((rx_frame.wi_dat_len +
|
|
|
|
sizeof(struct ether_header)) > MCLBYTES) {
|
|
|
|
printf("%s: oversized packet received "
|
|
|
|
"(wi_dat_len=%d, wi_status=0x%x)\n",
|
|
|
|
sc->sc_dev.dv_xname,
|
|
|
|
rx_frame.wi_dat_len, rx_frame.wi_status);
|
|
|
|
m_freem(m);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m->m_pkthdr.len = m->m_len =
|
|
|
|
rx_frame.wi_dat_len + sizeof(struct ether_header);
|
|
|
|
|
|
|
|
if (wi_read_data(sc, id, WI_802_3_OFFSET,
|
|
|
|
mtod(m, caddr_t), m->m_len + 2)) {
|
|
|
|
m_freem(m);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ifp->if_ipackets++;
|
|
|
|
|
1999-07-15 03:07:29 +04:00
|
|
|
#if NBPFILTER > 0
|
1999-07-15 02:24:07 +04:00
|
|
|
/* Handle BPF listeners. */
|
2000-10-02 03:32:39 +04:00
|
|
|
if (ifp->if_bpf)
|
1999-07-15 03:07:29 +04:00
|
|
|
bpf_mtap(ifp->if_bpf, m);
|
1999-07-15 02:24:07 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Receive packet. */
|
|
|
|
(*ifp->if_input)(ifp, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_txeof(sc, status)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int status;
|
|
|
|
{
|
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
ifp->if_timer = 0;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
|
|
|
if (status & WI_EV_TX_EXC)
|
|
|
|
ifp->if_oerrors++;
|
|
|
|
else
|
|
|
|
ifp->if_opackets++;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wi_inquire(xsc)
|
|
|
|
void *xsc;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
sc = xsc;
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
2000-02-13 02:35:28 +03:00
|
|
|
if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
|
|
|
|
return;
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->wi_inquire_ch, hz * 60, wi_inquire, sc);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Don't do this while we're transmitting */
|
|
|
|
if (ifp->if_flags & IFF_OACTIVE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_COUNTERS);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wi_update_stats(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
|
|
|
struct wi_ltv_gen gen;
|
|
|
|
u_int16_t id;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
u_int32_t *ptr;
|
2000-05-14 21:19:18 +04:00
|
|
|
int len, i;
|
1999-07-15 02:24:07 +04:00
|
|
|
u_int16_t t;
|
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
id = CSR_READ_2(sc, WI_INFO_FID);
|
|
|
|
|
|
|
|
wi_read_data(sc, id, 0, (char *)&gen, 4);
|
|
|
|
|
2000-05-14 21:19:18 +04:00
|
|
|
if (gen.wi_type != WI_INFO_COUNTERS)
|
1999-07-15 02:24:07 +04:00
|
|
|
return;
|
|
|
|
|
2000-05-14 21:19:18 +04:00
|
|
|
/* some card versions have a larger stats structure */
|
|
|
|
len = (gen.wi_len - 1 < sizeof(sc->wi_stats) / 4) ?
|
|
|
|
gen.wi_len - 1 : sizeof(sc->wi_stats) / 4;
|
1999-07-15 02:24:07 +04:00
|
|
|
ptr = (u_int32_t *)&sc->wi_stats;
|
|
|
|
|
2000-05-14 21:19:18 +04:00
|
|
|
for (i = 0; i < len; i++) {
|
1999-07-15 02:24:07 +04:00
|
|
|
t = CSR_READ_2(sc, WI_DATA1);
|
|
|
|
#ifdef WI_HERMES_STATS_WAR
|
|
|
|
if (t > 0xF000)
|
|
|
|
t = ~t & 0xFFFF;
|
|
|
|
#endif
|
|
|
|
ptr[i] += t;
|
|
|
|
}
|
|
|
|
|
|
|
|
ifp->if_collisions = sc->wi_stats.wi_tx_single_retries +
|
|
|
|
sc->wi_stats.wi_tx_multi_retries +
|
|
|
|
sc->wi_stats.wi_tx_retry_limit;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wi_intr(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = arg;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
u_int16_t status;
|
|
|
|
|
2000-10-13 23:15:08 +04:00
|
|
|
if (sc->sc_enabled == 0 ||
|
|
|
|
(sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 ||
|
|
|
|
(sc->sc_ethercom.ec_if.if_flags & IFF_RUNNING) == 0)
|
2000-02-13 02:35:28 +03:00
|
|
|
return (0);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
if (!(ifp->if_flags & IFF_UP)) {
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable interrupts. */
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
|
|
|
|
status = CSR_READ_2(sc, WI_EVENT_STAT);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, ~WI_INTRS);
|
|
|
|
|
|
|
|
if (status & WI_EV_RX) {
|
|
|
|
wi_rxeof(sc);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & WI_EV_TX) {
|
|
|
|
wi_txeof(sc, status);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & WI_EV_ALLOC) {
|
|
|
|
int id;
|
|
|
|
id = CSR_READ_2(sc, WI_ALLOC_FID);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC);
|
|
|
|
if (id == sc->wi_tx_data_id)
|
|
|
|
wi_txeof(sc, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & WI_EV_INFO) {
|
|
|
|
wi_update_stats(sc);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & WI_EV_TX_EXC) {
|
|
|
|
wi_txeof(sc, status);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX_EXC);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & WI_EV_INFO_DROP) {
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO_DROP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-enable interrupts. */
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
|
|
|
|
|
2000-12-14 09:27:23 +03:00
|
|
|
if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
|
1999-07-15 02:24:07 +04:00
|
|
|
wi_start(ifp);
|
|
|
|
|
2000-08-28 17:25:22 +04:00
|
|
|
#if NRND > 0
|
|
|
|
rnd_add_uint32(&sc->rnd_source, status);
|
|
|
|
#endif
|
1999-07-15 02:24:07 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wi_cmd(sc, cmd, val)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int cmd;
|
|
|
|
int val;
|
|
|
|
{
|
|
|
|
int i, s = 0;
|
|
|
|
|
|
|
|
CSR_WRITE_2(sc, WI_PARAM0, val);
|
|
|
|
CSR_WRITE_2(sc, WI_COMMAND, cmd);
|
|
|
|
|
|
|
|
for (i = 0; i < WI_TIMEOUT; i++) {
|
|
|
|
/*
|
|
|
|
* Wait for 'command complete' bit to be
|
|
|
|
* set in the event status register.
|
|
|
|
*/
|
|
|
|
s = CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_CMD;
|
|
|
|
if (s) {
|
|
|
|
/* Ack the event and read result code. */
|
|
|
|
s = CSR_READ_2(sc, WI_STATUS);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_CMD);
|
|
|
|
#ifdef foo
|
|
|
|
if ((s & WI_CMD_CODE_MASK) != (cmd & WI_CMD_CODE_MASK))
|
|
|
|
return(EIO);
|
|
|
|
#endif
|
|
|
|
if (s & WI_STAT_CMD_RESULT)
|
|
|
|
return(EIO);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == WI_TIMEOUT)
|
|
|
|
return(ETIMEDOUT);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_reset(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
|
|
|
if (wi_cmd(sc, WI_CMD_INI, 0))
|
|
|
|
printf("%s: init failed\n", sc->sc_dev.dv_xname);
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
|
|
|
|
|
|
|
|
/* Calibrate timer. */
|
|
|
|
WI_SETVAL(WI_RID_TICK_TIME, 8);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read an LTV record from the NIC.
|
|
|
|
*/
|
|
|
|
static int wi_read_record(sc, ltv)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct wi_ltv_gen *ltv;
|
|
|
|
{
|
|
|
|
u_int16_t *ptr;
|
|
|
|
int i, len, code;
|
2000-07-18 19:01:55 +04:00
|
|
|
struct wi_ltv_gen *oltv, p2ltv;
|
|
|
|
|
|
|
|
if (sc->sc_prism2) {
|
|
|
|
oltv = ltv;
|
|
|
|
switch (ltv->wi_type) {
|
|
|
|
case WI_RID_ENCRYPTION:
|
|
|
|
p2ltv.wi_type = WI_RID_P2_ENCRYPTION;
|
|
|
|
p2ltv.wi_len = 2;
|
|
|
|
ltv = &p2ltv;
|
|
|
|
break;
|
|
|
|
case WI_RID_TX_CRYPT_KEY:
|
|
|
|
p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY;
|
|
|
|
p2ltv.wi_len = 2;
|
|
|
|
ltv = &p2ltv;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Tell the NIC to enter record read mode. */
|
|
|
|
if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_READ, ltv->wi_type))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
/* Seek to the record. */
|
|
|
|
if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the length and record type and make sure they
|
|
|
|
* match what we expect (this verifies that we have enough
|
|
|
|
* room to hold all of the returned data).
|
|
|
|
*/
|
|
|
|
len = CSR_READ_2(sc, WI_DATA1);
|
|
|
|
if (len > ltv->wi_len)
|
|
|
|
return(ENOSPC);
|
|
|
|
code = CSR_READ_2(sc, WI_DATA1);
|
|
|
|
if (code != ltv->wi_type)
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
ltv->wi_len = len;
|
|
|
|
ltv->wi_type = code;
|
|
|
|
|
|
|
|
/* Now read the data. */
|
|
|
|
ptr = <v->wi_val;
|
|
|
|
for (i = 0; i < ltv->wi_len - 1; i++)
|
|
|
|
ptr[i] = CSR_READ_2(sc, WI_DATA1);
|
|
|
|
|
2000-07-18 19:01:55 +04:00
|
|
|
if (sc->sc_prism2) {
|
2000-07-25 16:04:29 +04:00
|
|
|
switch (oltv->wi_type) {
|
|
|
|
case WI_RID_TX_RATE:
|
|
|
|
case WI_RID_CUR_TX_RATE:
|
|
|
|
switch (ltv->wi_val) {
|
|
|
|
case 1: oltv->wi_val = 1; break;
|
|
|
|
case 2: oltv->wi_val = 2; break;
|
|
|
|
case 3: oltv->wi_val = 6; break;
|
|
|
|
case 4: oltv->wi_val = 5; break;
|
|
|
|
case 7: oltv->wi_val = 7; break;
|
|
|
|
case 8: oltv->wi_val = 11; break;
|
|
|
|
case 15: oltv->wi_val = 3; break;
|
|
|
|
default: oltv->wi_val = 0x100 + ltv->wi_val; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WI_RID_ENCRYPTION:
|
2000-07-18 19:01:55 +04:00
|
|
|
oltv->wi_len = 2;
|
|
|
|
if (ltv->wi_val & 0x01)
|
|
|
|
oltv->wi_val = 1;
|
|
|
|
else
|
|
|
|
oltv->wi_val = 0;
|
|
|
|
break;
|
2000-07-25 16:04:29 +04:00
|
|
|
case WI_RID_TX_CRYPT_KEY:
|
2000-07-18 19:01:55 +04:00
|
|
|
oltv->wi_len = 2;
|
|
|
|
oltv->wi_val = ltv->wi_val;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Same as read, except we inject data instead of reading it.
|
|
|
|
*/
|
|
|
|
static int wi_write_record(sc, ltv)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct wi_ltv_gen *ltv;
|
|
|
|
{
|
|
|
|
u_int16_t *ptr;
|
|
|
|
int i;
|
2000-07-18 19:01:55 +04:00
|
|
|
struct wi_ltv_gen p2ltv;
|
|
|
|
|
|
|
|
if (sc->sc_prism2) {
|
|
|
|
switch (ltv->wi_type) {
|
2000-07-25 16:04:29 +04:00
|
|
|
case WI_RID_TX_RATE:
|
|
|
|
p2ltv.wi_type = WI_RID_TX_RATE;
|
|
|
|
p2ltv.wi_len = 2;
|
|
|
|
switch (ltv->wi_val) {
|
|
|
|
case 1: p2ltv.wi_val = 1; break;
|
|
|
|
case 2: p2ltv.wi_val = 2; break;
|
|
|
|
case 3: p2ltv.wi_val = 15; break;
|
|
|
|
case 5: p2ltv.wi_val = 4; break;
|
|
|
|
case 6: p2ltv.wi_val = 3; break;
|
|
|
|
case 7: p2ltv.wi_val = 7; break;
|
|
|
|
case 11: p2ltv.wi_val = 8; break;
|
|
|
|
default: return EINVAL;
|
|
|
|
}
|
|
|
|
ltv = &p2ltv;
|
|
|
|
break;
|
2000-07-18 19:01:55 +04:00
|
|
|
case WI_RID_ENCRYPTION:
|
|
|
|
p2ltv.wi_type = WI_RID_P2_ENCRYPTION;
|
|
|
|
p2ltv.wi_len = 2;
|
|
|
|
if (ltv->wi_val)
|
|
|
|
p2ltv.wi_val = 0x03;
|
|
|
|
else
|
|
|
|
p2ltv.wi_val = 0x90;
|
|
|
|
ltv = &p2ltv;
|
|
|
|
break;
|
|
|
|
case WI_RID_TX_CRYPT_KEY:
|
|
|
|
p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY;
|
|
|
|
p2ltv.wi_len = 2;
|
|
|
|
p2ltv.wi_val = ltv->wi_val;
|
|
|
|
ltv = &p2ltv;
|
|
|
|
break;
|
|
|
|
case WI_RID_DEFLT_CRYPT_KEYS:
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct wi_ltv_str ws;
|
|
|
|
struct wi_ltv_keys *wk = (struct wi_ltv_keys *)ltv;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
ws.wi_len = 4;
|
|
|
|
ws.wi_type = WI_RID_P2_CRYPT_KEY0 + i;
|
|
|
|
memcpy(ws.wi_str, &wk->wi_keys[i].wi_keydat, 5);
|
|
|
|
ws.wi_str[5] = '\0';
|
|
|
|
error = wi_write_record(sc,
|
|
|
|
(struct wi_ltv_gen *)&ws);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
CSR_WRITE_2(sc, WI_DATA1, ltv->wi_len);
|
|
|
|
CSR_WRITE_2(sc, WI_DATA1, ltv->wi_type);
|
|
|
|
|
|
|
|
ptr = <v->wi_val;
|
|
|
|
for (i = 0; i < ltv->wi_len - 1; i++)
|
|
|
|
CSR_WRITE_2(sc, WI_DATA1, ptr[i]);
|
|
|
|
|
|
|
|
if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_WRITE, ltv->wi_type))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wi_seek(sc, id, off, chan)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int id, off, chan;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int selreg, offreg;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
switch (chan) {
|
|
|
|
case WI_BAP0:
|
|
|
|
selreg = WI_SEL0;
|
|
|
|
offreg = WI_OFF0;
|
|
|
|
break;
|
|
|
|
case WI_BAP1:
|
|
|
|
selreg = WI_SEL1;
|
|
|
|
offreg = WI_OFF1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("%s: invalid data path: %x\n",
|
|
|
|
sc->sc_dev.dv_xname, chan);
|
|
|
|
return(EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSR_WRITE_2(sc, selreg, id);
|
|
|
|
CSR_WRITE_2(sc, offreg, off);
|
|
|
|
|
|
|
|
for (i = 0; i < WI_TIMEOUT; i++) {
|
|
|
|
status = CSR_READ_2(sc, offreg);
|
|
|
|
if (!(status & (WI_OFF_BUSY|WI_OFF_ERR)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == WI_TIMEOUT) {
|
|
|
|
printf("%s: timeout in wi_seek to %x/%x; last status %x\n",
|
|
|
|
sc->sc_dev.dv_xname, id, off, status);
|
|
|
|
return(ETIMEDOUT);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wi_read_data(sc, id, off, buf, len)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int id, off;
|
|
|
|
caddr_t buf;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int16_t *ptr;
|
|
|
|
|
|
|
|
if (wi_seek(sc, id, off, WI_BAP1))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
ptr = (u_int16_t *)buf;
|
|
|
|
for (i = 0; i < len / 2; i++)
|
|
|
|
ptr[i] = CSR_READ_2(sc, WI_DATA1);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* According to the comments in the HCF Light code, there is a bug in
|
|
|
|
* the Hermes (or possibly in certain Hermes firmware revisions) where
|
|
|
|
* the chip's internal autoincrement counter gets thrown off during
|
|
|
|
* data writes: the autoincrement is missed, causing one data word to
|
|
|
|
* be overwritten and subsequent words to be written to the wrong memory
|
|
|
|
* locations. The end result is that we could end up transmitting bogus
|
|
|
|
* frames without realizing it. The workaround for this is to write a
|
|
|
|
* couple of extra guard words after the end of the transfer, then
|
|
|
|
* attempt to read then back. If we fail to locate the guard words where
|
|
|
|
* we expect them, we preform the transfer over again.
|
|
|
|
*/
|
|
|
|
static int wi_write_data(sc, id, off, buf, len)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int id, off;
|
|
|
|
caddr_t buf;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int16_t *ptr;
|
|
|
|
|
|
|
|
#ifdef WI_HERMES_AUTOINC_WAR
|
|
|
|
again:
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (wi_seek(sc, id, off, WI_BAP0))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
ptr = (u_int16_t *)buf;
|
|
|
|
for (i = 0; i < (len / 2); i++)
|
|
|
|
CSR_WRITE_2(sc, WI_DATA0, ptr[i]);
|
|
|
|
|
|
|
|
#ifdef WI_HERMES_AUTOINC_WAR
|
|
|
|
CSR_WRITE_2(sc, WI_DATA0, 0x1234);
|
|
|
|
CSR_WRITE_2(sc, WI_DATA0, 0x5678);
|
|
|
|
|
|
|
|
if (wi_seek(sc, id, off + len, WI_BAP0))
|
|
|
|
return(EIO);
|
|
|
|
|
|
|
|
if (CSR_READ_2(sc, WI_DATA0) != 0x1234 ||
|
|
|
|
CSR_READ_2(sc, WI_DATA0) != 0x5678)
|
|
|
|
goto again;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a region of memory inside the NIC and zero
|
|
|
|
* it out.
|
|
|
|
*/
|
|
|
|
static int wi_alloc_nicmem(sc, len, id)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int len;
|
|
|
|
int *id;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (wi_cmd(sc, WI_CMD_ALLOC_MEM, len)) {
|
|
|
|
printf("%s: failed to allocate %d bytes on NIC\n",
|
|
|
|
sc->sc_dev.dv_xname, len);
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < WI_TIMEOUT; i++) {
|
|
|
|
if (CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_ALLOC)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == WI_TIMEOUT) {
|
|
|
|
printf("%s: TIMED OUT in alloc\n", sc->sc_dev.dv_xname);
|
|
|
|
return(ETIMEDOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC);
|
|
|
|
*id = CSR_READ_2(sc, WI_ALLOC_FID);
|
|
|
|
|
|
|
|
if (wi_seek(sc, *id, 0, WI_BAP0)) {
|
|
|
|
printf("%s: seek failed in alloc\n", sc->sc_dev.dv_xname);
|
|
|
|
return(EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len / 2; i++)
|
|
|
|
CSR_WRITE_2(sc, WI_DATA0, 0);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_setmulti(sc)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
{
|
|
|
|
struct ifnet *ifp;
|
|
|
|
int i = 0;
|
|
|
|
struct wi_ltv_mcast mcast;
|
|
|
|
struct ether_multi *enm;
|
|
|
|
struct ether_multistep estep;
|
|
|
|
struct ethercom *ec = &sc->sc_ethercom;
|
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
2000-03-27 15:03:47 +04:00
|
|
|
if ((ifp->if_flags & IFF_PROMISC) != 0) {
|
2000-03-27 11:04:21 +04:00
|
|
|
allmulti:
|
2000-03-27 15:03:47 +04:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
2000-03-27 11:04:21 +04:00
|
|
|
bzero((char *)&mcast, sizeof(mcast));
|
|
|
|
mcast.wi_type = WI_RID_MCAST;
|
|
|
|
mcast.wi_len = ((ETHER_ADDR_LEN / 2) * 16) + 1;
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
wi_write_record(sc, (struct wi_ltv_gen *)&mcast);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
ETHER_FIRST_MULTI(estep, ec, enm);
|
|
|
|
while (enm != NULL) {
|
2000-09-28 10:24:48 +04:00
|
|
|
/* Punt on ranges or too many multicast addresses. */
|
1999-07-15 02:24:07 +04:00
|
|
|
if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
|
2000-03-27 11:04:21 +04:00
|
|
|
ETHER_ADDR_LEN) != 0 ||
|
|
|
|
i >= 16)
|
1999-07-15 02:24:07 +04:00
|
|
|
goto allmulti;
|
2000-09-28 10:24:48 +04:00
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
bcopy(enm->enm_addrlo,
|
|
|
|
(char *)&mcast.wi_mcast[i], ETHER_ADDR_LEN);
|
|
|
|
i++;
|
|
|
|
ETHER_NEXT_MULTI(estep, enm);
|
|
|
|
}
|
|
|
|
|
2000-03-27 15:03:47 +04:00
|
|
|
ifp->if_flags &= ~IFF_ALLMULTI;
|
2000-03-27 11:04:21 +04:00
|
|
|
mcast.wi_type = WI_RID_MCAST;
|
|
|
|
mcast.wi_len = ((ETHER_ADDR_LEN / 2) * i) + 1;
|
1999-07-15 02:24:07 +04:00
|
|
|
wi_write_record(sc, (struct wi_ltv_gen *)&mcast);
|
|
|
|
}
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
static int
|
|
|
|
wi_setdef(sc, wreq)
|
1999-07-15 02:24:07 +04:00
|
|
|
struct wi_softc *sc;
|
|
|
|
struct wi_req *wreq;
|
|
|
|
{
|
|
|
|
struct sockaddr_dl *sdl;
|
|
|
|
struct ifnet *ifp;
|
2000-02-28 02:10:51 +03:00
|
|
|
int error = 0;
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
switch(wreq->wi_type) {
|
|
|
|
case WI_RID_MAC_NODE:
|
|
|
|
sdl = (struct sockaddr_dl *)ifp->if_sadl;
|
|
|
|
bcopy((char *)&wreq->wi_val, (char *)&sc->sc_macaddr,
|
2000-02-28 02:10:51 +03:00
|
|
|
ETHER_ADDR_LEN);
|
1999-07-15 02:24:07 +04:00
|
|
|
bcopy((char *)&wreq->wi_val, LLADDR(sdl), ETHER_ADDR_LEN);
|
|
|
|
break;
|
|
|
|
case WI_RID_PORTTYPE:
|
2000-07-31 07:25:11 +04:00
|
|
|
error = wi_sync_media(sc, wreq->wi_val[0], sc->wi_tx_rate);
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case WI_RID_TX_RATE:
|
2000-07-31 07:25:11 +04:00
|
|
|
error = wi_sync_media(sc, sc->wi_ptype, wreq->wi_val[0]);
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case WI_RID_MAX_DATALEN:
|
|
|
|
sc->wi_max_data_len = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_RTS_THRESH:
|
|
|
|
sc->wi_rts_thresh = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_SYSTEM_SCALE:
|
|
|
|
sc->wi_ap_density = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_CREATE_IBSS:
|
|
|
|
sc->wi_create_ibss = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_OWN_CHNL:
|
|
|
|
sc->wi_channel = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_NODENAME:
|
2000-03-02 08:00:47 +03:00
|
|
|
error = wi_set_ssid(&sc->wi_nodeid,
|
|
|
|
(u_int8_t *)&wreq->wi_val[1], wreq->wi_val[0]);
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case WI_RID_DESIRED_SSID:
|
2000-03-02 08:00:47 +03:00
|
|
|
error = wi_set_ssid(&sc->wi_netid,
|
|
|
|
(u_int8_t *)&wreq->wi_val[1], wreq->wi_val[0]);
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case WI_RID_OWN_SSID:
|
2000-03-02 08:00:47 +03:00
|
|
|
error = wi_set_ssid(&sc->wi_ibssid,
|
|
|
|
(u_int8_t *)&wreq->wi_val[1], wreq->wi_val[0]);
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case WI_RID_PM_ENABLED:
|
|
|
|
sc->wi_pm_enabled = wreq->wi_val[0];
|
|
|
|
break;
|
2000-08-23 23:01:04 +04:00
|
|
|
case WI_RID_MICROWAVE_OVEN:
|
|
|
|
sc->wi_mor_enabled = wreq->wi_val[0];
|
|
|
|
break;
|
1999-07-15 02:24:07 +04:00
|
|
|
case WI_RID_MAX_SLEEP:
|
|
|
|
sc->wi_max_sleep = wreq->wi_val[0];
|
|
|
|
break;
|
2000-02-04 10:48:29 +03:00
|
|
|
case WI_RID_ENCRYPTION:
|
|
|
|
sc->wi_use_wep = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_TX_CRYPT_KEY:
|
|
|
|
sc->wi_tx_key = wreq->wi_val[0];
|
|
|
|
break;
|
|
|
|
case WI_RID_DEFLT_CRYPT_KEYS:
|
|
|
|
bcopy((char *)wreq, (char *)&sc->wi_keys,
|
2000-02-28 02:10:51 +03:00
|
|
|
sizeof(struct wi_ltv_keys));
|
2000-02-04 10:48:29 +03:00
|
|
|
break;
|
1999-07-15 02:24:07 +04:00
|
|
|
default:
|
2000-02-28 02:10:51 +03:00
|
|
|
error = EINVAL;
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
return (error);
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
static int
|
|
|
|
wi_getdef(sc, wreq)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct wi_req *wreq;
|
|
|
|
{
|
|
|
|
struct sockaddr_dl *sdl;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
|
|
|
wreq->wi_len = 2; /* XXX */
|
|
|
|
switch (wreq->wi_type) {
|
|
|
|
case WI_RID_MAC_NODE:
|
|
|
|
wreq->wi_len += ETHER_ADDR_LEN / 2 - 1;
|
|
|
|
sdl = (struct sockaddr_dl *)ifp->if_sadl;
|
|
|
|
bcopy(&sc->sc_macaddr, &wreq->wi_val, ETHER_ADDR_LEN);
|
|
|
|
bcopy(LLADDR(sdl), &wreq->wi_val, ETHER_ADDR_LEN);
|
|
|
|
break;
|
|
|
|
case WI_RID_PORTTYPE:
|
|
|
|
wreq->wi_val[0] = sc->wi_ptype;
|
|
|
|
break;
|
|
|
|
case WI_RID_TX_RATE:
|
|
|
|
wreq->wi_val[0] = sc->wi_tx_rate;
|
|
|
|
break;
|
|
|
|
case WI_RID_MAX_DATALEN:
|
|
|
|
wreq->wi_val[0] = sc->wi_max_data_len;
|
|
|
|
break;
|
|
|
|
case WI_RID_RTS_THRESH:
|
|
|
|
wreq->wi_val[0] = sc->wi_rts_thresh;
|
|
|
|
break;
|
|
|
|
case WI_RID_SYSTEM_SCALE:
|
|
|
|
wreq->wi_val[0] = sc->wi_ap_density;
|
|
|
|
break;
|
|
|
|
case WI_RID_CREATE_IBSS:
|
|
|
|
wreq->wi_val[0] = sc->wi_create_ibss;
|
|
|
|
break;
|
|
|
|
case WI_RID_OWN_CHNL:
|
|
|
|
wreq->wi_val[0] = sc->wi_channel;
|
|
|
|
break;
|
|
|
|
case WI_RID_NODENAME:
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_request_fill_ssid(wreq, &sc->wi_nodeid);
|
2000-02-28 02:10:51 +03:00
|
|
|
break;
|
|
|
|
case WI_RID_DESIRED_SSID:
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_request_fill_ssid(wreq, &sc->wi_netid);
|
2000-02-28 02:10:51 +03:00
|
|
|
break;
|
|
|
|
case WI_RID_OWN_SSID:
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_request_fill_ssid(wreq, &sc->wi_ibssid);
|
2000-02-28 02:10:51 +03:00
|
|
|
break;
|
|
|
|
case WI_RID_PM_ENABLED:
|
|
|
|
wreq->wi_val[0] = sc->wi_pm_enabled;
|
|
|
|
break;
|
2000-08-23 23:01:04 +04:00
|
|
|
case WI_RID_MICROWAVE_OVEN:
|
|
|
|
wreq->wi_val[0] = sc->wi_mor_enabled;
|
|
|
|
break;
|
2000-02-28 02:10:51 +03:00
|
|
|
case WI_RID_MAX_SLEEP:
|
|
|
|
wreq->wi_val[0] = sc->wi_max_sleep;
|
|
|
|
break;
|
2000-05-23 12:25:51 +04:00
|
|
|
case WI_RID_WEP_AVAIL:
|
|
|
|
wreq->wi_val[0] = sc->wi_has_wep;
|
|
|
|
break;
|
2000-02-28 02:10:51 +03:00
|
|
|
case WI_RID_ENCRYPTION:
|
|
|
|
wreq->wi_val[0] = sc->wi_use_wep;
|
|
|
|
break;
|
|
|
|
case WI_RID_TX_CRYPT_KEY:
|
|
|
|
wreq->wi_val[0] = sc->wi_tx_key;
|
|
|
|
break;
|
|
|
|
case WI_RID_DEFLT_CRYPT_KEYS:
|
|
|
|
wreq->wi_len += sizeof(struct wi_ltv_keys) / 2 - 1;
|
|
|
|
bcopy(&sc->wi_keys, wreq, sizeof(struct wi_ltv_keys));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#if 0
|
|
|
|
error = EIO;
|
|
|
|
#else
|
2000-09-28 10:29:41 +04:00
|
|
|
#ifdef WI_DEBUG
|
2000-02-28 02:10:51 +03:00
|
|
|
printf("%s: wi_getdef: unknown request %d\n",
|
|
|
|
sc->sc_dev.dv_xname, wreq->wi_type);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wi_ioctl(ifp, command, data)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
u_long command;
|
|
|
|
caddr_t data;
|
|
|
|
{
|
2000-07-05 06:35:53 +04:00
|
|
|
int s, error = 0;
|
2000-02-28 02:10:51 +03:00
|
|
|
struct wi_softc *sc = ifp->if_softc;
|
1999-07-15 02:24:07 +04:00
|
|
|
struct wi_req wreq;
|
|
|
|
struct ifreq *ifr;
|
2000-02-04 10:48:29 +03:00
|
|
|
struct proc *p = curproc;
|
2000-07-05 06:35:53 +04:00
|
|
|
struct ieee80211_nwid nwid;
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2000-10-12 08:50:58 +04:00
|
|
|
s = splnet();
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
ifr = (struct ifreq *)data;
|
1999-09-10 04:30:59 +04:00
|
|
|
switch (command) {
|
2000-03-02 08:00:47 +03:00
|
|
|
case SIOCSIFMEDIA:
|
|
|
|
case SIOCGIFMEDIA:
|
|
|
|
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);
|
|
|
|
break;
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
case SIOCGWAVELAN:
|
|
|
|
error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
if (wreq.wi_type == WI_RID_IFACE_STATS) {
|
|
|
|
bcopy((char *)&sc->wi_stats, (char *)&wreq.wi_val,
|
|
|
|
sizeof(sc->wi_stats));
|
|
|
|
wreq.wi_len = (sizeof(sc->wi_stats) / 2) + 1;
|
2000-02-04 10:48:29 +03:00
|
|
|
} else if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS) {
|
|
|
|
/* For non-root user, return all-zeroes keys */
|
|
|
|
if (suser(p->p_ucred, &p->p_acflag))
|
|
|
|
bzero((char *)&wreq,
|
2000-02-28 02:10:51 +03:00
|
|
|
sizeof(struct wi_ltv_keys));
|
2000-02-04 10:48:29 +03:00
|
|
|
else
|
|
|
|
bcopy((char *)&sc->wi_keys, (char *)&wreq,
|
2000-02-28 02:10:51 +03:00
|
|
|
sizeof(struct wi_ltv_keys));
|
1999-07-15 02:24:07 +04:00
|
|
|
} else {
|
2000-02-28 02:10:51 +03:00
|
|
|
if (sc->sc_enabled == 0)
|
|
|
|
error = wi_getdef(sc, &wreq);
|
|
|
|
else if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq))
|
1999-07-15 02:24:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
}
|
2000-02-28 02:10:51 +03:00
|
|
|
if (error == 0)
|
|
|
|
error = copyout(&wreq, ifr->ifr_data, sizeof(wreq));
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
case SIOCSWAVELAN:
|
2000-02-04 10:48:29 +03:00
|
|
|
error = suser(p->p_ucred, &p->p_acflag);
|
|
|
|
if (error)
|
|
|
|
break;
|
1999-07-15 02:24:07 +04:00
|
|
|
error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
if (wreq.wi_type == WI_RID_IFACE_STATS) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
} else if (wreq.wi_type == WI_RID_MGMT_XMIT) {
|
|
|
|
error = wi_mgmt_xmit(sc, (caddr_t)&wreq.wi_val,
|
|
|
|
wreq.wi_len);
|
|
|
|
} else {
|
2000-02-28 02:10:51 +03:00
|
|
|
if (sc->sc_enabled != 0)
|
|
|
|
error = wi_write_record(sc,
|
|
|
|
(struct wi_ltv_gen *)&wreq);
|
|
|
|
if (error == 0)
|
|
|
|
error = wi_setdef(sc, &wreq);
|
|
|
|
if (error == 0 && sc->sc_enabled != 0)
|
|
|
|
/* Reinitialize WaveLAN. */
|
2000-10-12 06:24:08 +04:00
|
|
|
wi_init(ifp);
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-03-02 08:00:47 +03:00
|
|
|
case SIOCG80211NWID:
|
2000-07-05 06:35:53 +04:00
|
|
|
if (sc->sc_enabled == 0) {
|
2000-06-06 18:01:40 +04:00
|
|
|
/* Return the desired ID */
|
2000-07-05 06:35:53 +04:00
|
|
|
error = copyout(&sc->wi_netid, ifr->ifr_data,
|
|
|
|
sizeof(sc->wi_netid));
|
|
|
|
} else {
|
2000-03-02 08:00:47 +03:00
|
|
|
wreq.wi_type = WI_RID_CURRENT_SSID;
|
|
|
|
wreq.wi_len = WI_MAX_DATALEN;
|
|
|
|
if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq) ||
|
|
|
|
wreq.wi_val[0] > IEEE80211_NWID_LEN)
|
|
|
|
error = EINVAL;
|
2000-03-02 13:29:22 +03:00
|
|
|
else {
|
2000-07-05 06:35:53 +04:00
|
|
|
wi_set_ssid(&nwid, (u_int8_t *)&wreq.wi_val[1],
|
2000-03-02 13:29:22 +03:00
|
|
|
wreq.wi_val[0]);
|
2000-07-05 06:35:53 +04:00
|
|
|
error = copyout(&nwid, ifr->ifr_data,
|
|
|
|
sizeof(nwid));
|
2000-03-02 13:29:22 +03:00
|
|
|
}
|
|
|
|
}
|
2000-03-02 08:00:47 +03:00
|
|
|
break;
|
|
|
|
case SIOCS80211NWID:
|
2000-07-05 06:35:53 +04:00
|
|
|
error = copyin(ifr->ifr_data, &nwid, sizeof(nwid));
|
2000-03-02 08:00:47 +03:00
|
|
|
if (error != 0)
|
|
|
|
break;
|
2000-07-05 06:35:53 +04:00
|
|
|
if (nwid.i_len > IEEE80211_NWID_LEN) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sc->wi_netid.i_len == nwid.i_len &&
|
|
|
|
memcmp(sc->wi_netid.i_nwid, nwid.i_nwid, nwid.i_len) == 0)
|
2000-03-02 08:00:47 +03:00
|
|
|
break;
|
2000-07-05 06:35:53 +04:00
|
|
|
wi_set_ssid(&sc->wi_netid, nwid.i_nwid, nwid.i_len);
|
2000-03-02 08:54:22 +03:00
|
|
|
if (sc->sc_enabled != 0)
|
|
|
|
/* Reinitialize WaveLAN. */
|
2000-10-12 06:24:08 +04:00
|
|
|
wi_init(ifp);
|
2000-03-02 08:00:47 +03:00
|
|
|
break;
|
2000-07-21 08:48:55 +04:00
|
|
|
case SIOCS80211NWKEY:
|
|
|
|
error = wi_set_nwkey(sc, (struct ieee80211_nwkey *)data);
|
|
|
|
break;
|
|
|
|
case SIOCG80211NWKEY:
|
|
|
|
error = wi_get_nwkey(sc, (struct ieee80211_nwkey *)data);
|
|
|
|
break;
|
2000-12-12 07:04:29 +03:00
|
|
|
case SIOCS80211POWER:
|
|
|
|
error = wi_set_pm(sc, (struct ieee80211_power *)data);
|
|
|
|
break;
|
|
|
|
case SIOCG80211POWER:
|
|
|
|
error = wi_get_pm(sc, (struct ieee80211_power *)data);
|
|
|
|
break;
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
default:
|
2000-10-12 06:24:08 +04:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
|
|
|
if (error == ENETRESET) {
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
/*
|
|
|
|
* Multicast list has changed. Set the
|
|
|
|
* hardware filter accordingly.
|
|
|
|
*/
|
|
|
|
wi_setmulti(sc);
|
|
|
|
}
|
|
|
|
error = 0;
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
return (error);
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
2000-10-12 06:24:08 +04:00
|
|
|
static int
|
|
|
|
wi_init(ifp)
|
|
|
|
struct ifnet *ifp;
|
1999-07-15 02:24:07 +04:00
|
|
|
{
|
2000-10-12 06:24:08 +04:00
|
|
|
struct wi_softc *sc = ifp->if_softc;
|
2000-03-02 08:00:47 +03:00
|
|
|
struct wi_req wreq;
|
2000-02-28 02:10:51 +03:00
|
|
|
struct wi_ltv_macaddr mac;
|
2000-10-12 08:50:58 +04:00
|
|
|
int error, id = 0;
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-10-12 06:24:08 +04:00
|
|
|
if ((error = wi_enable(sc)) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
wi_stop(ifp, 0);
|
2000-02-28 02:10:51 +03:00
|
|
|
wi_reset(sc);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Program max data length. */
|
|
|
|
WI_SETVAL(WI_RID_MAX_DATALEN, sc->wi_max_data_len);
|
|
|
|
|
|
|
|
/* Enable/disable IBSS creation. */
|
|
|
|
WI_SETVAL(WI_RID_CREATE_IBSS, sc->wi_create_ibss);
|
|
|
|
|
|
|
|
/* Set the port type. */
|
|
|
|
WI_SETVAL(WI_RID_PORTTYPE, sc->wi_ptype);
|
|
|
|
|
|
|
|
/* Program the RTS/CTS threshold. */
|
|
|
|
WI_SETVAL(WI_RID_RTS_THRESH, sc->wi_rts_thresh);
|
|
|
|
|
|
|
|
/* Program the TX rate */
|
|
|
|
WI_SETVAL(WI_RID_TX_RATE, sc->wi_tx_rate);
|
|
|
|
|
|
|
|
/* Access point density */
|
|
|
|
WI_SETVAL(WI_RID_SYSTEM_SCALE, sc->wi_ap_density);
|
|
|
|
|
|
|
|
/* Power Management Enabled */
|
|
|
|
WI_SETVAL(WI_RID_PM_ENABLED, sc->wi_pm_enabled);
|
|
|
|
|
|
|
|
/* Power Managment Max Sleep */
|
|
|
|
WI_SETVAL(WI_RID_MAX_SLEEP, sc->wi_max_sleep);
|
|
|
|
|
|
|
|
/* Specify the IBSS name */
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_write_ssid(sc, WI_RID_OWN_SSID, &wreq, &sc->wi_ibssid);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Specify the network name */
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_write_ssid(sc, WI_RID_DESIRED_SSID, &wreq, &sc->wi_netid);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Specify the frequency to use */
|
|
|
|
WI_SETVAL(WI_RID_OWN_CHNL, sc->wi_channel);
|
|
|
|
|
|
|
|
/* Program the nodename. */
|
2000-03-02 08:00:47 +03:00
|
|
|
wi_write_ssid(sc, WI_RID_NODENAME, &wreq, &sc->wi_nodeid);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/* Set our MAC address. */
|
|
|
|
mac.wi_len = 4;
|
|
|
|
mac.wi_type = WI_RID_MAC_NODE;
|
|
|
|
memcpy(&mac.wi_mac_addr, sc->sc_macaddr, ETHER_ADDR_LEN);
|
|
|
|
wi_write_record(sc, (struct wi_ltv_gen *)&mac);
|
|
|
|
|
2000-02-04 10:48:29 +03:00
|
|
|
/* Configure WEP. */
|
|
|
|
if (sc->wi_has_wep) {
|
|
|
|
WI_SETVAL(WI_RID_ENCRYPTION, sc->wi_use_wep);
|
|
|
|
WI_SETVAL(WI_RID_TX_CRYPT_KEY, sc->wi_tx_key);
|
|
|
|
sc->wi_keys.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1;
|
|
|
|
sc->wi_keys.wi_type = WI_RID_DEFLT_CRYPT_KEYS;
|
|
|
|
wi_write_record(sc, (struct wi_ltv_gen *)&sc->wi_keys);
|
|
|
|
}
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
/* Initialize promisc mode. */
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
WI_SETVAL(WI_RID_PROMISC, 1);
|
|
|
|
} else {
|
|
|
|
WI_SETVAL(WI_RID_PROMISC, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set multicast filter. */
|
|
|
|
wi_setmulti(sc);
|
|
|
|
|
|
|
|
/* Enable desired port */
|
2000-02-28 02:10:51 +03:00
|
|
|
wi_cmd(sc, WI_CMD_ENABLE | sc->wi_portnum, 0);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-10-12 07:29:59 +04:00
|
|
|
if ((error = wi_alloc_nicmem(sc,
|
|
|
|
1518 + sizeof(struct wi_frame) + 8, &id)) != 0) {
|
1999-07-15 02:24:07 +04:00
|
|
|
printf("%s: tx buffer allocation failed\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-10-12 07:29:59 +04:00
|
|
|
goto out;
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
sc->wi_tx_data_id = id;
|
|
|
|
|
2000-10-12 07:29:59 +04:00
|
|
|
if ((error = wi_alloc_nicmem(sc,
|
|
|
|
1518 + sizeof(struct wi_frame) + 8, &id)) != 0) {
|
1999-07-15 02:24:07 +04:00
|
|
|
printf("%s: mgmt. buffer allocation failed\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-10-12 07:29:59 +04:00
|
|
|
goto out;
|
|
|
|
}
|
1999-07-15 02:24:07 +04:00
|
|
|
sc->wi_tx_mgmt_id = id;
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
/* Enable interrupts */
|
1999-07-15 02:24:07 +04:00
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
1999-07-15 02:24:07 +04:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->wi_inquire_ch, hz * 60, wi_inquire, sc);
|
2000-10-12 06:24:08 +04:00
|
|
|
|
|
|
|
out:
|
|
|
|
if (error) {
|
|
|
|
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
|
|
|
|
ifp->if_timer = 0;
|
|
|
|
printf("%s: interface not running\n", sc->sc_dev.dv_xname);
|
|
|
|
}
|
|
|
|
return (error);
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_start(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct mbuf *m0;
|
|
|
|
struct wi_frame tx_frame;
|
|
|
|
struct ether_header *eh;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
sc = ifp->if_softc;
|
|
|
|
|
|
|
|
if (ifp->if_flags & IFF_OACTIVE)
|
|
|
|
return;
|
|
|
|
|
2000-12-14 09:27:23 +03:00
|
|
|
IFQ_DEQUEUE(&ifp->if_snd, m0);
|
1999-07-15 02:24:07 +04:00
|
|
|
if (m0 == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bzero((char *)&tx_frame, sizeof(tx_frame));
|
|
|
|
id = sc->wi_tx_data_id;
|
|
|
|
eh = mtod(m0, struct ether_header *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use RFC1042 encoding for IP and ARP datagrams,
|
|
|
|
* 802.3 for anything else.
|
|
|
|
*/
|
|
|
|
if (ntohs(eh->ether_type) == ETHERTYPE_IP ||
|
|
|
|
ntohs(eh->ether_type) == ETHERTYPE_ARP ||
|
1999-09-10 04:30:59 +04:00
|
|
|
ntohs(eh->ether_type) == ETHERTYPE_REVARP ||
|
|
|
|
ntohs(eh->ether_type) == ETHERTYPE_IPV6) {
|
2000-12-20 07:36:26 +03:00
|
|
|
bcopy((char *)&eh->ether_dhost,
|
|
|
|
(char *)&tx_frame.wi_addr1, ETHER_ADDR_LEN);
|
|
|
|
bcopy((char *)&eh->ether_shost,
|
|
|
|
(char *)&tx_frame.wi_addr2, ETHER_ADDR_LEN);
|
|
|
|
bcopy((char *)&eh->ether_dhost,
|
|
|
|
(char *)&tx_frame.wi_dst_addr, ETHER_ADDR_LEN);
|
|
|
|
bcopy((char *)&eh->ether_shost,
|
|
|
|
(char *)&tx_frame.wi_src_addr, ETHER_ADDR_LEN);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
tx_frame.wi_dat_len = m0->m_pkthdr.len - WI_SNAPHDR_LEN;
|
2000-12-20 07:36:26 +03:00
|
|
|
tx_frame.wi_frame_ctl = WI_FTYPE_DATA;
|
1999-07-15 02:24:07 +04:00
|
|
|
tx_frame.wi_dat[0] = htons(WI_SNAP_WORD0);
|
|
|
|
tx_frame.wi_dat[1] = htons(WI_SNAP_WORD1);
|
|
|
|
tx_frame.wi_len = htons(m0->m_pkthdr.len - WI_SNAPHDR_LEN);
|
|
|
|
tx_frame.wi_type = eh->ether_type;
|
|
|
|
|
|
|
|
m_copydata(m0, sizeof(struct ether_header),
|
|
|
|
m0->m_pkthdr.len - sizeof(struct ether_header),
|
|
|
|
(caddr_t)&sc->wi_txbuf);
|
|
|
|
|
|
|
|
wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
|
|
|
|
sizeof(struct wi_frame));
|
|
|
|
wi_write_data(sc, id, WI_802_11_OFFSET, (caddr_t)&sc->wi_txbuf,
|
|
|
|
(m0->m_pkthdr.len - sizeof(struct ether_header)) + 2);
|
|
|
|
} else {
|
|
|
|
tx_frame.wi_dat_len = m0->m_pkthdr.len;
|
|
|
|
|
|
|
|
m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&sc->wi_txbuf);
|
|
|
|
|
|
|
|
wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
|
|
|
|
sizeof(struct wi_frame));
|
|
|
|
wi_write_data(sc, id, WI_802_3_OFFSET, (caddr_t)&sc->wi_txbuf,
|
|
|
|
m0->m_pkthdr.len + 2);
|
|
|
|
}
|
|
|
|
|
1999-07-15 03:07:29 +04:00
|
|
|
#if NBPFILTER > 0
|
1999-07-15 02:24:07 +04:00
|
|
|
/*
|
2000-08-18 08:11:48 +04:00
|
|
|
* If there's a BPF listener, bounce a copy of
|
1999-07-15 02:24:07 +04:00
|
|
|
* this frame to him.
|
|
|
|
*/
|
|
|
|
if (ifp->if_bpf)
|
1999-07-15 03:07:29 +04:00
|
|
|
bpf_mtap(ifp->if_bpf, m0);
|
1999-07-15 02:24:07 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
m_freem(m0);
|
|
|
|
|
|
|
|
if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id))
|
|
|
|
printf("%s: xmit failed\n", sc->sc_dev.dv_xname);
|
|
|
|
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a timeout in case the chip goes out to lunch.
|
|
|
|
*/
|
|
|
|
ifp->if_timer = 5;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wi_mgmt_xmit(sc, data, len)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
caddr_t data;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
struct wi_frame tx_frame;
|
|
|
|
int id;
|
2000-12-20 07:36:26 +03:00
|
|
|
struct wi_80211_hdr *hdr;
|
1999-07-15 02:24:07 +04:00
|
|
|
caddr_t dptr;
|
|
|
|
|
2000-12-20 07:36:26 +03:00
|
|
|
hdr = (struct wi_80211_hdr *)data;
|
|
|
|
dptr = data + sizeof(struct wi_80211_hdr);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
bzero((char *)&tx_frame, sizeof(tx_frame));
|
|
|
|
id = sc->wi_tx_mgmt_id;
|
|
|
|
|
2000-12-20 07:36:26 +03:00
|
|
|
bcopy((char *)hdr, (char *)&tx_frame.wi_frame_ctl,
|
|
|
|
sizeof(struct wi_80211_hdr));
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
tx_frame.wi_dat_len = len - WI_SNAPHDR_LEN;
|
|
|
|
tx_frame.wi_len = htons(len - WI_SNAPHDR_LEN);
|
|
|
|
|
|
|
|
wi_write_data(sc, id, 0, (caddr_t)&tx_frame, sizeof(struct wi_frame));
|
|
|
|
wi_write_data(sc, id, WI_802_11_OFFSET_RAW, dptr,
|
2000-12-20 07:36:26 +03:00
|
|
|
(len - sizeof(struct wi_80211_hdr)) + 2);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) {
|
|
|
|
printf("%s: xmit failed\n", sc->sc_dev.dv_xname);
|
|
|
|
return(EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2000-10-12 06:24:08 +04:00
|
|
|
static void
|
|
|
|
wi_stop(ifp, disable)
|
|
|
|
struct ifnet *ifp;
|
1999-07-15 02:24:07 +04:00
|
|
|
{
|
2000-10-12 06:24:08 +04:00
|
|
|
struct wi_softc *sc = ifp->if_softc;
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
wi_cmd(sc, WI_CMD_DISABLE|sc->wi_portnum, 0);
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&sc->wi_inquire_ch);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
2000-10-12 06:24:08 +04:00
|
|
|
if (disable)
|
|
|
|
wi_disable(sc);
|
|
|
|
|
2000-02-28 02:10:51 +03:00
|
|
|
ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
|
|
|
|
ifp->if_timer = 0;
|
1999-07-15 02:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wi_watchdog(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc;
|
|
|
|
|
|
|
|
sc = ifp->if_softc;
|
|
|
|
|
|
|
|
printf("%s: device timeout\n", sc->sc_dev.dv_xname);
|
|
|
|
|
2000-10-12 06:24:08 +04:00
|
|
|
wi_init(ifp);
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
ifp->if_oerrors++;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-07-15 03:07:29 +04:00
|
|
|
static void wi_shutdown(arg)
|
1999-07-15 02:24:07 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc;
|
|
|
|
|
|
|
|
sc = arg;
|
1999-07-15 03:07:29 +04:00
|
|
|
wi_disable(sc);
|
1999-07-15 02:24:07 +04:00
|
|
|
return;
|
|
|
|
}
|
2000-02-12 19:08:04 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
wi_activate(self, act)
|
|
|
|
struct device *self;
|
|
|
|
enum devact act;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = (struct wi_softc *)self;
|
|
|
|
int rv = 0, s;
|
|
|
|
|
|
|
|
s = splnet();
|
|
|
|
switch (act) {
|
|
|
|
case DVACT_ACTIVATE:
|
|
|
|
rv = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DVACT_DEACTIVATE:
|
|
|
|
if_deactivate(&sc->sc_ethercom.ec_if);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return (rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wi_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = (struct wi_softc *)self;
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
2000-03-06 13:31:27 +03:00
|
|
|
if (sc->sc_iowin == -1)
|
|
|
|
/* Nothing to detach. */
|
|
|
|
return (0);
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&sc->wi_inquire_ch);
|
2000-03-06 13:31:27 +03:00
|
|
|
if (sc->sc_sdhook != NULL)
|
|
|
|
shutdownhook_disestablish(sc->sc_sdhook);
|
2000-02-12 19:08:04 +03:00
|
|
|
wi_disable(sc);
|
|
|
|
|
2000-03-02 08:00:47 +03:00
|
|
|
/* Delete all remaining media. */
|
|
|
|
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
|
|
|
|
|
2000-08-28 17:25:22 +04:00
|
|
|
#if NRND > 0
|
|
|
|
rnd_detach_source(&sc->rnd_source);
|
2000-02-12 19:08:04 +03:00
|
|
|
#endif
|
2000-03-06 13:31:27 +03:00
|
|
|
ether_ifdetach(ifp);
|
|
|
|
if_detach(ifp);
|
2000-02-12 19:08:04 +03:00
|
|
|
|
2000-03-06 13:31:27 +03:00
|
|
|
/* Unmap and free our i/o windows */
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
|
2000-02-12 19:08:04 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
2000-03-02 08:00:47 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
wi_set_ssid(ws, id, len)
|
2000-07-05 06:35:53 +04:00
|
|
|
struct ieee80211_nwid *ws;
|
2000-03-02 08:00:47 +03:00
|
|
|
u_int8_t *id;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (len > IEEE80211_NWID_LEN)
|
|
|
|
return (EINVAL);
|
2000-07-05 06:35:53 +04:00
|
|
|
ws->i_len = len;
|
|
|
|
memcpy(ws->i_nwid, id, len);
|
2000-03-02 08:00:47 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wi_request_fill_ssid(wreq, ws)
|
|
|
|
struct wi_req *wreq;
|
2000-07-05 06:35:53 +04:00
|
|
|
struct ieee80211_nwid *ws;
|
2000-03-02 08:00:47 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
memset(&wreq->wi_val[0], 0, sizeof(wreq->wi_val));
|
2000-07-05 06:35:53 +04:00
|
|
|
wreq->wi_val[0] = ws->i_len;
|
2000-03-02 08:54:22 +03:00
|
|
|
wreq->wi_len = roundup(wreq->wi_val[0], 2) / 2 + 2;
|
2000-07-05 06:35:53 +04:00
|
|
|
memcpy(&wreq->wi_val[1], ws->i_nwid, wreq->wi_val[0]);
|
2000-03-02 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wi_write_ssid(sc, type, wreq, ws)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int type;
|
|
|
|
struct wi_req *wreq;
|
2000-07-05 06:35:53 +04:00
|
|
|
struct ieee80211_nwid *ws;
|
2000-03-02 08:00:47 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
wreq->wi_type = type;
|
|
|
|
wi_request_fill_ssid(wreq, ws);
|
|
|
|
return (wi_write_record(sc, (struct wi_ltv_gen *)wreq));
|
|
|
|
}
|
|
|
|
|
2000-07-31 07:25:11 +04:00
|
|
|
static int
|
|
|
|
wi_sync_media(sc, ptype, txrate)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
int ptype;
|
|
|
|
int txrate;
|
|
|
|
{
|
|
|
|
int media = sc->sc_media.ifm_cur->ifm_media;
|
|
|
|
int options = IFM_OPTIONS(media);
|
|
|
|
int subtype;
|
|
|
|
|
|
|
|
switch (txrate) {
|
|
|
|
case 1:
|
|
|
|
subtype = IFM_IEEE80211_DS1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
subtype = IFM_IEEE80211_DS2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
subtype = IFM_AUTO;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
subtype = IFM_IEEE80211_DS11;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
subtype = IFM_MANUAL; /* Unable to represent */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (ptype) {
|
|
|
|
case WI_PORTTYPE_ADHOC:
|
|
|
|
options |= IFM_IEEE80211_ADHOC;
|
|
|
|
break;
|
|
|
|
case WI_PORTTYPE_BSS:
|
|
|
|
options &= ~IFM_IEEE80211_ADHOC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
subtype = IFM_MANUAL; /* Unable to represent */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
media = IFM_MAKEWORD(IFM_TYPE(media), subtype, options,
|
|
|
|
IFM_INST(media));
|
|
|
|
if (ifmedia_match(&sc->sc_media, media, sc->sc_media.ifm_mask) == NULL)
|
|
|
|
return (EINVAL);
|
|
|
|
ifmedia_set(&sc->sc_media, media);
|
|
|
|
sc->wi_ptype = ptype;
|
|
|
|
sc->wi_tx_rate = txrate;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-03-02 08:00:47 +03:00
|
|
|
static int
|
|
|
|
wi_media_change(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = ifp->if_softc;
|
|
|
|
int otype = sc->wi_ptype;
|
|
|
|
int orate = sc->wi_tx_rate;
|
|
|
|
|
|
|
|
if ((sc->sc_media.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
|
|
|
|
sc->wi_ptype = WI_PORTTYPE_ADHOC;
|
|
|
|
else
|
|
|
|
sc->wi_ptype = WI_PORTTYPE_BSS;
|
|
|
|
|
|
|
|
switch (IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media)) {
|
|
|
|
case IFM_IEEE80211_DS1:
|
|
|
|
sc->wi_tx_rate = 1;
|
|
|
|
break;
|
|
|
|
case IFM_IEEE80211_DS2:
|
|
|
|
sc->wi_tx_rate = 2;
|
|
|
|
break;
|
|
|
|
case IFM_AUTO:
|
|
|
|
sc->wi_tx_rate = 3;
|
|
|
|
break;
|
|
|
|
case IFM_IEEE80211_DS11:
|
|
|
|
sc->wi_tx_rate = 11;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
if (otype != sc->wi_ptype ||
|
|
|
|
orate != sc->wi_tx_rate)
|
2000-10-12 06:24:08 +04:00
|
|
|
wi_init(ifp);
|
2000-03-02 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
2000-03-07 00:02:37 +03:00
|
|
|
ifp->if_baudrate = ifmedia_baudrate(sc->sc_media.ifm_cur->ifm_media);
|
|
|
|
|
2000-03-02 08:00:47 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wi_media_status(ifp, imr)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifmediareq *imr;
|
|
|
|
{
|
|
|
|
struct wi_softc *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
if (sc->sc_enabled == 0) {
|
|
|
|
imr->ifm_active = IFM_IEEE80211|IFM_NONE;
|
|
|
|
imr->ifm_status = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
imr->ifm_active = sc->sc_media.ifm_cur->ifm_media;
|
|
|
|
imr->ifm_status = IFM_AVALID|IFM_ACTIVE;
|
|
|
|
}
|
2000-07-21 08:48:55 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
wi_set_nwkey(sc, nwkey)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct ieee80211_nwkey *nwkey;
|
|
|
|
{
|
|
|
|
int i, len, error;
|
|
|
|
struct wi_req wreq;
|
|
|
|
struct wi_ltv_keys *wk = (struct wi_ltv_keys *)&wreq;
|
|
|
|
|
|
|
|
if (!sc->wi_has_wep)
|
|
|
|
return ENODEV;
|
|
|
|
if (nwkey->i_defkid <= 0 ||
|
|
|
|
nwkey->i_defkid > IEEE80211_WEP_NKID)
|
|
|
|
return EINVAL;
|
|
|
|
memcpy(wk, &sc->wi_keys, sizeof(*wk));
|
|
|
|
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
|
|
|
if (nwkey->i_key[i].i_keydat == NULL)
|
|
|
|
continue;
|
|
|
|
len = nwkey->i_key[i].i_keylen;
|
|
|
|
if (len > sizeof(wk->wi_keys[i].wi_keydat))
|
|
|
|
return EINVAL;
|
|
|
|
error = copyin(nwkey->i_key[i].i_keydat,
|
|
|
|
wk->wi_keys[i].wi_keydat, len);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
wk->wi_keys[i].wi_keylen = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
wk->wi_len = (sizeof(*wk) / 2) + 1;
|
|
|
|
wk->wi_type = WI_RID_DEFLT_CRYPT_KEYS;
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
error = wi_write_record(sc, (struct wi_ltv_gen *)&wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
error = wi_setdef(sc, &wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
wreq.wi_len = 2;
|
|
|
|
wreq.wi_type = WI_RID_TX_CRYPT_KEY;
|
|
|
|
wreq.wi_val[0] = nwkey->i_defkid - 1;
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
error = wi_write_record(sc, (struct wi_ltv_gen *)&wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
error = wi_setdef(sc, &wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
wreq.wi_type = WI_RID_ENCRYPTION;
|
|
|
|
wreq.wi_val[0] = nwkey->i_wepon;
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
error = wi_write_record(sc, (struct wi_ltv_gen *)&wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
error = wi_setdef(sc, &wreq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (sc->sc_enabled != 0)
|
2000-10-12 06:24:08 +04:00
|
|
|
wi_init(&sc->sc_ethercom.ec_if);
|
2000-07-21 08:48:55 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wi_get_nwkey(sc, nwkey)
|
|
|
|
struct wi_softc *sc;
|
|
|
|
struct ieee80211_nwkey *nwkey;
|
|
|
|
{
|
|
|
|
int i, len, error;
|
|
|
|
struct wi_ltv_keys *wk = &sc->wi_keys;
|
|
|
|
|
|
|
|
if (!sc->wi_has_wep)
|
|
|
|
return ENODEV;
|
|
|
|
nwkey->i_wepon = sc->wi_use_wep;
|
|
|
|
nwkey->i_defkid = sc->wi_tx_key + 1;
|
|
|
|
|
|
|
|
/* do not show any keys to non-root user */
|
|
|
|
error = suser(curproc->p_ucred, &curproc->p_acflag);
|
|
|
|
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
|
|
|
if (nwkey->i_key[i].i_keydat == NULL)
|
|
|
|
continue;
|
|
|
|
/* error holds results of suser() for the first time */
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
len = wk->wi_keys[i].wi_keylen;
|
|
|
|
if (nwkey->i_key[i].i_keylen < len)
|
|
|
|
return ENOSPC;
|
|
|
|
nwkey->i_key[i].i_keylen = len;
|
|
|
|
error = copyout(wk->wi_keys[i].wi_keydat,
|
|
|
|
nwkey->i_key[i].i_keydat, len);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-12 07:04:29 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
wi_set_pm(struct wi_softc *sc, struct ieee80211_power *power)
|
|
|
|
{
|
|
|
|
|
|
|
|
sc->wi_pm_enabled = power->i_enabled;
|
|
|
|
sc->wi_max_sleep = power->i_maxsleep;
|
|
|
|
|
|
|
|
if (sc->sc_enabled)
|
|
|
|
return (wi_init(&sc->sc_ethercom.ec_if));
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wi_get_pm(struct wi_softc *sc, struct ieee80211_power *power)
|
|
|
|
{
|
|
|
|
|
|
|
|
power->i_enabled = sc->wi_pm_enabled;
|
|
|
|
power->i_maxsleep = sc->wi_max_sleep;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|