Selaa lähdekoodia

qcacld-3.0: Merge NAN component files from CMN into CLD

NAN component is not needed in the CMN repo. To reduce the
unnecessary lines of code, merge the NAN component files
from CMN into CLD with updated copyrights. Subsequently
remove these files from the CMN repo.

Merge NAN component files from CMN into CLD.

Change-Id: I63c2fb90ea517496946ea45a66bdf290af9d5a7c
Linux Build Service Account 6 vuotta sitten
sitoutus
ac5ee8ca94

+ 639 - 0
nan/core/inc/nan_public_structs.h

@@ -0,0 +1,639 @@
+/*
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains nan definitions exposed to other modules
+ */
+
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+#ifndef _NAN_PUBLIC_STRUCTS_H_
+#define _NAN_PUBLIC_STRUCTS_H_
+
+#include "qdf_types.h"
+#include "qdf_status.h"
+
+struct wlan_objmgr_psoc;
+struct wlan_objmgr_vdev;
+
+#define IFACE_NAME_SIZE 64
+#define NDP_QOS_INFO_LEN 255
+#define NDP_APP_INFO_LEN 255
+#define NDP_PMK_LEN 32
+#define NDP_SCID_BUF_LEN 256
+#define NDP_NUM_INSTANCE_ID 255
+#define NAN_MAX_SERVICE_NAME_LEN 255
+#define NAN_PASSPHRASE_MIN_LEN 8
+#define NAN_PASSPHRASE_MAX_LEN 63
+#define NAN_CH_INFO_MAX_CHANNELS 4
+
+/**
+ * enum nan_datapath_msg_type - NDP msg type
+ * @NAN_DATAPATH_INF_CREATE_REQ: ndi create request
+ * @NAN_DATAPATH_INF_CREATE_RSP: ndi create response
+ * @NAN_DATAPATH_INF_DELETE_REQ: ndi delete request
+ * @NAN_DATAPATH_INF_DELETE_RSP: ndi delete response
+ * @NDP_INITIATOR_REQ: ndp initiator request
+ * @NDP_INITIATOR_RSP: ndp initiator response
+ * @NDP_RESPONDER_REQ: ndp responder request
+ * @NDP_RESPONDER_RSP: ndp responder response
+ * @NDP_END_REQ: ndp end request
+ * @NDP_END_RSP: ndp end response
+ * @NDP_INDICATION: ndp indication
+ * @NDP_CONFIRM: ndp confirm
+ * @NDP_END_IND: ndp end indication
+ * @NDP_NEW_PEER: ndp new peer created
+ * @NDP_PEER_DEPARTED: ndp peer departed/deleted
+ * @NDP_SCHEDULE_UPDATE: ndp schedule update
+ */
+enum nan_datapath_msg_type {
+	NAN_DATAPATH_INF_CREATE_REQ  = 0,
+	NAN_DATAPATH_INF_CREATE_RSP  = 1,
+	NAN_DATAPATH_INF_DELETE_REQ  = 2,
+	NAN_DATAPATH_INF_DELETE_RSP  = 3,
+	NDP_INITIATOR_REQ            = 4,
+	NDP_INITIATOR_RSP            = 5,
+	NDP_RESPONDER_REQ            = 6,
+	NDP_RESPONDER_RSP            = 7,
+	NDP_END_REQ                  = 8,
+	NDP_END_RSP                  = 9,
+	NDP_INDICATION               = 10,
+	NDP_CONFIRM                  = 11,
+	NDP_END_IND                  = 12,
+	NDP_NEW_PEER                 = 13,
+	NDP_PEER_DEPARTED            = 14,
+	NDP_SCHEDULE_UPDATE          = 15,
+};
+
+/**
+ * enum nan_datapath_status_type - NDP status type
+ * @NAN_DATAPATH_RSP_STATUS_SUCCESS: request was successful
+ * @NAN_DATAPATH_RSP_STATUS_ERROR: request failed
+ */
+enum nan_datapath_status_type {
+	NAN_DATAPATH_RSP_STATUS_SUCCESS = 0x00,
+	NAN_DATAPATH_RSP_STATUS_ERROR = 0x01,
+};
+
+/**
+ * enum nan_datapath_reason_code - NDP command rsp reason code value
+ * @NDP_UNSUPPORTED_CONCURRENCY: Will be used in unsupported concurrency cases
+ * @NDP_NAN_DATA_IFACE_CREATE_FAILED: ndi create failed
+ * @NDP_NAN_DATA_IFACE_DELETE_FAILED: ndi delete failed
+ * @NDP_DATA_INITIATOR_REQ_FAILED: data initiator request failed
+ * @NDP_DATA_RESPONDER_REQ_FAILED: data responder request failed
+ * @NDP_INVALID_SERVICE_INSTANCE_ID: invalid service instance id
+ * @NDP_INVALID_NDP_INSTANCE_ID: invalid ndp instance id
+ * @NDP_INVALID_RSP_CODE: invalid response code in ndp responder request
+ * @NDP_INVALID_APP_INFO_LEN: invalid app info length
+ * @NDP_NMF_REQ_FAIL: OTA nan mgmt frame failure for data request
+ * @NDP_NMF_RSP_FAIL: OTA nan mgmt frame failure for data response
+ * @NDP_NMF_CNF_FAIL: OTA nan mgmt frame failure for confirm
+ * @NDP_END_FAILED: ndp end failed
+ * @NDP_NMF_END_REQ_FAIL: OTA nan mgmt frame failure for data end
+ * @NDP_VENDOR_SPECIFIC_ERROR: other vendor specific failures
+ */
+enum nan_datapath_reason_code {
+	NAN_DATAPATH_UNSUPPORTED_CONCURRENCY = 9000,
+	NAN_DATAPATH_NAN_DATA_IFACE_CREATE_FAILED = 9001,
+	NAN_DATAPATH_NAN_DATA_IFACE_DELETE_FAILED = 9002,
+	NAN_DATAPATH_DATA_INITIATOR_REQ_FAILED = 9003,
+	NAN_DATAPATH_DATA_RESPONDER_REQ_FAILED = 9004,
+	NAN_DATAPATH_INVALID_SERVICE_INSTANCE_ID = 9005,
+	NAN_DATAPATH_INVALID_NDP_INSTANCE_ID = 9006,
+	NAN_DATAPATH_INVALID_RSP_CODE = 9007,
+	NAN_DATAPATH_INVALID_APP_INFO_LEN = 9008,
+	NAN_DATAPATH_NMF_REQ_FAIL = 9009,
+	NAN_DATAPATH_NMF_RSP_FAIL = 9010,
+	NAN_DATAPATH_NMF_CNF_FAIL = 9011,
+	NAN_DATAPATH_END_FAILED = 9012,
+	NAN_DATAPATH_NMF_END_REQ_FAIL = 9013,
+	/* 9500 onwards vendor specific error codes */
+	NAN_DATAPATH_VENDOR_SPECIFIC_ERROR = 9500,
+};
+
+/**
+ * enum nan_datapath_response_code - responder's response code to nan data path
+ * request
+ * @NAN_DATAPATH_RESPONSE_ACCEPT: ndp request accepted
+ * @NAN_DATAPATH_RESPONSE_REJECT: ndp request rejected
+ * @NAN_DATAPATH_RESPONSE_DEFER: ndp request deferred until later (response to
+ * follow any time later)
+ *
+ */
+enum nan_datapath_response_code {
+	NAN_DATAPATH_RESPONSE_ACCEPT = 0,
+	NAN_DATAPATH_RESPONSE_REJECT = 1,
+	NAN_DATAPATH_RESPONSE_DEFER = 2,
+};
+
+/**
+ * enum nan_datapath_accept_policy - nan data path accept policy
+ * @NAN_DATAPATH_ACCEPT_POLICY_NONE: the framework will decide the policy
+ * @NAN_DATAPATH_ACCEPT_POLICY_ALL: accept policy offloaded to fw
+ *
+ */
+enum nan_datapath_accept_policy {
+	NAN_DATAPATH_ACCEPT_POLICY_NONE = 0,
+	NAN_DATAPATH_ACCEPT_POLICY_ALL = 1,
+};
+
+/**
+ * enum nan_datapath_self_role - nan data path role
+ * @NAN_DATAPATH_ROLE_INITIATOR: initiator of nan data path request
+ * @NAN_DATAPATH_ROLE_RESPONDER: responder to nan data path request
+ *
+ */
+enum nan_datapath_self_role {
+	NAN_DATAPATH_ROLE_INITIATOR = 0,
+	NAN_DATAPATH_ROLE_RESPONDER = 1,
+};
+
+/**
+ * enum nan_datapath_end_type - NDP end type
+ * @NAN_DATAPATH_END_TYPE_UNSPECIFIED: type is unspecified
+ * @NAN_DATAPATH_END_TYPE_PEER_UNAVAILABLE: type is peer unavailable
+ * @NAN_DATAPATH_END_TYPE_OTA_FRAME: NDP end frame received from peer
+ *
+ */
+enum nan_datapath_end_type {
+	NAN_DATAPATH_END_TYPE_UNSPECIFIED = 0x00,
+	NAN_DATAPATH_END_TYPE_PEER_UNAVAILABLE = 0x01,
+	NAN_DATAPATH_END_TYPE_OTA_FRAME = 0x02,
+};
+
+/**
+ * enum nan_datapath_end_reason_code - NDP end reason code
+ * @NAN_DATAPATH_END_REASON_UNSPECIFIED: reason is unspecified
+ * @NAN_DATAPATH_END_REASON_INACTIVITY: reason is peer inactivity
+ * @NAN_DATAPATH_END_REASON_PEER_DATA_END: data end indication received from
+ * peer
+ *
+ */
+enum nan_datapath_end_reason_code {
+	NAN_DATAPATH_END_REASON_UNSPECIFIED = 0x00,
+	NAN_DATAPATH_END_REASON_INACTIVITY = 0x01,
+	NAN_DATAPATH_END_REASON_PEER_DATA_END = 0x02,
+};
+
+/** enum nan_datapath_state - NAN datapath states
+ * @NAN_DATA_NDI_CREATING_STATE: NDI create is in progress
+ * @NAN_DATA_NDI_CREATED_STATE: NDI successfully crated
+ * @NAN_DATA_NDI_DELETING_STATE: NDI delete is in progress
+ * @NAN_DATA_NDI_DELETED_STATE: NDI delete is in progress
+ * @NAN_DATA_PEER_CREATE_STATE: Peer create is in progress
+ * @NAN_DATA_PEER_DELETE_STATE: Peer delete is in progrss
+ * @NAN_DATA_CONNECTING_STATE: Data connection in progress
+ * @NAN_DATA_CONNECTED_STATE: Data connection successful
+ * @NAN_DATA_END_STATE: NDP end is in progress
+ * @NAN_DATA_DISCONNECTED_STATE: NDP is in disconnected state
+ */
+enum nan_datapath_state {
+	NAN_DATA_INVALID_STATE = -1,
+	NAN_DATA_NDI_CREATING_STATE = 0,
+	NAN_DATA_NDI_CREATED_STATE = 1,
+	NAN_DATA_NDI_DELETING_STATE = 2,
+	NAN_DATA_NDI_DELETED_STATE = 3,
+	NAN_DATA_PEER_CREATE_STATE = 4,
+	NAN_DATA_PEER_DELETE_STATE = 5,
+	NAN_DATA_CONNECTING_STATE = 6,
+	NAN_DATA_CONNECTED_STATE = 7,
+	NAN_DATA_END_STATE = 8,
+	NAN_DATA_DISCONNECTED_STATE = 9,
+};
+
+/**
+ * struct nan_datapath_app_info - application info shared during ndp setup
+ * @ndp_app_info_len: ndp app info length
+ * @ndp_app_info: variable length application information
+ *
+ */
+struct nan_datapath_app_info {
+	uint32_t ndp_app_info_len;
+	uint8_t ndp_app_info[NDP_APP_INFO_LEN];
+};
+
+/**
+ * struct nan_datapath_cfg - ndp configuration
+ * @ndp_cfg_len: ndp configuration length
+ * @ndp_cfg: variable length ndp configuration
+ *
+ */
+struct nan_datapath_cfg {
+	uint32_t ndp_cfg_len;
+	uint8_t ndp_cfg[NDP_QOS_INFO_LEN];
+};
+
+/**
+ * struct nan_datapath_pmk - structure to hold pairwise master key
+ * @pmk_len: length of pairwise master key
+ * @pmk: buffer containing pairwise master key
+ *
+ */
+struct nan_datapath_pmk {
+	uint32_t pmk_len;
+	uint8_t pmk[NDP_PMK_LEN];
+};
+
+/**
+ * struct nan_datapath_scid - structure to hold sceurity context identifier
+ * @scid_len: length of scid
+ * @scid: scid
+ *
+ */
+struct nan_datapath_scid {
+	uint32_t scid_len;
+	uint8_t scid[NDP_SCID_BUF_LEN];
+};
+
+/**
+ * struct ndp_passphrase - structure to hold passphrase
+ * @passphrase_len: length of passphrase
+ * @passphrase: buffer containing passphrase
+ *
+ */
+struct ndp_passphrase {
+	uint32_t passphrase_len;
+	uint8_t passphrase[NAN_PASSPHRASE_MAX_LEN];
+};
+
+/**
+ * struct ndp_service_name - structure to hold service_name
+ * @service_name_len: length of service_name
+ * @service_name: buffer containing service_name
+ *
+ */
+struct ndp_service_name {
+	uint32_t service_name_len;
+	uint8_t service_name[NAN_MAX_SERVICE_NAME_LEN];
+};
+
+/**
+ * struct peer_nan_datapath_map  - mapping of NDP instances to peer to VDEV
+ * @vdev_id: session id of the interface over which ndp is being created
+ * @peer_ndi_mac_addr: peer NDI mac address
+ * @num_active_ndp_sessions: number of active NDP sessions on the peer
+ * @type: NDP end indication type
+ * @reason_code: NDP end indication reason code
+ * @ndp_instance_id: NDP instance ID
+ *
+ */
+struct peer_nan_datapath_map {
+	uint32_t vdev_id;
+	struct qdf_mac_addr peer_ndi_mac_addr;
+	uint32_t num_active_ndp_sessions;
+	enum nan_datapath_end_type type;
+	enum nan_datapath_end_reason_code reason_code;
+	uint32_t ndp_instance_id;
+};
+
+/**
+ * struct nan_datapath_channel_info - ndp channel and channel bandwidth
+ * @channel: channel freq in mhz of the ndp connection
+ * @ch_width: channel width (wmi_channel_width) of the ndp connection
+ * @nss: nss used for ndp connection
+ *
+ */
+struct nan_datapath_channel_info {
+	uint32_t channel;
+	uint32_t ch_width;
+	uint32_t nss;
+};
+
+#define NAN_CH_INFO_MAX_LEN \
+	(NAN_CH_INFO_MAX_CHANNELS * sizeof(struct nan_datapath_channel_info))
+
+/**
+ * struct nan_datapath_inf_create_req - ndi create request params
+ * @transaction_id: unique identifier
+ * @iface_name: interface name
+ *
+ */
+struct nan_datapath_inf_create_req {
+	uint32_t transaction_id;
+	char  iface_name[IFACE_NAME_SIZE];
+};
+
+/*
+ * struct nan_datapath_inf_create_rsp - ndi create response params
+ * @status: request status
+ * @reason: reason if any
+ *
+ */
+struct nan_datapath_inf_create_rsp {
+	uint32_t status;
+	uint32_t reason;
+	uint8_t sta_id;
+};
+
+/**
+ * struct nan_datapath_inf_delete_rsp - ndi delete response params
+ * @status: request status
+ * @reason: reason if any
+ *
+ */
+struct nan_datapath_inf_delete_rsp {
+	uint32_t status;
+	uint32_t reason;
+};
+
+/**
+ * struct nan_datapath_initiator_req - ndp initiator request params
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique identifier
+ * @channel: suggested channel for ndp creation
+ * @channel_cfg: channel config, 0=no channel, 1=optional, 2=mandatory
+ * @service_instance_id: Service identifier
+ * @peer_discovery_mac_addr: Peer's discovery mac address
+ * @self_ndi_mac_addr: self NDI mac address
+ * @ndp_config: ndp configuration params
+ * @ndp_info: ndp application info
+ * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
+ * @pmk: pairwise master key
+ * @passphrase: passphrase
+ * @service_name: service name
+ * @is_ipv6_addr_present: indicates if following ipv6 address is valid
+ * @ipv6_addr: ipv6 address address used by ndp
+ */
+struct nan_datapath_initiator_req {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t channel;
+	uint32_t channel_cfg;
+	uint32_t service_instance_id;
+	uint32_t ncs_sk_type;
+	struct qdf_mac_addr peer_discovery_mac_addr;
+	struct qdf_mac_addr self_ndi_mac_addr;
+	struct nan_datapath_cfg ndp_config;
+	struct nan_datapath_app_info ndp_info;
+	struct nan_datapath_pmk pmk;
+	struct ndp_passphrase passphrase;
+	struct ndp_service_name service_name;
+	bool is_ipv6_addr_present;
+	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
+};
+
+/**
+ * struct nan_datapath_initiator_rsp - response event from FW
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique identifier
+ * @ndp_instance_id: locally created NDP instance ID
+ * @status: status of the ndp request
+ * @reason: reason for failure if any
+ *
+ */
+struct nan_datapath_initiator_rsp {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t ndp_instance_id;
+	uint32_t status;
+	uint32_t reason;
+};
+
+/**
+ * struct nan_datapath_responder_req - responder's response to ndp create
+ * request
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique identifier
+ * @ndp_instance_id: locally created NDP instance ID
+ * @ndp_rsp: response to the ndp create request
+ * @ndp_config: ndp configuration params
+ * @ndp_info: ndp application info
+ * @pmk: pairwise master key
+ * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
+ * @passphrase: passphrase
+ * @service_name: service name
+ * @is_ipv6_addr_present: indicates if following ipv6 address is valid
+ * @ipv6_addr: ipv6 address address used by ndp
+ * @is_port_present: indicates if following port is valid
+ * @port: port specified by for this NDP
+ * @is_protocol_present: indicates if following protocol is valid
+ * @protocol: protocol used by this NDP
+ *
+ */
+struct nan_datapath_responder_req {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t ndp_instance_id;
+	enum nan_datapath_response_code ndp_rsp;
+	struct nan_datapath_cfg ndp_config;
+	struct nan_datapath_app_info ndp_info;
+	struct nan_datapath_pmk pmk;
+	uint32_t ncs_sk_type;
+	struct ndp_passphrase passphrase;
+	struct ndp_service_name service_name;
+	bool is_ipv6_addr_present;
+	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
+	bool is_port_present;
+	uint16_t port;
+	bool is_protocol_present;
+	uint8_t protocol;
+};
+
+/**
+ * struct nan_datapath_responder_rsp - response to responder's request
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique identifier
+ * @status: command status
+ * @reason: reason for failure if any
+ * @peer_mac_addr: Peer's mac address
+ * @create_peer: Flag to indicate to create peer
+ */
+struct nan_datapath_responder_rsp {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t status;
+	uint32_t reason;
+	struct qdf_mac_addr peer_mac_addr;
+	bool create_peer;
+};
+
+/**
+ * struct nan_datapath_end_req - ndp end request
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique transaction identifier
+ * @num_ndp_instances: number of ndp instances to be terminated
+ * @ndp_ids: array of ndp_instance_id to be terminated
+ *
+ */
+struct nan_datapath_end_req {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t num_ndp_instances;
+	uint32_t ndp_ids[NDP_NUM_INSTANCE_ID];
+};
+
+/**
+ * struct nan_datapath_end_rsp_event  - firmware response to ndp end request
+ * @vdev: pointer to vdev object
+ * @transaction_id: unique identifier for the request
+ * @status: status of operation
+ * @reason: reason(opaque to host driver)
+ *
+ */
+struct nan_datapath_end_rsp_event {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t transaction_id;
+	uint32_t status;
+	uint32_t reason;
+};
+
+/**
+ * struct nan_datapath_end_indication_event - ndp termination notification from
+ * FW
+ * @vdev: pointer to vdev object
+ * @num_ndp_ids: number of NDP ids
+ * @ndp_map: mapping of NDP instances to peer and vdev
+ *
+ */
+struct nan_datapath_end_indication_event {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t num_ndp_ids;
+	struct peer_nan_datapath_map ndp_map[];
+};
+
+/**
+ * struct nan_datapath_confirm_event - ndp confirmation event from FW
+ * @vdev: pointer to vdev object
+ * @ndp_instance_id: ndp instance id for which confirm is being generated
+ * @reason_code : reason code(opaque to driver)
+ * @num_active_ndps_on_peer: number of ndp instances on peer
+ * @peer_ndi_mac_addr: peer NDI mac address
+ * @rsp_code: ndp response code
+ * @num_channels: num channels
+ * @ch: channel info struct array
+ * @ndp_info: ndp application info
+ * @is_ipv6_addr_present: indicates if following ipv6 address is valid
+ * @ipv6_addr: ipv6 address address used by ndp
+ * @is_port_present: indicates if following port is valid
+ * @port: port specified by for this NDP
+ * @is_protocol_present: indicates if following protocol is valid
+ * @protocol: protocol used by this NDP
+ *
+ */
+struct nan_datapath_confirm_event {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t ndp_instance_id;
+	uint32_t reason_code;
+	uint32_t num_active_ndps_on_peer;
+	struct qdf_mac_addr peer_ndi_mac_addr;
+	enum nan_datapath_response_code rsp_code;
+	uint32_t num_channels;
+	struct nan_datapath_channel_info ch[NAN_CH_INFO_MAX_CHANNELS];
+	struct nan_datapath_app_info ndp_info;
+	bool is_ipv6_addr_present;
+	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
+	bool is_port_present;
+	uint16_t port;
+	bool is_protocol_present;
+	uint8_t protocol;
+};
+
+/**
+ * struct nan_datapath_indication_event - create ndp indication on the responder
+ * @vdev: pointer to vdev object
+ * @service_instance_id: Service identifier
+ * @peer_discovery_mac_addr: Peer's discovery mac address
+ * @peer_mac_addr: Peer's NDI mac address
+ * @ndp_initiator_mac_addr: NDI mac address of the peer initiating NDP
+ * @ndp_instance_id: locally created NDP instance ID
+ * @role: self role for NDP
+ * @ndp_accept_policy: accept policy configured by the upper layer
+ * @ndp_config: ndp configuration params
+ * @ndp_info: ndp application info
+ * @ncs_sk_type: indicates NCS_SK_128 or NCS_SK_256
+ * @scid: security context identifier
+ * @is_ipv6_addr_present: indicates if following ipv6 address is valid
+ * @ipv6_addr: ipv6 address address used by ndp
+ *
+ */
+struct nan_datapath_indication_event {
+	struct wlan_objmgr_vdev *vdev;
+	uint32_t service_instance_id;
+	struct qdf_mac_addr peer_discovery_mac_addr;
+	struct qdf_mac_addr peer_mac_addr;
+	uint32_t ndp_instance_id;
+	enum nan_datapath_self_role role;
+	enum nan_datapath_accept_policy policy;
+	struct nan_datapath_cfg ndp_config;
+	struct nan_datapath_app_info ndp_info;
+	uint32_t ncs_sk_type;
+	struct nan_datapath_scid scid;
+	bool is_ipv6_addr_present;
+	uint8_t ipv6_addr[QDF_IPV6_ADDR_SIZE];
+};
+
+/**
+ * struct nan_datapath_peer_ind - ndp peer indication
+ * @peer_mac_addr: peer mac address
+ * @sta_id: station id
+ *
+ */
+struct nan_datapath_peer_ind {
+	struct qdf_mac_addr peer_mac_addr;
+	uint16_t sta_id;
+};
+
+/**
+ * struct nan_datapath_sch_update_event - ndp schedule update indication
+ * @vdev: vdev schedule update was received
+ * @peer_addr: peer for which schedule update was received
+ * @flags: reason for sch update (opaque to driver)
+ * @num_channels: num of channels
+ * @num_ndp_instances: num of ndp instances
+ * @ch: channel info array
+ * @ndp_instances: array of ndp instances
+ *
+ */
+struct nan_datapath_sch_update_event {
+	struct wlan_objmgr_vdev *vdev;
+	struct qdf_mac_addr peer_addr;
+	uint32_t flags;
+	uint32_t num_channels;
+	uint32_t num_ndp_instances;
+	struct nan_datapath_channel_info ch[NAN_CH_INFO_MAX_CHANNELS];
+	uint32_t ndp_instances[NDP_NUM_INSTANCE_ID];
+};
+
+/**
+ * struct nan_callbacks - struct containing callback to non-converged driver
+ *
+ */
+struct nan_callbacks {
+	/* callback to os_if layer from umac */
+	void (*os_if_event_handler)(struct wlan_objmgr_psoc *psoc,
+				    struct wlan_objmgr_vdev *vdev,
+				    uint32_t type, void *msg);
+
+	int (*ndi_open)(char *iface_name);
+	int (*ndi_start)(char *iface_name, uint16_t);
+	void (*ndi_close)(uint8_t);
+	int (*ndi_delete)(uint8_t, char *iface_name, uint16_t transaction_id);
+	void (*drv_ndi_create_rsp_handler)
+				(uint8_t, struct nan_datapath_inf_create_rsp *);
+	void (*drv_ndi_delete_rsp_handler)(uint8_t);
+	int (*new_peer_ind)(uint8_t, uint16_t, struct qdf_mac_addr *, bool);
+	int (*get_peer_idx)(uint8_t, struct qdf_mac_addr *);
+	QDF_STATUS (*add_ndi_peer)(uint32_t, struct qdf_mac_addr);
+	void (*peer_departed_ind)(uint8_t, uint16_t, struct qdf_mac_addr *,
+				  bool);
+	void (*ndp_delete_peers)(struct peer_nan_datapath_map*, uint8_t);
+	void (*delete_peers_by_addr)(uint8_t, struct qdf_mac_addr);
+};
+
+#endif
+#endif /* WLAN_FEATURE_NAN_CONVERGENCE */

