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 #ifndef PACKED
40 #define PACKED  __attribute__((packed))
41 #endif
42 #define NAN_CERT_VERSION                        5
43 #define NAN_MAX_DEBUG_MESSAGE_DATA_LEN          100
44 #define NAN_MAX_ALLOWED_DW_AWAKE_INTERVAL       16
45 
46 typedef struct {
47     /* NAN master rank being advertised by DE */
48     u64 master_rank;
49     /* NAN master preference being advertised by DE */
50     u8 master_pref;
51     /* random value being advertised by DE */
52     u8 random_factor;
53     /* hop_count from anchor master */
54     u8 hop_count;
55     u32 beacon_transmit_time;
56     /* NDP channel Frequency */
57     u32 ndp_channel_freq;
58 } NanStaParameter;
59 
60 /* NAN Data Path Supported Band */
61 typedef enum {
62     NAN_DATA_PATH_SUPPORTED_BAND_2G = 1,
63     NAN_DATA_PATH_SUPPORTED_BAND_5G = 2,
64     NAN_DATA_PATH_SUPPORT_DUAL_BAND = 3
65 } NdpSupportedBand;
66 
67 /* NAN Responder mode policy */
68 typedef enum {
69     NAN_DATA_RESPONDER_MODE_AUTO    = 0,
70     NAN_DATA_RESPONDER_MODE_ACCEPT  = 1,
71     NAN_DATA_RESPONDER_MODE_REJECT  = 2,
72     NAN_DATA_RESPONDER_MODE_COUNTER = 3,
73     NAN_DATA_RESPONDER_MODE_COUNTER_NO_CHANNEL_CHANGE = 4
74 } NanDataResponderMode;
75 
76 /* NAN Data Path M4 response type */
77 typedef enum {
78     NAN_DATA_PATH_M4_RESPONSE_ACCEPT = 1,
79     NAN_DATA_PATH_M4_RESPONSE_REJECT = 2,
80     NAN_DATA_PATH_M4_RESPONSE_BADMIC = 3
81 } NdpM4ResponseType;
82 
83 /* NAN NMF Security Clear type */
84 typedef enum {
85     NAN_NMF_CLEAR_DISABLE = 0,
86     NAN_NMF_CLEAR_ENABLE = 1
87 } NanNmfClearConfig;
88 
89 /* NAN Schedule type */
90 typedef enum {
91     NAN_SCHED_VALID = 0,
92     NAN_SCHED_INVALID_BAD_FA = 1,
93     NAN_SCHED_INVALID_BAD_NDC = 2,
94     NAN_SCHED_INVALID_BAD_IMMU = 3
95 } NanSchedType;
96 
97 /* NAN device type */
98 typedef enum {
99     NAN_DEVICE_TYPE_TEST_BED = 1,
100     NAN_DEVICE_TYPE_DUT = 2
101 } NanDeviceType;
102 
103 /* NAN NDPE absent or present */
104 typedef enum {
105     NAN_NDPE_ATTR_PRESENT = 0,
106     NAN_NDPE_ATTR_ABSENT = 1
107 } NanNdpeAttrType;
108 
109 /* NAN NDP absent or present */
110 typedef enum {
111     NAN_NDP_ATTR_ABSENT = 0,
112     NAN_NDP_ATTR_PRESENT = 1
113 } NanNdpAttrType;
114 
115  /*
116   * Definitions of debug subcommand type for the
117   * generic debug command.
118   */
119 typedef enum {
120     NAN_TEST_MODE_CMD_NAN_AVAILABILITY = 1,
121     NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE = 2,
122     NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL = 3,
123     NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS = 4,
124     NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE = 5,
125     NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE = 6,
126     NAN_TEST_MODE_CMD_NAN_SCHED_TYPE = 7,
127     NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG = 8,
128     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY = 9,
129     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE = 10,
130     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY = 11,
131     NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER = 12,
132     NAN_TEST_MODE_CMD_CONFIG_QOS = 13,
133     NAN_TEST_MODE_CMD_DEVICE_TYPE = 14,
134     NAN_TEST_MODE_CMD_DISABLE_NDPE = 15,
135     NAN_TEST_MODE_CMD_ENABLE_NDP = 16,
136 } NanDebugModeCmd;
137 
138 /*
139  * This debug command carries any one command type
140  * followed by corresponding command data content
141  * as indicated below.
142  *
143  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY
144  * content: NAN Avaiability attribute blob
145  *
146  * command: NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE
147  * content: u32 value (0 - Ignore 1 - Include immuatable,
148  *                     2 - Don't include immutable)
149  *
150  * command: NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL
151  * content: u32 channel_frequency; (0 - Ignore)
152  *
153  * command: NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS
154  * content: u32 supported_bands; (0 . Ignore, 1 . 2g,
155  *                                2 . 5g, 3 . 2g & 5g)
156  *
157  * command: NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE
158  * content: u32 auto_resp_mode; (0 . Auto, 1 . Accept,
159  *                               2 . Reject, 3 . Counter)
160  *
161  * command: NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE
162  * content: u32 m4_response_type; (0.Ignore, 1.Accept,
163  *                                 2.Reject, 3.BadMic)
164  *
165  * command: NAN_TEST_MODE_CMD_NAN_SCHED_TYPE
166  * content: u32 invalid_nan_schedule; (0. Valid sched,
167  *                                     1.Invalid Sched bad FA,
168  *                                     2.Invalid schedbad NDC,
169  *                                     3.Invalid sched bad Immutable)
170  *
171  * command: NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG
172  * content: u32 nmf_security_config_val;(0:NAN_NMF_CLEAR_DISABLE,
173  *                                       1:NAN_NMF_CLEAR_ENABLE)
174  *
175  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY
176  * content: u32 channel_availability;(0/1)
177  *
178  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE
179  * content: responder_nmi_mac (Responder NMI Mac Address)
180  *
181  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY
182  * content: NONE
183  *
184  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER
185  * content: u32 map_order_val; (0/1)
186  *
187  */
188 typedef struct PACKED {
189     /*
190      * To indicate the debug command type.
191      */
192     u32 cmd;
193     /*
194      * To hold the data for the above command
195      * type.
196      */
197     u8 debug_cmd_data[NAN_MAX_DEBUG_MESSAGE_DATA_LEN];
198 } NanDebugParams;
199 
200 /*
201    Function to get the sta_parameter expected by Sigma
202    as per CAPI spec.
203 */
204 wifi_error nan_get_sta_parameter(transaction_id id,
205                                  wifi_interface_handle iface,
206                                  NanStaParameter* msg);
207 
208 wifi_error nan_debug_command_config(transaction_id id,
209                                    wifi_interface_handle iface,
210                                    NanDebugParams msg,
211                                    int debug_msg_length);
212 #ifdef __cplusplus
213 }
214 #endif /* __cplusplus */
215 #endif /* __NAN_CERT_H__ */
216 
217