1 /* $FreeBSD$ */ 2 3 /*- 4 * Copyright (c) 2004, 2005 5 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 struct ipw_firmware { 31 void *main; 32 int main_size; 33 void *ucode; 34 int ucode_size; 35 }; 36 37 #define IPW_MAX_NSEG 1 38 39 struct ipw_soft_bd { 40 struct ipw_bd *bd; 41 int type; 42 #define IPW_SBD_TYPE_NOASSOC 0 43 #define IPW_SBD_TYPE_COMMAND 1 44 #define IPW_SBD_TYPE_HEADER 2 45 #define IPW_SBD_TYPE_DATA 3 46 void *priv; 47 }; 48 49 struct ipw_soft_hdr { 50 struct ipw_hdr hdr; 51 bus_dmamap_t map; 52 SLIST_ENTRY(ipw_soft_hdr) next; 53 }; 54 55 struct ipw_soft_buf { 56 struct mbuf *m; 57 struct ieee80211_node *ni; 58 bus_dmamap_t map; 59 SLIST_ENTRY(ipw_soft_buf) next; 60 }; 61 62 struct ipw_rx_radiotap_header { 63 struct ieee80211_radiotap_header wr_ihdr; 64 uint8_t wr_flags; 65 uint16_t wr_chan_freq; 66 uint16_t wr_chan_flags; 67 uint8_t wr_antsignal; 68 }; 69 70 #define IPW_RX_RADIOTAP_PRESENT \ 71 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 72 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 73 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)) 74 75 struct ipw_tx_radiotap_header { 76 struct ieee80211_radiotap_header wt_ihdr; 77 uint8_t wt_flags; 78 uint16_t wt_chan_freq; 79 uint16_t wt_chan_flags; 80 }; 81 82 #define IPW_TX_RADIOTAP_PRESENT \ 83 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 84 (1 << IEEE80211_RADIOTAP_CHANNEL)) 85 86 struct ipw_softc { 87 struct arpcom sc_arp; 88 struct ieee80211com sc_ic; 89 int (*sc_newstate)(struct ieee80211com *, 90 enum ieee80211_state, int); 91 device_t sc_dev; 92 93 struct mtx sc_mtx; 94 95 struct ipw_firmware fw; 96 uint32_t flags; 97 #define IPW_FLAG_FW_CACHED (1 << 0) 98 #define IPW_FLAG_FW_INITED (1 << 1) 99 #define IPW_FLAG_HAS_RADIO_SWITCH (1 << 2) 100 101 int irq_rid; 102 int mem_rid; 103 struct resource *irq; 104 struct resource *mem; 105 bus_space_tag_t sc_st; 106 bus_space_handle_t sc_sh; 107 void *sc_ih; 108 109 int sc_tx_timer; 110 111 bus_dma_tag_t tbd_dmat; 112 bus_dma_tag_t rbd_dmat; 113 bus_dma_tag_t status_dmat; 114 bus_dma_tag_t cmd_dmat; 115 bus_dma_tag_t hdr_dmat; 116 bus_dma_tag_t txbuf_dmat; 117 bus_dma_tag_t rxbuf_dmat; 118 119 bus_dmamap_t tbd_map; 120 bus_dmamap_t rbd_map; 121 bus_dmamap_t status_map; 122 bus_dmamap_t cmd_map; 123 124 bus_addr_t tbd_phys; 125 bus_addr_t rbd_phys; 126 bus_addr_t status_phys; 127 128 struct ipw_bd *tbd_list; 129 struct ipw_bd *rbd_list; 130 struct ipw_status *status_list; 131 132 struct ipw_cmd cmd; 133 struct ipw_soft_bd stbd_list[IPW_NTBD]; 134 struct ipw_soft_buf tx_sbuf_list[IPW_NDATA]; 135 struct ipw_soft_hdr shdr_list[IPW_NDATA]; 136 struct ipw_soft_bd srbd_list[IPW_NRBD]; 137 struct ipw_soft_buf rx_sbuf_list[IPW_NRBD]; 138 139 SLIST_HEAD(, ipw_soft_hdr) free_shdr; 140 SLIST_HEAD(, ipw_soft_buf) free_sbuf; 141 142 uint32_t table1_base; 143 uint32_t table2_base; 144 145 uint32_t txcur; 146 uint32_t txold; 147 uint32_t rxcur; 148 int txfree; 149 150 int dwelltime; 151 152 struct bpf_if *sc_drvbpf; 153 154 union { 155 struct ipw_rx_radiotap_header th; 156 uint8_t pad[64]; 157 } sc_rxtapu; 158 #define sc_rxtap sc_rxtapu.th 159 int sc_rxtap_len; 160 161 union { 162 struct ipw_tx_radiotap_header th; 163 uint8_t pad[64]; 164 } sc_txtapu; 165 #define sc_txtap sc_txtapu.th 166 int sc_txtap_len; 167 }; 168 169 #define SIOCSLOADFW _IOW('i', 137, struct ifreq) 170 #define SIOCSKILLFW _IOW('i', 138, struct ifreq) 171 172 #define IPW_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 173 #define IPW_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 174