1 /*
2  * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
3 
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above
10  *       copyright notice, this list of conditions and the following
11  *       disclaimer in the documentation and/or other materials provided
12  *       with the distribution.
13  *     * Neither the name of The Linux Foundation nor the names of its
14  *       contributors may be used to endorse or promote products derived
15  *       from this software without specific prior written permission.
16 
17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __NAN_CERT_H__
31 #define __NAN_CERT_H__
32 
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif /* __cplusplus */
38 
39 #define NAN_CERT_VERSION                        4
40 #define NAN_MAX_DEBUG_MESSAGE_DATA_LEN          100
41 #define NAN_MAX_ALLOWED_DW_AWAKE_INTERVAL       16
42 
43 typedef struct {
44     /* NAN master rank being advertised by DE */
45     u64 master_rank;
46     /* NAN master preference being advertised by DE */
47     u8 master_pref;
48     /* random value being advertised by DE */
49     u8 random_factor;
50     /* hop_count from anchor master */
51     u8 hop_count;
52     u32 beacon_transmit_time;
53     /* NDP channel Frequency */
54     u32 ndp_channel_freq;
55 } NanStaParameter;
56 
57 /* NAN Data Path Supported Band */
58 typedef enum {
59     NAN_DATA_PATH_SUPPORTED_BAND_2G = 1,
60     NAN_DATA_PATH_SUPPORTED_BAND_5G = 2,
61     NAN_DATA_PATH_SUPPORT_DUAL_BAND = 3
62 } NdpSupportedBand;
63 
64 /* NAN Responder mode policy */
65 typedef enum {
66     NAN_DATA_RESPONDER_MODE_AUTO    = 0,
67     NAN_DATA_RESPONDER_MODE_ACCEPT  = 1,
68     NAN_DATA_RESPONDER_MODE_REJECT  = 2,
69     NAN_DATA_RESPONDER_MODE_COUNTER = 3,
70     NAN_DATA_RESPONDER_MODE_COUNTER_NO_CHANNEL_CHANGE = 4
71 } NanDataResponderMode;
72 
73 /* NAN Data Path M4 response type */
74 typedef enum {
75     NAN_DATA_PATH_M4_RESPONSE_ACCEPT = 1,
76     NAN_DATA_PATH_M4_RESPONSE_REJECT = 2,
77     NAN_DATA_PATH_M4_RESPONSE_BADMIC = 3
78 } NdpM4ResponseType;
79 
80 /* NAN NMF Security Clear type */
81 typedef enum {
82     NAN_NMF_CLEAR_DISABLE = 0,
83     NAN_NMF_CLEAR_ENABLE = 1
84 } NanNmfClearConfig;
85 
86 /* NAN Schedule type */
87 typedef enum {
88     NAN_SCHED_VALID = 0,
89     NAN_SCHED_INVALID_BAD_FA = 1,
90     NAN_SCHED_INVALID_BAD_NDC = 2,
91     NAN_SCHED_INVALID_BAD_IMMU = 3
92 } NanSchedType;
93 
94 /* NAN device type */
95 typedef enum {
96     NAN_DEVICE_TYPE_TEST_BED = 1,
97     NAN_DEVICE_TYPE_DUT = 2
98 } NanDeviceType;
99 
100  /*
101   * Definitions of debug subcommand type for the
102   * generic debug command.
103   */
104 typedef enum {
105     NAN_TEST_MODE_CMD_NAN_AVAILABILITY = 1,
106     NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE = 2,
107     NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL = 3,
108     NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS = 4,
109     NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE = 5,
110     NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE = 6,
111     NAN_TEST_MODE_CMD_NAN_SCHED_TYPE = 7,
112     NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG = 8,
113     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY = 9,
114     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE = 10,
115     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY = 11,
116     NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER = 12,
117     NAN_TEST_MODE_CMD_CONFIG_QOS = 13,
118     NAN_TEST_MODE_CMD_DEVICE_TYPE = 14
119 } NanDebugModeCmd;
120 
121 /*
122  * This debug command carries any one command type
123  * followed by corresponding command data content
124  * as indicated below.
125  *
126  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY
127  * content: NAN Avaiability attribute blob
128  *
129  * command: NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE
130  * content: u32 value (0 - Ignore 1 - Include immuatable,
131  *                     2 - Don't include immutable)
132  *
133  * command: NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL
134  * content: u32 channel_frequency; (0 - Ignore)
135  *
136  * command: NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS
137  * content: u32 supported_bands; (0 . Ignore, 1 . 2g,
138  *                                2 . 5g, 3 . 2g & 5g)
139  *
140  * command: NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE
141  * content: u32 auto_resp_mode; (0 . Auto, 1 . Accept,
142  *                               2 . Reject, 3 . Counter)
143  *
144  * command: NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE
145  * content: u32 m4_response_type; (0.Ignore, 1.Accept,
146  *                                 2.Reject, 3.BadMic)
147  *
148  * command: NAN_TEST_MODE_CMD_NAN_SCHED_TYPE
149  * content: u32 invalid_nan_schedule; (0. Valid sched,
150  *                                     1.Invalid Sched bad FA,
151  *                                     2.Invalid schedbad NDC,
152  *                                     3.Invalid sched bad Immutable)
153  *
154  * command: NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG
155  * content: u32 nmf_security_config_val;(0:NAN_NMF_CLEAR_DISABLE,
156  *                                       1:NAN_NMF_CLEAR_ENABLE)
157  *
158  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY
159  * content: u32 channel_availability;(0/1)
160  *
161  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE
162  * content: responder_nmi_mac (Responder NMI Mac Address)
163  *
164  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY
165  * content: NONE
166  *
167  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER
168  * content: u32 map_order_val; (0/1)
169  *
170  */
171 typedef struct PACKED {
172     /*
173      * To indicate the debug command type.
174      */
175     u32 cmd;
176     /*
177      * To hold the data for the above command
178      * type.
179      */
180     u8 debug_cmd_data[NAN_MAX_DEBUG_MESSAGE_DATA_LEN];
181 } NanDebugParams;
182 
183 /*
184    Function to get the sta_parameter expected by Sigma
185    as per CAPI spec.
186 */
187 wifi_error nan_get_sta_parameter(transaction_id id,
188                                  wifi_interface_handle iface,
189                                  NanStaParameter* msg);
190 
191 wifi_error nan_debug_command_config(transaction_id id,
192                                    wifi_interface_handle iface,
193                                    NanDebugParams msg,
194                                    int debug_msg_length);
195 #ifdef __cplusplus
196 }
197 #endif /* __cplusplus */
198 #endif /* __NAN_CERT_H__ */
199 
200