home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / mobile / wi.44.patches / if_wireg.h < prev    next >
C/C++ Source or Header  |  2002-01-17  |  21KB  |  750 lines

  1. /*
  2.  * Copyright (c) 1997, 1998, 1999
  3.  *    Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by Bill Paul.
  16.  * 4. Neither the name of the author nor the names of any co-contributors
  17.  *    may be used to endorse or promote products derived from this software
  18.  *    without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
  21.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
  24.  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  30.  * THE POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * $FreeBSD: src/sys/i386/isa/if_wireg.h,v 1.8.2.2 2001/08/25 00:48:25 nsayer Exp $
  33.  */
  34.  
  35. struct wi_counters {
  36.     u_int32_t        wi_tx_unicast_frames;
  37.     u_int32_t        wi_tx_multicast_frames;
  38.     u_int32_t        wi_tx_fragments;
  39.     u_int32_t        wi_tx_unicast_octets;
  40.     u_int32_t        wi_tx_multicast_octets;
  41.     u_int32_t        wi_tx_deferred_xmits;
  42.     u_int32_t        wi_tx_single_retries;
  43.     u_int32_t        wi_tx_multi_retries;
  44.     u_int32_t        wi_tx_retry_limit;
  45.     u_int32_t        wi_tx_discards;
  46.     u_int32_t        wi_rx_unicast_frames;
  47.     u_int32_t        wi_rx_multicast_frames;
  48.     u_int32_t        wi_rx_fragments;
  49.     u_int32_t        wi_rx_unicast_octets;
  50.     u_int32_t        wi_rx_multicast_octets;
  51.     u_int32_t        wi_rx_fcs_errors;
  52.     u_int32_t        wi_rx_discards_nobuf;
  53.     u_int32_t        wi_tx_discards_wrong_sa;
  54.     u_int32_t        wi_rx_WEP_cant_decrypt;
  55.     u_int32_t        wi_rx_msg_in_msg_frags;
  56.     u_int32_t        wi_rx_msg_in_bad_msg_frags;
  57.         u_int32_t               wi_rx_discards_wep_icv_error;
  58.         u_int32_t               wi_rx_discards_wep_excluded;
  59. };
  60.  
  61. /*
  62.  * this is a prism2 structure, not Lucent/wavelan
  63.  */
  64. struct wi_scan_data_p2 {
  65.        u_int16_t               wi_noise;
  66.        u_int16_t               wi_channel1;
  67.        u_int16_t               wi_channel2;
  68.        u_int16_t               wi_signal;
  69.        u_int8_t                wi_bssid[6];    /* AP/mac address */
  70.        u_int16_t               wi_interval;    /* beacon xmit interval */
  71.        u_int16_t               wi_capinfo;    /* ? 0-ess, 1-ibss, wep-4 */
  72.        u_int16_t               wi_namelen;    /* length of essid name */
  73.        u_int8_t                wi_name[32];     /* essid string */ 
  74.        u_int16_t           wi_unknown2[5];   
  75. /*
  76.        u_int16_t               wi_unknown2[24]; 
  77. */
  78. };
  79.  
  80. /* lucent/wavelan version.  note 25 shorts in all
  81. */
  82. struct wi_scan_data {
  83.        u_int16_t               wi_channel;
  84.        u_int16_t               wi_noise;
  85.        u_int16_t               wi_signal;
  86.        u_int8_t                wi_bssid[6];    /* AP/mac address */
  87.        u_int16_t               wi_interval;    /* beacon xmit interval */
  88.        u_int16_t               wi_capinfo;    /* ? 0-ess, 1-ibss, wep-4 */
  89.        u_int16_t               wi_namelen;    /* length of essid name */
  90.        u_int8_t                wi_name[32];     /* essid string */ 
  91. };
  92.  
  93. /*
  94.  * Encryption controls. We can enable or disable encryption as
  95.  * well as specify up to 4 encryption keys. We can also specify
  96.  * which of the four keys will be used for transmit encryption.
  97.  */
  98. #define WI_RID_ENCRYPTION    0xFC20
  99. #define WI_RID_AUTHTYPE        0xFC21
  100. #define WI_RID_DEFLT_CRYPT_KEYS    0xFCB0
  101. #define WI_RID_TX_CRYPT_KEY    0xFCB1
  102. #define WI_RID_WEP_AVAIL    0xFD4F
  103. #define WI_RID_P2_TX_CRYPT_KEY    0xFC23
  104. #define WI_RID_P2_CRYPT_KEY0    0xFC24
  105. #define WI_RID_P2_CRYPT_KEY1    0xFC25
  106. #define WI_RID_P2_CRYPT_KEY2    0xFC26
  107. #define WI_RID_P2_CRYPT_KEY3    0xFC27
  108. #define WI_RID_P2_ENCRYPTION    0xFC28
  109. #define WI_RID_CUR_TX_RATE    0xFD44 /* current TX rate */
  110.  
  111. struct wi_key {
  112.     u_int16_t        wi_keylen;
  113.     u_int8_t        wi_keydat[14];
  114. };
  115.  
  116. struct wi_ltv_keys {
  117.     u_int16_t        wi_len;
  118.     u_int16_t        wi_type;
  119.     struct wi_key        wi_keys[4];
  120. };
  121.  
  122. struct wi_softc    {
  123.     struct arpcom        arpcom;
  124.     struct ifmedia        ifmedia;
  125.     device_t        dev;
  126.     int            wi_unit;
  127.     struct resource *    local;
  128.     int                    local_rid;
  129.     struct resource *    iobase;
  130.     int                    iobase_rid;
  131.     struct resource *    irq;
  132.     int                    irq_rid;
  133.     struct resource *    mem;
  134.     int                    mem_rid;
  135.     bus_space_handle_t    wi_localhandle;
  136.     bus_space_tag_t        wi_localtag;
  137.     bus_space_handle_t    wi_bhandle;
  138.     bus_space_tag_t        wi_btag;
  139.     bus_space_handle_t    wi_bmemhandle;
  140.     bus_space_tag_t        wi_bmemtag;
  141.     void *            wi_intrhand;
  142.     int            wi_io_addr;    
  143.     int            wi_tx_data_id;
  144.     int            wi_tx_mgmt_id;
  145.     int            wi_gone;
  146.     int            wi_if_flags;
  147.     u_int16_t        wi_ptype;
  148.     u_int16_t        wi_portnum;
  149.     u_int16_t        wi_max_data_len;
  150.     u_int16_t        wi_rts_thresh;
  151.     u_int16_t        wi_ap_density;
  152.     u_int16_t        wi_tx_rate;
  153.     u_int16_t        wi_create_ibss;
  154.     u_int16_t        wi_channel;
  155.     u_int16_t        wi_pm_enabled;
  156.     u_int16_t        wi_max_sleep;
  157.     char            wi_node_name[32];
  158.     char            wi_net_name[32];
  159.     char            wi_ibss_name[32];
  160.     u_int8_t        wi_txbuf[1596];
  161.     struct wi_counters    wi_stats;
  162.     int            wi_has_wep;
  163.     int            wi_use_wep;
  164.     int            wi_tx_key;
  165.     struct wi_ltv_keys    wi_keys;
  166.     /* monitor info
  167.     */
  168.         struct wi_apinfo        wi_aps[MAXAPINFO];
  169.         int                     wi_naps;
  170.         int                     wi_scanning;    /* scan mode */
  171.         int                     wi_monitor;     /* monitor mode */
  172. #ifdef WICACHE
  173.     int            wi_sigitems;
  174.     struct wi_sigcache    wi_sigcache[MAXWICACHE];
  175.     int            wi_nextitem;
  176. #endif
  177.     struct callout_handle    wi_stat_ch;
  178.     struct callout_handle    wi_scan_ch;
  179.     int            wi_prism2;    /* set to 1 if it uses a Prism II chip */
  180. };
  181.  
  182. #define WI_TIMEOUT    65536
  183.  
  184. #define WI_PORT0    0
  185. #define WI_PORT1    1
  186. #define WI_PORT2    2
  187. #define WI_PORT3    3
  188. #define WI_PORT4    4
  189. #define WI_PORT5    5
  190.  
  191. #define WI_PCI_LOCALRES    0x14    /* The PLX chip's local registers */
  192. #define WI_PCI_MEMRES    0x18    /* The PCCard's attribute memory */
  193. #define WI_PCI_IORES    0x1C    /* The PCCard's I/O space */
  194.  
  195. #define WI_LOCAL_INTCSR            0x4c
  196. #define WI_LOCAL_INTEN            0x40 /* poke this into INTCSR */
  197. #define WI_HFA384X_SWSUPPORT0_OFF    0x28
  198. #define WI_PRISM2STA_MAGIC        0x4A2D
  199.  
  200. /* Default port: 0 (only 0 exists on stations) */
  201. #define WI_DEFAULT_PORT    (WI_PORT0 << 8)
  202.  
  203. /* Default TX rate: 2Mbps, auto fallback */
  204. #define WI_DEFAULT_TX_RATE    3
  205.  
  206. /* Default network name: empty string implies any */
  207. #define WI_DEFAULT_NETNAME    ""
  208.  
  209. #define WI_DEFAULT_AP_DENSITY    1
  210.  
  211. #define WI_DEFAULT_RTS_THRESH    2347
  212.     
  213. #define WI_DEFAULT_DATALEN    2304
  214.  
  215. #define WI_DEFAULT_CREATE_IBSS    0
  216.  
  217. #define WI_DEFAULT_PM_ENABLED    0
  218.  
  219. #define WI_DEFAULT_MAX_SLEEP    100
  220.  
  221. #define WI_DEFAULT_NODENAME    "FreeBSD WaveLAN/IEEE node"
  222.  
  223. #define WI_DEFAULT_IBSS        "FreeBSD IBSS"
  224.  
  225. #define WI_DEFAULT_CHAN        3
  226.  
  227. #define WI_DEFAULT_MONITOR      0
  228.  
  229. /*
  230.  * register space access macros
  231.  */
  232. #define CSR_WRITE_4(sc, reg, val)    \
  233.     bus_space_write_4(sc->wi_btag, sc->wi_bhandle, reg, val)
  234. #define CSR_WRITE_2(sc, reg, val)    \
  235.     bus_space_write_2(sc->wi_btag, sc->wi_bhandle, reg, val)
  236. #define CSR_WRITE_1(sc, reg, val)    \
  237.     bus_space_write_1(sc->wi_btag, sc->wi_bhandle, reg, val)
  238.  
  239. #define CSR_READ_4(sc, reg)        \
  240.     bus_space_read_4(sc->wi_btag, sc->wi_bhandle, reg)
  241. #define CSR_READ_2(sc, reg)        \
  242.     bus_space_read_2(sc->wi_btag, sc->wi_bhandle, reg)
  243. #define CSR_READ_1(sc, reg)        \
  244.     bus_space_read_1(sc->wi_btag, sc->wi_bhandle, reg)
  245.  
  246. #define CSM_WRITE_1(sc, off, val)    \
  247.     bus_space_write_1(sc->wi_bmemtag, sc->wi_bmemhandle, off, val)
  248.  
  249. #define CSM_READ_1(sc, off)        \
  250.     bus_space_read_1(sc->wi_bmemtag, sc->wi_bmemhandle, off)
  251.  
  252.  
  253. /*
  254.  * The WaveLAN/IEEE cards contain an 802.11 MAC controller which Lucent
  255.  * calls 'Hermes.' In typical fashion, getting documentation about this
  256.  * controller is about as easy as squeezing blood from a stone. Here
  257.  * is more or less what I know:
  258.  *
  259.  * - The Hermes controller is firmware driven, and the host interacts
  260.  *   with the Hermes via a firmware interface, which can change.
  261.  *
  262.  * - The Hermes is described in a document called: "Hermes Firmware
  263.  *   WaveLAN/IEEE Station Functions," document #010245, which of course
  264.  *   Lucent will not release without an NDA.
  265.  *
  266.  * - Lucent has created a library called HCF (Hardware Control Functions)
  267.  *   though which it wants developers to interact with the card. The HCF
  268.  *   is needlessly complex, ill conceived and badly documented. Actually,
  269.  *   the comments in the HCP code itself aren't bad, but the publically
  270.  *   available manual that comes with it is awful, probably due largely to
  271.  *   the fact that it has been emasculated in order to hide information
  272.  *   that Lucent wants to keep proprietary. The purpose of the HCF seems
  273.  *   to be to insulate the driver programmer from the Hermes itself so that
  274.  *   Lucent has an excuse not to release programming in for it.
  275.  *
  276.  * - Lucent only makes available documentation and code for 'HCF Light'
  277.  *   which is a stripped down version of HCF with certain features not
  278.  *   implemented, most notably support for 802.11 frames.
  279.  *
  280.  * - The HCF code which I have seen blows goats. Whoever decided to
  281.  *   use a 132 column format should be shot.
  282.  *
  283.  * Rather than actually use the Lucent HCF library, I have stripped all
  284.  * the useful information from it and used it to create a driver in the
  285.  * usual BSD form. Note: I don't want to hear anybody whining about the
  286.  * fact that the Lucent code is GPLed and mine isn't. I did not actually
  287.  * put any of Lucent's code in this driver: I only used it as a reference
  288.  * to obtain information about the underlying hardware. The Hermes
  289.  * programming interface is not GPLed, so bite me.
  290.  */
  291.  
  292. /*
  293.  * Size of Hermes I/O space.
  294.  */
  295. #define WI_IOSIZ        0x40
  296.  
  297. /*
  298.  * Hermes register definitions and what little I know about them.
  299.  */
  300.  
  301. /* Hermes command/status registers. */
  302. #define WI_COMMAND        0x00
  303. #define WI_PARAM0        0x02
  304. #define WI_PARAM1        0x04
  305. #define WI_PARAM2        0x06
  306. #define WI_STATUS        0x08
  307. #define WI_RESP0        0x0A
  308. #define WI_RESP1        0x0C
  309. #define WI_RESP2        0x0E
  310.  
  311. /* Command register values. */
  312. #define WI_CMD_BUSY        0x8000 /* busy bit */
  313. #define WI_CMD_INI        0x0000 /* initialize */
  314. #define WI_CMD_ENABLE        0x0001 /* enable */
  315. #define WI_CMD_DISABLE        0x0002 /* disable */
  316. #define WI_CMD_DIAG        0x0003
  317. #define WI_CMD_ALLOC_MEM    0x000A /* allocate NIC memory */
  318. #define WI_CMD_TX        0x000B /* transmit */
  319. #define WI_CMD_NOTIFY        0x0010
  320. #define WI_CMD_INQUIRE        0x0011
  321. #define WI_CMD_ACCESS        0x0021
  322. #define WI_CMD_PROGRAM        0x0022
  323. #define WI_CMD_TEST         0x0038
  324.  
  325. #define WI_CMD_CODE_MASK    0x003F
  326.  
  327. /*
  328.  * Reclaim qualifier bit, applicable to the
  329.  * TX and INQUIRE commands.
  330.  */
  331. #define WI_RECLAIM        0x0100 /* reclaim NIC memory */
  332.  
  333. /*
  334.  * ACCESS command qualifier bits.
  335.  */
  336. #define WI_ACCESS_READ        0x0000
  337. #define WI_ACCESS_WRITE        0x0100
  338.  
  339. /*
  340.  * PROGRAM command qualifier bits.
  341.  */
  342. #define WI_PROGRAM_DISABLE    0x0000
  343. #define WI_PROGRAM_ENABLE_RAM    0x0100
  344. #define WI_PROGRAM_ENABLE_NVRAM    0x0200
  345. #define WI_PROGRAM_NVRAM    0x0300
  346.  
  347. /*
  348.  * TEST command qualifier bits.
  349.  */
  350. #define WI_TEST_MONITOR                0x0B00
  351. #define WI_TEST_STOP           0x0F00
  352.  
  353. /* Status register values */
  354. #define WI_STAT_CMD_CODE    0x003F
  355. #define WI_STAT_DIAG_ERR    0x0100
  356. #define WI_STAT_INQ_ERR        0x0500
  357. #define WI_STAT_CMD_RESULT    0x7F00
  358.  
  359. /* memory handle management registers */
  360. #define WI_INFO_FID        0x10
  361. #define WI_RX_FID        0x20
  362. #define WI_ALLOC_FID        0x22
  363. #define WI_TX_CMP_FID        0x24
  364.  
  365. /*
  366.  * Buffer Access Path (BAP) registers.
  367.  * These are I/O channels. I believe you can use each one for
  368.  * any desired purpose independently of the other. In general
  369.  * though, we use BAP1 for reading and writing LTV records and
  370.  * reading received data frames, and BAP0 for writing transmit
  371.  * frames. This is a convention though, not a rule.
  372.  */
  373. #define WI_SEL0            0x18
  374. #define WI_SEL1            0x1A
  375. #define WI_OFF0            0x1C
  376. #define WI_OFF1            0x1E
  377. #define WI_DATA0        0x36
  378. #define WI_DATA1        0x38
  379. #define WI_BAP0            WI_DATA0
  380. #define WI_BAP1            WI_DATA1
  381.  
  382. #define WI_OFF_BUSY        0x8000
  383. #define WI_OFF_ERR        0x4000
  384. #define WI_OFF_DATAOFF        0x0FFF
  385.  
  386. /* Event registers */
  387. #define WI_EVENT_STAT        0x30    /* Event status */
  388. #define WI_INT_EN        0x32    /* Interrupt enable/disable */
  389. #define WI_EVENT_ACK        0x34    /* Ack event */
  390.  
  391. /* Events */
  392. #define WI_EV_TICK        0x8000    /* aux timer tick */
  393. #define WI_EV_RES        0x4000    /* controller h/w error (time out) */
  394. #define WI_EV_INFO_DROP        0x2000    /* no RAM to build unsolicited frame */
  395. #define WI_EV_NO_CARD        0x0800    /* card removed (hunh?) */
  396. #define WI_EV_DUIF_RX        0x0400    /* wavelan management packet received */
  397. #define WI_EV_INFO        0x0080    /* async info frame */
  398. #define WI_EV_CMD        0x0010    /* command completed */
  399. #define WI_EV_ALLOC        0x0008    /* async alloc/reclaim completed */
  400. #define WI_EV_TX_EXC        0x0004    /* async xmit completed with failure */
  401. #define WI_EV_TX        0x0002    /* async xmit completed succesfully */
  402. #define WI_EV_RX        0x0001    /* async rx completed */
  403.  
  404. #define WI_INTRS    \
  405.     (WI_EV_RX|WI_EV_TX|WI_EV_TX_EXC|WI_EV_ALLOC|WI_EV_INFO|WI_EV_INFO_DROP)
  406.  
  407. /* Host software registers */
  408. #define WI_SW0            0x28
  409. #define WI_SW1            0x2A
  410. #define WI_SW2            0x2C
  411. #define WI_SW3            0x2E
  412.  
  413. #define WI_CNTL            0x14
  414.  
  415. #define WI_CNTL_AUX_ENA        0xC000
  416. #define WI_CNTL_AUX_ENA_STAT    0xC000
  417. #define WI_CNTL_AUX_DIS_STAT    0x0000
  418. #define WI_CNTL_AUX_ENA_CNTL    0x8000
  419. #define WI_CNTL_AUX_DIS_CNTL    0x4000
  420.  
  421. #define WI_AUX_PAGE        0x3A
  422. #define WI_AUX_OFFSET        0x3C
  423. #define WI_AUX_DATA        0x3E
  424.  
  425. #define WI_COR_OFFSET    0x3e0
  426. #define WI_COR_VALUE    0x41
  427.  
  428. /*
  429.  * One form of communication with the Hermes is with what Lucent calls
  430.  * LTV records, where LTV stands for Length, Type and Value. The length
  431.  * and type are 16 bits and are in native byte order. The value is in
  432.  * multiples of 16 bits and is in little endian byte order.
  433.  */
  434. struct wi_ltv_gen {
  435.     u_int16_t        wi_len;
  436.     u_int16_t        wi_type;
  437.     u_int16_t        wi_val;
  438. };
  439.  
  440. struct wi_ltv_str {
  441.     u_int16_t        wi_len;
  442.     u_int16_t        wi_type;
  443.     u_int16_t        wi_str[17];
  444. };
  445.  
  446. #define WI_SETVAL(recno, val)            \
  447.     do {                    \
  448.         struct wi_ltv_gen    g;    \
  449.                         \
  450.         g.wi_len = 2;            \
  451.         g.wi_type = recno;        \
  452.         g.wi_val = val;            \
  453.         wi_write_record(sc, &g);    \
  454.     } while (0)
  455.  
  456. #define WI_SETSTR(recno, str)                    \
  457.     do {                            \
  458.         struct wi_ltv_str    s;            \
  459.         int            l;            \
  460.                                 \
  461.         l = (strlen(str) + 1) & ~0x1;            \
  462.         bzero((char *)&s, sizeof(s));            \
  463.         s.wi_len = (l / 2) + 2;                \
  464.         s.wi_type = recno;                \
  465.         s.wi_str[0] = strlen(str);            \
  466.         bcopy(str, (char *)&s.wi_str[1], strlen(str));    \
  467.         wi_write_record(sc, (struct wi_ltv_gen *)&s);    \
  468.     } while (0)
  469.  
  470. /*
  471.  * Download buffer location and length (0xFD01).
  472.  */
  473. #define WI_RID_DNLD_BUF        0xFD01
  474. struct wi_ltv_dnld_buf {
  475.     u_int16_t        wi_len;
  476.     u_int16_t        wi_type;
  477.     u_int16_t        wi_buf_pg; /* page addr of intermediate dl buf*/
  478.     u_int16_t        wi_buf_off; /* offset of idb */
  479.     u_int16_t        wi_buf_len; /* len of idb */
  480. };
  481.  
  482. /*
  483.  * Mem sizes (0xFD02).
  484.  */
  485. #define WI_RID_MEMSZ        0xFD02
  486. struct wi_ltv_memsz {
  487.     u_int16_t        wi_len;
  488.     u_int16_t        wi_type;
  489.     u_int16_t        wi_mem_ram;
  490.     u_int16_t        wi_mem_nvram;
  491. };
  492.  
  493. /*
  494.  * List of intended regulatory domains (0xFD11).
  495.  */
  496. #define WI_RID_DOMAINS        0xFD11
  497. struct wi_ltv_domains {
  498.     u_int16_t        wi_len;
  499.     u_int16_t        wi_type;
  500.     u_int16_t        wi_domains[6];
  501. };
  502.  
  503. /*
  504.  * CIS struct (0xFD13).
  505.  */
  506. #define WI_RID_CIS        0xFD13
  507. struct wi_ltv_cis {
  508.     u_int16_t        wi_len;
  509.     u_int16_t        wi_type;
  510.     u_int16_t        wi_cis[240];
  511. };
  512.  
  513. /*      
  514.  * station identity (0xFD20)    
  515.  * len: 32
  516.  */     
  517. #define WI_RID_STAID            0xFD20
  518. struct wi_ltv_staid {
  519.         u_int16_t               wi_len;
  520.         u_int16_t               wi_type;
  521.         u_int16_t               wi_data[31];
  522. };      
  523.  
  524. /*
  525.  * Communications quality (0xFD43).
  526.  */
  527. #define WI_RID_COMMQUAL        0xFD43
  528. struct wi_ltv_commqual {
  529.     u_int16_t        wi_len;
  530.     u_int16_t        wi_type;
  531.     u_int16_t        wi_coms_qual;
  532.     u_int16_t        wi_sig_lvl;
  533.     u_int16_t        wi_noise_lvl;
  534. };
  535.  
  536. /*
  537.  * Actual system scale thresholds (0xFD46).
  538.  */
  539. #define WI_RID_SYSTEM_SCALE    0xFC06
  540. #define WI_RID_SCALETHRESH    0xFD46
  541. struct wi_ltv_scalethresh {
  542.     u_int16_t        wi_len;
  543.     u_int16_t        wi_type;
  544.     u_int16_t        wi_energy_detect;
  545.     u_int16_t        wi_carrier_detect;
  546.     u_int16_t        wi_defer;
  547.     u_int16_t        wi_cell_search;
  548.     u_int16_t        wi_out_of_range;
  549.     u_int16_t        wi_delta_snr;
  550. };
  551.  
  552. /*
  553.  * PCF info struct (0xFD87).
  554.  */
  555. #define WI_RID_PCF        0xFD87
  556. struct wi_ltv_pcf {
  557.     u_int16_t        wi_len;
  558.     u_int16_t        wi_type;
  559.     u_int16_t        wi_energy_detect;
  560.     u_int16_t        wi_carrier_detect;
  561.     u_int16_t        wi_defer;
  562.     u_int16_t        wi_cell_search;
  563.     u_int16_t        wi_range;
  564. };
  565.  
  566. /*
  567.  * Connection control characteristics.
  568.  * 1 == Basic Service Set (BSS)
  569.  * 2 == Wireless Distribudion System (WDS)
  570.  * 3 == Pseudo IBSS
  571.  */
  572. #define WI_RID_PORTTYPE        0xFC00
  573. #define WI_PORTTYPE_BSS        0x1
  574. #define WI_PORTTYPE_WDS        0x2
  575. #define WI_PORTTYPE_ADHOC    0x3
  576.  
  577. /*
  578.  * Mac addresses.
  579.  */
  580. #define WI_RID_MAC_NODE        0xFC01
  581. #define WI_RID_MAC_WDS        0xFC08
  582. struct wi_ltv_macaddr {
  583.     u_int16_t        wi_len;
  584.     u_int16_t        wi_type;
  585.     u_int16_t        wi_mac_addr[3];
  586. };
  587.  
  588. /*
  589.  * Station set identification (SSID).
  590.  */
  591. #define WI_RID_DESIRED_SSID    0xFC02
  592. #define WI_RID_OWN_SSID        0xFC04
  593. struct wi_ltv_ssid {
  594.     u_int16_t        wi_len;
  595.     u_int16_t        wi_type;
  596.     u_int16_t        wi_id[17];
  597. };
  598.  
  599. /*
  600.  * Set communications channel (radio frequency).
  601.  */
  602. #define WI_RID_OWN_CHNL        0xFC03
  603.  
  604. /*
  605.  * Frame data size.
  606.  */
  607. #define WI_RID_MAX_DATALEN    0xFC07
  608.  
  609. /*
  610.  * ESS power management enable
  611.  */
  612. #define WI_RID_PM_ENABLED    0xFC09
  613.  
  614. /*
  615.  * ESS max PM sleep internal
  616.  */
  617. #define WI_RID_MAX_SLEEP    0xFC0C
  618.  
  619. /*
  620.  * Set our station name.
  621.  */
  622. #define WI_RID_NODENAME        0xFC0E
  623. struct wi_ltv_nodename {
  624.     u_int16_t        wi_len;
  625.     u_int16_t        wi_type;
  626.     u_int16_t        wi_nodename[17];
  627. };
  628.  
  629. /*
  630.  * Multicast addresses to be put in filter. We're
  631.  * allowed up to 16 addresses in the filter.
  632.  */
  633. #define WI_RID_MCAST        0xFC80
  634. struct wi_ltv_mcast {
  635.     u_int16_t        wi_len;
  636.     u_int16_t        wi_type;
  637.     struct ether_addr    wi_mcast[16];
  638. };
  639.  
  640. /*
  641.  * Request scan for access points. We supply channels
  642.  * and TX rates for the scan.
  643.  */
  644. #define WI_RID_SCAN_RESULT_STABLE      0xFD88
  645. #define WI_RID_SCAN_REQUEST            0xFCE1
  646. struct wi_ltv_scanreq {
  647.        u_int16_t               wi_len;
  648.        u_int16_t               wi_type;
  649.        u_int16_t               wi_channels;
  650.        u_int16_t               wi_txrate;
  651. };
  652.  
  653. /*
  654.  * Create IBSS.
  655.  */
  656. #define WI_RID_CREATE_IBSS    0xFC81
  657.  
  658. #define WI_RID_FRAG_THRESH    0xFC82
  659. #define WI_RID_RTS_THRESH    0xFC83
  660.  
  661. /*
  662.  * TX rate control
  663.  * 0 == Fixed 1mbps
  664.  * 1 == Fixed 2mbps
  665.  * 2 == auto fallback
  666.  */
  667. #define WI_RID_TX_RATE        0xFC84
  668.  
  669. /*
  670.  * promiscuous mode.
  671.  */
  672. #define WI_RID_PROMISC        0xFC85
  673.  
  674. /*
  675.  * Auxiliary Timer tick interval
  676.  */
  677. #define WI_RID_TICK_TIME    0xFCE0
  678.  
  679. /*
  680.  * Information frame types.
  681.  */
  682. #define WI_INFO_NOTIFY        0xF000    /* Handover address */
  683. #define WI_INFO_COUNTERS    0xF100    /* Statistics counters */
  684. #define WI_INFO_SCAN_RESULTS    0xF101    /* Scan results */
  685. #define WI_INFO_LINK_STAT    0xF200    /* Link status */
  686. #define WI_INFO_ASSOC_STAT    0xF201    /* Association status */
  687.  
  688. /*
  689.  * Hermes transmit/receive frame structure
  690.  */
  691. struct wi_frame {
  692.     u_int16_t        wi_status;    /* 0x00 */
  693.     u_int16_t        wi_rsvd0;    /* 0x02 */
  694.     u_int16_t        wi_rsvd1;    /* 0x04 */
  695.     u_int16_t        wi_q_info;    /* 0x06 */
  696.     u_int16_t        wi_rsvd2;    /* 0x08 */
  697.     u_int16_t        wi_rsvd3;    /* 0x0A */
  698.     u_int16_t        wi_tx_ctl;    /* 0x0C */
  699.     u_int16_t        wi_frame_ctl;    /* 0x0E */
  700.     u_int16_t        wi_id;        /* 0x10 */
  701.     u_int8_t        wi_addr1[6];    /* 0x12 */
  702.     u_int8_t        wi_addr2[6];    /* 0x18 */
  703.     u_int8_t        wi_addr3[6];    /* 0x1E */
  704.     u_int16_t        wi_seq_ctl;    /* 0x24 */
  705.     u_int8_t        wi_addr4[6];    /* 0x26 */
  706.     u_int16_t        wi_dat_len;    /* 0x2C */
  707.     u_int8_t        wi_dst_addr[6];    /* 0x2E */
  708.     u_int8_t        wi_src_addr[6];    /* 0x34 */
  709.     u_int16_t        wi_len;        /* 0x3A */
  710.     u_int16_t        wi_dat[3];    /* 0x3C */ /* SNAP header */
  711.     u_int16_t        wi_type;    /* 0x42 */
  712. };
  713.  
  714. #define WI_802_3_OFFSET        0x2E
  715. #define WI_802_11_OFFSET    0x44
  716. #define WI_802_11_OFFSET_RAW    0x3C
  717. #define WI_802_11_OFFSET_HDR    0x0E
  718.  
  719. #define WI_STAT_BADCRC        0x0001
  720. #define WI_STAT_UNDECRYPTABLE    0x0002
  721. #define WI_STAT_ERRSTAT        0x0003
  722. #define WI_STAT_MAC_PORT    0x0700
  723. #define WI_STAT_1042        0x2000    /* RFC1042 encoded */
  724. #define WI_STAT_TUNNEL        0x4000    /* Bridge-tunnel encoded */
  725. #define WI_STAT_WMP_MSG        0x6000    /* WaveLAN-II management protocol */
  726. #define WI_RXSTAT_MSG_TYPE    0xE000
  727.  
  728. #define WI_ENC_TX_802_3        0x00
  729. #define WI_ENC_TX_802_11    0x11
  730. #define WI_ENC_TX_E_II        0x0E
  731.  
  732. #define WI_ENC_TX_1042        0x00
  733. #define WI_ENC_TX_TUNNEL    0xF8
  734.  
  735. #define WI_TXCNTL_MACPORT    0x00FF
  736. #define WI_TXCNTL_STRUCTTYPE    0xFF00
  737.  
  738. /*
  739.  * SNAP (sub-network access protocol) constants for transmission
  740.  * of IP datagrams over IEEE 802 networks, taken from RFC1042.
  741.  * We need these for the LLC/SNAP header fields in the TX/RX frame
  742.  * structure.
  743.  */
  744. #define WI_SNAP_K1        0xaa    /* assigned global SAP for SNAP */
  745. #define WI_SNAP_K2        0x00
  746. #define WI_SNAP_CONTROL        0x03    /* unnumbered information format */
  747. #define WI_SNAP_WORD0        (WI_SNAP_K1 | (WI_SNAP_K1 << 8))
  748. #define WI_SNAP_WORD1        (WI_SNAP_K2 | (WI_SNAP_CONTROL << 8))
  749. #define WI_SNAPHDR_LEN        0x6
  750.