1 /* $OpenBSD: if_rtwnreg.h,v 1.3 2015/06/14 08:02:47 stsp Exp $ */
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>
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.
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.
23 #ifndef RTWN_PCI_VAR_H
24 #define RTWN_PCI_VAR_H
26 #define RTWN_PCI_RX_LIST_COUNT 256
27 #define RTWN_PCI_TX_LIST_COUNT 256
29 /* sizeof(struct rtwn_rx_stat_common) + R88E_INTR_MSG_LEN */
30 #define RTWN_PCI_RX_TMP_BUF_SIZE 84
39 struct rtwn_rx_stat_pci *desc;
41 bus_dma_tag_t desc_dmat;
42 bus_dmamap_t desc_map;
43 bus_dma_tag_t data_dmat;
44 bus_dma_segment_t seg;
45 struct rtwn_rx_data rx_data[RTWN_PCI_RX_LIST_COUNT];
52 struct ieee80211_node *ni;
57 bus_dma_tag_t desc_dmat;
58 bus_dmamap_t desc_map;
59 bus_dma_tag_t data_dmat;
60 bus_dma_segment_t seg;
62 struct rtwn_tx_data tx_data[RTWN_PCI_TX_LIST_COUNT];
76 RTWN_PCI_BEACON_QUEUE,
88 RTWN_PCI_INTR_RX_ERROR = 0x00000001,
89 RTWN_PCI_INTR_RX_OVERFLOW = 0x00000002,
90 RTWN_PCI_INTR_RX_DESC_UNAVAIL = 0x00000004,
91 RTWN_PCI_INTR_RX_DONE = 0x00000008,
92 RTWN_PCI_INTR_TX_ERROR = 0x00000010,
93 RTWN_PCI_INTR_TX_OVERFLOW = 0x00000020,
94 RTWN_PCI_INTR_TX_REPORT = 0x00000040,
95 RTWN_PCI_INTR_PS_TIMEOUT = 0x00000080
99 /* Vendor driver treats RX errors like ROK... */
100 #define RTWN_PCI_INTR_RX \
101 (RTWN_PCI_INTR_RX_ERROR | RTWN_PCI_INTR_RX_OVERFLOW | \
102 RTWN_PCI_INTR_RX_DESC_UNAVAIL | RTWN_PCI_INTR_RX_DONE)
104 struct rtwn_pci_softc {
105 struct rtwn_softc pc_sc; /* must be the first */
107 struct resource *irq;
108 struct resource *mem;
109 bus_space_tag_t pc_st;
110 bus_space_handle_t pc_sh;
112 bus_size_t pc_mapsize;
114 uint8_t pc_rx_buf[RTWN_PCI_RX_TMP_BUF_SIZE];
115 struct rtwn_rx_ring rx_ring;
116 struct rtwn_tx_ring tx_ring[RTWN_PCI_NTXQUEUES];
118 /* must be set by the driver. */
122 void (*pc_setup_tx_desc)(struct rtwn_pci_softc *,
124 void (*pc_tx_postsetup)(struct rtwn_pci_softc *,
125 void *, bus_dma_segment_t *);
126 void (*pc_copy_tx_desc)(void *, const void *);
127 void (*pc_enable_intr)(struct rtwn_pci_softc *);
128 int (*pc_get_intr_status)(struct rtwn_pci_softc *,
131 #define RTWN_PCI_SOFTC(sc) ((struct rtwn_pci_softc *)(sc))
133 #define rtwn_pci_setup_tx_desc(_pc, _desc, _addr) \
134 (((_pc)->pc_setup_tx_desc)((_pc), (_desc), (_addr)))
135 #define rtwn_pci_tx_postsetup(_pc, _txd, _segs) \
136 (((_pc)->pc_tx_postsetup)((_pc), (_txd), (_segs)))
137 #define rtwn_pci_copy_tx_desc(_pc, _dest, _src) \
138 (((_pc)->pc_copy_tx_desc)((_dest), (_src)))
139 #define rtwn_pci_enable_intr(_pc) \
140 (((_pc)->pc_enable_intr)((_pc)))
141 #define rtwn_pci_get_intr_status(_pc, _tx_rings) \
142 (((_pc)->pc_get_intr_status)((_pc), (_tx_rings)))
144 #endif /* RTWN_PCI_VAR_H */