1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLWLAN_IMPL_H
27 #define	_LIBDLWLAN_IMPL_H
28 
29 #include <sys/types.h>
30 #include <inet/wifi_ioctl.h>
31 #include <sys/mac.h>
32 
33 /*
34  * Implementation-private data structures, macros, and constants.
35  */
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Map a signal value from 0-15 into an enumerated strength.  Since there are
43  * 5 strengths but 16 values, by convention the "middle" strength gets the
44  * extra value.  Thus, the buckets are 0-2, 3-5, 6-9, 10-12, and 13-15.
45  */
46 #define	DLADM_WLAN_SIGNAL2STRENGTH(signal)			\
47 	    (((signal) > 12 ? DLADM_WLAN_STRENGTH_EXCELLENT :	\
48 	    ((signal) > 9 ? DLADM_WLAN_STRENGTH_VERY_GOOD : 	\
49 	    ((signal) > 5 ? DLADM_WLAN_STRENGTH_GOOD :		\
50 	    ((signal) > 2 ? DLADM_WLAN_STRENGTH_WEAK :		\
51 	    DLADM_WLAN_STRENGTH_VERY_WEAK)))))
52 
53 /*
54  * Convert between an OFDM MHz and a channel number.
55  */
56 #define	DLADM_WLAN_OFDM2CHAN(mhz)		(((mhz) - 5000) / 5)
57 
58 #define	DLADM_WLAN_CONNECT_POLLRATE		200 /* milliseconds */
59 
60 #define	DLADM_WLAN_MAX_RATES	4
61 typedef struct dladm_wlan_rates {
62 	uint8_t		wr_rates[DLADM_WLAN_MAX_RATES];
63 	int		wr_cnt;
64 } dladm_wlan_rates_t;
65 
66 typedef enum {
67 	DLADM_WLAN_RADIO_ON = 1,
68 	DLADM_WLAN_RADIO_OFF
69 } dladm_wlan_radio_t;
70 
71 typedef enum {
72 	DLADM_WLAN_PM_OFF = 1,
73 	DLADM_WLAN_PM_MAX,
74 	DLADM_WLAN_PM_FAST
75 } dladm_wlan_powermode_t;
76 
77 extern	dladm_status_t i_dladm_wlan_legacy_ioctl(dladm_handle_t,
78 			    datalink_id_t, wldp_t *, uint_t, size_t, uint_t,
79 			    size_t);
80 extern dladm_status_t	i_dladm_wlan_param(dladm_handle_t, datalink_id_t,
81 			    void *, mac_prop_id_t, size_t, boolean_t);
82 extern boolean_t	i_dladm_wlan_convert_chan(wl_phy_conf_t *, uint32_t *);
83 
84 #ifdef	__cplusplus
85 }
86 #endif
87 
88 #endif	/* _LIBDLWLAN_IMPL_H */
89