Home | History | Annotate | Line # | Download | only in ic
anvar.h revision 1.2
      1 /*	$NetBSD: anvar.h,v 1.2 2000/12/12 05:11:15 onoe Exp $	*/
      2 /*
      3  * Copyright (c) 1997, 1998, 1999
      4  *	Bill Paul <wpaul (at) ctr.columbia.edu>.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by Bill Paul.
     17  * 4. Neither the name of the author nor the names of any co-contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31  * THE POSSIBILITY OF SUCH DAMAGE.
     32  *
     33  * $FreeBSD: src/sys/dev/an/if_aironet_ieee.h,v 1.2 2000/11/13 23:04:12 wpaul Exp $
     34  */
     35 
     36 #ifndef _DEV_IC_ANVAR_H
     37 #define _DEV_IC_ANVAR_H
     38 
     39 /*
     40  * This header defines a simple command interface to the FreeBSD
     41  * Aironet driver (an) driver, which is used to set certain
     42  * device-specific parameters which can't be easily managed through
     43  * ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_
     44  * interface, didn't I.
     45  */
     46 
     47 #ifndef SIOCSAIRONET
     48 #define SIOCSAIRONET	SIOCSIFGENERIC
     49 #endif
     50 
     51 #ifndef SIOCGAIRONET
     52 #define SIOCGAIRONET	SIOCGIFGENERIC
     53 #endif
     54 
     55 #define AN_TIMEOUT	65536
     56 
     57 /* Default network name: ANY */
     58 #define AN_DEFAULT_NETNAME	""
     59 
     60 /* The nodename must be less than 16 bytes */
     61 #define AN_DEFAULT_NODENAME	"NetBSD"
     62 
     63 #define AN_DEFAULT_IBSS		"NetBSD IBSS"
     64 
     65 /*
     66  * register space access macros
     67  */
     68 #define CSR_WRITE_2(sc, reg, val)	\
     69 	bus_space_write_2(sc->an_btag, sc->an_bhandle, reg, val)
     70 
     71 #define CSR_READ_2(sc, reg)		\
     72 	bus_space_read_2(sc->an_btag, sc->an_bhandle, reg)
     73 
     74 #define CSR_WRITE_1(sc, reg, val)	\
     75 	bus_space_write_1(sc->an_btag, sc->an_bhandle, reg, val)
     76 
     77 #define CSR_READ_1(sc, reg)		\
     78 	bus_space_read_1(sc->an_btag, sc->an_bhandle, reg)
     79 
     80 /*
     81  * Technically I don't think there's a limit to a record
     82  * length. The largest record is the one that contains the CIS
     83  * data, which is 240 words long, so 256 should be a safe
     84  * value.
     85  */
     86 #define AN_MAX_DATALEN	512
     87 
     88 struct an_req {
     89 	u_int16_t	an_len;
     90 	u_int16_t	an_type;
     91 	u_int16_t	an_val[AN_MAX_DATALEN];
     92 };
     93 
     94 /*
     95  * Private LTV records (interpreted only by the driver). This is
     96  * a minor kludge to allow reading the interface statistics from
     97  * the driver.
     98  */
     99 #define AN_RID_IFACE_STATS	0x0100
    100 #define AN_RID_MGMT_XMIT	0x0200
    101 #ifdef ANCACHE
    102 #define AN_RID_ZERO_CACHE	0x0300
    103 #define AN_RID_READ_CACHE	0x0400
    104 #endif
    105 #define AN_RID_TX_SPEED		0x1234
    106 
    107 /*
    108  * Aironet IEEE signal strength cache
    109  *
    110  * driver keeps cache of last
    111  * MAXANCACHE packets to arrive including signal strength info.
    112  * daemons may read this via ioctl
    113  *
    114  * Each entry in the wi_sigcache has a unique macsrc.
    115  */
    116 #ifdef ANCACHE
    117 #define MAXANCACHE      10
    118 
    119 struct an_sigcache {
    120 	char	macsrc[6];	/* unique MAC address for entry */
    121 	int	ipsrc;		/* ip address associated with packet */
    122 	int	signal;		/* signal strength of the packet */
    123 	int	noise;		/* noise value */
    124 	int	quality;	/* quality of the packet */
    125 };
    126 #endif
    127 
    128 #define AN_TXGAP_80211		0
    129 #define AN_TXGAP_8023		0
    130 
    131 #define AN_TX_RING_CNT		4
    132 #define AN_INC(x, y)		(x) = (x + 1) % y
    133 
    134 struct an_tx_ring_data {
    135 	u_int16_t		an_tx_fids[AN_TX_RING_CNT];
    136 	u_int16_t		an_tx_ring[AN_TX_RING_CNT];
    137 	int			an_tx_prod;
    138 	int			an_tx_cons;
    139 };
    140 
    141 struct an_softc	{
    142 	struct device		an_dev;
    143 	struct ethercom		arpcom;
    144 	int			(*sc_enable) __P((struct an_softc *));
    145 	void			(*sc_disable) __P((struct an_softc *));
    146 	int			sc_enabled;
    147 	struct ifmedia		sc_media;
    148 
    149 	void*	irq_handle;	/* handle for irq handler */
    150 
    151 	bus_space_handle_t	an_bhandle;
    152 	bus_space_tag_t		an_btag;
    153 	struct an_ltv_genconfig	an_config;
    154 	struct an_ltv_caps	an_caps;
    155 	struct an_ltv_ssidlist	an_ssidlist;
    156 	struct an_ltv_aplist	an_aplist;
    157         struct an_ltv_wepkey	an_temp_keys;
    158         struct an_ltv_wepkey	an_perm_keys;
    159 	int			an_tx_rate;
    160 	int			an_rxmode;
    161 	int			an_if_flags;
    162 	u_int8_t		an_txbuf[1536];
    163 	struct an_tx_ring_data	an_rdata;
    164 	struct an_ltv_stats	an_stats;
    165 	struct an_ltv_status	an_status;
    166 	u_int8_t		an_associated;
    167 #ifdef ANCACHE
    168 	int			an_sigitems;
    169 	struct an_sigcache	an_sigcache[MAXANCACHE];
    170 	int			an_nextitem;
    171 #endif
    172 	struct callout		an_stat_ch;
    173 };
    174 
    175 void	an_release_resources	__P((struct device *));
    176 int	an_alloc_port		__P((struct device *, int, int));
    177 int	an_alloc_memory		__P((struct device *, int, int));
    178 int	an_alloc_irq		__P((struct device *, int, int));
    179 int	an_probe	        __P((struct an_softc *));
    180 void	an_shutdown	        __P((struct device *));
    181 int	an_attach		__P((struct an_softc *));
    182 int	an_detach		__P((struct an_softc *));
    183 int	an_intr			__P((void *));
    184 int	an_activate		__P((struct device *, enum devact));
    185 
    186 #endif	/* _DEV_IC_ANVAR_H */
    187