* Adding remaining wlan drivers (FreeBSD RELEASE_8_0_0) to trunk.

Both are compiling, but not linking yet. Only for compilation of pci support
  has been taken care of, as neither ISA nor PCMCIA are usable within Haiku 
  anyway.
* Enhancing the FreeBSD compat layer so that the above drivers are compiling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34621 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Colin Günther 2009-12-10 16:23:38 +00:00
parent 3d9728baf9
commit 0229a55264
27 changed files with 10216 additions and 44 deletions

View File

@ -1,6 +1,7 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan ;
#FreeBSD 8 WLAN drivers
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan aironetwifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan atheros ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi2100 ;
@ -10,3 +11,4 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi4965 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8335 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan wavelanwifi ;

View File

@ -0,0 +1,23 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan aironetwifi ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ]
-Wno-format
-Wno-unused
-Wno-uninitialized ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev an ] ;
KernelAddon aironetwifi :
if_an.c
if_an_pci.c
:
libfreebsd_wlan.a
libfreebsd_network.a
;

View File

@ -0,0 +1,798 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _IF_AIRONET_IEEE_H
#define _IF_AIRONET_IEEE_H
/*
* This header defines a simple command interface to the FreeBSD
* Aironet driver (an) driver, which is used to set certain
* device-specific parameters which can't be easily managed through
* ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_
* interface, didn't I.
*/
#ifndef SIOCSAIRONET
#define SIOCSAIRONET SIOCSIFGENERIC
#endif
#ifndef SIOCGAIRONET
#define SIOCGAIRONET SIOCGIFGENERIC
#endif
/*
* This is a make-predend RID value used only by the driver
* to allow the user to set the speed.
*/
#define AN_RID_TX_SPEED 0x1234
/*
* Technically I don't think there's a limit to a record
* length. The largest record is the one that contains the CIS
* data, which is 240 words long, so 256 should be a safe
* value.
*/
#define AN_MAX_DATALEN 4096
struct an_req {
u_int16_t an_len;
u_int16_t an_type;
u_int16_t an_val[AN_MAX_DATALEN];
};
/*
* Private LTV records (interpreted only by the driver). This is
* a minor kludge to allow reading the interface statistics from
* the driver.
*/
#define AN_RID_IFACE_STATS 0x0100
#define AN_RID_MGMT_XMIT 0x0200
#ifdef ANCACHE
#define AN_RID_ZERO_CACHE 0x0300
#define AN_RID_READ_CACHE 0x0400
#endif
#define AN_FCTL_VERS 0x0002
#define AN_FCTL_FTYPE 0x000C
#define AN_FCTL_STYPE 0x00F0
#define AN_FCTL_TODS 0x0100
#define AN_FCTL_FROMDS 0x0200
#define AN_FCTL_MOREFRAGS 0x0400
#define AN_FCTL_RETRY 0x0800
#define AN_FCTL_PM 0x1000
#define AN_FCTL_MOREDATA 0x2000
#define AN_FCTL_WEP 0x4000
#define AN_FCTL_ORDER 0x8000
#define AN_FTYPE_MGMT 0x0000
#define AN_FTYPE_CTL 0x0004
#define AN_FTYPE_DATA 0x0008
#define AN_STYPE_MGMT_ASREQ 0x0000 /* association request */
#define AN_STYPE_MGMT_ASRESP 0x0010 /* association response */
#define AN_STYPE_MGMT_REASREQ 0x0020 /* reassociation request */
#define AN_STYPE_MGMT_REASRESP 0x0030 /* reassociation response */
#define AN_STYPE_MGMT_PROBEREQ 0x0040 /* probe request */
#define AN_STYPE_MGMT_PROBERESP 0x0050 /* probe response */
#define AN_STYPE_MGMT_BEACON 0x0080 /* beacon */
#define AN_STYPE_MGMT_ATIM 0x0090 /* announcement traffic ind msg */
#define AN_STYPE_MGMT_DISAS 0x00A0 /* disassociation */
#define AN_STYPE_MGMT_AUTH 0x00B0 /* authentication */
#define AN_STYPE_MGMT_DEAUTH 0x00C0 /* deauthentication */
/*
* Aironet IEEE signal strength cache
*
* driver keeps cache of last
* MAXANCACHE packets to arrive including signal strength info.
* daemons may read this via ioctl
*
* Each entry in the wi_sigcache has a unique macsrc.
*/
#ifdef ANCACHE
#define MAXANCACHE 10
struct an_sigcache {
char macsrc[6]; /* unique MAC address for entry */
int ipsrc; /* ip address associated with packet */
int signal; /* signal strength of the packet */
int noise; /* noise value */
int quality; /* quality of the packet */
};
#endif
/*
* The card provides an 8-bit signal strength value (RSSI), which can
* be converted to a dBm power value (or a percent) using a table in
* the card's firmware (when available). The tables are slightly
* different in individual cards, even of the same model. If the
* table is not available, the mapping can be approximated by dBm =
* RSSI - 100. This approximation can be seen by plotting a few
* tables, and also matches some info on the Intersil web site (I
* think they make the RF front end for the cards. However, the linux
* driver uses the approximation dBm = RSSI/2 - 95. I think that is
* just wrong.
*/
struct an_rssi_entry {
u_int8_t an_rss_pct;
u_int8_t an_rss_dbm;
};
struct an_ltv_key {
u_int16_t an_len;
u_int16_t an_type;
u_int16_t kindex;
u_int8_t mac[6];
u_int16_t klen;
u_int8_t key[16]; /* 128-bit keys */
};
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[15];
};
/*
* General configuration information.
*/
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; /* 0x78 */
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_spare[19];
};
#define AN_OPMODE_IBSS_ADHOC 0x0000
#define AN_OPMODE_INFRASTRUCTURE_STATION 0x0001
#define AN_OPMODE_AP 0x0002
#define AN_OPMODE_AP_REPEATER 0x0003
#define AN_OPMODE_UNMODIFIED_PAYLOAD 0x0100
#define AN_OPMODE_AIRONET_EXTENSIONS 0x0200
#define AN_OPMODE_AP_EXTENSIONS 0x0400
#define AN_RXMODE_BC_MC_ADDR 0x0000
#define AN_RXMODE_BC_ADDR 0x0001
#define AN_RXMODE_ADDR 0x0002
#define AN_RXMODE_80211_MONITOR_CURBSS 0x0003
#define AN_RXMODE_80211_MONITOR_ANYBSS 0x0004
#define AN_RXMODE_LAN_MONITOR_CURBSS 0x0005
#define AN_RXMODE_NO_8023_HEADER 0x0100
#define AN_RXMODE_NORMALIZED_RSSI 0x0200
#define AN_RATE_1MBPS 0x0002
#define AN_RATE_2MBPS 0x0004
#define AN_RATE_5_5MBPS 0x000B
#define AN_RATE_11MBPS 0x0016
#define AN_DEVTYPE_PC4500 0x0065
#define AN_DEVTYPE_PC4800 0x006D
#define AN_SCANMODE_ACTIVE 0x0000
#define AN_SCANMODE_PASSIVE 0x0001
#define AN_SCANMODE_AIRONET_ACTIVE 0x0002
#define AN_AUTHTYPE_NONE 0x0000
#define AN_AUTHTYPE_OPEN 0x0001
#define AN_AUTHTYPE_SHAREDKEY 0x0002
#define AN_AUTHTYPE_MASK 0x00ff
#define AN_AUTHTYPE_ENABLE 0x0100
#define AN_AUTHTYPE_PRIVACY_IN_USE 0x0100
#define AN_AUTHTYPE_ALLOW_UNENCRYPTED 0x0200
#define AN_AUTHTYPE_LEAP 0x1000
#define AN_PSAVE_NONE 0x0000
#define AN_PSAVE_CAM 0x0001
#define AN_PSAVE_PSP 0x0002
#define AN_PSAVE_PSP_CAM 0x0003
#define AN_RADIOTYPE_80211_FH 0x0001
#define AN_RADIOTYPE_80211_DS 0x0002
#define AN_RADIOTYPE_LM2000_DS 0x0004
#define AN_DIVERSITY_FACTORY_DEFAULT 0x0000
#define AN_DIVERSITY_ANTENNA_1_ONLY 0x0001
#define AN_DIVERSITY_ANTENNA_2_ONLY 0x0002
#define AN_DIVERSITY_ANTENNA_1_AND_2 0x0003
#define AN_TXPOWER_FACTORY_DEFAULT 0x0000
#define AN_TXPOWER_50MW 50
#define AN_TXPOWER_100MW 100
#define AN_TXPOWER_250MW 250
#define AN_HOME_NETWORK 0x0001
#define AN_HOME_INSTALL_AP 0x0002
/*
* 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;
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];
};
struct an_ltv_ssid_entry{
u_int16_t an_len;
char an_ssid[32];
};
#define MAX_SSIDS 25
struct an_ltv_ssidlist_new {
u_int16_t an_len;
u_int16_t an_type;
struct an_ltv_ssid_entry an_entry[MAX_SSIDS];
};
/*
* Valid AP list.
*/
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.
*/
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;
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
#define AN_RXENCAP_NONE 0x0000
#define AN_RXENCAP_RFC1024 0x0001
#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 */
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 */
u_int16_t an_unknown[31]; /* 0x82 */
};
/*
* Access point (read only)
*/
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).
*/
struct an_ltv_radioinfo {
u_int16_t an_len;
u_int16_t an_type;
/* ??? */
};
/*
* RSSI map. If available in the card's firmware, this can be used to
* convert the 8-bit RSSI values from the card into dBm.
*/
struct an_ltv_rssi_map {
u_int16_t an_len;
u_int16_t an_type;
struct an_rssi_entry an_entries[256];
};
/*
* 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 */
u_int8_t an_macaddr[6]; /* 0x02 */
u_int16_t an_opmode; /* 0x08 */
u_int16_t an_errcode; /* 0x0A */
u_int16_t an_signal_quality; /* 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_strength; /* 0x72 */
u_int16_t an_short_pre_in_use; /* 0x74 */
u_int8_t an_ap_ip_addr[4]; /* 0x76 */
u_int8_t an_noise_prev_sec_pc; /* 0x7A */
u_int8_t an_noise_prev_sec_db; /* 0x7B */
u_int8_t an_avg_noise_prev_min_pc; /* 0x7C */
u_int8_t an_avg_noise_prev_min_db; /* 0x7D */
u_int8_t an_max_noise_prev_min_pc; /* 0x7E */
u_int8_t an_max_noise_prev_min_db; /* 0x7F */
u_int16_t an_spare[18];
};
#define AN_STATUS_OPMODE_CONFIGURED 0x0001
#define AN_STATUS_OPMODE_MAC_ENABLED 0x0002
#define AN_STATUS_OPMODE_RX_ENABLED 0x0004
#define AN_STATUS_OPMODE_IN_SYNC 0x0010
#define AN_STATUS_OPMODE_ASSOCIATED 0x0020
#define AN_STATUS_OPMODE_LEAP 0x0040
#define AN_STATUS_OPMODE_ERROR 0x8000
/*
* WEP Key
*/
struct an_ltv_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_int8_t an_gaplen; /* 0x32 */
} __packed;
/* Do not modify this unless you are modifying LEAP itself */
#define LEAP_USERNAME_MAX 32
#define LEAP_PASSWORD_MAX 32
/*
* LEAP Username
*/
struct an_ltv_leap_username {
u_int16_t an_len; /* 0x00 */
u_int16_t an_type; /* 0xXX */
u_int16_t an_username_len; /* 0x02 */
u_int8_t an_username[LEAP_USERNAME_MAX]; /* 0x04 */
};
/*
* LEAP Password
*/
struct an_ltv_leap_password {
u_int16_t an_len; /* 0x00 */
u_int16_t an_type; /* 0xXX */
u_int16_t an_password_len; /* 0x02 */
u_int8_t an_password[LEAP_PASSWORD_MAX]; /* 0x04 */
};
/*
* These are all the LTV record types that we can read or write
* from the Aironet. Not all of them are temendously useful, but I
* list as many as I know about here for completeness.
*/
/*
* Configuration (read/write)
*/
#define AN_RID_GENCONFIG 0xFF10 /* General configuration info */
#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_WEP_TEMP 0xFF15 /* Temporary Key */
#define AN_RID_WEP_PERM 0xFF16 /* Perminant Key */
#define AN_RID_ACTUALCFG 0xFF20 /* Current configuration settings */
/*
* 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_RSSI_MAP 0xFF04 /* RSSI <-> dBm table */
#define AN_RID_STATUS 0xFF50 /* Current status info */
#define AN_RID_BEACONS_HST 0xFF51
#define AN_RID_BUSY_HST 0xFF52
#define AN_RID_RETRIES_HST 0xFF53
/*
* Statistics
*/
#define AN_RID_16BITS_CUM 0xFF60 /* Cumulative 16-bit stats counters */
#define AN_RID_16BITS_DELTA 0xFF61 /* 16-bit stats (since last clear) */
#define AN_RID_16BITS_DELTACLR 0xFF62 /* 16-bit stats, clear on read */
#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 */
/*
* LEAP
*/
#define AN_RID_LEAPUSERNAME 0xFF23 /* Username */
#define AN_RID_LEAPPASSWORD 0xFF24 /* Password */
/*
* OTHER Unknonwn for now
*/
#define AN_RID_MOD 0xFF17
#define AN_RID_OPTIONS 0xFF18
#define AN_RID_FACTORY_CONFIG 0xFF18
/*
* FreeBSD fake RID
*/
#define AN_RID_MONITOR_MODE 0x0001 /* Set monitor mode for driver */
#define AN_MONITOR 1
#define AN_MONITOR_ANY_BSS 2
#define AN_MONITOR_INCLUDE_BEACON 4
#define AN_MONITOR_AIRONET_HEADER 8
#define DLT_AIRONET_HEADER 120 /* Has been allocated at tcpdump.org */
/*
* from the Linux driver from Cisco ... no copyright header.
* Removed duplicated information that already existed in the FreeBSD driver
* provides emulation of the Cisco extensions to the Linux Aironet driver.
*/
/*
* Ioctl constants to be used in airo_ioctl.command
*/
#define AIROGCAP 0 /* Capability rid */
#define AIROGCFG 1 /* USED A LOT */
#define AIROGSLIST 2 /* System ID list */
#define AIROGVLIST 3 /* List of specified AP's */
#define AIROGDRVNAM 4 /* NOTUSED */
#define AIROGEHTENC 5 /* NOTUSED */
#define AIROGWEPKTMP 6
#define AIROGWEPKNV 7
#define AIROGSTAT 8
#define AIROGSTATSC32 9
#define AIROGSTATSD32 10
/*
* Leave gap of 40 commands after AIROGSTATSD32
*/
#define AIROPCAP AIROGSTATSD32 + 40
#define AIROPVLIST AIROPCAP + 1
#define AIROPSLIST AIROPVLIST + 1
#define AIROPCFG AIROPSLIST + 1
#define AIROPSIDS AIROPCFG + 1
#define AIROPAPLIST AIROPSIDS + 1
#define AIROPMACON AIROPAPLIST + 1 /* Enable mac */
#define AIROPMACOFF AIROPMACON + 1 /* Disable mac */
#define AIROPSTCLR AIROPMACOFF + 1
#define AIROPWEPKEY AIROPSTCLR + 1
#define AIROPWEPKEYNV AIROPWEPKEY + 1
#define AIROPLEAPPWD AIROPWEPKEYNV + 1
#define AIROPLEAPUSR AIROPLEAPPWD + 1
/*
* Another gap of 40 commands before flash codes
*/
#define AIROFLSHRST AIROPWEPKEYNV + 40
#define AIROFLSHGCHR AIROFLSHRST + 1
#define AIROFLSHSTFL AIROFLSHGCHR + 1
#define AIROFLSHPCHR AIROFLSHSTFL + 1
#define AIROFLPUTBUF AIROFLSHPCHR + 1
#define AIRORESTART AIROFLPUTBUF + 1
/*
* Struct to enable up to 65535 ioctl's
*/
#define AIROMAGIC 0xa55a
typedef struct aironet_ioctl {
unsigned short command; /* What to do */
unsigned short len; /* Len of data */
unsigned char *data; /* d-data */
} airo_ioctl;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD.
*
* Written by Bill Paul <wpaul@ctr.columbia.edu>
* Electrical Engineering Department
* Columbia University, New York City
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_inet.h"
#ifdef INET
#define ANCACHE
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_media.h>
#include <isa/isavar.h>
#include <isa/pnpvar.h>
#include <dev/an/if_aironet_ieee.h>
#include <dev/an/if_anreg.h>
static struct isa_pnp_id an_ids[] = {
{ 0x0100ec06, "Aironet ISA4500/ISA4800" },
{ 0, NULL }
};
static int an_probe_isa(device_t);
static int an_attach_isa(device_t);
static int
an_probe_isa(device_t dev)
{
int error = 0;
error = ISA_PNP_PROBE(device_get_parent(dev), dev, an_ids);
if (error == ENXIO)
return(error);
error = an_probe(dev);
an_release_resources(dev);
if (error == 0)
return (ENXIO);
error = an_alloc_irq(dev, 0, 0);
an_release_resources(dev);
if (!error)
device_set_desc(dev, "Aironet ISA4500/ISA4800");
return (error);
}
static int
an_attach_isa(device_t dev)
{
struct an_softc *sc = device_get_softc(dev);
int flags = device_get_flags(dev);
int error;
an_alloc_port(dev, sc->port_rid, 1);
an_alloc_irq(dev, sc->irq_rid, 0);
sc->an_bhandle = rman_get_bushandle(sc->port_res);
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error) {
an_release_resources(dev);
return (error);
}
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
NULL, an_intr, sc, &sc->irq_handle);
if (error) {
an_release_resources(dev);
return (error);
}
return (0);
}
static device_method_t an_isa_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, an_probe_isa),
DEVMETHOD(device_attach, an_attach_isa),
DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
{ 0, 0 }
};
static driver_t an_isa_driver = {
"an",
an_isa_methods,
sizeof(struct an_softc)
};
static devclass_t an_isa_devclass;
DRIVER_MODULE(an, isa, an_isa_driver, an_isa_devclass, 0, 0);
MODULE_DEPEND(an, isa, 1, 1, 1);
MODULE_DEPEND(an, wlan, 1, 1, 1);

