if_rumvar.h revision 287197
1188417Sthompsa/* $FreeBSD: head/sys/dev/usb/wlan/if_rumvar.h 287197 2015-08-27 08:56:39Z glebius $ */ 2184610Salfred 3184610Salfred/*- 4184610Salfred * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr> 5184610Salfred * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org> 6184610Salfred * 7184610Salfred * Permission to use, copy, modify, and distribute this software for any 8184610Salfred * purpose with or without fee is hereby granted, provided that the above 9184610Salfred * copyright notice and this permission notice appear in all copies. 10184610Salfred * 11184610Salfred * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12184610Salfred * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13184610Salfred * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14184610Salfred * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15184610Salfred * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16184610Salfred * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17184610Salfred * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18184610Salfred */ 19184610Salfred 20188417Sthompsa#define RUM_TX_LIST_COUNT 8 21188969Sthompsa#define RUM_TX_MINFREE 2 22184610Salfred 23184610Salfredstruct rum_rx_radiotap_header { 24184610Salfred struct ieee80211_radiotap_header wr_ihdr; 25188417Sthompsa uint8_t wr_flags; 26188417Sthompsa uint8_t wr_rate; 27188417Sthompsa uint16_t wr_chan_freq; 28188417Sthompsa uint16_t wr_chan_flags; 29192468Ssam int8_t wr_antsignal; 30192468Ssam int8_t wr_antnoise; 31188417Sthompsa uint8_t wr_antenna; 32253757Shselasky} __packed __aligned(8); 33184610Salfred 34188417Sthompsa#define RT2573_RX_RADIOTAP_PRESENT \ 35184610Salfred ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 36184610Salfred (1 << IEEE80211_RADIOTAP_RATE) | \ 37184610Salfred (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 38192468Ssam (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 39192468Ssam (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ 40184610Salfred (1 << IEEE80211_RADIOTAP_ANTENNA) | \ 41192468Ssam 0) 42184610Salfred 43184610Salfredstruct rum_tx_radiotap_header { 44184610Salfred struct ieee80211_radiotap_header wt_ihdr; 45188417Sthompsa uint8_t wt_flags; 46188417Sthompsa uint8_t wt_rate; 47188417Sthompsa uint16_t wt_chan_freq; 48188417Sthompsa uint16_t wt_chan_flags; 49188417Sthompsa uint8_t wt_antenna; 50253757Shselasky} __packed __aligned(8); 51184610Salfred 52188417Sthompsa#define RT2573_TX_RADIOTAP_PRESENT \ 53184610Salfred ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 54184610Salfred (1 << IEEE80211_RADIOTAP_RATE) | \ 55184610Salfred (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 56184610Salfred (1 << IEEE80211_RADIOTAP_ANTENNA)) 57184610Salfred 58188417Sthompsastruct rum_softc; 59184610Salfred 60188417Sthompsastruct rum_tx_data { 61188417Sthompsa STAILQ_ENTRY(rum_tx_data) next; 62188417Sthompsa struct rum_softc *sc; 63188417Sthompsa struct rum_tx_desc desc; 64188417Sthompsa struct mbuf *m; 65188417Sthompsa struct ieee80211_node *ni; 66188417Sthompsa int rate; 67188417Sthompsa}; 68188417Sthompsatypedef STAILQ_HEAD(, rum_tx_data) rum_txdhead; 69188417Sthompsa 70188417Sthompsastruct rum_vap { 71188417Sthompsa struct ieee80211vap vap; 72188417Sthompsa struct ieee80211_beacon_offsets bo; 73206358Srpaulo struct usb_callout ratectl_ch; 74206358Srpaulo struct task ratectl_task; 75188417Sthompsa 76188417Sthompsa int (*newstate)(struct ieee80211vap *, 77188417Sthompsa enum ieee80211_state, int); 78188417Sthompsa}; 79188417Sthompsa#define RUM_VAP(vap) ((struct rum_vap *)(vap)) 80188417Sthompsa 81187259Sthompsaenum { 82188417Sthompsa RUM_BULK_WR, 83188417Sthompsa RUM_BULK_RD, 84188417Sthompsa RUM_N_TRANSFER = 2, 85187259Sthompsa}; 86187259Sthompsa 87184610Salfredstruct rum_softc { 88287197Sglebius struct ieee80211com sc_ic; 89287197Sglebius struct mbufq sc_snd; 90188417Sthompsa device_t sc_dev; 91192984Sthompsa struct usb_device *sc_udev; 92184610Salfred 93192984Sthompsa struct usb_xfer *sc_xfer[RUM_N_TRANSFER]; 94184610Salfred 95188417Sthompsa uint8_t rf_rev; 96188417Sthompsa uint8_t rffreq; 97184610Salfred 98188419Sthompsa struct rum_tx_data tx_data[RUM_TX_LIST_COUNT]; 99188417Sthompsa rum_txdhead tx_q; 100188417Sthompsa rum_txdhead tx_free; 101188417Sthompsa int tx_nfree; 102188417Sthompsa struct rum_rx_desc sc_rx_desc; 103184610Salfred 104188417Sthompsa struct mtx sc_mtx; 105184610Salfred 106188417Sthompsa uint32_t sta[6]; 107188417Sthompsa uint32_t rf_regs[4]; 108188417Sthompsa uint8_t txpow[44]; 109287197Sglebius u_int sc_detached:1, 110287197Sglebius sc_running:1; 111184610Salfred 112188417Sthompsa struct { 113188417Sthompsa uint8_t val; 114188417Sthompsa uint8_t reg; 115188417Sthompsa } __packed bbp_prom[16]; 116188417Sthompsa 117188417Sthompsa int hw_radio; 118188417Sthompsa int rx_ant; 119188417Sthompsa int tx_ant; 120188417Sthompsa int nb_ant; 121188417Sthompsa int ext_2ghz_lna; 122188417Sthompsa int ext_5ghz_lna; 123188417Sthompsa int rssi_2ghz_corr; 124188417Sthompsa int rssi_5ghz_corr; 125188417Sthompsa uint8_t bbp17; 126188417Sthompsa 127188417Sthompsa struct rum_rx_radiotap_header sc_rxtap; 128188417Sthompsa int sc_rxtap_len; 129188417Sthompsa 130188417Sthompsa struct rum_tx_radiotap_header sc_txtap; 131188417Sthompsa int sc_txtap_len; 132184610Salfred}; 133188417Sthompsa 134188417Sthompsa#define RUM_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 135188417Sthompsa#define RUM_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 136188417Sthompsa#define RUM_LOCK_ASSERT(sc, t) mtx_assert(&(sc)->sc_mtx, t) 137