root/dev/ic/awivar.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. memcmp
  2. memset

    1 /* $OpenBSD: awivar.h,v 1.6 2003/10/21 18:58:49 jmc Exp $ */
    2 /* $NetBSD: awivar.h,v 1.12 2000/07/21 04:48:56 onoe Exp $ */
    3 
    4 /*-
    5  * Copyright (c) 1999 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Bill Sommerfeld
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *        This product includes software developed by the NetBSD
   22  *        Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 /* timer values in msec */
   41 #define AWI_SELFTEST_TIMEOUT    5000
   42 #define AWI_CMD_TIMEOUT         2000
   43 #define AWI_LOCKOUT_TIMEOUT     50
   44 #define AWI_ASCAN_DURATION      100
   45 #define AWI_ASCAN_WAIT          3000
   46 #define AWI_PSCAN_DURATION      200
   47 #define AWI_PSCAN_WAIT          5000
   48 #define AWI_TRANS_TIMEOUT       2000
   49 
   50 #define AWI_NTXBUFS             4
   51 #define AWI_MAX_KEYLEN          16
   52 
   53 enum awi_status {
   54         AWI_ST_INIT,
   55         AWI_ST_SCAN,
   56         AWI_ST_SETSS,
   57         AWI_ST_SYNC,
   58         AWI_ST_AUTH,
   59         AWI_ST_ASSOC,
   60         AWI_ST_RUNNING
   61 };
   62 
   63 struct awi_bss 
   64 {
   65         TAILQ_ENTRY(awi_bss)    list;
   66         u_int8_t        esrc[ETHER_ADDR_LEN];
   67         u_int8_t        chanset;        /* channel set to use */
   68         u_int8_t        pattern;        /* hop pattern to use */
   69         u_int8_t        index;          /* index to use */
   70         u_int8_t        rssi;           /* strength of this beacon */
   71         u_int16_t       dwell_time;     /* dwell time */
   72         u_int8_t        timestamp[8];   /* timestamp of this bss */
   73         u_int8_t        bssid[ETHER_ADDR_LEN];
   74         u_int16_t       capinfo;
   75         u_int32_t       rxtime;         /* unit's local time */
   76         u_int16_t       interval;       /* beacon interval */
   77         u_int8_t        txrate;
   78         u_int8_t        fails;
   79         u_int8_t        essid[IEEE80211_NWID_LEN + 2];
   80 };
   81 
   82 struct awi_wep_algo {
   83         char            *awa_name;
   84         int             (*awa_ctxlen)(void);
   85         void            (*awa_setkey)(void *, u_char *, int);
   86         void            (*awa_encrypt)(void *, u_char *, u_char *, int);
   87         void            (*awa_decrypt)(void *, u_char *, u_char *, int);
   88 };
   89 
   90 struct awi_softc 
   91 {
   92 #ifdef __NetBSD__
   93         struct device           sc_dev;
   94         struct ethercom         sc_ec;
   95         void                    *sc_ih; /* interrupt handler */
   96 #endif
   97 #ifdef __FreeBSD__
   98 #if __FreeBSD__ >= 4
   99         struct {
  100                 char    dv_xname[64];   /*XXX*/
  101         }                       sc_dev;
  102 #else
  103         struct device           sc_dev;
  104 #endif
  105 #endif
  106 #ifdef __OpenBSD__
  107         struct device           sc_dev;
  108         struct arpcom           sc_arpcom;
  109         void                    *sc_ih; /* interrupt handler */
  110 #endif
  111         struct am79c930_softc   sc_chip;
  112         struct ifnet            *sc_ifp;
  113         int                     (*sc_enable)(struct awi_softc *);
  114         void                    (*sc_disable)(struct awi_softc *);
  115 
  116         struct ifmedia          sc_media;
  117         enum awi_status         sc_status;
  118         unsigned int            sc_enabled:1,
  119                                 sc_busy:1,
  120                                 sc_cansleep:1,
  121                                 sc_invalid:1,
  122                                 sc_enab_intr:1,
  123                                 sc_format_llc:1,
  124                                 sc_start_bss:1,
  125                                 sc_rawbpf:1,
  126                                 sc_no_bssid:1,
  127                                 sc_active_scan:1,
  128                                 sc_attached:1;  /* attach has succeeded */
  129         u_int8_t                sc_cmd_inprog;
  130         int                     sc_sleep_cnt;
  131 
  132         int                     sc_mgt_timer;
  133 
  134         TAILQ_HEAD(, awi_bss)   sc_scan;
  135         u_int8_t                sc_scan_cur;
  136         u_int8_t                sc_scan_min;
  137         u_int8_t                sc_scan_max;
  138         u_int8_t                sc_scan_set;
  139         struct awi_bss          sc_bss;
  140         u_int8_t                sc_ownssid[IEEE80211_NWID_LEN + 2];
  141         u_int8_t                sc_ownch;
  142 
  143         int                     sc_rx_timer;
  144         u_int32_t               sc_rxdoff;
  145         u_int32_t               sc_rxmoff;
  146         struct mbuf             *sc_rxpend;
  147 
  148         int                     sc_tx_timer;
  149         u_int8_t                sc_tx_rate;
  150         struct ifqueue          sc_mgtq;
  151         u_int32_t               sc_txbase;
  152         u_int32_t               sc_txend;
  153         u_int32_t               sc_txnext;
  154         u_int32_t               sc_txdone;
  155 
  156         int                     sc_wep_keylen[IEEE80211_WEP_NKID]; /* keylen */
  157         u_int8_t                sc_wep_key[IEEE80211_WEP_NKID][AWI_MAX_KEYLEN];
  158         int                     sc_wep_defkid;
  159         void                    *sc_wep_ctx;    /* work area */
  160         struct awi_wep_algo     *sc_wep_algo;
  161 
  162         u_char                  sc_banner[AWI_BANNER_LEN];
  163         struct awi_mib_local    sc_mib_local;
  164         struct awi_mib_addr     sc_mib_addr;
  165         struct awi_mib_mac      sc_mib_mac;
  166         struct awi_mib_stat     sc_mib_stat;
  167         struct awi_mib_mgt      sc_mib_mgt;
  168         struct awi_mib_phy      sc_mib_phy;
  169 };
  170 
  171 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
  172 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
  173 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
  174 #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
  175 
  176 #define awi_write_1(sc, off, val) \
  177         ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
  178 #define awi_write_2(sc, off, val) \
  179         ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
  180 #define awi_write_4(sc, off, val) \
  181         ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
  182 #define awi_write_bytes(sc, off, ptr, len) \
  183         ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
  184 
  185 #define awi_drvstate(sc, state) \
  186         awi_write_1(sc, AWI_DRIVERSTATE, \
  187             ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
  188 
  189 /* unaligned little endian access */
  190 #define LE_READ_2(p)                                                    \
  191         (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
  192 #define LE_READ_4(p)                                                    \
  193         (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) |           \
  194          (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
  195 #define LE_WRITE_2(p, v)                                                \
  196         ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)),              \
  197          (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
  198 #define LE_WRITE_4(p, v)                                                \
  199         ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)),              \
  200          (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)),       \
  201          (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)),      \
  202          (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
  203 
  204 #define AWI_80211_RATE(rate)    (((rate) & 0x7f) * 5)
  205 
  206 int     awi_attach(struct awi_softc *);
  207 int     awi_intr(void *);
  208 void    awi_reset(struct awi_softc *);
  209 #ifndef __FreeBSD__
  210 int     awi_activate(struct device *, enum devact);
  211 int     awi_detach(struct awi_softc *);
  212 void    awi_power(struct awi_softc *, int);
  213 #endif
  214 
  215 void awi_stop(struct awi_softc *sc);
  216 int awi_init(struct awi_softc *sc);
  217 int awi_init_region(struct awi_softc *);
  218 int awi_wicfg(struct ifnet *, u_long, caddr_t);
  219 
  220 int awi_wep_setnwkey(struct awi_softc *, struct ieee80211_nwkey *);
  221 int awi_wep_getnwkey(struct awi_softc *, struct ieee80211_nwkey *);
  222 int awi_wep_getalgo(struct awi_softc *);
  223 int awi_wep_setalgo(struct awi_softc *, int);
  224 int awi_wep_setkey(struct awi_softc *, int, unsigned char *, int);
  225 int awi_wep_getkey(struct awi_softc *, int, unsigned char *, int *);
  226 struct mbuf *awi_wep_encrypt(struct awi_softc *, struct mbuf *, int);
  227 
  228 #ifdef __FreeBSD__
  229 /* Provide mem* for compat with NetBSD to fix LINT */
  230 static __inline int
  231 memcmp(const void *b1, const void *b2, size_t len)
  232 {
  233         return (bcmp(b1, b2, len));
  234 }
  235 
  236 static __inline void *
  237 memset(void *b, int c, size_t len)
  238 {
  239         bzero(b, len);
  240         return (b);
  241 }
  242 #endif

/* [<][>][^][v][top][bottom][index][help] */