Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by

Jean-Baptiste Campesato.

From PR kern/33778.
This commit is contained in:
simonb 2006-08-13 02:21:45 +00:00
parent a79c18d72f
commit af29995e74
7 changed files with 3901 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.917 2006/07/29 19:10:56 ad Exp $
# $NetBSD: mi,v 1.918 2006/08/13 02:21:45 simonb Exp $
./etc/mtree/set.man man-sys-root
./usr/share/info/am-utils.info man-amd-info info
./usr/share/info/as.info man-computil-info bfd,info
@ -1475,6 +1475,7 @@
./usr/share/man/cat4/we.0 man-sys-catman .cat
./usr/share/man/cat4/wi.0 man-sys-catman .cat
./usr/share/man/cat4/wm.0 man-sys-catman .cat
./usr/share/man/cat4/wpi.0 man-sys-catman .cat
./usr/share/man/cat4/wscons.0 man-sys-catman .cat
./usr/share/man/cat4/wsdisplay.0 man-sys-catman .cat
./usr/share/man/cat4/wsfont.0 man-sys-catman .cat
@ -3840,6 +3841,7 @@
./usr/share/man/man4/we.4 man-sys-man .man
./usr/share/man/man4/wi.4 man-sys-man .man
./usr/share/man/man4/wm.4 man-sys-man .man
./usr/share/man/man4/wpi.4 man-sys-man .man
./usr/share/man/man4/wscons.4 man-sys-man .man
./usr/share/man/man4/wsdisplay.4 man-sys-man .man
./usr/share/man/man4/wsfont.4 man-sys-man .man

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.397 2006/07/29 08:54:52 wiz Exp $
# $NetBSD: Makefile,v 1.398 2006/08/13 02:21:45 simonb Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 adc.4 adt7467c.4 adv.4 \
@ -45,7 +45,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 adc.4 adt7467c.4 adv.4 \
tqphy.4 twa.4 twe.4 txp.4 ubsec.4 udp.4 uep.4 uha.4 uk.4 ukphy.4 \
unix.4 userconf.4 veriexec.4 vga.4 vge.4 viaide.4 \
vlan.4 vmmon.4 vmnet.4 vnd.4 vr.4 wd.4 wdc.4 \
wi.4 wm.4 wscons.4 wsdisplay.4 wsfont.4 wskbd.4 \
wi.4 wm.4 wpi.4 wscons.4 wsdisplay.4 wsfont.4 wskbd.4 \
wsmouse.4 wsmux.4 xbox.4 xge.4 yds.4 ym.4 zero.4 zstty.4
# USB devices

255
share/man/man4/wpi.4 Normal file
View File

@ -0,0 +1,255 @@
.\" $NetBSD $
.\"
.\" Copyright (c) 2006
.\" Damien Bergamini <damien.bergamini@free.fr>. 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 unmodified, 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR OR CONTRIBUTORS 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.
.\"
.Dd May 23, 2006
.Os
.Dt WPI 4
.Sh NAME
.Nm wpi
.Nd Intel PRO/Wireless 3945ABG IEEE 802.11a/b/g wireless network driver
.Sh SYNOPSIS
.Cd "wpi* at pci? dev ? function ?"
.Sh DESCRIPTION
.Pp
The
.Nm
driver provides support for
.Tn Intel
PRO/Wireless 3945ABG Mini PCI Express network adapters.
.Pp
These are the modes the
.Nm
driver can operate in:
.Bl -tag -width Ds
.It BSS mode
Also known as
.Em infrastructure
mode, this is used when associating with an access point, through
which all traffic passes.
This mode is the default.
.It monitor mode
In this mode the driver is able to receive packets without
associating with an access point.
This disables the internal receive filter and enables the card to
capture packets from networks which it wouldn't normally have access to,
or to scan for access points.
.El
.Pp
.Nm
supports software WEP.
Wired Equivalent Privacy (WEP) is the de facto encryption standard
for wireless networks.
It can be typically configured in one of three modes:
no encryption; 40-bit encryption; or 104-bit encryption.
Unfortunately, due to serious weaknesses in WEP protocol
it is strongly recommended that it not be used as the
sole mechanism to secure wireless communication.
WEP is not enabled by default.
.Sh CONFIGURATION
The
.Nm
driver can be configured at runtime with
.Xr ifconfig 8
using the following parameters:
.Bl -tag -width Ds
.It Cm bssid Ar bssid
Set the desired BSSID.
.It Fl bssid
Unset the desired BSSID.
The interface will automatically select a BSSID in this mode, which is
the default.
.It Cm chan Ar n
Set the channel (radio frequency) to be used by the driver based on
the given channel ID
.Ar n .
.It Fl chan
Unset the desired channel to be used by the driver.
The driver will automatically select a channel in this mode, which is
the default.
.It Cm media Ar media
The
.Nm
driver supports the following
.Ar media
types:
.Pp
.Bl -tag -width autoselect -compact
.It Cm autoselect
Enable autoselection of the media type and options.
.El
.It Cm mediaopt Ar opts
The
.Nm
driver supports the following media options:
.Pp
.Bl -tag -width monitor -compact
.It Cm monitor
Select monitor mode.
.El
.It Fl mediaopt Ar opts
Disable the specified media options on the driver and return it to the
default mode of operation (BSS).
.It Cm mode Ar mode
The
.Nm
driver supports the following modes:
.Pp
.Bl -tag -width 11b -compact
.It Cm 11a
Force 802.11a operation.
.It Cm 11b
Force 802.11b operation.
.It Cm 11g
Force 802.11g operation.
.El
.It Cm nwid Ar id
Set the network ID.
The
.Ar id
can either be any text string up to 32 characters in length,
or a series of hexadecimal digits up to 64 digits.
An empty
.Ar id
string allows the interface to connect to any available access points.
By default the
.Nm
driver uses an empty string.
Note that network ID is synonymous with Extended Service Set ID (ESSID).
.It Cm nwkey Ar key
Enable WEP encryption using the specified
.Ar key .
The
.Ar key
can either be a string, a series of hexadecimal digits (preceded by
.Sq 0x ) ,
or a set of keys of the form
.Dq n:k1,k2,k3,k4 ,
where
.Sq n
specifies which of the keys will be used for transmitted packets,
and the four keys,
.Dq k1
through
.Dq k4 ,
are configured as WEP keys.
If a set of keys is specified, a comma
.Pq Sq \&,
within the key must be escaped with a backslash.
Note that if multiple keys are used, their order must be the same within
the network.
.Nm
is capable of using both 40-bit (5 characters or 10 hexadecimal digits)
or 104-bit (13 characters or 26 hexadecimal digits) keys.
.It Fl nwkey
Disable WEP encryption.
This is the default mode of operation.
.El
.Sh FILES
The driver needs at least version 1.13 of the following firmware file,
which is loaded when an interface is brought up:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It Pa /usr/pkg/libdata/if_wpi/ipw3945.ucode
.El
.Pp
This firmware file is not free because Intel refuses to grant
distribution rights without contractual obligations.
As a result, even though
.Nx
includes the driver, the firmware file cannot be included and
users have to download this file on their own.
The official person to state your views to about this issue is
peter.engelbrecht@intel.com at (858) 391 1857.
.Pp
The firmware can be found at:
.Pp
.Pa http://bughost.org/ipw3945/
(Microcode)
.Sh EXAMPLES
.Bd -literal -offset indent
# ifconfig wpi0 nwkey 0x1deadbeef1
.Ed
.Pp
Return wpi0 to its default settings:
.Bd -literal -offset indent
# ifconfig wpi0 -bssid -chan media autoselect \e
nwid "" -nwkey
.Ed
.Pp
Join an existing BSS network,
.Dq my_net :
.Bd -literal -offset indent
# ifconfig wpi0 192.168.1.1 netmask 0xffffff00 nwid my_net
.Ed
.Sh DIAGNOSTICS
.Bl -diag
.It "wpi%d: device timeout"
A frame dispatched to the hardware for transmission did not complete in time.
The driver will reset the hardware.
This should not happen.
.It "wpi%d: fatal firmware error"
For some reason, the firmware crashed.
The driver will reset the hardware.
This should not happen.
.It "wpi%d: Radio transmitter is off"
The radio transmitter is off and thus no packet can go out.
The driver will reset the hardware.
Make sure the laptop radio switch is on.
.It "wpi%d: could not read firmware file"
For some reason, the driver was unable to read the firmware image from the
filesystem.
The file might be missing or corrupted.
.It "wpi%d: firmware file too short: %d bytes"
The firmware image is corrupted and can't be loaded into the adapter.
.It "wpi%d: could not load firmware"
An attempt to load the firmware into the adapter failed.
The driver will reset the hardware.
.El
.Sh NOTES
802.11a is not working yet.
.Pp
On some laptops the radio transmitter button must be pushed twice to get the driver working, or you will get a
.Pa "wpi%d: fatal firmware error"
when the interface will be set to up
.Sh SEE ALSO
.Xr arp 4 ,
.Xr ifmedia 4 ,
.Xr intro 4 ,
.Xr netintro 4 ,
.Xr pci 4 ,
.Xr ifconfig 8
.Rs
.%T The IPW Web Page
.%O http://damien.bergamini.free.fr/ipw/
.Re
.Sh AUTHORS
The
.Nm
driver was originally written by
.An Damien Bergamini Aq damien@openbsd.org .
NetBSD porting was done by
.An Jean-Baptiste Campesato Aq camjelemon@gmail.com .