+ 60 - 0
nan/core/inc/wlan_nan_api.h

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains nan definitions exposed to other modules
+ */
+
+#ifndef _WLAN_NAN_API_H_
+#define _WLAN_NAN_API_H_
+
+#include "qdf_status.h"
+
+struct wlan_objmgr_psoc;
+
+/**
+ * nan_init: initializes NAN component, called by dispatcher init
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_init(void);
+
+/**
+ * nan_deinit: de-initializes NAN component, called by dispatcher init
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_deinit(void);
+
+/**
+ * nan_psoc_enable: psoc enable API for NANitioning component
+ * @psoc: pointer to PSOC
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_psoc_enable(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * nan_psoc_disable: psoc disable API for NANitioning component
+ * @psoc: pointer to PSOC
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_psoc_disable(struct wlan_objmgr_psoc *psoc);
+
+#endif

+ 368 - 0
nan/core/src/nan_api.c

@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains nan public API function definitions
+ */
+
+#include "nan_main_i.h"
+#include "wlan_nan_api.h"
+#include "target_if_nan.h"
+#include "nan_public_structs.h"
+#include "wlan_objmgr_cmn.h"
+#include "wlan_objmgr_global_obj.h"
+#include "wlan_objmgr_psoc_obj.h"
+#include "wlan_objmgr_pdev_obj.h"
+#include "wlan_objmgr_vdev_obj.h"
+#include "cfg_nan.h"
+#include "cfg_ucfg_api.h"
+
+/**
+ * nan_cfg_init() - Initialize NAN config params
+ * @psoc: Pointer to PSOC Object
+ * @nan_obj: Pointer to NAN private object
+ *
+ * This function initialize NAN config params
+ */
+#ifdef WLAN_FEATURE_NAN
+static void nan_cfg_init(struct wlan_objmgr_psoc *psoc,
+			 struct nan_psoc_priv_obj *nan_obj)
+{
+	if (!psoc || !nan_obj)
+		return;
+
+	nan_obj->cfg_param.enable = cfg_get(psoc, CFG_NAN_ENABLE);
+}
+#else
+static void nan_cfg_init(struct wlan_objmgr_psoc *psoc,
+			 struct nan_psoc_priv_obj *nan_obj)
+{
+}
+#endif
+
+/**
+ * nan_cfg_dp_init() - Initialize NAN Datapath config params
+ * @psoc: Pointer to PSOC Object
+ * @nan_obj: Pointer to NAN private object
+ *
+ * This function initialize NAN config params
+ */
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+static void nan_cfg_dp_init(struct wlan_objmgr_psoc *psoc,
+			    struct nan_psoc_priv_obj *nan_obj)
+{
+	if (!psoc || !nan_obj)
+		return;
+	nan_obj->cfg_param.dp_enable = cfg_get(psoc,
+					       CFG_NAN_DATAPATH_ENABLE);
+	nan_obj->cfg_param.ndi_ch = cfg_get(psoc, CFG_NAN_NDI_CHANNEL);
+	nan_obj->cfg_param.ndi_mac_randomize =
+				cfg_get(psoc, CFG_NAN_RANDOMIZE_NDI_MAC);
+}
+#else
+static void nan_cfg_dp_init(struct wlan_objmgr_psoc *psoc,
+			    struct nan_psoc_priv_obj *nan_obj)
+{
+}
+#endif
+
+static QDF_STATUS nan_psoc_obj_created_notification(
+		struct wlan_objmgr_psoc *psoc, void *arg_list)
+{
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct nan_psoc_priv_obj *nan_obj;
+
+	nan_debug("nan_psoc_create_notif called");
+	nan_obj = qdf_mem_malloc(sizeof(*nan_obj));
+	if (!nan_obj) {
+		nan_alert("malloc failed for nan prv obj");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	qdf_spinlock_create(&nan_obj->lock);
+	status = wlan_objmgr_psoc_component_obj_attach(psoc, WLAN_UMAC_COMP_NAN,
+						       nan_obj,
+						       QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_alert("obj attach with psoc failed");
+		goto nan_psoc_notif_failed;
+	}
+
+	nan_cfg_init(psoc, nan_obj);
+	nan_cfg_dp_init(psoc, nan_obj);
+
+	return QDF_STATUS_SUCCESS;
+
+nan_psoc_notif_failed:
+
+	qdf_spinlock_destroy(&nan_obj->lock);
+	qdf_mem_free(nan_obj);
+	return status;
+}
+
+static void nan_psoc_delete_peer(struct wlan_objmgr_psoc *psoc,
+				 void *peer, void *arg)
+{
+	if (WLAN_PEER_NDP == wlan_peer_get_peer_type(peer))
+		wlan_objmgr_peer_obj_delete(peer);
+}
+
+static void nan_psoc_delete_vdev(struct wlan_objmgr_psoc *psoc,
+				 void *vdev, void *arg)
+{
+	enum nan_datapath_state state;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return;
+	}
+	/*
+	 * user may issue rrmod wlan without explicitly NDI Delete.
+	 * In that case pending NDI vdev state will not be DELETED/DELETEING
+	 * Forcefully delete vdev object
+	 */
+	if (QDF_NDI_MODE != wlan_vdev_mlme_get_opmode(vdev))
+		return;
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	state = priv_obj->state;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	/* if already in deleted or deleting state - do not delete */
+	if (state == NAN_DATA_NDI_DELETED_STATE ||
+	    state == NAN_DATA_NDI_DELETING_STATE)
+		return;
+
+	wlan_objmgr_vdev_obj_delete(vdev);
+}
+
+static QDF_STATUS nan_psoc_obj_destroyed_notification(
+				struct wlan_objmgr_psoc *psoc, void *arg_list)
+{
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct nan_psoc_priv_obj *nan_obj = nan_get_psoc_priv_obj(psoc);
+
+	nan_debug("nan_psoc_delete_notif called");
+	if (!nan_obj) {
+		nan_err("nan_obj is NULL");
+		return QDF_STATUS_E_FAULT;
+	}
+
+	wlan_objmgr_iterate_obj_list(psoc, WLAN_PEER_OP,
+				     nan_psoc_delete_peer,
+				     NULL, 1, WLAN_NAN_ID);
+
+	wlan_objmgr_iterate_obj_list(psoc, WLAN_VDEV_OP,
+				     nan_psoc_delete_vdev,
+				     NULL, 1, WLAN_NAN_ID);
+
+	status = wlan_objmgr_psoc_component_obj_detach(psoc, WLAN_UMAC_COMP_NAN,
+						       nan_obj);
+	if (QDF_IS_STATUS_ERROR(status))
+		nan_err("nan_obj detach failed");
+
+	nan_debug("nan_obj deleted with status %d", status);
+	qdf_spinlock_destroy(&nan_obj->lock);
+	qdf_mem_free(nan_obj);
+
+	return status;
+}
+
+static QDF_STATUS nan_vdev_obj_created_notification(
+		struct wlan_objmgr_vdev *vdev, void *arg_list)
+{
+	struct nan_vdev_priv_obj *nan_obj;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+	nan_debug("nan_vdev_create_notif called");
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_NDI_MODE) {
+		nan_debug("not a ndi vdev. do nothing");
+		return QDF_STATUS_SUCCESS;
+	}
+
+	nan_obj = qdf_mem_malloc(sizeof(*nan_obj));
+	if (!nan_obj) {
+		nan_err("malloc failed for nan prv obj");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	qdf_spinlock_create(&nan_obj->lock);
+	status = wlan_objmgr_vdev_component_obj_attach(vdev, WLAN_UMAC_COMP_NAN,
+						       (void *)nan_obj,
+						       QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_alert("obj attach with vdev failed");
+		goto nan_vdev_notif_failed;
+	}
+
+	return QDF_STATUS_SUCCESS;
+
+nan_vdev_notif_failed:
+
+	qdf_spinlock_destroy(&nan_obj->lock);
+	qdf_mem_free(nan_obj);
+	return status;
+}
+
+static QDF_STATUS nan_vdev_obj_destroyed_notification(
+				struct wlan_objmgr_vdev *vdev, void *arg_list)
+{
+	struct nan_vdev_priv_obj *nan_obj;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+	nan_debug("nan_vdev_delete_notif called");
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_NDI_MODE) {
+		nan_debug("not a ndi vdev. do nothing");
+		return QDF_STATUS_SUCCESS;
+	}
+
+	nan_obj = nan_get_vdev_priv_obj(vdev);
+	if (!nan_obj) {
+		nan_err("nan_obj is NULL");
+		return QDF_STATUS_E_FAULT;
+	}
+
+	status = wlan_objmgr_vdev_component_obj_detach(vdev, WLAN_UMAC_COMP_NAN,
+						       nan_obj);
+	if (QDF_IS_STATUS_ERROR(status))
+		nan_err("nan_obj detach failed");
+
+	nan_debug("nan_obj deleted with status %d", status);
+	qdf_spinlock_destroy(&nan_obj->lock);
+	qdf_mem_free(nan_obj);
+
+	return status;
+}
+
+QDF_STATUS nan_init(void)
+{
+	QDF_STATUS status;
+
+	/* register psoc create handler functions. */
+	status = wlan_objmgr_register_psoc_create_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_psoc_obj_created_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_register_psoc_create_handler failed");
+		return status;
+	}
+
+	/* register psoc delete handler functions. */
+	status = wlan_objmgr_register_psoc_destroy_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_psoc_obj_destroyed_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_register_psoc_destroy_handler failed");
+		nan_deinit();
+		return status;
+	}
+
+	/* register vdev create handler functions. */
+	status = wlan_objmgr_register_vdev_create_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_vdev_obj_created_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_register_psoc_create_handler failed");
+		nan_deinit();
+		return status;
+	}
+
+	/* register vdev delete handler functions. */
+	status = wlan_objmgr_register_vdev_destroy_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_vdev_obj_destroyed_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_register_psoc_destroy_handler failed");
+		nan_deinit();
+		return status;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS nan_deinit(void)
+{
+	QDF_STATUS ret = QDF_STATUS_SUCCESS, status;
+
+	/* register psoc create handler functions. */
+	status = wlan_objmgr_unregister_psoc_create_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_psoc_obj_created_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_unregister_psoc_create_handler failed");
+		ret = status;
+	}
+
+	/* register vdev create handler functions. */
+	status = wlan_objmgr_unregister_psoc_destroy_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_psoc_obj_destroyed_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_deregister_psoc_destroy_handler failed");
+		ret = status;
+	}
+
+	/* de-register vdev create handler functions. */
+	status = wlan_objmgr_unregister_vdev_create_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_vdev_obj_created_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_unregister_psoc_create_handler failed");
+		ret = status;
+	}
+
+	/* de-register vdev delete handler functions. */
+	status = wlan_objmgr_unregister_vdev_destroy_handler(
+		WLAN_UMAC_COMP_NAN,
+		nan_vdev_obj_destroyed_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("wlan_objmgr_deregister_psoc_destroy_handler failed");
+		ret = status;
+	}
+
+	return ret;
+}
+
+QDF_STATUS nan_psoc_enable(struct wlan_objmgr_psoc *psoc)
+{
+	QDF_STATUS status = target_if_nan_register_events(psoc);
+
+	if (QDF_IS_STATUS_ERROR(status))
+		nan_err("target_if_nan_register_events failed");
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS nan_psoc_disable(struct wlan_objmgr_psoc *psoc)
+{
+	QDF_STATUS status = target_if_nan_deregister_events(psoc);
+
+	if (QDF_IS_STATUS_ERROR(status))
+		nan_err("target_if_nan_deregister_events failed");
+
+	return QDF_STATUS_SUCCESS;
+}

+ 521 - 0
nan/core/src/nan_main.c

@@ -0,0 +1,521 @@
+/*
+ * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains core nan function definitions
+ */
+
+#include "nan_main_i.h"
+#include "nan_ucfg_api.h"
+#include "wlan_nan_api.h"
+#include "target_if_nan.h"
+#include "scheduler_api.h"
+#include "wlan_serialization_api.h"
+#include "wlan_objmgr_cmn.h"
+#include "wlan_objmgr_global_obj.h"
+#include "wlan_objmgr_psoc_obj.h"
+#include "wlan_objmgr_pdev_obj.h"
+#include "wlan_objmgr_vdev_obj.h"
+
+struct nan_vdev_priv_obj *nan_get_vdev_priv_obj(
+				struct wlan_objmgr_vdev *vdev)
+{
+	struct nan_vdev_priv_obj *obj;
+
+	if (!vdev) {
+		nan_err("vdev is null");
+		return NULL;
+	}
+	obj = wlan_objmgr_vdev_get_comp_private_obj(vdev, WLAN_UMAC_COMP_NAN);
+
+	return obj;
+}
+
+struct nan_psoc_priv_obj *nan_get_psoc_priv_obj(
+				struct wlan_objmgr_psoc *psoc)
+{
+	struct nan_psoc_priv_obj *obj;
+
+	if (!psoc) {
+		nan_err("psoc is null");
+		return NULL;
+	}
+	obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_NAN);
+
+	return obj;
+}
+
+void nan_release_cmd(void *in_req, uint32_t cmdtype)
+{
+	struct wlan_objmgr_vdev *vdev = NULL;
+
+	if (!in_req)
+		return;
+
+	switch (cmdtype) {
+	case WLAN_SER_CMD_NDP_INIT_REQ: {
+		struct nan_datapath_initiator_req *req = in_req;
+
+		vdev = req->vdev;
+		break;
+	}
+	case WLAN_SER_CMD_NDP_RESP_REQ: {
+		struct nan_datapath_responder_req *req = in_req;
+
+		vdev = req->vdev;
+		break;
+	}
+	case WLAN_SER_CMD_NDP_DATA_END_INIT_REQ: {
+		struct nan_datapath_end_req *req = in_req;
+
+		vdev = req->vdev;
+		break;
+	}
+	default:
+		nan_err("invalid req type: %d", cmdtype);
+		break;
+	}
+
+	if (vdev)
+		wlan_objmgr_vdev_release_ref(vdev, WLAN_NAN_ID);
+	else
+		nan_err("vdev is null");
+
+	qdf_mem_free(in_req);
+}
+
+static void nan_req_incomplete(void *req, uint32_t cmdtype)
+{
+	/* send msg to userspace if needed that cmd got incomplete */
+}
+
+static void nan_req_activated(void *in_req, uint32_t cmdtype)
+{
+	uint32_t req_type;
+	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_vdev *vdev;
+	struct wlan_lmac_if_nan_tx_ops *tx_ops;
+
+	switch (cmdtype) {
+	case WLAN_SER_CMD_NDP_INIT_REQ: {
+		struct nan_datapath_initiator_req *req = in_req;
+
+		vdev = req->vdev;
+		req_type = NDP_INITIATOR_REQ;
+		break;
+	}
+	case WLAN_SER_CMD_NDP_RESP_REQ: {
+		struct nan_datapath_responder_req *req = in_req;
+
+		vdev = req->vdev;
+		req_type = NDP_RESPONDER_REQ;
+		break;
+	}
+	case WLAN_SER_CMD_NDP_DATA_END_INIT_REQ: {
+		struct nan_datapath_end_req *req = in_req;
+
+		vdev = req->vdev;
+		req_type = NDP_END_REQ;
+		break;
+	}
+	default:
+		nan_alert("in correct cmdtype: %d", cmdtype);
+		return;
+	}
+
+	if (!vdev) {
+		nan_alert("vdev is null");
+		return;
+	}
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		nan_alert("psoc is null");
+		return;
+	}
+
+	tx_ops = target_if_nan_get_tx_ops(psoc);
+	if (!tx_ops) {
+		nan_alert("tx_ops is null");
+		return;
+	}
+
+	/* send ndp_intiator_req/responder_req/end_req to FW */
+	tx_ops->nan_req_tx(in_req, req_type);
+}
+
+static QDF_STATUS nan_serialized_cb(void *cmd,
+				    enum wlan_serialization_cb_reason reason)
+{
+	void *req;
+	struct wlan_serialization_command *ser_cmd = cmd;
+
+	if (!ser_cmd || !ser_cmd->umac_cmd) {
+		nan_alert("cmd or umac_cmd is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	req = ser_cmd->umac_cmd;
+
+	switch (reason) {
+	case WLAN_SER_CB_ACTIVATE_CMD:
+		nan_req_activated(req, ser_cmd->cmd_type);
+		break;
+	case WLAN_SER_CB_CANCEL_CMD:
+	case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
+		nan_req_incomplete(req, ser_cmd->cmd_type);
+		break;
+	case WLAN_SER_CB_RELEASE_MEM_CMD:
+		nan_release_cmd(req, ser_cmd->cmd_type);
+		break;
+	default:
+		/* Do nothing but logging */
+		nan_alert("invalid serialized cb reason: %d", reason);
+		break;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS nan_scheduled_msg_handler(struct scheduler_msg *msg)
+{
+	enum wlan_serialization_status status = 0;
+	struct wlan_serialization_command cmd = {0};
+
+	if (!msg || !msg->bodyptr) {
+		nan_alert("msg or bodyptr is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	switch (msg->type) {
+	case NDP_INITIATOR_REQ: {
+		struct nan_datapath_initiator_req *req = msg->bodyptr;
+
+		cmd.cmd_type = WLAN_SER_CMD_NDP_INIT_REQ;
+		cmd.vdev = req->vdev;
+		break;
+	}
+	case NDP_RESPONDER_REQ: {
+		struct nan_datapath_responder_req *req = msg->bodyptr;
+
+		cmd.cmd_type = WLAN_SER_CMD_NDP_RESP_REQ;
+		cmd.vdev = req->vdev;
+		break;
+	}
+	case NDP_END_REQ: {
+		struct nan_datapath_end_req *req = msg->bodyptr;
+
+		cmd.cmd_type = WLAN_SER_CMD_NDP_DATA_END_INIT_REQ;
+		cmd.vdev = req->vdev;
+		break;
+	}
+	default:
+		nan_err("wrong request type: %d", msg->type);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	/* TBD - support more than one req of same type or avoid */
+	cmd.cmd_id = 0;
+	cmd.cmd_cb = nan_serialized_cb;
+	cmd.umac_cmd = msg->bodyptr;
+	cmd.source = WLAN_UMAC_COMP_NAN;
+	cmd.is_high_priority = false;
+	cmd.cmd_timeout_duration = 30000 /* 30 sec for now. TBD */;
+	nan_debug("cmd_type: %d", cmd.cmd_type);
+	cmd.is_blocking = true;
+
+	status = wlan_serialization_request(&cmd);
+	/* following is TBD */
+	if (status != WLAN_SER_CMD_ACTIVE && status != WLAN_SER_CMD_PENDING) {
+		nan_err("unable to serialize command");
+		wlan_objmgr_vdev_release_ref(cmd.vdev, WLAN_NAN_ID);
+		return QDF_STATUS_E_INVAL;
+	}
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_confirm(
+				struct nan_datapath_confirm_event *confirm)
+{
+	uint8_t vdev_id;
+	struct wlan_objmgr_psoc *psoc;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	vdev_id = wlan_vdev_get_id(confirm->vdev);
+	psoc = wlan_vdev_get_psoc(confirm->vdev);
+	if (!psoc) {
+		nan_err("psoc is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	if (confirm->rsp_code != NAN_DATAPATH_RESPONSE_ACCEPT &&
+	    confirm->num_active_ndps_on_peer == 0) {
+		/*
+		 * This peer was created at ndp_indication but
+		 * confirm failed, so it needs to be deleted
+		 */
+		nan_err("NDP confirm with reject and no active ndp sessions. deleting peer: "QDF_MAC_ADDR_STR" on vdev_id: %d",
+			QDF_MAC_ADDR_ARRAY(confirm->peer_ndi_mac_addr.bytes),
+			vdev_id);
+		psoc_nan_obj->cb_obj.delete_peers_by_addr(vdev_id,
+						confirm->peer_ndi_mac_addr);
+	}
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, confirm->vdev,
+						 NDP_CONFIRM, confirm);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_initiator_rsp(
+				struct nan_datapath_initiator_rsp *rsp,
+				struct wlan_objmgr_vdev **vdev)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	*vdev = rsp->vdev;
+	psoc = wlan_vdev_get_psoc(rsp->vdev);
+	if (!psoc) {
+		nan_err("psoc is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, rsp->vdev,
+					NDP_INITIATOR_RSP, rsp);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_ndp_ind(
+				struct nan_datapath_indication_event *ndp_ind)
+{
+	uint8_t vdev_id;
+	struct wlan_objmgr_psoc *psoc;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	vdev_id = wlan_vdev_get_id(ndp_ind->vdev);
+	psoc = wlan_vdev_get_psoc(ndp_ind->vdev);
+	if (!psoc) {
+		nan_err("psoc is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	nan_debug("role: %d, vdev: %d, csid: %d, peer_mac_addr "
+		QDF_MAC_ADDR_STR,
+		ndp_ind->role, vdev_id, ndp_ind->ncs_sk_type,
+		QDF_MAC_ADDR_ARRAY(ndp_ind->peer_mac_addr.bytes));
+
+	if ((ndp_ind->role == NAN_DATAPATH_ROLE_INITIATOR) ||
+	    ((NAN_DATAPATH_ROLE_RESPONDER == ndp_ind->role) &&
+	    (NAN_DATAPATH_ACCEPT_POLICY_ALL == ndp_ind->policy))) {
+		status = psoc_nan_obj->cb_obj.add_ndi_peer(vdev_id,
+						ndp_ind->peer_mac_addr);
+		if (QDF_IS_STATUS_ERROR(status)) {
+			nan_err("Couldn't add ndi peer, ndp_role: %d",
+				ndp_ind->role);
+			return status;
+		}
+	}
+	if (NAN_DATAPATH_ROLE_RESPONDER == ndp_ind->role)
+		psoc_nan_obj->cb_obj.os_if_event_handler(psoc, ndp_ind->vdev,
+						NDP_INDICATION, ndp_ind);
+
+	return status;
+}
+
+static QDF_STATUS nan_handle_responder_rsp(
+				struct nan_datapath_responder_rsp *rsp,
+				struct wlan_objmgr_vdev **vdev)
+{
+	struct wlan_objmgr_psoc *psoc;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	*vdev = rsp->vdev;
+	psoc = wlan_vdev_get_psoc(rsp->vdev);
+	if (!psoc) {
+		nan_err("psoc is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	if (QDF_IS_STATUS_SUCCESS(rsp->status) && rsp->create_peer) {
+		status = psoc_nan_obj->cb_obj.add_ndi_peer(
+						wlan_vdev_get_id(rsp->vdev),
+						rsp->peer_mac_addr);
+		if (QDF_IS_STATUS_ERROR(status)) {
+			nan_err("Couldn't add ndi peer");
+			rsp->status = QDF_STATUS_E_FAILURE;
+		}
+	}
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, rsp->vdev,
+						 NDP_RESPONDER_RSP, rsp);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_ndp_end_rsp(
+			struct nan_datapath_end_rsp_event *rsp,
+			struct wlan_objmgr_vdev **vdev)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	*vdev = rsp->vdev;
+	psoc = wlan_vdev_get_psoc(rsp->vdev);
+	if (!psoc) {
+		nan_err("psoc is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, rsp->vdev,
+						NDP_END_RSP, rsp);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_end_ind(
+				struct nan_datapath_end_indication_event *ind)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	psoc = wlan_vdev_get_psoc(ind->vdev);
+	if (!psoc) {
+		nan_err("psoc is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj->cb_obj.ndp_delete_peers(ind->ndp_map, ind->num_ndp_ids);
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, ind->vdev,
+						 NDP_END_IND, ind);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS nan_handle_schedule_update(
+				struct nan_datapath_sch_update_event *ind)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct nan_psoc_priv_obj *psoc_nan_obj;
+
+	psoc = wlan_vdev_get_psoc(ind->vdev);
+	if (!psoc) {
+		nan_err("psoc is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj = nan_get_psoc_priv_obj(psoc);
+	if (!psoc_nan_obj) {
+		nan_err("psoc_nan_obj is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, ind->vdev,
+						 NDP_SCHEDULE_UPDATE, ind);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS nan_event_handler(struct scheduler_msg *pe_msg)
+{
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct wlan_serialization_queued_cmd_info cmd;
+
+	cmd.requestor = WLAN_UMAC_COMP_NAN;
+	cmd.cmd_id = 0;
+	cmd.req_type = WLAN_SER_CANCEL_NON_SCAN_CMD;
+	cmd.queue_type = WLAN_SERIALIZATION_ACTIVE_QUEUE;
+
+	if (!pe_msg->bodyptr) {
+		nan_err("msg body is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	switch (pe_msg->type) {
+	case NDP_CONFIRM: {
+		nan_handle_confirm(pe_msg->bodyptr);
+		break;
+	}
+	case NDP_INITIATOR_RSP: {
+		nan_handle_initiator_rsp(pe_msg->bodyptr, &cmd.vdev);
+		cmd.cmd_type = WLAN_SER_CMD_NDP_INIT_REQ;
+		wlan_serialization_remove_cmd(&cmd);
+		break;
+	}
+	case NDP_INDICATION: {
+		nan_handle_ndp_ind(pe_msg->bodyptr);
+		break;
+	}
+	case NDP_RESPONDER_RSP:
+		nan_handle_responder_rsp(pe_msg->bodyptr, &cmd.vdev);
+		cmd.cmd_type = WLAN_SER_CMD_NDP_RESP_REQ;
+		wlan_serialization_remove_cmd(&cmd);
+		break;
+	case NDP_END_RSP:
+		nan_handle_ndp_end_rsp(pe_msg->bodyptr, &cmd.vdev);
+		cmd.cmd_type = WLAN_SER_CMD_NDP_DATA_END_INIT_REQ;
+		wlan_serialization_remove_cmd(&cmd);
+		break;
+	case NDP_END_IND:
+		nan_handle_end_ind(pe_msg->bodyptr);
+		break;
+	case NDP_SCHEDULE_UPDATE:
+		nan_handle_schedule_update(pe_msg->bodyptr);
+		break;
+	default:
+		nan_alert("Unhandled NDP event: %d", pe_msg->type);
+		status = QDF_STATUS_E_NOSUPPORT;
+		break;
+	}
+	return status;
+}

+ 158 - 0
nan/core/src/nan_main_i.h

@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains declaration of common utility APIs and private structs to be
+ * used in NAN modules
+ */
+
+#ifndef _WLAN_NAN_MAIN_I_H_
+#define _WLAN_NAN_MAIN_I_H_
+
+#include "qdf_types.h"
+#include "qdf_status.h"
+#include "nan_public_structs.h"
+#include "wlan_objmgr_cmn.h"
+
+struct wlan_objmgr_vdev;
+struct wlan_objmgr_psoc;
+struct scheduler_msg;
+
+#define nan_alert(params...) \
+	QDF_TRACE_FATAL(QDF_MODULE_ID_NAN, params)
+#define nan_err(params...) \
+	QDF_TRACE_ERROR(QDF_MODULE_ID_NAN, params)
+#define nan_warn(params...) \
+	QDF_TRACE_WARN(QDF_MODULE_ID_NAN, params)
+#define nan_notice(params...) \
+	QDF_TRACE_INFO(QDF_MODULE_ID_NAN, params)
+#define nan_info(params...) \
+	QDF_TRACE_INFO(QDF_MODULE_ID_NAN, params)
+#define nan_debug(params...) \
+	QDF_TRACE_DEBUG(QDF_MODULE_ID_NAN, params)
+
+#define nan_nofl_alert(params...) \
+	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_NAN, params)
+#define nan_nofl_err(params...) \
+	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_NAN, params)
+#define nan_nofl_warn(params...) \
+	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_NAN, params)
+#define nan_nofl_info(params...) \
+	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_NAN, params)
+#define nan_nofl_debug(params...) \
+	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_NAN, params)
+
+#ifndef MAX_PEERS
+#define MAX_PEERS 32
+#endif
+
+/**
+ * struct nan_cfg_params - NAN INI config params
+ * @enable: NAN feature enable
+ * @dp_enable: NAN Datapath feature enable
+ * @ndi_ch: NAN Datapath channel
+ * @ndi_mac_randomize: Randomize NAN datapath interface MAC
+ */
+struct nan_cfg_params {
+#ifdef WLAN_FEATURE_NAN
+	bool enable;
+#endif
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+	bool dp_enable;
+	uint32_t ndi_ch;
+	bool ndi_mac_randomize;
+#endif
+};
+
+/**
+ * struct nan_psoc_priv_obj - nan private psoc obj
+ * @lock: lock to be acquired before reading or writing to object
+ * @cb_obj: struct contaning callback pointers
+ */
+struct nan_psoc_priv_obj {
+	qdf_spinlock_t lock;
+	struct nan_callbacks cb_obj;
+	struct nan_cfg_params cfg_param;
+};
+
+/**
+ * struct nan_vdev_priv_obj - nan private vdev obj
+ * @lock: lock to be acquired before reading or writing to object
+ * @state: Current state of NDP
+ * @active_ndp_sessions: active ndp sessions per adapter
+ * @active_ndp_peers: number of active ndp peers
+ * @ndp_create_transaction_id: transaction id for create req
+ * @ndp_delete_transaction_id: transaction id for delete req
+ * @ndi_delete_rsp_reason: reason code for ndi_delete rsp
+ * @ndi_delete_rsp_status: status for ndi_delete rsp
+ */
+struct nan_vdev_priv_obj {
+	qdf_spinlock_t lock;
+	enum nan_datapath_state state;
+	/* idx in following array should follow conn_info.peerMacAddress */
+	uint32_t active_ndp_sessions[MAX_PEERS];
+	uint32_t active_ndp_peers;
+	uint16_t ndp_create_transaction_id;
+	uint16_t ndp_delete_transaction_id;
+	uint32_t ndi_delete_rsp_reason;
+	uint32_t ndi_delete_rsp_status;
+};
+
+/**
+ * nan_get_vdev_priv_obj: get NAN priv object from vdev object
+ * @vdev: pointer to vdev object
+ *
+ * Return: pointer to NAN vdev private object
+ */
+struct nan_vdev_priv_obj *nan_get_vdev_priv_obj(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * nan_get_psoc_priv_obj: get NAN priv object from psoc object
+ * @psoc: pointer to psoc object
+ *
+ * Return: pointer to NAN psoc private object
+ */
+struct nan_psoc_priv_obj *nan_get_psoc_priv_obj(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * nan_release_cmd: frees resources for NAN command.
+ * @in_req: pointer to msg buffer to be freed
+ * @req_type: type of request
+ *
+ * Return: None
+ */
+void nan_release_cmd(void *in_req, uint32_t req_type);
+
+/**
+ * nan_scheduled_msg_handler: callback pointer to be called when scheduler
+ * starts executing enqueued NAN command.
+ * @msg: pointer to msg
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_scheduled_msg_handler(struct scheduler_msg *msg);
+
+/*
+ * nan_event_handler: function to process events from firmware
+ * @msg: message received from lmac
+ *
+ * Return: status of operation
+ */
+QDF_STATUS nan_event_handler(struct scheduler_msg *msg);
+
+#endif

+ 138 - 0
nan/dispatcher/inc/cfg_nan.h

@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if !defined(__NAN_CFG_H__)
+#define __NAN_CFG_H__
+
+/**
+ *
+ * DOC: nan_cfg.h
+ *
+ * NAN feature INI configuration parameter definitions
+ */
+#include "cfg_define.h"
+#include "cfg_converged.h"
+#include "qdf_types.h"
+
+/*
+ * <ini>
+ * gEnableNanSupport - NAN feature support configuration
+ * @Min: 0
+ * @Max: 1
+ * @Default: 0
+ *
+ * When set to 1 NAN feature will be enabled.
+ *
+ * Related: None
+ *
+ * Supported Feature: NAN
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_NAN_ENABLE CFG_INI_BOOL("gEnableNanSupport", \
+				    0, \
+				    "Enable NAN Support")
+/*
+ * <ini>
+ * genable_nan_datapath - Enable NaN data path feature. NaN data path
+ *                        enables NAN supported devices to exchange
+ *                        data over TCP/UDP network stack.
+ * @Min: 0
+ * @Max: 1
+ * @Default: 0
+ *
+ * When set to 1 NAN Datapath feature will be enabled.
+ *
+ * Related: gEnableNanSupport
+ *
+ * Supported Feature: NAN
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_NAN_DATAPATH_ENABLE CFG_INI_BOOL("genable_nan_datapath", \
+					     0, \
+					     "Enable NAN Datapath support")
+
+/*
+ * <ini>
+ * gnan_datapath_ndi_channel - Default channel for NAN Datapath
+ * @Min: 6
+ * @Max: 149
+ * @Default: 6
+ *
+ * Host suggests this channel for NAN datapath. But FW is free to
+ * choose other channels based on system constraints.
+ *
+ * Related: genable_nan_datapath
+ *
+ * Supported Feature: NAN
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+/*
+ * NAN channel on which NAN data interface to start
+ */
+#define CFG_NAN_NDI_CHANNEL CFG_INI_UINT("gnan_datapath_ndi_channel", \
+					 6, 149, 6, \
+					 CFG_VALUE_OR_DEFAULT, \
+					 "NAN Datapath Channel")
+/*
+ * <ini>
+ * gEnableNDIMacRandomization - When enabled this will randomize NDI Mac
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * When enabled this will randomize NDI Mac
+ *
+ * Related: gEnableNanSupport
+ *
+ * Supported Feature: NAN
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_NAN_RANDOMIZE_NDI_MAC CFG_INI_BOOL("gEnableNDIMacRandomization", \
+					       1, \
+					       "Enable NAN MAC Randomization")
+
+#ifdef WLAN_FEATURE_NAN
+#define CFG_NAN_DISC CFG(CFG_NAN_ENABLE)
+#else
+#define CFG_NAN_DISC
+#endif
+
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+#define CFG_NAN_DP      CFG(CFG_NAN_DATAPATH_ENABLE) \
+			CFG(CFG_NAN_NDI_CHANNEL) \
+			CFG(CFG_NAN_RANDOMIZE_NDI_MAC)
+#else
+#define CFG_NAN_DP
+#endif
+
+#define CFG_NAN_ALL     CFG_NAN_DISC \
+			CFG_NAN_DP
+
+#endif

+ 88 - 0
nan/dispatcher/inc/cfg_nan_api.h

@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if !defined(__NAN_CFG_API_H__)
+#define __NAN_CFG_API_H__
+
+/**
+ *
+ * DOC: nan_cfg_api.h
+ *
+ * NAN feature INI configuration parameters get/set APIs
+ */
+#include "qdf_types.h"
+
+struct wlan_objmgr_psoc;
+
+#ifdef WLAN_FEATURE_NAN
+/**
+ * cfg_nan_get_enable() - get NAN support enable status
+ * @psoc: pointer to psoc object
+ *
+ * This function returns NAN enable status
+ */
+bool cfg_nan_get_enable(struct wlan_objmgr_psoc *psoc);
+#else
+static inline bool cfg_nan_get_enable(struct wlan_objmgr_psoc *psoc)
+{
+	return false;
+}
+#endif
+
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+/**
+ * cfg_nan_get_datapath_enable() - get NAN Datapath support enable status
+ * @psoc: pointer to psoc object
+ *
+ * This function returns NAN Datapath enable status
+ */
+bool cfg_nan_get_datapath_enable(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * cfg_nan_get_ndi_channel() - get NAN Datapath channel
+ * @psoc: pointer to psoc object
+ *
+ * This function returns NAN Datapath channel
+ */
+uint32_t cfg_nan_get_ndi_channel(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * cfg_nan_get_ndi_mac_randomize() - get NDI MAC randomize enable status
+ * @psoc: pointer to psoc object
+ *
+ * This function returns NAN Datapath Interface MAC randomization status
+ */
+bool cfg_nan_get_ndi_mac_randomize(struct wlan_objmgr_psoc *psoc);
+#else
+static inline bool cfg_nan_get_datapath_enable(struct wlan_objmgr_psoc *psoc)
+{
+	return false;
+}
+
+static inline uint32_t cfg_nan_get_ndi_channel(struct wlan_objmgr_psoc *psoc)
+{
+	return 0;
+}
+
+static inline bool cfg_nan_get_ndi_mac_randomize(struct wlan_objmgr_psoc *psoc)
+{
+	return false;
+}
+#endif
+#endif
+

+ 239 - 0
nan/dispatcher/inc/nan_ucfg_api.h

@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains interface prototypes for OS_IF layer
+ */
+
+#ifndef _NAN_UCFG_API_H_
+#define _NAN_UCFG_API_H_
+
+#include "qdf_types.h"
+#include "qdf_status.h"
+#include "wlan_objmgr_cmn.h"
+
+struct nan_callbacks;
+struct wlan_objmgr_vdev;
+struct wlan_objmgr_psoc;
+struct wlan_objmgr_vdev;
+struct nan_callbacks;
+
+/**
+ * ucfg_nan_set_ndi_state: set ndi state
+ * @vdev: pointer to vdev object
+ * @state: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_ndi_state(struct wlan_objmgr_vdev *vdev,
+				  uint32_t state);
+
+/**
+ * ucfg_nan_get_ndi_state: get ndi state from vdev obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: ndi state
+ */
+enum nan_datapath_state ucfg_nan_get_ndi_state(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_set_active_peers: set active ndi peer
+ * @vdev: pointer to vdev object
+ * @val: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_active_peers(struct wlan_objmgr_vdev *vdev,
+				     uint32_t val);
+
+/**
+ * ucfg_nan_get_active_peers: get active ndi peer from vdev obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: active ndi peer
+ */
+uint32_t ucfg_nan_get_active_peers(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_set_active_ndp_sessions: set active ndp sessions
+ * @vdev: pointer to vdev object
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_active_ndp_sessions(struct wlan_objmgr_vdev *vdev,
+					    uint32_t val, uint8_t idx);
+
+/**
+ * ucfg_nan_get_active_ndp_sessions: get active ndp sessions from vdev obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: pointer to NAN psoc private object
+ */
+uint32_t ucfg_nan_get_active_ndp_sessions(struct wlan_objmgr_vdev *vdev,
+					  uint8_t idx);
+
+/**
+ * ucfg_nan_set_ndp_create_transaction_id: set ndp create transaction id
+ * @vdev: pointer to vdev object
+ * @val: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_ndp_create_transaction_id(struct wlan_objmgr_vdev *vdev,
+						  uint16_t val);
+
+/**
+ * ucfg_nan_get_ndp_create_transaction_id: get ndp create transaction id
+ * vdev obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: ndp create transaction_id
+ */
+uint16_t ucfg_nan_get_ndp_create_transaction_id(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_set_ndp_delete_transaction_id: set ndp delete transaction id
+ * @vdev: pointer to vdev object
+ * @val: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_ndp_delete_transaction_id(struct wlan_objmgr_vdev *vdev,
+						  uint16_t val);
+
+/**
+ * ucfg_nan_get_ndp_delete_transaction_id: get ndp delete transaction id from
+ * vdev obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: ndp delete transaction_id
+ */
+uint16_t ucfg_nan_get_ndp_delete_transaction_id(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_set_ndi_delete_rsp_reason: set ndi delete response reason
+ * @vdev: pointer to vdev object
+ * @val: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_ndi_delete_rsp_reason(struct wlan_objmgr_vdev *vdev,
+					      uint32_t val);
+
+/**
+ * ucfg_nan_get_ndi_delete_rsp_reason: get ndi delete response reason from vdev
+ * obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: ndi delete rsp reason
+ */
+uint32_t ucfg_nan_get_ndi_delete_rsp_reason(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_set_ndi_delete_rsp_status: set ndi delete response reason
+ * @vdev: pointer to vdev object
+ * @val: value to set
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_set_ndi_delete_rsp_status(struct wlan_objmgr_vdev *vdev,
+					      uint32_t val);
+
+/**
+ * ucfg_nan_get_ndi_delete_rsp_status: get ndi delete response status from vdev
+ * obj
+ * @vdev: pointer to vdev object
+ *
+ * Return: ndi delete rsp status
+ */
+uint32_t ucfg_nan_get_ndi_delete_rsp_status(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * ucfg_nan_get_callbacks: ucfg API to return callbacks
+ * @psoc: pointer to psoc object
+ * @cb_obj: callback struct to populate
+ *
+ * Return: callback struct on success, NULL otherwise
+ */
+QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
+				  struct nan_callbacks *cb_obj);
+
+/**
+ * ucfg_nan_req_processor: ucfg API to be called from HDD/OS_IF to
+ * process nan datapath initiator request from userspace
+ * @vdev: nan vdev pointer
+ * @in_req: NDP request
+ * @psoc: pointer to psoc object
+ * @req_type: type of request
+ *
+ * Return: status of operation
+ */
+QDF_STATUS ucfg_nan_req_processor(struct wlan_objmgr_vdev *vdev,
+				  void *in_req, uint32_t req_type);
+
+/**
+ * ucfg_nan_event_handler: ucfg API to be called from legacy code to
+ * post events to os_if/hdd layer
+ * @psoc: pointer to psoc object
+ * @vdev: pointer to vdev object
+ * @type: message type
+ * @msg: msg buffer
+ *
+ * Return: None
+ */
+void ucfg_nan_event_handler(struct wlan_objmgr_psoc *psoc,
+			    struct wlan_objmgr_vdev *vdev,
+			    uint32_t type, void *msg);
+
+/**
+ * ucfg_nan_register_hdd_callbacks: ucfg API to set hdd callbacks
+ * @psoc: pointer to psoc object
+ * @cb_obj: structs containing callbacks
+ * @os_if_event_handler: os if event handler callback
+ *
+ * Return: status of operation
+ */
+int ucfg_nan_register_hdd_callbacks(struct wlan_objmgr_psoc *,
+				    struct nan_callbacks *,
+				    void (os_if_event_handler)
+						(struct wlan_objmgr_psoc *,
+						 struct wlan_objmgr_vdev *,
+						 uint32_t, void *));
+
+/*
+ * ucfg_nan_register_lim_callbacks: ucfg API to set lim callbacks
+ * @psoc: pointer to psoc object
+ * @cb_obj: structs containing callbacks
+ *
+ * Return: status of operation
+ */
+int ucfg_nan_register_lim_callbacks(struct wlan_objmgr_psoc *psoc,
+				    struct nan_callbacks *cb_obj);
+
+/**
+ * ucfg_nan_get_callbacks: ucfg API to return callbacks
+ * @psoc: pointer to psoc object
+ * @cb_obj: callback struct to populate
+ *
+ * Return: callback struct on success, NULL otherwise
+ */
+QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
+				  struct nan_callbacks *cb_obj);
+
+#endif /* _NAN_UCFG_API_H_ */
+

+ 80 - 0
nan/dispatcher/src/cfg_nan.c

@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains NAN INI configurations
+ */
+
+#include "wlan_objmgr_psoc_obj.h"
+#include "cfg_nan_api.h"
+#include "../../core/src/nan_main_i.h"
+
+static inline struct nan_psoc_priv_obj
+		 *cfg_nan_get_priv_obj(struct wlan_objmgr_psoc *psoc)
+{
+	if (!psoc) {
+		nan_err("PSOC obj null");
+		return NULL;
+	}
+	return wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_NAN);
+}
+
+bool cfg_nan_get_enable(struct wlan_objmgr_psoc *psoc)
+{
+	struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
+
+	if (!nan_obj) {
+		nan_err("NAN obj null");
+		return false;
+	}
+	return nan_obj->cfg_param.enable;
+}
+
+bool cfg_nan_get_datapath_enable(struct wlan_objmgr_psoc *psoc)
+{
+	struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
+
+	if (!nan_obj) {
+		nan_err("NAN obj null");
+		return false;
+	}
+	return nan_obj->cfg_param.dp_enable;
+}
+
+uint32_t cfg_nan_get_ndi_channel(struct wlan_objmgr_psoc *psoc)
+{
+	struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
+
+	if (!nan_obj) {
+		nan_err("NAN obj null");
+		return 0;
+	}
+	return nan_obj->cfg_param.ndi_ch;
+}
+
+bool cfg_nan_get_ndi_mac_randomize(struct wlan_objmgr_psoc *psoc)
+{
+	struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
+
+	if (!nan_obj) {
+		nan_err("NAN obj null");
+		return false;
+	}
+	return nan_obj->cfg_param.ndi_mac_randomize;
+}
+

+ 446 - 0
nan/dispatcher/src/nan_ucfg_api.c

@@ -0,0 +1,446 @@
+/*
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: contains interface definitions for OS_IF layer
+ */
+
+#include "nan_ucfg_api.h"
+#include "nan_public_structs.h"
+#include "../../core/src/nan_main_i.h"
+#include "scheduler_api.h"
+#include "wlan_objmgr_psoc_obj.h"
+#include "wlan_objmgr_pdev_obj.h"
+#include "wlan_objmgr_vdev_obj.h"
+
+struct wlan_objmgr_psoc;
+struct wlan_objmgr_vdev;
+
+inline QDF_STATUS ucfg_nan_set_ndi_state(struct wlan_objmgr_vdev *vdev,
+					 uint32_t state)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->state = state;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline enum nan_datapath_state ucfg_nan_get_ndi_state(
+					struct wlan_objmgr_vdev *vdev)
+{
+	enum nan_datapath_state val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return NAN_DATA_INVALID_STATE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->state;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_active_peers(struct wlan_objmgr_vdev *vdev,
+				     uint32_t val)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->active_ndp_peers = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint32_t ucfg_nan_get_active_peers(struct wlan_objmgr_vdev *vdev)
+{
+	uint32_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return 0;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->active_ndp_peers;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_active_ndp_sessions(
+		struct wlan_objmgr_vdev *vdev, uint32_t val, uint8_t idx)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	if (idx >= MAX_PEERS) {
+		nan_err("peer_idx(%d), MAX(%d)",
+			idx, MAX_PEERS);
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->active_ndp_sessions[idx] = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint32_t ucfg_nan_get_active_ndp_sessions(struct wlan_objmgr_vdev *vdev,
+						 uint8_t idx)
+{
+	uint32_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return 0;
+	}
+
+	if (idx >= MAX_PEERS) {
+		nan_err("peer_idx(%d), MAX(%d)",
+			idx, MAX_PEERS);
+		return 0;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->active_ndp_sessions[idx];
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_ndp_create_transaction_id(
+				struct wlan_objmgr_vdev *vdev, uint16_t val)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->ndp_create_transaction_id = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint16_t ucfg_nan_get_ndp_create_transaction_id(
+						struct wlan_objmgr_vdev *vdev)
+{
+	uint16_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return 0;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->ndp_create_transaction_id;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_ndp_delete_transaction_id(
+				struct wlan_objmgr_vdev *vdev, uint16_t val)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->ndp_delete_transaction_id = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint16_t ucfg_nan_get_ndp_delete_transaction_id(
+					struct wlan_objmgr_vdev *vdev)
+{
+	uint16_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return 0;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->ndp_delete_transaction_id;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_ndi_delete_rsp_reason(
+				struct wlan_objmgr_vdev *vdev, uint32_t val)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->ndi_delete_rsp_reason = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint32_t ucfg_nan_get_ndi_delete_rsp_reason(
+					struct wlan_objmgr_vdev *vdev)
+{
+	uint32_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return 0;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->ndi_delete_rsp_reason;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_set_ndi_delete_rsp_status(
+				struct wlan_objmgr_vdev *vdev, uint32_t val)
+{
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	priv_obj->ndi_delete_rsp_status = val;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+inline uint32_t ucfg_nan_get_ndi_delete_rsp_status(
+						struct wlan_objmgr_vdev *vdev)
+{
+	uint32_t val;
+	struct nan_vdev_priv_obj *priv_obj = nan_get_vdev_priv_obj(vdev);
+
+	if (!priv_obj) {
+		nan_err("priv_obj is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	qdf_spin_lock_bh(&priv_obj->lock);
+	val = priv_obj->ndi_delete_rsp_status;
+	qdf_spin_unlock_bh(&priv_obj->lock);
+
+	return val;
+}
+
+inline QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
+					 struct nan_callbacks *cb_obj)
+{
+	struct nan_psoc_priv_obj *psoc_obj = nan_get_psoc_priv_obj(psoc);
+
+	if (!psoc_obj) {
+		nan_err("nan psoc priv object is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	qdf_spin_lock_bh(&psoc_obj->lock);
+	qdf_mem_copy(cb_obj, &psoc_obj->cb_obj, sizeof(*cb_obj));
+	qdf_spin_unlock_bh(&psoc_obj->lock);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS ucfg_nan_sch_msg_flush_cb(struct scheduler_msg *msg)
+{
+	struct wlan_objmgr_vdev *vdev = NULL;
+
+	if (!msg || !msg->bodyptr)
+		return QDF_STATUS_E_NULL_VALUE;
+
+	switch (msg->type) {
+	case NDP_INITIATOR_REQ:
+		vdev = ((struct nan_datapath_initiator_req *)
+			msg->bodyptr)->vdev;
+		break;
+	case NDP_RESPONDER_REQ:
+		vdev = ((struct nan_datapath_responder_req *)
+			msg->bodyptr)->vdev;
+		break;
+	case NDP_END_REQ:
+		vdev = ((struct nan_datapath_end_req *)msg->bodyptr)->vdev;
+		break;
+	default:
+		nan_err("Invalid NAN msg type during sch flush");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (vdev) {
+		wlan_objmgr_vdev_release_ref(vdev, WLAN_NAN_ID);
+		qdf_mem_free(msg->bodyptr);
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS ucfg_nan_req_processor(struct wlan_objmgr_vdev *vdev,
+				  void *in_req, uint32_t req_type)
+{
+	uint32_t len;
+	QDF_STATUS status;
+	struct scheduler_msg msg = {0};
+
+	if (!in_req) {
+		nan_alert("req is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	switch (req_type) {
+	case NDP_INITIATOR_REQ:
+		len = sizeof(struct nan_datapath_initiator_req);
+		break;
+	case NDP_RESPONDER_REQ:
+		len = sizeof(struct nan_datapath_responder_req);
+		break;
+	case NDP_END_REQ:
+		len = sizeof(struct nan_datapath_end_req);
+		break;
+	default:
+		nan_err("in correct message req type: %d", req_type);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	msg.bodyptr = qdf_mem_malloc(len);
+	if (!msg.bodyptr) {
+		nan_err("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+	qdf_mem_copy(msg.bodyptr, in_req, len);
+	msg.type = req_type;
+	msg.callback = nan_scheduled_msg_handler;
+	msg.flush_callback = ucfg_nan_sch_msg_flush_cb;
+	status = scheduler_post_message(QDF_MODULE_ID_HDD,
+					QDF_MODULE_ID_NAN,
+					QDF_MODULE_ID_OS_IF, &msg);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		nan_err("failed to post msg to NAN component, status: %d",
+			status);
+		qdf_mem_free(msg.bodyptr);
+	}
+
+	return status;
+}
+
+void ucfg_nan_event_handler(struct wlan_objmgr_psoc *psoc,
+			    struct wlan_objmgr_vdev *vdev,
+			    uint32_t type, void *msg)
+{
+	struct nan_psoc_priv_obj *psoc_obj = nan_get_psoc_priv_obj(psoc);
+
+	if (!psoc_obj) {
+		nan_err("nan psoc priv object is NULL");
+		return;
+	}
+
+	psoc_obj->cb_obj.os_if_event_handler(psoc, vdev, type, msg);
+}
+
+int ucfg_nan_register_hdd_callbacks(struct wlan_objmgr_psoc *psoc,
+				    struct nan_callbacks *cb_obj,
+				    void (os_if_event_handler)(
+				    struct wlan_objmgr_psoc *,
+				    struct wlan_objmgr_vdev *,
+				    uint32_t, void *))
+{
+	struct nan_psoc_priv_obj *psoc_obj = nan_get_psoc_priv_obj(psoc);
+
+	if (!psoc_obj) {
+		nan_err("nan psoc priv object is NULL");
+		return -EINVAL;
+	}
+
+	psoc_obj->cb_obj.os_if_event_handler = os_if_event_handler;
+
+	psoc_obj->cb_obj.ndi_open = cb_obj->ndi_open;
+	psoc_obj->cb_obj.ndi_start = cb_obj->ndi_start;
+	psoc_obj->cb_obj.ndi_delete = cb_obj->ndi_delete;
+	psoc_obj->cb_obj.ndi_close = cb_obj->ndi_close;
+	psoc_obj->cb_obj.drv_ndi_create_rsp_handler =
+				cb_obj->drv_ndi_create_rsp_handler;
+	psoc_obj->cb_obj.drv_ndi_delete_rsp_handler =
+				cb_obj->drv_ndi_delete_rsp_handler;
+
+	psoc_obj->cb_obj.get_peer_idx = cb_obj->get_peer_idx;
+	psoc_obj->cb_obj.new_peer_ind = cb_obj->new_peer_ind;
+	psoc_obj->cb_obj.peer_departed_ind = cb_obj->peer_departed_ind;
+
+	return 0;
+}
+
+int ucfg_nan_register_lim_callbacks(struct wlan_objmgr_psoc *psoc,
+				    struct nan_callbacks *cb_obj)
+{
+	struct nan_psoc_priv_obj *psoc_obj = nan_get_psoc_priv_obj(psoc);
+
+	if (!psoc_obj) {
+		nan_err("nan psoc priv object is NULL");
+		return -EINVAL;
+	}
+
+	psoc_obj->cb_obj.add_ndi_peer = cb_obj->add_ndi_peer;
+	psoc_obj->cb_obj.ndp_delete_peers = cb_obj->ndp_delete_peers;
+	psoc_obj->cb_obj.delete_peers_by_addr = cb_obj->delete_peers_by_addr;
+
+	return 0;
+}