Source-Changes-HG archive

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

[src/trunk]: src/sys Port 'an' driver for Aironet PC4500/PC4800 IEEE802.11 ca...



details:   https://anonhg.NetBSD.org/src/rev/1c4bf52df00b
branches:  trunk
changeset: 500428:1c4bf52df00b
user:      onoe <onoe%NetBSD.org@localhost>
date:      Mon Dec 11 23:16:50 2000 +0000

description:
Port 'an' driver for Aironet PC4500/PC4800 IEEE802.11 card from FreeBSD.
This is very adhoc work for IETF meeting.
- Since it seems that 'an' and 'wi' have similar hardware, low level
  functions should be shared.
- There are PCI/ISA cards of Aironet but not supported yet.
- The wiconfig interface is changed so that wiconfig cannot be used.
- 'ancontrol' of FreeBSD is not ported.
- Only infrastructure mode is tested.
- WEP is not supported.

Though I only have an Aironet card, Cisco card should be expected to work.

diffstat:

 sys/arch/i386/conf/GENERIC    |     5 +-
 sys/conf/files                |     6 +-
 sys/dev/DEVNAMES              |     3 +-
 sys/dev/ic/an.c               |  1592 +++++++++++++++++++++++++++++++++++++++++
 sys/dev/ic/anreg.h            |   890 ++++++++++++++++++++++
 sys/dev/ic/anvar.h            |   585 +++++++++++++++
 sys/dev/pcmcia/files.pcmcia   |     6 +-
 sys/dev/pcmcia/if_an_pcmcia.c |   368 +++++++++
 8 files changed, 3450 insertions(+), 5 deletions(-)

diffs (truncated from 3530 to 300 lines):

diff -r 2e2af0f0a134 -r 1c4bf52df00b sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Mon Dec 11 22:19:18 2000 +0000
+++ b/sys/arch/i386/conf/GENERIC        Mon Dec 11 23:16:50 2000 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: GENERIC,v 1.381 2000/11/28 19:44:07 augustss Exp $
+#      $NetBSD: GENERIC,v 1.382 2000/12/11 23:16:51 onoe Exp $
 #
 #      GENERIC -- everything that's currently supported
 #
 
 include "arch/i386/conf/std.i386"
 
-#ident                 "GENERIC-$Revision: 1.381 $"
+#ident                 "GENERIC-$Revision: 1.382 $"
 
 maxusers       32              # estimated number of users
 
@@ -576,6 +576,7 @@
 tr*    at isapnp?                      # IBM/3COM TROPIC Token-Ring
 
 # PCMCIA network interfaces
+an*    at pcmcia? function ?           # Aironet PC4500/PC4800 (802.11)
 awi*   at pcmcia? function ?           # BayStack 650/660 (802.11FH/DS)
 cnw*   at pcmcia? function ?           # Xircom/Netwave AirSurfer
 ep*    at pcmcia? function ?           # 3Com 3c589 and 3c562 Ethernet
diff -r 2e2af0f0a134 -r 1c4bf52df00b sys/conf/files
--- a/sys/conf/files    Mon Dec 11 22:19:18 2000 +0000
+++ b/sys/conf/files    Mon Dec 11 23:16:50 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.408 2000/12/05 17:59:43 drochner Exp $
+#      $NetBSD: files,v 1.409 2000/12/11 23:16:51 onoe Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -279,6 +279,10 @@
 device uha: scsi
 file   dev/ic/uha.c                    uha
 
+# Aironet PC4500/PC4800
+device an: arp, ether, ifnet
+file   dev/ic/an.c                     an
+
 # AMD 79c930-based 802.11 cards
 device awi: arp, wlan, ifnet
 file   dev/ic/awi.c                    awi
diff -r 2e2af0f0a134 -r 1c4bf52df00b sys/dev/DEVNAMES
--- a/sys/dev/DEVNAMES  Mon Dec 11 22:19:18 2000 +0000
+++ b/sys/dev/DEVNAMES  Mon Dec 11 23:16:50 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: DEVNAMES,v 1.23 2000/12/02 17:19:27 ragge Exp $
+#      $NetBSD: DEVNAMES,v 1.24 2000/12/11 23:16:51 onoe Exp $
 #
 # This file contains all used device names and defined attributes in 
 # alphabetical order. New devices added to the system somewhere should first 
