xref: /freebsd/sys/dev/ath/if_ath_misc.h (revision 3d184db2f82e0bfab9e52a155be9d3eb8c71382a)
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 
51*3d184db2SAdrian Chadd extern int ath_rxbuf;
52*3d184db2SAdrian Chadd extern int ath_txbuf;
53*3d184db2SAdrian Chadd extern int ath_txbuf_mgmt;
54*3d184db2SAdrian Chadd 
55b8e788a5SAdrian Chadd extern int ath_tx_findrix(const struct ath_softc *sc, uint8_t rate);
56b8e788a5SAdrian Chadd 
57af33d486SAdrian Chadd extern struct ath_buf * ath_getbuf(struct ath_softc *sc,
58af33d486SAdrian Chadd 	    ath_buf_type_t btype);
59af33d486SAdrian Chadd extern struct ath_buf * _ath_getbuf_locked(struct ath_softc *sc,
60af33d486SAdrian Chadd 	    ath_buf_type_t btype);
61e346b073SAdrian Chadd extern struct ath_buf * ath_buf_clone(struct ath_softc *sc,
62e346b073SAdrian Chadd 	    const struct ath_buf *bf);
63af33d486SAdrian Chadd /* XXX change this to NULL the buffer pointer? */
649352fb7aSAdrian Chadd extern void ath_freebuf(struct ath_softc *sc, struct ath_buf *bf);
65e1a50456SAdrian Chadd extern void ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf);
66e1a50456SAdrian Chadd extern void ath_returnbuf_tail(struct ath_softc *sc, struct ath_buf *bf);
67b8e788a5SAdrian Chadd 
68517526efSAdrian Chadd extern int ath_reset(struct ifnet *, ATH_RESET_TYPE);
699352fb7aSAdrian Chadd extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq);
709352fb7aSAdrian Chadd extern void ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf,
719352fb7aSAdrian Chadd 	    int fail);
72eb6f0de0SAdrian Chadd extern void ath_tx_update_ratectrl(struct ath_softc *sc,
73eb6f0de0SAdrian Chadd 	    struct ieee80211_node *ni, struct ath_rc_series *rc,
74eb6f0de0SAdrian Chadd 	    struct ath_tx_status *ts, int frmlen, int nframes, int nbad);
759352fb7aSAdrian Chadd 
769352fb7aSAdrian Chadd extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf,
779352fb7aSAdrian Chadd     int status);
786079fdbeSAdrian Chadd 
79ba5c15d9SAdrian Chadd extern void ath_txqmove(struct ath_txq *dst, struct ath_txq *src);
80ba5c15d9SAdrian Chadd 
81e60c4fc2SAdrian Chadd extern void ath_mode_init(struct ath_softc *sc);
82e60c4fc2SAdrian Chadd 
83e60c4fc2SAdrian Chadd extern void ath_setdefantenna(struct ath_softc *sc, u_int antenna);
84e60c4fc2SAdrian Chadd 
85ba5c15d9SAdrian Chadd extern void ath_setslottime(struct ath_softc *sc);
86ba5c15d9SAdrian Chadd 
87*3d184db2SAdrian Chadd extern	int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
88*3d184db2SAdrian Chadd 	    ath_bufhead *head, const char *name, int nbuf, int ndesc);
89*3d184db2SAdrian Chadd extern	void ath_descdma_cleanup(struct ath_softc *sc,
90*3d184db2SAdrian Chadd 	    struct ath_descdma *dd, ath_bufhead *head);
91*3d184db2SAdrian Chadd 
92e60c4fc2SAdrian Chadd /*
93e60c4fc2SAdrian Chadd  * This is only here so that the RX proc function can call it.
94e60c4fc2SAdrian Chadd  * It's very likely that the "start TX after RX" call should be
95e60c4fc2SAdrian Chadd  * done via something in if_ath.c, moving "rx tasklet" into
96e60c4fc2SAdrian Chadd  * if_ath.c and do the ath_start() call there.  Once that's done,
97e60c4fc2SAdrian Chadd  * we can kill this.
98e60c4fc2SAdrian Chadd  */
99e60c4fc2SAdrian Chadd extern void ath_start(struct ifnet *ifp);
100e60c4fc2SAdrian Chadd 
10114d33c7eSAdrian Chadd static inline void
10214d33c7eSAdrian Chadd ath_tx_kick(struct ath_softc *sc)
10314d33c7eSAdrian Chadd {
10414d33c7eSAdrian Chadd 
1059f956098SAdrian Chadd 	ath_start(sc->sc_ifp);
10614d33c7eSAdrian Chadd }
107ba5c15d9SAdrian Chadd 
108b8e788a5SAdrian Chadd #endif
109