xref: /openbsd-src/sys/dev/ic/malo.h (revision 37ecb59650d3f381e0120446318f17da385095e3)
1*37ecb596Sderaadt /*	$OpenBSD: malo.h,v 1.12 2013/12/06 21:03:03 deraadt Exp $ */
20fb92cdaSclaudio 
39a5c977bSclaudio /*
49a5c977bSclaudio  * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
5b50d1de7Smglocker  * Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
69a5c977bSclaudio  *
79a5c977bSclaudio  * Permission to use, copy, modify, and distribute this software for any
89a5c977bSclaudio  * purpose with or without fee is hereby granted, provided that the above
99a5c977bSclaudio  * copyright notice and this permission notice appear in all copies.
109a5c977bSclaudio  *
119a5c977bSclaudio  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
129a5c977bSclaudio  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
139a5c977bSclaudio  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
149a5c977bSclaudio  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
159a5c977bSclaudio  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
169a5c977bSclaudio  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
179a5c977bSclaudio  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
189a5c977bSclaudio  */
199a5c977bSclaudio 
2066a8c19bSclaudio struct malo_rx_desc;
2166a8c19bSclaudio struct malo_rx_data;
2266a8c19bSclaudio 
2366a8c19bSclaudio struct malo_rx_ring {
2466a8c19bSclaudio 	bus_dmamap_t		map;
2566a8c19bSclaudio 	bus_dma_segment_t	seg;
2666a8c19bSclaudio 	bus_addr_t		physaddr;
2766a8c19bSclaudio 	struct malo_rx_desc	*desc;
2866a8c19bSclaudio 	struct malo_rx_data	*data;
2966a8c19bSclaudio 	int			count;
3066a8c19bSclaudio 	int			cur;
3166a8c19bSclaudio 	int			next;
3266a8c19bSclaudio };
3366a8c19bSclaudio 
34e280f016Sclaudio struct malo_tx_desc;
35e280f016Sclaudio struct malo_tx_data;
36e280f016Sclaudio 
37e280f016Sclaudio struct malo_tx_ring {
38e280f016Sclaudio 	bus_dmamap_t		map;
39e280f016Sclaudio 	bus_dma_segment_t	seg;
40e280f016Sclaudio 	bus_addr_t		physaddr;
41e280f016Sclaudio 	struct malo_tx_desc	*desc;
42e280f016Sclaudio 	struct malo_tx_data	*data;
43e280f016Sclaudio 	int			count;
44e280f016Sclaudio 	int			queued;
45e280f016Sclaudio 	int			cur;
46e280f016Sclaudio 	int			next;
47e280f016Sclaudio 	int			stat;
48e280f016Sclaudio };
49e280f016Sclaudio 
50b8966d96Smglocker #define MALO_RX_RADIOTAP_PRESENT					\
51b8966d96Smglocker 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
52b8966d96Smglocker 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
53b8966d96Smglocker 	 (1 << IEEE80211_RADIOTAP_RSSI))
54b8966d96Smglocker 
55b8966d96Smglocker struct malo_rx_radiotap_hdr {
56b8966d96Smglocker 	struct ieee80211_radiotap_header	wr_ihdr;
57b8966d96Smglocker 	uint8_t					wr_flags;
58b8966d96Smglocker 	uint16_t				wr_chan_freq;
59b8966d96Smglocker 	uint16_t				wr_chan_flags;
60b8966d96Smglocker 	uint8_t					wr_rssi;
61b8966d96Smglocker 	uint8_t					wr_max_rssi;
62b8966d96Smglocker } __packed;
63b8966d96Smglocker 
64b8966d96Smglocker #define MALO_TX_RADIOTAP_PRESENT					\
65b8966d96Smglocker 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
66b8966d96Smglocker 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
67b8966d96Smglocker 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
68b8966d96Smglocker 
69b8966d96Smglocker struct malo_tx_radiotap_hdr {
70b8966d96Smglocker 	struct ieee80211_radiotap_header	wt_ihdr;
71b8966d96Smglocker 	uint8_t					wt_flags;
72b8966d96Smglocker 	uint8_t					wt_rate;
73b8966d96Smglocker 	uint16_t				wt_chan_freq;
74b8966d96Smglocker 	uint16_t				wt_chan_flags;
75b8966d96Smglocker } __packed;
76b8966d96Smglocker 
779a5c977bSclaudio struct malo_softc {
789a5c977bSclaudio 	struct device		sc_dev;
799a5c977bSclaudio 	struct ieee80211com	sc_ic;
80e280f016Sclaudio 	struct malo_rx_ring	sc_rxring;
81e280f016Sclaudio 	struct malo_tx_ring	sc_txring;
829a5c977bSclaudio 
839a5c977bSclaudio 	bus_dma_tag_t		sc_dmat;
849a5c977bSclaudio 	bus_space_tag_t		sc_mem1_bt;
859a5c977bSclaudio 	bus_space_tag_t		sc_mem2_bt;
869a5c977bSclaudio 	bus_space_handle_t	sc_mem1_bh;
879a5c977bSclaudio 	bus_space_handle_t	sc_mem2_bh;
889a5c977bSclaudio 
899a5c977bSclaudio 	bus_dmamap_t		sc_cmd_dmam;
909a5c977bSclaudio 	bus_dma_segment_t	sc_cmd_dmas;
919a5c977bSclaudio 	void			*sc_cmd_mem;
929a5c977bSclaudio 	bus_addr_t		sc_cmd_dmaaddr;
939a5c977bSclaudio 	uint32_t		*sc_cookie;
949a5c977bSclaudio 	bus_addr_t		sc_cookie_dmaaddr;
959a5c977bSclaudio 
96dee33123Smglocker 	uint32_t		sc_RxPdWrPtr;
97dee33123Smglocker 	uint32_t		sc_RxPdRdPtr;
98dee33123Smglocker 
999a5c977bSclaudio 	int			(*sc_newstate)
1009a5c977bSclaudio 				(struct ieee80211com *,
1019a5c977bSclaudio 				 enum ieee80211_state, int);
1029a5c977bSclaudio 
1039a5c977bSclaudio 	int			(*sc_enable)(struct malo_softc *);
1049a5c977bSclaudio 	void			(*sc_disable)(struct malo_softc *);
105b8966d96Smglocker 
106b50d1de7Smglocker 	struct timeout		sc_scan_to;
1073258cee5Smglocker 	int			sc_tx_timer;
108085e5c94Smglocker 	int			sc_last_txrate;
109b50d1de7Smglocker 
110b8966d96Smglocker #if NBPFILTER > 0
111b8966d96Smglocker 	caddr_t		sc_drvbpf;
112b8966d96Smglocker 
113b8966d96Smglocker 	union {
114b8966d96Smglocker 		struct malo_rx_radiotap_hdr th;
115b8966d96Smglocker 		uint8_t pad[64];
116b8966d96Smglocker 	}		sc_rxtapu;
117b8966d96Smglocker #define sc_rxtap	sc_rxtapu.th
118b8966d96Smglocker 	int		sc_rxtap_len;
119b8966d96Smglocker 
120b8966d96Smglocker 	union {
121b8966d96Smglocker 		struct malo_tx_radiotap_hdr th;
122b8966d96Smglocker 		uint8_t pad[64];
123b8966d96Smglocker 	}		sc_txtapu;
124b8966d96Smglocker #define sc_txtap	sc_txtapu.th
125b8966d96Smglocker 	int		sc_txtap_len;
126b8966d96Smglocker #endif
1279a5c977bSclaudio };
1289a5c977bSclaudio 
1299a5c977bSclaudio int malo_intr(void *arg);
1309a5c977bSclaudio int malo_attach(struct malo_softc *sc);
1319a5c977bSclaudio int malo_detach(void *arg);
132c8904f75Sderaadt int malo_init(struct ifnet *);
133c8904f75Sderaadt void malo_stop(struct malo_softc *);
134