View File

@ -0,0 +1,161 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD.
*
* Written by Bill Paul <wpaul@ctr.columbia.edu>
* Electrical Engineering Department
* Columbia University, New York City
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_inet.h"
#ifdef INET
#define ANCACHE
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <machine/resource.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_media.h>
#include <dev/an/if_aironet_ieee.h>
#include <dev/an/if_anreg.h>
#include <dev/pccard/pccardvar.h>
#include "pccarddevs.h"
#include "card_if.h"
/*
* Support for PCMCIA cards.
*/
static int an_pccard_probe(device_t);
static int an_pccard_attach(device_t);
static device_method_t an_pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, an_pccard_probe),
DEVMETHOD(device_attach, an_pccard_attach),
DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
{ 0, 0 }
};
static driver_t an_pccard_driver = {
"an",
an_pccard_methods,
sizeof(struct an_softc)
};
static devclass_t an_pccard_devclass;
DRIVER_MODULE(an, pccard, an_pccard_driver, an_pccard_devclass, 0, 0);
MODULE_DEPEND(an, wlan, 1, 1, 1);
static const struct pccard_product an_pccard_products[] = {
PCMCIA_CARD(AIRONET, PC4800),
PCMCIA_CARD(AIRONET, PC4500),
PCMCIA_CARD(AIRONET, 350),
PCMCIA_CARD(XIRCOM, CWE1130),
{ NULL }
};
static int
an_pccard_probe(device_t dev)
{
const struct pccard_product *pp;
if ((pp = pccard_product_lookup(dev, an_pccard_products,
sizeof(an_pccard_products[0]), NULL)) != NULL) {
if (pp->pp_name != NULL)
device_set_desc(dev, pp->pp_name);
return (0);
}
return (ENXIO);
}
static int
an_pccard_attach(device_t dev)
{
struct an_softc *sc = device_get_softc(dev);
int flags = device_get_flags(dev);
int error;
error = an_probe(dev); /* 0 is failure for now */
if (error == 0) {
error = ENXIO;
goto fail;
}
error = an_alloc_irq(dev, 0, 0);
if (error != 0)
goto fail;
an_alloc_irq(dev, sc->irq_rid, 0);
sc->an_bhandle = rman_get_bushandle(sc->port_res);
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error)
goto fail;
/*
* Must setup the interrupt after the an_attach to prevent racing.
*/
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
NULL, an_intr, sc, &sc->irq_handle);
fail:
if (error)
an_release_resources(dev);
return (error);
}

View File

@ -0,0 +1,291 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* This is a PCI shim for the Aironet PC4500/4800 wireless network
* driver. Aironet makes PCMCIA, ISA and PCI versions of these devices,
* which all have basically the same interface. The ISA and PCI cards
* are actually bridge adapters with PCMCIA cards inserted into them,
* however they appear as normal PCI or ISA devices to the host.
*
* All we do here is handle the PCI probe and attach and set up an
* interrupt handler entry point. The PCI version of the card uses
* a PLX 9050 PCI to "dumb bus" bridge chip, which provides us with
* multiple PCI address space mappings. The primary mapping at PCI
* register 0x14 is for the PLX chip itself, *NOT* the Aironet card.
* The I/O address of the Aironet is actually at register 0x18, which
* is the local bus mapping register for bus space 0. There are also
* registers for additional register spaces at registers 0x1C and
* 0x20, but these are unused in the Aironet devices. To find out
* more, you need a datasheet for the 9050 from PLX, but you have
* to go through their sales office to get it. Bleh.
*/
#include "opt_inet.h"
#ifdef INET
#define ANCACHE
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <machine/resource.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/an/if_aironet_ieee.h>
#include <dev/an/if_anreg.h>
struct an_type {
u_int16_t an_vid;
u_int16_t an_did;
char *an_name;
};
#define AIRONET_VENDORID 0x14B9
#define AIRONET_DEVICEID_35x 0x0350
#define AIRONET_DEVICEID_4500 0x4500
#define AIRONET_DEVICEID_4800 0x4800
#define AIRONET_DEVICEID_4xxx 0x0001
#define AIRONET_DEVICEID_MPI350 0xA504
#define AN_PCI_PLX_LOIO 0x14 /* PLX chip iobase */
#define AN_PCI_LOIO 0x18 /* Aironet iobase */
static struct an_type an_devs[] = {
{ AIRONET_VENDORID, AIRONET_DEVICEID_35x, "Cisco Aironet 350 Series" },
{ AIRONET_VENDORID, AIRONET_DEVICEID_4500, "Aironet PCI4500" },
{ AIRONET_VENDORID, AIRONET_DEVICEID_4800, "Aironet PCI4800" },
{ AIRONET_VENDORID, AIRONET_DEVICEID_4xxx, "Aironet PCI4500/PCI4800" },
{ 0, 0, NULL }
};
static int an_probe_pci (device_t);
static int an_attach_pci (device_t);
static int an_suspend_pci (device_t);
static int an_resume_pci (device_t);
static int
an_probe_pci(device_t dev)
{
struct an_type *t;
struct an_softc *sc = device_get_softc(dev);
bzero(sc, sizeof(struct an_softc));
t = an_devs;
while (t->an_name != NULL) {
if (pci_get_vendor(dev) == t->an_vid &&
pci_get_device(dev) == t->an_did) {
device_set_desc(dev, t->an_name);
an_pci_probe(dev);
return(BUS_PROBE_DEFAULT);
}
t++;
}
if (pci_get_vendor(dev) == AIRONET_VENDORID &&
pci_get_device(dev) == AIRONET_DEVICEID_MPI350) {
device_set_desc(dev, "Cisco Aironet MPI350");
an_pci_probe(dev);
return(BUS_PROBE_DEFAULT);
}
return(ENXIO);
}
static int
an_attach_pci(dev)
device_t dev;
{
u_int32_t command;
struct an_softc *sc;
int unit, flags, error = 0;
sc = device_get_softc(dev);
unit = device_get_unit(dev);
flags = device_get_flags(dev);
if (pci_get_vendor(dev) == AIRONET_VENDORID &&
pci_get_device(dev) == AIRONET_DEVICEID_MPI350) {
sc->mpi350 = 1;
sc->port_rid = PCIR_BAR(0);
} else {
/*
* Map control/status registers.
*/
command = pci_read_config(dev, PCIR_COMMAND, 4);
command |= PCIM_CMD_PORTEN;
pci_write_config(dev, PCIR_COMMAND, command, 4);
command = pci_read_config(dev, PCIR_COMMAND, 4);
if (!(command & PCIM_CMD_PORTEN)) {
printf("an%d: failed to enable I/O ports!\n", unit);
error = ENXIO;
goto fail;
}
sc->port_rid = AN_PCI_LOIO;
}
error = an_alloc_port(dev, sc->port_rid, 1);
if (error) {
printf("an%d: couldn't map ports\n", unit);
goto fail;
}
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_bhandle = rman_get_bushandle(sc->port_res);
/* Allocate memory for MPI350 */
if (sc->mpi350) {
/* Allocate memory */
sc->mem_rid = PCIR_BAR(1);
error = an_alloc_memory(dev, sc->mem_rid, 1);
if (error) {
printf("an%d: couldn't map memory\n", unit);
goto fail;
}
sc->an_mem_btag = rman_get_bustag(sc->mem_res);
sc->an_mem_bhandle = rman_get_bushandle(sc->mem_res);
/* Allocate aux. memory */
sc->mem_aux_rid = PCIR_BAR(2);
error = an_alloc_aux_memory(dev, sc->mem_aux_rid,
AN_AUX_MEM_SIZE);
if (error) {
printf("an%d: couldn't map aux memory\n", unit);
goto fail;
}
sc->an_mem_aux_btag = rman_get_bustag(sc->mem_aux_res);
sc->an_mem_aux_bhandle = rman_get_bushandle(sc->mem_aux_res);
/* Allocate DMA region */
error = bus_dma_tag_create(NULL, /* parent */
1, 0, /* alignment, bounds */
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */
NULL, NULL, /* filter, filterarg */
0x3ffff, /* maxsize XXX */
1, /* nsegments */
0xffff, /* maxsegsize XXX */
BUS_DMA_ALLOCNOW, /* flags */
NULL, /* lockfunc */
NULL, /* lockarg */
&sc->an_dtag);
if (error) {
printf("an%d: couldn't get DMA region\n", unit);
goto fail;
}
}
/* Allocate interrupt */
error = an_alloc_irq(dev, 0, RF_SHAREABLE);
if (error) {
goto fail;
}
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error) {
goto fail;
}
/*
* Must setup the interrupt after the an_attach to prevent racing.
*/
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
NULL, an_intr, sc, &sc->irq_handle);
fail:
if (error)
an_release_resources(dev);
return(error);
}
static int
an_suspend_pci(device_t dev)
{
an_shutdown(dev);
return (0);
}
static int
an_resume_pci(device_t dev)
{
an_resume(dev);
return (0);
}
static device_method_t an_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, an_probe_pci),
DEVMETHOD(device_attach, an_attach_pci),
DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
DEVMETHOD(device_suspend, an_suspend_pci),
DEVMETHOD(device_resume, an_resume_pci),
{ 0, 0 }
};
static driver_t an_pci_driver = {
"an",
an_pci_methods,
sizeof(struct an_softc),
};
static devclass_t an_devclass;
DRIVER_MODULE(an, pci, an_pci_driver, an_devclass, 0, 0);
MODULE_DEPEND(an, pci, 1, 1, 1);
MODULE_DEPEND(an, wlan, 1, 1, 1);

View File

