xref: /titanic_44/usr/src/lib/libdladm/common/libdlwlan_impl.h (revision 98157a7002f4f2cf7978f3084ca5577f0a1d72b2)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <inet/wifi_ioctl.h>
33 
34 /*
35  * Implementation-private data structures, macros, and constants.
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Map a signal value from 0-15 into an enumerated strength.  Since there are
44  * 5 strengths but 16 values, by convention the "middle" strength gets the
45  * extra value.  Thus, the buckets are 0-2, 3-5, 6-9, 10-12, and 13-15.
46  */
47 #define	DLADM_WLAN_SIGNAL2STRENGTH(signal)			\
48 	    (((signal) > 12 ? DLADM_WLAN_STRENGTH_EXCELLENT :	\
49 	    ((signal) > 9 ? DLADM_WLAN_STRENGTH_VERY_GOOD : 	\
50 	    ((signal) > 5 ? DLADM_WLAN_STRENGTH_GOOD :		\
51 	    ((signal) > 2 ? DLADM_WLAN_STRENGTH_WEAK :		\
52 	    DLADM_WLAN_STRENGTH_VERY_WEAK)))))
53 
54 /*
55  * Convert between an OFDM MHz and a channel number.
56  */
57 #define	DLADM_WLAN_OFDM2CHAN(mhz)		(((mhz) - 5000) / 5)
58 
59 #define	DLADM_WLAN_CONNECT_POLLRATE		200 /* milliseconds */
60 
61 #define	DLADM_WLAN_MAX_RATES	4
62 typedef struct dladm_wlan_rates {
63 	uint8_t		wr_rates[DLADM_WLAN_MAX_RATES];
64 	int		wr_cnt;
65 } dladm_wlan_rates_t;
66 
67 typedef enum {
68 	DLADM_WLAN_RADIO_ON = 1,
69 	DLADM_WLAN_RADIO_OFF
70 } dladm_wlan_radio_t;
71 
72 typedef enum {
73 	DLADM_WLAN_PM_OFF = 1,
74 	DLADM_WLAN_PM_MAX,
75 	DLADM_WLAN_PM_FAST
76 } dladm_wlan_powermode_t;
77 
78 extern dladm_status_t	i_dladm_wlan_get_ioctl(datalink_id_t, wldp_t *,
79 			    uint_t);
80 extern dladm_status_t	i_dladm_wlan_set_ioctl(datalink_id_t, uint_t,
81 			    void *, uint_t);
82 extern dladm_status_t	i_dladm_wlan_ioctl(datalink_id_t, wldp_t *, uint_t,
83 			    size_t, uint_t, size_t);
84 extern boolean_t	i_dladm_wlan_convert_chan(wl_phy_conf_t *, uint32_t *);
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif	/* _LIBDLWLAN_IMPL_H */
91