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
36 struct rtwn_rx_stat_pci *desc;
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];
49 struct ieee80211_node *ni;
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;
59 struct rtwn_tx_data tx_data[RTWN_PCI_TX_LIST_COUNT];
73 RTWN_PCI_BEACON_QUEUE,
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
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)
102 struct rtwn_pci_softc {
103 struct rtwn_softc pc_sc; /* must be the first */
105 struct resource *irq;
106 struct resource *mem;
107 bus_space_tag_t pc_st;
108 bus_space_handle_t pc_sh;
110 bus_size_t pc_mapsize;
112 struct rtwn_rx_ring rx_ring;
113 struct rtwn_tx_ring tx_ring[RTWN_PCI_NTXQUEUES];
115 /* must be set by the driver. */
119 void (*pc_setup_tx_desc)(struct rtwn_pci_softc *,
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 *);
126 #define RTWN_PCI_SOFTC(sc) ((struct rtwn_pci_softc *)(sc))
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)))
137 #endif /* RTWN_PCI_VAR_H */