Home | History | Annotate | Line # | Download | only in ic
rt2560var.h revision 1.2
      1 /*	$NetBSD: rt2560var.h,v 1.2 2006/06/06 20:48:27 rpaulo Exp $	*/
      2 /*	$OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $  */
      3 
      4 /*-
      5  * Copyright (c) 2005, 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 rt2560_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_antenna;
     30 	uint8_t		wr_antsignal;
     31 } __packed;
     32 
     33 #define RT2560_RX_RADIOTAP_PRESENT					\
     34 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
     35 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
     36 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     37 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     38 	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
     39 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
     40 
     41 struct rt2560_tx_radiotap_header {
     42 	struct ieee80211_radiotap_header wt_ihdr;
     43 	uint8_t		wt_flags;
     44 	uint8_t		wt_rate;
     45 	uint16_t	wt_chan_freq;
     46 	uint16_t	wt_chan_flags;
     47 	uint8_t		wt_antenna;
     48 } __packed;
     49 
     50 #define RT2560_TX_RADIOTAP_PRESENT					\
     51 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     52 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     53 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     54 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
     55 
     56 struct rt2560_tx_data {
     57 	bus_dmamap_t			map;
     58 	struct mbuf			*m;
     59 	struct ieee80211_node		*ni;
     60 	struct ieee80211_rssdesc	id;
     61 };
     62 
     63 struct rt2560_tx_ring {
     64 	bus_dmamap_t		map;
     65 	bus_dma_segment_t	seg;
     66 	bus_addr_t		physaddr;
     67 	struct rt2560_tx_desc	*desc;
     68 	struct rt2560_tx_data	*data;
     69 	int			count;
     70 	int			queued;
     71 	int			cur;
     72 	int			next;
     73 	int			cur_encrypt;
     74 	int			next_encrypt;
     75 };
     76 
     77 struct rt2560_rx_data {
     78 	bus_dmamap_t	map;
     79 	struct mbuf	*m;
     80 	int		drop;
     81 };
     82 
     83 struct rt2560_rx_ring {
     84 	bus_dmamap_t		map;
     85 	bus_dma_segment_t	seg;
     86 	bus_addr_t		physaddr;
     87 	struct rt2560_rx_desc	*desc;
     88 	struct rt2560_rx_data	*data;
     89 	int			count;
     90 	int			cur;
     91 	int			next;
     92 	int			cur_decrypt;
     93 };
     94 
     95 struct rt2560_node {
     96 	struct ieee80211_node		ni;
     97 	struct ieee80211_rssadapt	rssadapt;
     98 };
     99 
    100 struct rt2560_softc {
    101 	struct device		sc_dev;
    102 
    103 	struct ieee80211com	sc_ic;
    104 	int			(*sc_newstate)(struct ieee80211com *,
    105 				    enum ieee80211_state, int);
    106 
    107 	int			(*sc_enable)(struct rt2560_softc *);
    108 	void			(*sc_disable)(struct rt2560_softc *);
    109 	void			(*sc_power)(struct rt2560_softc *, int);
    110 
    111 	bus_dma_tag_t		sc_dmat;
    112 	bus_space_tag_t		sc_st;
    113 	bus_space_handle_t	sc_sh;
    114 
    115 	struct sysctllog	*sc_sysctllog;
    116 
    117 	struct ethercom		sc_ec;
    118 
    119 	struct callout		scan_ch;
    120 	struct callout		rssadapt_ch;
    121 
    122 	int			sc_flags;
    123 #define RT2560_ENABLED	(1 << 0)
    124 
    125 	int			sc_tx_timer;
    126 
    127 	uint32_t		asic_rev;
    128 	uint8_t			rf_rev;
    129 
    130 	struct rt2560_tx_ring	txq;
    131 	struct rt2560_tx_ring	prioq;
    132 	struct rt2560_tx_ring	atimq;
    133 	struct rt2560_tx_ring	bcnq;
    134 	struct rt2560_rx_ring	rxq;
    135 
    136 	struct ieee80211_beacon_offsets	sc_bo;
    137 
    138 	uint32_t		rf_regs[4];
    139 	uint8_t			txpow[14];
    140 
    141 	struct {
    142 		uint8_t	reg;
    143 		uint8_t	val;
    144 	}			bbp_prom[16];
    145 
    146 	int			led_mode;
    147 	int			hw_radio;
    148 	int			rx_ant;
    149 	int			tx_ant;
    150 	int			nb_ant;
    151 
    152 	int			dwelltime;
    153 
    154 #if NBPFILTER > 0
    155 	caddr_t			sc_drvbpf;
    156 
    157 	union {
    158 		struct rt2560_rx_radiotap_header th;
    159 		uint8_t	pad[64];
    160 	}			sc_rxtapu;
    161 #define sc_rxtap		sc_rxtapu.th
    162 	int			sc_rxtap_len;
    163 
    164 	union {
    165 		struct rt2560_tx_radiotap_header th;
    166 		uint8_t	pad[64];
    167 	}			sc_txtapu;
    168 #define sc_txtap		sc_txtapu.th
    169 	int			sc_txtap_len;
    170 #endif
    171 };
    172 
    173 #define	sc_if		sc_ec.ec_if
    174 
    175 int	rt2560_attach(void *, int);
    176 int	rt2560_detach(void *);
    177 int	rt2560_intr(void *);
    178