root/dev/pcmcia/if_malovar.h

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

INCLUDED FROM


    1 /*      $OpenBSD: if_malovar.h,v 1.24 2007/08/09 21:24:02 mglocker Exp $ */
    2 
    3 /*
    4  * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
    5  *
    6  * Permission to use, copy, modify, and distribute this software for any
    7  * purpose with or without fee is hereby granted, provided that the above
    8  * copyright notice and this permission notice appear in all copies.
    9  *
   10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   17  */
   18 
   19 /* simplify bus space access */
   20 #define MALO_READ_1(sc, reg) \
   21         bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (reg))
   22 #define MALO_READ_2(sc, reg) \
   23         bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (reg))
   24 #define MALO_READ_MULTI_2(sc, reg, off, size) \
   25         bus_space_read_raw_multi_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), \
   26         (size))
   27 #define MALO_WRITE_1(sc, reg, val) \
   28         bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
   29 #define MALO_WRITE_2(sc, reg, val) \
   30         bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
   31 #define MALO_WRITE_MULTI_2(sc, reg, off, size) \
   32         bus_space_write_raw_multi_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), \
   33         (size))
   34 
   35 /* miscellaneous */
   36 #define MALO_FW_HELPER_BSIZE    256     /* helper FW block size */
   37 #define MALO_FW_HELPER_LOADED   0x10    /* helper FW loaded */
   38 #define MALO_FW_MAIN_MAXRETRY   20      /* main FW block resend max retry */
   39 #define MALO_CMD_BUFFER_SIZE    256     /* cmd buffer */
   40 
   41 /* device flags */
   42 #define MALO_DEVICE_ATTACHED    (1 << 0)
   43 #define MALO_FW_LOADED          (1 << 1)
   44 #define MALO_ASSOC_FAILED       (1 << 2)
   45 
   46 /*
   47  * FW command structures
   48  */
   49 struct malo_cmd_header {
   50         uint16_t        cmd;
   51         uint16_t        size;
   52         uint16_t        seqnum;
   53         uint16_t        result;
   54         /* malo_cmd_body */
   55 };
   56 
   57 struct malo_cmd_body_spec {
   58         uint16_t        hw_if_version;
   59         uint16_t        hw_version;
   60         uint16_t        num_of_wcb;
   61         uint16_t        num_of_mcast;
   62         uint8_t         macaddr[ETHER_ADDR_LEN];
   63         uint16_t        regioncode;
   64         uint16_t        num_of_antenna;
   65         uint32_t        fw_version;
   66         uint32_t        wcbbase;
   67         uint32_t        rxpdrdptr;
   68         uint32_t        rxpdwrptr;
   69         uint32_t        fw_capinfo;
   70 } __packed;
   71 
   72 struct malo_cmd_body_scan {
   73         uint8_t         bsstype;
   74         uint8_t         bssid[ETHER_ADDR_LEN];
   75         /* malo_cmd_tlv_ssid */
   76         /* malo_cmd_tlv_chanlist */
   77         /* malo_cmd_tlv_rates */
   78         /* malo_cmd_tlv_numprobes */
   79 } __packed;
   80 
   81 struct malo_cmd_body_rsp_scan {
   82         uint16_t        bufsize;
   83         uint8_t         numofset;
   84 } __packed;
   85 struct malo_cmd_body_rsp_scan_set {
   86         uint16_t        size;
   87         uint8_t         bssid[ETHER_ADDR_LEN];
   88         uint8_t         rssi;
   89         uint8_t         timestamp[8];
   90         uint16_t        beaconintvl;
   91         uint16_t        capinfo;
   92 } __packed;
   93 
   94 struct malo_cmd_body_auth {
   95         uint8_t         peermac[ETHER_ADDR_LEN];
   96         uint8_t         authtype;
   97 } __packed;
   98 
   99 #define MALO_WEP_ACTION_TYPE_ADD        0x02
  100 #define MALO_WEP_ACTION_TYPE_REMOVE     0x04
  101 #define MALO_WEP_ACTION_TYPE_DEFAULT    0x08
  102 #define MALO_WEP_KEY_TYPE_40BIT         0x01
  103 #define MALO_WEP_KEY_TYPE_104BIT        0x02
  104 struct malo_cmd_body_wep {
  105         uint16_t        action;
  106         uint16_t        key_index;
  107         uint8_t         key_type_1;
  108         uint8_t         key_type_2;
  109         uint8_t         key_type_3;
  110         uint8_t         key_type_4;
  111         uint8_t         key_value_1[16];
  112         uint8_t         key_value_2[16];
  113         uint8_t         key_value_3[16];
  114         uint8_t         key_value_4[16];
  115 } __packed;
  116 
  117 #define MALO_OID_BSS            0x00
  118 #define MALO_OID_RATE           0x01
  119 #define MALO_OID_BCNPERIOD      0x02
  120 #define MALO_OID_DTIMPERIOD     0x03
  121 #define MALO_OID_ASSOCTIMEOUT   0x04
  122 #define MALO_OID_RTSTRESH       0x05
  123 #define MALO_OID_SHORTRETRY     0x06
  124 #define MALO_OID_LONGRETRY      0x07
  125 #define MALO_OID_FRAGTRESH      0x08
  126 #define MALO_OID_80211D         0x09
  127 #define MALO_OID_80211H         0x0a
  128 struct malo_cmd_body_snmp {
  129         uint16_t        action;
  130         uint16_t        oid;
  131         uint16_t        size;
  132         uint8_t         data[128];
  133 } __packed;
  134 
  135 struct malo_cmd_body_radio {
  136         uint16_t        action;
  137         uint16_t        control;
  138 } __packed;
  139 
  140 struct malo_cmd_body_channel {
  141         uint16_t        action;
  142         uint16_t        channel;
  143         uint16_t        rftype;
  144         uint16_t        reserved;
  145         uint8_t         channel_list[32];
  146 } __packed;
  147 
  148 struct malo_cmd_body_txpower {
  149         uint16_t        action;
  150         int16_t         txpower;        
  151 } __packed;
  152 
  153 struct malo_cmd_body_antenna {
  154         uint16_t        action;
  155         uint16_t        antenna_mode;
  156 } __packed;
  157 
  158 struct malo_cmd_body_macctrl {
  159         uint16_t        action;
  160         uint16_t        reserved;
  161 } __packed;
  162 
  163 struct malo_cmd_body_assoc {
  164         uint8_t         peermac[ETHER_ADDR_LEN];
  165         uint16_t        capinfo;
  166         uint16_t        listenintrv;
  167         uint16_t        bcnperiod;
  168         uint8_t         dtimperiod;
  169         /* malo_cmd_tlv_ssid */
  170         /* malo_cmd_tlv_phy */
  171         /* malo_cmd_tlv_cf */
  172         /* malo_cmd_tlv_rate */
  173 } __packed;
  174 
  175 struct malo_cmd_body_rsp_assoc {
  176         uint16_t        capinfo;
  177         uint16_t        status;
  178         uint16_t        assoc_id;
  179         uint16_t        info_len;
  180         /* uint8_t      info[270] */
  181 } __packed;
  182 
  183 struct malo_cmd_body_80211d {
  184         uint16_t        action;
  185         /* malo_cmd_tlv_80211d */
  186 } __packed;
  187 
  188 struct malo_cmd_body_bgscan_config {
  189         uint16_t        action;
  190         uint8_t         enable;
  191         uint8_t         bsstype;
  192         uint8_t         chperscan;
  193         uint8_t         discard;
  194         uint16_t        reserved;
  195         uint32_t        scanintvl;
  196         uint32_t        storecond;
  197         uint32_t        reportcond;
  198         uint16_t        maxscanres;
  199 } __packed;
  200 
  201 struct malo_cmd_body_bgscan_query {
  202         uint8_t         flush;
  203 } __packed;
  204 
  205 struct malo_cmd_body_rate {
  206         uint16_t        action;
  207         uint16_t        hwauto;
  208         uint16_t        ratebitmap;
  209 } __packed;
  210 
  211 /*
  212  * FW command TLV structures
  213  */
  214 #define MALO_TLV_TYPE_SSID      0x0000
  215 #define MALO_TLV_TYPE_RATES     0x0001
  216 #define MALO_TLV_TYPE_PHY       0x0003
  217 #define MALO_TLV_TYPE_CF        0x0004
  218 #define MALO_TLV_TYPE_80211D    0x0007
  219 #define MALO_TLV_TYPE_CHANLIST  0x0101
  220 #define MALO_TLV_TYPE_NUMPROBES 0x0102
  221 #define MALO_TLV_TYPE_PASSEID   0x010a
  222 
  223 struct malo_cmd_tlv_ssid {
  224         uint16_t        type;
  225         uint16_t        size;
  226         uint8_t         data[1];
  227 } __packed;
  228 
  229 struct malo_cmd_tlv_rates {
  230         uint16_t        type;
  231         uint16_t        size;
  232         uint8_t         data[1];
  233 } __packed;
  234 
  235 struct malo_cmd_tlv_phy {
  236         uint16_t        type;
  237         uint16_t        size;
  238         uint8_t         data[1];
  239 } __packed;
  240 
  241 struct malo_cmd_tlv_cf {
  242         uint16_t        type;
  243         uint16_t        size;
  244         uint8_t         data[1];
  245 } __packed;
  246 
  247 struct malo_cmd_tlv_80211d_param {
  248         uint8_t         firstchannel;
  249         uint8_t         numchannels;
  250         uint8_t         maxtxpower;
  251 } __packed;
  252 struct malo_cmd_tlv_80211d {
  253         uint16_t        type;
  254         uint16_t        size;
  255         uint8_t         countrycode[3];
  256         struct malo_cmd_tlv_80211d_param data[12];
  257 } __packed;
  258 
  259 struct malo_cmd_tlv_chanlist_param {
  260         uint8_t         radiotype;
  261         uint8_t         channumber;
  262         uint8_t         scantype;
  263         uint16_t        minscantime;
  264         uint16_t        maxscantime;
  265 } __packed;
  266 #define CHANNELS        12
  267 struct malo_cmd_tlv_chanlist {
  268         uint16_t        type;
  269         uint16_t        size;
  270         struct malo_cmd_tlv_chanlist_param data[CHANNELS];
  271 } __packed;
  272 
  273 struct malo_cmd_tlv_numprobes {
  274         uint16_t        type;
  275         uint16_t        size;
  276         uint16_t        numprobes;
  277 } __packed;
  278 
  279 struct malo_cmd_tlv_passeid {
  280         uint16_t        type;
  281         uint16_t        size;
  282         uint8_t         data[1];
  283 } __packed;
  284 
  285 /* RX descriptor */
  286 #define MALO_RX_STATUS_OK       0x0001
  287 struct malo_rx_desc {
  288         uint16_t        status;
  289         uint8_t         snr;
  290         uint8_t         control;
  291         uint16_t        pkglen;
  292         uint8_t         nf;
  293         uint8_t         rate;
  294         uint32_t        pkgoffset;
  295         uint32_t        reserved1;
  296         uint8_t         priority;
  297         uint8_t         reserved2[3];
  298 } __packed;
  299 
  300 /* TX descriptor */
  301 struct malo_tx_desc {
  302         uint32_t        status;
  303         uint32_t        control;
  304         uint32_t        pkgoffset;
  305         uint16_t        pkglen;
  306         uint8_t         dstaddrhigh[2];
  307         uint8_t         dstaddrlow[4];
  308         uint8_t         priority;
  309         uint8_t         flags;
  310         uint8_t         reserved[2];
  311 } __packed;
  312 
  313 /* scanned network */
  314 struct malo_networks {
  315         uint8_t         bssid[ETHER_ADDR_LEN];
  316         uint8_t         rssi;
  317         uint8_t         timestamp[8];
  318         uint16_t        beaconintvl;
  319         uint16_t        capinfo;
  320         uint8_t         ssid[32];
  321         uint8_t         rates[14];
  322         uint8_t         channel;
  323 } __packed;
  324 
  325 /*
  326  * Softc
  327  */
  328 struct malo_softc {
  329         struct device            sc_dev;
  330         struct ieee80211com      sc_ic;
  331         bus_space_tag_t          sc_iot;
  332         bus_space_handle_t       sc_ioh;
  333         int                      (*sc_newstate)
  334                                  (struct ieee80211com *, enum ieee80211_state,
  335                                      int);
  336 
  337         int                      sc_flags;
  338         int                      sc_cmd_ctxsave;
  339         void                    *sc_cmd;
  340         void                    *sc_data;
  341         uint8_t                  sc_curchan;
  342         int                      sc_net_num;
  343         int                      sc_net_cur;
  344         struct malo_networks     sc_net[12];
  345         struct timeout           sc_scan_to;
  346 };

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