@ -0,0 +1,556 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#define AN_TIMEOUT 65536
/* Default network name: <empty string> */
#define AN_DEFAULT_NETNAME ""
/* The nodename must be less than 16 bytes */
#define AN_DEFAULT_NODENAME "FreeBSD"
#define AN_DEFAULT_IBSS "FreeBSD IBSS"
/*
* register space access macros
*/
#define CSR_WRITE_2(sc, reg, val) \
bus_space_write_2(sc->an_btag, sc->an_bhandle, reg, val)
#define CSR_READ_2(sc, reg) \
bus_space_read_2(sc->an_btag, sc->an_bhandle, reg)
#define CSR_WRITE_1(sc, reg, val) \
bus_space_write_1(sc->an_btag, sc->an_bhandle, reg, val)
#define CSR_READ_1(sc, reg) \
bus_space_read_1(sc->an_btag, sc->an_bhandle, reg)
/*
* memory space access macros
*/
#define CSR_MEM_WRITE_2(sc, reg, val) \
bus_space_write_2(sc->an_mem_btag, sc->an_mem_bhandle, reg, val)
#define CSR_MEM_READ_2(sc, reg) \
bus_space_read_2(sc->an_mem_btag, sc->an_mem_bhandle, reg)
#define CSR_MEM_WRITE_1(sc, reg, val) \
bus_space_write_1(sc->an_mem_btag, sc->an_mem_bhandle, reg, val)
#define CSR_MEM_READ_1(sc, reg) \
bus_space_read_1(sc->an_mem_btag, sc->an_mem_bhandle, reg)
/*
* aux. memory space access macros
*/
#define CSR_MEM_AUX_WRITE_4(sc, reg, val) \
bus_space_write_4(sc->an_mem_aux_btag, sc->an_mem_aux_bhandle, reg, val)
#define CSR_MEM_AUX_READ_4(sc, reg) \
bus_space_read_4(sc->an_mem_aux_btag, sc->an_mem_aux_bhandle, reg)
#define CSR_MEM_AUX_WRITE_1(sc, reg, val) \
bus_space_write_1(sc->an_mem_aux_btag, sc->an_mem_aux_bhandle, reg, val)
#define CSR_MEM_AUX_READ_1(sc, reg) \
bus_space_read_1(sc->an_mem_aux_btag, sc->an_mem_aux_bhandle, reg)
/*
* Size of Aironet I/O space.
*/
#define AN_IOSIZ 0x40
/*
* Size of aux. memory space ... probably not needed DJA
*/
#define AN_AUX_MEM_SIZE (256 * 1024)
/*
* Hermes register definitions and what little I know about them.
*/
/* Hermes command/status registers. */
#define AN_COMMAND(x) (x ? 0x00 : 0x00)
#define AN_PARAM0(x) (x ? 0x04 : 0x02)
#define AN_PARAM1(x) (x ? 0x08 : 0x04)
#define AN_PARAM2(x) (x ? 0x0c : 0x06)
#define AN_STATUS(x) (x ? 0x10 : 0x08)
#define AN_RESP0(x) (x ? 0x14 : 0x0A)
#define AN_RESP1(x) (x ? 0x18 : 0x0C)
#define AN_RESP2(x) (x ? 0x1c : 0x0E)
#define AN_LINKSTAT(x) (x ? 0x20 : 0x10)
/* Command register */
#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 restart */
#define AN_CMD_HOST_SLEEP 0x0005
#define AN_CMD_MAGIC_PKT 0x0006
#define AN_CMD_READCFG 0x0008
#define AN_CMD_SET_MODE 0x0009
#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_ALLOC_DESC 0x0020
#define AN_CMD_ACCESS 0x0021
#define AN_CMD_ALLOC_BUF 0x0028
#define AN_CMD_PSP_NODES 0x0030
#define AN_CMD_SET_PHYREG 0x003E
#define AN_CMD_TX_TEST 0x003F
#define AN_CMD_SLEEP 0x0085
#define AN_CMD_SAVECFG 0x0108
/*
* MPI 350 DMA descriptor information
*/
#define AN_DESCRIPTOR_TX 0x01
#define AN_DESCRIPTOR_RX 0x02
#define AN_DESCRIPTOR_TXCMP 0x04
#define AN_DESCRIPTOR_HOSTWRITE 0x08
#define AN_DESCRIPTOR_HOSTREAD 0x10
#define AN_DESCRIPTOR_HOSTRW 0x20
#define AN_MAX_RX_DESC 1
#define AN_MAX_TX_DESC 1
#define AN_HOSTBUFSIZ 1840
struct an_card_rid_desc
{
unsigned an_rid:16;
unsigned an_len:15;
unsigned an_valid:1;
u_int64_t an_phys;
};
struct an_card_rx_desc
{
unsigned an_ctrl:15;
unsigned an_done:1;
unsigned an_len:15;
unsigned an_valid:1;
u_int64_t an_phys;
};
struct an_card_tx_desc
{
unsigned an_offset:15;
unsigned an_eoc:1;
unsigned an_len:15;
unsigned an_valid:1;
u_int64_t an_phys;
};
#define AN_RID_BUFFER_SIZE AN_MAX_DATALEN
#define AN_RX_BUFFER_SIZE AN_HOSTBUFSIZ
#define AN_TX_BUFFER_SIZE AN_HOSTBUFSIZ
/*#define AN_HOST_DESC_OFFSET 0xC sort of works */
#define AN_HOST_DESC_OFFSET 0x800
#define AN_RX_DESC_OFFSET (AN_HOST_DESC_OFFSET + \
sizeof(struct an_card_rid_desc))
#define AN_TX_DESC_OFFSET (AN_RX_DESC_OFFSET + \
(AN_MAX_RX_DESC * sizeof(struct an_card_rx_desc)))
struct an_command {
u_int16_t an_cmd;
u_int16_t an_parm0;
u_int16_t an_parm1;
u_int16_t an_parm2;
};
struct an_reply {
u_int16_t an_status;
u_int16_t an_resp0;
u_int16_t an_resp1;
u_int16_t an_resp2;
};
/*
* Reclaim qualifier bit, applicable to the
* TX command.
*/
#define AN_RECLAIM 0x0100 /* reclaim NIC memory */
/*
* ACCESS command qualifier bits.
*/
#define AN_ACCESS_READ 0x0000
#define AN_ACCESS_WRITE 0x0100
/*
* PROGRAM command qualifier bits.
*/
#define AN_PROGRAM_DISABLE 0x0000
#define AN_PROGRAM_ENABLE_RAM 0x0100
#define AN_PROGRAM_ENABLE_NVRAM 0x0200
#define AN_PROGRAM_NVRAM 0x0300
/* Status register values */
#define AN_STAT_CMD_CODE 0x003F
#define AN_STAT_CMD_RESULT 0x7F00
/* Linkstat register */
#define AN_LINKSTAT_ASSOCIATED 0x0400
#define AN_LINKSTAT_AUTHFAIL 0x0300
#define AN_LINKSTAT_ASSOC_FAIL 0x8400
#define AN_LINKSTAT_DISASSOC 0x8200
#define AN_LINKSTAT_DEAUTH 0x8100
#define AN_LINKSTAT_SYNCLOST_TSF 0x8004
#define AN_LINKSTAT_SYNCLOST_HOSTREQ 0x8003
#define AN_LINKSTAT_SYNCLOST_AVGRETRY 0x8002
#define AN_LINKSTAT_SYNCLOST_MAXRETRY 0x8001
#define AN_LINKSTAT_SYNCLOST_MISSBEACON 0x8000
/* memory handle management registers */
#define AN_RX_FID 0x20
#define AN_ALLOC_FID 0x22
#define AN_TX_CMP_FID(x) (x ? 0x1a : 0x24)
/*
* Buffer Access Path (BAP) registers.
* These are I/O channels. I believe you can use each one for
* any desired purpose independently of the other. In general
* though, we use BAP1 for reading and writing LTV records and
* reading received data frames, and BAP0 for writing transmit
* frames. This is a convention though, not a rule.
*/
#define AN_SEL0 0x18
#define AN_SEL1 0x1A
#define AN_OFF0 0x1C
#define AN_OFF1 0x1E
#define AN_DATA0 0x36
#define AN_DATA1 0x38
#define AN_BAP0 AN_DATA0
#define AN_BAP1 AN_DATA1
#define AN_OFF_BUSY 0x8000
#define AN_OFF_ERR 0x4000
#define AN_OFF_DONE 0x2000
#define AN_OFF_DATAOFF 0x0FFF
/* Event registers */
#define AN_EVENT_STAT(x) (x ? 0x60 : 0x30) /* Event status */
#define AN_INT_EN(x) (x ? 0x64 : 0x32) /* Interrupt enable/
disable */
#define AN_EVENT_ACK(x) (x ? 0x68 : 0x34) /* Ack event */
/* Events */
#define AN_EV_CLR_STUCK_BUSY 0x4000 /* clear stuck busy bit */
#define AN_EV_WAKEREQUEST 0x2000 /* awaken from PSP mode */
#define AN_EV_MIC 0x1000 /* Message Integrity Check*/
#define AN_EV_AWAKE 0x0100 /* station woke up from PSP mode*/
#define AN_EV_LINKSTAT 0x0080 /* link status available */
#define AN_EV_CMD 0x0010 /* command completed */
#define AN_EV_ALLOC 0x0008 /* async alloc/reclaim completed */
#define AN_EV_TX_CPY 0x0400
#define AN_EV_TX_EXC 0x0004 /* async xmit completed with failure */
#define AN_EV_TX 0x0002 /* async xmit completed succesfully */
#define AN_EV_RX 0x0001 /* async rx completed */
#define AN_INTRS(x) \
( x ? (AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_TX_CPY|AN_EV_ALLOC \
|AN_EV_LINKSTAT|AN_EV_MIC) \
: \
(AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC \
|AN_EV_LINKSTAT|AN_EV_MIC) \
)
/* Host software registers */
#define AN_SW0(x) (x ? 0x50 : 0x28)
#define AN_SW1(x) (x ? 0x54 : 0x2A)
#define AN_SW2(x) (x ? 0x58 : 0x2C)
#define AN_SW3(x) (x ? 0x5c : 0x2E)
#define AN_CNTL 0x14
#define AN_CNTL_AUX_ENA 0xC000
#define AN_CNTL_AUX_ENA_STAT 0xC000
#define AN_CNTL_AUX_DIS_STAT 0x0000
#define AN_CNTL_AUX_ENA_CNTL 0x8000
#define AN_CNTL_AUX_DIS_CNTL 0x4000
#define AN_AUX_PAGE 0x3A
#define AN_AUX_OFFSET 0x3C
#define AN_AUX_DATA 0x3E
/*
* Length, Type, Value (LTV) record definitions and RID values.
*/
struct an_ltv_gen {
u_int16_t an_len;
u_int16_t an_type;
u_int16_t an_val;
};
#define AN_DEF_SSID_LEN 7
#define AN_DEF_SSID "tsunami"
#define AN_RXGAP_MAX 8
/*
* 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_int8_t an_gaplen; /* 0x32 */
} __packed;
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 */
};
#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 */
};
#define AN_TXSTAT_EXCESS_RETRY 0x0002
#define AN_TXSTAT_LIFE_EXCEEDED 0x0004
#define AN_TXSTAT_AID_FAIL 0x0008
#define AN_TXSTAT_MAC_DISABLED 0x0010
#define AN_TXSTAT_ASSOC_LOST 0x0020
#define AN_TXCTL_RSVD 0x0001
#define AN_TXCTL_TXOK_INTR 0x0002
#define AN_TXCTL_TXERR_INTR 0x0004
#define AN_TXCTL_HEADER_TYPE 0x0008
#define AN_TXCTL_PAYLOAD_TYPE 0x0010
#define AN_TXCTL_NORELEASE 0x0020
#define AN_TXCTL_NORETRIES 0x0040
#define AN_TXCTL_CLEAR_AID 0x0080
#define AN_TXCTL_STRICT_ORDER 0x0100
#define AN_TXCTL_USE_RTS 0x0200
#define AN_HEADERTYPE_8023 0x0000
#define AN_HEADERTYPE_80211 0x0008
#define AN_PAYLOADTYPE_ETHER 0x0000
#define AN_PAYLOADTYPE_LLC 0x0010
#define AN_TXCTL_80211 \
(AN_TXCTL_TXOK_INTR|AN_TXCTL_TXERR_INTR|AN_HEADERTYPE_80211| \
AN_PAYLOADTYPE_LLC|AN_TXCTL_NORELEASE)
#define AN_TXCTL_8023 \
(AN_TXCTL_TXOK_INTR|AN_TXCTL_TXERR_INTR|AN_HEADERTYPE_8023| \
AN_PAYLOADTYPE_ETHER|AN_TXCTL_NORELEASE)
#define AN_TXGAP_80211 0
#define AN_TXGAP_8023 0
struct an_802_3_hdr {
u_int16_t an_8023_status;
u_int16_t an_8023_payload_len;
u_int8_t an_8023_dst_addr[6];
u_int8_t an_8023_src_addr[6];
u_int16_t an_8023_dat[3]; /* SNAP header */
u_int16_t an_8023_type;
};
struct an_snap_hdr {
u_int16_t an_snap_dat[3]; /* SNAP header */
u_int16_t an_snap_type;
};
struct an_dma_alloc {
u_int32_t an_dma_paddr;
caddr_t an_dma_vaddr;
bus_dmamap_t an_dma_map;
bus_dma_segment_t an_dma_seg;
bus_size_t an_dma_size;
int an_dma_nseg;
};
#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;
int an_tx_empty;
};
struct an_softc {
struct ifnet *an_ifp;
int an_unit;
int port_rid; /* resource id for port range */
struct resource* port_res; /* resource for port range */
int mem_rid; /* resource id for memory range */
int mem_used; /* nonzero if memory used */
struct resource* mem_res; /* resource for memory range */
int mem_aux_rid; /* resource id for memory range */
int mem_aux_used; /* nonzero if memory used */
struct resource* mem_aux_res; /* resource for memory range */
int irq_rid; /* resource id for irq */
void* irq_handle; /* handle for irq handler */
struct resource* irq_res; /* resource for irq */
bus_space_handle_t an_bhandle_p;
bus_space_handle_t an_bhandle;
bus_space_tag_t an_btag;
bus_space_handle_t an_mem_bhandle;
bus_space_tag_t an_mem_btag;
bus_space_handle_t an_mem_aux_bhandle;
bus_space_tag_t an_mem_aux_btag;
bus_dma_tag_t an_dtag;
struct an_ltv_genconfig an_config;
struct an_ltv_caps an_caps;
struct an_ltv_ssidlist_new an_ssidlist;
struct an_ltv_aplist an_aplist;
struct an_ltv_key an_temp_keys[4];
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_sigitems;
struct an_sigcache an_sigcache[MAXANCACHE];
int an_nextitem;
int an_have_rssimap;
struct an_ltv_rssi_map an_rssimap;
#endif
struct callout an_stat_ch;
struct mtx an_mtx;
device_t an_dev;
struct ifmedia an_ifmedia;
int an_monitor;
int an_was_monitor;
u_char buf_802_11[MCLBYTES];
struct an_req areq;
unsigned short* an_flash_buffer;
int mpi350;
struct an_dma_alloc an_rid_buffer;
struct an_dma_alloc an_rx_buffer[AN_MAX_RX_DESC];
struct an_dma_alloc an_tx_buffer[AN_MAX_TX_DESC];
};
#define AN_LOCK(_sc) mtx_lock(&(_sc)->an_mtx)
#define AN_UNLOCK(_sc) mtx_unlock(&(_sc)->an_mtx)
#define AN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->an_mtx, MA_OWNED)
void an_release_resources (device_t);
int an_alloc_port (device_t, int, int);
int an_alloc_memory (device_t, int, int);
int an_alloc_aux_memory (device_t, int, int);
int an_alloc_irq (device_t, int, int);
int an_pci_probe (device_t);
int an_probe (device_t);
int an_shutdown (device_t);
void an_resume (device_t);
int an_attach (struct an_softc *, int, int);
int an_detach (device_t);
void an_stop (struct an_softc *);
driver_intr_t an_intr;
#define AN_802_3_OFFSET 0x2E
#define AN_802_11_OFFSET 0x44
#define AN_802_11_OFFSET_RAW 0x3C
#define AN_STAT_BADCRC 0x0001
#define AN_STAT_UNDECRYPTABLE 0x0002
#define AN_STAT_ERRSTAT 0x0003
#define AN_STAT_MAC_PORT 0x0700
#define AN_STAT_1042 0x2000 /* RFC1042 encoded */
#define AN_STAT_TUNNEL 0x4000 /* Bridge-tunnel encoded */
#define AN_STAT_WMP_MSG 0x6000 /* WaveLAN-II management protocol */
#define AN_RXSTAT_MSG_TYPE 0xE000
#define AN_ENC_TX_802_3 0x00
#define AN_ENC_TX_802_11 0x11
#define AN_ENC_TX_E_II 0x0E
#define AN_ENC_TX_1042 0x00
#define AN_ENC_TX_TUNNEL 0xF8
#define AN_TXCNTL_MACPORT 0x00FF
#define AN_TXCNTL_STRUCTTYPE 0xFF00
/*
* SNAP (sub-network access protocol) constants for transmission
* of IP datagrams over IEEE 802 networks, taken from RFC1042.
* We need these for the LLC/SNAP header fields in the TX/RX frame
* structure.
*/
#define AN_SNAP_K1 0xaa /* assigned global SAP for SNAP */
#define AN_SNAP_K2 0x00
#define AN_SNAP_CONTROL 0x03 /* unnumbered information format */
#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

View File

@ -0,0 +1 @@
#define INET 1

View File

@ -0,0 +1,23 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan wavelanwifi ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ]
-Wno-format
-Wno-unused
-Wno-uninitialized ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev wi ] ;
KernelAddon wavelanwifi :
if_wi.c
if_wi_pci.c
:
libfreebsd_wlan.a
libfreebsd_network.a
;

View File

