1*49e18393Smrg /* $NetBSD: if_ipwvar.h,v 1.19 2019/10/05 23:27:20 mrg Exp $ */ 2a91684ceSlukem 3a91684ceSlukem /*- 4a91684ceSlukem * Copyright (c) 2004 5a91684ceSlukem * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 6a91684ceSlukem * 7a91684ceSlukem * Redistribution and use in source and binary forms, with or without 8a91684ceSlukem * modification, are permitted provided that the following conditions 9a91684ceSlukem * are met: 10a91684ceSlukem * 1. Redistributions of source code must retain the above copyright 11a91684ceSlukem * notice unmodified, this list of conditions, and the following 12a91684ceSlukem * disclaimer. 13a91684ceSlukem * 2. Redistributions in binary form must reproduce the above copyright 14a91684ceSlukem * notice, this list of conditions and the following disclaimer in the 15a91684ceSlukem * documentation and/or other materials provided with the distribution. 16a91684ceSlukem * 17a91684ceSlukem * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18a91684ceSlukem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19a91684ceSlukem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20a91684ceSlukem * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21a91684ceSlukem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22a91684ceSlukem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23a91684ceSlukem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24a91684ceSlukem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25a91684ceSlukem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26a91684ceSlukem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27a91684ceSlukem * SUCH DAMAGE. 28a91684ceSlukem */ 29a91684ceSlukem 301fbab01aSdholland #include <sys/ioccom.h> 311fbab01aSdholland 3274331c12Sskrll struct ipw_firmware { 3374331c12Sskrll void *main; 3474331c12Sskrll int main_size; 3574331c12Sskrll void *ucode; 3674331c12Sskrll int ucode_size; 3774331c12Sskrll }; 3874331c12Sskrll 3974331c12Sskrll #define IPW_MAX_NSEG 1 4074331c12Sskrll 41a91684ceSlukem struct ipw_soft_bd { 42a91684ceSlukem struct ipw_bd *bd; 43a91684ceSlukem int type; 44a91684ceSlukem #define IPW_SBD_TYPE_NOASSOC 0 45a91684ceSlukem #define IPW_SBD_TYPE_COMMAND 1 46a91684ceSlukem #define IPW_SBD_TYPE_HEADER 2 47a91684ceSlukem #define IPW_SBD_TYPE_DATA 3 48a91684ceSlukem void *priv; 49a91684ceSlukem }; 50a91684ceSlukem 51a91684ceSlukem struct ipw_soft_hdr { 5274331c12Sskrll struct ipw_hdr *hdr; 5374331c12Sskrll bus_addr_t addr; 5474331c12Sskrll bus_addr_t offset; 55a91684ceSlukem TAILQ_ENTRY(ipw_soft_hdr) next; 56a91684ceSlukem }; 57a91684ceSlukem 58a91684ceSlukem struct ipw_soft_buf { 59a91684ceSlukem struct mbuf *m; 60a91684ceSlukem struct ieee80211_node *ni; 61a91684ceSlukem bus_dmamap_t map; 62a91684ceSlukem TAILQ_ENTRY(ipw_soft_buf) next; 63a91684ceSlukem }; 64a91684ceSlukem 659e6574e2Slukem struct ipw_rx_radiotap_header { 669e6574e2Slukem struct ieee80211_radiotap_header wr_ihdr; 6774331c12Sskrll uint16_t wr_chan_freq; 6874331c12Sskrll uint16_t wr_chan_flags; 6974331c12Sskrll uint8_t wr_antsignal; 70*49e18393Smrg }; 719e6574e2Slukem 729e6574e2Slukem #define IPW_RX_RADIOTAP_PRESENT \ 73a238dc97Sdyoung ((1 << IEEE80211_RADIOTAP_CHANNEL) | \ 749e6574e2Slukem (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)) 759e6574e2Slukem 769e6574e2Slukem struct ipw_tx_radiotap_header { 779e6574e2Slukem struct ieee80211_radiotap_header wt_ihdr; 7874331c12Sskrll uint16_t wt_chan_freq; 7974331c12Sskrll uint16_t wt_chan_flags; 80*49e18393Smrg }; 819e6574e2Slukem 829e6574e2Slukem #define IPW_TX_RADIOTAP_PRESENT \ 83a238dc97Sdyoung ((1 << IEEE80211_RADIOTAP_CHANNEL)) 849e6574e2Slukem 85a91684ceSlukem struct ipw_softc { 86cbab9cadSchs device_t sc_dev; 87a91684ceSlukem 8890634029Sdyoung struct ethercom sc_ec; 89a91684ceSlukem struct ieee80211com sc_ic; 90a91684ceSlukem int (*sc_newstate)(struct ieee80211com *, 91a91684ceSlukem enum ieee80211_state, int); 92a91684ceSlukem 9374331c12Sskrll struct ipw_firmware fw; 94866b295dSjoerg const char *sc_fwname; 9574331c12Sskrll uint32_t flags; 9674331c12Sskrll #define IPW_FLAG_FW_CACHED (1 << 0) 9774331c12Sskrll #define IPW_FLAG_FW_INITED (1 << 1) 9874331c12Sskrll #define IPW_FLAG_HAS_RADIO_SWITCH (1 << 2) 9974331c12Sskrll #define IPW_FLAG_FW_WARNED (1 << 3) 100a91684ceSlukem 101a91684ceSlukem struct resource *irq; 102a91684ceSlukem struct resource *mem; 103a91684ceSlukem bus_space_tag_t sc_st; 104a91684ceSlukem bus_space_handle_t sc_sh; 105a91684ceSlukem void *sc_ih; 1065ffb0503Snonaka void *sc_soft_ih; 107a91684ceSlukem pci_chipset_tag_t sc_pct; 10874331c12Sskrll pcitag_t sc_pcitag; 109a91684ceSlukem bus_size_t sc_sz; 110a91684ceSlukem 111a91684ceSlukem int sc_tx_timer; 112a91684ceSlukem 113a91684ceSlukem bus_dma_tag_t sc_dmat; 114a91684ceSlukem 115a91684ceSlukem bus_dmamap_t tbd_map; 116a91684ceSlukem bus_dmamap_t rbd_map; 117a91684ceSlukem bus_dmamap_t status_map; 118a91684ceSlukem bus_dmamap_t cmd_map; 11974331c12Sskrll bus_dmamap_t hdr_map; 120a91684ceSlukem 121a91684ceSlukem bus_dma_segment_t tbd_seg; 122a91684ceSlukem bus_dma_segment_t rbd_seg; 123a91684ceSlukem bus_dma_segment_t status_seg; 124a91684ceSlukem bus_dma_segment_t cmd_seg; 12574331c12Sskrll bus_dma_segment_t hdr_seg; 126a91684ceSlukem 127a91684ceSlukem struct ipw_bd *tbd_list; 128a91684ceSlukem struct ipw_bd *rbd_list; 129a91684ceSlukem struct ipw_status *status_list; 13074331c12Sskrll struct ipw_hdr *hdr_list; 131a91684ceSlukem 13274331c12Sskrll struct ipw_cmd cmd; 13374331c12Sskrll struct ipw_soft_bd stbd_list[IPW_NTBD]; 13474331c12Sskrll struct ipw_soft_buf tx_sbuf_list[IPW_NDATA]; 13574331c12Sskrll struct ipw_soft_bd srbd_list[IPW_NRBD]; 13674331c12Sskrll struct ipw_soft_buf rx_sbuf_list[IPW_NRBD]; 13774331c12Sskrll struct ipw_soft_hdr shdr_list[IPW_NDATA]; 138a91684ceSlukem 139a91684ceSlukem TAILQ_HEAD(, ipw_soft_hdr) sc_free_shdr; 140a91684ceSlukem TAILQ_HEAD(, ipw_soft_buf) sc_free_sbuf; 141a91684ceSlukem 14274331c12Sskrll uint32_t table1_base; 14374331c12Sskrll uint32_t table2_base; 144a91684ceSlukem 14574331c12Sskrll uint32_t txcur; 14674331c12Sskrll uint32_t txold; 14774331c12Sskrll uint32_t rxcur; 14874331c12Sskrll int txfree; 14974331c12Sskrll 15074331c12Sskrll int dwelltime; 1519e6574e2Slukem 1529e6574e2Slukem struct bpf_if *sc_drvbpf; 1539e6574e2Slukem 1549e6574e2Slukem union { 1559e6574e2Slukem struct ipw_rx_radiotap_header th; 15674331c12Sskrll uint8_t pad[64]; 1579e6574e2Slukem } sc_rxtapu; 1589e6574e2Slukem #define sc_rxtap sc_rxtapu.th 1599e6574e2Slukem int sc_rxtap_len; 1609e6574e2Slukem 1619e6574e2Slukem union { 1629e6574e2Slukem struct ipw_tx_radiotap_header th; 16374331c12Sskrll uint8_t pad[64]; 1649e6574e2Slukem } sc_txtapu; 1659e6574e2Slukem #define sc_txtap sc_txtapu.th 1669e6574e2Slukem int sc_txtap_len; 167a91684ceSlukem }; 168a91684ceSlukem 16990634029Sdyoung #define sc_if sc_ec.ec_if 17090634029Sdyoung 171a91684ceSlukem #define SIOCGRADIO _IOWR('i', 139, struct ifreq) 172a91684ceSlukem #define SIOCGTABLE1 _IOWR('i', 140, struct ifreq) 173