Home | History | Annotate | Line # | Download | only in ic
rt2661var.h revision 1.2
      1 /*	$NetBSD: rt2661var.h,v 1.2 2006/06/06 20:48:27 rpaulo Exp $	*/
      2 /*	$OpenBSD: rt2661var.h,v 1.4 2006/02/25 12:56:47 damien Exp $	*/
      3 
      4 /*-
      5  * Copyright (c) 2006
      6  *	Damien Bergamini <damien.bergamini (at) free.fr>
      7  *
      8  * Permission to use, copy, modify, and distribute this software for any
      9  * purpose with or without fee is hereby granted, provided that the above
     10  * copyright notice and this permission notice appear in all copies.
     11  *
     12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19  */
     20 
     21 struct rt2661_rx_radiotap_header {
     22 	struct ieee80211_radiotap_header wr_ihdr;
     23 	uint64_t	wr_tsf;
     24 	uint8_t		wr_flags;
     25 	uint8_t		_pad;
     26 	uint8_t		wr_rate;
     27 	uint16_t	wr_chan_freq;
     28 	uint16_t	wr_chan_flags;
     29 	uint8_t		wr_antsignal;
     30 } __packed;
     31 
     32 #define RT2661_RX_RADIOTAP_PRESENT					\
     33 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
     34 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
     35 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     36 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     37 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
     38 
     39 struct rt2661_tx_radiotap_header {
     40 	struct ieee80211_radiotap_header wt_ihdr;
     41 	uint8_t		wt_flags;
     42 	uint8_t		wt_rate;
     43 	uint16_t	wt_chan_freq;
     44 	uint16_t	wt_chan_flags;
     45 } __packed;
     46 
     47 #define RT2661_TX_RADIOTAP_PRESENT					\
     48 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     49 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     50 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
     51 
     52 struct rt2661_tx_data {
     53 	bus_dmamap_t			map;
     54 	struct mbuf			*m;
     55 	struct ieee80211_node		*ni;
     56 	struct ieee80211_rssdesc	id;
     57 };
     58 
     59 struct rt2661_tx_ring {
     60 	bus_dmamap_t		map;
     61 	bus_dma_segment_t	seg;
     62 	bus_addr_t		physaddr;
     63 	struct rt2661_tx_desc	*desc;
     64 	struct rt2661_tx_data	*data;
     65 	int			count;
     66 	int			queued;
     67 	int			cur;
     68 	int			next;
     69 	int			stat;
     70 };
     71 
     72 struct rt2661_rx_data {
     73 	bus_dmamap_t	map;
     74 	struct mbuf	*m;
     75 };
     76 
     77 struct rt2661_rx_ring {
     78 	bus_dmamap_t		map;
     79 	bus_dma_segment_t	seg;
     80 	bus_addr_t		physaddr;
     81 	struct rt2661_rx_desc	*desc;
     82 	struct rt2661_rx_data	*data;
     83 	int			count;
     84 	int			cur;
     85 	int			next;
     86 };
     87 
     88 struct rt2661_node {
     89 	struct ieee80211_node		ni;
     90 	struct ieee80211_rssadapt	rssadapt;
     91 };
     92 
     93 struct rt2661_softc {
     94 	struct device			sc_dev;
     95 
     96 	struct ieee80211com		sc_ic;
     97 	int				(*sc_newstate)(struct ieee80211com *,
     98 					    enum ieee80211_state, int);
     99 
    100 	int				(*sc_enable)(struct rt2661_softc *);
    101 	void				(*sc_disable)(struct rt2661_softc *);
    102 	void				(*sc_power)(struct rt2661_softc *, int);
    103 
    104 	bus_dma_tag_t			sc_dmat;
    105 	bus_space_tag_t			sc_st;
    106 	bus_space_handle_t		sc_sh;
    107 
    108 	struct ethercom			sc_ec;
    109 
    110 	struct callout			scan_ch;
    111 	struct callout			rssadapt_ch;
    112 
    113 	int				sc_id;
    114 	int				sc_flags;
    115 #define RT2661_ENABLED	(1 << 0)
    116 #define RT2661_FWLOADED	(1 << 1)
    117 
    118 	int				sc_tx_timer;
    119 
    120 	struct ieee80211_channel	*sc_curchan;
    121 
    122 	uint8_t				rf_rev;
    123 
    124 	uint8_t				rfprog;
    125 	uint8_t				rffreq;
    126 
    127 	struct rt2661_tx_ring		txq[5];
    128 	struct rt2661_tx_ring		mgtq;
    129 	struct rt2661_rx_ring		rxq;
    130 
    131 	uint32_t			rf_regs[4];
    132 	int8_t				txpow[38];
    133 
    134 	struct {
    135 		uint8_t	reg;
    136 		uint8_t	val;
    137 	}				bbp_prom[16];
    138 
    139 	int				hw_radio;
    140 	int				rx_ant;
    141 	int				tx_ant;
    142 	int				nb_ant;
    143 	int				ext_2ghz_lna;
    144 	int				ext_5ghz_lna;
    145 	int				rssi_2ghz_corr;
    146 	int				rssi_5ghz_corr;
    147 
    148 	uint8_t				bbp18;
    149 	uint8_t				bbp21;
    150 	uint8_t				bbp22;
    151 	uint8_t				bbp16;
    152 	uint8_t				bbp17;
    153 	uint8_t				bbp64;
    154 
    155 #if NBPFILTER > 0
    156 	caddr_t			sc_drvbpf;
    157 
    158 	union {
    159 		struct rt2661_rx_radiotap_header th;
    160 		uint8_t	pad[64];
    161 	}			sc_rxtapu;
    162 #define sc_rxtap		sc_rxtapu.th
    163 	int			sc_rxtap_len;
    164 
    165 	union {
    166 		struct rt2661_tx_radiotap_header th;
    167 		uint8_t	pad[64];
    168 	}			sc_txtapu;
    169 #define sc_txtap		sc_txtapu.th
    170 	int			sc_txtap_len;
    171 #endif
    172 };
    173 
    174 #define	sc_if		sc_ec.ec_if
    175 
    176 int	rt2661_attach(void *, int);
    177 int	rt2661_detach(void *);
    178 int	rt2661_intr(void *);
    179