@ -0,0 +1,753 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _IF_WAVELAN_IEEE_H
#define _IF_WAVELAN_IEEE_H
/*
* This header defines a simple command interface to the FreeBSD
* WaveLAN/IEEE driver (wi) driver, which is used to set certain
* device-specific parameters which can't be easily managed through
* ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_
* interface, didn't I.
*/
#ifndef SIOCSWAVELAN
#define SIOCSWAVELAN SIOCSIFGENERIC
#endif
#ifndef SIOCGWAVELAN
#define SIOCGWAVELAN SIOCGIFGENERIC
#endif
/*
* Technically I don't think there's a limit to a record
* length. The largest record is the one that contains the CIS
* data, which is 240 words long, so 256 should be a safe
* value.
*/
#define WI_MAX_DATALEN 512
#if 0
struct wi_req {
u_int16_t wi_len;
u_int16_t wi_type;
u_int16_t wi_val[WI_MAX_DATALEN];
};
#endif
/*
* Private LTV records (interpreted only by the driver). This is
* a minor kludge to allow reading the interface statistics from
* the driver.
*/
#define WI_RID_IFACE_STATS 0x0100
#define WI_RID_MGMT_XMIT 0x0200
#define WI_RID_ZERO_CACHE 0x0300
#define WI_RID_READ_CACHE 0x0400
#define WI_RID_FWDOWNLOAD 0x0500
#define WI_RID_MONITOR_MODE 0x0600
#define WI_RID_MIF 0x0700
#define WI_RID_SCAN_APS 0x0800
#define WI_RID_READ_APS 0x0900
struct wi_80211_hdr {
u_int16_t frame_ctl;
u_int16_t dur_id;
u_int8_t addr1[6];
u_int8_t addr2[6];
u_int8_t addr3[6];
u_int16_t seq_ctl;
u_int8_t addr4[6];
};
#define WI_FCTL_VERS 0x0002
#define WI_FCTL_FTYPE 0x000C
#define WI_FCTL_STYPE 0x00F0
#define WI_FCTL_TODS 0x0100
#define WI_FCTL_FROMDS 0x0200
#define WI_FCTL_MOREFRAGS 0x0400
#define WI_FCTL_RETRY 0x0800
#define WI_FCTL_PM 0x1000
#define WI_FCTL_MOREDATA 0x2000
#define WI_FCTL_WEP 0x4000
#define WI_FCTL_ORDER 0x8000
#define WI_FTYPE_MGMT 0x0000
#define WI_FTYPE_CTL 0x0004
#define WI_FTYPE_DATA 0x0008
#define WI_STYPE_MGMT_ASREQ 0x0000 /* association request */
#define WI_STYPE_MGMT_ASRESP 0x0010 /* association response */
#define WI_STYPE_MGMT_REASREQ 0x0020 /* reassociation request */
#define WI_STYPE_MGMT_REASRESP 0x0030 /* reassociation response */
#define WI_STYPE_MGMT_PROBEREQ 0x0040 /* probe request */
#define WI_STYPE_MGMT_PROBERESP 0x0050 /* probe response */
#define WI_STYPE_MGMT_BEACON 0x0080 /* beacon */
#define WI_STYPE_MGMT_ATIM 0x0090 /* announcement traffic ind msg */
#define WI_STYPE_MGMT_DISAS 0x00A0 /* disassociation */
#define WI_STYPE_MGMT_AUTH 0x00B0 /* authentication */
#define WI_STYPE_MGMT_DEAUTH 0x00C0 /* deauthentication */
#define WI_STYPE_CTL_PSPOLL 0x00A0
#define WI_STYPE_CTL_RTS 0x00B0
#define WI_STYPE_CTL_CTS 0x00C0
#define WI_STYPE_CTL_ACK 0x00D0
#define WI_STYPE_CTL_CFEND 0x00E0
#define WI_STYPE_CTL_CFENDACK 0x00F0
struct wi_mgmt_hdr {
u_int16_t frame_ctl;
u_int16_t duration;
u_int8_t dst_addr[6];
u_int8_t src_addr[6];
u_int8_t bssid[6];
u_int16_t seq_ctl;
};
/*
* Lucent/wavelan IEEE signal strength cache
*
* driver keeps cache of last
* MAXWICACHE packets to arrive including signal strength info.
* daemons may read this via ioctl
*
* Each entry in the wi_sigcache has a unique macsrc.
*/
struct wi_sigcache {
char macsrc[6]; /* unique MAC address for entry */
int ipsrc; /* ip address associated with packet */
int signal; /* signal strength of the packet */
int noise; /* noise value */
int quality; /* quality of the packet */
};
/*
* Firmware downloading API. We support downloading into RAM and into
* flash. We copy the entire .hex file for both the primary and secondary
* firmware into the kernel, which is minorly gross, but matches the
* format of the compiled in firmware.
*/
struct wi_fwdownload {
int type; /* What type of download. */
#define WI_FW_RAM 1
#define WI_FW_FLASH 2
size_t pri_len; /* Primary firmware length */
size_t sec_len; /* Secondary firmware length */
caddr_t pri_data; /* Pointer (user) to primary data */
caddr_t sec_data; /* Pointer (user) to secondary data */
};
struct wi_counters {
u_int32_t wi_tx_unicast_frames;
u_int32_t wi_tx_multicast_frames;
u_int32_t wi_tx_fragments;
u_int32_t wi_tx_unicast_octets;
u_int32_t wi_tx_multicast_octets;
u_int32_t wi_tx_deferred_xmits;
u_int32_t wi_tx_single_retries;
u_int32_t wi_tx_multi_retries;
u_int32_t wi_tx_retry_limit;
u_int32_t wi_tx_discards;
u_int32_t wi_rx_unicast_frames;
u_int32_t wi_rx_multicast_frames;
u_int32_t wi_rx_fragments;
u_int32_t wi_rx_unicast_octets;
u_int32_t wi_rx_multicast_octets;
u_int32_t wi_rx_fcs_errors;
u_int32_t wi_rx_discards_nobuf;
u_int32_t wi_tx_discards_wrong_sa;
u_int32_t wi_rx_WEP_cant_decrypt;
u_int32_t wi_rx_msg_in_msg_frags;
u_int32_t wi_rx_msg_in_bad_msg_frags;
};
/*
* Network parameters, static configuration entities.
*/
#define WI_RID_PORTTYPE 0xFC00 /* Connection control characteristics */
#define WI_RID_MAC_NODE 0xFC01 /* MAC address of this station */
#define WI_RID_DESIRED_SSID 0xFC02 /* Service Set ID for connection */
#define WI_RID_OWN_CHNL 0xFC03 /* Comm channel for BSS creation */
#define WI_RID_OWN_SSID 0xFC04 /* IBSS creation ID */
#define WI_RID_OWN_ATIM_WIN 0xFC05 /* ATIM window time for IBSS creation */
#define WI_RID_SYSTEM_SCALE 0xFC06 /* scale that specifies AP density */
#define WI_RID_MAX_DATALEN 0xFC07 /* Max len of MAC frame body data */
#define WI_RID_MAC_WDS 0xFC08 /* MAC addr of corresponding WDS node */
#define WI_RID_PM_ENABLED 0xFC09 /* ESS power management enable */
#define WI_RID_PM_EPS 0xFC0A /* PM EPS/PS mode */
#define WI_RID_MCAST_RX 0xFC0B /* ESS PM mcast reception */
#define WI_RID_MAX_SLEEP 0xFC0C /* max sleep time for ESS PM */
#define WI_RID_HOLDOVER 0xFC0D /* holdover time for ESS PM */
#define WI_RID_NODENAME 0xFC0E /* ID name of this node for diag */
#define WI_RID_DTIM_PERIOD 0xFC10 /* beacon interval between DTIMs */
#define WI_RID_WDS_ADDR1 0xFC11 /* port 1 MAC of WDS link node */
#define WI_RID_WDS_ADDR2 0xFC12 /* port 1 MAC of WDS link node */
#define WI_RID_WDS_ADDR3 0xFC13 /* port 1 MAC of WDS link node */
#define WI_RID_WDS_ADDR4 0xFC14 /* port 1 MAC of WDS link node */
#define WI_RID_WDS_ADDR5 0xFC15 /* port 1 MAC of WDS link node */
#define WI_RID_WDS_ADDR6 0xFC16 /* port 1 MAC of WDS link node */
#define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */
#define WI_RID_ENCRYPTION 0xFC20 /* enable/disable WEP */
#define WI_RID_AUTHTYPE 0xFC21 /* specify authentication type */
#define WI_RID_P2_TX_CRYPT_KEY 0xFC23
#define WI_RID_P2_CRYPT_KEY0 0xFC24
#define WI_RID_P2_CRYPT_KEY1 0xFC25
#define WI_RID_MICROWAVE_OVEN 0xFC25
#define WI_RID_P2_CRYPT_KEY2 0xFC26
#define WI_RID_P2_CRYPT_KEY3 0xFC27
#define WI_RID_P2_ENCRYPTION 0xFC28
#define WI_RID_ALT_RETRY_CNT 0xFC32
#define PRIVACY_INVOKED 0x01
#define EXCLUDE_UNENCRYPTED 0x02
#define HOST_ENCRYPT 0x10
#define IV_EVERY_FRAME 0x00 /* IV = Initialization Vector */
#define IV_EVERY10_FRAME 0x20 /* every 10 frame IV reuse */
#define IV_EVERY50_FRAME 0x40 /* every 50 frame IV reuse */
#define IV_EVERY100_FRAME 0x60 /* every 100 frame IV reuse */
#define HOST_DECRYPT 0x80
#define WI_RID_WEP_MAPTABLE 0xFC29
#define WI_RID_CNFAUTHMODE 0xFC2A
#define WI_RID_ROAMING_MODE 0xFC2D
#define WI_RID_OWN_BEACON_INT 0xFC33 /* beacon xmit time for BSS creation */
#define WI_RID_ENH_SECURITY 0xFC43 /* enhanced security (AP mode) */
#define WI_RID_CNF_DBM_ADJUST 0xFC46
#define WI_RID_DBM_ADJUST 0xFC46 /* RSSI - WI_RID_DBM_ADJUST ~ dBm */
#define WI_RID_WPA_DATA 0xFC48 /* WPA IE */
#define WI_RID_BASIC_RATE 0xFCB3
#define WI_RID_SUPPORT_RATE 0xFCB4
#define WI_RID_WPA_HANDLING 0xFCBB /* WPA handling procedures */
/*
* Network parameters, dynamic configuration entities
*/
#define WI_RID_MCAST_LIST 0xFC80 /* list of multicast addrs */
#define WI_RID_CREATE_IBSS 0xFC81 /* create IBSS */
#define WI_RID_FRAG_THRESH 0xFC82 /* frag len, unicast msg xmit */
#define WI_RID_RTS_THRESH 0xFC83 /* frame len for RTS/CTS handshake */
#define WI_RID_TX_RATE 0xFC84 /* data rate for message xmit
* 0 == Fixed 1mbps
* 1 == Fixed 2mbps
* 2 == auto fallback
*/
#define WI_RID_PROMISC 0xFC85 /* enable promisc mode */
#define WI_RID_FRAG_THRESH0 0xFC90
#define WI_RID_FRAG_THRESH1 0xFC91
#define WI_RID_FRAG_THRESH2 0xFC92
#define WI_RID_FRAG_THRESH3 0xFC93
#define WI_RID_FRAG_THRESH4 0xFC94
#define WI_RID_FRAG_THRESH5 0xFC95
#define WI_RID_FRAG_THRESH6 0xFC96
#define WI_RID_RTS_THRESH0 0xFC97
#define WI_RID_RTS_THRESH1 0xFC98
#define WI_RID_RTS_THRESH2 0xFC99
#define WI_RID_RTS_THRESH3 0xFC9A
#define WI_RID_RTS_THRESH4 0xFC9B
#define WI_RID_RTS_THRESH5 0xFC9C
#define WI_RID_RTS_THRESH6 0xFC9D
#define WI_RID_TX_RATE0 0xFC9E
#define WI_RID_TX_RATE1 0xFC9F
#define WI_RID_TX_RATE2 0xFCA0
#define WI_RID_TX_RATE3 0xFCA1
#define WI_RID_TX_RATE4 0xFCA2
#define WI_RID_TX_RATE5 0xFCA3
#define WI_RID_TX_RATE6 0xFCA4
#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
#define WI_RID_TX_CRYPT_KEY 0xFCB1
#define WI_RID_TICK_TIME 0xFCE0
struct wi_key {
u_int16_t wi_keylen;
u_int8_t wi_keydat[14];
};
#define WI_NLTV_KEYS 4
struct wi_ltv_keys {
u_int16_t wi_len;
u_int16_t wi_type;
struct wi_key wi_keys[WI_NLTV_KEYS];
};
/*
* NIC information
*/
#define WI_RID_DNLD_BUF 0xFD01
#define WI_RID_MEMSZ 0xFD02 /* memory size info (XXX Lucent) */
/* Looks like on lucnet pri firm too */
#define WI_RID_PRI_IDENTITY 0xFD02 /* primary funcs firmware ident (PRISM2) */
#define WI_RID_PRI_SUP_RANGE 0xFD03 /* primary supplier compatibility */
#define WI_RID_CIF_ACT_RANGE 0xFD04 /* controller sup. compatibility */
#define WI_RID_SERIALNO 0xFD0A /* card serial number */
#define WI_RID_CARD_ID 0xFD0B /* card identification */
#define WI_RID_MFI_SUP_RANGE 0xFD0C /* modem supplier compatibility */
#define WI_RID_CFI_SUP_RANGE 0xFD0D /* controller sup. compatibility */
#define WI_RID_CHANNEL_LIST 0xFD10 /* allowd comm. frequencies. */
#define WI_RID_REG_DOMAINS 0xFD11 /* list of intendted regulatory doms */
#define WI_RID_TEMP_TYPE 0xFD12 /* hw temp range code */
#define WI_RID_CIS 0xFD13 /* PC card info struct */
#define WI_RID_STA_IDENTITY 0xFD20 /* station funcs firmware ident */
#define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */
#define WI_RID_MFI_ACT_RANGE 0xFD22
#define WI_RID_SYMBOL_IDENTITY 0xFD24
#define WI_RID_CFI_ACT_RANGE 0xFD33
#define WI_RID_COMMQUAL 0xFD43
#define WI_RID_SCALETHRESH 0xFD46
#define WI_RID_PCF 0xFD87
/*
* MAC information
*/
#define WI_RID_PORT_STAT 0xFD40 /* actual MAC port con control stat */
#define WI_RID_CURRENT_SSID 0xFD41 /* ID of actually connected SS */
#define WI_RID_CURRENT_BSSID 0xFD42 /* ID of actually connected BSS */
#define WI_RID_COMMS_QUALITY 0xFD43 /* quality of BSS connection */
#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */
#define WI_RID_CUR_BEACON_INT 0xFD45 /* current beacon interval */
#define WI_RID_CUR_SCALE_THRESH 0xFD46 /* actual system scane thresh setting */
#define WI_RID_PROT_RESP_TIME 0xFD47 /* time to wait for resp to req msg */
#define WI_RID_SHORT_RTR_LIM 0xFD48 /* max tx attempts for short frames */
#define WI_RID_LONG_RTS_LIM 0xFD49 /* max tx attempts for long frames */
#define WI_RID_MAX_TX_LIFE 0xFD4A /* max tx frame handling duration */
#define WI_RID_MAX_RX_LIFE 0xFD4B /* max rx frame handling duration */
#define WI_RID_CF_POLL 0xFD4C /* contention free pollable ind */
#define WI_RID_AUTH_ALGS 0xFD4D /* auth algorithms available */
#define WI_RID_AUTH_TYPE 0xFD4E /* availanle auth types */
#define WI_RID_WEP_AVAIL 0xFD4F /* WEP privacy option available */
#define WI_RID_DBM_COMMS_QUAL 0xFD51 /* CommQuality normalized to dBm */
#define WI_RID_CUR_TX_RATE1 0xFD80
#define WI_RID_CUR_TX_RATE2 0xFD81
#define WI_RID_CUR_TX_RATE3 0xFD82
#define WI_RID_CUR_TX_RATE4 0xFD83
#define WI_RID_CUR_TX_RATE5 0xFD84
#define WI_RID_CUR_TX_RATE6 0xFD85
#define WI_RID_OWN_MAC 0xFD86 /* unique local MAC addr */
#define WI_RID_PCI_INFO 0xFD87 /* point coordination func cap */
/*
* Scan Information
*/
#define WI_RID_BCAST_SCAN_REQ 0xFCAB /* Broadcast Scan request (Symbol) */
#define BSCAN_5SEC 0x01
#define BSCAN_ONETIME 0x02
#define BSCAN_PASSIVE 0x40
#define BSCAN_BCAST 0x80
#define WI_RID_SCAN_REQ 0xFCE1 /* Scan request (STA only) */
#define WI_RID_JOIN_REQ 0xFCE2 /* Join request (STA only) */
#define WI_RID_AUTH_STATION 0xFCE3 /* Authenticates Station (AP) */
#define WI_RID_CHANNEL_REQ 0xFCE4 /* Channel Information Request (AP) */
#define WI_RID_SCAN_RESULTS 0xFD88 /* Scan Results Table */
struct wi_apinfo {
int scanreason; /* ScanReason */
char bssid[6]; /* BSSID (mac address) */
int channel; /* Channel */
int signal; /* Signal level */
int noise; /* Average Noise Level*/
int quality; /* Quality */
int namelen; /* Length of SSID string */
char name[32]; /* SSID string */
int capinfo; /* Capability info. */
int interval; /* BSS Beacon Interval */
int rate; /* Data Rate */
};
/*
* Modem information
*/
#define WI_RID_PHY_TYPE 0xFDC0 /* phys layer type indication */
#define WI_RID_CURRENT_CHAN 0xFDC1 /* current frequency */
#define WI_RID_PWR_STATE 0xFDC2 /* pwr consumption status */
#define WI_RID_CCA_MODE 0xFDC3 /* clear chan assess mode indication */
#define WI_RID_CCA_TIME 0xFDC4 /* clear chan assess time */
#define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */
#define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */
/*
* bsd-airtools v0.2 - source-mods v0.2 [common.h]
* by h1kari - (c) Dachb0den Labs 2001
*/
/*
* Copyright (c) 2001 Dachb0den Labs.
* David Hulton <h1kari@dachb0den.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by David Hulton.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY David Hulton AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL David Hulton OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* standard hermes recieve frame used by wavelan/prism2 cards
*/
struct wi_rx_frame {
/*
* hermes prefix header. supplies information on the current status of
* the network and various other statistics gathered from the
* management/control frames as used internally.
*/
u_int16_t wi_status;
u_int16_t wi_ts0;
u_int16_t wi_ts1;
u_int8_t wi_silence;
u_int8_t wi_signal;
u_int8_t wi_rate;
u_int8_t wi_rx_flow;
u_int16_t wi_rsvd0;
u_int16_t wi_rsvd1;
/*
* standard 80211 frame header. all packets have to use this header as
* per the AN9900 from intersil, even management/control. for
* management packets, they just threw the header into the data field,
* but for control packets the headers are lost in translation and
* therefore not all control packet info can be displayed.
*/
u_int16_t wi_frame_ctl;
u_int16_t wi_id;
u_int8_t wi_addr1[6];
u_int8_t wi_addr2[6];
u_int8_t wi_addr3[6];
u_int16_t wi_seq_ctl;
u_int8_t wi_addr4[6];
u_int16_t wi_dat_len;
/*
* another wierdity with the drivers. they append a 802.3 header which
* is somewhat redundant, since all the same data is provided in the
* 802.11 header.
*/
u_int8_t wi_dst_addr[6];
u_int8_t wi_src_addr[6];
u_int16_t wi_len;
};
#define WI_DATA_HDRLEN 0x3C
#define WI_MGMT_HDRLEN 0x3C
#define WI_CTL_HDRLEN 0x3C
/*
* all data packets have a snap (sub-network access protocol) header that
* isn't entirely definied, but added for ethernet compatibility.
*/
struct wi_snap_frame {
u_int16_t wi_dat[3];
u_int16_t wi_type;
};
/*
* management frame headers
* note: all management frames consist of a static header and variable length
* fields.
*/
/*
* variable length field structure
*/
struct wi_mgmt_var_hdr {
u_int8_t wi_code;
u_int8_t wi_len;
u_int8_t wi_data[256];
};
/*
* management beacon frame prefix
*/
struct wi_mgmt_beacon_hdr {
u_int32_t wi_ts0;
u_int32_t wi_ts1;
u_int16_t wi_interval;
u_int16_t wi_capinfo;
};
/*
* ibss announcement traffic indication message (atim) frame
* note: no parameters
*/
/*
* management disassociation frame
*/
struct wi_mgmt_disas_hdr {
u_int16_t wi_reason;
};
/*
* management association request frame prefix
*/
struct wi_mgmt_asreq_hdr {
u_int16_t wi_capinfo;
u_int16_t wi_interval;
};
/*
* management association response frame prefix
*/
struct wi_mgmt_asresp_hdr {
u_int16_t wi_capinfo;
u_int16_t wi_status;
u_int16_t wi_aid;
};
/*
* management reassociation request frame prefix
*/
struct wi_mgmt_reasreq_hdr {
u_int16_t wi_capinfo;
u_int16_t wi_interval;
u_int8_t wi_currap[6];
};
/*
* management reassociation response frame prefix
*/
struct wi_mgmt_reasresp_hdr {
u_int16_t wi_capinfo;
u_int16_t wi_status;
u_int16_t wi_aid;
};
/*
* management probe request frame prefix
* note: no static parameters, only variable length
*/
/*
* management probe response frame prefix
*/
struct wi_mgmt_proberesp_hdr {
u_int32_t wi_ts0;
u_int32_t wi_ts1;
u_int16_t wi_interval;
u_int16_t wi_capinfo;
};
/*
* management authentication frame prefix
*/
struct wi_mgmt_auth_hdr {
u_int16_t wi_algo;
u_int16_t wi_seq;
u_int16_t wi_status;
};
/*
* management deauthentication frame
*/
struct wi_mgmt_deauth_hdr {
u_int16_t wi_reason;
};
/*
* rid configuration register definitions
*/
#define WI_RID_SCAN_REQ 0xFCE1 /* scan request information */
#define WI_RID_SCAN_RES 0xFD88 /* scan result information */
#define WI_RID_PROCFRAME 0x3137 /* Return full frame information */
#define WI_RID_PRISM2 0x3138 /* tell if we're a prism2 card or not */
/*
* 802.11 definitions
*/
#define WI_STAT_BADCRC 0x0001
#define WI_STAT_UNDECRYPTABLE 0x0002
#define WI_STAT_ERRSTAT 0x0003
#define WI_STAT_MAC_PORT 0x0700
#define WI_STAT_1042 0x2000
#define WI_STAT_TUNNEL 0x4000
#define WI_STAT_WMP_MSG 0x6000
#define WI_RXSTAT_MSG_TYPE 0xE000
#define WI_FCTL_OPT_MASK 0xFF00
#define WI_AID_SET 0xC000
#define WI_AID_MASK 0x3FFF
#define WI_SCTL_FRAGNUM_MASK 0x000F
#define WI_SCTL_SEQNUM_MASK 0xFFF0
#define WI_STAT_UNSPEC_FAIL 1
#define WI_STAT_CAPINFO_FAIL 10
#define WI_STAT_REAS_DENY 11
#define WI_STAT_ASSOC_DENY 12
#define WI_STAT_ALGO_FAIL 13
#define WI_STAT_SEQ_FAIL 14
#define WI_STAT_CHAL_FAIL 15
#define WI_STAT_TOUT_FAIL 16
#define WI_STAT_OVERL_DENY 17
#define WI_STAT_RATE_DENY 18
#define WI_FTYPE_MGMT 0x0000
#define WI_FTYPE_CTL 0x0004
#define WI_FTYPE_DATA 0x0008
#define WI_FCTL_VERS 0x0002
#define WI_FCTL_FTYPE 0x000C
#define WI_FCTL_STYPE 0x00F0
#define WI_FCTL_TODS 0x0100
#define WI_FCTL_FROMDS 0x0200
#define WI_FCTL_MOREFRAGS 0x0400
#define WI_FCTL_RETRY 0x0800
#define WI_FCTL_PM 0x1000
#define WI_FCTL_MOREDATA 0x2000
#define WI_FCTL_WEP 0x4000
#define WI_FCTL_ORDER 0x8000
#define WI_FCS_LEN 0x4 /* checksum length */
/*
* management definitions
*/
#define WI_STYPE_MGMT_ASREQ 0x0000
#define WI_STYPE_MGMT_ASRESP 0x0010
#define WI_STYPE_MGMT_REASREQ 0x0020
#define WI_STYPE_MGMT_REASRESP 0x0030
#define WI_STYPE_MGMT_PROBEREQ 0x0040
#define WI_STYPE_MGMT_PROBERESP 0x0050
#define WI_STYPE_MGMT_BEACON 0x0080
#define WI_STYPE_MGMT_ATIM 0x0090
#define WI_STYPE_MGMT_DISAS 0x00A0
#define WI_STYPE_MGMT_AUTH 0x00B0
#define WI_STYPE_MGMT_DEAUTH 0x00C0
#define WI_CAPINFO_ESS 0x01
#define WI_CAPINFO_IBSS 0x02
#define WI_CAPINFO_CFPOLL 0x04
#define WI_CAPINFO_CFPOLLREQ 0x08
#define WI_CAPINFO_PRIV 0x10
#define WI_REASON_UNSPEC 1
#define WI_REASON_AUTH_INVALID 2
#define WI_REASON_DEAUTH_LEAVE 3
#define WI_REASON_DISAS_INACT 4
#define WI_REASON_DISAS_OVERL 5
#define WI_REASON_CLASS2 6
#define WI_REASON_CLASS3 7
#define WI_REASON_DISAS_LEAVE 8
#define WI_REASON_NOAUTH 9
#define WI_VAR_SSID 0
#define WI_VAR_SRATES 1
#define WI_VAR_FH 2
#define WI_VAR_DS 3
#define WI_VAR_CF 4
#define WI_VAR_TIM 5
#define WI_VAR_IBSS 6
#define WI_VAR_CHAL 16
#define WI_VAR_SRATES_MASK 0x7F
/*
* control definitions
*/
#define WI_STYPE_CTL_PSPOLL 0x00A0
#define WI_STYPE_CTL_RTS 0x00B0
#define WI_STYPE_CTL_CTS 0x00C0
#define WI_STYPE_CTL_ACK 0x00D0
#define WI_STYPE_CTL_CFEND 0x00E0
#define WI_STYPE_CTL_CFENDCFACK 0x00F0
/*
* ap scanning structures
*/
struct wi_scan_res {
u_int16_t wi_chan;
u_int16_t wi_noise;
u_int16_t wi_signal;
u_int8_t wi_bssid[6];
u_int16_t wi_interval;
u_int16_t wi_capinfo;
u_int16_t wi_ssid_len;
u_int8_t wi_ssid[32];
u_int8_t wi_srates[10];
u_int8_t wi_rate;
u_int8_t wi_rsvd;
};
#define WI_WAVELAN_RES_SIZE 50
struct wi_scan_p2_hdr {
u_int16_t wi_rsvd;
u_int16_t wi_reason;
};
#define WI_PRISM2_RES_SIZE 62
/*
* prism2 debug mode definitions
*/
#define SIOCSPRISM2DEBUG _IOW('i', 137, struct ifreq)
#define SIOCGPRISM2DEBUG _IOWR('i', 138, struct ifreq)
#define WI_DEBUG_RESET 0x00
#define WI_DEBUG_INIT 0x01
#define WI_DEBUG_SLEEP 0x02
#define WI_DEBUG_WAKE 0x03
#define WI_DEBUG_CHAN 0x08
#define WI_DEBUG_DELAYSUPP 0x09
#define WI_DEBUG_TXSUPP 0x0A
#define WI_DEBUG_MONITOR 0x0B
#define WI_DEBUG_LEDTEST 0x0C
#define WI_DEBUG_CONTTX 0x0E
#define WI_DEBUG_STOPTEST 0x0F
#define WI_DEBUG_CONTRX 0x10
#define WI_DEBUG_SIGSTATE 0x11
#define WI_DEBUG_CALENABLE 0x13
#define WI_DEBUG_CONFBITS 0x15
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,201 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
*
* Written by Bill Paul <wpaul@ctr.columbia.edu>
* Electrical Engineering Department
* Columbia University, New York City
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
#define PCCARD_API_LEVEL 6
#include <dev/pccard/pccardvar.h>
#include <dev/pccard/pccard_cis.h>
#include <dev/wi/if_wavelan_ieee.h>
#include <dev/wi/if_wireg.h>
#include <dev/wi/if_wivar.h>
#include "card_if.h"
#include "pccarddevs.h"
static int wi_pccard_probe(device_t);
static int wi_pccard_attach(device_t);
static device_method_t wi_pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, wi_pccard_probe),
DEVMETHOD(device_attach, wi_pccard_attach),
DEVMETHOD(device_detach, wi_detach),
DEVMETHOD(device_shutdown, wi_shutdown),
{ 0, 0 }
};
static driver_t wi_pccard_driver = {
"wi",
wi_pccard_methods,
sizeof(struct wi_softc)
};
DRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
MODULE_DEPEND(wi, wlan, 1, 1, 1);
static const struct pccard_product wi_pccard_products[] = {
PCMCIA_CARD(3COM, 3CRWE737A),
PCMCIA_CARD(3COM, 3CRWE777A),
PCMCIA_CARD(ACTIONTEC, PRISM),
PCMCIA_CARD(ADAPTEC2, ANW8030),
PCMCIA_CARD(ADDTRON, AWP100),
PCMCIA_CARD(AIRVAST, WN_100B),
PCMCIA_CARD(AIRVAST, WN_100),
PCMCIA_CARD(ALLIEDTELESIS, WR211PCM),
PCMCIA_CARD(ARTEM, ONAIR),
PCMCIA_CARD(ASUS, WL100),
PCMCIA_CARD(BAY, EMOBILITY_11B),
PCMCIA_CARD(BROMAX, IWN),
PCMCIA_CARD(BROMAX, IWN3),
PCMCIA_CARD(BROMAX, WCF11),
PCMCIA_CARD(BUFFALO, WLI_CF_S11G),
PCMCIA_CARD(BUFFALO, WLI_PCM_S11),
PCMCIA_CARD(COMPAQ, NC5004),
PCMCIA_CARD(CONTEC, FX_DS110_PCC),
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11),
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11),
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11),
PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCL_11),
PCMCIA_CARD(DLINK, DWL650H),
PCMCIA_CARD(ELSA, XI300_IEEE),
PCMCIA_CARD(ELSA, XI325_IEEE),
PCMCIA_CARD(ELSA, APDL325_IEEE),
PCMCIA_CARD(ELSA, XI330_IEEE),
PCMCIA_CARD(ELSA, XI800_IEEE),
PCMCIA_CARD(ELSA, WIFI_FLASH),
PCMCIA_CARD(EMTAC, WLAN),
PCMCIA_CARD(ERICSSON, WIRELESSLAN),
PCMCIA_CARD(GEMTEK, WLAN),
PCMCIA_CARD(HWN, AIRWAY80211),
PCMCIA_CARD(INTEL, PRO_WLAN_2011),
PCMCIA_CARD(INTERSIL, ISL37100P),
PCMCIA_CARD(INTERSIL, ISL37110P),
PCMCIA_CARD(INTERSIL, ISL37300P),
PCMCIA_CARD(INTERSIL2, PRISM2),
PCMCIA_CARD(IODATA2, WCF12),
PCMCIA_CARD(IODATA2, WNB11PCM),
PCMCIA_CARD(FUJITSU, WL110),
PCMCIA_CARD(LUCENT, WAVELAN_IEEE),
PCMCIA_CARD(MICROSOFT, MN_520),
PCMCIA_CARD(NOKIA, C020_WLAN),
PCMCIA_CARD(NOKIA, C110_WLAN),
PCMCIA_CARD(PLANEX, GWNS11H),
PCMCIA_CARD(PROXIM, HARMONY),
PCMCIA_CARD(PROXIM, RANGELANDS_8430),
PCMCIA_CARD(SAMSUNG, SWL_2000N),
PCMCIA_CARD(SIEMENS, SS1021),
PCMCIA_CARD(SIEMENS, SS1021A),
PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT),
PCMCIA_CARD(SOCKET, LP_WLAN_CF),
PCMCIA_CARD(TDK, LAK_CD011WL),
{ NULL }
};
static int
wi_pccard_probe(device_t dev)
{
const struct pccard_product *pp;
u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
int error;
/* Make sure we're a network driver */
error = pccard_get_function(dev, &fcn);
if (error != 0)
return error;
if (fcn != PCCARD_FUNCTION_NETWORK)
return ENXIO;
pp = pccard_product_lookup(dev, wi_pccard_products,
sizeof(wi_pccard_products[0]), NULL);
if (pp != NULL) {
if (pp->pp_name != NULL)
device_set_desc(dev, pp->pp_name);
return 0;
}
return ENXIO;
}
static int
wi_pccard_attach(device_t dev)
{
struct wi_softc *sc;
int error;
sc = device_get_softc(dev);
sc->wi_gone = 0;
sc->wi_bus_type = WI_BUS_PCCARD;
error = wi_alloc(dev, 0);
if (error == 0) {
/* Make sure interrupts are disabled. */
CSR_WRITE_2(sc, WI_INT_EN, 0);
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
error = wi_attach(dev);
if (error != 0)
wi_free(dev);
}
return error;
}

View File

@ -0,0 +1,271 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
*
* Written by Bill Paul <wpaul@ctr.columbia.edu>
* Electrical Engineering Department
* Columbia University, New York City
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
#include <dev/wi/if_wavelan_ieee.h>
#include <dev/wi/if_wireg.h>
#include <dev/wi/if_wivar.h>
static int wi_pci_probe(device_t);
static int wi_pci_attach(device_t);
static int wi_pci_suspend(device_t);
static int wi_pci_resume(device_t);
static device_method_t wi_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, wi_pci_probe),
DEVMETHOD(device_attach, wi_pci_attach),
DEVMETHOD(device_detach, wi_detach),
DEVMETHOD(device_shutdown, wi_shutdown),
DEVMETHOD(device_suspend, wi_pci_suspend),
DEVMETHOD(device_resume, wi_pci_resume),
{ 0, 0 }
};
static driver_t wi_pci_driver = {
"wi",
wi_pci_methods,
sizeof(struct wi_softc)
};
static struct {
unsigned int vendor,device;
int bus_type;
char *desc;
} pci_ids[] = {
/* Sorted by description */
{0x10b7, 0x7770, WI_BUS_PCI_PLX, "3Com Airconnect"},
{0x16ab, 0x1101, WI_BUS_PCI_PLX, "GLPRISM2 WaveLAN"},
{0x1260, 0x3872, WI_BUS_PCI_NATIVE, "Intersil Prism3"},
{0x1260, 0x3873, WI_BUS_PCI_NATIVE, "Intersil Prism2.5"},
{0x16ab, 0x1102, WI_BUS_PCI_PLX, "Linksys WDT11"},
{0x1385, 0x4100, WI_BUS_PCI_PLX, "Netgear MA301"},
{0x1638, 0x1100, WI_BUS_PCI_PLX, "PRISM2STA WaveLAN"},
{0x111a, 0x1023, WI_BUS_PCI_PLX, "Siemens SpeedStream"},
{0x10b5, 0x9050, WI_BUS_PCI_PLX, "SMC 2602W"},
{0x16ec, 0x3685, WI_BUS_PCI_PLX, "US Robotics 2415"},
{0x4033, 0x7001, WI_BUS_PCI_PLX, "Addtron AWA-100 PCI"},
{0, 0, 0, NULL}
};
DRIVER_MODULE(wi, pci, wi_pci_driver, wi_devclass, 0, 0);
MODULE_DEPEND(wi, pci, 1, 1, 1);
MODULE_DEPEND(wi, wlan, 1, 1, 1);
static int
wi_pci_probe(dev)
device_t dev;
{
struct wi_softc *sc;
int i;
sc = device_get_softc(dev);
for(i=0; pci_ids[i].vendor != 0; i++) {
if ((pci_get_vendor(dev) == pci_ids[i].vendor) &&
(pci_get_device(dev) == pci_ids[i].device)) {
sc->wi_bus_type = pci_ids[i].bus_type;
device_set_desc(dev, pci_ids[i].desc);
return (BUS_PROBE_DEFAULT);
}
}
return(ENXIO);
}
static int
wi_pci_attach(device_t dev)
{
struct wi_softc *sc;
u_int32_t command, wanted;
u_int16_t reg;
int error;
int timeout;
sc = device_get_softc(dev);
command = pci_read_config(dev, PCIR_COMMAND, 4);
wanted = PCIM_CMD_PORTEN|PCIM_CMD_MEMEN;
command |= wanted;
pci_write_config(dev, PCIR_COMMAND, command, 4);
command = pci_read_config(dev, PCIR_COMMAND, 4);
if ((command & wanted) != wanted) {
device_printf(dev, "wi_pci_attach() failed to enable pci!\n");
return (ENXIO);
}
if (sc->wi_bus_type != WI_BUS_PCI_NATIVE) {
error = wi_alloc(dev, WI_PCI_IORES);
if (error)
return (error);
/* Make sure interrupts are disabled. */
CSR_WRITE_2(sc, WI_INT_EN, 0);
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
/* We have to do a magic PLX poke to enable interrupts */
sc->local_rid = WI_PCI_LOCALRES;
sc->local = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
&sc->local_rid, RF_ACTIVE);
sc->wi_localtag = rman_get_bustag(sc->local);
sc->wi_localhandle = rman_get_bushandle(sc->local);
command = bus_space_read_4(sc->wi_localtag, sc->wi_localhandle,
WI_LOCAL_INTCSR);
command |= WI_LOCAL_INTEN;
bus_space_write_4(sc->wi_localtag, sc->wi_localhandle,
WI_LOCAL_INTCSR, command);
bus_release_resource(dev, SYS_RES_IOPORT, sc->local_rid,
sc->local);
sc->local = NULL;
sc->mem_rid = WI_PCI_MEMRES;
sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->mem_rid, RF_ACTIVE);
if (sc->mem == NULL) {
device_printf(dev, "couldn't allocate memory\n");
wi_free(dev);
return (ENXIO);
}
sc->wi_bmemtag = rman_get_bustag(sc->mem);
sc->wi_bmemhandle = rman_get_bushandle(sc->mem);
/*
* Write COR to enable PC card
* This is a subset of the protocol that the pccard bus code
* would do. In theory, we should parse the CIS to find the
* COR offset. In practice, the COR_OFFSET is always 0x3e0.
*/
CSM_WRITE_1(sc, WI_COR_OFFSET, WI_COR_VALUE);
reg = CSM_READ_1(sc, WI_COR_OFFSET);
if (reg != WI_COR_VALUE) {
device_printf(dev, "CSM_READ_1(WI_COR_OFFSET) "
"wanted %d, got %d\n", WI_COR_VALUE, reg);
wi_free(dev);
return (ENXIO);
}
} else {
error = wi_alloc(dev, WI_PCI_LMEMRES);
if (error)
return (error);
CSR_WRITE_2(sc, WI_PCICOR_OFF, WI_PCICOR_RESET);
DELAY(250000);
CSR_WRITE_2(sc, WI_PCICOR_OFF, 0x0000);
DELAY(500000);
timeout=2000000;
while ((--timeout > 0) &&
(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY))
DELAY(10);
if (timeout == 0) {
device_printf(dev, "couldn't reset prism pci core.\n");
wi_free(dev);
return(ENXIO);
}
}
CSR_WRITE_2(sc, WI_HFA384X_SWSUPPORT0_OFF, WI_PRISM2STA_MAGIC);
reg = CSR_READ_2(sc, WI_HFA384X_SWSUPPORT0_OFF);
if (reg != WI_PRISM2STA_MAGIC) {
device_printf(dev,
"CSR_READ_2(WI_HFA384X_SWSUPPORT0_OFF) "
"wanted %d, got %d\n", WI_PRISM2STA_MAGIC, reg);
wi_free(dev);
return (ENXIO);
}
error = wi_attach(dev);
if (error != 0)
wi_free(dev);
return (error);
}
static int
wi_pci_suspend(device_t dev)
{
struct wi_softc *sc = device_get_softc(dev);
wi_stop(sc, 1);
return (0);
}
static int
wi_pci_resume(device_t dev)
{
struct wi_softc *sc = device_get_softc(dev);
struct ifnet *ifp = sc->sc_ifp;
if (sc->wi_bus_type != WI_BUS_PCI_NATIVE)
return (0);
if (ifp->if_flags & IFF_UP) {
ifp->if_init(ifp->if_softc);
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
ifp->if_start(ifp);
}
return (0);
}

