Home | History | Annotate | Line # | Download | only in pci
if_ipwvar.h revision 1.12
      1 /*	$NetBSD: if_ipwvar.h,v 1.12 2007/12/09 20:28:09 jmcneill Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2004
      5  *      Damien Bergamini <damien.bergamini (at) free.fr>. All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice unmodified, this list of conditions, and the following
     12  *    disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27  * SUCH DAMAGE.
     28  */
     29 
     30 struct ipw_firmware {
     31 	void	*main;
     32 	int	main_size;
     33 	void	*ucode;
     34 	int	ucode_size;
     35 };
     36 
     37 #define IPW_MAX_NSEG	1
     38 
     39 struct ipw_soft_bd {
     40 	struct ipw_bd	*bd;
     41 	int		type;
     42 #define IPW_SBD_TYPE_NOASSOC	0
     43 #define IPW_SBD_TYPE_COMMAND	1
     44 #define IPW_SBD_TYPE_HEADER	2
     45 #define IPW_SBD_TYPE_DATA	3
     46 	void		*priv;
     47 };
     48 
     49 struct ipw_soft_hdr {
     50 	struct ipw_hdr			*hdr;
     51 	bus_addr_t			addr;
     52 	bus_addr_t			offset;
     53 	TAILQ_ENTRY(ipw_soft_hdr)	next;
     54 };
     55 
     56 struct ipw_soft_buf {
     57 	struct mbuf			*m;
     58 	struct ieee80211_node		*ni;
     59 	bus_dmamap_t			map;
     60 	TAILQ_ENTRY(ipw_soft_buf)	next;
     61 };
     62 
     63 struct ipw_rx_radiotap_header {
     64 	struct ieee80211_radiotap_header wr_ihdr;
     65 	uint8_t		wr_flags;
     66 	uint16_t	wr_chan_freq;
     67 	uint16_t	wr_chan_flags;
     68 	uint8_t		wr_antsignal;
     69 };
     70 
     71 #define IPW_RX_RADIOTAP_PRESENT						\
     72 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     73 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     74 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
     75 
     76 struct ipw_tx_radiotap_header {
     77 	struct ieee80211_radiotap_header wt_ihdr;
     78 	uint8_t		wt_flags;
     79 	uint16_t	wt_chan_freq;
     80 	uint16_t	wt_chan_flags;
     81 };
     82 
     83 #define IPW_TX_RADIOTAP_PRESENT						\
     84 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     85 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
     86 
     87 struct ipw_softc {
     88 	struct device			sc_dev;
     89 
     90 	struct ethercom			sc_ec;
     91 	struct ieee80211com		sc_ic;
     92 	int				(*sc_newstate)(struct ieee80211com *,
     93 					    enum ieee80211_state, int);
     94 
     95 	struct ipw_firmware		fw;
     96 	char				sc_fwname[24];
     97 	uint32_t			flags;
     98 #define IPW_FLAG_FW_CACHED		(1 << 0)
     99 #define IPW_FLAG_FW_INITED		(1 << 1)
    100 #define IPW_FLAG_HAS_RADIO_SWITCH	(1 << 2)
    101 #define	IPW_FLAG_FW_WARNED		(1 << 3)
    102 
    103 	struct resource			*irq;
    104 	struct resource			*mem;
    105 	bus_space_tag_t			sc_st;
    106 	bus_space_handle_t		sc_sh;
    107 	void				*sc_ih;
    108 	pci_chipset_tag_t		sc_pct;
    109 	pcitag_t			sc_pcitag;
    110 	bus_size_t			sc_sz;
    111 
    112 	int				sc_tx_timer;
    113 
    114 	bus_dma_tag_t			sc_dmat;
    115 
    116 	bus_dmamap_t			tbd_map;
    117 	bus_dmamap_t			rbd_map;
    118 	bus_dmamap_t			status_map;
    119 	bus_dmamap_t			cmd_map;
    120 	bus_dmamap_t			hdr_map;
    121 
    122 	bus_dma_segment_t		tbd_seg;
    123 	bus_dma_segment_t		rbd_seg;
    124 	bus_dma_segment_t		status_seg;
    125 	bus_dma_segment_t		cmd_seg;
    126 	bus_dma_segment_t		hdr_seg;
    127 
    128 	struct ipw_bd			*tbd_list;
    129 	struct ipw_bd			*rbd_list;
    130 	struct ipw_status		*status_list;
    131 	struct ipw_hdr			*hdr_list;
    132 
    133 	struct ipw_cmd			cmd;
    134 	struct ipw_soft_bd		stbd_list[IPW_NTBD];
    135 	struct ipw_soft_buf		tx_sbuf_list[IPW_NDATA];
    136 	struct ipw_soft_bd		srbd_list[IPW_NRBD];
    137 	struct ipw_soft_buf		rx_sbuf_list[IPW_NRBD];
    138 	struct ipw_soft_hdr		shdr_list[IPW_NDATA];
    139 
    140 	TAILQ_HEAD(, ipw_soft_hdr)	sc_free_shdr;
    141 	TAILQ_HEAD(, ipw_soft_buf)	sc_free_sbuf;
    142 
    143 	uint32_t			table1_base;
    144 	uint32_t			table2_base;
    145 
    146 	uint32_t			txcur;
    147 	uint32_t			txold;
    148 	uint32_t			rxcur;
    149 	int				txfree;
    150 
    151 	int				dwelltime;
    152 
    153 #if NBPFILTER > 0
    154 	struct bpf_if			*sc_drvbpf;
    155 
    156 	union {
    157 		struct ipw_rx_radiotap_header th;
    158 		uint8_t	pad[64];
    159 	} sc_rxtapu;
    160 #define sc_rxtap	sc_rxtapu.th
    161 	int				sc_rxtap_len;
    162 
    163 	union {
    164 		struct ipw_tx_radiotap_header th;
    165 		uint8_t	pad[64];
    166 	} sc_txtapu;
    167 #define sc_txtap	sc_txtapu.th
    168 	int				sc_txtap_len;
    169 #endif
    170 };
    171 
    172 #define	sc_if	sc_ec.ec_if
    173 
    174 #define SIOCGRADIO	_IOWR('i', 139, struct ifreq)
    175 #define SIOCGTABLE1	_IOWR('i', 140, struct ifreq)
    176