View File

@ -1,4 +1,4 @@
# $NetBSD: files.pci,v 1.263 2006/08/10 12:22:25 cube Exp $
# $NetBSD: files.pci,v 1.264 2006/08/13 02:21:45 simonb Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@ -793,6 +793,16 @@ device ipw: ifnet, arp, wlan, firmload
attach ipw at pci
file dev/pci/if_ipw.c ipw
# Intel PRO/Wireless 2200BG/2915ABG
device iwi: ifnet, arp, wlan, firmload
attach iwi at pci
file dev/pci/if_iwi.c iwi
# Intel PRO/Wireless 3945ABG
device wpi: ifnet, arp, wlan, firmload
attach wpi at pci
file dev/pci/if_wpi.c wpi
# Workbit NinjaSCSI-32 controllers
# device declaration in sys/conf/files
attach njs at pci with njs_pci
@ -803,11 +813,6 @@ device xge: ether, ifnet, arp
attach xge at pci
file dev/pci/if_xge.c xge
# Intel PRO/Wireless 2200BG/2915ABG
device iwi: ifnet, arp, wlan, firmload
attach iwi at pci
file dev/pci/if_iwi.c iwi
# Via Velocity 612x 10/100/1000 Ethernet
device vge: ether, ifnet, arp, mii
attach vge at pci

2911
sys/dev/pci/if_wpi.c Normal file

File diff suppressed because it is too large Load Diff

563
sys/dev/pci/if_wpireg.h Normal file
View File

