Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys divided into PCMCIA attachment and common code of wi.



details:   https://anonhg.NetBSD.org/src/rev/858367b433a1
branches:  trunk
changeset: 509478:858367b433a1
user:      ichiro <ichiro%NetBSD.org@localhost>
date:      Sun May 06 03:26:38 2001 +0000

description:
divided into PCMCIA attachment and common code of wi.
since if_wi_ieee.h does not depend for pcmcia,
sys/dev/pcmcia/if_wi_ieee.h was moved to sys/dev/ic/wi_ieee.h .

diffstat:

 sys/conf/files                |     6 +-
 sys/dev/ic/Makefile           |     4 +-
 sys/dev/ic/awi_wicfg.c        |     4 +-
 sys/dev/ic/wi.c               |  1909 ++++++++++++++++++++++++++++++++++++
 sys/dev/ic/wi_ieee.h          |   336 ++++++
 sys/dev/ic/wireg.h            |   567 ++++++++++
 sys/dev/ic/wivar.h            |    92 +
 sys/dev/pcmcia/Makefile       |     4 +-
 sys/dev/pcmcia/files.pcmcia   |    11 +-
 sys/dev/pcmcia/if_wi.c        |  2134 -----------------------------------------
 sys/dev/pcmcia/if_wi_ieee.h   |   336 ------
 sys/dev/pcmcia/if_wi_pcmcia.c |   470 +++++++++
 sys/dev/pcmcia/if_wireg.h     |   567 ----------
 sys/dev/pcmcia/if_wivar.h     |    88 -
 14 files changed, 3390 insertions(+), 3138 deletions(-)

diffs (truncated from 6635 to 300 lines):

diff -r 04743d6bc085 -r 858367b433a1 sys/conf/files
--- a/sys/conf/files    Sun May 06 01:54:19 2001 +0000
+++ b/sys/conf/files    Sun May 06 03:26:38 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.437 2001/05/02 12:53:32 minoura Exp $
+#      $NetBSD: files,v 1.438 2001/05/06 03:26:38 ichiro Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -311,6 +311,10 @@
 file   dev/ic/awi_wicfg.c              awi
 file   dev/ic/am79c930.c               awi
 
+# Lucent & Intersil WaveLan IEEE (802.11)
+device wi: arp, wlan, ifnet
+file   dev/ic/wi.c                     wi
+
 # 3Com Etherlink-III Ethernet controller
 device ep: arp, ether, ifnet, mii, mii_bitbang
 file   dev/ic/elink3.c                 ep
diff -r 04743d6bc085 -r 858367b433a1 sys/dev/ic/Makefile
--- a/sys/dev/ic/Makefile       Sun May 06 01:54:19 2001 +0000
+++ b/sys/dev/ic/Makefile       Sun May 06 03:26:38 2001 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.19 2001/04/11 09:07:21 wiz Exp $
+#      $NetBSD: Makefile,v 1.20 2001/05/06 03:26:38 ichiro Exp $
 
 INCSDIR= /usr/include/dev/ic
 
 # Only install includes which are used by userland
-INCS=  bt8xx.h isp_ioctl.h mlxreg.h mlxio.h rrunnerreg.h rrunnervar.h wdcreg.h
+INCS=  bt8xx.h isp_ioctl.h mlxreg.h mlxio.h rrunnerreg.h rrunnervar.h wdcreg.h wi_ieee.h
 
 .include <bsd.kinc.mk>
diff -r 04743d6bc085 -r 858367b433a1 sys/dev/ic/awi_wicfg.c
--- a/sys/dev/ic/awi_wicfg.c    Sun May 06 01:54:19 2001 +0000
+++ b/sys/dev/ic/awi_wicfg.c    Sun May 06 03:26:38 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awi_wicfg.c,v 1.3 2000/07/06 17:22:25 onoe Exp $       */
+/*     $NetBSD: awi_wicfg.c,v 1.4 2001/05/06 03:26:38 ichiro Exp $     */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
 #include <dev/ic/awireg.h>
 #include <dev/ic/awivar.h>
 