View File

@ -0,0 +1,724 @@
/*-
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#define WI_DELAY 5
#define WI_TIMEOUT (500000/WI_DELAY) /* 500 ms */
#define WI_PORT0 (0 << 8)
#define WI_PORT1 (1 << 8)
#define WI_PORT2 (2 << 8)
#define WI_PORT3 (3 << 8)
#define WI_PORT4 (4 << 8)
#define WI_PORT5 (5 << 8)
#define WI_PCI_LMEMRES 0x10 /* PCI Memory (native PCI implementations) */
#define WI_PCI_LOCALRES 0x14 /* The PLX chip's local registers */
#define WI_PCI_MEMRES 0x18 /* The PCCard's attribute memory */
#define WI_PCI_IORES 0x1C /* The PCCard's I/O space */
#define WI_LOCAL_INTCSR 0x4c
#define WI_LOCAL_INTEN 0x40
#define WI_HFA384X_SWSUPPORT0_OFF 0x28
#define WI_PRISM2STA_MAGIC 0x4A2D
#define WI_PCICOR_OFF 0x26
#define WI_PCICOR_RESET 0x0080
/* Default port: 0 (only 0 exists on stations) */
#define WI_DEFAULT_PORT WI_PORT0
/* Default network name: ANY */
/*
* [sommerfeld 1999/07/15] Changed from "ANY" to ""; according to Bill Fenner,
* ANY is used in MS driver user interfaces, while "" is used over the
* wire..
*/
#define WI_DEFAULT_NETNAME ""
#define WI_DEFAULT_AP_DENSITY 1
#define WI_DEFAULT_RTS_THRESH 2347
#define WI_DEFAULT_DATALEN 2304
#define WI_DEFAULT_CREATE_IBSS 0
#define WI_DEFAULT_PM_ENABLED 0
#define WI_DEFAULT_MAX_SLEEP 100
#define WI_DEFAULT_ROAMING 1
#define WI_DEFAULT_AUTHTYPE 1
#ifdef __NetBSD__
#define OS_STRING_NAME "NetBSD"
#endif
#ifdef __FreeBSD__
#define OS_STRING_NAME "FreeBSD"
#endif
#ifdef __OpenBSD__
#define OS_STRING_NAME "OpenBSD"
#endif
#define WI_DEFAULT_NODENAME OS_STRING_NAME " WaveLAN/IEEE node"
#define WI_DEFAULT_IBSS OS_STRING_NAME " IBSS"
#define WI_BUS_PCCARD 0 /* pccard device */
#define WI_BUS_PCI_PLX 1 /* PCI card w/ PLX PCI/PCMICA bridge */
#define WI_BUS_PCI_NATIVE 2 /* native PCI device (Prism 2.5) */
/*
* register space access macros
*/
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg), val)
#define CSR_WRITE_2(sc, reg, val) \
bus_space_write_2((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg), val)
#define CSR_WRITE_1(sc, reg, val) \
bus_space_write_1((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg), val)
#define CSR_READ_4(sc, reg) \
bus_space_read_4((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg))
#define CSR_READ_2(sc, reg) \
bus_space_read_2((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg))
#define CSR_READ_1(sc, reg) \
bus_space_read_1((sc)->wi_btag, (sc)->wi_bhandle, \
(sc)->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg)*2 : (reg))
#define CSM_WRITE_1(sc, off, val) \
bus_space_write_1((sc)->wi_bmemtag, (sc)->wi_bmemhandle, off, val)
#define CSM_READ_1(sc, off) \
bus_space_read_1((sc)->wi_bmemtag, (sc)->wi_bmemhandle, off)
#define CSR_WRITE_STREAM_2(sc, reg, val) \
bus_space_write_stream_2(sc->wi_btag, sc->wi_bhandle, \
(sc->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg) * 2 : (reg)), val)
#define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count) \
bus_space_write_multi_stream_2(sc->wi_btag, sc->wi_bhandle, \
(sc->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg) * 2 : (reg)), val, count)
#define CSR_READ_STREAM_2(sc, reg) \
bus_space_read_stream_2(sc->wi_btag, sc->wi_bhandle, \
(sc->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg) * 2 : (reg)))
#define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count) \
bus_space_read_multi_stream_2(sc->wi_btag, sc->wi_bhandle, \
(sc->wi_bus_type == WI_BUS_PCI_NATIVE ? (reg) * 2 : (reg)), buf, count)
/*
* The WaveLAN/IEEE cards contain an 802.11 MAC controller which Lucent
* calls 'Hermes.' In typical fashion, getting documentation about this
* controller is about as easy as squeezing blood from a stone. Here
* is more or less what I know:
*
* - The Hermes controller is firmware driven, and the host interacts
* with the Hermes via a firmware interface, which can change.
*
* - The Hermes is described in a document called: "Hermes Firmware
* WaveLAN/IEEE Station Functions," document #010245, which of course
* Lucent will not release without an NDA.
*
* - Lucent has created a library called HCF (Hardware Control Functions)
* though which it wants developers to interact with the card. The HCF
* is needlessly complex, ill conceived and badly documented. Actually,
* the comments in the HCP code itself aren't bad, but the publically
* available manual that comes with it is awful, probably due largely to
* the fact that it has been emasculated in order to hide information
* that Lucent wants to keep proprietary. The purpose of the HCF seems
* to be to insulate the driver programmer from the Hermes itself so that
* Lucent has an excuse not to release programming in for it.
*
* - Lucent only makes available documentation and code for 'HCF Light'
* which is a stripped down version of HCF with certain features not
* implemented, most notably support for 802.11 frames.
*
* - The HCF code which I have seen blows goats. Whoever decided to
* use a 132 column format should be shot.
*
* Rather than actually use the Lucent HCF library, I have stripped all
* the useful information from it and used it to create a driver in the
* usual BSD form. Note: I don't want to hear anybody whining about the
* fact that the Lucent code is GPLed and mine isn't. I did not actually
* put any of Lucent's code in this driver: I only used it as a reference
* to obtain information about the underlying hardware. The Hermes
* programming interface is not GPLed, so bite me.
*/
/*
* Size of Hermes & Prism2 I/O space.
*/
#define WI_IOSIZ 0x40
/*
* Hermes & Prism2 register definitions
*/
/* Hermes command/status registers. */
#define WI_COMMAND 0x00
#define WI_PARAM0 0x02
#define WI_PARAM1 0x04
#define WI_PARAM2 0x06
#define WI_STATUS 0x08
#define WI_RESP0 0x0A
#define WI_RESP1 0x0C
#define WI_RESP2 0x0E
/* Command register values. */
#define WI_CMD_BUSY 0x8000 /* busy bit */
#define WI_CMD_INI 0x0000 /* initialize */
#define WI_CMD_ENABLE 0x0001 /* enable */
#define WI_CMD_DISABLE 0x0002 /* disable */
#define WI_CMD_DIAG 0x0003
#define WI_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */
#define WI_CMD_TX 0x000B /* transmit */
#define WI_CMD_NOTIFY 0x0010
#define WI_CMD_INQUIRE 0x0011
#define WI_CMD_ACCESS 0x0021
#define WI_CMD_ACCESS_WRITE 0x0121
#define WI_CMD_PROGRAM 0x0022
#define WI_CMD_READEE 0x0030 /* symbol only */
#define WI_CMD_READMIF 0x0030 /* prism2 */
#define WI_CMD_WRITEMIF 0x0031 /* prism2 */
#define WI_CMD_DEBUG 0x0038 /* Various test commands */
#define WI_CMD_CODE_MASK 0x003F
/*
* Various cmd test stuff.
*/
#define WI_TEST_MONITOR 0x0B
#define WI_TEST_STOP 0x0F
#define WI_TEST_CFG_BITS 0x15
#define WI_TEST_CFG_BIT_ALC 0x08
/*
* Reclaim qualifier bit, applicable to the
* TX and INQUIRE commands.
*/
#define WI_RECLAIM 0x0100 /* reclaim NIC memory */
/*
* ACCESS command qualifier bits.
*/
#define WI_ACCESS_READ 0x0000
#define WI_ACCESS_WRITE 0x0100
/*
* PROGRAM command qualifier bits.
*/
#define WI_PROGRAM_DISABLE 0x0000
#define WI_PROGRAM_ENABLE_RAM 0x0100
#define WI_PROGRAM_ENABLE_NVRAM 0x0200
#define WI_PROGRAM_NVRAM 0x0300
/* Status register values */
#define WI_STAT_CMD_CODE 0x003F
#define WI_STAT_DIAG_ERR 0x0100
#define WI_STAT_INQ_ERR 0x0500
#define WI_STAT_CMD_RESULT 0x7F00
/* memory handle management registers */
#define WI_INFO_FID 0x10
#define WI_RX_FID 0x20
#define WI_ALLOC_FID 0x22
#define WI_TX_CMP_FID 0x24
/*
* Buffer Access Path (BAP) registers.
* These are I/O channels. I believe you can use each one for
* any desired purpose independently of the other. In general
* though, we use BAP1 for reading and writing LTV records and
* reading received data frames, and BAP0 for writing transmit
* frames. This is a convention though, not a rule.
*/
#define WI_SEL0 0x18
#define WI_SEL1 0x1A
#define WI_OFF0 0x1C
#define WI_OFF1 0x1E
#define WI_DATA0 0x36
#define WI_DATA1 0x38
#define WI_BAP0 WI_DATA0
#define WI_BAP1 WI_DATA1
#define WI_OFF_BUSY 0x8000
#define WI_OFF_ERR 0x4000
#define WI_OFF_DATAOFF 0x0FFF
/* Event registers */
#define WI_EVENT_STAT 0x30 /* Event status */
#define WI_INT_EN 0x32 /* Interrupt enable/disable */
#define WI_EVENT_ACK 0x34 /* Ack event */
/* Events */
#define WI_EV_TICK 0x8000 /* aux timer tick */
#define WI_EV_RES 0x4000 /* controller h/w error (time out) */
#define WI_EV_INFO_DROP 0x2000 /* no RAM to build unsolicited frame */
#define WI_EV_NO_CARD 0x0800 /* card removed (hunh?) */
#define WI_EV_DUIF_RX 0x0400 /* wavelan management packet received */
#define WI_EV_INFO 0x0080 /* async info frame */
#define WI_EV_CMD 0x0010 /* command completed */
#define WI_EV_ALLOC 0x0008 /* async alloc/reclaim completed */
#define WI_EV_TX_EXC 0x0004 /* async xmit completed with failure */
#define WI_EV_TX 0x0002 /* async xmit completed succesfully */
#define WI_EV_RX 0x0001 /* async rx completed */
/* Host software registers */
#define WI_SW0 0x28
#define WI_SW1 0x2A
#define WI_SW2 0x2C
#define WI_SW3 0x2E /* does not appear in Prism2 */
#define WI_CNTL 0x14
#define WI_CNTL_AUX_ENA 0xC000
#define WI_CNTL_AUX_ENA_STAT 0xC000
#define WI_CNTL_AUX_DIS_STAT 0x0000
#define WI_CNTL_AUX_ENA_CNTL 0x8000
#define WI_CNTL_AUX_DIS_CNTL 0x4000
#define WI_AUX_PAGE 0x3A
#define WI_AUX_OFFSET 0x3C
#define WI_AUX_DATA 0x3E
#define WI_AUX_PGSZ 128
#define WI_AUX_KEY0 0xfe01
#define WI_AUX_KEY1 0xdc23
#define WI_AUX_KEY2 0xba45
#define WI_COR 0x40 /* only for Symbol */
#define WI_COR_RESET 0x0080
#define WI_COR_IOMODE 0x0041
#define WI_HCR 0x42 /* only for Symbol */
#define WI_HCR_4WIRE 0x0010
#define WI_HCR_RUN 0x0007
#define WI_HCR_HOLD 0x000f
#define WI_HCR_EEHOLD 0x00ce
#define WI_COR_OFFSET 0x3e0 /* OK for PCI, default COR for Prism PC Card */
#define WI_COR_VALUE 0x41
/*
* One form of communication with the Hermes is with what Lucent calls
* LTV records, where LTV stands for Length, Type and Value. The length
* and type are 16 bits and are in native byte order. The value is in
* multiples of 16 bits and is in little endian byte order.
*/
struct wi_lt_hdr {
u_int16_t wi_len;
u_int16_t wi_type;
/* value is vary depends on resource id */
};
/*
* Download buffer location and length (0xFD01).
*/
struct wi_dnld_buf {
u_int16_t wi_buf_pg; /* page addr of intermediate dl buf*/
u_int16_t wi_buf_off; /* offset of idb */
u_int16_t wi_buf_len; /* len of idb */
};
/*
* Mem sizes (0xFD02).
*/
struct wi_memsz {
u_int16_t wi_mem_ram;
u_int16_t wi_mem_nvram;
};
/*
* NIC Identification (0xFD0B, 0xFD20)
*/
struct wi_ver {
u_int16_t wi_ver[4];
};
/* define card ident */
#define WI_NIC_LUCENT_ID 0x0001
#define WI_NIC_LUCENT_STR "Lucent Technologies, WaveLAN/IEEE"
#define WI_NIC_SONY_ID 0x0002
#define WI_NIC_SONY_STR "Sony WaveLAN/IEEE"
#define WI_NIC_LUCENT_EMB_ID 0x0005
#define WI_NIC_LUCENT_EMB_STR "Lucent Embedded WaveLAN/IEEE"
#define WI_NIC_EVB2_ID 0x8000
#define WI_NIC_EVB2_STR "RF:PRISM2 MAC:HFA3841"
#define WI_NIC_HWB3763_ID 0x8001
#define WI_NIC_HWB3763_STR "RF:PRISM2 MAC:HFA3841 CARD:HWB3763 rev.B"
#define WI_NIC_HWB3163_ID 0x8002
#define WI_NIC_HWB3163_STR "RF:PRISM2 MAC:HFA3841 CARD:HWB3163 rev.A"
#define WI_NIC_HWB3163B_ID 0x8003
#define WI_NIC_HWB3163B_STR "RF:PRISM2 MAC:HFA3841 CARD:HWB3163 rev.B"
#define WI_NIC_EVB3_ID 0x8004
#define WI_NIC_EVB3_STR "RF:PRISM2 MAC:HFA3842 CARD:HFA3842 EVAL"
#define WI_NIC_HWB1153_ID 0x8007
#define WI_NIC_HWB1153_STR "RF:PRISM1 MAC:HFA3841 CARD:HWB1153"
#define WI_NIC_P2_SST_ID 0x8008 /* Prism2 with SST flush */
#define WI_NIC_P2_SST_STR "RF:PRISM2 MAC:HFA3841 CARD:HWB3163-SST-flash"
#define WI_NIC_EVB2_SST_ID 0x8009
#define WI_NIC_EVB2_SST_STR "RF:PRISM2 MAC:HFA3841 CARD:HWB3163-SST-flash"
#define WI_NIC_3842_EVA_ID 0x800A /* 3842 Evaluation Board */
#define WI_NIC_3842_EVA_STR "RF:PRISM2 MAC:HFA3842 CARD:HFA3842 EVAL"
#define WI_NIC_3842_PCMCIA_AMD_ID 0x800B /* Prism2.5 PCMCIA */
#define WI_NIC_3842_PCMCIA_SST_ID 0x800C
#define WI_NIC_3842_PCMCIA_ATL_ID 0x800D
#define WI_NIC_3842_PCMCIA_ATS_ID 0x800E
#define WI_NIC_3842_PCMCIA_STR "RF:PRISM2.5 MAC:ISL3873"
#define WI_NIC_3842_MINI_AMD_ID 0x8012 /* Prism2.5 Mini-PCI */
#define WI_NIC_3842_MINI_SST_ID 0x8013
#define WI_NIC_3842_MINI_ATL_ID 0x8014
#define WI_NIC_3842_MINI_ATS_ID 0x8015
#define WI_NIC_3842_MINI_STR "RF:PRISM2.5 MAC:ISL3874A(Mini-PCI)"
#define WI_NIC_3842_PCI_AMD_ID 0x8016 /* Prism2.5 PCI-bridge */
#define WI_NIC_3842_PCI_SST_ID 0x8017
#define WI_NIC_3842_PCI_ATL_ID 0x8018
#define WI_NIC_3842_PCI_ATS_ID 0x8019
#define WI_NIC_3842_PCI_STR "RF:PRISM2.5 MAC:ISL3874A(PCI-bridge)"
#define WI_NIC_P3_PCMCIA_AMD_ID 0x801A /* Prism3 PCMCIA */
#define WI_NIC_P3_PCMCIA_SST_ID 0x801B
#define WI_NIC_P3_PCMCIA_ATL_ID 0x801C
#define WI_NIC_P3_PCMCIA_ATS_ID 0x801D
#define WI_NIC_P3_PCMCIA_STR "RF:PRISM3(PCMCIA)"
#define WI_NIC_P3_USB_AMD_ID 0x801E
#define WI_NIC_P3_USB_SST_ID 0x801F
#define WI_NIC_P3_USB_ATL_ID 0x8020
#define WI_NIC_P3_MINI_AMD_ID 0x8021 /* Prism3 Mini-PCI */
#define WI_NIC_P3_MINI_SST_ID 0x8022
#define WI_NIC_P3_MINI_ATL_ID 0x8023
#define WI_NIC_P3_MINI_ATS_ID 0x8024
#define WI_NIC_P3_MINI_STR "RF:PRISM3(Mini-PCI)"
/*
* List of intended regulatory domains (0xFD11).
*/
struct wi_ltv_domains {
u_int16_t wi_len;
u_int16_t wi_type;
u_int16_t wi_num_dom;
u_int8_t wi_domains[10];
};
/*
* CIS struct (0xFD13).
*/
struct wi_cis {
u_int16_t wi_cis[240];
};
/*
* Communications quality (0xFD43).
*/
struct wi_commqual {
u_int16_t wi_coms_qual;
u_int16_t wi_sig_lvl;
u_int16_t wi_noise_lvl;
};
/*
* Actual system scale thresholds (0xFC06, 0xFD46).
*/
struct wi_scalethresh {
u_int16_t wi_energy_detect;
u_int16_t wi_carrier_detect;
u_int16_t wi_defer;
u_int16_t wi_cell_search;
u_int16_t wi_out_of_range;
u_int16_t wi_delta_snr;
};
/*
* PCF info struct (0xFD87).
*/
struct wi_pcf {
u_int16_t wi_medium_occupancy_limit;
u_int16_t wi_cfp_period;
u_int16_t wi_cfp_max_duration;
};
/*
* Connection control characteristics. (0xFC00)
* 0 == IBSS (802.11 compliant mode) (Only PRISM2)
* 1 == Basic Service Set (BSS)
* 2 == Wireless Distribudion System (WDS)
* 3 == Pseudo IBSS
* (Only PRISM2; not 802.11 compliant mode, testing use only)
* 6 == HOST AP (Only PRISM2)
*/
#define WI_PORTTYPE_IBSS 0x0
#define WI_PORTTYPE_BSS 0x1
#define WI_PORTTYPE_WDS 0x2
#define WI_PORTTYPE_ADHOC 0x3
#define WI_PORTTYPE_APSILENT 0x5
#define WI_PORTTYPE_HOSTAP 0x6
/*
* Mac addresses. (0xFC01, 0xFC08)
*/
struct wi_macaddr {
u_int8_t wi_mac_addr[6];
};
/*
* Station set identification (SSID). (0xFC02, 0xFC04)
*/
struct wi_ssid {
u_int16_t wi_len;
u_int8_t wi_ssid[32];
};
/*
* Set our station name. (0xFC0E)
*/
struct wi_nodename {
u_int16_t wi_nodelen;
u_int8_t wi_nodename[32];
};
/*
* Multicast addresses to be put in filter. We're
* allowed up to 16 addresses in the filter. (0xFC80)
*/
struct wi_mcast {
struct ether_addr wi_mcast[16];
};
/*
* Join request. (0xFCE2)
*/
struct wi_joinreq {
struct ether_addr wi_bssid;
u_int16_t wi_chan;
};
/*
* supported rates. (0xFCB4)
*/
#define WI_SUPPRATES_1M 0x0001
#define WI_SUPPRATES_2M 0x0002
#define WI_SUPPRATES_5M 0x0004
#define WI_SUPPRATES_11M 0x0008
#define WI_RATES_BITS "\20\0011M\0022M\0035.5M\00411M"
/*
* Information frame types.
*/
#define WI_INFO_NOTIFY 0xF000 /* Handover address */
#define WI_INFO_COUNTERS 0xF100 /* Statistics counters */
#define WI_INFO_SCAN_RESULTS 0xF101 /* Scan results */
#define WI_INFO_HOST_SCAN_RESULTS 0xF104 /* Scan results */
#define WI_INFO_LINK_STAT 0xF200 /* Link status */
#define WI_INFO_LINK_STAT_CONNECTED 1
#define WI_INFO_LINK_STAT_DISCONNECTED 2
#define WI_INFO_LINK_STAT_AP_CHG 3 /* AP Change */
#define WI_INFO_LINK_STAT_AP_OOR 4 /* AP Out Of Range */
#define WI_INFO_LINK_STAT_AP_INR 5 /* AP In Range */
#define WI_INFO_LINK_STAT_ASSOC_FAILED 6
#define WI_INFO_ASSOC_STAT 0xF201 /* Association status */
#define WI_INFO_AUTH_REQUEST 0xF202 /* Authentication Request (AP) */
#define WI_INFO_POWERSAVE_COUNT 0xF203 /* PowerSave User Count (AP) */
struct wi_assoc {
u_int16_t wi_assoc_stat; /* Association Status */
#define ASSOC 1
#define REASSOC 2
#define DISASSOC 3
#define ASSOCFAIL 4
#define AUTHFAIL 5
u_int8_t wi_assoc_sta[6]; /* Station Address */
u_int8_t wi_assoc_osta[6]; /* OLD Station Address */
u_int16_t wi_assoc_reason; /* Reason */
u_int16_t wi_assoc_reserve; /* Reserved */
};
/*
* Scan Results of Prism2 chip
*/
struct wi_scan_header {
u_int16_t wi_reserve; /* future use */
u_int16_t wi_reason; /* The reason this scan was initiated
1: Host initiated
2: Firmware initiated
3: Inquiry request from host */
};
struct wi_scan_data_p2 {
u_int16_t wi_chid; /* BSS Channel ID from Probe Res.(PR)*/
u_int16_t wi_noise; /* Average Noise Level of the PR */
u_int16_t wi_signal; /* Signal Level on the PR */
u_int8_t wi_bssid[6]; /* MACaddress of BSS responder from PR */
u_int16_t wi_interval; /* BSS beacon interval */
u_int16_t wi_capinfo; /* BSS Capability Information
IEEE Std 802.11(1997) ,see 7.3.1.4 */
u_int16_t wi_namelen; /* Length of SSID strings */
u_int8_t wi_name[32]; /* SSID strings */
u_int16_t wi_suprate[5]; /* Supported Rates element from the PR
IEEE Std 802.11(1997) ,see 7.3.2.2 */
u_int16_t wi_rate; /* Data rate of the PR */
#define WI_APRATE_1 0x0A /* 1 Mbps */
#define WI_APRATE_2 0x14 /* 2 Mbps */
#define WI_APRATE_5 0x37 /* 5.5 Mbps */
#define WI_APRATE_11 0x6E /* 11 Mbps */
};
/*
* Scan Results of Lucent chip
*/
struct wi_scan_data {
u_int16_t wi_chid; /* BSS Channel ID from PR */
u_int16_t wi_noise; /* Average Noise Level of the PR */
u_int16_t wi_signal; /* Signal Level on the PR */
u_int8_t wi_bssid[6]; /* MACaddress of BSS responder from PR */
u_int16_t wi_interval; /* BSS beacon interval */
u_int16_t wi_capinfo; /* BSS Capability Information
IEEE Std 802.11(1997) ,see 7.3.1.4 */
u_int16_t wi_namelen; /* Length of SSID strings */
u_int8_t wi_name[32]; /* SSID strings */
};
/*
* transmit/receive frame structure
*/
struct wi_frame {
u_int16_t wi_status; /* 0x00 */
u_int16_t wi_rx_tstamp1; /* 0x02 */
u_int16_t wi_rx_tstamp0; /* 0x04 */
u_int8_t wi_rx_silence; /* 0x06 */
u_int8_t wi_rx_signal; /* 0x07 */
u_int8_t wi_rx_rate; /* 0x08 */
u_int8_t wi_rx_flow; /* 0x09 */
u_int8_t wi_tx_rtry; /* 0x0a */ /* Prism2 AP Only */
u_int8_t wi_tx_rate; /* 0x0b */ /* Prism2 AP Only */
u_int16_t wi_tx_ctl; /* 0x0c */
struct ieee80211_frame_addr4 wi_whdr; /* 0x0e */
u_int16_t wi_dat_len; /* 0x2c */
struct ether_header wi_ehdr; /* 0x2e */
} __attribute__((__packed__));
/* Tx Status Field */
#define WI_TXSTAT_RET_ERR 0x0001
#define WI_TXSTAT_AGED_ERR 0x0002
#define WI_TXSTAT_DISCONNECT 0x0004
#define WI_TXSTAT_FORM_ERR 0x0008
/* Rx Status Field */
#define WI_STAT_BADCRC 0x0001
#define WI_STAT_UNDECRYPTABLE 0x0002
#define WI_STAT_ERRSTAT 0x0003
#define WI_STAT_MAC_PORT 0x0700
#define WI_STAT_PCF 0x1000
#define WI_RXSTAT_MSG_TYPE 0xE000
#define WI_STAT_1042 0x2000 /* RFC1042 encoded */
#define WI_STAT_TUNNEL 0x4000 /* Bridge-tunnel encoded */
#define WI_STAT_WMP_MSG 0x6000 /* WaveLAN-II management protocol */
#define WI_STAT_MGMT 0x8000 /* 802.11b management frames */
#define WI_ENC_TX_E_II 0x0E
#define WI_ENC_TX_1042 0x00
#define WI_ENC_TX_TUNNEL 0xF8
/* TxControl Field (enhanced) */
#define WI_TXCNTL_TX_OK 0x0002
#define WI_TXCNTL_TX_EX 0x0004
#define WI_TXCNTL_STRUCT_TYPE 0x0018
#define WI_ENC_TX_802_3 0x00
#define WI_ENC_TX_802_11 0x08
#define WI_TXCNTL_ALTRTRY 0x0020
#define WI_TXCNTL_NOCRYPT 0x0080
/*
* HFA3861/3863 (BBP) Control Registers
*/
#define WI_HFA386X_CR_A_D_TEST_MODES2 0x1A
#define WI_HFA386X_CR_MANUAL_TX_POWER 0x3E
#ifdef IEEE80211_RADIOTAP_F_CFP
/*
* Radio capture format for Prism.
*/
#define WI_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
(1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
struct wi_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
u_int64_t wr_tsf;
u_int8_t wr_flags;
u_int8_t wr_rate;
u_int16_t wr_chan_freq;
u_int16_t wr_chan_flags;
u_int8_t wr_antsignal;
u_int8_t wr_antnoise;
};
#define WI_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct wi_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
u_int8_t wt_flags;
u_int8_t wt_rate;
u_int16_t wt_chan_freq;
u_int16_t wt_chan_flags;
};
#endif /* IEEE80211_RADIOTAP_F_CFP */

