1  /*
2   * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3   * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4   *
5   * Permission to use, copy, modify, and/or distribute this software for
6   * any purpose with or without fee is hereby granted, provided that the
7   * above copyright notice and this permission notice appear in all
8   * copies.
9   *
10   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11   * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12   * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13   * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14   * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15   * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16   * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17   * PERFORMANCE OF THIS SOFTWARE.
18   */
19  
20  /**
21   * DOC: contains nan definitions exposed to other modules
22   */
23  
24  #ifndef _NAN_PUBLIC_STRUCTS_H_
25  #define _NAN_PUBLIC_STRUCTS_H_
26  
27  #include "qdf_types.h"
28  #include "qdf_status.h"
29  #include "scheduler_api.h"
30  #if defined(CONFIG_HL_SUPPORT)
31  #include "wlan_tgt_def_config_hl.h"
32  #else
33  #include "wlan_tgt_def_config.h"
34  #endif
35  
36  struct wlan_objmgr_psoc;
37  struct wlan_objmgr_vdev;
38  
39  #define IFACE_NAME_SIZE 64
40  #define NDP_QOS_INFO_LEN 255
41  #define NDP_APP_INFO_LEN 255
42  #define NDP_PMK_LEN 32
43  #define NDP_SCID_BUF_LEN 256
44  #define NDP_NUM_INSTANCE_ID 255
45  #define NAN_MAX_SERVICE_NAME_LEN 255
46  #define NAN_PASSPHRASE_MIN_LEN 8
47  #define NAN_PASSPHRASE_MAX_LEN 63
48  #define NAN_CH_INFO_MAX_CHANNELS 4
49  #define WLAN_WAIT_TIME_NDP_END 4000
50  
51  #define NAN_PSEUDO_VDEV_ID CFG_TGT_NUM_VDEV
52  
53  #define NAN_SER_CMD_TIMEOUT 4000
54  #define NDP_SERVICE_ID_LEN 6
55  /**
56   * enum nan_discovery_msg_type - NAN msg type
57   * @NAN_GENERIC_REQ: Type for all the NAN requests other than enable/disable
58   * @NAN_ENABLE_REQ: Request type for enabling the NAN Discovery
59   * @NAN_DISABLE_REQ: Request type for disabling the NAN Discovery
60   */
61  enum nan_discovery_msg_type {
62  	NAN_GENERIC_REQ = 0,
63  	NAN_ENABLE_REQ  = 1,
64  	NAN_DISABLE_REQ = 2,
65  };
66  
67  /**
68   * enum nan_datapath_msg_type - NDP msg type
69   * @NAN_DATAPATH_INF_CREATE_REQ: ndi create request
70   * @NAN_DATAPATH_INF_CREATE_RSP: ndi create response
71   * @NAN_DATAPATH_INF_DELETE_REQ: ndi delete request
72   * @NAN_DATAPATH_INF_DELETE_RSP: ndi delete response
73   * @NDP_INITIATOR_REQ: ndp initiator request
74   * @NDP_INITIATOR_RSP: ndp initiator response
75   * @NDP_RESPONDER_REQ: ndp responder request
76   * @NDP_RESPONDER_RSP: ndp responder response
77   * @NDP_END_REQ: ndp end request
78   * @NDP_END_RSP: ndp end response
79   * @NDP_INDICATION: ndp indication
80   * @NDP_CONFIRM: ndp confirm
81   * @NDP_END_IND: ndp end indication
82   * @NDP_NEW_PEER: ndp new peer created
83   * @NDP_PEER_DEPARTED: ndp peer departed/deleted
84   * @NDP_SCHEDULE_UPDATE: ndp schedule update
85   * @NDP_END_ALL: end all NDPs request
86   * @NDP_HOST_UPDATE: update host about ndp status
87   */
88  enum nan_datapath_msg_type {
89  	NAN_DATAPATH_INF_CREATE_REQ  = 0,
90  	NAN_DATAPATH_INF_CREATE_RSP  = 1,
91  	NAN_DATAPATH_INF_DELETE_REQ  = 2,
92  	NAN_DATAPATH_INF_DELETE_RSP  = 3,
93  	NDP_INITIATOR_REQ            = 4,
94  	NDP_INITIATOR_RSP            = 5,
95  	NDP_RESPONDER_REQ            = 6,
96  	NDP_RESPONDER_RSP            = 7,
97  	NDP_END_REQ                  = 8,
98  	NDP_END_RSP                  = 9,
99  	NDP_INDICATION               = 10,
100  	NDP_CONFIRM                  = 11,
101  	NDP_END_IND                  = 12,
102  	NDP_NEW_PEER                 = 13,
103  	NDP_PEER_DEPARTED            = 14,
104  	NDP_SCHEDULE_UPDATE          = 15,
105  	NDP_END_ALL                  = 16,
106  	NDP_HOST_UPDATE              = 17,
107  };
108  
109  /**
110   * enum nan_datapath_status_type - NDP status type
111   * @NAN_DATAPATH_RSP_STATUS_SUCCESS: request was successful
112   * @NAN_DATAPATH_RSP_STATUS_ERROR: request failed
113   */
114  enum nan_datapath_status_type {
115  	NAN_DATAPATH_RSP_STATUS_SUCCESS = 0x00,
116  	NAN_DATAPATH_RSP_STATUS_ERROR = 0x01,
117  };
118  
119  /**
120   * enum nan_datapath_reason_code - NDP command rsp reason code value
121   * @NAN_DATAPATH_UNSUPPORTED_CONCURRENCY: Will be used in unsupported
122   *                                        concurrency cases
123   * @NAN_DATAPATH_NAN_DATA_IFACE_CREATE_FAILED: ndi create failed
124   * @NAN_DATAPATH_NAN_DATA_IFACE_DELETE_FAILED: ndi delete failed
125   * @NAN_DATAPATH_DATA_INITIATOR_REQ_FAILED: data initiator request failed
126   * @NAN_DATAPATH_DATA_RESPONDER_REQ_FAILED: data responder request failed
127   * @NAN_DATAPATH_INVALID_SERVICE_INSTANCE_ID: invalid service instance id
128   * @NAN_DATAPATH_INVALID_NDP_INSTANCE_ID: invalid ndp instance id
129   * @NAN_DATAPATH_INVALID_RSP_CODE: invalid response code in ndp responder
130   *                                 request
131   * @NAN_DATAPATH_INVALID_APP_INFO_LEN: invalid app info length
132   * @NAN_DATAPATH_NMF_REQ_FAIL: OTA nan mgmt frame failure for data request
133   * @NAN_DATAPATH_NMF_RSP_FAIL: OTA nan mgmt frame failure for data response
134   * @NAN_DATAPATH_NMF_CNF_FAIL: OTA nan mgmt frame failure for confirm
135   * @NAN_DATAPATH_END_FAILED: ndp end failed
136   * @NAN_DATAPATH_NMF_END_REQ_FAIL: OTA nan mgmt frame failure for data end
137   * @NAN_DATAPATH_VENDOR_SPECIFIC_ERROR: other vendor specific failures
138   */
139  enum nan_datapath_reason_code {
140  	NAN_DATAPATH_UNSUPPORTED_CONCURRENCY = 9000,
141  	NAN_DATAPATH_NAN_DATA_IFACE_CREATE_FAILED = 9001,
142  	NAN_DATAPATH_NAN_DATA_IFACE_DELETE_FAILED = 9002,
143  	NAN_DATAPATH_DATA_INITIATOR_REQ_FAILED = 9003,
144  	NAN_DATAPATH_DATA_RESPONDER_REQ_FAILED = 9004,
145  	NAN_DATAPATH_INVALID_SERVICE_INSTANCE_ID = 9005,
146  	NAN_DATAPATH_INVALID_NDP_INSTANCE_ID = 9006,
147  	NAN_DATAPATH_INVALID_RSP_CODE = 9007,
148  	NAN_DATAPATH_INVALID_APP_INFO_LEN = 9008,
149  	NAN_DATAPATH_NMF_REQ_FAIL = 9009,
150  	NAN_DATAPATH_NMF_RSP_FAIL = 9010,
151  	NAN_DATAPATH_NMF_CNF_FAIL = 9011,
152  	NAN_DATAPATH_END_FAILED = 9012,
153  	NAN_DATAPATH_NMF_END_REQ_FAIL = 9013,
154  	/* 9500 onwards vendor specific error codes */
155  	NAN_DATAPATH_VENDOR_SPECIFIC_ERROR = 9500,
156  };
157  
158  /**
159   * enum nan_datapath_response_code - responder's response code to nan data path
160   * request
161   * @NAN_DATAPATH_RESPONSE_ACCEPT: ndp request accepted
162   * @NAN_DATAPATH_RESPONSE_REJECT: ndp request rejected
163   * @NAN_DATAPATH_RESPONSE_DEFER: ndp request deferred until later (response to
164   * follow any time later)
165   */
166  enum nan_datapath_response_code {
167  	NAN_DATAPATH_RESPONSE_ACCEPT = 0,
168  	NAN_DATAPATH_RESPONSE_REJECT = 1,
169  	NAN_DATAPATH_RESPONSE_DEFER = 2,
170  };
171  
172  /**
173   * enum nan_datapath_accept_policy - nan data path accept policy
174   * @NAN_DATAPATH_ACCEPT_POLICY_NONE: the framework will decide the policy
175   * @NAN_DATAPATH_ACCEPT_POLICY_ALL: accept policy offloaded to fw
176   */
177  enum nan_datapath_accept_policy {
178  	NAN_DATAPATH_ACCEPT_POLICY_NONE = 0,
179  	NAN_DATAPATH_ACCEPT_POLICY_ALL = 1,
180  };
181  
182  /**
183   * enum nan_datapath_self_role - nan data path role
184   * @NAN_DATAPATH_ROLE_INITIATOR: initiator of nan data path request
185   * @NAN_DATAPATH_ROLE_RESPONDER: responder to nan data path request
186   */
187  enum nan_datapath_self_role {
188  	NAN_DATAPATH_ROLE_INITIATOR = 0,
189  	NAN_DATAPATH_ROLE_RESPONDER = 1,
190  };
191  
192  /**
193   * enum nan_datapath_end_type - NDP end type
194   * @NAN_DATAPATH_END_TYPE_UNSPECIFIED: type is unspecified
195   * @NAN_DATAPATH_END_TYPE_PEER_UNAVAILABLE: type is peer unavailable
196   * @NAN_DATAPATH_END_TYPE_OTA_FRAME: NDP end frame received from peer
197   */
198  enum nan_datapath_end_type {
199  	NAN_DATAPATH_END_TYPE_UNSPECIFIED = 0x00,
200  	NAN_DATAPATH_END_TYPE_PEER_UNAVAILABLE = 0x01,
201  	NAN_DATAPATH_END_TYPE_OTA_FRAME = 0x02,
202  };
203  
204  /**
205   * enum nan_datapath_end_reason_code - NDP end reason code
206   * @NAN_DATAPATH_END_REASON_UNSPECIFIED: reason is unspecified
207   * @NAN_DATAPATH_END_REASON_INACTIVITY: reason is peer inactivity
208   * @NAN_DATAPATH_END_REASON_PEER_DATA_END: data end indication received from
209   * peer
210   */
211  enum nan_datapath_end_reason_code {
212  	NAN_DATAPATH_END_REASON_UNSPECIFIED = 0x00,
213  	NAN_DATAPATH_END_REASON_INACTIVITY = 0x01,
214  	NAN_DATAPATH_END_REASON_PEER_DATA_END = 0x02,
215  };
216  
217  /**
218   * enum nan_datapath_state - NAN datapath states
219   * @NAN_DATA_INVALID_STATE: Invalid state
220   * @NAN_DATA_NDI_CREATING_STATE: NDI create is in progress
221   * @NAN_DATA_NDI_CREATED_STATE: NDI successfully created
222   * @NAN_DATA_NDI_DELETING_STATE: NDI delete is in progress
223   * @NAN_DATA_NDI_DELETED_STATE: NDI delete is in progress
224   * @NAN_DATA_PEER_CREATE_STATE: Peer create is in progress
225   * @NAN_DATA_PEER_DELETE_STATE: Peer delete is in progress
226   * @NAN_DATA_CONNECTING_STATE: Data connection in progress
227   * @NAN_DATA_CONNECTED_STATE: Data connection successful
228   * @NAN_DATA_END_STATE: NDP end is in progress
229   * @NAN_DATA_DISCONNECTED_STATE: NDP is in disconnected state
230   */
231  enum nan_datapath_state {
232  	NAN_DATA_INVALID_STATE = -1,
233  	NAN_DATA_NDI_CREATING_STATE = 0,
234  	NAN_DATA_NDI_CREATED_STATE = 1,
235  	NAN_DATA_NDI_DELETING_STATE = 2,
236  	NAN_DATA_NDI_DELETED_STATE = 3,
237  	NAN_DATA_PEER_CREATE_STATE = 4,
238  	NAN_DATA_PEER_DELETE_STATE = 5,
239  	NAN_DATA_CONNECTING_STATE = 6,
240  	NAN_DATA_CONNECTED_STATE = 7,
241  	NAN_DATA_END_STATE = 8,
242  	NAN_DATA_DISCONNECTED_STATE = 9,
243  };
244  
245  /**
246   * struct nan_datapath_app_info - application info shared during ndp setup
247   * @ndp_app_info_len: ndp app info length
248   * @ndp_app_info: variable length application information
249   */
250  struct nan_datapath_app_info {
251  	uint32_t ndp_app_info_len;
252  	uint8_t ndp_app_info[NDP_APP_INFO_LEN];
253  };
254  
255  /**
256   * struct nan_datapath_cfg - ndp configuration
257   * @ndp_cfg_len: ndp configuration length
258   * @ndp_cfg: variable length ndp configuration
259   */
260  struct nan_datapath_cfg {
261  	uint32_t ndp_cfg_len;
262  	uint8_t ndp_cfg[NDP_QOS_INFO_LEN];
263  };
264  
265  /**
266   * struct nan_datapath_pmk - structure to hold pairwise master key
267   * @pmk_len: length of pairwise master key
268   * @pmk: buffer containing pairwise master key
269   */
270  struct nan_datapath_pmk {
271  	uint32_t pmk_len;
272  	uint8_t pmk[NDP_PMK_LEN];
273  };
274  
275  /**
276   * struct nan_datapath_scid - structure to hold security context identifier
277   * @scid_len: length of scid
278   * @scid: scid
279   */
280  struct nan_datapath_scid {
281  	uint32_t scid_len;
282  	uint8_t scid[NDP_SCID_BUF_LEN];
283  };
284  
285  /**
286   * struct ndp_passphrase - structure to hold passphrase
287   * @passphrase_len: length of passphrase
288   * @passphrase: buffer containing passphrase
289   */
290  struct ndp_passphrase {
291  	uint32_t passphrase_len;
292  	uint8_t passphrase[NAN_PASSPHRASE_MAX_LEN];
293  };
294  
295  /**
296   * struct ndp_service_name - structure to hold service_name
297   * @service_name_len: length of service_name
298   * @service_name: buffer containing service_name
299   */
300  struct ndp_service_name {
301  	uint32_t service_name_len;
302  	uint8_t service_name[NAN_MAX_SERVICE_NAME_LEN];
303  };
304  
305  /**
306   * struct peer_nan_datapath_map  - mapping of NDP instances to peer to VDEV
307   * @vdev_id: session id of the interface over which ndp is being created
308   * @peer_ndi_mac_addr: peer NDI mac address
309   * @num_active_ndp_sessions: number of active NDP sessions on the peer
310   * @type: NDP end indication type
311   * @reason_code: NDP end indication reason code
312   * @ndp_instance_id: NDP instance ID
313   */
314  struct peer_nan_datapath_map {
315  	uint32_t vdev_id;
316  	struct qdf_mac_addr peer_ndi_mac_addr;
317  	uint32_t num_active_ndp_sessions;
318  	enum nan_datapath_end_type type;
319  	enum nan_datapath_end_reason_code reason_code;
320  	uint32_t ndp_instance_id;
321  };
322  
323  /**
324   * struct nan_datapath_channel_info - ndp channel and channel bandwidth
325   * @freq: channel freq in mhz of the ndp connection
326   * @ch_width: channel width (wmi_channel_width) of the ndp connection
327   * @nss: nss used for ndp connection
328   * @mac_id: MAC ID associated with the NDP channel
329   */
330  struct nan_datapath_channel_info {
331  	uint32_t freq;
332  	uint32_t ch_width;
333  	uint32_t nss;
334  	uint8_t mac_id;
335  };
336  
337  #define NAN_CH_INFO_MAX_LEN \
338  	(NAN_CH_INFO_MAX_CHANNELS * sizeof(struct nan_datapath_channel_info))
339  
340  /**
341   * struct nan_datapath_inf_create_req - ndi create request params
342   * @transaction_id: unique identifier
343   * @iface_name: interface name
344   */
345  struct nan_datapath_inf_create_req {
346  	uint32_t transaction_id;
347  	char  iface_name[IFACE_NAME_SIZE];
348  };
349  
350  /**
351   * struct nan_datapath_inf_create_rsp - ndi create response params
352   * @status: request status
353   * @reason: reason if any
354   */
355  struct nan_datapath_inf_create_rsp {
356  	uint32_t status;
357  	uint32_t reason;
358  };
359  
360  /**
361   * struct nan_datapath_inf_delete_rsp - ndi delete response params
362   * @status: request status
363   * @reason: reason if any
364   */
365  struct nan_datapath_inf_delete_rsp {
366  	uint32_t status;
367  	uint32_t reason;
368  };
369  
370  /**
371   * struct ndp_additional_params - NDP parameters
372   * @csid_cap: NAN Cipher Suite Capability field
373   * @gtk: GTK protection is required for the NDP
374   */
375  struct ndp_additional_params {
376  	uint32_t csid_cap;
377  	uint32_t gtk;
378  };
379  
380  /**
381   * struct nan_datapath_initiator_req - ndp initiator request params
382   * @vdev: pointer to vdev object
383   * @transaction_id: unique identifier
384   * @channel: suggested channel for ndp creation
385   * @channel_cfg: channel config, 0=no channel, 1=optional, 2=mandatory
386   * @service_instance_id: Service identifier
387   * @peer_discovery_mac_addr: Peer's discovery mac address
388   * @self_ndi_mac_addr: self NDI mac address
389   * @ndp_config: ndp configuration params
390   * @ndp_info: ndp application info
391   * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
392   * @pmk: pairwise master key
393   * @passphrase: passphrase
394   * @service_name: service name
395   * @is_ipv6_addr_present: indicates if following ipv6 address is valid
396   * @ipv6_addr: ipv6 address address used by ndp
397   * @ndp_add_params: NDP additional parameters
398   */
399  struct nan_datapath_initiator_req {
400  	struct wlan_objmgr_vdev *vdev;
401  	uint32_t transaction_id;
402  	uint32_t channel;
403  	uint32_t channel_cfg;
404  	uint32_t service_instance_id;
405  	uint32_t ncs_sk_type;
406  	struct qdf_mac_addr peer_discovery_mac_addr;
407  	struct qdf_mac_addr self_ndi_mac_addr;
408  	struct nan_datapath_cfg ndp_config;
409  	struct nan_datapath_app_info ndp_info;
410  	struct nan_datapath_pmk pmk;
411  	struct ndp_passphrase passphrase;
412  	struct ndp_service_name service_name;
413  	bool is_ipv6_addr_present;
414  	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
415  	struct ndp_additional_params ndp_add_params;
416  };
417  
418  /**
419   * struct nan_datapath_initiator_rsp - response event from FW
420   * @vdev: pointer to vdev object
421   * @transaction_id: unique identifier
422   * @ndp_instance_id: locally created NDP instance ID
423   * @status: status of the ndp request
424   * @reason: reason for failure if any
425   */
426  struct nan_datapath_initiator_rsp {
427  	struct wlan_objmgr_vdev *vdev;
428  	uint32_t transaction_id;
429  	uint32_t ndp_instance_id;
430  	uint32_t status;
431  	uint32_t reason;
432  };
433  
434  /**
435   * struct nan_datapath_responder_req - responder's response to ndp create
436   * request
437   * @vdev: pointer to vdev object
438   * @transaction_id: unique identifier
439   * @ndp_instance_id: locally created NDP instance ID
440   * @ndp_rsp: response to the ndp create request
441   * @ndp_config: ndp configuration params
442   * @ndp_info: ndp application info
443   * @pmk: pairwise master key
444   * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
445   * @passphrase: passphrase
446   * @service_name: service name
447   * @is_ipv6_addr_present: indicates if following ipv6 address is valid
448   * @ipv6_addr: ipv6 address address used by ndp
449   * @is_port_present: indicates if following port is valid
450   * @port: port specified by for this NDP
451   * @is_protocol_present: indicates if following protocol is valid
452   * @protocol: protocol used by this NDP
453   * @ndp_add_params: NDP additional parameters
454   */
455  struct nan_datapath_responder_req {
456  	struct wlan_objmgr_vdev *vdev;
457  	uint32_t transaction_id;
458  	uint32_t ndp_instance_id;
459  	enum nan_datapath_response_code ndp_rsp;
460  	struct nan_datapath_cfg ndp_config;
461  	struct nan_datapath_app_info ndp_info;
462  	struct nan_datapath_pmk pmk;
463  	uint32_t ncs_sk_type;
464  	struct ndp_passphrase passphrase;
465  	struct ndp_service_name service_name;
466  	bool is_ipv6_addr_present;
467  	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
468  	bool is_port_present;
469  	uint16_t port;
470  	bool is_protocol_present;
471  	uint8_t protocol;
472  	struct ndp_additional_params ndp_add_params;
473  };
474  
475  /**
476   * struct nan_datapath_responder_rsp - response to responder's request
477   * @vdev: pointer to vdev object
478   * @transaction_id: unique identifier
479   * @status: command status
480   * @reason: reason for failure if any
481   * @peer_mac_addr: Peer's mac address
482   * @create_peer: Flag to indicate to create peer
483   */
484  struct nan_datapath_responder_rsp {
485  	struct wlan_objmgr_vdev *vdev;
486  	uint32_t transaction_id;
487  	uint32_t status;
488  	uint32_t reason;
489  	struct qdf_mac_addr peer_mac_addr;
490  	bool create_peer;
491  };
492  
493  /**
494   * struct nan_datapath_end_req - ndp end request
495   * @vdev: pointer to vdev object
496   * @transaction_id: unique transaction identifier
497   * @num_ndp_instances: number of ndp instances to be terminated
498   * @ndp_ids: array of ndp_instance_id to be terminated
499   */
500  struct nan_datapath_end_req {
501  	struct wlan_objmgr_vdev *vdev;
502  	uint32_t transaction_id;
503  	uint32_t num_ndp_instances;
504  	uint32_t ndp_ids[NDP_NUM_INSTANCE_ID];
505  };
506  
507  /**
508   * struct nan_datapath_end_all_ndps - Datapath termination request to end all
509   * NDPs on the given vdev
510   * @vdev: pointer to vdev object
511   */
512  struct nan_datapath_end_all_ndps {
513  	struct wlan_objmgr_vdev *vdev;
514  };
515  
516  /**
517   * enum nan_event_id_types - NAN event ID types
518   * @nan_event_id_error_rsp: NAN event indicating error
519   * @nan_event_id_enable_rsp: NAN Enable Response event ID
520   * @nan_event_id_disable_ind: NAN Disable Indication event ID
521   * @nan_event_id_generic_rsp: All remaining NAN events, treated as passthrough
522   */
523  enum nan_event_id_types {
524  	nan_event_id_error_rsp = 0,
525  	nan_event_id_enable_rsp,
526  	nan_event_id_disable_ind,
527  	nan_event_id_generic_rsp,
528  };
529  
530  /**
531   * struct nan_event_params - NAN event received from the Target
532   * @psoc: Pointer to the psoc object
533   * @evt_type: NAN Discovery event type
534   * @is_nan_enable_success: Status from the NAN Enable Response event
535   * @mac_id: MAC ID associated with NAN Discovery from NAN Enable Response event
536   * @vdev_id: vdev id of the interface created for NAN discovery
537   * @buf_len: Event buffer length
538   * @buf: Event buffer starts here
539   */
540  struct nan_event_params {
541  	struct wlan_objmgr_psoc *psoc;
542  	enum nan_event_id_types evt_type;
543  	bool is_nan_enable_success;
544  	uint8_t mac_id;
545  	uint8_t vdev_id;
546  	uint32_t buf_len;
547  	/* Variable length, do not add anything after this */
548  	uint8_t buf[];
549  };
550  
551  #define NAN_MSG_ID_DISABLE_INDICATION 26
552  /**
553   * struct nan_msg_hdr - NAN msg header to be sent to userspace
554   * @msg_version: NAN msg version
555   * @msg_id: NAN message id
556   * @reserved: Reserved for now to avoid padding
557   *
558   * 8-byte control message header used by NAN
559   *
560   */
561  struct nan_msg_hdr {
562  	uint16_t msg_version:4;
563  	uint16_t msg_id:12;
564  	uint16_t reserved[3];
565  };
566  
567  #define NAN_STATUS_SUCCESS 0
568  #define NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED 12
569  
570  /**
571   * struct nan_disable_ind_msg - NAN disable ind params
572   * @msg_hdr: NAN msg header
573   * @reason: NAN disable reason, below are valid reasons for NAN disable ind
574   *          NAN_STATUS_SUCCESS
575   *          NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED
576   * @reserved: Reserved for now to avoid padding
577   */
578  struct nan_disable_ind_msg {
579  	struct nan_msg_hdr msg_hdr;
580  	uint16_t reason;
581  	uint16_t reserved;
582  };
583  
584  /**
585   * struct nan_msg_params - NAN request params
586   * @request_data_len: request data length
587   * @request_data: request data
588   * @rtt_cap: indicate if responder/initiator role is supported
589   * @disable_6g_nan: Disable NAN in 6Ghz
590   */
591  struct nan_msg_params {
592  	uint16_t request_data_len;
593  	uint32_t rtt_cap;
594  	bool disable_6g_nan;
595  	/* Variable length, do not add anything after this */
596  	uint8_t request_data[];
597  };
598  
599  /**
600   * struct nan_generic_req - A NAN request for the Target
601   * @psoc: Pointer to the psoc object
602   * @params: NAN request structure containing message fr the Target
603   */
604  struct nan_generic_req {
605  	struct wlan_objmgr_psoc *psoc;
606  	/* Variable length, do not add anything after this */
607  	struct nan_msg_params params;
608  };
609  
610  /**
611   * struct nan_disable_req - NAN request to disable NAN Discovery
612   * @psoc: Pointer to the psoc object
613   * @disable_2g_discovery: Flag for disabling Discovery in 2G band
614   * @disable_5g_discovery: Flag for disabling Discovery in 5G band
615   * @params: NAN request structure containing message for the target
616   */
617  struct nan_disable_req {
618  	struct wlan_objmgr_psoc *psoc;
619  	bool disable_2g_discovery;
620  	bool disable_5g_discovery;
621  	/* Variable length, do not add anything after this */
622  	struct nan_msg_params params;
623  };
624  
625  /**
626   * struct nan_enable_req - NAN request to enable NAN Discovery
627   * @psoc: Pointer to the psoc object
628   * @social_chan_2g_freq: Social channel in 2G band for the NAN Discovery
629   * @social_chan_5g_freq: Social channel in 5G band for the NAN Discovery
630   * @pdev: Pointer to the pdev object
631   * @params: NAN request structure containing message for the target
632   */
633  struct nan_enable_req {
634  	struct wlan_objmgr_psoc *psoc;
635  	uint32_t social_chan_2g_freq;
636  	uint32_t social_chan_5g_freq;
637  	struct wlan_objmgr_pdev *pdev;
638  	/* Variable length, do not add anything after this */
639  	struct nan_msg_params params;
640  };
641  
642  /**
643   * struct nan_datapath_end_rsp_event  - firmware response to ndp end request
644   * @vdev: pointer to vdev object
645   * @transaction_id: unique identifier for the request
646   * @status: status of operation
647   * @reason: reason(opaque to host driver)
648   */
649  struct nan_datapath_end_rsp_event {
650  	struct wlan_objmgr_vdev *vdev;
651  	uint32_t transaction_id;
652  	uint32_t status;
653  	uint32_t reason;
654  };
655  
656  /**
657   * struct nan_datapath_end_indication_event - ndp termination notification from
658   * FW
659   * @vdev: pointer to vdev object
660   * @num_ndp_ids: number of NDP ids
661   * @ndp_map: mapping of NDP instances to peer and vdev
662   */
663  struct nan_datapath_end_indication_event {
664  	struct wlan_objmgr_vdev *vdev;
665  	uint32_t num_ndp_ids;
666  	struct peer_nan_datapath_map ndp_map[];
667  };
668  
669  /**
670   * struct nan_dump_msg - ndp logging message
671   * @msg: msg received by FW
672   * @data_len: data length
673   *
674   */
675  struct nan_dump_msg {
676  	uint8_t *msg;
677  	uint32_t data_len;
678  };
679  
680  /**
681   * struct nan_datapath_confirm_event - ndp confirmation event from FW
682   * @vdev: pointer to vdev object
683   * @ndp_instance_id: ndp instance id for which confirm is being generated
684   * @reason_code : reason code(opaque to driver)
685   * @num_active_ndps_on_peer: number of ndp instances on peer
686   * @peer_ndi_mac_addr: peer NDI mac address
687   * @rsp_code: ndp response code
688   * @num_channels: num channels
689   * @ch: channel info struct array
690   * @ndp_info: ndp application info
691   * @is_ipv6_addr_present: indicates if following ipv6 address is valid
692   * @ipv6_addr: ipv6 address address used by ndp
693   * @is_port_present: indicates if following port is valid
694   * @port: port specified by for this NDP
695   * @is_protocol_present: indicates if following protocol is valid
696   * @protocol: protocol used by this NDP
697   */
698  struct nan_datapath_confirm_event {
699  	struct wlan_objmgr_vdev *vdev;
700  	uint32_t ndp_instance_id;
701  	uint32_t reason_code;
702  	uint32_t num_active_ndps_on_peer;
703  	struct qdf_mac_addr peer_ndi_mac_addr;
704  	enum nan_datapath_response_code rsp_code;
705  	uint32_t num_channels;
706  	struct nan_datapath_channel_info ch[NAN_CH_INFO_MAX_CHANNELS];
707  	struct nan_datapath_app_info ndp_info;
708  	bool is_ipv6_addr_present;
709  	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
710  	bool is_port_present;
711  	uint16_t port;
712  	bool is_protocol_present;
713  	uint8_t protocol;
714  };
715  
716  /**
717   * struct nan_datapath_indication_event - create ndp indication on the responder
718   * @vdev: pointer to vdev object
719   * @service_instance_id: Service identifier
720   * @peer_discovery_mac_addr: Peer's discovery mac address
721   * @peer_mac_addr: Peer's NDI mac address
722   * @ndp_initiator_mac_addr: NDI mac address of the peer initiating NDP
723   * @ndp_instance_id: locally created NDP instance ID
724   * @role: self role for NDP
725   * @policy: accept policy configured by the upper layer
726   * @ndp_config: ndp configuration params
727   * @ndp_info: ndp application info
728   * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
729   * @scid: security context identifier
730   * @is_ipv6_addr_present: indicates if following ipv6 address is valid
731   * @ipv6_addr: ipv6 address address used by ndp
732   * @is_service_id_present: indicates if service id is present
733   * @service_id: NDP service id
734   * @ndp_add_params: NDP additional parameters
735   */
736  struct nan_datapath_indication_event {
737  	struct wlan_objmgr_vdev *vdev;
738  	uint32_t service_instance_id;
739  	struct qdf_mac_addr peer_discovery_mac_addr;
740  	struct qdf_mac_addr peer_mac_addr;
741  	uint32_t ndp_instance_id;
742  	enum nan_datapath_self_role role;
743  	enum nan_datapath_accept_policy policy;
744  	struct nan_datapath_cfg ndp_config;
745  	struct nan_datapath_app_info ndp_info;
746  	uint32_t ncs_sk_type;
747  	struct nan_datapath_scid scid;
748  	bool is_ipv6_addr_present;
749  	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
750  	bool is_service_id_present;
751  	uint8_t service_id[NDP_SERVICE_ID_LEN];
752  	struct ndp_additional_params ndp_add_params;
753  };
754  
755  /**
756   * struct nan_datapath_peer_ind - ndp peer indication
757   * @peer_mac_addr: peer mac address
758   * @sta_id: station id
759   *
760   */
761  struct nan_datapath_peer_ind {
762  	struct qdf_mac_addr peer_mac_addr;
763  	uint16_t sta_id;
764  };
765  
766  /**
767   * struct nan_datapath_sch_update_event - ndp schedule update indication
768   * @vdev: vdev schedule update was received
769   * @peer_addr: peer for which schedule update was received
770   * @flags: reason for sch update (opaque to driver)
771   * @num_channels: num of channels
772   * @num_ndp_instances: num of ndp instances
773   * @ch: channel info array
774   * @ndp_instances: array of ndp instances
775   */
776  struct nan_datapath_sch_update_event {
777  	struct wlan_objmgr_vdev *vdev;
778  	struct qdf_mac_addr peer_addr;
779  	uint32_t flags;
780  	uint32_t num_channels;
781  	uint32_t num_ndp_instances;
782  	struct nan_datapath_channel_info ch[NAN_CH_INFO_MAX_CHANNELS];
783  	uint32_t ndp_instances[NDP_NUM_INSTANCE_ID];
784  };
785  
786  /**
787   * struct nan_datapath_host_event - ndp host event parameters
788   * @vdev: vdev obj associated with the ndp
789   * @ndp_termination_in_progress: flag that indicates whether NDPs associated
790   * with the given vdev are being terminated
791   */
792  struct nan_datapath_host_event {
793  	struct wlan_objmgr_vdev *vdev;
794  	bool ndp_termination_in_progress;
795  };
796  
797  /**
798   * struct nan_callbacks - struct containing callback to non-converged driver
799   * @os_if_nan_event_handler: OS IF Callback for handling NAN Discovery events
800   * @os_if_ndp_event_handler: OS IF Callback for handling NAN Datapath events
801   * @ucfg_nan_request_process_cb: Callback to indicate NAN enable/disable
802   * request processing is complete
803   * @ndi_open: HDD callback for creating the NAN Datapath Interface
804   * @ndi_start: HDD callback for starting the NAN Datapath Interface
805   * @ndi_set_mode: HDD callback for setting the adapter mode to NDI
806   * @ndi_close: HDD callback for closing the NAN Datapath Interface
807   * @ndi_delete: HDD callback for deleting the NAN Datapath Interface
808   * @drv_ndi_create_rsp_handler: HDD callback for handling NDI interface creation
809   * @drv_ndi_delete_rsp_handler: HDD callback for handling NDI interface deletion
810   * @new_peer_ind: HDD callback for handling new NDP peer
811   * @add_ndi_peer: LIM callback for adding NDP peer
812   * @peer_departed_ind: HDD callback for handling departing of NDP peer
813   * @ndp_delete_peers: LIM callback for deleting NDP peer
814   * @delete_peers_by_addr: LIM callback for deleting peer by MAC address
815   * @update_ndi_conn: WMA callback to update NDI's connection info
816   * @nan_concurrency_update: Callback to handle nan concurrency
817   * @set_mc_list: HDD callback to set multicast peer list
818   * @nan_sr_concurrency_update: Callback to handle nan SR(Spatial Reuse)
819   * concurrency
820   */
821  struct nan_callbacks {
822  	/* callback to os_if layer from umac */
823  	void (*os_if_nan_event_handler)(struct nan_event_params *nan_event);
824  	void (*os_if_ndp_event_handler)(struct wlan_objmgr_psoc *psoc,
825  					struct wlan_objmgr_vdev *vdev,
826  					uint32_t type, void *msg);
827  	void (*ucfg_nan_request_process_cb)(void *cookie);
828  	int (*ndi_open)(const char *iface_name, bool is_add_virtual_iface);
829  	int (*ndi_set_mode)(const char *iface_name);
830  	int (*ndi_start)(const char *iface_name, uint16_t);
831  	void (*ndi_close)(uint8_t);
832  	int (*ndi_delete)(uint8_t, const char *iface_name, uint16_t transaction_id);
833  	void (*drv_ndi_create_rsp_handler)
834  				(uint8_t, struct nan_datapath_inf_create_rsp *);
835  	void (*drv_ndi_delete_rsp_handler)(uint8_t);
836  	int (*new_peer_ind)(uint8_t, uint16_t, struct qdf_mac_addr *, bool);
837  	QDF_STATUS (*add_ndi_peer)(uint32_t, struct qdf_mac_addr);
838  	void (*peer_departed_ind)(uint8_t, uint16_t, struct qdf_mac_addr *,
839  				  bool);
840  	void (*ndp_delete_peers)(struct peer_nan_datapath_map*, uint8_t);
841  	void (*delete_peers_by_addr)(uint8_t, struct qdf_mac_addr);
842  	QDF_STATUS (*update_ndi_conn)(uint8_t vdev_id,
843  				      struct nan_datapath_channel_info
844  								    *chan_info);
845  	void (*nan_concurrency_update)(void);
846  	void (*set_mc_list)(struct wlan_objmgr_vdev *vdev);
847  #ifdef WLAN_FEATURE_SR
848  	void (*nan_sr_concurrency_update)(struct nan_event_params *nan_evt);
849  #endif
850  };
851  
852  /**
853   * struct wlan_nan_tx_ops - structure of tx function pointers for nan component
854   * @nan_discovery_req_tx: Msg handler for TX operations for the NAN Discovery
855   * @nan_datapath_req_tx: Msg handler for TX operations for the NAN Datapath
856   */
857  struct wlan_nan_tx_ops {
858  	QDF_STATUS (*nan_discovery_req_tx)(void *nan_req, uint32_t req_type);
859  	QDF_STATUS (*nan_datapath_req_tx)(void *req, uint32_t req_id);
860  };
861  
862  /**
863   * struct wlan_nan_rx_ops - structure of rx function pointers for nan component
864   * @nan_discovery_event_rx: Evt handler for RX operations for the NAN Discovery
865   * @nan_datapath_event_rx: Evt handler for RX operations for the NAN Datapath
866   */
867  struct wlan_nan_rx_ops {
868  	QDF_STATUS (*nan_discovery_event_rx)(struct scheduler_msg *event);
869  	QDF_STATUS (*nan_datapath_event_rx)(struct scheduler_msg *event);
870  };
871  
872  /**
873   * struct nan_tgt_caps - NAN Target capabilities
874   * @nan_conc_control: Target supports disabling NAN Discovery from host
875   *		      so that host is able to handle(disable) NAN
876   *		      concurrencies.
877   * @nan_dbs_supported: Target supports NAN Discovery with DBS
878   * @ndi_dbs_supported: Target supports NAN Datapath with DBS
879   * @nan_sap_supported: Target supports NAN Discovery with SAP concurrency
880   * @ndi_sap_supported: Target supports NAN Datapath with SAP concurrency
881   * @nan_vdev_allowed: Allow separate vdev creation for NAN discovery
882   * @sta_nan_ndi_ndi_allowed: 4 port concurrency of STA+NAN+NDI+NDI is supported
883   * @ndi_txbf_supported: Target supports NAN Datapath with TX beamforming
884   * by Fw or not.
885   * @mlo_sta_nan_ndi_allowed: MLO STA + NAN + NDI concurrency is supported
886   */
887  struct nan_tgt_caps {
888  	uint32_t nan_conc_control:1;
889  	uint32_t nan_dbs_supported:1;
890  	uint32_t ndi_dbs_supported:1;
891  	uint32_t nan_sap_supported:1;
892  	uint32_t ndi_sap_supported:1;
893  	uint32_t nan_vdev_allowed:1;
894  	uint32_t sta_nan_ndi_ndi_allowed:1;
895  	uint32_t ndi_txbf_supported:1;
896  #ifdef WLAN_FEATURE_11BE_MLO
897  	uint32_t mlo_sta_nan_ndi_allowed:1;
898  #endif
899  };
900  
901  #endif
902