Home | History | Annotate | Line # | Download | only in usb
      1 /*	$NetBSD: if_rumvar.h,v 1.12 2020/03/15 23:04:50 thorpej Exp $	*/
      2 /*	$OpenBSD: if_rumvar.h,v 1.7 2006/11/13 20:06:38 damien Exp $	*/
      3 
      4 /*-
      5  * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini (at) free.fr>
      6  * Copyright (c) 2006 Niall O'Higgins <niallo (at) openbsd.org>
      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 #define RUM_RX_LIST_COUNT	1
     22 #define RUM_TX_LIST_COUNT	8
     23 
     24 struct rum_rx_radiotap_header {
     25 	struct ieee80211_radiotap_header wr_ihdr;
     26 	uint8_t		wr_flags;
     27 	uint8_t		wr_rate;
     28 	uint16_t	wr_chan_freq;
     29 	uint16_t	wr_chan_flags;
     30 	uint8_t		wr_antenna;
     31 	uint8_t		wr_antsignal;
     32 };
     33 
     34 #define RT2573_RX_RADIOTAP_PRESENT					\
     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 rum_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 };
     49 
     50 #define RT2573_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 rum_softc;
     57 
     58 struct rum_tx_data {
     59 	struct rum_softc	*sc;
     60 	struct usbd_xfer	*xfer;
     61 	uint8_t			*buf;
     62 	struct mbuf		*m;
     63 	struct ieee80211_node	*ni;
     64 };
     65 
     66 struct rum_rx_data {
     67 	struct rum_softc	*sc;
     68 	struct usbd_xfer	*xfer;
     69 	uint8_t			*buf;
     70 	struct mbuf		*m;
     71 };
     72 
     73 struct rum_softc {
     74 	device_t			sc_dev;
     75 	struct ethercom			sc_ec;
     76 #define sc_if	sc_ec.ec_if
     77 	struct ieee80211com		sc_ic;
     78 	int				(*sc_newstate)(struct ieee80211com *,
     79 					    enum ieee80211_state, int);
     80 
     81 	kmutex_t			sc_media_mtx;	/* XXX */
     82 
     83 	struct usbd_device *		sc_udev;
     84 	struct usbd_interface *		sc_iface;
     85 	int				sc_flags;
     86 #define	RT2573_FWLOADED	(1 << 0)
     87 
     88 	struct ieee80211_channel	*sc_curchan;
     89 
     90 	int				sc_rx_no;
     91 	int				sc_tx_no;
     92 
     93 	uint16_t			macbbp_rev;
     94 	uint8_t				rf_rev;
     95 	uint8_t				rffreq;
     96 
     97 	struct usbd_xfer *		amrr_xfer;
     98 
     99 	struct usbd_pipe *		sc_rx_pipeh;
    100 	struct usbd_pipe *		sc_tx_pipeh;
    101 
    102 	enum ieee80211_state		sc_state;
    103 	int				sc_arg;
    104 	struct usb_task			sc_task;
    105 
    106 	struct ieee80211_amrr		amrr;
    107 	struct ieee80211_amrr_node	amn;
    108 
    109 	struct rum_rx_data		rx_data[RUM_RX_LIST_COUNT];
    110 	struct rum_tx_data		tx_data[RUM_TX_LIST_COUNT];
    111 	int				tx_queued;
    112 	int				tx_cur;
    113 
    114 	struct ieee80211_beacon_offsets	sc_bo;
    115 
    116 	struct callout			sc_scan_ch;
    117 	struct callout			sc_amrr_ch;
    118 
    119 	int				sc_tx_timer;
    120 
    121 	uint32_t			sta[6];
    122 	uint32_t			rf_regs[4];
    123 	uint8_t				txpow[44];
    124 
    125 	struct {
    126 		uint8_t	val;
    127 		uint8_t	reg;
    128 	} __packed			bbp_prom[16];
    129 
    130 	int				hw_radio;
    131 	int				rx_ant;
    132 	int				tx_ant;
    133 	int				nb_ant;
    134 	int				ext_2ghz_lna;
    135 	int				ext_5ghz_lna;
    136 	int				rssi_2ghz_corr;
    137 	int				rssi_5ghz_corr;
    138 	int				sifs;
    139 	uint8_t				bbp17;
    140 
    141 	struct bpf_if *			sc_drvbpf;
    142 
    143 	union {
    144 		struct rum_rx_radiotap_header th;
    145 		uint8_t	pad[64];
    146 	}				sc_rxtapu;
    147 #define sc_rxtap	sc_rxtapu.th
    148 	int				sc_rxtap_len;
    149 
    150 	union {
    151 		struct rum_tx_radiotap_header th;
    152 		uint8_t	pad[64];
    153 	}				sc_txtapu;
    154 #define sc_txtap	sc_txtapu.th
    155 	int				sc_txtap_len;
    156 };
    157