xref: /openbsd/sys/dev/ic/if_wivar.h (revision 49e2ec9e)
1 /*	$OpenBSD: if_wivar.h,v 1.30 2010/08/30 20:42:27 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1997, 1998, 1999
5  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Bill Paul.
18  * 4. Neither the name of the author nor the names of any co-contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *	From: if_wireg.h,v 1.8.2.2 2001/08/25 00:48:25 nsayer Exp $
35  */
36 
37 #include <dev/ic/if_wi_hostap.h>
38 
39 struct wi_softc	{
40 	struct device		sc_dev;
41 	struct ieee80211com	sc_ic;
42 	struct ifmedia		sc_media;
43 	bus_space_handle_t	wi_bhandle;
44 	bus_space_tag_t		wi_btag;
45 	bus_space_handle_t	wi_lhandle;
46 	bus_space_tag_t		wi_ltag;
47 	bus_size_t		wi_cor_offset;
48 	int			wi_tx_data_id;
49 	int			wi_tx_mgmt_id;
50 	int			wi_flags;
51 	int			wi_if_flags;
52 	int			wi_cmd_count;
53 	u_int16_t		wi_procframe;
54 	u_int16_t		wi_ptype;
55 	u_int16_t		wi_portnum;
56 	u_int16_t		wi_max_data_len;
57 	u_int16_t		wi_rts_thresh;
58 	u_int16_t		wi_ap_density;
59 	u_int16_t		wi_tx_rate;
60 	u_int16_t		wi_create_ibss;
61 	u_int16_t		wi_channel;
62 	u_int16_t		wi_pm_enabled;
63 	u_int16_t		wi_mor_enabled;
64 	u_int16_t		wi_max_sleep;
65 	u_int16_t		wi_authtype;
66 	u_int16_t		wi_roaming;
67 	u_int16_t		wi_supprates;
68 	u_int16_t		wi_diversity;
69 
70 	u_int8_t		wi_rxbuf[1596];
71 	u_int8_t		wi_txbuf[1596];
72 	u_int8_t		wi_scanbuf[1596];
73 	int			wi_scan_lock;
74 	struct timeout		wi_scan_timeout;
75 
76 	u_int8_t		wi_scanbuf_len;
77 
78 	struct ieee80211_nwid	wi_node_name;
79 	struct ieee80211_nwid	wi_net_name;
80 	struct ieee80211_nwid	wi_ibss_name;
81 
82 	int			wi_use_wep;
83 	int			wi_enh_security;
84 	int			wi_crypto_algorithm;
85 	int			wi_tx_key;
86 	struct wi_ltv_keys	wi_keys;
87 	struct wi_counters	wi_stats;
88 	void			*sc_ih;
89 	struct timeout		sc_timo;
90 	int			sc_firmware_type;
91 	int			sc_sta_firmware_ver;
92 	int			sc_pci;
93 	struct wihap_info	wi_hostap_info;
94 	u_int32_t		wi_icv;
95 	int			wi_icv_flag;
96 	int			wi_ibss_port;
97 	int16_t			wi_txpower;
98 
99 	struct {
100 		u_int16_t		wi_sleep;
101 		u_int16_t		wi_delaysupp;
102 		u_int16_t		wi_txsupp;
103 		u_int16_t		wi_monitor;
104 		u_int16_t		wi_ledtest;
105 		u_int16_t		wi_ledtest_param0;
106 		u_int16_t		wi_ledtest_param1;
107 		u_int16_t		wi_conttx;
108 		u_int16_t		wi_conttx_param0;
109 		u_int16_t		wi_contrx;
110 		u_int16_t		wi_sigstate;
111 		u_int16_t		wi_sigstate_param0;
112 		u_int16_t		wi_confbits;
113 		u_int16_t		wi_confbits_param0;
114 	} wi_debug;
115 	struct wi_usb_softc		*wi_usb_cdata;
116 
117 	struct wi_funcs			*sc_funcs;
118 };
119 #define wi_cmd		sc->sc_funcs->f_cmd
120 #define wi_read_record	sc->sc_funcs->f_read_record
121 #define wi_write_record	sc->sc_funcs->f_write_record
122 #define wi_alloc_nicmem	sc->sc_funcs->f_alloc_nicmem
123 #define wi_read_data	sc->sc_funcs->f_read_data
124 #define wi_write_data	sc->sc_funcs->f_write_data
125 #define wi_get_fid	sc->sc_funcs->f_get_fid
126 #define wi_init		sc->sc_funcs->f_init
127 
128 /* Values for wi_flags. */
129 #define WI_FLAGS_ATTACHED		0x0001
130 #define WI_FLAGS_INITIALIZED		0x0002
131 #define WI_FLAGS_HAS_WEP		0x0004
132 #define WI_FLAGS_HAS_IBSS		0x0008
133 #define WI_FLAGS_HAS_CREATE_IBSS	0x0010
134 #define WI_FLAGS_HAS_MOR		0x0020
135 #define WI_FLAGS_HAS_ROAMING		0x0040
136 #define WI_FLAGS_HAS_DIVERSITY		0x0080
137 #define WI_FLAGS_HAS_HOSTAP		0x0100
138 #define WI_FLAGS_BUS_PCMCIA		0x0200
139 #define WI_FLAGS_BUS_USB		0x0400
140 #define WI_FLAGS_HAS_ENH_SECURITY	0x0800
141 #define WI_FLAGS_TXPOWER		0x1000
142 #define WI_FLAGS_BUSY			0x2000
143 
144 #define WI_PRT_FMT "%s"
145 #define WI_PRT_ARG(sc)	(sc)->sc_dev.dv_xname
146 
147 struct wi_funcs {
148 	int (*f_cmd)(struct wi_softc *sc, int cmd, int val0, int val1,
149 	    int val2);
150 	int (*f_read_record)(struct wi_softc *sc, struct wi_ltv_gen *ltv);
151 	int (*f_write_record)(struct wi_softc *sc,
152 	    struct wi_ltv_gen *ltv);
153 	int (*f_alloc_nicmem)(struct wi_softc *sc, int len, int *id);
154 	int (*f_read_data)(struct wi_softc *sc, int id, int off,
155 	    caddr_t buf, int len);
156 	int (*f_write_data)(struct wi_softc *sc, int id, int off,
157 	    caddr_t buf, int len);
158 	int (*f_get_fid)(struct wi_softc *sc, int fid);
159 	void (*f_init)(struct wi_softc *sc);
160 
161 	void (*f_start)(struct ifnet *ifp);
162 	int (*f_ioctl)(struct ifnet *, u_long, caddr_t);
163 	void (*f_watchdog)(struct ifnet *ifp);
164 	void (*f_inquire)(void *xsc);
165 };
166 
167 extern struct wi_funcs wi_func_io;
168 
169 int	wi_attach(struct wi_softc *, struct wi_funcs *);
170 void	wi_detach(struct wi_softc *);
171 int	wi_intr(void *);
172 void	wi_stop(struct wi_softc *);
173 void	wi_cor_reset(struct wi_softc *);
174 int	wi_mgmt_xmit(struct wi_softc *, caddr_t, int);
175 
176 void wi_update_stats(struct wi_softc *sc);
177 void wi_rxeof(struct wi_softc *sc);
178 void wi_txeof(struct wi_softc *sc, int status);
179