if_ath_alq.h revision 243158
1/*-
2 * Copyright (c) 2012 Adrian Chadd
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer,
10 *    without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 *    redistribution must be conditioned upon including a substantially
14 *    similar Disclaimer requirement for further binary redistribution.
15 *
16 * NO WARRANTY
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
29 * $FreeBSD: head/sys/dev/ath/if_ath_alq.h 243158 2012-11-16 19:39:29Z adrian $
30 */
31#ifndef	__IF_ATH_ALQ_H__
32#define	__IF_ATH_ALQ_H__
33
34#define	ATH_ALQ_INIT_STATE		1
35struct if_ath_alq_init_state {
36	uint32_t	sc_mac_version;
37	uint32_t	sc_mac_revision;
38	uint32_t	sc_phy_rev;
39	uint32_t	sc_hal_magic;
40};
41
42#define	ATH_ALQ_EDMA_TXSTATUS		2
43#define	ATH_ALQ_EDMA_RXSTATUS		3
44#define	ATH_ALQ_EDMA_TXDESC		4
45
46/*
47 * These will always be logged, regardless.
48 */
49#define	ATH_ALQ_LOG_ALWAYS_MASK		0x00000001
50
51#define	ATH_ALQ_FILENAME_LEN	128
52#define	ATH_ALQ_DEVNAME_LEN	32
53
54struct if_ath_alq {
55	uint32_t	sc_alq_debug;		/* Debug flags to report */
56	struct alq *	sc_alq_alq;		/* alq state */
57	unsigned int	sc_alq_qsize;		/* queue size */
58	unsigned int	sc_alq_numlost;		/* number of "lost" entries */
59	int		sc_alq_isactive;
60	char		sc_alq_devname[ATH_ALQ_DEVNAME_LEN];
61	char		sc_alq_filename[ATH_ALQ_FILENAME_LEN];
62	struct if_ath_alq_init_state sc_alq_cfg;
63};
64
65/* 128 bytes in total */
66#define	ATH_ALQ_PAYLOAD_LEN		112
67
68struct if_ath_alq_hdr {
69	uint64_t	threadid;
70	uint32_t	tstamp;
71	uint16_t	op;
72	uint16_t	len;	/* Length of (optional) payload */
73};
74
75struct if_ath_alq_payload {
76	struct if_ath_alq_hdr hdr;
77	char		payload[];
78};
79
80#ifdef	_KERNEL
81static inline int
82if_ath_alq_checkdebug(struct if_ath_alq *alq, uint16_t op)
83{
84
85	return ((alq->sc_alq_debug | ATH_ALQ_LOG_ALWAYS_MASK)
86	    & (1 << (op - 1)));
87}
88
89extern	void if_ath_alq_init(struct if_ath_alq *alq, const char *devname);
90extern	void if_ath_alq_setcfg(struct if_ath_alq *alq, uint32_t macVer,
91	    uint32_t macRev, uint32_t phyRev, uint32_t halMagic);
92extern	void if_ath_alq_tidyup(struct if_ath_alq *alq);
93extern	int if_ath_alq_start(struct if_ath_alq *alq);
94extern	int if_ath_alq_stop(struct if_ath_alq *alq);
95extern	void if_ath_alq_post(struct if_ath_alq *alq, uint16_t op,
96	    uint16_t len, const char *buf);
97#endif	/* _KERNEL */
98
99#endif
100