@ -0,0 +1,563 @@
/* $NetBSD: if_wpireg.h,v 1.1 2006/08/13 02:21:45 simonb Exp $ */
/*-
* Copyright (c) 2006
* Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define WPI_TX_RING_COUNT 256
#define WPI_SVC_RING_COUNT 256
#define WPI_CMD_RING_COUNT 256
#define WPI_RX_RING_COUNT 64
/*
* Rings must be aligned on a four 4K-pages boundary.
* I had a hard time figuring this out.
*/
#define WPI_RING_DMA_ALIGN 0x4000
/* maximum scatter/gather */
#define WPI_MAX_SCATTER 4
/*
* Control and status registers.
*/
#define WPI_HWCONFIG 0x000
#define WPI_INTR 0x008
#define WPI_MASK 0x00c
#define WPI_INTR_STATUS 0x010
#define WPI_GPIO_STATUS 0x018
#define WPI_RESET 0x020
#define WPI_GPIO_CTL 0x024
#define WPI_EEPROM_CTL 0x02c
#define WPI_EEPROM_STATUS 0x030
#define WPI_UCODE_CLR 0x05c
#define WPI_TEMPERATURE 0x060
#define WPI_CHICKEN 0x100
#define WPI_PLL_CTL 0x20c
#define WPI_FW_TARGET 0x410
#define WPI_WRITE_MEM_ADDR 0x444
#define WPI_READ_MEM_ADDR 0x448
#define WPI_WRITE_MEM_DATA 0x44c
#define WPI_READ_MEM_DATA 0x450
#define WPI_TX_WIDX 0x460
#define WPI_TX_CTL(qid) (0x940 + (qid) * 8)
#define WPI_TX_BASE(qid) (0x944 + (qid) * 8)
#define WPI_TX_DESC(qid) (0x980 + (qid) * 80)
#define WPI_RX_CONFIG 0xc00
#define WPI_RX_BASE 0xc04
#define WPI_RX_WIDX 0xc20
#define WPI_RX_RIDX_PTR 0xc24
#define WPI_RX_CTL 0xcc0
#define WPI_RX_STATUS 0xcc4
#define WPI_TX_CONFIG(qid) (0xd00 + (qid) * 32)
#define WPI_TX_CREDIT(qid) (0xd04 + (qid) * 32)
#define WPI_TX_STATE(qid) (0xd08 + (qid) * 32)
#define WPI_TX_BASE_PTR 0xe80
#define WPI_MSG_CONFIG 0xe88
#define WPI_TX_STATUS 0xe90
/*
* NIC internal memory offsets.
*/
#define WPI_MEM_MODE 0x2e00
#define WPI_MEM_RA 0x2e04
#define WPI_MEM_TXCFG 0x2e10
#define WPI_MEM_MAGIC4 0x2e14
#define WPI_MEM_MAGIC5 0x2e20
#define WPI_MEM_BYPASS1 0x2e2c
#define WPI_MEM_BYPASS2 0x2e30
#define WPI_MEM_CLOCK1 0x3004
#define WPI_MEM_CLOCK2 0x3008
#define WPI_MEM_POWER 0x300c
#define WPI_MEM_PCIDEV 0x3010
#define WPI_MEM_UCODE_CTL 0x3400
#define WPI_MEM_UCODE_SRC 0x3404
#define WPI_MEM_UCODE_DST 0x3408
#define WPI_MEM_UCODE_SIZE 0x340c
#define WPI_MEM_UCODE_BASE 0x3800
/* possible flags for register WPI_HWCONFIG */
#define WPI_HW_ALM_MB (1 << 8)
#define WPI_HW_ALM_MM (1 << 9)
#define WPI_HW_SKU_MRC (1 << 10)
#define WPI_HW_REV_D (1 << 11)
#define WPI_HW_TYPE_B (1 << 12)
/* possible flags for registers WPI_READ_MEM_ADDR/WPI_WRITE_MEM_ADDR */
#define WPI_MEM_4 ((sizeof (uint32_t) - 1) << 24)
/* possible values for WPI_FW_TARGET */
#define WPI_FW_TEXT 0x00000000
#define WPI_FW_DATA 0x00800000
/* possible flags for WPI_GPIO_STATUS */
#define WPI_POWERED (1 << 9)
/* possible flags for register WPI_RESET */
#define WPI_NEVO_RESET (1 << 0)
#define WPI_SW_RESET (1 << 7)
#define WPI_MASTER_DISABLED (1 << 8)
#define WPI_STOP_MASTER (1 << 9)
/* possible flags for register WPI_GPIO_CTL */
#define WPI_GPIO_CLOCK (1 << 0)
#define WPI_GPIO_INIT (1 << 2)
#define WPI_GPIO_MAC (1 << 3)
#define WPI_GPIO_SLEEP (1 << 4)
#define WPI_GPIO_PWR_STATUS 0x07000000
#define WPI_GPIO_PWR_SLEEP (4 << 24)
/* possible flags for register WPI_CHICKEN */
#define WPI_CHICKEN_RXNOLOS (1 << 23)
/* possible flags for register WPI_PLL_CTL */
#define WPI_PLL_INIT (1 << 24)
/* possible flags for register WPI_UCODE_CLR */
#define WPI_RADIO_OFF (1 << 1)
#define WPI_DISABLE_CMD (1 << 2)
/* possible flags for WPI_RX_STATUS */
#define WPI_RX_IDLE (1 << 24)
/* possible flags for register WPI_UC_CTL */
#define WPI_UC_RUN (1 << 30)
/* possible flags for register WPI_INTR_CSR */
#define WPI_ALIVE_INTR (1 << 0)
#define WPI_WAKEUP_INTR (1 << 1)
#define WPI_SW_ERROR (1 << 25)
#define WPI_TX_INTR (1 << 27)
#define WPI_HW_ERROR (1 << 29)
#define WPI_RX_INTR (1 << 31)
#define WPI_INTR_MASK \
(WPI_SW_ERROR | WPI_HW_ERROR | WPI_TX_INTR | WPI_RX_INTR | \
WPI_ALIVE_INTR | WPI_WAKEUP_INTR)
/* possible flags for register WPI_TX_STATUS */
#define WPI_TX_IDLE(qid) (1 << ((qid) + 24) | 1 << ((qid) + 16))
/* possible flags for register WPI_EEPROM_CTL */
#define WPI_EEPROM_READY (1 << 0)
/* possible flags for register WPI_EEPROM_STATUS */
#define WPI_EEPROM_VERSION 0x00000007
#define WPI_EEPROM_LOCKED 0x00000180
struct wpi_shared {
uint32_t txbase[8];
uint32_t next;
uint32_t reserved[2];
} __attribute__((__packed__));
#define WPI_MAX_SEG_LEN 65520
struct wpi_tx_desc {
uint32_t flags;
#define WPI_PAD32(x) ((((x) + 3) & ~3) - (x))
struct {
uint32_t addr;
uint32_t len;
} __attribute__((__packed__)) segs[WPI_MAX_SCATTER];
uint8_t reserved[28];
} __attribute__((__packed__));
struct wpi_tx_stat {
uint8_t nrts;
uint8_t ntries;
uint8_t nkill;
uint8_t rate;
uint32_t duration;
uint32_t status;
} __attribute__((__packed__));
struct wpi_rx_desc {
uint32_t len;
uint8_t type;
#define WPI_UC_READY 1
#define WPI_RX_DONE 27
#define WPI_TX_DONE 28
#define WPI_START_SCAN 130
#define WPI_STOP_SCAN 132
#define WPI_STATE_CHANGED 161
uint8_t flags;
uint8_t idx;
uint8_t qid;
} __attribute__((__packed__));
struct wpi_rx_stat {
uint8_t len;
#define WPI_STAT_MAXLEN 20
uint8_t id;
uint8_t rssi; /* received signal strength */
#define WPI_RSSI_OFFSET 95
uint8_t agc; /* access gain control */
uint16_t signal;
uint16_t noise;
} __attribute__((__packed__));
struct wpi_rx_head {
uint16_t chan;
uint16_t flags;
uint8_t reserved;
uint8_t rate;
uint16_t len;
} __attribute__((__packed__));
struct wpi_rx_tail {
uint32_t flags;
#define WPI_RX_NO_CRC_ERR (1 << 0)
#define WPI_RX_NO_OVFL_ERR (1 << 1)
/* shortcut for the above */
#define WPI_RX_NOERROR (WPI_RX_NO_CRC_ERR | WPI_RX_NO_OVFL_ERR)
uint64_t tstamp;
uint32_t tbeacon;
} __attribute__((__packed__));
struct wpi_tx_cmd {
uint8_t code;
#define WPI_CMD_CONFIGURE 16
#define WPI_CMD_ASSOCIATE 17
#define WPI_CMD_SET_WME 19
#define WPI_CMD_TSF 20
#define WPI_CMD_ADD_NODE 24
#define WPI_CMD_TX_DATA 28
#define WPI_CMD_MRR_SETUP 71
#define WPI_CMD_SET_LED 72
#define WPI_CMD_SET_POWER_MODE 119
#define WPI_CMD_SCAN 128
#define WPI_CMD_SET_BEACON 145
#define WPI_CMD_BLUETOOTH 155
#define WPI_CMD_TXPOWER 176
uint8_t flags;
uint8_t idx;
uint8_t qid;
uint8_t data[124];
} __attribute__((__packed__));
/* structure for WPI_CMD_CONFIGURE */
struct wpi_config {
uint8_t myaddr[IEEE80211_ADDR_LEN];
uint16_t reserved1;
uint8_t bssid[IEEE80211_ADDR_LEN];
uint16_t reserved2;
uint32_t reserved3[2];
uint8_t mode;
#define WPI_MODE_HOSTAP 1
#define WPI_MODE_STA 3
#define WPI_MODE_IBSS 4
#define WPI_MODE_MONITOR 6
uint8_t reserved4[3];
uint8_t ofdm_mask;
uint8_t cck_mask;
uint16_t state;
#define WPI_STATE_ASSOCIATED 4
uint32_t flags;
#define WPI_CONFIG_24GHZ (1 << 0)
#define WPI_CONFIG_CCK (1 << 1)
#define WPI_CONFIG_AUTO (1 << 2)
#define WPI_CONFIG_SHSLOT (1 << 4)
#define WPI_CONFIG_SHPREAMBLE (1 << 5)
#define WPI_CONFIG_NODIVERSITY (1 << 7)
#define WPI_CONFIG_ANTENNA_A (1 << 8)
#define WPI_CONFIG_ANTENNA_B (1 << 9)
#define WPI_CONFIG_TSF (1 << 15)
uint32_t filter;
#define WPI_FILTER_PROMISC (1 << 0)
#define WPI_FILTER_CTL (1 << 1)
#define WPI_FILTER_MULTICAST (1 << 2)
#define WPI_FILTER_NODECRYPT (1 << 3)
#define WPI_FILTER_BSS (1 << 5)
#define WPI_FILTER_BEACON (1 << 6)
uint8_t chan;
uint8_t reserved6[3];
} __attribute__((__packed__));
/* structure for command WPI_CMD_ASSOCIATE */
struct wpi_assoc {
uint32_t flags;
uint32_t filter;
uint8_t ofdm_mask;
uint8_t cck_mask;
uint16_t reserved;
} __attribute__((__packed__));
/* structure for command WPI_CMD_SET_WME */
struct wpi_wme_setup {
uint32_t flags;
struct {
uint16_t cwmin;
uint16_t cwmax;
uint8_t aifsn;
uint8_t reserved;
uint16_t txop;
} __packed ac[WME_NUM_AC];
} __packed;
/* structure for command WPI_CMD_TSF */
struct wpi_cmd_tsf {
uint64_t tstamp;
uint16_t bintval;
uint16_t atim;
uint32_t binitval;
uint16_t lintval;
uint16_t reserved;
} __attribute__((__packed__));
/* structure for WPI_CMD_ADD_NODE */
struct wpi_node {
uint8_t control;
#define WPI_NODE_UPDATE (1 << 0)
uint8_t reserved1[3];
uint8_t bssid[IEEE80211_ADDR_LEN];
uint16_t reserved2;
uint8_t id;
#define WPI_ID_BSS 0
#define WPI_ID_BROADCAST 24
uint8_t sta_mask;
uint16_t reserved3;
uint16_t key_flags;
uint8_t tkip;
uint8_t reserved4;
uint16_t ttak[5];
uint16_t reserved5;
uint8_t key[IEEE80211_KEYBUF_SIZE];
uint32_t flags;
uint32_t mask;
uint16_t tid;
uint8_t rate;
uint8_t reserved6;
uint8_t add_imm;
uint8_t del_imm;
uint16_t add_imm_start;
} __attribute__((__packed__));
/* structure for command WPI_CMD_TX_DATA */
struct wpi_cmd_data {
uint16_t len;
uint16_t lnext;
uint32_t flags;
#define WPI_TX_NEED_RTS (1 << 1)
#define WPI_TX_NEED_ACK (1 << 3)
#define WPI_TX_FULL_TXOP (1 << 7)
#define WPI_TX_AUTO_SEQ (1 << 13)
#define WPI_TX_INSERT_TSTAMP (1 << 16)
uint8_t rate;
uint8_t id;
uint8_t tid;
uint8_t security;
uint8_t key[IEEE80211_KEYBUF_SIZE];
uint8_t tkip[IEEE80211_WEP_MICLEN];
uint32_t fnext;
uint32_t lifetime;
uint8_t ofdm_mask;
uint8_t cck_mask;
uint8_t rts_ntries;
uint8_t data_ntries;
uint16_t timeout;
uint16_t txop;
struct ieee80211_frame wh;
} __attribute__((__packed__));
/* structure for command WPI_CMD_SET_BEACON */
struct wpi_cmd_beacon {
uint16_t len;
uint16_t reserved1;
uint32_t flags; /* same as wpi_cmd_data */
uint8_t rate;
uint8_t id;
uint8_t reserved2[30];
uint32_t lifetime;
uint8_t ofdm_mask;
uint8_t cck_mask;
uint16_t reserved3[3];
uint16_t tim;
uint8_t timsz;
uint8_t reserved4;
struct ieee80211_frame wh;
} __attribute__((__packed__));
/* structure for WPI_CMD_MRR_SETUP */
struct wpi_mrr_setup {
uint32_t which;
#define WPI_MRR_CTL 0
#define WPI_MRR_DATA 1
struct {
uint8_t plcp;
uint8_t flags;
uint8_t ntries;
uint8_t next;
#define WPI_OFDM6 0
#define WPI_OFDM54 7
#define WPI_CCK1 8
#define WPI_CCK2 9
#define WPI_CCK11 11
} __attribute__((__packed__)) rates[WPI_CCK11 + 1];
} __attribute__((__packed__));
/* structure for WPI_CMD_SET_LED */
struct wpi_cmd_led {
uint32_t unit; /* multiplier (in usecs) */
uint8_t which;
#define WPI_LED_ACTIVITY 1
#define WPI_LED_LINK 2
uint8_t off;
uint8_t on;
uint8_t reserved;
} __attribute__((__packed__));
/* structure for WPI_CMD_SET_POWER_MODE */
struct wpi_power {
uint32_t flags;
uint32_t rx_timeout;
uint32_t tx_timeout;
uint32_t sleep[5];
} __attribute__((__packed__));
/* structure for command WPI_CMD_SCAN */
struct wpi_scan_hdr {
uint8_t len;
uint8_t first;
uint8_t reserved1;
uint8_t nchan;
uint16_t quiet;
uint16_t threshold;
uint16_t band;
#define WPI_SCAN_5GHZ 1
uint16_t reserved2[5];
uint32_t flags;
uint32_t filter;
uint16_t pbrlen;
uint16_t reserved4;
uint32_t magic1;
uint8_t rate;
uint8_t id;
uint16_t reserved5;
uint32_t reserved6[7];
uint32_t mask;
uint32_t reserved7[2];
uint8_t reserved8;
uint8_t esslen;
uint8_t essid[134];
/* followed by probe request body */
/* followed by nchan x wpi_scan_chan */
} __attribute__((__packed__));
struct wpi_scan_chan {
uint8_t flags;
uint8_t chan;
#define WPI_CHAN_ACTIVE 3
uint16_t magic; /* XXX */
uint16_t active; /* msecs */
uint16_t passive; /* msecs */
} __attribute__((__packed__));
/* structure for WPI_CMD_BLUETOOTH */
struct wpi_bluetooth {
uint8_t flags;
uint8_t lead;
uint8_t kill;
uint8_t reserved;
uint32_t ack;
uint32_t cts;
} __attribute__((__packed__));
/* structure for command WPI_CMD_TXPOWER */
struct wpi_txpower {
uint32_t reserved1;
uint16_t pwr1[14];
uint32_t reserved2[2];
uint16_t pwr2[14];
uint32_t reserved3[2];
} __attribute__((__packed__));
/* firmware image header */
struct wpi_firmware_hdr {
uint32_t version;
uint32_t textsz;
uint32_t datasz;
uint32_t bootsz;
} __attribute__((__packed__));
/* structure for WPI_UC_READY notification */
struct wpi_ucode_info {
uint32_t version;
uint8_t revision[8];
uint8_t type;
uint8_t subtype;
uint16_t reserved;
uint32_t logptr;
uint32_t errorptr;
uint32_t timestamp;
uint32_t valid;
} __attribute__((__packed__));
/* structure for WPI_START_SCAN notification */
struct wpi_start_scan {
uint64_t tstamp;
uint32_t tbeacon;
uint8_t chan;
uint8_t band;
uint16_t reserved;
uint32_t status;
} __attribute__((__packed__));
/* structure for WPI_STOP_SCAN notification */
struct wpi_stop_scan {
uint8_t nchan;
uint8_t status;
uint8_t reserved;
uint8_t chan;
uint64_t tsf;
} __packed;
#define WPI_EEPROM_MAC 0x015
#define WPI_EEPROM_REVISION 0x035
#define WPI_EEPROM_CAPABILITIES 0x045
#define WPI_EEPROM_TYPE 0x04a
#define WPI_EEPROM_PWR1 0x1ae
#define WPI_EEPROM_PWR2 0x1bc
#define WPI_READ(sc, reg) \
bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
#define WPI_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define WPI_WRITE_REGION_4(sc, offset, datap, count) \
bus_space_write_region_4((sc)->sc_st, (sc)->sc_sh, (offset), \
(datap), (count))

