Add malo(4)@pci driver for Marvell Libertas wireless adaptor
Ported from OpenBSD Known issues : - contrary to OpenBSD one, only support pci at the moment, because I don't have the necessary hardware to test PCMCIA / CARDUS Marvell Card - not connected to pmf(9) (unable to test it)
This commit is contained in:
parent
d19212c5d5
commit
aead3000b0
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1399 2012/07/19 09:06:33 rkujawa Exp $
|
||||
# $NetBSD: mi,v 1.1400 2012/07/30 18:57:17 degroote Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -1290,6 +1290,7 @@
|
|||
./usr/share/man/cat4/macppc/snapper.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/mainbus.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/makphy.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/malo.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/mbe.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/mc.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/mca.0 man-sys-catman .cat
|
||||
|
@ -4133,6 +4134,7 @@
|
|||
./usr/share/man/html4/macppc/snapper.html man-sys-htmlman html
|
||||
./usr/share/man/html4/mainbus.html man-sys-htmlman html
|
||||
./usr/share/man/html4/makphy.html man-sys-htmlman html
|
||||
./usr/share/man/html4/malo.html man-sys-htmlman html
|
||||
./usr/share/man/html4/mbe.html man-sys-htmlman html
|
||||
./usr/share/man/html4/mc.html man-sys-htmlman html
|
||||
./usr/share/man/html4/mca.html man-sys-htmlman html
|
||||
|
@ -6829,6 +6831,7 @@
|
|||
./usr/share/man/man4/macppc/snapper.4 man-sys-man .man
|
||||
./usr/share/man/man4/mainbus.4 man-sys-man .man
|
||||
./usr/share/man/man4/makphy.4 man-sys-man .man
|
||||
./usr/share/man/man4/malo.4 man-sys-man .man
|
||||
./usr/share/man/man4/mbe.4 man-sys-man .man
|
||||
./usr/share/man/man4/mc.4 man-sys-man .man
|
||||
./usr/share/man/man4/mca.4 man-sys-man .man
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.589 2012/07/19 08:57:09 rkujawa Exp $
|
||||
# $NetBSD: Makefile,v 1.590 2012/07/30 18:57:18 degroote Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/18/93
|
||||
|
||||
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
|
||||
|
@ -37,7 +37,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
|
|||
jme.4 jmide.4 joy.4 \
|
||||
kloader.4 kse.4 ksyms.4 kttcp.4 \
|
||||
lc.4 ld.4 lii.4 lo.4 lxtphy.4 \
|
||||
mainbus.4 makphy.4 mbe.4 mca.4 mcclock.4 md.4 mfb.4 mfi.4 mhzc.4 \
|
||||
mainbus.4 makphy.4 malo.4 mbe.4 mca.4 mcclock.4 md.4 mfb.4 mfi.4 mhzc.4 \
|
||||
midi.4 mii.4 mk48txx.4 mlx.4 mly.4 mpls.4 mpii.4 mpt.4 mpu.4 mtd.4 \
|
||||
mtio.4 multicast.4 mvsata.4 \
|
||||
nadb.4 ne.4 neo.4 netintro.4 nfe.4 nfsmb.4 njata.4 njs.4 \
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
.\" $NetBSD: malo.4,v 1.1 2012/07/30 18:57:18 degroote Exp $
|
||||
.\" $OpenBSD: malo.4,v 1.35 2010/11/01 17:59:09 jmc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2006 Theo de Raadt.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
|
||||
.\" COPYRIGHT HOLDERS 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 November 1, 2010 $
|
||||
.Dt MALO 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm malo
|
||||
.Nd Marvell Libertas IEEE 802.11b/g wireless network device
|
||||
.Sh SYNOPSIS
|
||||
.Cd "malo* at pci?"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for Marvell Libertas 88W8335/88W8310/88W8385 based
|
||||
PCI network adapters.
|
||||
The second generation 88W8335/88W8310 chipsets support 802.11b/g.
|
||||
.Pp
|
||||
These are the modes the
|
||||
.Nm
|
||||
driver can operate in:
|
||||
.Bl -tag -width "IBSS-masterXX"
|
||||
.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 IBSS mode
|
||||
.\" Also known as
|
||||
.\" .Em IEEE ad-hoc
|
||||
.\" mode or
|
||||
.\" .Em peer-to-peer
|
||||
.\" mode.
|
||||
.\" This is the standardized method of operating without an access point.
|
||||
.\" Stations associate with a service set.
|
||||
.\" However, actual connections between stations are peer-to-peer.
|
||||
.\" .It Host AP
|
||||
.\" In this mode the driver acts as an access point (base station)
|
||||
.\" for other cards.
|
||||
.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
|
||||
The
|
||||
.Nm
|
||||
driver can be configured to use
|
||||
Wired Equivalent Privacy (WEP) or
|
||||
Wi-Fi Protected Access (WPA-PSK and WPA2-PSK).
|
||||
WPA is the de facto encryption standard for wireless networks.
|
||||
It is strongly recommended that WEP
|
||||
not be used as the sole mechanism
|
||||
to secure wireless communication,
|
||||
due to serious weaknesses in it.
|
||||
The
|
||||
.Nm
|
||||
driver relies on the software 802.11 stack for both encryption and decryption
|
||||
of data frames.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver can be configured at runtime with
|
||||
.Xr ifconfig 8
|
||||
or on boot with
|
||||
.Xr ifconfig.if 5 .
|
||||
.Sh FILES
|
||||
The driver needs a set of firmware files which are loaded when
|
||||
an interface is brought up:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.It Pa /libdata/firmware/malo/malo8335-h
|
||||
.It Pa /libdata/firmware/malo/malo8335-m
|
||||
.It Pa /libdata/firmware/malo/malo8338
|
||||
.It Pa /libdata/firmware/malo/malo8385-h
|
||||
.It Pa /libdata/firmware/malo/malo8385-m
|
||||
.El
|
||||
.Pp
|
||||
These firmware files are not free because Marvell refuses
|
||||
to grant distribution rights.
|
||||
As a result, even though
|
||||
.Ox
|
||||
includes the driver, the firmware files cannot be included and
|
||||
users have to download these files on their own.
|
||||
.Pp
|
||||
A prepackaged version of the firmware, designed to be used with
|
||||
.Xr pkg_add 1 ,
|
||||
can be found at:
|
||||
.Bd -literal -offset 3n
|
||||
http://www.nazgul.ch/malo/malo-firmware-1.4.tgz
|
||||
.Ed
|
||||
.Sh HARDWARE
|
||||
The following cards are among those supported by the
|
||||
.Nm
|
||||
driver:
|
||||
.Pp
|
||||
.Bl -column -compact "Microcom Travelcard" "MALO111" "CardBus" "a/b/g" -offset 6n
|
||||
.It Em "Card Chip Bus Standard"
|
||||
.It Netgear WG311v3 88W8335 PCI b/g
|
||||
.It Tenda TWL542P 88W8335 PCI b/g
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
The following
|
||||
.Xr ifconfig.if 5
|
||||
example configures malo0 to join whatever network is available on boot,
|
||||
using WEP key
|
||||
.Dq 0x1deadbeef1 ,
|
||||
channel 11, obtaining an IP address using DHCP:
|
||||
.Bd -literal -offset indent
|
||||
dhcp NONE NONE NONE nwkey 0x1deadbeef1 chan 11
|
||||
.Ed
|
||||
.Pp
|
||||
.\"The following
|
||||
.\".Xr ifconfig.if 5
|
||||
.\"example creates a host-based access point on boot:
|
||||
.\".Bd -literal -offset indent
|
||||
.\"inet 192.168.1.1 255.255.255.0 NONE media autoselect \e
|
||||
.\" mediaopt hostap nwid my_net chan 11
|
||||
.\".Ed
|
||||
.\".Pp
|
||||
Join an existing BSS network,
|
||||
.Dq my_net :
|
||||
.Bd -literal -offset indent
|
||||
# ifconfig malo0 192.168.1.1 netmask 0xffffff00 nwid my_net
|
||||
.Ed
|
||||
.Sh NOTES
|
||||
Contrary to the driver on
|
||||
.Ox
|
||||
, this driver currently does not work on PCMCIA/CARDBUS.
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 4 ,
|
||||
.Xr ifmedia 4 ,
|
||||
.Xr intro 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr pci 4 ,
|
||||
.Xr ifconfig.if 5 ,
|
||||
.Xr hostapd 8 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was first written by
|
||||
.An Claudio Jeker Aq claudio@openbsd.org
|
||||
and
|
||||
.An Marcus Glocker Aq mglocker@openbsd.org
|
||||
and apparead first in
|
||||
.Ox 4.1 .
|
||||
.Nx
|
||||
porting was done by
|
||||
.An Arnaud Degroote Aq degroote@NetBSD.org
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files,v 1.1052 2012/07/26 20:49:47 jakllsch Exp $
|
||||
# $NetBSD: files,v 1.1053 2012/07/30 18:57:18 degroote Exp $
|
||||
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
|
||||
|
||||
version 20100430
|
||||
|
@ -649,6 +649,10 @@ device ral: arp, ether, ifnet, wlan, firmload
|
|||
file dev/ic/rt2560.c ral
|
||||
file dev/ic/rt2661.c ral
|
||||
|
||||
# Marvell Libertas Open
|
||||
device malo: arp, ether, ifnet, wlan, firmload
|
||||
file dev/ic/malo.c malo
|
||||
|
||||
# 3Com Etherlink-III Ethernet controller
|
||||
#
|
||||
device ep: arp, ether, ifnet, mii, mii_bitbang
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,119 @@
|
|||
/* $NetBSD: maloreg.h,v 1.1 2012/07/30 18:57:19 degroote Exp $ */
|
||||
/* $OpenBSD: if_maloreg.h,v 1.15 2007/10/08 22:08:12 mglocker Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
|
||||
*
|
||||
* 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 MALO_REG_INT_CODE 0x00000C14
|
||||
/* From host to ARM */
|
||||
#define MALO_REG_H2A_INTERRUPT_EVENTS 0x00000C18
|
||||
|
||||
/* bit definitions for MALO_REG_H2A_INTERRUPT_CAUSE */
|
||||
#define MALO_H2ARIC_BIT_PPA_READY 0x00000001
|
||||
#define MALO_H2ARIC_BIT_DOOR_BELL 0x00000002 /* bit 1 */
|
||||
#define MALO_H2ARIC_BIT_PS 0x00000004
|
||||
#define MALO_H2ARIC_BIT_PSPOLL 0x00000008 /* bit 3 */
|
||||
|
||||
/* From ARM to host */
|
||||
#define MALO_REG_A2H_INTERRUPT_CAUSE 0x00000C30
|
||||
#define MALO_REG_A2H_INTERRUPT_MASK 0x00000C34
|
||||
#define MALO_REG_A2H_INTERRUPT_CLEAR_SEL 0x00000C38
|
||||
#define MALO_REG_A2H_INTERRUPT_STATUS_MASK 0x00000C3C
|
||||
|
||||
/* bit definitions for MALO_REG_A2H_INTERRUPT_CAUSE */
|
||||
#define MALO_A2HRIC_BIT_TX_DONE 0x00000001 /* bit 0 */
|
||||
#define MALO_A2HRIC_BIT_RX_RDY 0x00000002 /* bit 1 */
|
||||
#define MALO_A2HRIC_BIT_OPC_DONE 0x00000004
|
||||
#define MALO_A2HRIC_BIT_MAC_EVENT 0x00000008
|
||||
#define MALO_A2HRIC_BIT_RX_PROBLEM 0x00000010
|
||||
#define MALO_A2HRIC_BIT_RADIO_OFF 0x00000020 /* bit 5 */
|
||||
#define MALO_A2HRIC_BIT_RADIO_ON 0x00000040
|
||||
#define MALO_A2HRIC_BIT_RADAR_DETECT 0x00000080
|
||||
#define MALO_A2HRIC_BIT_ICV_ERROR 0x00000100
|
||||
#define MALO_A2HRIC_BIT_MIC_ERROR 0x00000200 /* bit 9 */
|
||||
#define MALO_A2HRIC_BIT_QUEUE_EMPTY 0x00000400
|
||||
#define MALO_A2HRIC_BIT_QUEUE_FULL 0x00000800
|
||||
#define MALO_A2HRIC_BIT_CHAN_SWITCH 0x00001000
|
||||
#define MALO_A2HRIC_BIT_TX_WATCHDOG 0x00002000
|
||||
#define MALO_A2HRIC_BIT_BA_WATCHDOG 0x00004000
|
||||
|
||||
#define MALO_ISR_SRC_BITS \
|
||||
(MALO_A2HRIC_BIT_RX_RDY | \
|
||||
MALO_A2HRIC_BIT_TX_DONE | \
|
||||
MALO_A2HRIC_BIT_OPC_DONE | \
|
||||
MALO_A2HRIC_BIT_MAC_EVENT | \
|
||||
MALO_A2HRIC_BIT_MIC_ERROR | \
|
||||
MALO_A2HRIC_BIT_ICV_ERROR | \
|
||||
MALO_A2HRIC_BIT_RADAR_DETECT | \
|
||||
MALO_A2HRIC_BIT_CHAN_SWITCH | \
|
||||
MALO_A2HRIC_BIT_TX_WATCHDOG | \
|
||||
MALO_A2HRIC_BIT_QUEUE_EMPTY)
|
||||
#define MALO_ISR_RESET (1<<15)
|
||||
|
||||
#define MALO_A2HRIC_BIT_MASK MALO_ISR_SRC_BITS
|
||||
|
||||
/* map to 0x80000000 on BAR1 */
|
||||
#define MALO_REG_GEN_PTR 0x00000C10
|
||||
#define MALO_REG_INT_CODE 0x00000C14
|
||||
#define MALO_REG_SCRATCH 0x00000C40
|
||||
|
||||
/*
|
||||
* define OpMode for SoftAP/Station mode
|
||||
*
|
||||
* the following mode signature has to be written to PCI scratch register#0
|
||||
* right after successfully downloading the last block of firmware and
|
||||
* before waiting for firmware ready signature
|
||||
*/
|
||||
#define MALO_HOSTCMD_STA_MODE 0x5A
|
||||
#define MALO_HOSTCMD_STA_FWRDY_SIGNATURE 0xF0F1F2F4
|
||||
|
||||
/*
|
||||
* 16 bit host command code
|
||||
*/
|
||||
#define MALO_HOSTCMD_NONE 0x0000
|
||||
#define MALO_HOSTCMD_CODE_DNLD 0x0001
|
||||
#define MALO_HOSTCMD_GET_HW_SPEC 0x0003
|
||||
#define MALO_HOSTCMD_SET_HW_SPEC 0x0004
|
||||
#define MALO_HOSTCMD_MAC_MULTICAST_ADR 0x0010
|
||||
#define MALO_HOSTCMD_SET_WEPKEY 0x0013
|
||||
#define MALO_HOSTCMD_802_11_RADIO_CONTROL 0x001c
|
||||
#define MALO_HOSTCMD_802_11_RF_TX_POWER 0x001e
|
||||
#define MALO_HOSTCMD_802_11_RF_ANTENNA 0x0020
|
||||
#define MALO_HOSTCMD_SET_PRE_SCAN 0x0107
|
||||
#define MALO_HOSTCMD_SET_POST_SCAN 0x0108
|
||||
#define MALO_HOSTCMD_SET_RF_CHANNEL 0x010a
|
||||
#define MALO_HOSTCMD_SET_AID 0x010d
|
||||
#define MALO_HOSTCMD_SET_RATE 0x0110
|
||||
#define MALO_HOSTCMD_SET_SLOT 0x0114
|
||||
/* define DFS lab commands */
|
||||
#define MALO_HOSTCMD_SET_FIXED_RATE 0x0126
|
||||
#define MALO_HOSTCMD_SET_REGION_POWER 0x0128
|
||||
#define MALO_HOSTCMD_GET_CALTABLE 0x1134
|
||||
|
||||
/*
|
||||
* definition of action or option for each command.
|
||||
*/
|
||||
/* define general purpose action */
|
||||
#define MALO_HOSTCMD_ACT_GEN_GET 0x0000
|
||||
#define MALO_HOSTCMD_ACT_GEN_SET 0x0001
|
||||
#define MALO_HOSTCMD_ACT_GEN_SET_LIST 0x0002
|
||||
|
||||
/* define action or option for HostCmd_FW_USE_FIXED_RATE */
|
||||
#define MALO_HOSTCMD_ACT_USE_FIXED_RATE 0x0001
|
||||
#define MALO_HOSTCMD_ACT_NOT_USE_FIXED_RATE 0x0002
|
||||
|
||||
/* INT code register event definition */
|
||||
#define MALO_INT_CODE_CMD_FINISHED 0x00000005
|
|
@ -0,0 +1,131 @@
|
|||
/* $OpenBSD: malo.h,v 1.10 2010/08/08 16:36:33 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
|
||||
*
|
||||
* 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 MALO_DEBUG
|
||||
|
||||
struct malo_rx_desc;
|
||||
struct malo_rx_data;
|
||||
|
||||
struct malo_rx_ring {
|
||||
bus_dmamap_t map;
|
||||
bus_dma_segment_t seg;
|
||||
bus_addr_t physaddr;
|
||||
struct malo_rx_desc *desc;
|
||||
struct malo_rx_data *data;
|
||||
int count;
|
||||
int cur;
|
||||
int next;
|
||||
};
|
||||
|
||||
struct malo_tx_desc;
|
||||
struct malo_tx_data;
|
||||
|
||||
struct malo_tx_ring {
|
||||
bus_dmamap_t map;
|
||||
bus_dma_segment_t seg;
|
||||
bus_addr_t physaddr;
|
||||
struct malo_tx_desc *desc;
|
||||
struct malo_tx_data *data;
|
||||
int count;
|
||||
int queued;
|
||||
int cur;
|
||||
int next;
|
||||
int stat;
|
||||
};
|
||||
|
||||
// XXX Support for RSSI ?
|
||||
#define MALO_RX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL))
|
||||
|
||||
struct malo_rx_radiotap_hdr {
|
||||
struct ieee80211_radiotap_header wr_ihdr;
|
||||
uint8_t wr_flags;
|
||||
uint16_t wr_chan_freq;
|
||||
uint16_t wr_chan_flags;
|
||||
} __packed;
|
||||
|
||||
#define MALO_TX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_RATE) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL))
|
||||
|
||||
struct malo_tx_radiotap_hdr {
|
||||
struct ieee80211_radiotap_header wt_ihdr;
|
||||
uint8_t wt_flags;
|
||||
uint8_t wt_rate;
|
||||
uint16_t wt_chan_freq;
|
||||
uint16_t wt_chan_flags;
|
||||
} __packed;
|
||||
|
||||
struct malo_softc {
|
||||
device_t sc_dev;
|
||||
struct ethercom sc_ec;
|
||||
struct ieee80211com sc_ic;
|
||||
#define sc_if sc_ec.ec_if
|
||||
struct malo_rx_ring sc_rxring;
|
||||
struct malo_tx_ring sc_txring;
|
||||
|
||||
bus_dma_tag_t sc_dmat;
|
||||
bus_space_tag_t sc_mem1_bt;
|
||||
bus_space_tag_t sc_mem2_bt;
|
||||
bus_space_handle_t sc_mem1_bh;
|
||||
bus_space_handle_t sc_mem2_bh;
|
||||
|
||||
bus_dmamap_t sc_cmd_dmam;
|
||||
bus_dma_segment_t sc_cmd_dmas;
|
||||
void *sc_cmd_mem;
|
||||
bus_addr_t sc_cmd_dmaaddr;
|
||||
uint32_t *sc_cookie;
|
||||
bus_addr_t sc_cookie_dmaaddr;
|
||||
|
||||
uint32_t sc_RxPdWrPtr;
|
||||
uint32_t sc_RxPdRdPtr;
|
||||
|
||||
int (*sc_newstate)
|
||||
(struct ieee80211com *,
|
||||
enum ieee80211_state, int);
|
||||
|
||||
int (*sc_enable)(struct malo_softc *);
|
||||
void (*sc_disable)(struct malo_softc *);
|
||||
|
||||
struct callout sc_scan_to;
|
||||
int sc_tx_timer;
|
||||
int sc_last_txrate;
|
||||
|
||||
struct bpf_if * sc_drvbpf;
|
||||
|
||||
union {
|
||||
struct malo_rx_radiotap_hdr th;
|
||||
uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
|
||||
} sc_rxtapu;
|
||||
#define sc_rxtap sc_rxtapu.th
|
||||
int sc_rxtap_len;
|
||||
|
||||
union {
|
||||
struct malo_tx_radiotap_hdr th;
|
||||
uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
|
||||
} sc_txtapu;
|
||||
#define sc_txtap sc_txtapu.th
|
||||
int sc_txtap_len;
|
||||
};
|
||||
|
||||
int malo_intr(void *arg);
|
||||
int malo_attach(struct malo_softc *sc);
|
||||
int malo_detach(void *arg);
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.pci,v 1.358 2012/07/18 23:30:13 rkujawa Exp $
|
||||
# $NetBSD: files.pci,v 1.359 2012/07/30 18:57:19 degroote Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent PCI code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -778,6 +778,10 @@ file dev/pci/if_rtw_pci.c rtw_pci
|
|||
attach ral at pci with ral_pci
|
||||
file dev/pci/if_ral_pci.c ral_pci
|
||||
|
||||
# Marvel Libertas Open
|
||||
attach malo at pci with malo_pci
|
||||
file dev/pci/if_malo_pci.c malo_pci
|
||||
|
||||
# Intersil Prism2.5 Mini-PCI
|
||||
attach wi at pci with wi_pci
|
||||
file dev/pci/if_wi_pci.c wi_pci
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/* $OpenBSD: if_malo_pci.c,v 1.6 2010/08/28 23:19:29 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PCI front-end for the Marvell Libertas
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net80211/ieee80211_var.h>
|
||||
#include <net80211/ieee80211_radiotap.h>
|
||||
|
||||
#include <dev/ic/malovar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
/* Base Address Register */
|
||||
#define MALO_PCI_BAR1 0x10
|
||||
#define MALO_PCI_BAR2 0x14
|
||||
|
||||
static int malo_pci_match(device_t parent, cfdata_t match, void *aux);
|
||||
static void malo_pci_attach(device_t, device_t, void *);
|
||||
static int malo_pci_detach(struct device *, int);
|
||||
|
||||
struct malo_pci_softc {
|
||||
struct malo_softc sc_malo;
|
||||
|
||||
pci_chipset_tag_t sc_pc;
|
||||
void *sc_ih;
|
||||
|
||||
bus_size_t sc_mapsize1;
|
||||
bus_size_t sc_mapsize2;
|
||||
};
|
||||
|
||||
CFATTACH_DECL_NEW(malo_pci, sizeof(struct malo_pci_softc),
|
||||
malo_pci_match, malo_pci_attach, malo_pci_detach, NULL);
|
||||
|
||||
static int
|
||||
malo_pci_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_MARVELL)
|
||||
return (0);
|
||||
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_MARVELL_88W8310:
|
||||
case PCI_PRODUCT_MARVELL_88W8335_1:
|
||||
case PCI_PRODUCT_MARVELL_88W8335_2:
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
malo_pci_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct malo_pci_softc *psc = device_private(self);
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct malo_softc *sc = &psc->sc_malo;
|
||||
const char *intrstr = NULL;
|
||||
pci_intr_handle_t ih;
|
||||
pcireg_t memtype1, memtype2;
|
||||
int error;
|
||||
|
||||
sc->sc_dev = self;
|
||||
sc->sc_dmat = pa->pa_dmat;
|
||||
psc->sc_pc = pa->pa_pc;
|
||||
|
||||
aprint_normal("\n");
|
||||
aprint_normal_dev(self,"Marvell Libertas Wireless\n");
|
||||
|
||||
/* map control / status registers */
|
||||
memtype1 = pci_mapreg_type(pa->pa_pc, pa->pa_tag, MALO_PCI_BAR1);
|
||||
switch (memtype1) {
|
||||
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
|
||||
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
|
||||
break;
|
||||
default:
|
||||
aprint_error_dev(self, "invalid base address register\n");
|
||||
return;
|
||||
}
|
||||
|
||||
error = pci_mapreg_map(pa, MALO_PCI_BAR1,
|
||||
memtype1, 0, &sc->sc_mem1_bt, &sc->sc_mem1_bh,
|
||||
NULL, &psc->sc_mapsize1);
|
||||
if (error != 0) {
|
||||
aprint_error_dev(self, "can't map 1st mem space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* map control / status registers */
|
||||
memtype2 = pci_mapreg_type(pa->pa_pc, pa->pa_tag, MALO_PCI_BAR1);
|
||||
switch (memtype2) {
|
||||
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
|
||||
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
|
||||
break;
|
||||
default:
|
||||
aprint_error_dev(self, "invalid base address register\n");
|
||||
return;
|
||||
}
|
||||
|
||||
error = pci_mapreg_map(pa, MALO_PCI_BAR2,
|
||||
memtype2, 0, &sc->sc_mem2_bt, &sc->sc_mem2_bh,
|
||||
NULL, &psc->sc_mapsize2);
|
||||
if (error != 0) {
|
||||
aprint_error_dev(self, "can't map 2nd mem space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* map interrupt */
|
||||
if (pci_intr_map(pa, &ih) != 0) {
|
||||
aprint_error_dev(self, "can't map interrupt\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* establish interrupt */
|
||||
intrstr = pci_intr_string(psc->sc_pc, ih);
|
||||
psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, malo_intr, sc);
|
||||
if (psc->sc_ih == NULL) {
|
||||
aprint_error_dev(self, "could not establish interrupt");
|
||||
if (intrstr != NULL)
|
||||
aprint_error(" at %s", intrstr);
|
||||
aprint_error("\n");
|
||||
return;
|
||||
}
|
||||
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
|
||||
|
||||
malo_attach(sc);
|
||||
}
|
||||
|
||||
int
|
||||
malo_pci_detach(struct device *self, int flags)
|
||||
{
|
||||
struct malo_pci_softc *psc = (struct malo_pci_softc *)self;
|
||||
struct malo_softc *sc = &psc->sc_malo;
|
||||
|
||||
malo_detach(sc);
|
||||
pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
|
||||
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue