1 /* $OpenBSD: if_rtwnreg.h,v 1.3 2015/06/14 08:02:47 stsp Exp $ */ 2 3 /*- 4 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> 6 * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.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 * $FreeBSD$ 21 */ 22 23 #ifndef RTWN_PCI_VAR_H 24 #define RTWN_PCI_VAR_H 25 26 #define RTWN_PCI_RX_LIST_COUNT 256 27 #define RTWN_PCI_TX_LIST_COUNT 256 28 29 struct rtwn_rx_data { 30 bus_dmamap_t map; 31 struct mbuf *m; 32 bus_addr_t paddr; 33 }; 34 35 struct rtwn_rx_ring { 36 struct rtwn_rx_stat_pci *desc; 37 bus_addr_t paddr; 38 bus_dma_tag_t desc_dmat; 39 bus_dmamap_t desc_map; 40 bus_dma_tag_t data_dmat; 41 bus_dma_segment_t seg; 42 struct rtwn_rx_data rx_data[RTWN_PCI_RX_LIST_COUNT]; 43 int cur; 44 }; 45 46 struct rtwn_tx_data { 47 bus_dmamap_t map; 48 struct mbuf *m; 49 struct ieee80211_node *ni; 50 }; 51 52 struct rtwn_tx_ring { 53 bus_addr_t paddr; 54 bus_dma_tag_t desc_dmat; 55 bus_dmamap_t desc_map; 56 bus_dma_tag_t data_dmat; 57 bus_dma_segment_t seg; 58 void *desc; 59 struct rtwn_tx_data tx_data[RTWN_PCI_TX_LIST_COUNT]; 60 int queued; 61 int cur; 62 int last; 63 }; 64 65 /* 66 * TX queue indices. 67 */ 68 enum { 69 RTWN_PCI_BK_QUEUE, 70 RTWN_PCI_BE_QUEUE, 71 RTWN_PCI_VI_QUEUE, 72 RTWN_PCI_VO_QUEUE, 73 RTWN_PCI_BEACON_QUEUE, 74 RTWN_PCI_TXCMD_QUEUE, 75 RTWN_PCI_MGNT_QUEUE, 76 RTWN_PCI_HIGH_QUEUE, 77 RTWN_PCI_HCCA_QUEUE, 78 RTWN_PCI_NTXQUEUES 79 }; 80 81 /* 82 * Interrupt events. 83 */ 84 enum { 85 RTWN_PCI_INTR_RX_ERROR = 0x00000001, 86 RTWN_PCI_INTR_RX_OVERFLOW = 0x00000002, 87 RTWN_PCI_INTR_RX_DESC_UNAVAIL = 0x00000004, 88 RTWN_PCI_INTR_RX_DONE = 0x00000008, 89 RTWN_PCI_INTR_TX_ERROR = 0x00000010, 90 RTWN_PCI_INTR_TX_OVERFLOW = 0x00000020, 91 RTWN_PCI_INTR_TX_REPORT = 0x00000040, 92 RTWN_PCI_INTR_PS_TIMEOUT = 0x00000080 93 }; 94 95 /* Shortcuts */ 96 /* Vendor driver treats RX errors like ROK... */ 97 #define RTWN_PCI_INTR_RX \ 98 (RTWN_PCI_INTR_RX_OVERFLOW | RTWN_PCI_INTR_RX_DESC_UNAVAIL | \ 99 RTWN_PCI_INTR_RX_DONE) 100 101 102 struct rtwn_pci_softc { 103 struct rtwn_softc pc_sc; /* must be the first */ 104 105 struct resource *irq; 106 struct resource *mem; 107 bus_space_tag_t pc_st; 108 bus_space_handle_t pc_sh; 109 void *pc_ih; 110 bus_size_t pc_mapsize; 111 112 struct rtwn_rx_ring rx_ring; 113 struct rtwn_tx_ring tx_ring[RTWN_PCI_NTXQUEUES]; 114 115 /* must be set by the driver. */ 116 uint16_t pc_qmap; 117 uint32_t tcr; 118 119 void (*pc_setup_tx_desc)(struct rtwn_pci_softc *, 120 void *, uint32_t); 121 void (*pc_tx_postsetup)(struct rtwn_pci_softc *, 122 void *, bus_dma_segment_t *); 123 void (*pc_copy_tx_desc)(void *, const void *); 124 void (*pc_enable_intr)(struct rtwn_pci_softc *); 125 }; 126 #define RTWN_PCI_SOFTC(sc) ((struct rtwn_pci_softc *)(sc)) 127 128 #define rtwn_pci_setup_tx_desc(_pc, _desc, _addr) \ 129 (((_pc)->pc_setup_tx_desc)((_pc), (_desc), (_addr))) 130 #define rtwn_pci_tx_postsetup(_pc, _txd, _segs) \ 131 (((_pc)->pc_tx_postsetup)((_pc), (_txd), (_segs))) 132 #define rtwn_pci_copy_tx_desc(_pc, _dest, _src) \ 133 (((_pc)->pc_copy_tx_desc)((_dest), (_src))) 134 #define rtwn_pci_enable_intr(_pc) \ 135 (((_pc)->pc_enable_intr)((_pc))) 136 137 #endif /* RTWN_PCI_VAR_H */ 138