diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-15 02:40:37 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-15 02:40:37 +0000 |
commit | fe94e414308b31ce821f7118a9adbdcc66c14d75 (patch) | |
tree | 5eb1cd2a861c8dc7538beb0ce1dda086330f72e8 /sys | |
parent | 8180cc247a212c589024e0d52a345ee24765eff1 (diff) |
Split wi(4) into bus-dependent and bus-independent bits similar to
an(4) -- no real code changes at this point.
Rename if_wavelan_ieee.h to if_wi_ieee.h while I'm at it and
create an if_wivar.h similar to NetBSD.
PCI adaptors exist that are not true PCMCIA controllers so
wi(4) @ PCI is possible (though the code is not working yet ;-).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/files | 5 | ||||
-rw-r--r-- | sys/dev/ic/if_wi.c (renamed from sys/dev/pcmcia/if_wi.c) | 325 | ||||
-rw-r--r-- | sys/dev/ic/if_wi_ieee.h (renamed from sys/dev/pcmcia/if_wavelan_ieee.h) | 16 | ||||
-rw-r--r-- | sys/dev/ic/if_wireg.h (renamed from sys/dev/pcmcia/if_wireg.h) | 101 | ||||
-rw-r--r-- | sys/dev/ic/if_wivar.h | 74 | ||||
-rw-r--r-- | sys/dev/pcmcia/files.pcmcia | 7 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wi_pcmcia.c | 377 |
7 files changed, 485 insertions, 420 deletions
diff --git a/sys/conf/files b/sys/conf/files index abdaaaa8172..87fb7fb8914 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.199 2001/05/13 15:39:26 deraadt Exp $ +# $OpenBSD: files,v 1.200 2001/05/15 02:40:34 millert Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -155,7 +155,8 @@ device ep: ether, ifnet, ifmedia, mii file dev/ic/elink3.c ep # WaveLan -# device wlp: ether, ifnet +device wi: ether, ifnet, ifmedia +file dev/ic/if_wi.c wi # Aironet 802.11 DS Ethernet controller device an: ether, ifnet, ifmedia diff --git a/sys/dev/pcmcia/if_wi.c b/sys/dev/ic/if_wi.c index d36b9a65325..5f71bda0099 100644 --- a/sys/dev/pcmcia/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.32 2001/05/14 21:45:25 mickey Exp $ */ +/* $OpenBSD: if_wi.c,v 1.1 2001/05/15 02:40:35 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -35,9 +35,9 @@ */ /* - * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD. + * Lucent WaveLAN/IEEE 802.11 driver for OpenBSD. * - * Written by Bill Paul <wpaul@ctr.columbia.edu> + * Originally written by Bill Paul <wpaul@ctr.columbia.edu> * Electrical Engineering Department * Columbia University, New York City */ @@ -57,13 +57,6 @@ * 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. */ #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ @@ -100,19 +93,13 @@ #include <machine/bus.h> -#include <i386/isa/icu.h> - -#include <dev/pcmcia/pcmciareg.h> -#include <dev/pcmcia/pcmciavar.h> -#include <dev/pcmcia/pcmciadevs.h> -#include <dev/pcmcia/if_wireg.h> -#include <dev/pcmcia/if_wavelan_ieee.h> +#include <dev/ic/if_wireg.h> +#include <dev/ic/if_wi_ieee.h> +#include <dev/ic/if_wivar.h> #define BPF_MTAP(if,mbuf) bpf_mtap((if)->if_bpf, (mbuf)) #define BPFATTACH(if_bpf,if,dlt,sz) #define STATIC -#define WI_PRT_FMT "%s" -#define WI_PRT_ARG(sc) (sc)->sc_dev.dv_xname #ifdef WIDEBUG @@ -133,7 +120,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.32 2001/05/14 21:45:25 mickey Exp $"; + "$OpenBSD: if_wi.c,v 1.1 2001/05/15 02:40:35 millert Exp $"; #endif /* lint */ #ifdef foo @@ -142,9 +129,7 @@ static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 }; STATIC void wi_reset __P((struct wi_softc *)); STATIC int wi_ioctl __P((struct ifnet *, u_long, caddr_t)); -STATIC void wi_init __P((void *)); STATIC void wi_start __P((struct ifnet *)); -STATIC void wi_stop __P((struct wi_softc *)); STATIC void wi_watchdog __P((struct ifnet *)); STATIC void wi_shutdown __P((void *)); STATIC void wi_rxeof __P((struct wi_softc *)); @@ -165,243 +150,29 @@ STATIC void wi_inquire __P((void *)); STATIC void wi_setdef __P((struct wi_softc *, struct wi_req *)); STATIC int wi_mgmt_xmit __P((struct wi_softc *, caddr_t, int)); -int wi_pcmcia_match __P((struct device *, void *, void *)); -void wi_pcmcia_attach __P((struct device *, struct device *, void *)); -int wi_pcmcia_detach __P((struct device *, int)); -int wi_pcmcia_activate __P((struct device *, enum devact)); int wi_intr __P((void *)); +int wi_attach __P((struct wi_softc *)); +void wi_init __P((void *)); +void wi_stop __P((struct wi_softc *)); /* Autoconfig definition of driver back-end */ struct cfdriver wi_cd = { NULL, "wi", DV_IFNET }; -struct cfattach wi_ca = { - sizeof (struct wi_softc), wi_pcmcia_match, wi_pcmcia_attach, - wi_pcmcia_detach, wi_pcmcia_activate -}; - -static const struct wi_pcmcia_product { - u_int32_t pp_vendor; - u_int32_t pp_product; - const char *pp_cisinfo[4]; - const char *pp_name; - int pp_prism2; -} wi_pcmcia_products[] = { - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_LUCENT_WAVELAN_IEEE, - "WaveLAN/IEEE", - 0 }, - - { PCMCIA_VENDOR_3COM, - PCMCIA_PRODUCT_3COM_3CRWE737A, - PCMCIA_CIS_3COM_3CRWE737A, - "3Com AirConnect Wireless LAN", - 1 }, - - { PCMCIA_VENDOR_COREGA, - PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11, - PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11, - "Corega Wireless LAN PCC-11", - 1 }, - - { PCMCIA_VENDOR_COREGA, - PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCA_11, - PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCA_11, - "Corega Wireless LAN PCCA-11", - 1 }, - - { PCMCIA_VENDOR_INTERSIL, - PCMCIA_PRODUCT_INTERSIL_PRISM2, - PCMCIA_CIS_INTERSIL_PRISM2, - "Intersil Prism II", - 1 }, - - { PCMCIA_VENDOR_SAMSUNG, - PCMCIA_PRODUCT_SAMSUNG_SWL_2000N, - PCMCIA_CIS_SAMSUNG_SWL_2000N, - "Samsung MagicLAN SWL-2000N", - 1 }, - - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_SMC_2632W, - "SMC 2632 EZ Connect Wireless PC Card", - 1 }, - - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_NANOSPEED_PRISM2, - "NANOSPEED ROOT-RZ2000 WLAN Card", - 1 }, - - { PCMCIA_VENDOR_ELSA, - PCMCIA_PRODUCT_ELSA_XI300_IEEE, - PCMCIA_CIS_ELSA_XI300_IEEE, - "XI300 Wireless LAN", - 1 }, - - { PCMCIA_VENDOR_COMPAQ, - PCMCIA_PRODUCT_COMPAQ_NC5004, - PCMCIA_CIS_COMPAQ_NC5004, - "Compaq Agency NC5004 Wireless Card", - 1 }, - - { PCMCIA_VENDOR_CONTEC, - PCMCIA_PRODUCT_CONTEC_FX_DS110_PCC, - PCMCIA_CIS_CONTEC_FX_DS110_PCC, - "Contec FLEXLAN/FX-DS110-PCC", - 1 }, - - { PCMCIA_VENDOR_TDK, - PCMCIA_PRODUCT_TDK_LAK_CD011WL, - PCMCIA_CIS_TDK_LAK_CD011WL, - "TDK LAK-CD011WL", - 1 }, - - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_NEC_CMZ_RT_WP, - "NEC Wireless Card CMZ-RT-WP", - 1 }, - - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_NTT_ME_WLAN, - "NTT-ME 11Mbps Wireless LAN PC Card", - 1 }, - - { PCMCIA_VENDOR_ADDTRON, - PCMCIA_PRODUCT_ADDTRON_AWP100, - PCMCIA_CIS_ADDTRON_AWP100, - "Addtron AWP-100", - 1 }, - - { PCMCIA_VENDOR_LUCENT, - PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, - PCMCIA_CIS_CABLETRON_ROAMABOUT, - "Cabletron RoamAbout", - 0 }, - - { PCMCIA_VENDOR_IODATA2, - PCMCIA_PRODUCT_IODATA2_WNB11PCM, - PCMCIA_CIS_IODATA2_WNB11PCM, - "I-O DATA WN-B11/PCM", - 1 }, - - { PCMCIA_VENDOR_LINKSYS, - PCMCIA_PRODUCT_LINKSYS_WPC11, - PCMCIA_CIS_LINKSYS_WPC11, - "Linksys WPC11", - 1 }, - - { 0, - 0, - { NULL, NULL, NULL, NULL }, - NULL, - 0 } -}; - -static const struct wi_pcmcia_product *wi_lookup __P((struct pcmcia_attach_args *pa)); - -const struct wi_pcmcia_product * -wi_lookup(pa) - struct pcmcia_attach_args *pa; -{ - const 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; -} - int -wi_pcmcia_match(parent, match, aux) - struct device *parent; - void *match, *aux; +wi_attach(sc) + struct wi_softc *sc; { - struct pcmcia_attach_args *pa = aux; - - if (wi_lookup(pa) != NULL) - return 1; - return 0; -} - -void -wi_pcmcia_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct wi_softc *sc = (struct wi_softc *)self; - struct pcmcia_attach_args *pa = aux; - struct pcmcia_function *pf = pa->pf; - struct pcmcia_config_entry *cfe = pf->cfe_head.sqh_first; - const struct wi_pcmcia_product *pp; struct wi_ltv_macaddr mac; struct wi_ltv_gen gen; struct ifnet *ifp; - int state = 0; - - sc->sc_pf = pf; - - /* Enable the card. */ - pcmcia_function_init(pf, cfe); - if (pcmcia_function_enable(pf)) { - printf(": function enable failed\n"); - goto bad; - } - state++; - - if (pcmcia_io_alloc(pf, 0, WI_IOSIZ, WI_IOSIZ, &sc->sc_pcioh)) { - printf(": can't alloc i/o space\n"); - goto bad; - } - state++; - - if (pcmcia_io_map(pf, PCMCIA_WIDTH_IO16, 0, WI_IOSIZ, &sc->sc_pcioh, - &sc->sc_io_window)) { - printf(": can't map io space\n"); - goto bad; - } - state++; sc->wi_gone = 0; - sc->wi_btag = sc->sc_pcioh.iot; - sc->wi_bhandle = sc->sc_pcioh.ioh; - - pp = wi_lookup(pa); - if (pp == NULL) { - /* should not happen */ - sc->sc_prism2 = 0; - } else - sc->sc_prism2 = pp->pp_prism2; /* Make sure interrupts are disabled. */ CSR_WRITE_2(sc, WI_INT_EN, 0); - CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); + CSR_WRITE_2(sc, WI_EVENT_ACK, 0xffff); wi_reset(sc); @@ -474,6 +245,7 @@ wi_pcmcia_attach(parent, self, aux) */ if_attach(ifp); ether_ifattach(ifp); + printf("\n"); #if NBPFILTER > 0 BPFATTACH(&sc->arpcom.ac_if.if_bpf, ifp, DLT_EN10MB, @@ -482,75 +254,9 @@ wi_pcmcia_attach(parent, self, aux) shutdownhook_establish(wi_shutdown, sc); - /* Establish the interrupt. */ - sc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, wi_intr, sc); - if (sc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt\n", - sc->sc_dev.dv_xname); - goto bad; - } - printf("\n"); - wi_init(sc); wi_stop(sc); - return; - -bad: - if (state > 2) - pcmcia_io_unmap(pf, sc->sc_io_window); - if (state > 1) - pcmcia_io_free(pf, &sc->sc_pcioh); - if (state > 0) - pcmcia_function_disable(pf); -} - -int -wi_pcmcia_detach(dev, flags) - struct device *dev; - int flags; -{ - struct wi_softc *sc = (struct wi_softc *)dev; - struct ifnet *ifp = &sc->arpcom.ac_if; - int rv = 0; - pcmcia_io_unmap(sc->sc_pf, sc->sc_io_window); - pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh); - - ether_ifdetach(ifp); - if_detach(ifp); - - return (rv); -} - -int -wi_pcmcia_activate(dev, act) - struct device *dev; - enum devact act; -{ - struct wi_softc *sc = (struct wi_softc *)dev; - struct ifnet *ifp = &sc->arpcom.ac_if; - int s; - - s = splnet(); - switch (act) { - case DVACT_ACTIVATE: - pcmcia_function_enable(sc->sc_pf); - printf("%s:", WI_PRT_ARG(sc)); - sc->sc_ih = - pcmcia_intr_establish(sc->sc_pf, IPL_NET, wi_intr, sc); - printf("\n"); - wi_init(sc); - break; - - case DVACT_DEACTIVATE: - ifp->if_timer = 0; - if (ifp->if_flags & IFF_RUNNING) - wi_stop(sc); - pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); - pcmcia_function_disable(sc->sc_pf); - break; - } - splx(s); return (0); } @@ -1002,7 +708,8 @@ wi_write_record(sc, 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); + bcopy(&wk->wi_keys[i].wi_keydat, + ws.wi_str, 5); ws.wi_str[5] = '\0'; error = wi_write_record(sc, (struct wi_ltv_gen *)&ws); diff --git a/sys/dev/pcmcia/if_wavelan_ieee.h b/sys/dev/ic/if_wi_ieee.h index 3ef054b76be..01fe72c1ed8 100644 --- a/sys/dev/pcmcia/if_wavelan_ieee.h +++ b/sys/dev/ic/if_wi_ieee.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wavelan_ieee.h,v 1.2 2000/02/03 00:56:45 angelos Exp $ */ +/* $OpenBSD: if_wi_ieee.h,v 1.1 2001/05/15 02:40:36 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -34,8 +34,8 @@ * From: if_wavelan_ieee.h,v 1.1 1999/05/05 07:36:50 wpaul Exp $ */ -#ifndef _IF_WAVELAN_IEEE_H -#define _IF_WAVELAN_IEEE_H +#ifndef _IF_WI_IEEE_H +#define _IF_WI_IEEE_H /* * This header defines a simple command interface to the FreeBSD @@ -130,7 +130,6 @@ struct wi_mgmt_hdr { u_int16_t seq_ctl; }; -#if (defined(__FreeBSD__) && !defined(KERNEL)) || (!defined(__FreeBSD__) && !defined(_KERNEL)) struct wi_counters { u_int32_t wi_tx_unicast_frames; u_int32_t wi_tx_multicast_frames; @@ -197,6 +196,13 @@ struct wi_counters { #define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */ #define WI_RID_ENCRYPTION 0xFC20 /* enable/disable WEP */ #define WI_RID_AUTHTYPE 0xFC21 /* specify authentication type */ +#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 +#define WI_RID_P2_CRYPT_KEY0 0xFC24 +#define WI_RID_P2_CRYPT_KEY1 0xFC25 +#define WI_RID_MICROWAVE_OVEN 0xFC25 +#define WI_RID_P2_CRYPT_KEY2 0xFC26 +#define WI_RID_P2_CRYPT_KEY3 0xFC27 +#define WI_RID_P2_ENCRYPTION 0xFC28 /* * Network parameters, dynamic configuration entities @@ -300,7 +306,5 @@ struct wi_ltv_keys { #define WI_RID_CCA_TIME 0xFDC4 /* clear chan assess time */ #define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */ #define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */ -#endif - #endif diff --git a/sys/dev/pcmcia/if_wireg.h b/sys/dev/ic/if_wireg.h index 3b0f61996de..8f64d7ff40c 100644 --- a/sys/dev/pcmcia/if_wireg.h +++ b/sys/dev/ic/if_wireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wireg.h,v 1.10 2001/04/04 20:13:12 mickey Exp $ */ +/* $OpenBSD: if_wireg.h,v 1.1 2001/05/15 02:40:36 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -34,97 +34,6 @@ * From: if_wireg.h,v 1.5 1999/07/20 20:03:42 wpaul Exp $ */ -struct wi_counters { - u_int32_t wi_tx_unicast_frames; - u_int32_t wi_tx_multicast_frames; - u_int32_t wi_tx_fragments; - u_int32_t wi_tx_unicast_octets; - u_int32_t wi_tx_multicast_octets; - u_int32_t wi_tx_deferred_xmits; - u_int32_t wi_tx_single_retries; - u_int32_t wi_tx_multi_retries; - u_int32_t wi_tx_retry_limit; - u_int32_t wi_tx_discards; - u_int32_t wi_rx_unicast_frames; - u_int32_t wi_rx_multicast_frames; - u_int32_t wi_rx_fragments; - u_int32_t wi_rx_unicast_octets; - u_int32_t wi_rx_multicast_octets; - u_int32_t wi_rx_fcs_errors; - u_int32_t wi_rx_discards_nobuf; - u_int32_t wi_tx_discards_wrong_sa; - u_int32_t wi_rx_WEP_cant_decrypt; - u_int32_t wi_rx_msg_in_msg_frags; - u_int32_t wi_rx_msg_in_bad_msg_frags; -}; - -/* - * Encryption controls. We can enable or disable encryption as - * well as specify up to 4 encryption keys. We can also specify - * which of the four keys will be used for transmit encryption. - */ -#define WI_RID_ENCRYPTION 0xFC20 -#define WI_RID_AUTHTYPE 0xFC21 -#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 -#define WI_RID_P2_CRYPT_KEY0 0xFC24 -#define WI_RID_P2_CRYPT_KEY1 0xFC25 -#define WI_RID_MICROWAVE_OVEN 0xFC25 -#define WI_RID_P2_CRYPT_KEY2 0xFC26 -#define WI_RID_P2_CRYPT_KEY3 0xFC27 -#define WI_RID_P2_ENCRYPTION 0xFC28 -#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 -#define WI_RID_TX_CRYPT_KEY 0xFCB1 -#define WI_RID_WEP_AVAIL 0xFD4F -struct wi_key { - u_int16_t wi_keylen; - u_int8_t wi_keydat[14]; -}; - -struct wi_ltv_keys { - u_int16_t wi_len; - u_int16_t wi_type; - struct wi_key wi_keys[4]; -}; - -struct wi_softc { -#ifndef __FreeBSD__ - struct device sc_dev; -#endif /* !__FreeBSD__ */ - struct arpcom arpcom; - struct ifmedia ifmedia; - bus_space_handle_t wi_bhandle; - bus_space_tag_t wi_btag; - int wi_tx_data_id; - int wi_tx_mgmt_id; - int wi_gone; - int wi_if_flags; - u_int16_t wi_ptype; - u_int16_t wi_portnum; - u_int16_t wi_max_data_len; - u_int16_t wi_rts_thresh; - u_int16_t wi_ap_density; - u_int16_t wi_tx_rate; - u_int16_t wi_create_ibss; - u_int16_t wi_channel; - u_int16_t wi_pm_enabled; - u_int16_t wi_max_sleep; - char wi_node_name[32]; - char wi_net_name[32]; - char wi_ibss_name[32]; - u_int8_t wi_txbuf[1596]; - int wi_has_wep; - int wi_use_wep; - int wi_tx_key; - struct wi_ltv_keys wi_keys; - struct wi_counters wi_stats; - void *sc_ih; - struct pcmcia_io_handle sc_pcioh; - int sc_io_window; - struct pcmcia_function *sc_pf; - struct timeout sc_timo; - int sc_prism2; -}; - #define WI_TIMEOUT 50000 /* XXX just a guess at a good value. */ #define WI_PORT0 0 @@ -140,7 +49,7 @@ struct wi_softc { /* Default TX rate: 2Mbps, auto fallback */ #define WI_DEFAULT_TX_RATE 3 -/* Default network name: ANY */ +/* Default network name (wildcard) */ #define WI_DEFAULT_NETNAME "" #define WI_DEFAULT_AP_DENSITY 1 @@ -155,15 +64,9 @@ struct wi_softc { #define WI_DEFAULT_MAX_SLEEP 100 -#ifdef __FreeBSD__ -#define WI_DEFAULT_NODENAME "FreeBSD WaveLAN/IEEE node" - -#define WI_DEFAULT_IBSS "FreeBSD IBSS" -#else /* !__FreeBSD__ */ #define WI_DEFAULT_NODENAME "WaveLAN/IEEE node" #define WI_DEFAULT_IBSS "IBSS" -#endif /* __FreeBSD__ */ #define WI_DEFAULT_CHAN 3 diff --git a/sys/dev/ic/if_wivar.h b/sys/dev/ic/if_wivar.h new file mode 100644 index 00000000000..fbd36ef22c1 --- /dev/null +++ b/sys/dev/ic/if_wivar.h @@ -0,0 +1,74 @@ +/* $OpenBSD: if_wivar.h,v 1.1 2001/05/15 02:40:36 millert Exp $ */ + +/* + * 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. + * + * From: if_wireg.h,v 1.5 1999/07/20 20:03:42 wpaul Exp $ + */ + +struct wi_softc { +#ifndef __FreeBSD__ + struct device sc_dev; +#endif /* !__FreeBSD__ */ + struct arpcom arpcom; + struct ifmedia ifmedia; + bus_space_handle_t wi_bhandle; + bus_space_tag_t wi_btag; + int wi_tx_data_id; + int wi_tx_mgmt_id; + int wi_gone; + int wi_if_flags; + u_int16_t wi_ptype; + u_int16_t wi_portnum; + u_int16_t wi_max_data_len; + u_int16_t wi_rts_thresh; + u_int16_t wi_ap_density; + u_int16_t wi_tx_rate; + u_int16_t wi_create_ibss; + u_int16_t wi_channel; + u_int16_t wi_pm_enabled; + u_int16_t wi_max_sleep; + char wi_node_name[32]; + char wi_net_name[32]; + char wi_ibss_name[32]; + u_int8_t wi_txbuf[1596]; + int wi_has_wep; + int wi_use_wep; + int wi_tx_key; + struct wi_ltv_keys wi_keys; + struct wi_counters wi_stats; + void *sc_ih; + struct timeout sc_timo; + int sc_prism2; +}; + +#define WI_PRT_FMT "%s" +#define WI_PRT_ARG(sc) (sc)->sc_dev.dv_xname diff --git a/sys/dev/pcmcia/files.pcmcia b/sys/dev/pcmcia/files.pcmcia index 01a10c0dd11..6913fddcb46 100644 --- a/sys/dev/pcmcia/files.pcmcia +++ b/sys/dev/pcmcia/files.pcmcia @@ -1,4 +1,4 @@ -# $OpenBSD: files.pcmcia,v 1.34 2001/03/29 01:39:32 aaron Exp $ +# $OpenBSD: files.pcmcia,v 1.35 2001/05/15 02:40:35 millert Exp $ # $NetBSD: files.pcmcia,v 1.9 1998/06/21 18:45:41 christos Exp $ # # Config.new file and device description for machine-independent PCMCIA code. @@ -70,9 +70,8 @@ attach cnw at pcmcia file dev/pcmcia/if_cnw.c cnw # Lucent WaveLAN -device wi: ether, ifnet -attach wi at pcmcia -file dev/pcmcia/if_wi.c wi +attach wi at pcmcia with wi_pcmcia +file dev/pcmcia/if_wi_pcmcia.c wi_pcmcia # AMD 79c930-based 802.11 cards (including BayStack 650 FH card). device awi: ether, ifnet diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c new file mode 100644 index 00000000000..7bfb262a24f --- /dev/null +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -0,0 +1,377 @@ +/* $OpenBSD: if_wi_pcmcia.c,v 1.1 2001/05/15 02:40:35 millert Exp $ */ + +/* + * 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. + * + * From: if_wi.c,v 1.7 1999/07/04 14:40:22 wpaul Exp $ + */ + +/* + * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for OpenBSD. + * + * Originally written by Bill Paul <wpaul@ctr.columbia.edu> + * Electrical Engineering Department + * Columbia University, New York City + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/timeout.h> +#include <sys/socket.h> +#include <sys/device.h> + +#include <net/if.h> +#include <net/if_dl.h> +#include <net/if_media.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/if_ether.h> +#endif + +#include <machine/bus.h> + +#include <dev/pcmcia/pcmciareg.h> +#include <dev/pcmcia/pcmciavar.h> +#include <dev/pcmcia/pcmciadevs.h> + +#include <dev/ic/if_wireg.h> +#include <dev/ic/if_wi_ieee.h> +#include <dev/ic/if_wivar.h> + +int wi_pcmcia_match __P((struct device *, void *, void *)); +void wi_pcmcia_attach __P((struct device *, struct device *, void *)); +int wi_pcmcia_detach __P((struct device *, int)); +int wi_pcmcia_activate __P((struct device *, enum devact)); +void wi_pcmcia_attach __P((struct device *, struct device *, void *)); + +int wi_intr __P((void *)); +int wi_attach __P((struct wi_softc *)); +void wi_init __P((void *)); +void wi_stop __P((struct wi_softc *)); + +struct wi_pcmcia_softc { + struct wi_softc sc_wi; + + struct pcmcia_io_handle sc_pcioh; + int sc_io_window; + struct pcmcia_function *sc_pf; +}; + +struct cfattach wi_pcmcia_ca = { + sizeof (struct wi_pcmcia_softc), wi_pcmcia_match, wi_pcmcia_attach, + wi_pcmcia_detach, wi_pcmcia_activate +}; + +static const struct wi_pcmcia_product { + u_int32_t pp_vendor; + u_int32_t pp_product; + const char *pp_cisinfo[4]; + const char *pp_name; + int pp_prism2; +} wi_pcmcia_products[] = { + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_LUCENT_WAVELAN_IEEE, + "WaveLAN/IEEE", + 0 }, + + { PCMCIA_VENDOR_3COM, + PCMCIA_PRODUCT_3COM_3CRWE737A, + PCMCIA_CIS_3COM_3CRWE737A, + "3Com AirConnect Wireless LAN", + 1 }, + + { PCMCIA_VENDOR_COREGA, + PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11, + PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11, + "Corega Wireless LAN PCC-11", + 1 }, + + { PCMCIA_VENDOR_COREGA, + PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCA_11, + PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCA_11, + "Corega Wireless LAN PCCA-11", + 1 }, + + { PCMCIA_VENDOR_INTERSIL, + PCMCIA_PRODUCT_INTERSIL_PRISM2, + PCMCIA_CIS_INTERSIL_PRISM2, + "Intersil Prism II", + 1 }, + + { PCMCIA_VENDOR_SAMSUNG, + PCMCIA_PRODUCT_SAMSUNG_SWL_2000N, + PCMCIA_CIS_SAMSUNG_SWL_2000N, + "Samsung MagicLAN SWL-2000N", + 1 }, + + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_SMC_2632W, + "SMC 2632 EZ Connect Wireless PC Card", + 1 }, + + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_NANOSPEED_PRISM2, + "NANOSPEED ROOT-RZ2000 WLAN Card", + 1 }, + + { PCMCIA_VENDOR_ELSA, + PCMCIA_PRODUCT_ELSA_XI300_IEEE, + PCMCIA_CIS_ELSA_XI300_IEEE, + "XI300 Wireless LAN", + 1 }, + + { PCMCIA_VENDOR_COMPAQ, + PCMCIA_PRODUCT_COMPAQ_NC5004, + PCMCIA_CIS_COMPAQ_NC5004, + "Compaq Agency NC5004 Wireless Card", + 1 }, + + { PCMCIA_VENDOR_CONTEC, + PCMCIA_PRODUCT_CONTEC_FX_DS110_PCC, + PCMCIA_CIS_CONTEC_FX_DS110_PCC, + "Contec FLEXLAN/FX-DS110-PCC", + 1 }, + + { PCMCIA_VENDOR_TDK, + PCMCIA_PRODUCT_TDK_LAK_CD011WL, + PCMCIA_CIS_TDK_LAK_CD011WL, + "TDK LAK-CD011WL", + 1 }, + + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_NEC_CMZ_RT_WP, + "NEC Wireless Card CMZ-RT-WP", + 1 }, + + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_NTT_ME_WLAN, + "NTT-ME 11Mbps Wireless LAN PC Card", + 1 }, + + { PCMCIA_VENDOR_ADDTRON, + PCMCIA_PRODUCT_ADDTRON_AWP100, + PCMCIA_CIS_ADDTRON_AWP100, + "Addtron AWP-100", + 1 }, + + { PCMCIA_VENDOR_LUCENT, + PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE, + PCMCIA_CIS_CABLETRON_ROAMABOUT, + "Cabletron RoamAbout", + 0 }, + + { PCMCIA_VENDOR_IODATA2, + PCMCIA_PRODUCT_IODATA2_WNB11PCM, + PCMCIA_CIS_IODATA2_WNB11PCM, + "I-O DATA WN-B11/PCM", + 1 }, + + { PCMCIA_VENDOR_LINKSYS, + PCMCIA_PRODUCT_LINKSYS_WPC11, + PCMCIA_CIS_LINKSYS_WPC11, + "Linksys WPC11", + 1 }, + + { 0, + 0, + { NULL, NULL, NULL, NULL }, + NULL, + 0 } +}; + +static const struct wi_pcmcia_product *wi_lookup __P((struct pcmcia_attach_args *pa)); + +const struct wi_pcmcia_product * +wi_lookup(pa) + struct pcmcia_attach_args *pa; +{ + const struct wi_pcmcia_product *pp; + + /* + * Several PRISM II-based cards use the Lucent WaveLAN vendor + * and product IDs so we match by CIS information first. + */ + 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); +} + +int +wi_pcmcia_match(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct pcmcia_attach_args *pa = aux; + + if (wi_lookup(pa) != NULL) + return (1); + return (0); +} + +void +wi_pcmcia_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)self; + struct wi_softc *sc = &psc->sc_wi; + struct pcmcia_attach_args *pa = aux; + struct pcmcia_function *pf = pa->pf; + struct pcmcia_config_entry *cfe = pf->cfe_head.sqh_first; + const struct wi_pcmcia_product *pp; + int state = 0; + + psc->sc_pf = pf; + + /* Enable the card. */ + pcmcia_function_init(pf, cfe); + if (pcmcia_function_enable(pf)) { + printf(": function enable failed\n"); + goto bad; + } + state++; + + if (pcmcia_io_alloc(pf, 0, WI_IOSIZ, WI_IOSIZ, &psc->sc_pcioh)) { + printf(": can't alloc i/o space\n"); + goto bad; + } + state++; + + if (pcmcia_io_map(pf, PCMCIA_WIDTH_IO16, 0, WI_IOSIZ, + &psc->sc_pcioh, &psc->sc_io_window)) { + printf(": can't map io space\n"); + goto bad; + } + state++; + + pp = wi_lookup(pa); + if (pp == NULL) { + /* should not happen */ + sc->sc_prism2 = 0; + } else + sc->sc_prism2 = pp->pp_prism2; + + sc->wi_btag = psc->sc_pcioh.iot; + sc->wi_bhandle = psc->sc_pcioh.ioh; + + /* Establish the interrupt. */ + sc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, wi_intr, psc); + if (sc->sc_ih == NULL) { + printf("%s: couldn't establish interrupt\n", + sc->sc_dev.dv_xname); + goto bad; + } + + wi_attach(sc); + return; + +bad: + if (state > 2) + pcmcia_io_unmap(pf, psc->sc_io_window); + if (state > 1) + pcmcia_io_free(pf, &psc->sc_pcioh); + if (state > 0) + pcmcia_function_disable(pf); +} + +int +wi_pcmcia_detach(dev, flags) + struct device *dev; + int flags; +{ + struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)dev; + struct wi_softc *sc = &psc->sc_wi; + struct ifnet *ifp = &sc->arpcom.ac_if; + + pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window); + pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh); + + ether_ifdetach(ifp); + if_detach(ifp); + + return (0); +} + +int +wi_pcmcia_activate(dev, act) + struct device *dev; + enum devact act; +{ + struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)dev; + struct wi_softc *sc = &psc->sc_wi; + struct ifnet *ifp = &sc->arpcom.ac_if; + int s; + + s = splnet(); + switch (act) { + case DVACT_ACTIVATE: + pcmcia_function_enable(psc->sc_pf); + printf("%s:", WI_PRT_ARG(sc)); + sc->sc_ih = + pcmcia_intr_establish(psc->sc_pf, IPL_NET, wi_intr, sc); + printf("\n"); + wi_init(sc); + break; + + case DVACT_DEACTIVATE: + ifp->if_timer = 0; + if (ifp->if_flags & IFF_RUNNING) + wi_stop(sc); + pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); + pcmcia_function_disable(psc->sc_pf); + break; + } + splx(s); + return (0); +} |