xref: /freebsd/sys/dev/ath/if_ath_misc.h (revision 9f9560982863554689b1598ef5393012389d9f08)
1b8e788a5SAdrian Chadd /*-
2b8e788a5SAdrian Chadd  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3b8e788a5SAdrian Chadd  * All rights reserved.
4b8e788a5SAdrian Chadd  *
5b8e788a5SAdrian Chadd  * Redistribution and use in source and binary forms, with or without
6b8e788a5SAdrian Chadd  * modification, are permitted provided that the following conditions
7b8e788a5SAdrian Chadd  * are met:
8b8e788a5SAdrian Chadd  * 1. Redistributions of source code must retain the above copyright
9b8e788a5SAdrian Chadd  *    notice, this list of conditions and the following disclaimer,
10b8e788a5SAdrian Chadd  *    without modification.
11b8e788a5SAdrian Chadd  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12b8e788a5SAdrian Chadd  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13b8e788a5SAdrian Chadd  *    redistribution must be conditioned upon including a substantially
14b8e788a5SAdrian Chadd  *    similar Disclaimer requirement for further binary redistribution.
15b8e788a5SAdrian Chadd  *
16b8e788a5SAdrian Chadd  * NO WARRANTY
17b8e788a5SAdrian Chadd  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18b8e788a5SAdrian Chadd  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19b8e788a5SAdrian Chadd  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20b8e788a5SAdrian Chadd  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21b8e788a5SAdrian Chadd  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22b8e788a5SAdrian Chadd  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23b8e788a5SAdrian Chadd  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24b8e788a5SAdrian Chadd  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25b8e788a5SAdrian Chadd  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26b8e788a5SAdrian Chadd  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27b8e788a5SAdrian Chadd  * THE POSSIBILITY OF SUCH DAMAGES.
28b8e788a5SAdrian Chadd  *
29b8e788a5SAdrian Chadd  * $FreeBSD$
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 
42b8e788a5SAdrian Chadd /* unaligned little endian access */
43b8e788a5SAdrian Chadd #define LE_READ_2(p)							\
44b8e788a5SAdrian Chadd 	((u_int16_t)							\
45b8e788a5SAdrian Chadd 	 ((((u_int8_t *)(p))[0]      ) | (((u_int8_t *)(p))[1] <<  8)))
46b8e788a5SAdrian Chadd #define LE_READ_4(p)							\
47b8e788a5SAdrian Chadd 	((u_int32_t)							\
48b8e788a5SAdrian Chadd 	 ((((u_int8_t *)(p))[0]      ) | (((u_int8_t *)(p))[1] <<  8) |	\
49b8e788a5SAdrian Chadd 	  (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24)))
50b8e788a5SAdrian Chadd 
51b8e788a5SAdrian Chadd extern int ath_tx_findrix(const struct ath_softc *sc, uint8_t rate);
52b8e788a5SAdrian Chadd 
53b8e788a5SAdrian Chadd extern struct ath_buf * ath_getbuf(struct ath_softc *sc);
54b8e788a5SAdrian Chadd extern struct ath_buf * _ath_getbuf_locked(struct ath_softc *sc);
55e346b073SAdrian Chadd extern struct ath_buf * ath_buf_clone(struct ath_softc *sc,
56e346b073SAdrian Chadd 	    const struct ath_buf *bf);
579352fb7aSAdrian Chadd extern void ath_freebuf(struct ath_softc *sc, struct ath_buf *bf);
58b8e788a5SAdrian Chadd 
59517526efSAdrian Chadd extern int ath_reset(struct ifnet *, ATH_RESET_TYPE);
609352fb7aSAdrian Chadd extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq);
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,
65eb6f0de0SAdrian Chadd 	    struct ath_tx_status *ts, int frmlen, int nframes, int nbad);
669352fb7aSAdrian Chadd 
679352fb7aSAdrian Chadd extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf,
689352fb7aSAdrian Chadd     int status);
696079fdbeSAdrian Chadd 
70ba5c15d9SAdrian Chadd extern void ath_txqmove(struct ath_txq *dst, struct ath_txq *src);
71ba5c15d9SAdrian Chadd 
72e60c4fc2SAdrian Chadd extern void ath_mode_init(struct ath_softc *sc);
73e60c4fc2SAdrian Chadd 
74e60c4fc2SAdrian Chadd extern void ath_setdefantenna(struct ath_softc *sc, u_int antenna);
75e60c4fc2SAdrian Chadd 
76ba5c15d9SAdrian Chadd extern void ath_setslottime(struct ath_softc *sc);
77ba5c15d9SAdrian Chadd 
78e60c4fc2SAdrian Chadd /*
79e60c4fc2SAdrian Chadd  * This is only here so that the RX proc function can call it.
80e60c4fc2SAdrian Chadd  * It's very likely that the "start TX after RX" call should be
81e60c4fc2SAdrian Chadd  * done via something in if_ath.c, moving "rx tasklet" into
82e60c4fc2SAdrian Chadd  * if_ath.c and do the ath_start() call there.  Once that's done,
83e60c4fc2SAdrian Chadd  * we can kill this.
84e60c4fc2SAdrian Chadd  */
85e60c4fc2SAdrian Chadd extern void ath_start(struct ifnet *ifp);
86e60c4fc2SAdrian Chadd 
8714d33c7eSAdrian Chadd static inline void
8814d33c7eSAdrian Chadd ath_tx_kick(struct ath_softc *sc)
8914d33c7eSAdrian Chadd {
9014d33c7eSAdrian Chadd 
91*9f956098SAdrian Chadd 	ath_start(sc->sc_ifp);
9214d33c7eSAdrian Chadd }
93ba5c15d9SAdrian Chadd 
94b8e788a5SAdrian Chadd #endif
95