@@ -54,6 +54,7 @@
 amps                   arm32
 ams                    mac68k
 ams                    macppc
+an                     MI
 ap                     newsmips
 apci                   hp300
 apecs                  alpha
diff -r 2e2af0f0a134 -r 1c4bf52df00b sys/dev/ic/an.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/an.c   Mon Dec 11 23:16:50 2000 +0000
@@ -0,0 +1,1592 @@
+/*     $NetBSD: an.c,v 1.1 2000/12/11 23:16:50 onoe 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.
+ *
+ * $FreeBSD: src/sys/dev/an/if_an.c,v 1.12 2000/11/13 23:04:12 wpaul Exp $
+ */
+
+/*
+ * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD.
+ *
+ * Written by Bill Paul <wpaul%ctr.columbia.edu@localhost>
+ * Electrical Engineering Department
+ * Columbia University, New York City
+ */
+
+/*
+ * The Aironet 4500/4800 series cards some in PCMCIA, ISA and PCI form.
+ * This driver supports all three device types (PCI devices are supported
+ * through an extra PCI shim: /sys/pci/if_an_p.c). ISA devices can be
+ * supported either using hard-coded IO port/IRQ settings or via Plug
+ * and Play. The 4500 series devices support 1Mbps and 2Mbps data rates.
+ * The 4800 devices support 1, 2, 5.5 and 11Mbps rates.
+ *
+ * Like the WaveLAN/IEEE cards, the Aironet NICs are all essentially
+ * PCMCIA devices. The ISA and PCI cards are a combination of a PCMCIA
+ * device and a PCMCIA to ISA or PCMCIA to PCI adapter card. There are
+ * a couple of important differences though:
+ *
+ * - Lucent doesn't currently offer a PCI card, however Aironet does
+ * - Lucent ISA card looks to the host like a PCMCIA controller with
+ *   a PCMCIA WaveLAN card inserted. This means that even desktop
+ *   machines need to be configured with PCMCIA support in order to
+ *   use WaveLAN/IEEE ISA cards. The Aironet cards on the other hand
+ *   actually look like normal ISA and PCI devices to the host, so
+ *   no PCMCIA controller support is needed
+ *
+ * The latter point results in a small gotcha. The Aironet PCMCIA
+ * cards can be configured for one of two operating modes depending
+ * on how the Vpp1 and Vpp2 programming voltages are set when the
+ * card is activated. In order to put the card in proper PCMCIA
+ * operation (where the CIS table is visible and the interface is
+ * programmed for PCMCIA operation), both Vpp1 and Vpp2 have to be
+ * set to 5 volts. FreeBSD by default doesn't set the Vpp voltages,
+ * which leaves the card in ISA/PCI mode, which prevents it from
+ * being activated as an PCMCIA device. Consequently, /sys/pccard/pccard.c
+ * has to be patched slightly in order to enable the Vpp voltages in
+ * order to make the Aironet PCMCIA cards work.
+ *
+ * Note that some PCMCIA controller software packages for Windows NT
+ * fail to set the voltages as well.
+ * 
+ * The Aironet devices can operate in both station mode and access point
+ * mode. Typically, when programmed for station mode, the card can be set
+ * to automatically perform encapsulation/decapsulation of Ethernet II
+ * and 802.3 frames within 802.11 frames so that the host doesn't have
+ * to do it itself. This driver doesn't program the card that way: the
+ * driver handles all of the encapsulation/decapsulation itself.
+ */
+
+/*
+ * Ported to NetBSD from FreeBSD by Atsushi Onoe at the San Diego
+ * IETF meeting.
+ */
+
+#include "opt_inet.h"
+#include "bpfilter.h"
+
+#ifdef INET
+#define ANCACHE                        /* enable signal strength cache */
+#endif
+
+#include <sys/param.h>
+#include <sys/callout.h>
+#include <sys/systm.h>
+#include <sys/sockio.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/ucred.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+#ifdef ANCACHE
+#include <sys/syslog.h>
+#include <sys/sysctl.h>
+#endif
+
+#include <machine/bus.h>
+
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+#include <net/if_ieee80211.h>
+#include <net/if_types.h>
+#include <net/if_media.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#endif
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
+#include <dev/ic/anvar.h>
+#include <dev/ic/anreg.h>
+
+#if !defined(lint)
+static const char rcsid[] =
+  "$FreeBSD: src/sys/dev/an/if_an.c,v 1.12 2000/11/13 23:04:12 wpaul Exp $";
+#endif
+
+/* These are global because we need them in sys/pci/if_an_p.c. */
+static void an_reset           __P((struct an_softc *));
+static int an_ioctl            __P((struct ifnet *, u_long, caddr_t));
+static int an_init             __P((struct ifnet *));
+static void an_stop            __P((struct ifnet *, int));
+static int an_init_tx_ring     __P((struct an_softc *));
+static void an_start           __P((struct ifnet *));
+static void an_watchdog                __P((struct ifnet *));
+static void an_rxeof           __P((struct an_softc *));
+static void an_txeof           __P((struct an_softc *, int));
+
+static void an_promisc         __P((struct an_softc *, int));
+static int an_cmd              __P((struct an_softc *, int, int));
+static int an_read_record      __P((struct an_softc *, struct an_ltv_gen *));
+static int an_write_record     __P((struct an_softc *, struct an_ltv_gen *));
+static int an_read_data                __P((struct an_softc *, int,
+                                       int, caddr_t, int));
+static int an_write_data       __P((struct an_softc *, int,
+                                       int, caddr_t, int));
+static int an_seek             __P((struct an_softc *, int, int, int));
+static int an_alloc_nicmem     __P((struct an_softc *, int, int *));
+static void an_stats_update    __P((void *));
+static void an_setdef          __P((struct an_softc *, struct an_req *));
+#ifdef ANCACHE
+static void an_cache_store     __P((struct an_softc *, struct ether_header *,
+                                       struct mbuf *, unsigned short));
+#endif
+#ifdef IFM_IEEE80211
+static int an_media_change __P((struct ifnet *ifp));
+static void an_media_status __P((struct ifnet *ifp, struct ifmediareq *imr));
+#endif
+
+/* 
+ * We probe for an Aironet 4500/4800 card by attempting to
+ * read the default SSID list. On reset, the first entry in
+ * the SSID list will contain the name "tsunami." If we don't
+ * find this, then there's no card present.
+ */
+int an_probe(sc)
+       struct an_softc *sc;
+{
+       struct an_ltv_ssidlist  ssid;
+
+       bzero((char *)&ssid, sizeof(ssid));
+
+       ssid.an_len = sizeof(ssid);
+       ssid.an_type = AN_RID_SSIDLIST;
+
+        /* Make sure interrupts are disabled. */
+        CSR_WRITE_2(sc, AN_INT_EN, 0);
+        CSR_WRITE_2(sc, AN_EVENT_ACK, 0xFFFF);
+
+       an_reset(sc);
+
+       if (an_cmd(sc, AN_CMD_READCFG, 0))
+               return(0);
+
+       if (an_read_record(sc, (struct an_ltv_gen *)&ssid))
+               return(0);
+
+       /* See if the ssid matches what we expect ... but doesn't have to */
+       if (strcmp(ssid.an_ssid1, AN_DEF_SSID))
+               return(0);
+       
+       return(AN_IOSIZ);
+}
+
+int an_attach(sc)
+       struct an_softc *sc;
+{
+       struct ifnet            *ifp = &sc->arpcom.ec_if;
+#ifdef IFM_IEEE80211
+       struct ifmediareq imr;
+#endif
+
+       sc->an_gone = 0;
+       sc->an_associated = 0;
+
+       /* Reset the NIC. */
+       an_reset(sc);
+
+       /* Load factory config */
+       if (an_cmd(sc, AN_CMD_READCFG, 0)) {
+               printf("%s: failed to load config data\n", sc->an_dev.dv_xname);
+               return(EIO);
+       }
+
+       /* Read the current configuration */
+       sc->an_config.an_type = AN_RID_GENCONFIG;
+       sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
+       if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
+               printf("%s: read record failed\n", sc->an_dev.dv_xname);



Home | Main Index | Thread Index | Old Index