xref: /illumos-gate/usr/src/lib/libdladm/common/libdlwlan_impl.h (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
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 2007 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 #define	DLADM_WLAN_CONNECT_DEFAULT_CHANNEL	1
61 
62 #define	DLADM_WLAN_MAX_RATES	4
63 typedef	struct dladm_wlan_rates {
64 	uint8_t		wr_rates[DLADM_WLAN_MAX_RATES];
65 	int		wr_cnt;
66 } dladm_wlan_rates_t;
67 
68 typedef enum {
69 	DLADM_WLAN_RADIO_ON = 1,
70 	DLADM_WLAN_RADIO_OFF
71 } dladm_wlan_radio_t;
72 
73 typedef	enum {
74 	DLADM_WLAN_PM_OFF = 1,
75 	DLADM_WLAN_PM_MAX,
76 	DLADM_WLAN_PM_FAST
77 } dladm_wlan_powermode_t;
78 
79 #ifdef	__cplusplus
80 }
81 #endif
82 
83 #endif	/* _LIBDLWLAN_IMPL_H */
84