diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-06-25 21:11:18 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-06-25 21:11:18 +0000 |
commit | 5a91e6ce42250218ea9e9db378a9c8c5830e2aa9 (patch) | |
tree | 752e6275461b8d18f291faebe4edd55807065e21 | |
parent | ae3fa35e6ecb76a53483ecd337373d10b1cdd194 (diff) |
remove struct and contsts duplicated in between the files.
make it work on powerpc.
improve performance by using the bus_*_multi_* finctions instead of loops.
-rw-r--r-- | sys/dev/ic/an.c | 262 | ||||
-rw-r--r-- | sys/dev/ic/anreg.h | 542 | ||||
-rw-r--r-- | sys/dev/ic/anvar.h | 113 |
3 files changed, 327 insertions, 590 deletions
diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 80b4820cf92..7a10311b013 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $OpenBSD: an.c,v 1.17 2001/06/23 23:36:02 mickey Exp $ */ +/* $OpenBSD: an.c,v 1.18 2001/06/25 21:11:16 mickey Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -163,6 +163,13 @@ void an_cache_store __P((struct an_softc *, struct ether_header *, struct mbuf *, unsigned short)); #endif +static __inline void +an_swap16(u_int16_t *p, int cnt) +{ + for (; cnt--; p++) + *p = swap16(*p); +} + int an_attach(sc) struct an_softc *sc; @@ -321,14 +328,13 @@ an_rxeof(sc) } /* Check for insane frame length */ - if (rx_frame_802_3.an_rx_802_3_payload_len > MCLBYTES) { + if (letoh16(rx_frame_802_3.an_rx_802_3_payload_len) > MCLBYTES) { ifp->if_ierrors++; return; } m->m_pkthdr.len = m->m_len = - rx_frame_802_3.an_rx_802_3_payload_len + 12; - + letoh16(rx_frame_802_3.an_rx_802_3_payload_len) + 12; bcopy((char *)&rx_frame_802_3.an_rx_dst_addr, (char *)&eh->ether_dhost, ETHER_ADDR_LEN); @@ -337,8 +343,7 @@ an_rxeof(sc) /* in mbuf header type is just before payload */ error = an_read_data(sc, id, 0x44, (caddr_t)&(eh->ether_type), - rx_frame_802_3.an_rx_802_3_payload_len); - + letoh16(rx_frame_802_3.an_rx_802_3_payload_len)); if (error) { m_freem(m); ifp->if_ierrors++; @@ -362,11 +367,11 @@ an_rxeof(sc) void an_txeof(sc, status) - struct an_softc *sc; - int status; + struct an_softc *sc; + int status; { - struct ifnet *ifp; - int id; + struct ifnet *ifp; + int id; ifp = &sc->arpcom.ac_if; @@ -375,9 +380,9 @@ an_txeof(sc, status) id = CSR_READ_2(sc, AN_TX_CMP_FID); - if (status & AN_EV_TX_EXC) { + if (status & AN_EV_TX_EXC) ifp->if_oerrors++; - } else + else ifp->if_opackets++; if (id != sc->an_rdata.an_tx_ring[sc->an_rdata.an_tx_cons]) @@ -576,8 +581,8 @@ an_read_record(sc, ltv) struct an_softc *sc; struct an_ltv_gen *ltv; { - u_int16_t *ptr; - int i, len; + u_int16_t *ptr, len; + int i; if (ltv->an_len == 0 || ltv->an_type == 0) return(EINVAL); @@ -612,10 +617,51 @@ an_read_record(sc, ltv) ltv->an_len = len; /* Now read the data. */ - ptr = <v->an_val; + ptr = ltv->an_val; for (i = 0; i < (ltv->an_len - 1) >> 1; i++) ptr[i] = CSR_READ_2(sc, AN_DATA1); +#if BYTE_ORDER == BIG_ENDIAN + switch (ltv->an_type) { + case AN_RID_GENCONFIG: + an_swap16(<v->an_val[4], 7); /* an_macaddr, an_rates */ + an_swap16(<v->an_val[63], 8); /* an_nodename */ + break; + case AN_RID_SSIDLIST: + an_swap16(<v->an_val[1], 16); /* an_ssid1 */ + an_swap16(<v->an_val[18], 16); /* an_ssid2 */ + an_swap16(<v->an_val[35], 16); /* an_ssid3 */ + break; + case AN_RID_APLIST: + an_swap16(ltv->an_val, 12); + break; + case AN_RID_DRVNAME: + an_swap16(ltv->an_val, 8); + break; + case AN_RID_CAPABILITIES: + an_swap16(ltv->an_val, 2); /* an_oui */ + an_swap16(<v->an_val[3], 34); /* an_manufname .. an_aironetaddr */ + an_swap16(<v->an_val[39], 8); /* an_callid .. an_tx_diversity */ + break; + case AN_RID_STATUS: + an_swap16(<v->an_val[0], 3); /* an_macaddr */ + an_swap16(<v->an_val[7], 36); /* an_ssid .. an_prev_bssid3 */ + an_swap16(<v->an_val[0x74/2], 2); /* an_ap_ip_addr */ + break; + case AN_RID_WEP_VOLATILE: + case AN_RID_WEP_PERMANENT: + an_swap16(<v->an_val[1], 3); /* an_mac_addr */ + an_swap16(<v->an_val[5], 6); + break; + case AN_RID_32BITS_CUM: + for (i = 0x60; i--; ) { + u_int16_t t = ltv->an_val[i * 2] ^ ltv->an_val[i * 2 + 1]; + ltv->an_val[i * 2] ^= t; + ltv->an_val[i * 2 + 1] ^= t; + } + break; + } +#endif return(0); } @@ -627,8 +673,8 @@ an_write_record(sc, ltv) struct an_softc *sc; struct an_ltv_gen *ltv; { - u_int16_t *ptr; - int i; + u_int16_t *ptr; + int i; if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) return(EIO); @@ -636,9 +682,44 @@ an_write_record(sc, ltv) if (an_seek(sc, ltv->an_type, 0, AN_BAP1)) return(EIO); +#if BYTE_ORDER == BIG_ENDIAN + switch (ltv->an_type) { + case AN_RID_GENCONFIG: + an_swap16(<v->an_val[4], 7); /* an_macaddr, an_rates */ + an_swap16(<v->an_val[63], 8); /* an_nodename */ + break; + case AN_RID_SSIDLIST: + an_swap16(<v->an_val[1], 16); /* an_ssid1 */ + an_swap16(<v->an_val[18], 16); /* an_ssid2 */ + an_swap16(<v->an_val[35], 16); /* an_ssid3 */ + break; + case AN_RID_APLIST: + an_swap16(ltv->an_val, 12); + break; + case AN_RID_DRVNAME: + an_swap16(ltv->an_val, 8); + break; + case AN_RID_CAPABILITIES: + an_swap16(ltv->an_val, 2); /* an_oui */ + an_swap16(<v->an_val[3], 34); /* an_manufname .. an_aironetaddr */ + an_swap16(<v->an_val[39], 8); /* an_callid .. an_tx_diversity */ + break; + case AN_RID_STATUS: + an_swap16(<v->an_val[0], 3); /* an_macaddr */ + an_swap16(<v->an_val[7], 36); /* an_ssid .. an_prev_bssid3 */ + an_swap16(<v->an_val[0x74/2], 2); /* an_ap_ip_addr */ + break; + case AN_RID_WEP_VOLATILE: + case AN_RID_WEP_PERMANENT: + an_swap16(<v->an_val[1], 3); /* an_mac_addr */ + an_swap16(<v->an_val[5], 6); + break; + } +#endif + CSR_WRITE_2(sc, AN_DATA1, ltv->an_len); - ptr = <v->an_val; + ptr = ltv->an_val; for (i = 0; i < (ltv->an_len - 1) >> 1; i++) CSR_WRITE_2(sc, AN_DATA1, ptr[i]); @@ -668,7 +749,7 @@ an_seek(sc, id, off, chan) default: printf("%s: invalid data path: %x\n", sc->sc_dev.dv_xname, chan); - return(EIO); + return (EIO); } CSR_WRITE_2(sc, selreg, id); @@ -682,7 +763,7 @@ an_seek(sc, id, off, chan) if (i <= 0) return(ETIMEDOUT); - return(0); + return (0); } int @@ -692,25 +773,15 @@ an_read_data(sc, id, off, buf, len) caddr_t buf; int len; { - int i; - u_int16_t *ptr; - u_int8_t *ptr2; - - if (off != -1) { - if (an_seek(sc, id, off, AN_BAP1)) - return(EIO); - } + if (off != -1 && an_seek(sc, id, off, AN_BAP1)) + return(EIO); - ptr = (u_int16_t *)buf; - for (i = 0; i < len / 2; i++) - ptr[i] = CSR_READ_2(sc, AN_DATA1); - i*=2; - if (i<len){ - ptr2 = (u_int8_t *)buf; - ptr2[i] = CSR_READ_1(sc, AN_DATA1); - } + bus_space_read_raw_multi_2(sc->an_btag, sc->an_bhandle, + AN_DATA1, buf, len & ~1); + if (len & 1) + ((u_int8_t *)buf)[len - 1] = CSR_READ_1(sc, AN_DATA1); - return(0); + return (0); } int @@ -720,25 +791,15 @@ an_write_data(sc, id, off, buf, len) caddr_t buf; int len; { - int i; - u_int16_t *ptr; - u_int8_t *ptr2; - - if (off != -1) { - if (an_seek(sc, id, off, AN_BAP0)) - return(EIO); - } + if (off != -1 && an_seek(sc, id, off, AN_BAP0)) + return(EIO); - ptr = (u_int16_t *)buf; - for (i = 0; i < (len / 2); i++) - CSR_WRITE_2(sc, AN_DATA0, ptr[i]); - i*=2; - if (i<len){ - ptr2 = (u_int8_t *)buf; - CSR_WRITE_1(sc, AN_DATA0, ptr2[i]); - } + bus_space_write_raw_multi_2(sc->an_btag, sc->an_bhandle, + AN_DATA0, buf, len & ~1); + if (len & 1) + CSR_WRITE_1(sc, AN_DATA0, ((u_int8_t *)buf)[len - 1]); - return(0); + return (0); } /* @@ -773,8 +834,9 @@ an_alloc_nicmem(sc, len, id) if (an_seek(sc, *id, 0, AN_BAP0)) return(EIO); - for (i = 0; i < len / 2; i++) - CSR_WRITE_2(sc, AN_DATA0, 0); + bus_space_set_multi_2(sc->an_btag, sc->an_bhandle, + AN_DATA0, 0, len / 2); + CSR_WRITE_1(sc, AN_DATA0, 0); return(0); } @@ -820,7 +882,7 @@ an_setdef(sc, areq) break; case AN_RID_TX_SPEED: sp = (struct an_ltv_gen *)areq; - sc->an_tx_rate = sp->an_val; + sc->an_tx_rate = sp->an_val[0]; break; case AN_RID_WEP_VOLATILE: /* Disable the MAC */ @@ -865,13 +927,14 @@ an_promisc(sc, promisc) struct an_softc *sc; int promisc; { + struct an_ltv_genconfig genconf; + /* Disable the MAC. */ an_cmd(sc, AN_CMD_DISABLE, 0); /* Set RX mode. */ if (promisc && - !(sc->an_config.an_rxmode & AN_RXMODE_LAN_MONITOR_CURBSS) - ) { + !(sc->an_config.an_rxmode & AN_RXMODE_LAN_MONITOR_CURBSS) ) { sc->an_rxmode = sc->an_config.an_rxmode; sc->an_config.an_rxmode |= AN_RXMODE_LAN_MONITOR_CURBSS; @@ -880,9 +943,10 @@ an_promisc(sc, promisc) } /* Transfer the configuration to the NIC */ - sc->an_config.an_len = sizeof(struct an_ltv_genconfig); - sc->an_config.an_type = AN_RID_GENCONFIG; - if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) { + genconf = sc->an_config; + genconf.an_len = sizeof(struct an_ltv_genconfig); + genconf.an_type = AN_RID_GENCONFIG; + if (an_write_record(sc, (struct an_ltv_gen *)&genconf)) { printf("%s: failed to set configuration\n", sc->sc_dev.dv_xname); return; @@ -1035,7 +1099,10 @@ an_init(sc) struct an_softc *sc; { struct ifnet *ifp = &sc->arpcom.ac_if; - int s; + struct an_ltv_ssidlist ssid; + struct an_ltv_aplist aplist; + struct an_ltv_genconfig genconf; + int s; if (sc->an_gone) return; @@ -1074,27 +1141,30 @@ an_init(sc) sc->an_rxmode = sc->an_config.an_rxmode; /* Set the ssid list */ - sc->an_ssidlist.an_type = AN_RID_SSIDLIST; - sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist); - if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) { + ssid = sc->an_ssidlist; + ssid.an_type = AN_RID_SSIDLIST; + ssid.an_len = sizeof(struct an_ltv_ssidlist); + if (an_write_record(sc, (struct an_ltv_gen *)&ssid)) { printf("%s: failed to set ssid list\n", sc->sc_dev.dv_xname); splx(s); return; } /* Set the AP list */ - sc->an_aplist.an_type = AN_RID_APLIST; - sc->an_aplist.an_len = sizeof(struct an_ltv_aplist); - if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) { + aplist = sc->an_aplist; + aplist.an_type = AN_RID_APLIST; + aplist.an_len = sizeof(struct an_ltv_aplist); + if (an_write_record(sc, (struct an_ltv_gen *)&aplist)) { printf("%s: failed to set AP list\n", sc->sc_dev.dv_xname); splx(s); return; } /* Set the configuration in the NIC */ - sc->an_config.an_len = sizeof(struct an_ltv_genconfig); - sc->an_config.an_type = AN_RID_GENCONFIG; - if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) { + genconf = sc->an_config; + genconf.an_len = sizeof(struct an_ltv_genconfig); + genconf.an_type = AN_RID_GENCONFIG; + if (an_write_record(sc, (struct an_ltv_gen *)&genconf)) { printf("%s: failed to set configuration\n", sc->sc_dev.dv_xname); splx(s); @@ -1127,6 +1197,7 @@ an_start(ifp) struct mbuf *m0 = NULL; struct an_txframe_802_3 tx_frame_802_3; struct ether_header *eh; + u_int16_t len; int id; int idx; unsigned char txcontrol; @@ -1158,11 +1229,10 @@ an_start(ifp) bcopy((char *)&eh->ether_shost, (char *)&tx_frame_802_3.an_tx_src_addr, ETHER_ADDR_LEN); - tx_frame_802_3.an_tx_802_3_payload_len = - m0->m_pkthdr.len - 12; /* minus src/dest mac & type */ + len = m0->m_pkthdr.len - 12; /* minus src/dest mac & type */ + tx_frame_802_3.an_tx_802_3_payload_len = htole16(len); - m_copydata(m0, sizeof(struct ether_header) - 2 , - tx_frame_802_3.an_tx_802_3_payload_len, + m_copydata(m0, sizeof(struct ether_header) - 2, len, (caddr_t)&sc->an_txbuf); txcontrol=AN_TXCTL_8023; @@ -1175,8 +1245,7 @@ an_start(ifp) sizeof(struct an_txframe_802_3)); /* in mbuf header type is just before payload */ - an_write_data(sc, id, 0x44, (caddr_t)&sc->an_txbuf, - tx_frame_802_3.an_tx_802_3_payload_len); + an_write_data(sc, id, 0x44, (caddr_t)&sc->an_txbuf, len); /* * If there's a BPF listner, bounce a copy of @@ -1339,59 +1408,50 @@ an_cache_store (sc, eh, m, rx_quality) * keep multicast only. */ - if ((ntohs(eh->ether_type) == 0x800)) { + if ((ntohs(eh->ether_type) == 0x800)) saanp = 1; - } /* filter for ip packets only */ - if (sc->an_cache_iponly && !saanp) { + if (sc->an_cache_iponly && !saanp) return; - } - /* filter for broadcast/multicast only - */ - if (sc->an_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) { + /* filter for broadcast/multicast only */ + if (sc->an_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) return; - } #ifdef SIGDEBUG printf("an: q value %x (MSB=0x%x, LSB=0x%x) \n", rx_quality & 0xffff, rx_quality >> 8, rx_quality & 0xff); #endif - /* find the ip header. we want to store the ip_src - * address. - */ - if (saanp) { + /* find the ip header. we want to store the ip_src address */ + if (saanp) ip = (struct ip *)(mtod(m, char *) + sizeof(struct ether_header)); - } /* do a linear search for a matching MAC address * in the cache table * . MAC address is 6 bytes, * . var w_nextitem holds total number of entries already cached */ - for(i = 0; i < sc->an_nextitem; i++) { - if (!bcmp(eh->ether_shost , sc->an_sigcache[i].macsrc, 6)) { + for(i = 0; i < sc->an_nextitem; i++) + if (!bcmp(eh->ether_shost , sc->an_sigcache[i].macsrc, 6)) /* Match!, * so we already have this entry, update the data */ break; - } - } /* did we find a matching mac address? * if yes, then overwrite a previously existing cache entry */ - if (i < sc->an_nextitem ) { + if (i < sc->an_nextitem ) cache_slot = i; - } + /* else, have a new address entry,so * add this new entry, * if table full, then we need to replace LRU entry */ - else { + else { /* check for space in cache table * note: an_nextitem also holds number of entries @@ -1406,9 +1466,8 @@ an_cache_store (sc, eh, m, rx_quality) * and "zap" the next entry */ else { - if (wrapindex == MAXANCACHE) { + if (wrapindex == MAXANCACHE) wrapindex = 0; - } cache_slot = wrapindex++; } } @@ -1428,9 +1487,8 @@ an_cache_store (sc, eh, m, rx_quality) * .mac src * .signal, etc. */ - if (saanp) { + if (saanp) sc->an_sigcache[cache_slot].ipsrc = ip->ip_src.s_addr; - } bcopy( eh->ether_shost, sc->an_sigcache[cache_slot].macsrc, 6); sc->an_sigcache[cache_slot].signal = rx_quality; diff --git a/sys/dev/ic/anreg.h b/sys/dev/ic/anreg.h index bc6a9a9094f..902afd048c2 100644 --- a/sys/dev/ic/anreg.h +++ b/sys/dev/ic/anreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: anreg.h,v 1.6 2001/04/06 19:14:55 deraadt Exp $ */ +/* $OpenBSD: anreg.h,v 1.7 2001/06/25 21:11:17 mickey Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -34,6 +34,8 @@ * $FreeBSD: src/sys/dev/an/if_anreg.h,v 1.1 2000/01/14 20:40:56 wpaul Exp $ */ +#pragma pack(1) + #define AN_TIMEOUT 65536 /* Default network name: empty string */ @@ -80,22 +82,22 @@ #define AN_LINKSTAT 0x10 /* Command register */ -#define AN_CMD_BUSY 0x8000 /* busy bit */ -#define AN_CMD_NO_ACK 0x0080 /* don't acknowledge command */ +#define AN_CMD_BUSY 0x8000 /* busy bit */ +#define AN_CMD_NO_ACK 0x0080 /* don't acknowledge command */ #define AN_CMD_CODE_MASK 0x003F #define AN_CMD_QUAL_MASK 0x7F00 /* Command codes */ -#define AN_CMD_NOOP 0x0000 /* no-op */ -#define AN_CMD_ENABLE 0x0001 /* enable */ -#define AN_CMD_DISABLE 0x0002 /* disable */ -#define AN_CMD_FORCE_SYNCLOSS 0x0003 /* force loss of sync */ -#define AN_CMD_FW_RESTART 0x0004 /* firmware resrart */ +#define AN_CMD_NOOP 0x0000 /* no-op */ +#define AN_CMD_ENABLE 0x0001 /* enable */ +#define AN_CMD_DISABLE 0x0002 /* disable */ +#define AN_CMD_FORCE_SYNCLOSS 0x0003 /* force loss of sync */ +#define AN_CMD_FW_RESTART 0x0004 /* firmware resrart */ #define AN_CMD_HOST_SLEEP 0x0005 #define AN_CMD_MAGIC_PKT 0x0006 #define AN_CMD_READCFG 0x0008 -#define AN_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */ -#define AN_CMD_TX 0x000B /* transmit */ +#define AN_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */ +#define AN_CMD_TX 0x000B /* transmit */ #define AN_CMD_DEALLOC_MEM 0x000C #define AN_CMD_NOOP2 0x0010 #define AN_CMD_ACCESS 0x0021 @@ -110,7 +112,7 @@ * Reclaim qualifier bit, applicable to the * TX command. */ -#define AN_RECLAIM 0x0100 /* reclaim NIC memory */ +#define AN_RECLAIM 0x0100 /* reclaim NIC memory */ /* * ACCESS command qualifier bits. @@ -212,83 +214,7 @@ struct an_ltv_gen { u_int16_t an_len; u_int16_t an_type; - u_int16_t an_val; -}; - -/* - * General configuration information. - */ -#define AN_RID_GENCONFIG 0xFF10 -struct an_ltv_genconfig { - /* General configuration. */ - u_int16_t an_len; /* 0x00 */ - u_int16_t an_type; /* XXXX */ - u_int16_t an_opmode; /* 0x02 */ - u_int16_t an_rxmode; /* 0x04 */ - u_int16_t an_fragthresh; /* 0x06 */ - u_int16_t an_rtsthresh; /* 0x08 */ - u_int8_t an_macaddr[6]; /* 0x0A */ - u_int8_t an_rates[8]; /* 0x10 */ - u_int16_t an_shortretry_limit; /* 0x18 */ - u_int16_t an_longretry_limit; /* 0x1A */ - u_int16_t an_tx_msdu_lifetime; /* 0x1C */ - u_int16_t an_rx_msdu_lifetime; /* 0x1E */ - u_int16_t an_stationary; /* 0x20 */ - u_int16_t an_ordering; /* 0x22 */ - u_int16_t an_devtype; /* 0x24 */ - u_int16_t an_rsvd0[5]; /* 0x26 */ - /* Scanning associating. */ - u_int16_t an_scanmode; /* 0x30 */ - u_int16_t an_probedelay; /* 0x32 */ - u_int16_t an_probe_energy_timeout;/* 0x34 */ - u_int16_t an_probe_response_timeout;/*0x36 */ - u_int16_t an_beacon_listen_timeout;/*0x38 */ - u_int16_t an_ibss_join_net_timeout;/*0x3A */ - u_int16_t an_auth_timeout; /* 0x3C */ - u_int16_t an_authtype; /* 0x3E */ - u_int16_t an_assoc_timeout; /* 0x40 */ - u_int16_t an_specified_ap_timeout;/* 0x42 */ - u_int16_t an_offline_scan_interval;/*0x44 */ - u_int16_t an_offline_scan_duration;/*0x46 */ - u_int16_t an_link_loss_delay; /* 0x48 */ - u_int16_t an_max_beacon_lost_time;/* 0x4A */ - u_int16_t an_refresh_interval; /* 0x4C */ - u_int16_t an_rsvd1; /* 0x4E */ - /* Power save operation */ - u_int16_t an_psave_mode; /* 0x50 */ - u_int16_t an_sleep_for_dtims; /* 0x52 */ - u_int16_t an_listen_interval; /* 0x54 */ - u_int16_t an_fast_listen_interval;/* 0x56 */ - u_int16_t an_listen_decay; /* 0x58 */ - u_int16_t an_fast_listen_decay; /* 0x5A */ - u_int16_t an_rsvd2[2]; /* 0x5C */ - /* Ad-hoc (or AP) operation. */ - u_int16_t an_beacon_period; /* 0x60 */ - u_int16_t an_atim_duration; /* 0x62 */ - u_int16_t an_rsvd3; /* 0x64 */ - u_int16_t an_ds_channel; /* 0x66 */ - u_int16_t an_rsvd4; /* 0x68 */ - u_int16_t an_dtim_period; /* 0x6A */ - u_int16_t an_rsvd5[2]; /* 0x6C */ - /* Radio operation. */ - u_int16_t an_radiotype; /* 0x70 */ - u_int16_t an_diversity; /* 0x72 */ - u_int16_t an_tx_power; /* 0x74 */ - u_int16_t an_rss_thresh; /* 0x76 */ - u_int16_t an_modulation_type; /* 0x77 */ - u_int16_t an_short_preamble; /* 0x7A */ - u_int16_t an_home_product; /* 0x7C */ - u_int16_t an_rsvd6; /* 0x7E */ - /* Aironet extensions. */ - u_int8_t an_nodename[16]; /* 0x80 */ - u_int16_t an_arl_thresh; /* 0x90 */ - u_int16_t an_arl_decay; /* 0x92 */ - u_int16_t an_arl_delay; /* 0x94 */ - u_int8_t an_rsvd7; /* 0x96 */ - u_int8_t an_rsvd8; /* 0x97 */ - u_int8_t an_magic_packet_action; /* 0x98 */ - u_int8_t an_magic_packet_ctl; /* 0x99 */ - u_int16_t an_rsvd9; + u_int16_t an_val[1]; }; #define AN_OPMODE_IBSS_ADHOC 0x0000 @@ -344,74 +270,9 @@ struct an_ltv_genconfig { #define AN_TXPOWER_100MW 100 #define AN_TXPOWER_250MW 250 -/* - * Valid SSID list. You can specify up to three SSIDs denoting - * the service sets that you want to join. The first SSID always - * defaults to "tsunami" which is a handy way to detect the - * card. - */ -#define AN_RID_SSIDLIST 0xFF11 -struct an_ltv_ssidlist { - u_int16_t an_len; - u_int16_t an_type; - u_int16_t an_ssid1_len; - char an_ssid1[32]; - u_int16_t an_ssid2_len; - char an_ssid2[32]; - u_int16_t an_ssid3_len; - char an_ssid3[32]; -}; - #define AN_DEF_SSID_LEN 7 #define AN_DEF_SSID "tsunami" -/* - * Valid AP list. - */ -#define AN_RID_APLIST 0xFF12 -struct an_ltv_aplist { - u_int16_t an_len; - u_int16_t an_type; - u_int8_t an_ap1[8]; - u_int8_t an_ap2[8]; - u_int8_t an_ap3[8]; - u_int8_t an_ap4[8]; -}; - -/* - * Driver name. - */ -#define AN_RID_DRVNAME 0xFF13 -struct an_ltv_drvname { - u_int16_t an_len; - u_int16_t an_type; - u_int8_t an_drvname[16]; -}; - -/* - * Frame encapsulation. - */ -#define AN_RID_ENCAP 0xFF14 -struct an_rid_encap { - u_int16_t an_len; - u_int16_t an_type; - u_int16_t an_ethertype_default; - u_int16_t an_action_default; - u_int16_t an_ethertype0; - u_int16_t an_action0; - u_int16_t an_ethertype1; - u_int16_t an_action1; - u_int16_t an_ethertype2; - u_int16_t an_action2; - u_int16_t an_ethertype3; - u_int16_t an_action3; - u_int16_t an_ethertype4; - u_int16_t an_action4; - u_int16_t an_ethertype5; - u_int16_t an_action5; - u_int16_t an_ethertype6; - u_int16_t an_action6; -}; #define AN_ENCAP_ACTION_RX 0x0001 #define AN_ENCAP_ACTION_TX 0x0002 @@ -422,113 +283,6 @@ struct an_rid_encap { #define AN_TXENCAP_RFC1024 0x0000 #define AN_TXENCAP_80211 0x0002 -/* - * Actual config, same structure as general config (read only). - */ -#define AN_RID_ACTUALCFG 0xFF20 - -/* - * Card capabilities (read only). - */ -#define AN_RID_CAPABILITIES 0xFF00 -struct an_ltv_caps { - u_int16_t an_len; /* 0x00 */ - u_int16_t an_type; /* XXXX */ - u_int8_t an_oui[3]; /* 0x02 */ - u_int8_t an_rsvd0; /* 0x05 */ - u_int16_t an_prodnum; /* 0x06 */ - u_int8_t an_manufname[32]; /* 0x08 */ - u_int8_t an_prodname[16]; /* 0x28 */ - u_int8_t an_prodvers[8]; /* 0x38 */ - u_int8_t an_oemaddr[6]; /* 0x40 */ - u_int8_t an_aironetaddr[6]; /* 0x46 */ - u_int16_t an_radiotype; /* 0x4C */ - u_int16_t an_regdomain; /* 0x4E */ - u_int8_t an_callid[6]; /* 0x50 */ - u_int8_t an_rates[8]; /* 0x56 */ - u_int8_t an_rx_diversity; /* 0x5E */ - u_int8_t an_tx_diversity; /* 0x5F */ - u_int16_t an_tx_powerlevels[8]; /* 0x60 */ - u_int16_t an_hwrev; /* 0x70 */ - u_int16_t an_hwcaps; /* 0x72 */ - u_int16_t an_temprange; /* 0x74 */ - u_int16_t an_fwrev; /* 0x76 */ - u_int16_t an_fwsubrev; /* 0x78 */ - u_int16_t an_ifacerev; /* 0x7A */ - u_int16_t an_softcaps; /* 0x7C */ - u_int16_t an_bootblockrev; /* 0x7E */ - u_int16_t an_req_hw_support; /* 0x80 */ -}; - -/* - * Access point (read only) - */ -#define AN_RID_APINFO 0xFF01 -struct an_ltv_apinfo { - u_int16_t an_len; - u_int16_t an_type; - u_int16_t an_tim_addr; - u_int16_t an_airo_addr; -}; - -/* - * Radio info (read only). - */ -#define AN_RID_RADIOINFO 0xFF02 -struct an_ltv_radioinfo { - u_int16_t an_len; - u_int16_t an_type; - /* ??? */ -}; - -/* - * Status (read only). Note: the manual claims this RID is 108 bytes - * long (0x6A is the last datum, which is 2 bytes long) however when - * this RID is read from the NIC, it returns a length of 110. To be - * on the safe side, this structure is padded with an extra 16-bit - * word. (There is a misprint in the manual which says the macaddr - * field is 8 bytes long.) - * - * Also, the channel_set and current_channel fields appear to be - * reversed. Either that, or the hop_period field is unused. - */ -#define AN_RID_STATUS 0xFF50 -struct an_ltv_status { - u_int16_t an_len; /* 0x00 */ - u_int16_t an_type; /* 0xXX */ - u_int8_t an_macaddr[6]; /* 0x02 */ - u_int16_t an_opmode; /* 0x08 */ - u_int16_t an_errcode; /* 0x0A */ - u_int16_t an_cur_signal_strength; /* 0x0C */ - u_int16_t an_ssidlen; /* 0x0E */ - u_int8_t an_ssid[32]; /* 0x10 */ - u_int8_t an_ap_name[16]; /* 0x30 */ - u_int8_t an_cur_bssid[6]; /* 0x40 */ - u_int8_t an_prev_bssid1[6]; /* 0x46 */ - u_int8_t an_prev_bssid2[6]; /* 0x4C */ - u_int8_t an_prev_bssid3[6]; /* 0x52 */ - u_int16_t an_beacon_period; /* 0x58 */ - u_int16_t an_dtim_period; /* 0x5A */ - u_int16_t an_atim_duration; /* 0x5C */ - u_int16_t an_hop_period; /* 0x5E */ - u_int16_t an_cur_channel; /* 0x62 */ - u_int16_t an_channel_set; /* 0x60 */ - u_int16_t an_hops_to_backbone; /* 0x64 */ - u_int16_t an_ap_total_load; /* 0x66 */ - u_int16_t an_our_generated_load; /* 0x68 */ - u_int16_t an_accumulated_arl; /* 0x6A */ - u_int16_t an_cur_signal_quality; /* 0x6C */ - u_int16_t an_current_tx_rate; /* 0x6E */ - u_int16_t an_ap_device; /* 0x70 */ - u_int16_t an_normalized_rssi; /* 0x72 */ - u_int16_t an_short_pre_in_use; /* 0x74 */ - u_int8_t an_ap_ip_addr[4]; /* 0x76 */ - u_int16_t an_max_noise_prev_sec; /* 0x7A */ - u_int16_t an_avg_noise_prev_min; /* 0x7C */ - u_int16_t an_max_noise_prev_min; /* 0x7E */ - u_int16_t an_rsvd0[3]; /* 0x80 */ -}; - #define AN_STATUS_OPMODE_CONFIGURED 0x0001 #define AN_STATUS_OPMODE_MAC_ENABLED 0x0002 #define AN_STATUS_OPMODE_RX_ENABLED 0x0004 @@ -548,150 +302,27 @@ struct an_ltv_status { #define AN_RID_32BITS_DELTACLR 0xFF6A /* 32-bit stats, clear on read */ /* - * Grrr. The manual says the statistics record is 384 bytes in length, - * but the card says the record is 404 bytes. There's some padding left - * at the end of this structure to account for any discrepancies. - */ -struct an_ltv_stats { - u_int16_t an_fudge; - u_int16_t an_len; /* 0x00 */ - u_int16_t an_type; /* 0xXX */ - u_int16_t an_spacer; /* 0x02 */ - u_int32_t an_rx_overruns; /* 0x04 */ - u_int32_t an_rx_plcp_csum_errs; /* 0x08 */ - u_int32_t an_rx_plcp_format_errs; /* 0x0C */ - u_int32_t an_rx_plcp_len_errs; /* 0x10 */ - u_int32_t an_rx_mac_crc_errs; /* 0x14 */ - u_int32_t an_rx_mac_crc_ok; /* 0x18 */ - u_int32_t an_rx_wep_errs; /* 0x1C */ - u_int32_t an_rx_wep_ok; /* 0x20 */ - u_int32_t an_retry_long; /* 0x24 */ - u_int32_t an_retry_short; /* 0x28 */ - u_int32_t an_retry_max; /* 0x2C */ - u_int32_t an_no_ack; /* 0x30 */ - u_int32_t an_no_cts; /* 0x34 */ - u_int32_t an_rx_ack_ok; /* 0x38 */ - u_int32_t an_rx_cts_ok; /* 0x3C */ - u_int32_t an_tx_ack_ok; /* 0x40 */ - u_int32_t an_tx_rts_ok; /* 0x44 */ - u_int32_t an_tx_cts_ok; /* 0x48 */ - u_int32_t an_tx_lmac_mcasts; /* 0x4C */ - u_int32_t an_tx_lmac_bcasts; /* 0x50 */ - u_int32_t an_tx_lmac_ucast_frags; /* 0x54 */ - u_int32_t an_tx_lmac_ucasts; /* 0x58 */ - u_int32_t an_tx_beacons; /* 0x5C */ - u_int32_t an_rx_beacons; /* 0x60 */ - u_int32_t an_tx_single_cols; /* 0x64 */ - u_int32_t an_tx_multi_cols; /* 0x68 */ - u_int32_t an_tx_defers_no; /* 0x6C */ - u_int32_t an_tx_defers_prot; /* 0x70 */ - u_int32_t an_tx_defers_energy; /* 0x74 */ - u_int32_t an_rx_dups; /* 0x78 */ - u_int32_t an_rx_partial; /* 0x7C */ - u_int32_t an_tx_too_old; /* 0x80 */ - u_int32_t an_rx_too_old; /* 0x84 */ - u_int32_t an_lostsync_max_retries;/* 0x88 */ - u_int32_t an_lostsync_missed_beacons;/* 0x8C */ - u_int32_t an_lostsync_arl_exceeded;/*0x90 */ - u_int32_t an_lostsync_deauthed; /* 0x94 */ - u_int32_t an_lostsync_disassociated;/*0x98 */ - u_int32_t an_lostsync_tsf_timing; /* 0x9C */ - u_int32_t an_tx_host_mcasts; /* 0xA0 */ - u_int32_t an_tx_host_bcasts; /* 0xA4 */ - u_int32_t an_tx_host_ucasts; /* 0xA8 */ - u_int32_t an_tx_host_failed; /* 0xAC */ - u_int32_t an_rx_host_mcasts; /* 0xB0 */ - u_int32_t an_rx_host_bcasts; /* 0xB4 */ - u_int32_t an_rx_host_ucasts; /* 0xB8 */ - u_int32_t an_rx_host_discarded; /* 0xBC */ - u_int32_t an_tx_hmac_mcasts; /* 0xC0 */ - u_int32_t an_tx_hmac_bcasts; /* 0xC4 */ - u_int32_t an_tx_hmac_ucasts; /* 0xC8 */ - u_int32_t an_tx_hmac_failed; /* 0xCC */ - u_int32_t an_rx_hmac_mcasts; /* 0xD0 */ - u_int32_t an_rx_hmac_bcasts; /* 0xD4 */ - u_int32_t an_rx_hmac_ucasts; /* 0xD8 */ - u_int32_t an_rx_hmac_discarded; /* 0xDC */ - u_int32_t an_tx_hmac_accepted; /* 0xE0 */ - u_int32_t an_ssid_mismatches; /* 0xE4 */ - u_int32_t an_ap_mismatches; /* 0xE8 */ - u_int32_t an_rates_mismatches; /* 0xEC */ - u_int32_t an_auth_rejects; /* 0xF0 */ - u_int32_t an_auth_timeouts; /* 0xF4 */ - u_int32_t an_assoc_rejects; /* 0xF8 */ - u_int32_t an_assoc_timeouts; /* 0xFC */ - u_int32_t an_reason_outside_table;/* 0x100 */ - u_int32_t an_reason1; /* 0x104 */ - u_int32_t an_reason2; /* 0x108 */ - u_int32_t an_reason3; /* 0x10C */ - u_int32_t an_reason4; /* 0x110 */ - u_int32_t an_reason5; /* 0x114 */ - u_int32_t an_reason6; /* 0x118 */ - u_int32_t an_reason7; /* 0x11C */ - u_int32_t an_reason8; /* 0x120 */ - u_int32_t an_reason9; /* 0x124 */ - u_int32_t an_reason10; /* 0x128 */ - u_int32_t an_reason11; /* 0x12C */ - u_int32_t an_reason12; /* 0x130 */ - u_int32_t an_reason13; /* 0x134 */ - u_int32_t an_reason14; /* 0x138 */ - u_int32_t an_reason15; /* 0x13C */ - u_int32_t an_reason16; /* 0x140 */ - u_int32_t an_reason17; /* 0x144 */ - u_int32_t an_reason18; /* 0x148 */ - u_int32_t an_reason19; /* 0x14C */ - u_int32_t an_rx_mgmt_pkts; /* 0x150 */ - u_int32_t an_tx_mgmt_pkts; /* 0x154 */ - u_int32_t an_rx_refresh_pkts; /* 0x158 */ - u_int32_t an_tx_refresh_pkts; /* 0x15C */ - u_int32_t an_rx_poll_pkts; /* 0x160 */ - u_int32_t an_tx_poll_pkts; /* 0x164 */ - u_int32_t an_host_retries; /* 0x168 */ - u_int32_t an_lostsync_hostreq; /* 0x16C */ - u_int32_t an_host_tx_bytes; /* 0x170 */ - u_int32_t an_host_rx_bytes; /* 0x174 */ - u_int32_t an_uptime_usecs; /* 0x178 */ - u_int32_t an_uptime_secs; /* 0x17C */ - u_int32_t an_lostsync_better_ap; /* 0x180 */ - u_int32_t an_rsvd[10]; -}; - -/* - * WEP config - */ -#define AN_RID_WEP_VOLATILE 0xFF15 -#define AN_RID_WEP_PERMANENT 0xFF16 -struct an_wepkey { - u_int16_t an_len; /* 0x00 */ - u_int16_t an_type; /* 0xXX */ - u_int16_t an_key_index; /* 0x02 */ - u_int8_t an_mac_addr[6]; /* 0x04 */ - u_int16_t an_key_len; /* 0x0A */ - u_int8_t an_key[13]; /* 0x0C */ -}; - -/* * Receive frame structure. */ struct an_rxframe { - u_int32_t an_rx_time; /* 0x00 */ - u_int16_t an_rx_status; /* 0x04 */ - u_int16_t an_rx_payload_len; /* 0x06 */ - u_int8_t an_rsvd0; /* 0x08 */ - u_int8_t an_rx_signal_strength; /* 0x09 */ - u_int8_t an_rx_rate; /* 0x0A */ - u_int8_t an_rx_chan; /* 0x0B */ - u_int8_t an_rx_assoc_cnt; /* 0x0C */ - u_int8_t an_rsvd1[3]; /* 0x0D */ - u_int8_t an_plcp_hdr[4]; /* 0x10 */ - u_int16_t an_frame_ctl; /* 0x14 */ - u_int16_t an_duration; /* 0x16 */ - u_int8_t an_addr1[6]; /* 0x18 */ - u_int8_t an_addr2[6]; /* 0x1E */ - u_int8_t an_addr3[6]; /* 0x24 */ - u_int16_t an_seq_ctl; /* 0x2A */ - u_int8_t an_addr4[6]; /* 0x2C */ - u_int16_t an_gaplen; /* 0x32 */ + u_int32_t an_rx_time; /* 0x00 */ + u_int16_t an_rx_status; /* 0x04 */ + u_int16_t an_rx_payload_len; /* 0x06 */ + u_int8_t an_rsvd0; /* 0x08 */ + u_int8_t an_rx_signal_strength; /* 0x09 */ + u_int8_t an_rx_rate; /* 0x0A */ + u_int8_t an_rx_chan; /* 0x0B */ + u_int8_t an_rx_assoc_cnt; /* 0x0C */ + u_int8_t an_rsvd1[3]; /* 0x0D */ + u_int8_t an_plcp_hdr[4]; /* 0x10 */ + u_int16_t an_frame_ctl; /* 0x14 */ + u_int16_t an_duration; /* 0x16 */ + u_int8_t an_addr1[6]; /* 0x18 */ + u_int8_t an_addr2[6]; /* 0x1E */ + u_int8_t an_addr3[6]; /* 0x24 */ + u_int16_t an_seq_ctl; /* 0x2A */ + u_int8_t an_addr4[6]; /* 0x2C */ + u_int16_t an_gaplen; /* 0x32 */ }; #define AN_RXGAP_MAX 8 @@ -700,44 +331,44 @@ struct an_rxframe { * Transmit frame structure. */ struct an_txframe { - u_int32_t an_tx_sw; /* 0x00 */ - u_int16_t an_tx_status; /* 0x04 */ - u_int16_t an_tx_payload_len; /* 0x06 */ - u_int16_t an_tx_ctl; /* 0x08 */ - u_int16_t an_tx_assoc_id; /* 0x0A */ - u_int16_t an_tx_retry; /* 0x0C */ - u_int8_t an_tx_assoc_cnt; /* 0x0E */ - u_int8_t an_tx_rate; /* 0x0F */ - u_int8_t an_tx_max_long_retries; /* 0x10 */ - u_int8_t an_tx_max_short_retries; /*0x11 */ - u_int8_t an_rsvd0[2]; /* 0x12 */ - u_int16_t an_frame_ctl; /* 0x14 */ - u_int16_t an_duration; /* 0x16 */ - u_int8_t an_addr1[6]; /* 0x18 */ - u_int8_t an_addr2[6]; /* 0x1E */ - u_int8_t an_addr3[6]; /* 0x24 */ - u_int16_t an_seq_ctl; /* 0x2A */ - u_int8_t an_addr4[6]; /* 0x2C */ - u_int16_t an_gaplen; /* 0x32 */ + u_int32_t an_tx_sw; /* 0x00 */ + u_int16_t an_tx_status; /* 0x04 */ + u_int16_t an_tx_payload_len; /* 0x06 */ + u_int16_t an_tx_ctl; /* 0x08 */ + u_int16_t an_tx_assoc_id; /* 0x0A */ + u_int16_t an_tx_retry; /* 0x0C */ + u_int8_t an_tx_assoc_cnt; /* 0x0E */ + u_int8_t an_tx_rate; /* 0x0F */ + u_int8_t an_tx_max_long_retries; /* 0x10 */ + u_int8_t an_tx_max_short_retries; /*0x11 */ + u_int8_t an_rsvd0[2]; /* 0x12 */ + u_int16_t an_frame_ctl; /* 0x14 */ + u_int16_t an_duration; /* 0x16 */ + u_int8_t an_addr1[6]; /* 0x18 */ + u_int8_t an_addr2[6]; /* 0x1E */ + u_int8_t an_addr3[6]; /* 0x24 */ + u_int16_t an_seq_ctl; /* 0x2A */ + u_int8_t an_addr4[6]; /* 0x2C */ + u_int16_t an_gaplen; /* 0x32 */ }; struct an_rxframe_802_3 { - u_int16_t an_rx_802_3_status; /* 0x34 */ - u_int16_t an_rx_802_3_payload_len;/* 0x36 */ - u_int8_t an_rx_dst_addr[6]; /* 0x38 */ - u_int8_t an_rx_src_addr[6]; /* 0x3E */ + u_int16_t an_rx_802_3_status; /* 0x34 */ + u_int16_t an_rx_802_3_payload_len;/* 0x36 */ + u_int8_t an_rx_dst_addr[6]; /* 0x38 */ + u_int8_t an_rx_src_addr[6]; /* 0x3E */ }; #define AN_RXGAP_MAX 8 -struct an_txframe_802_3 { /* * Transmit 802.3 header structure. */ - u_int16_t an_tx_802_3_status; /* 0x34 */ - u_int16_t an_tx_802_3_payload_len;/* 0x36 */ - u_int8_t an_tx_dst_addr[6]; /* 0x38 */ - u_int8_t an_tx_src_addr[6]; /* 0x3E */ +struct an_txframe_802_3 { + u_int16_t an_tx_802_3_status; /* 0x34 */ + u_int16_t an_tx_802_3_payload_len;/* 0x36 */ + u_int8_t an_tx_dst_addr[6]; /* 0x38 */ + u_int8_t an_tx_src_addr[6]; /* 0x3E */ }; #define AN_TXSTAT_EXCESS_RETRY 0x0002 @@ -788,59 +419,8 @@ struct an_snap_hdr { u_int16_t an_snap_type; }; -#define AN_TX_RING_CNT 4 #define AN_INC(x, y) (x) = (x + 1) % y -struct an_tx_ring_data { - u_int16_t an_tx_fids[AN_TX_RING_CNT]; - u_int16_t an_tx_ring[AN_TX_RING_CNT]; - int an_tx_prod; - int an_tx_cons; -}; - -struct an_softc { - struct device sc_dev; - struct arpcom arpcom; - void *sc_ih; - - bus_space_tag_t an_btag; - bus_space_handle_t an_bhandle; - - struct an_ltv_genconfig an_config; - struct an_ltv_caps an_caps; - struct an_ltv_ssidlist an_ssidlist; - struct an_ltv_aplist an_aplist; - int an_tx_rate; - int an_rxmode; - int an_gone; - int an_if_flags; - u_int8_t an_txbuf[1536]; - struct an_tx_ring_data an_rdata; - struct an_ltv_stats an_stats; - struct an_ltv_status an_status; - u_int8_t an_associated; -#ifdef ANCACHE - int an_cache_iponly; - int an_cache_mcastonly; - - int an_sigitems; - struct an_sigcache an_sigcache[MAXANCACHE]; - int an_nextitem; -#endif - struct timeout an_stat_ch; -}; - -void an_release_resources __P((struct device *)); -int an_alloc_port __P((struct device *, int, int)); -int an_alloc_memory __P((struct device *, int, int)); -int an_alloc_irq __P((struct device *, int, int)); -int an_probe __P((struct device *)); -void an_shutdown __P((void *)); -int an_attach __P((struct an_softc *)); -void an_init __P((struct an_softc *)); -void an_stop __P((struct an_softc *)); -int an_intr __P((void *)); - #define AN_802_3_OFFSET 0x2E #define AN_802_11_OFFSET 0x44 #define AN_802_11_OFFSET_RAW 0x3C @@ -876,3 +456,5 @@ int an_intr __P((void *)); #define AN_SNAP_WORD0 (AN_SNAP_K1 | (AN_SNAP_K1 << 8)) #define AN_SNAP_WORD1 (AN_SNAP_K2 | (AN_SNAP_CONTROL << 8)) #define AN_SNAPHDR_LEN 0x6 + +#pragma pack() diff --git a/sys/dev/ic/anvar.h b/sys/dev/ic/anvar.h index 3f67b6b7476..bb77509d03b 100644 --- a/sys/dev/ic/anvar.h +++ b/sys/dev/ic/anvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: anvar.h,v 1.3 2001/02/27 06:43:10 tholo Exp $ */ +/* $OpenBSD: anvar.h,v 1.4 2001/06/25 21:11:17 mickey Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -37,6 +37,8 @@ #ifndef _IF_AIRONET_IEEE_H #define _IF_AIRONET_IEEE_H +#pragma pack(1) + /* * This header defines a simple command interface to the FreeBSD * Aironet driver (an) driver, which is used to set certain @@ -140,7 +142,7 @@ struct an_mgmt_hdr { u_int16_t seq_ctl; }; -/* +/* * Aironet IEEE signal strength cache * * driver keeps cache of last @@ -161,7 +163,6 @@ struct an_sigcache { }; #endif -#ifndef _KERNEL struct an_ltv_key { u_int16_t an_len; u_int16_t an_type; @@ -171,6 +172,11 @@ struct an_ltv_key { u_int8_t key[16]; }; +/* + * Grrr. The manual says the statistics record is 384 bytes in length, + * but the card says the record is 404 bytes. There's some padding left + * at the end of this structure to account for any discrepancies. + */ struct an_ltv_stats { u_int16_t an_fudge; u_int16_t an_len; /* 0x00 */ @@ -269,8 +275,8 @@ struct an_ltv_stats { u_int32_t an_lostsync_hostreq; /* 0x16C */ u_int32_t an_host_tx_bytes; /* 0x170 */ u_int32_t an_host_rx_bytes; /* 0x174 */ - u_int32_t an_uptime_usecs; /* 0x178 */ - u_int32_t an_uptime_secs; /* 0x17C */ + u_int32_t an_uptime_secs; /* 0x178 */ + u_int32_t an_uptime_usecs; /* 0x17C */ u_int32_t an_lostsync_better_ap; /* 0x180 */ u_int32_t an_rsvd[10]; }; @@ -401,6 +407,12 @@ struct an_ltv_genconfig { #define AN_TXPOWER_100MW 100 #define AN_TXPOWER_250MW 250 +/* + * Valid SSID list. You can specify up to three SSIDs denoting + * the service sets that you want to join. The first SSID always + * defaults to "tsunami" which is a handy way to detect the + * card. + */ struct an_ltv_ssidlist { u_int16_t an_len; u_int16_t an_type; @@ -412,6 +424,9 @@ struct an_ltv_ssidlist { char an_ssid3[32]; }; +/* + * Valid AP list. + */ struct an_ltv_aplist { u_int16_t an_len; u_int16_t an_type; @@ -421,12 +436,18 @@ struct an_ltv_aplist { u_int8_t an_ap4[8]; }; +/* + * Driver name. + */ struct an_ltv_drvname { u_int16_t an_len; u_int16_t an_type; u_int8_t an_drvname[16]; }; +/* + * Frame encapsulation. + */ struct an_rid_encap { u_int16_t an_len; u_int16_t an_type; @@ -457,6 +478,9 @@ struct an_rid_encap { #define AN_TXENCAP_RFC1024 0x0000 #define AN_TXENCAP_80211 0x0002 +/* + * Card capabilities (read only). + */ struct an_ltv_caps { u_int16_t an_len; /* 0x00 */ u_int16_t an_type; /* XXXX */ @@ -486,6 +510,9 @@ struct an_ltv_caps { u_int16_t an_req_hw_support; /* 0x80 */ }; +/* + * Access point (read only) + */ struct an_ltv_apinfo { u_int16_t an_len; u_int16_t an_type; @@ -493,12 +520,26 @@ struct an_ltv_apinfo { u_int16_t an_airo_addr; }; +/* + * Radio info (read only). + */ struct an_ltv_radioinfo { u_int16_t an_len; u_int16_t an_type; /* ??? */ }; +/* + * Status (read only). Note: the manual claims this RID is 108 bytes + * long (0x6A is the last datum, which is 2 bytes long) however when + * this RID is read from the NIC, it returns a length of 110. To be + * on the safe side, this structure is padded with an extra 16-bit + * word. (There is a misprint in the manual which says the macaddr + * field is 8 bytes long.) + * + * Also, the channel_set and current_channel fields appear to be + * reversed. Either that, or the hop_period field is unused. + */ struct an_ltv_status { u_int16_t an_len; /* 0x00 */ u_int16_t an_type; /* 0xXX */ @@ -542,6 +583,9 @@ struct an_ltv_status { #define AN_STATUS_OPMODE_ASSOCIATED 0x0020 #define AN_STATUS_OPMODE_ERROR 0x8000 +/* + * WEP config + */ struct an_ltv_wepkey { u_int16_t an_len; /* 0x00 */ u_int16_t an_type; /* 0xXX */ @@ -557,6 +601,8 @@ struct an_ltv_wepkey { * list as many as I know about here for completeness. */ +#pragma pack() + /* * Configuration (read/write) */ @@ -564,7 +610,7 @@ struct an_ltv_wepkey { #define AN_RID_SSIDLIST 0xFF11 /* Valid SSID list */ #define AN_RID_APLIST 0xFF12 /* Valid AP list */ #define AN_RID_DRVNAME 0xFF13 /* ID name of this node for diag */ -#define AN_RID_ENCAPPROTO 0xFF14 /* Payload encapsulation type */ +#define AN_RID_ENCAP 0xFF14 /* Payload encapsulation type */ #define AN_RID_WEP_VOLATILE 0xFF15 /* Temporary WEP key configuration */ #define AN_RID_WEP_PERMANENT 0xFF16 /* Permanent WEP key configuration */ #define AN_RID_ACTUALCFG 0xFF20 /* Current configuration settings */ @@ -573,8 +619,8 @@ struct an_ltv_wepkey { * Reporting (read only) */ #define AN_RID_CAPABILITIES 0xFF00 /* PC 4500/4800 capabilities */ -#define AN_RID_AP_INFO 0xFF01 /* Access point info */ -#define AN_RID_RADIO_INFO 0xFF02 /* Radio info */ +#define AN_RID_APINFO 0xFF01 /* Access point info */ +#define AN_RID_RADIOINFO 0xFF02 /* Radio info */ #define AN_RID_STATUS 0xFF50 /* Current status info */ /* @@ -586,7 +632,58 @@ struct an_ltv_wepkey { #define AN_RID_32BITS_CUM 0xFF68 /* Cumulative 32-bit stats counters */ #define AN_RID_32BITS_DELTA 0xFF69 /* 32-bit stats (since last clear) */ #define AN_RID_32BITS_DELTACLR 0xFF6A /* 32-bit stats, clear on read */ + +#ifdef _KERNEL +#define AN_TX_RING_CNT 4 +struct an_tx_ring_data { + u_int16_t an_tx_fids[AN_TX_RING_CNT]; + u_int16_t an_tx_ring[AN_TX_RING_CNT]; + int an_tx_prod; + int an_tx_cons; +}; + +struct an_softc { + struct device sc_dev; + struct arpcom arpcom; + void *sc_ih; + + bus_space_tag_t an_btag; + bus_space_handle_t an_bhandle; + + struct an_ltv_genconfig an_config; + struct an_ltv_caps an_caps; + struct an_ltv_ssidlist an_ssidlist; + struct an_ltv_aplist an_aplist; + int an_tx_rate; + int an_rxmode; + int an_gone; + int an_if_flags; + u_int8_t an_txbuf[1536]; + struct an_tx_ring_data an_rdata; + struct an_ltv_stats an_stats; + struct an_ltv_status an_status; + u_int8_t an_associated; +#ifdef ANCACHE + int an_cache_iponly; + int an_cache_mcastonly; + + int an_sigitems; + struct an_sigcache an_sigcache[MAXANCACHE]; + int an_nextitem; #endif + struct timeout an_stat_ch; +}; +void an_release_resources __P((struct device *)); +int an_alloc_port __P((struct device *, int, int)); +int an_alloc_memory __P((struct device *, int, int)); +int an_alloc_irq __P((struct device *, int, int)); +int an_probe __P((struct device *)); +void an_shutdown __P((void *)); +int an_attach __P((struct an_softc *)); +void an_init __P((struct an_softc *)); +void an_stop __P((struct an_softc *)); +int an_intr __P((void *)); +#endif #endif |