1b8e788a5SAdrian Chadd /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni *
4b8e788a5SAdrian Chadd * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
5b8e788a5SAdrian Chadd * All rights reserved.
6b8e788a5SAdrian Chadd *
7b8e788a5SAdrian Chadd * Redistribution and use in source and binary forms, with or without
8b8e788a5SAdrian Chadd * modification, are permitted provided that the following conditions
9b8e788a5SAdrian Chadd * are met:
10b8e788a5SAdrian Chadd * 1. Redistributions of source code must retain the above copyright
11b8e788a5SAdrian Chadd * notice, this list of conditions and the following disclaimer,
12b8e788a5SAdrian Chadd * without modification.
13b8e788a5SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14b8e788a5SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15b8e788a5SAdrian Chadd * redistribution must be conditioned upon including a substantially
16b8e788a5SAdrian Chadd * similar Disclaimer requirement for further binary redistribution.
17b8e788a5SAdrian Chadd *
18b8e788a5SAdrian Chadd * NO WARRANTY
19b8e788a5SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20b8e788a5SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21b8e788a5SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
22b8e788a5SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23b8e788a5SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24b8e788a5SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b8e788a5SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b8e788a5SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27b8e788a5SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b8e788a5SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29b8e788a5SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES.
30b8e788a5SAdrian Chadd */
31b8e788a5SAdrian Chadd #ifndef __IF_ATH_MISC_H__
32b8e788a5SAdrian Chadd #define __IF_ATH_MISC_H__
33b8e788a5SAdrian Chadd
34b8e788a5SAdrian Chadd /*
35b8e788a5SAdrian Chadd * This is where definitions for "public things" in if_ath.c
36b8e788a5SAdrian Chadd * will go for the time being.
37b8e788a5SAdrian Chadd *
38b8e788a5SAdrian Chadd * Anything in here should eventually be moved out of if_ath.c
39b8e788a5SAdrian Chadd * and into something else.
40b8e788a5SAdrian Chadd */
41b8e788a5SAdrian Chadd
423d184db2SAdrian Chadd extern int ath_rxbuf;
433d184db2SAdrian Chadd extern int ath_txbuf;
443d184db2SAdrian Chadd extern int ath_txbuf_mgmt;
453d184db2SAdrian Chadd
46b8e788a5SAdrian Chadd extern int ath_tx_findrix(const struct ath_softc *sc, uint8_t rate);
47b8e788a5SAdrian Chadd
48af33d486SAdrian Chadd extern struct ath_buf * ath_getbuf(struct ath_softc *sc,
49af33d486SAdrian Chadd ath_buf_type_t btype);
50af33d486SAdrian Chadd extern struct ath_buf * _ath_getbuf_locked(struct ath_softc *sc,
51af33d486SAdrian Chadd ath_buf_type_t btype);
52e346b073SAdrian Chadd extern struct ath_buf * ath_buf_clone(struct ath_softc *sc,
533f3a5dbdSAdrian Chadd struct ath_buf *bf);
54af33d486SAdrian Chadd /* XXX change this to NULL the buffer pointer? */
559352fb7aSAdrian Chadd extern void ath_freebuf(struct ath_softc *sc, struct ath_buf *bf);
56e1a50456SAdrian Chadd extern void ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf);
57e1a50456SAdrian Chadd extern void ath_returnbuf_tail(struct ath_softc *sc, struct ath_buf *bf);
58b8e788a5SAdrian Chadd
598c01c3dcSAdrian Chadd extern int ath_reset(struct ath_softc *, ATH_RESET_TYPE,
608c01c3dcSAdrian Chadd HAL_RESET_TYPE ah_reset_type);
619352fb7aSAdrian Chadd extern void ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf,
629352fb7aSAdrian Chadd int fail);
63eb6f0de0SAdrian Chadd extern void ath_tx_update_ratectrl(struct ath_softc *sc,
64eb6f0de0SAdrian Chadd struct ieee80211_node *ni, struct ath_rc_series *rc,
65cce63444SAdrian Chadd struct ath_tx_status *ts, int frmlen, int rc_framelen,
66cce63444SAdrian Chadd int nframes, int nbad);
679352fb7aSAdrian Chadd
68b837332dSAdrian Chadd extern int ath_hal_gethangstate(struct ath_hal *ah, uint32_t mask,
69b837332dSAdrian Chadd uint32_t *hangs);
70b837332dSAdrian Chadd
719352fb7aSAdrian Chadd extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf,
729352fb7aSAdrian Chadd int status);
733feffbd7SAdrian Chadd extern void ath_txq_freeholdingbuf(struct ath_softc *sc,
743feffbd7SAdrian Chadd struct ath_txq *txq);
756079fdbeSAdrian Chadd
76ba5c15d9SAdrian Chadd extern void ath_txqmove(struct ath_txq *dst, struct ath_txq *src);
77ba5c15d9SAdrian Chadd
78e60c4fc2SAdrian Chadd extern void ath_mode_init(struct ath_softc *sc);
79e60c4fc2SAdrian Chadd
80e60c4fc2SAdrian Chadd extern void ath_setdefantenna(struct ath_softc *sc, u_int antenna);
81e60c4fc2SAdrian Chadd
82ba5c15d9SAdrian Chadd extern void ath_setslottime(struct ath_softc *sc);
83ba5c15d9SAdrian Chadd
84f8418db5SAdrian Chadd extern void ath_legacy_attach_comp_func(struct ath_softc *sc);
85788e6aa9SAdrian Chadd
861762ec94SAdrian Chadd extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq);
871762ec94SAdrian Chadd
88788e6aa9SAdrian Chadd extern void ath_legacy_tx_drain(struct ath_softc *sc,
89788e6aa9SAdrian Chadd ATH_RESET_TYPE reset_type);
90f8418db5SAdrian Chadd
91bad98824SAdrian Chadd extern void ath_tx_process_buf_completion(struct ath_softc *sc,
92bad98824SAdrian Chadd struct ath_txq *txq, struct ath_tx_status *ts, struct ath_buf *bf);
93bad98824SAdrian Chadd
94bad98824SAdrian Chadd extern int ath_stoptxdma(struct ath_softc *sc);
95bad98824SAdrian Chadd
96548a605dSAdrian Chadd extern void ath_tx_update_tim(struct ath_softc *sc,
97548a605dSAdrian Chadd struct ieee80211_node *ni, int enable);
98548a605dSAdrian Chadd
99e60c4fc2SAdrian Chadd /*
100e60c4fc2SAdrian Chadd * This is only here so that the RX proc function can call it.
101e60c4fc2SAdrian Chadd * It's very likely that the "start TX after RX" call should be
102e60c4fc2SAdrian Chadd * done via something in if_ath.c, moving "rx tasklet" into
103e60c4fc2SAdrian Chadd * if_ath.c and do the ath_start() call there. Once that's done,
104e60c4fc2SAdrian Chadd * we can kill this.
105e60c4fc2SAdrian Chadd */
106ec22a3a2SJustin Hibbits extern void ath_start(if_t ifp);
1078e739394SAdrian Chadd extern void ath_start_task(void *arg, int npending);
108e60c4fc2SAdrian Chadd
1099be82a42SAdrian Chadd extern void ath_tx_dump(struct ath_softc *sc, struct ath_txq *txq);
1109be82a42SAdrian Chadd
11121bca442SAdrian Chadd /*
112f5c30c4eSAdrian Chadd * Power state tracking.
113f5c30c4eSAdrian Chadd */
1148c03e55dSAdrian Chadd extern void _ath_power_setpower(struct ath_softc *sc, int power_state,
1158c03e55dSAdrian Chadd int selfgen, const char *file, int line);
1168c03e55dSAdrian Chadd extern void _ath_power_set_selfgen(struct ath_softc *sc,
1178c03e55dSAdrian Chadd int power_state, const char *file, int line);
1188c03e55dSAdrian Chadd extern void _ath_power_set_power_state(struct ath_softc *sc,
1198c03e55dSAdrian Chadd int power_state, const char *file, int line);
1208c03e55dSAdrian Chadd extern void _ath_power_restore_power_state(struct ath_softc *sc,
1218c03e55dSAdrian Chadd const char *file, int line);
122f5c30c4eSAdrian Chadd
1238c03e55dSAdrian Chadd #define ath_power_setpower(sc, ps, sg) _ath_power_setpower(sc, ps, sg, \
1248c03e55dSAdrian Chadd __FILE__, __LINE__)
1258c03e55dSAdrian Chadd #define ath_power_setselfgen(sc, ps) _ath_power_set_selfgen(sc, ps, \
1268c03e55dSAdrian Chadd __FILE__, __LINE__)
1278c03e55dSAdrian Chadd #define ath_power_set_power_state(sc, ps) \
1288c03e55dSAdrian Chadd _ath_power_set_power_state(sc, ps, __FILE__, __LINE__)
1298c03e55dSAdrian Chadd #define ath_power_restore_power_state(sc) \
1308c03e55dSAdrian Chadd _ath_power_restore_power_state(sc, __FILE__, __LINE__)
131f5c30c4eSAdrian Chadd
132f5c30c4eSAdrian Chadd /*
13321bca442SAdrian Chadd * Kick the frame TX task.
13421bca442SAdrian Chadd */
13514d33c7eSAdrian Chadd static inline void
ath_tx_kick(struct ath_softc * sc)13614d33c7eSAdrian Chadd ath_tx_kick(struct ath_softc *sc)
13714d33c7eSAdrian Chadd {
13814d33c7eSAdrian Chadd
139cd7dffd0SAdrian Chadd /* XXX NULL for now */
14014d33c7eSAdrian Chadd }
141ba5c15d9SAdrian Chadd
14221bca442SAdrian Chadd /*
14321bca442SAdrian Chadd * Kick the software TX queue task.
14421bca442SAdrian Chadd */
14521bca442SAdrian Chadd static inline void
ath_tx_swq_kick(struct ath_softc * sc)14621bca442SAdrian Chadd ath_tx_swq_kick(struct ath_softc *sc)
14721bca442SAdrian Chadd {
14821bca442SAdrian Chadd
14953a835d2SAdrian Chadd taskqueue_enqueue(sc->sc_tq, &sc->sc_txqtask);
15021bca442SAdrian Chadd }
15121bca442SAdrian Chadd
152b8e788a5SAdrian Chadd #endif
153