-#include <dev/pcmcia/if_wi_ieee.h>     /* XXX */
+#include <dev/ic/wi_ieee.h>    /* XXX */
 #endif
 #ifdef __FreeBSD__
 #include <dev/awi/am79c930reg.h>
diff -r 04743d6bc085 -r 858367b433a1 sys/dev/ic/wi.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/wi.c   Sun May 06 03:26:38 2001 +0000
@@ -0,0 +1,1909 @@
+/* $NetBSD: wi.c,v 1.1 2001/05/06 03:26:39 ichiro Exp $ */
+
+/*
+ * Copyright (c) 1997, 1998, 1999
+ *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  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@localhost>
+ * 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"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/mbuf.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>                /* for hz */
+#include <sys/proc.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+#include <net/if_ieee80211.h>
+
+#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
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#include <net/bpfdesc.h>
+#endif
+
+#include <dev/pcmcia/pcmciareg.h>
+#include <dev/pcmcia/pcmciavar.h>
+#include <dev/pcmcia/pcmciadevs.h>
+
+#include <dev/ic/wi_ieee.h>
+#include <dev/ic/wireg.h>
+#include <dev/ic/wivar.h>
+
+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 *));
+static int wi_init             __P((struct ifnet *));
+static void wi_stop            __P((struct ifnet *, int));
+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 *));
+static int wi_setdef           __P((struct wi_softc *, struct wi_req *));
+static int wi_getdef           __P((struct wi_softc *, struct wi_req *));
+static int wi_mgmt_xmit                __P((struct wi_softc *, caddr_t, int));
+
+static int wi_media_change __P((struct ifnet *));
+static void wi_media_status __P((struct ifnet *, struct ifmediareq *));
+
+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 *));
+static int wi_write_ssid __P((struct wi_softc *, int, struct wi_req *,
+    struct ieee80211_nwid *));
+static int wi_set_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
+static int wi_get_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
+static int wi_sync_media __P((struct wi_softc *, int, int));
+static int wi_set_pm(struct wi_softc *, struct ieee80211_power *);
+static int wi_get_pm(struct wi_softc *, struct ieee80211_power *);
+
+int
+wi_attach(sc)
+       struct wi_softc *sc;
+{
+       struct ifnet *ifp = sc->sc_ifp;
+       struct wi_ltv_macaddr   mac;
+       struct wi_ltv_gen       gen;
+       static const u_int8_t empty_macaddr[ETHER_ADDR_LEN] = {
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       };
+       int s;
+
+       s = splnet();
+
+       callout_init(&sc->wi_inquire_ch);
+
+       /* 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);
+
+       /*
+        * Check if we got anything meaningful.
+        *
+        * Is it really enough just checking against null ethernet address?
+        * Or, check against possible vendor?  XXX.
+        */
+       if (bcmp(sc->sc_macaddr, empty_macaddr, ETHER_ADDR_LEN) == 0) {
+               printf("%s: could not get mac address, attach failed\n",
+                   sc->sc_dev.dv_xname);
+                       return 1;
+       }
+
+       printf(" 802.11 address %s\n", 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;
+       ifp->if_init = wi_init;
+       ifp->if_stop = wi_stop;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+#ifdef IFF_NOTRAILERS
+       ifp->if_flags |= IFF_NOTRAILERS;
+#endif
+       IFQ_SET_READY(&ifp->if_snd);
+
+       (void)wi_set_ssid(&sc->wi_nodeid, WI_DEFAULT_NODENAME,
+           sizeof(WI_DEFAULT_NODENAME) - 1);
+       (void)wi_set_ssid(&sc->wi_netid, WI_DEFAULT_NETNAME,
+           sizeof(WI_DEFAULT_NETNAME) - 1);
+       (void)wi_set_ssid(&sc->wi_ibssid, WI_DEFAULT_IBSS,
+           sizeof(WI_DEFAULT_IBSS) - 1);
+
+       sc->wi_portnum = WI_DEFAULT_PORT;
+       sc->wi_ptype = WI_PORTTYPE_BSS;
+       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));
+
+       /*
+        * Find out if we support WEP on this card.
+        */
+       gen.wi_type = WI_RID_WEP_AVAIL;



Home | Main Index | Thread Index | Old Index