156
sys/dev/pci/if_wpivar.h Normal file
View File

@ -0,0 +1,156 @@
/* $NetBSD: if_wpivar.h,v 1.1 2006/08/13 02:21:45 simonb Exp $ */
/*-
* Copyright (c) 2006
* Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
struct wpi_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsft;
uint8_t wr_flags;
uint8_t wr_rate;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
int8_t wr_dbm_antsignal;
int8_t wr_dbm_antnoise;
uint8_t wr_antenna;
};
#define WPI_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
(1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
(1 << IEEE80211_RADIOTAP_ANTENNA))
struct wpi_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
uint8_t wt_flags;
uint8_t wt_rate;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
uint8_t wt_hwqueue;
};
#define WPI_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct wpi_dma_info {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_addr_t paddr;
caddr_t vaddr;
bus_size_t size;
};
struct wpi_tx_data {
bus_dmamap_t map;
struct mbuf *m;
struct ieee80211_node *ni;
};
struct wpi_tx_ring {
struct wpi_dma_info desc_dma;
struct wpi_dma_info cmd_dma;
struct wpi_tx_desc *desc;
struct wpi_tx_cmd *cmd;
struct wpi_tx_data *data;
int qid;
int count;
int queued;
int cur;
};
struct wpi_rx_data {
bus_dmamap_t map;
struct mbuf *m;
};
struct wpi_rx_ring {
struct wpi_dma_info desc_dma;
uint32_t *desc;
struct wpi_rx_data data[WPI_RX_RING_COUNT];
int cur;
};
struct wpi_amrr {
struct ieee80211_node ni; /* must be the first */
int txcnt;
int retrycnt;
int success;
int success_threshold;
int recovery;
};
struct wpi_softc {
struct device sc_dev;
struct ethercom sc_ec;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
uint32_t flags;
#define WPI_FLAG_FW_INITED (1 << 0)
bus_dma_tag_t sc_dmat;
/* shared area */
struct wpi_dma_info shared_dma;
struct wpi_shared *shared;
struct wpi_tx_ring txq[4];
struct wpi_tx_ring cmdq;
struct wpi_tx_ring svcq;
struct wpi_rx_ring rxq;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
void *sc_ih;
pci_chipset_tag_t sc_pct;
pcitag_t sc_pcitag;
bus_size_t sc_sz;
struct callout amrr_ch;
struct wpi_config config;
uint16_t pwr1[14];
uint16_t pwr2[14];
int sc_tx_timer;
void *powerhook;
#if NBPFILTER > 0
caddr_t sc_drvbpf;
union {
struct wpi_rx_radiotap_header th;
uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
} sc_rxtapu;
#define sc_rxtap sc_rxtapu.th
int sc_rxtap_len;
union {
struct wpi_tx_radiotap_header th;
uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
} sc_txtapu;
#define sc_txtap sc_txtapu.th
int sc_txtap_len;
#endif
};