View File

@ -0,0 +1,186 @@
/*-
* Copyright (c) 2002
* M Warner Losh <imp@freebsd.org>. All rights reserved.
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Encryption controls. We can enable or disable encryption as
* well as specify up to 4 encryption keys. We can also specify
* which of the four keys will be used for transmit encryption.
*/
#define WI_RID_ENCRYPTION 0xFC20
#define WI_RID_AUTHTYPE 0xFC21
#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
#define WI_RID_TX_CRYPT_KEY 0xFCB1
#define WI_RID_WEP_AVAIL 0xFD4F
#define WI_RID_P2_TX_CRYPT_KEY 0xFC23
#define WI_RID_P2_CRYPT_KEY0 0xFC24
#define WI_RID_P2_CRYPT_KEY1 0xFC25
#define WI_RID_MICROWAVE_OVEN 0xFC25
#define WI_RID_P2_CRYPT_KEY2 0xFC26
#define WI_RID_P2_CRYPT_KEY3 0xFC27
#define WI_RID_P2_ENCRYPTION 0xFC28
#define WI_RID_ROAMING_MODE 0xFC2D
#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */
#define WI_MAX_AID 256 /* max stations for ap operation */
struct wi_vap {
struct ieee80211vap wv_vap;
struct ieee80211_beacon_offsets wv_bo;
void (*wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *,
int, int, int);
int (*wv_newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
};
#define WI_VAP(vap) ((struct wi_vap *)(vap))
struct wi_softc {
struct ifnet *sc_ifp;
device_t sc_dev;
struct mtx sc_mtx;
struct callout sc_watchdog;
int sc_unit;
int wi_gone;
int sc_enabled;
int sc_reset;
int sc_firmware_type;
#define WI_NOTYPE 0
#define WI_LUCENT 1
#define WI_INTERSIL 2
#define WI_SYMBOL 3
int sc_pri_firmware_ver; /* Primary firmware */
int sc_sta_firmware_ver; /* Station firmware */
unsigned int sc_nic_id; /* Type of NIC */
char * sc_nic_name;
int wi_bus_type; /* Bus attachment type */
struct resource * local;
int local_rid;
struct resource * iobase;
int iobase_rid;
struct resource * irq;
int irq_rid;
struct resource * mem;
int mem_rid;
bus_space_handle_t wi_localhandle;
bus_space_tag_t wi_localtag;
bus_space_handle_t wi_bhandle;
bus_space_tag_t wi_btag;
bus_space_handle_t wi_bmemhandle;
bus_space_tag_t wi_bmemtag;
void * wi_intrhand;
struct ieee80211_channel *wi_channel;
int wi_io_addr;
int wi_cmd_count;
int sc_flags;
int sc_if_flags;
int sc_bap_id;
int sc_bap_off;
int sc_porttype;
u_int16_t sc_portnum;
u_int16_t sc_encryption;
u_int16_t sc_monitor_port;
/* RSSI interpretation */
u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */
u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */
u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */
int sc_buflen; /* TX buffer size */
int sc_ntxbuf;
#define WI_NTXBUF 3
struct {
int d_fid;
int d_len;
} sc_txd[WI_NTXBUF]; /* TX buffers */
int sc_txnext; /* index of next TX */
int sc_txcur; /* index of current TX*/
int sc_tx_timer;
struct wi_counters sc_stats;
u_int16_t sc_ibss_port;
struct timeval sc_last_syn;
int sc_false_syns;
u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2];
struct wi_tx_radiotap_header sc_tx_th;
struct wi_rx_radiotap_header sc_rx_th;
};
/* maximum consecutive false change-of-BSSID indications */
#define WI_MAX_FALSE_SYNS 10
#define WI_FLAGS_HAS_ENHSECURITY 0x0001
#define WI_FLAGS_HAS_WPASUPPORT 0x0002
#define WI_FLAGS_HAS_ROAMING 0x0020
#define WI_FLAGS_HAS_FRAGTHR 0x0200
#define WI_FLAGS_HAS_DBMADJUST 0x0400
struct wi_card_ident {
u_int16_t card_id;
char *card_name;
u_int8_t firm_type;
};
#define WI_PRISM_MIN_RSSI 0x1b
#define WI_PRISM_MAX_RSSI 0x9a
#define WI_PRISM_DBM_OFFSET 100 /* XXX */
#define WI_LUCENT_MIN_RSSI 47
#define WI_LUCENT_MAX_RSSI 138
#define WI_LUCENT_DBM_OFFSET 149
#define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
#define WI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
#define WI_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
int wi_attach(device_t);
int wi_detach(device_t);
int wi_shutdown(device_t);
int wi_alloc(device_t, int);
void wi_free(device_t);
extern devclass_t wi_devclass;
void wi_init(void *);
void wi_intr(void *);
int wi_mgmt_xmit(struct wi_softc *, caddr_t, int);
void wi_stop(struct wi_softc *, int);

