xref: /freebsd/sys/dev/bwi/bwimac.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
5  *
6  * This code is derived from software contributed to The DragonFly Project
7  * by Sepherosa Ziehau <sepherosa@gmail.com>
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in
17  *    the documentation and/or other materials provided with the
18  *    distribution.
19  * 3. Neither the name of The DragonFly Project nor the names of its
20  *    contributors may be used to endorse or promote products derived
21  *    from this software without specific, prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
27  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * $DragonFly: src/sys/dev/netif/bwi/bwimac.h,v 1.2 2008/02/15 11:15:38 sephe Exp $
37  */
38 
39 #ifndef _BWI_MAC_H
40 #define _BWI_MAC_H
41 
42 int		bwi_mac_attach(struct bwi_softc *, int, uint8_t);
43 int		bwi_mac_lateattach(struct bwi_mac *);
44 void		bwi_mac_detach(struct bwi_mac *);
45 int		bwi_mac_init(struct bwi_mac *);
46 void		bwi_mac_reset(struct bwi_mac *, int);
47 int		bwi_mac_start(struct bwi_mac *);
48 int		bwi_mac_stop(struct bwi_mac *);
49 void		bwi_mac_shutdown(struct bwi_mac *);
50 void		bwi_mac_updateslot(struct bwi_mac *, int);
51 void		bwi_mac_set_promisc(struct bwi_mac *, int);
52 
53 void		bwi_mac_calibrate_txpower(struct bwi_mac *,
54 					  enum bwi_txpwrcb_type);
55 void		bwi_mac_set_tpctl_11bg(struct bwi_mac *,
56 				       const struct bwi_tpctl *);
57 void		bwi_mac_init_tpctl_11bg(struct bwi_mac *);
58 void		bwi_mac_dummy_xmit(struct bwi_mac *);
59 void		bwi_mac_reset_hwkeys(struct bwi_mac *);
60 int		bwi_mac_config_ps(struct bwi_mac *);
61 int		bwi_mac_fw_alloc(struct bwi_mac *);
62 
63 uint16_t	bwi_memobj_read_2(struct bwi_mac *, uint16_t, uint16_t);
64 uint32_t	bwi_memobj_read_4(struct bwi_mac *, uint16_t, uint16_t);
65 void		bwi_memobj_write_2(struct bwi_mac *, uint16_t, uint16_t,
66 				   uint16_t);
67 void		bwi_memobj_write_4(struct bwi_mac *, uint16_t, uint16_t,
68 				   uint32_t);
69 void		bwi_tmplt_write_4(struct bwi_mac *, uint32_t, uint32_t);
70 void		bwi_hostflags_write(struct bwi_mac *, uint64_t);
71 uint64_t	bwi_hostflags_read(struct bwi_mac *);
72 
73 #define MOBJ_WRITE_2(mac, objid, ofs, val)	\
74 	bwi_memobj_write_2((mac), (objid), (ofs), (val))
75 #define MOBJ_WRITE_4(mac, objid, ofs, val)	\
76 	bwi_memobj_write_4((mac), (objid), (ofs), (val))
77 #define MOBJ_READ_2(mac, objid, ofs)		\
78 	bwi_memobj_read_2((mac), (objid), (ofs))
79 #define MOBJ_READ_4(mac, objid, ofs)		\
80 	bwi_memobj_read_4((mac), (objid), (ofs))
81 
82 #define MOBJ_SETBITS_4(mac, objid, ofs, bits)	\
83 	MOBJ_WRITE_4((mac), (objid), (ofs),	\
84 		     MOBJ_READ_4((mac), (objid), (ofs)) | (bits))
85 #define MOBJ_CLRBITS_4(mac, objid, ofs, bits)	\
86 	MOBJ_WRITE_4((mac), (objid), (ofs),	\
87 		     MOBJ_READ_4((mac), (objid), (ofs)) & ~(bits))
88 
89 #define MOBJ_FILT_SETBITS_2(mac, objid, ofs, filt, bits) \
90 	MOBJ_WRITE_2((mac), (objid), (ofs),	\
91 		     (MOBJ_READ_2((mac), (objid), (ofs)) & (filt)) | (bits))
92 
93 #define TMPLT_WRITE_4(mac, ofs, val)	bwi_tmplt_write_4((mac), (ofs), (val))
94 
95 #define HFLAGS_WRITE(mac, flags)	bwi_hostflags_write((mac), (flags))
96 #define HFLAGS_READ(mac)		bwi_hostflags_read((mac))
97 #define HFLAGS_CLRBITS(mac, bits)	\
98 	HFLAGS_WRITE((mac), HFLAGS_READ((mac)) | (bits))
99 #define HFLAGS_SETBITS(mac, bits)	\
100 	HFLAGS_WRITE((mac), HFLAGS_READ((mac)) & ~(bits))
101 
102 #endif	/* !_BWI_MAC_H */
103