2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2012 Adrian Chadd
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15 * redistribution must be conditioned upon including a substantially
16 * similar Disclaimer requirement for further binary redistribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
22 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29 * THE POSSIBILITY OF SUCH DAMAGES.
33 #ifndef __IF_ATH_ALQ_H__
34 #define __IF_ATH_ALQ_H__
36 #define ATH_ALQ_INIT_STATE 1
37 struct if_ath_alq_init_state {
38 uint32_t sc_mac_version;
39 uint32_t sc_mac_revision;
41 uint32_t sc_hal_magic;
44 #define ATH_ALQ_EDMA_TXSTATUS 2
45 #define ATH_ALQ_EDMA_RXSTATUS 3
46 #define ATH_ALQ_EDMA_TXDESC 4
48 #define ATH_ALQ_TDMA_BEACON_STATE 5
49 struct if_ath_alq_tdma_beacon_state {
50 uint64_t rx_tsf; /* RX TSF of beacon frame */
51 uint64_t beacon_tsf; /* TSF inside beacon frame */
53 uint64_t nextslot_tsf;
58 #define ATH_ALQ_TDMA_TIMER_CONFIG 6
59 struct if_ath_alq_tdma_timer_config {
61 uint32_t tdma_slotlen;
62 uint32_t tdma_slotcnt;
63 uint32_t tdma_bintval;
65 uint32_t tdma_scbintval;
66 uint32_t tdma_dbaprep;
69 #define ATH_ALQ_TDMA_SLOT_CALC 7
70 struct if_ath_alq_tdma_slot_calc {
78 #define ATH_ALQ_TDMA_TSF_ADJUST 8
79 struct if_ath_alq_tdma_tsf_adjust {
85 #define ATH_ALQ_TDMA_TIMER_SET 9
86 struct if_ath_alq_tdma_timer_set {
93 uint32_t sc_tdmadbaprep;
94 uint32_t sc_tdmaswbaprep;
97 #define ATH_ALQ_INTR_STATUS 10
98 struct if_ath_alq_interrupt {
100 uint32_t intr_state[8];
101 uint32_t intr_syncstate;
104 #define ATH_ALQ_MIB_COUNTERS 11
105 struct if_ath_alq_mib_counters {
110 uint32_t ext_chan_busy;
111 uint32_t cycle_count;
114 #define ATH_ALQ_MISSED_BEACON 12
115 #define ATH_ALQ_STUCK_BEACON 13
116 #define ATH_ALQ_RESUME_BEACON 14
118 #define ATH_ALQ_TX_FIFO_PUSH 15
119 struct if_ath_alq_tx_fifo_push {
127 * These will always be logged, regardless.
129 #define ATH_ALQ_LOG_ALWAYS_MASK 0x00000001
131 #define ATH_ALQ_FILENAME_LEN 128
132 #define ATH_ALQ_DEVNAME_LEN 32
135 uint32_t sc_alq_debug; /* Debug flags to report */
136 struct alq * sc_alq_alq; /* alq state */
137 unsigned int sc_alq_qsize; /* queue size */
138 unsigned int sc_alq_numlost; /* number of "lost" entries */
140 char sc_alq_devname[ATH_ALQ_DEVNAME_LEN];
141 char sc_alq_filename[ATH_ALQ_FILENAME_LEN];
142 struct if_ath_alq_init_state sc_alq_cfg;
145 /* 128 bytes in total */
146 #define ATH_ALQ_PAYLOAD_LEN 112
148 struct if_ath_alq_hdr {
151 uint32_t tstamp_usec;
153 uint16_t len; /* Length of (optional) payload */
156 struct if_ath_alq_payload {
157 struct if_ath_alq_hdr hdr;
163 if_ath_alq_checkdebug(struct if_ath_alq *alq, uint16_t op)
166 return ((alq->sc_alq_debug | ATH_ALQ_LOG_ALWAYS_MASK)
170 extern void if_ath_alq_init(struct if_ath_alq *alq, const char *devname);
171 extern void if_ath_alq_setcfg(struct if_ath_alq *alq, uint32_t macVer,
172 uint32_t macRev, uint32_t phyRev, uint32_t halMagic);
173 extern void if_ath_alq_tidyup(struct if_ath_alq *alq);
174 extern int if_ath_alq_start(struct if_ath_alq *alq);
175 extern int if_ath_alq_stop(struct if_ath_alq *alq);
176 extern void if_ath_alq_post(struct if_ath_alq *alq, uint16_t op,
177 uint16_t len, const char *buf);
179 /* XXX maybe doesn't belong here? */
181 if_ath_alq_post_intr(struct if_ath_alq *alq, uint32_t status,
182 uint32_t *state, uint32_t sync_state)
185 struct if_ath_alq_interrupt intr;
187 if (! if_ath_alq_checkdebug(alq, ATH_ALQ_INTR_STATUS))
190 intr.intr_status = htobe32(status);
191 for (i = 0; i < 8; i++)
192 intr.intr_state[i] = htobe32(state[i]);
193 intr.intr_syncstate = htobe32(sync_state);
195 if_ath_alq_post(alq, ATH_ALQ_INTR_STATUS, sizeof(intr),
196 (const char *) &intr);