View File

@ -7,13 +7,20 @@
#define _FBSD_COMPAT_NET_BPF_H_
#define DLT_EN10MB 1 /* Ethernet (10Mb) */
#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
struct bpf_if;
#define bpf_mtap(bpf_if, mbuf) do { } while (0)
#define BPF_MTAP(ifp, m) do { } while (0)
#define bpf_mtap2(bpf_if, data, dlen, mbuf) do { } while (0)
#define bpfattach2(ifnet, dlt, hdrlen, bpf_if) do { } while (0)
#define BPF_TAP(ifp, pkt, pktlen) do { } while (0)
#define bpf_mtap2(bpf_if, data, dlen, mbuf) do { } while (0)
#define bpfattach(ifnet, dlt, hdrlen) do { } while (0);
#define bpfattach2(ifnet, dlt, hdrlen, bpf_if) do { } while (0)
#define bpfdetach(ifnet) do { } while (0);
static inline int

View File

@ -0,0 +1,11 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_SYS_CTYPE_H_
#define _FBSD_COMPAT_SYS_CTYPE_H_
#define isprint(c) ((c) >= ' ' && (c) <= '~')
#endif /* _FBSD_COMPAT_SYS_CTYPE_H_ */

View File

@ -13,6 +13,7 @@
#include <sys/cdefs.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/priority.h>
/* The version this compatibility layer is based on */

View File

@ -0,0 +1,12 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_SYS_PRIORITY_H_
#define _FBSD_COMPAT_SYS_PRIORITY_H_
#define PRI_MIN_KERN (64)
#define PZERO (PRI_MIN_KERN + 20)
#endif /* _FBSD_COMPAT_SYS_PRIORITY_H_ */

View File

@ -11,6 +11,7 @@
#include <sys/condvar.h>
#include <sys/queue.h>
#include <sys/_mutex.h>
#include <sys/priority.h>
#include <sys/pcpu.h>
#endif /* _FBSD_COMPAT_SYS_PROC_H_ */

View File

@ -25,5 +25,7 @@ struct resource {
bus_space_handle_t rman_get_bushandle(struct resource *);
bus_space_tag_t rman_get_bustag(struct resource *);
uint32_t rman_make_alignment_flags(uint32_t);
u_long rman_get_start(struct resource *);
#endif /* _FBSD_COMPAT_SYS_RMAN_H_ */

View File

@ -18,7 +18,9 @@ struct sysctl_req {
struct sysctl_ctx_list {
};
#define SYSCTL_HANDLER_ARGS void *oidp, void *arg1, void *arg2, struct sysctl_req *req
#define SYSCTL_HANDLER_ARGS void *oidp, void *arg1, int arg2, \
struct sysctl_req *req
#define OID_AUTO (-1)
@ -46,6 +48,7 @@ struct sysctl_ctx_list {
#define CTLFLAG_TUN 0x00080000 /* Tunable variable */
#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN)
static inline int
sysctl_ctx_init(struct sysctl_ctx_list *clist)
{
@ -61,11 +64,9 @@ sysctl_ctx_free(struct sysctl_ctx_list *clist)
static inline void *
sysctl_add_oid(struct sysctl_ctx_list *clist,
void *parent, int nbr, const char *name,
int kind, void *arg1, int arg2,
int (*handler) (SYSCTL_HANDLER_ARGS),
const char *fmt, const char *descr)
sysctl_add_oid(struct sysctl_ctx_list *clist, void *parent, int nbr,
const char *name, int kind, void *arg1, int arg2,
int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr)
{
return NULL;
}
@ -83,47 +84,52 @@ static inline int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { return -1; }
#define __DESCR(x) ""
#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr))
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, \
__DESCR(descr))
#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \
#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \
0, 0, handler, "N", __DESCR(descr))
#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \
#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \
arg, len, sysctl_handle_string, "A", __DESCR(descr))
#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access), \
#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access), \
ptr, val, sysctl_handle_int, "I", __DESCR(descr))
#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
ptr, val, sysctl_handle_int, "IU", __DESCR(descr))
#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access), \
#define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
ptr, val, sysctl_handle_int, "IX", __DESCR(descr))
#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access), \
ptr, 0, sysctl_handle_long, "L", __DESCR(descr))
#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \
#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \
ptr, 0, sysctl_handle_long, "LU", __DESCR(descr))
#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|(access), \
#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|(access), \
ptr, 0, sysctl_handle_quad, "Q", __DESCR(descr))
#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr))
#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr))
#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
sysctl_add_oid(ctx, parent, nbr, name, (access), \
ptr, arg, handler, fmt, __DESCR(descr))
sysctl_add_oid(ctx, parent, nbr, name, (access), ptr, arg, handler, fmt, \
__DESCR(descr))
static inline void *
@ -133,9 +139,9 @@ SYSCTL_CHILDREN(void *ptr)
}
#define SYSCTL_STATIC_CHILDREN(...) NULL
#define SYSCTL_STATIC_CHILDREN(...) NULL
#define SYSCTL_DECL(name) \
#define SYSCTL_DECL(name) \
extern struct sysctl_oid_list sysctl_##name##_children
#define SYSCTL_NODE(...)

View File

@ -0,0 +1,11 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_SYS_SYSLOG_H_
#define _FBSD_COMPAT_SYS_SYSLOG_H_
#define LOG_ERR 3 /* error conditions */
#endif /* _FBSD_COMPAT_SYS_SYSLOG_H_ */

View File

@ -25,15 +25,15 @@ int printf(const char *format, ...) __printflike(1, 2);
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
#define bootverbose 1
#define bootverbose 1
#ifdef INVARIANTS
#define KASSERT(cond,msg) do { \
if (!(cond)) \
panic msg; \
#ifdef INVARIANTS
#define KASSERT(cond,msg) do { \
if (!(cond)) \
panic msg; \
} while (0)
#else
#define KASSERT(exp,msg) do { \
#define KASSERT(exp,msg) do { \
} while (0)
#endif
@ -47,10 +47,10 @@ int printf(const char *format, ...) __printflike(1, 2);
void wakeup(void *);
#ifndef CTASSERT /* Allow lint to override */
#define CTASSERT(x) _CTASSERT(x, __LINE__)
#define _CTASSERT(x, y) __CTASSERT(x, y)
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
#ifndef CTASSERT /* Allow lint to override */
#define CTASSERT(x) _CTASSERT(x, __LINE__)
#define _CTASSERT(x, y) __CTASSERT(x, y)
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
#endif
@ -70,11 +70,14 @@ copyout(const void * __restrict kaddr, void * __restrict udaddr,
}
int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
static inline void log(int level, const char *fmt, ...) { }
int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
extern int sprintf(char *buf, const char *, ...);
extern void driver_vprintf(const char *format, va_list vl);
#define vprintf(fmt, vl) driver_vprintf(fmt, vl)
#define vprintf(fmt, vl) driver_vprintf(fmt, vl)
extern int vsnprintf(char *, size_t, const char *, __va_list)
__printflike(3, 0);
@ -82,7 +85,7 @@ extern int vsnprintf(char *, size_t, const char *, __va_list)
int msleep(void *, struct mtx *, int, const char *, int);
int _pause(const char *, int);
#define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
#define tsleep(channel, priority, waitMessage, timeout) \
#define tsleep(channel, priority, waitMessage, timeout) \
msleep((channel), NULL, (priority), (waitMessage), (timeout))
struct unrhdr;