1184610Salfred/* $FreeBSD: stable/11/sys/dev/usb/wlan/if_uralvar.h 345636 2019-03-28 09:50:25Z avos $ */ 2184610Salfred 3184610Salfred/*- 4184610Salfred * Copyright (c) 2005 5184610Salfred * Damien Bergamini <damien.bergamini@free.fr> 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 RAL_TX_LIST_COUNT 8 21188969Sthompsa#define RAL_TX_MINFREE 2 22184610Salfred 23188417Sthompsa#define URAL_SCAN_START 1 24188417Sthompsa#define URAL_SCAN_END 2 25188417Sthompsa#define URAL_SET_CHANNEL 3 26184610Salfred 27184610Salfred 28188417Sthompsastruct ural_rx_radiotap_header { 29188417Sthompsa struct ieee80211_radiotap_header wr_ihdr; 30188417Sthompsa uint8_t wr_flags; 31188417Sthompsa uint8_t wr_rate; 32188417Sthompsa uint16_t wr_chan_freq; 33188417Sthompsa uint16_t wr_chan_flags; 34192468Ssam int8_t wr_antsignal; 35192468Ssam int8_t wr_antnoise; 36188417Sthompsa uint8_t wr_antenna; 37253757Shselasky} __packed __aligned(8); 38184610Salfred 39188417Sthompsa#define RAL_RX_RADIOTAP_PRESENT \ 40188417Sthompsa ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 41188417Sthompsa (1 << IEEE80211_RADIOTAP_RATE) | \ 42188417Sthompsa (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 43188417Sthompsa (1 << IEEE80211_RADIOTAP_ANTENNA) | \ 44192468Ssam (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 45192468Ssam (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)) 46184610Salfred 47188417Sthompsastruct ural_tx_radiotap_header { 48188417Sthompsa struct ieee80211_radiotap_header wt_ihdr; 49188417Sthompsa uint8_t wt_flags; 50188417Sthompsa uint8_t wt_rate; 51188417Sthompsa uint16_t wt_chan_freq; 52188417Sthompsa uint16_t wt_chan_flags; 53188417Sthompsa uint8_t wt_antenna; 54345636Savos} __packed; 55184610Salfred 56188417Sthompsa#define RAL_TX_RADIOTAP_PRESENT \ 57188417Sthompsa ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 58188417Sthompsa (1 << IEEE80211_RADIOTAP_RATE) | \ 59188417Sthompsa (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 60188417Sthompsa (1 << IEEE80211_RADIOTAP_ANTENNA)) 61184610Salfred 62188417Sthompsastruct ural_softc; 63184610Salfred 64188417Sthompsastruct ural_tx_data { 65188417Sthompsa STAILQ_ENTRY(ural_tx_data) next; 66188417Sthompsa struct ural_softc *sc; 67188417Sthompsa struct ural_tx_desc desc; 68188417Sthompsa struct mbuf *m; 69188417Sthompsa struct ieee80211_node *ni; 70188417Sthompsa int rate; 71184610Salfred}; 72188417Sthompsatypedef STAILQ_HEAD(, ural_tx_data) ural_txdhead; 73184610Salfred 74188417Sthompsastruct ural_vap { 75188417Sthompsa struct ieee80211vap vap; 76288095Sadrian 77206358Srpaulo struct usb_callout ratectl_ch; 78206358Srpaulo struct task ratectl_task; 79184610Salfred 80188417Sthompsa int (*newstate)(struct ieee80211vap *, 81188417Sthompsa enum ieee80211_state, int); 82184610Salfred}; 83188417Sthompsa#define URAL_VAP(vap) ((struct ural_vap *)(vap)) 84184610Salfred 85187259Sthompsaenum { 86188417Sthompsa URAL_BULK_WR, 87188417Sthompsa URAL_BULK_RD, 88188417Sthompsa URAL_N_TRANSFER = 2, 89187259Sthompsa}; 90187259Sthompsa 91184610Salfredstruct ural_softc { 92287197Sglebius struct ieee80211com sc_ic; 93287197Sglebius struct mbufq sc_snd; 94188417Sthompsa device_t sc_dev; 95192984Sthompsa struct usb_device *sc_udev; 96184610Salfred 97188417Sthompsa uint32_t asic_rev; 98188417Sthompsa uint8_t rf_rev; 99184610Salfred 100296356Savos struct usb_xfer *sc_xfer[URAL_N_TRANSFER]; 101184610Salfred 102188419Sthompsa struct ural_tx_data tx_data[RAL_TX_LIST_COUNT]; 103188417Sthompsa ural_txdhead tx_q; 104188417Sthompsa ural_txdhead tx_free; 105188417Sthompsa int tx_nfree; 106188417Sthompsa struct ural_rx_desc sc_rx_desc; 107188417Sthompsa 108188417Sthompsa struct mtx sc_mtx; 109188417Sthompsa 110188417Sthompsa uint16_t sta[11]; 111188417Sthompsa uint32_t rf_regs[4]; 112188417Sthompsa uint8_t txpow[14]; 113287197Sglebius u_int sc_detached:1, 114287197Sglebius sc_running:1; 115188417Sthompsa 116296356Savos uint8_t sc_bssid[IEEE80211_ADDR_LEN]; 117296356Savos 118188417Sthompsa struct { 119188417Sthompsa uint8_t val; 120188417Sthompsa uint8_t reg; 121188417Sthompsa } __packed bbp_prom[16]; 122188417Sthompsa 123188417Sthompsa int led_mode; 124188417Sthompsa int hw_radio; 125188417Sthompsa int rx_ant; 126188417Sthompsa int tx_ant; 127188417Sthompsa int nb_ant; 128188417Sthompsa 129188417Sthompsa struct ural_rx_radiotap_header sc_rxtap; 130188417Sthompsa struct ural_tx_radiotap_header sc_txtap; 131184610Salfred}; 132188417Sthompsa 133188417Sthompsa#define RAL_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 134188417Sthompsa#define RAL_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 135188417Sthompsa#define RAL_LOCK_ASSERT(sc, t) mtx_assert(&(sc)->sc_mtx, t) 136