Parcourir la source

qcacmn: Avoid WMI TLV structures in NAN target_if

Refactor NAN target_if to make it wmi-type agnostic. Specifically
do not access wmi structures in NAN target_if. All the access to
wmi structures should happen in tlv and non-tlv specific wmi files.

Change-Id: I944b678fc501723d7cd26c9b21c4cc6ddb7fda4e
CRs-Fixed: 2159876
Naveen Rawat il y a 7 ans
Parent
commit
68805125fd

+ 1 - 10
os_if/linux/nan/inc/os_if_nan.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * 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
@@ -32,15 +32,6 @@ struct wlan_objmgr_vdev;
 
 #ifdef WLAN_FEATURE_NAN_CONVERGENCE
 
-#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
-
 /**
  * enum qca_wlan_vendor_attr_ndp_params - vendor attribute parameters
  * @QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD: NDP Sub command

+ 22 - 21
os_if/linux/nan/src/os_if_nan.c

@@ -206,10 +206,10 @@ static int os_if_nan_parse_security_params(struct nlattr **tb,
 	}
 
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
-		pmk->pmk_len =
-			nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
-		pmk->pmk =
-			nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
+		pmk->pmk_len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
+		qdf_mem_copy(pmk->pmk,
+			     nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]),
+			     pmk->pmk_len);
 		cfg80211_err("pmk len: %d", pmk->pmk_len);
 		QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
 				   pmk->pmk, pmk->pmk_len);
@@ -218,8 +218,9 @@ static int os_if_nan_parse_security_params(struct nlattr **tb,
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]) {
 		passphrase->passphrase_len =
 			nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]);
-		passphrase->passphrase =
-			nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]);
+		qdf_mem_copy(passphrase->passphrase,
+			     nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]),
+			     passphrase->passphrase_len);
 		cfg80211_err("passphrase len: %d", passphrase->passphrase_len);
 		QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
 			passphrase->passphrase, passphrase->passphrase_len);
@@ -228,8 +229,9 @@ static int os_if_nan_parse_security_params(struct nlattr **tb,
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]) {
 		service_name->service_name_len =
 			nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]);
-		service_name->service_name =
-			nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]);
+		qdf_mem_copy(service_name->service_name,
+			nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]),
+			service_name->service_name_len);
 		cfg80211_err("service_name len: %d",
 			     service_name->service_name_len);
 		QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
@@ -267,7 +269,6 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
 	int ret = 0;
 	char *iface_name;
 	QDF_STATUS status;
-	uint32_t ndp_qos_cfg;
 	enum nan_datapath_state state;
 	struct wlan_objmgr_vdev *nan_vdev;
 	struct nan_datapath_initiator_req req = {0};
@@ -343,15 +344,15 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]) {
 		req.ndp_info.ndp_app_info_len =
 			nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]);
-		req.ndp_info.ndp_app_info =
-			nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]);
+		qdf_mem_copy(req.ndp_info.ndp_app_info,
+			     nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]),
+			     req.ndp_info.ndp_app_info_len);
 	}
 
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS]) {
 		/* at present ndp config stores 4 bytes QOS info only */
 		req.ndp_config.ndp_cfg_len = 4;
-		req.ndp_config.ndp_cfg = (uint8_t *)&ndp_qos_cfg;
-		ndp_qos_cfg =
+		*((uint32_t *)req.ndp_config.ndp_cfg) =
 			nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS]);
 	}
 
@@ -400,7 +401,6 @@ static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
 	int ret = 0;
 	char *iface_name;
 	QDF_STATUS status;
-	uint32_t ndp_qos_cfg;
 	enum nan_datapath_state state;
 	struct wlan_objmgr_vdev *nan_vdev;
 	struct nan_datapath_responder_req req = {0};
@@ -461,19 +461,18 @@ static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]) {
 		req.ndp_info.ndp_app_info_len =
 			nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]);
-		if (req.ndp_info.ndp_app_info_len) {
-			req.ndp_info.ndp_app_info =
-				nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]);
-		}
+		qdf_mem_copy(req.ndp_info.ndp_app_info,
+			     nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO]),
+			     req.ndp_info.ndp_app_info_len);
 	} else {
 		cfg80211_debug("NDP app info is unavailable");
 	}
+
 	if (tb[QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS]) {
 		/* at present ndp config stores 4 bytes QOS info only */
 		req.ndp_config.ndp_cfg_len = 4;
-		ndp_qos_cfg =
+		*((uint32_t *)req.ndp_config.ndp_cfg) =
 			nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS]);
-		req.ndp_config.ndp_cfg = (uint8_t *)&ndp_qos_cfg;
 	} else {
 		cfg80211_debug("NDP config data is unavailable");
 	}
@@ -537,7 +536,9 @@ static int os_if_nan_process_ndp_end_req(struct wlan_objmgr_psoc *psoc,
 		cfg80211_err("Num NDP instances is 0");
 		return -EINVAL;
 	}
-	req.ndp_ids = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY]);
+	qdf_mem_copy(req.ndp_ids,
+		     tb[QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY],
+		     req.num_ndp_instances * sizeof(uint32_t));
 
 	cfg80211_debug("sending ndp_end_req to SME, transaction_id: %d",
 		req.transaction_id);

Fichier diff supprimé car celui-ci est trop grand
+ 143 - 628
target_if/nan/src/target_if_nan.c


+ 27 - 15
umac/nan/core/inc/nan_public_structs.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ * 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
@@ -31,6 +31,15 @@ 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_DATAPATH_INF_CREATE_REQ                     0
 #define NAN_DATAPATH_INF_CREATE_RSP                     1
@@ -193,7 +202,7 @@ enum nan_datapath_state {
  */
 struct nan_datapath_app_info {
 	uint32_t ndp_app_info_len;
-	uint8_t *ndp_app_info;
+	uint8_t ndp_app_info[NDP_APP_INFO_LEN];
 };
 
 /**
@@ -204,7 +213,7 @@ struct nan_datapath_app_info {
  */
 struct nan_datapath_cfg {
 	uint32_t ndp_cfg_len;
-	uint8_t *ndp_cfg;
+	uint8_t ndp_cfg[NDP_QOS_INFO_LEN];
 };
 
 /**
@@ -215,7 +224,7 @@ struct nan_datapath_cfg {
  */
 struct nan_datapath_pmk {
 	uint32_t pmk_len;
-	uint8_t *pmk;
+	uint8_t pmk[NDP_PMK_LEN];
 };
 
 /**
@@ -226,7 +235,7 @@ struct nan_datapath_pmk {
  */
 struct nan_datapath_scid {
 	uint32_t scid_len;
-	uint8_t *scid;
+	uint8_t scid[NDP_SCID_BUF_LEN];
 };
 
 /**
@@ -237,7 +246,7 @@ struct nan_datapath_scid {
  */
 struct ndp_passphrase {
 	uint32_t passphrase_len;
-	uint8_t *passphrase;
+	uint8_t passphrase[NAN_PASSPHRASE_MAX_LEN];
 };
 
 /**
@@ -248,7 +257,7 @@ struct ndp_passphrase {
  */
 struct ndp_service_name {
 	uint32_t service_name_len;
-	uint8_t *service_name;
+	uint8_t service_name[NAN_MAX_SERVICE_NAME_LEN];
 };
 
 /**
@@ -306,8 +315,8 @@ struct nan_datapath_inf_delete_rsp {
 
 /**
  * struct nan_datapath_initiator_req - ndp initiator request params
+ * @vdev: pointer to vdev object
  * @transaction_id: unique identifier
- * @vdev_id: session id of the interface over which ndp is being created
  * @channel: suggested channel for ndp creation
  * @channel_cfg: channel config, 0=no channel, 1=optional, 2=mandatory
  * @service_instance_id: Service identifier
@@ -338,8 +347,8 @@ struct nan_datapath_initiator_req {
 
 /**
  * struct nan_datapath_initiator_rsp - response event from FW
+ * @vdev: pointer to vdev object
  * @transaction_id: unique identifier
- * @vdev_id: session id of the interface over which ndp is being created
  * @ndp_instance_id: locally created NDP instance ID
  * @status: status of the ndp request
  * @reason: reason for failure if any
@@ -356,8 +365,8 @@ struct nan_datapath_initiator_rsp {
 /**
  * struct nan_datapath_responder_req - responder's response to ndp create
  * request
+ * @vdev: pointer to vdev object
  * @transaction_id: unique identifier
- * @vdev_id: session id of the interface over which ndp is being created
  * @ndp_instance_id: locally created NDP instance ID
  * @ndp_rsp: response to the ndp create request
  * @ndp_config: ndp configuration params
@@ -383,8 +392,8 @@ struct nan_datapath_responder_req {
 
 /**
  * struct nan_datapath_responder_rsp - response to responder's request
+ * @vdev: pointer to vdev object
  * @transaction_id: unique identifier
- * @vdev_id: session id of the interface over which ndp is being created
  * @status: command status
  * @reason: reason for failure if any
  * @peer_mac_addr: Peer's mac address
@@ -401,20 +410,22 @@ struct nan_datapath_responder_rsp {
 
 /**
  * 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: pointer to array of ndp_instance_id 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;
+	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)
@@ -430,6 +441,7 @@ struct nan_datapath_end_rsp_event {
 /**
  * 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
  *
@@ -442,7 +454,7 @@ struct nan_datapath_end_indication_event {
 
 /**
  * struct nan_datapath_confirm_event - ndp confirmation event from FW
- * @vdev_id: session id of the interface over which ndp is being created
+ * @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
@@ -463,7 +475,7 @@ struct nan_datapath_confirm_event {
 
 /**
  * struct nan_datapath_indication_event - create ndp indication on the responder
- * @vdev_id: session id of the interface over which ndp is being created
+ * @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

+ 7 - 30
umac/nan/core/src/nan_main.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
+ * 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
@@ -71,27 +71,16 @@ void nan_release_cmd(void *in_req, uint32_t cmdtype)
 	case WLAN_SER_CMD_NDP_INIT_REQ: {
 		struct nan_datapath_initiator_req *req = in_req;
 		vdev = req->vdev;
-		qdf_mem_free(req->pmk.pmk);
-		qdf_mem_free(req->ndp_info.ndp_app_info);
-		qdf_mem_free(req->ndp_config.ndp_cfg);
-		qdf_mem_free(req->passphrase.passphrase);
-		qdf_mem_free(req->service_name.service_name);
 		break;
 	}
 	case WLAN_SER_CMD_NDP_RESP_REQ: {
 		struct nan_datapath_responder_req *req = in_req;
 		vdev = req->vdev;
-		qdf_mem_free(req->pmk.pmk);
-		qdf_mem_free(req->ndp_info.ndp_app_info);
-		qdf_mem_free(req->ndp_config.ndp_cfg);
-		qdf_mem_free(req->passphrase.passphrase);
-		qdf_mem_free(req->service_name.service_name);
 		break;
 	}
 	case WLAN_SER_CMD_NDP_DATA_END_INIT_REQ: {
 		struct nan_datapath_end_req *req = in_req;
 		vdev = req->vdev;
-		qdf_mem_free(req->ndp_ids);
 		break;
 	}
 	default:
@@ -261,7 +250,6 @@ static QDF_STATUS nan_handle_confirm(
 				struct nan_datapath_confirm_event *confirm)
 {
 	uint8_t vdev_id;
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	struct wlan_objmgr_psoc *psoc;
 	struct nan_psoc_priv_obj *psoc_nan_obj;
 
@@ -269,15 +257,13 @@ static QDF_STATUS nan_handle_confirm(
 	psoc = wlan_vdev_get_psoc(confirm->vdev);
 	if (!psoc) {
 		nan_err("psoc is null");
-		status = QDF_STATUS_E_NULL_VALUE;
-		goto free_resource;
+		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");
-		status = QDF_STATUS_E_NULL_VALUE;
-		goto free_resource;
+		return QDF_STATUS_E_NULL_VALUE;
 	}
 
 	if (confirm->rsp_code != NAN_DATAPATH_RESPONSE_ACCEPT &&
@@ -295,10 +281,7 @@ static QDF_STATUS nan_handle_confirm(
 	psoc_nan_obj->cb_obj.os_if_event_handler(psoc, confirm->vdev,
 						 NDP_CONFIRM, confirm);
 
-free_resource:
-	qdf_mem_free(confirm->ndp_info.ndp_app_info);
-
-	return status;
+	return QDF_STATUS_SUCCESS;
 }
 
 static QDF_STATUS nan_handle_initiator_rsp(
@@ -339,15 +322,13 @@ static QDF_STATUS nan_handle_ndp_ind(
 	psoc = wlan_vdev_get_psoc(ndp_ind->vdev);
 	if (!psoc) {
 		nan_err("psoc is null");
-		status = QDF_STATUS_E_NULL_VALUE;
-		goto ndp_indication_failed;
+		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");
-		status = QDF_STATUS_E_NULL_VALUE;
-		goto ndp_indication_failed;
+		return QDF_STATUS_E_NULL_VALUE;
 	}
 
 	nan_debug("role: %d, vdev: %d, csid: %d, peer_mac_addr "
@@ -363,16 +344,12 @@ static QDF_STATUS nan_handle_ndp_ind(
 		if (QDF_IS_STATUS_ERROR(status)) {
 			nan_err("Couldn't add ndi peer, ndp_role: %d",
 				ndp_ind->role);
-			goto ndp_indication_failed;
+			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);
-ndp_indication_failed:
-	qdf_mem_free(ndp_ind->ndp_config.ndp_cfg);
-	qdf_mem_free(ndp_ind->ndp_info.ndp_app_info);
-	qdf_mem_free(ndp_ind->scid.scid);
 
 	return status;
 }

+ 9 - 223
umac/nan/dispatcher/src/nan_ucfg_api.c

@@ -302,224 +302,10 @@ inline QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
 	return QDF_STATUS_SUCCESS;
 }
 
-static struct nan_datapath_initiator_req *ucfg_nan_copy_intiator_req(
-			struct wlan_objmgr_vdev *vdev,
-			struct nan_datapath_initiator_req *in_req)
-{
-	struct nan_datapath_initiator_req *out_req;
-
-	out_req = qdf_mem_malloc(sizeof(*out_req));
-	if (!out_req) {
-		nan_alert("malloc failed");
-		return NULL;
-	}
-
-	qdf_mem_copy(out_req, in_req, sizeof(*out_req));
-	if (in_req->ndp_config.ndp_cfg_len) {
-		out_req->ndp_config.ndp_cfg =
-			qdf_mem_malloc(in_req->ndp_config.ndp_cfg_len);
-		if (!out_req->ndp_config.ndp_cfg) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(out_req->ndp_config.ndp_cfg,
-			     in_req->ndp_config.ndp_cfg,
-			     in_req->ndp_config.ndp_cfg_len);
-	}
-
-	if (in_req->ndp_info.ndp_app_info_len) {
-		out_req->ndp_info.ndp_app_info =
-			qdf_mem_malloc(in_req->ndp_info.ndp_app_info_len);
-		if (!out_req->ndp_info.ndp_app_info) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(out_req->ndp_info.ndp_app_info,
-			     in_req->ndp_info.ndp_app_info,
-			     in_req->ndp_info.ndp_app_info_len);
-	}
-
-	if (in_req->pmk.pmk_len) {
-		out_req->pmk.pmk = qdf_mem_malloc(in_req->pmk.pmk_len);
-		if (!out_req->pmk.pmk) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(out_req->pmk.pmk, in_req->pmk.pmk,
-			     in_req->pmk.pmk_len);
-	}
-
-	if (in_req->passphrase.passphrase_len) {
-		out_req->passphrase.passphrase =
-			qdf_mem_malloc(in_req->passphrase.passphrase_len);
-		if (NULL == out_req->passphrase.passphrase) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(out_req->passphrase.passphrase,
-			     in_req->passphrase.passphrase,
-			     in_req->passphrase.passphrase_len);
-	}
-
-	if (in_req->service_name.service_name_len) {
-		out_req->service_name.service_name =
-		    qdf_mem_malloc(in_req->service_name.service_name_len);
-		if (NULL == out_req->service_name.service_name) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(out_req->service_name.service_name,
-			     in_req->service_name.service_name,
-			     in_req->service_name.service_name_len);
-	}
-
-	nan_debug("pmk_len: %d, passphrase_len: %d, service_name_len: %d",
-		  out_req->pmk.pmk_len,
-		  out_req->passphrase.passphrase_len,
-		  out_req->service_name.service_name_len);
-
-	/* do not get ref here, rather take ref when request is activated */
-	out_req->vdev = vdev;
-	return out_req;
-
-free_resources:
-	qdf_mem_free(out_req->passphrase.passphrase);
-	qdf_mem_free(out_req->service_name.service_name);
-	qdf_mem_free(out_req->pmk.pmk);
-	qdf_mem_free(out_req->ndp_info.ndp_app_info);
-	qdf_mem_free(out_req->ndp_config.ndp_cfg);
-	qdf_mem_free(out_req);
-	return NULL;
-}
-
-static struct nan_datapath_responder_req *ucfg_nan_copy_responder_req(
-				struct wlan_objmgr_vdev *vdev,
-				struct nan_datapath_responder_req *in_req)
-{
-	struct nan_datapath_responder_req *req;
-
-	req = qdf_mem_malloc(sizeof(*req));
-	if (!req) {
-		nan_alert("malloc failed");
-		return NULL;
-	}
-
-	qdf_mem_copy(req, in_req, sizeof(*req));
-	if (in_req->ndp_config.ndp_cfg_len) {
-		req->ndp_config.ndp_cfg =
-			qdf_mem_malloc(in_req->ndp_config.ndp_cfg_len);
-		if (!req->ndp_config.ndp_cfg) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->ndp_config.ndp_cfg,
-			     in_req->ndp_config.ndp_cfg,
-			     in_req->ndp_config.ndp_cfg_len);
-	}
-
-	if (in_req->ndp_info.ndp_app_info_len) {
-		req->ndp_info.ndp_app_info =
-			qdf_mem_malloc(in_req->ndp_info.ndp_app_info_len);
-		if (!req->ndp_info.ndp_app_info) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->ndp_info.ndp_app_info,
-			     in_req->ndp_info.ndp_app_info,
-			     in_req->ndp_info.ndp_app_info_len);
-	}
-
-	if (in_req->pmk.pmk_len) {
-		req->pmk.pmk = qdf_mem_malloc(in_req->pmk.pmk_len);
-		if (!req->pmk.pmk) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->pmk.pmk, in_req->pmk.pmk,
-				in_req->pmk.pmk_len);
-	}
-
-	if (in_req->passphrase.passphrase_len) {
-		req->passphrase.passphrase =
-			qdf_mem_malloc(in_req->passphrase.passphrase_len);
-		if (NULL == req->passphrase.passphrase) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->passphrase.passphrase,
-			     in_req->passphrase.passphrase,
-			     in_req->passphrase.passphrase_len);
-	}
-
-	if (in_req->service_name.service_name_len) {
-		req->service_name.service_name =
-		    qdf_mem_malloc(in_req->service_name.service_name_len);
-		if (NULL == req->service_name.service_name) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->service_name.service_name,
-			     in_req->service_name.service_name,
-			     in_req->service_name.service_name_len);
-	}
-
-	nan_debug("pmk_len: %d, passphrase_len: %d, service_name_len: %d",
-		  req->pmk.pmk_len,
-		  req->passphrase.passphrase_len,
-		  req->service_name.service_name_len);
-
-	/* do not get ref here, rather take ref when request is activated */
-	req->vdev = vdev;
-	return req;
-
-free_resources:
-	qdf_mem_free(req->passphrase.passphrase);
-	qdf_mem_free(req->service_name.service_name);
-	qdf_mem_free(req->pmk.pmk);
-	qdf_mem_free(req->ndp_info.ndp_app_info);
-	qdf_mem_free(req->ndp_config.ndp_cfg);
-	qdf_mem_free(req);
-	return NULL;
-}
-
-static struct nan_datapath_end_req *ucfg_nan_copy_end_req(
-			struct wlan_objmgr_vdev *vdev,
-			struct nan_datapath_end_req *in_req)
-{
-	struct nan_datapath_end_req *req;
-
-	req = qdf_mem_malloc(sizeof(*req));
-	if (!req) {
-		nan_alert("malloc failed");
-		return NULL;
-	}
-
-	qdf_mem_copy(req, in_req, sizeof(*req));
-	if (in_req->num_ndp_instances) {
-		req->ndp_ids = qdf_mem_malloc(sizeof(uint32_t) *
-						in_req->num_ndp_instances);
-		if (!req->ndp_ids) {
-			nan_alert("malloc failed");
-			goto free_resources;
-		}
-		qdf_mem_copy(req->ndp_ids, in_req->ndp_ids,
-			     sizeof(uint32_t) * in_req->num_ndp_instances);
-	}
-
-	/* do not get ref here, rather take ref when request is activated */
-	req->vdev = vdev;
-	return req;
-
-free_resources:
-	qdf_mem_free(req->ndp_ids);
-	qdf_mem_free(req);
-	return NULL;
-}
-
 QDF_STATUS ucfg_nan_req_processor(struct wlan_objmgr_vdev *vdev,
 				  void *in_req, uint32_t req_type)
 {
-	void *req;
+	uint32_t len;
 	QDF_STATUS status;
 	struct scheduler_msg msg = {0};
 
@@ -530,26 +316,26 @@ QDF_STATUS ucfg_nan_req_processor(struct wlan_objmgr_vdev *vdev,
 
 	switch (req_type) {
 	case NDP_INITIATOR_REQ:
-		req = ucfg_nan_copy_intiator_req(vdev, in_req);
+		len = sizeof(struct nan_datapath_initiator_req);
 		break;
 	case NDP_RESPONDER_REQ:
-		req = ucfg_nan_copy_responder_req(vdev, in_req);
+		len = sizeof(struct nan_datapath_responder_req);
 		break;
 	case NDP_END_REQ:
-		req = ucfg_nan_copy_end_req(vdev, in_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;
 	}
 
-	if (!req) {
-		nan_err("failed to create local copy");
-		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.bodyptr = req;
 	msg.callback = nan_scheduled_msg_handler;
 	status = scheduler_post_msg(QDF_MODULE_ID_OS_IF, &msg);
 	if (QDF_IS_STATUS_ERROR(status)) {

+ 104 - 1
wmi/inc/wmi_unified_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -49,6 +49,10 @@
 #endif
 #include "wlan_scan_public_structs.h"
 
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+#include "nan_public_structs.h"
+#endif
+
 typedef qdf_nbuf_t wmi_buf_t;
 #define wmi_buf_data(_buf) qdf_nbuf_data(_buf)
 
@@ -1756,4 +1760,103 @@ QDF_STATUS wmi_unified_send_dump_wds_table_cmd(void *wmi_hdl);
 
 QDF_STATUS wmi_extract_wds_entry(void *wmi_hdl, uint8_t *evt_buf,
 			struct wdsentry *wds_entry, u_int32_t idx);
+
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+/**
+ * wmi_unified_ndp_initiator_req_cmd_send - api to send initiator request to FW
+ * @wmi_hdl: wma handle
+ * @req: pointer to request buffer
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl,
+				struct nan_datapath_initiator_req *req);
+
+/**
+ * wmi_unified_ndp_responder_req_cmd_send - api to send responder request to FW
+ * @wmi_hdl: wma handle
+ * @req: pointer to request buffer
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl,
+				struct nan_datapath_responder_req *req);
+
+/**
+ * wmi_unified_ndp_end_req_cmd_send - api to send end request to FW
+ * @wmi_hdl: wma handle
+ * @req: pointer to request buffer
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_unified_ndp_end_req_cmd_send(void *wmi_hdl,
+				struct nan_datapath_end_req *req);
+
+/**
+ * wmi_extract_ndp_initiator_rsp - api to extract initiator rsp from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @rsp: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_initiator_rsp **rsp);
+
+/**
+ * wmi_extract_ndp_ind - api to extract ndp indication struct from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @ind: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_ind(wmi_unified_t wmi_handle, uint8_t *data,
+			struct nan_datapath_indication_event **ind);
+
+/**
+ * wmi_extract_ndp_confirm - api to extract ndp confim struct from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @ev: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_confirm(wmi_unified_t wmi_handle, uint8_t *data,
+			struct nan_datapath_confirm_event **ev);
+
+/**
+ * wmi_extract_ndp_responder_rsp - api to extract responder rsp from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @rsp: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_responder_rsp(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_responder_rsp **rsp);
+
+/**
+ * wmi_extract_ndp_end_rsp - api to extract ndp end rsp from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @rsp: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_end_rsp(wmi_unified_t wmi_handle, uint8_t *data,
+			struct nan_datapath_end_rsp_event **rsp);
+
+/**
+ * wmi_extract_ndp_end_ind - api to extract ndp end indication from even buffer
+ * @wmi_hdl: wma handle
+ * @data: event buffer
+ * @ind: buffer to populate
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wmi_extract_ndp_end_ind(wmi_unified_t wmi_handle, uint8_t *data,
+			struct nan_datapath_end_indication_event **ind);
+
+#endif
 #endif /* _WMI_UNIFIED_API_H_ */

+ 28 - 1
wmi/inc/wmi_unified_priv.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -50,6 +50,10 @@
 #endif
 #include <qdf_threads.h>
 
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+#include "nan_public_structs.h"
+#endif
+
 #define WMI_UNIFIED_MAX_EVENT 0x100
 #define WMI_MAX_CMDS 1024
 
@@ -1452,6 +1456,29 @@ QDF_STATUS (*extract_wds_entry)(wmi_unified_t wmi_handle,
 		uint8_t *evt_buf,
 		struct wdsentry *wds_entry,
 		u_int32_t idx);
+
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+QDF_STATUS (*send_ndp_initiator_req_cmd)(wmi_unified_t wmi_handle,
+				struct nan_datapath_initiator_req *req);
+QDF_STATUS (*send_ndp_responder_req_cmd)(wmi_unified_t wmi_handle,
+				struct nan_datapath_responder_req *req);
+QDF_STATUS (*send_ndp_end_req_cmd)(wmi_unified_t wmi_handle,
+				struct nan_datapath_end_req *req);
+
+QDF_STATUS (*extract_ndp_initiator_rsp)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_initiator_rsp **rsp);
+QDF_STATUS (*extract_ndp_ind)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_indication_event **ind);
+QDF_STATUS (*extract_ndp_confirm)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_confirm_event **ev);
+QDF_STATUS (*extract_ndp_responder_rsp)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_responder_rsp **rsp);
+QDF_STATUS (*extract_ndp_end_rsp)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_end_rsp_event **rsp);
+QDF_STATUS (*extract_ndp_end_ind)(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_end_indication_event **ind);
+
+#endif
 };
 
 /* Forward declartion for psoc*/

+ 99 - 1
wmi/src/wmi_unified_api.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -7113,3 +7113,101 @@ QDF_STATUS wmi_extract_wds_entry(void *wmi_hdl, uint8_t *evt_buf,
 
 	return QDF_STATUS_E_FAILURE;
 }
+
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+QDF_STATUS wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl,
+					struct nan_datapath_initiator_req *req)
+{
+	wmi_unified_t wmi_handle = wmi_hdl;
+
+	if (wmi_handle->ops->send_ndp_initiator_req_cmd)
+		return wmi_handle->ops->send_ndp_initiator_req_cmd(wmi_handle,
+								    req);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl,
+				struct nan_datapath_responder_req *req)
+{
+	wmi_unified_t wmi_handle = wmi_hdl;
+
+	if (wmi_handle->ops->send_ndp_responder_req_cmd)
+		return wmi_handle->ops->send_ndp_responder_req_cmd(wmi_handle,
+								    req);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_unified_ndp_end_req_cmd_send(void *wmi_hdl,
+					    struct nan_datapath_end_req *req)
+{
+	wmi_unified_t wmi_handle = wmi_hdl;
+
+	if (wmi_handle->ops->send_ndp_end_req_cmd)
+		return wmi_handle->ops->send_ndp_end_req_cmd(wmi_handle,
+								    req);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
+{
+	if (wmi_handle->ops->extract_ndp_initiator_rsp)
+		return wmi_handle->ops->extract_ndp_initiator_rsp(wmi_handle,
+								data, rsp);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_ind(wmi_unified_t wmi_handle, uint8_t *data,
+			       struct nan_datapath_indication_event **ind)
+{
+	if (wmi_handle->ops->extract_ndp_ind)
+		return wmi_handle->ops->extract_ndp_ind(wmi_handle,
+							data, ind);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_confirm(wmi_unified_t wmi_handle, uint8_t *data,
+				   struct nan_datapath_confirm_event **ev)
+{
+	if (wmi_handle->ops->extract_ndp_confirm)
+		return wmi_handle->ops->extract_ndp_confirm(wmi_handle,
+							    data, ev);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_responder_rsp(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_responder_rsp **rsp)
+{
+	if (wmi_handle->ops->extract_ndp_responder_rsp)
+		return wmi_handle->ops->extract_ndp_responder_rsp(wmi_handle,
+								  data, rsp);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_end_rsp(wmi_unified_t wmi_handle, uint8_t *data,
+				   struct nan_datapath_end_rsp_event **rsp)
+{
+	if (wmi_handle->ops->extract_ndp_end_rsp)
+		return wmi_handle->ops->extract_ndp_end_rsp(wmi_handle,
+							    data, rsp);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wmi_extract_ndp_end_ind(wmi_unified_t wmi_handle, uint8_t *data,
+				struct nan_datapath_end_indication_event **ind)
+{
+	if (wmi_handle->ops->extract_ndp_end_ind)
+		return wmi_handle->ops->extract_ndp_end_ind(wmi_handle,
+							    data, ind);
+
+	return QDF_STATUS_E_FAILURE;
+}
+#endif

+ 603 - 1
wmi/src/wmi_unified_tlv.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -40,6 +40,10 @@
 #endif
 #include <wlan_utility.h>
 
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+#include "nan_public_structs.h"
+#endif
+
 /* copy_vdev_create_pdev_id() - copy pdev from host params to target command
  *                              buffer.
  * @wmi_handle: pointer to wmi_handle
@@ -16519,6 +16523,593 @@ QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
 	return ret;
 }
 
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
+				struct nan_datapath_initiator_req *ndp_req)
+{
+	uint16_t len;
+	wmi_buf_t buf;
+	uint8_t *tlv_ptr;
+	QDF_STATUS status;
+	wmi_channel *ch_tlv;
+	wmi_ndp_initiator_req_fixed_param *cmd;
+	uint32_t passphrase_len, service_name_len;
+	uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
+
+	/*
+	 * WMI command expects 4 byte alligned len:
+	 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
+	 */
+	ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
+	ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
+	pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
+	passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
+	service_name_len =
+		   qdf_roundup(ndp_req->service_name.service_name_len, 4);
+	/* allocated memory for fixed params as well as variable size data */
+	len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
+		+ ndp_cfg_len + ndp_app_info_len + pmk_len
+		+ passphrase_len + service_name_len;
+
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("wmi_buf_alloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN(
+				wmi_ndp_initiator_req_fixed_param));
+	cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
+	cmd->transaction_id = ndp_req->transaction_id;
+	cmd->service_instance_id = ndp_req->service_instance_id;
+	WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
+				   &cmd->peer_discovery_mac_addr);
+
+	cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
+	cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
+	cmd->ndp_channel_cfg = ndp_req->channel_cfg;
+	cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
+	cmd->nan_csid = ndp_req->ncs_sk_type;
+	cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
+	cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
+
+	ch_tlv = (wmi_channel *)&cmd[1];
+	WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
+			WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
+	ch_tlv->mhz = ndp_req->channel;
+	tlv_ptr = (uint8_t *)&ch_tlv[1];
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
+		     cmd->nan_pmk_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
+		     cmd->nan_passphrase_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     ndp_req->service_name.service_name,
+		     cmd->nan_servicename_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
+
+	WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
+		 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
+		 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
+	WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
+		 cmd->peer_discovery_mac_addr.mac_addr31to0,
+		 cmd->peer_discovery_mac_addr.mac_addr47to32);
+
+	WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   ndp_req->ndp_config.ndp_cfg,
+			   ndp_req->ndp_config.ndp_cfg_len);
+
+	WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   ndp_req->ndp_info.ndp_app_info,
+			   ndp_req->ndp_info.ndp_app_info_len);
+
+	WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   ndp_req->pmk.pmk, cmd->nan_pmk_len);
+
+	WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   ndp_req->passphrase.passphrase,
+			   cmd->nan_passphrase_len);
+
+	WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   ndp_req->service_name.service_name,
+			   cmd->nan_servicename_len);
+
+	WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
+		 WMI_NDP_INITIATOR_REQ_CMDID);
+
+	status = wmi_unified_cmd_send(wmi_handle, buf, len,
+				      WMI_NDP_INITIATOR_REQ_CMDID);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
+		wmi_buf_free(buf);
+	}
+
+	return status;
+}
+
+static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
+					struct nan_datapath_responder_req *req)
+{
+	uint16_t len;
+	wmi_buf_t buf;
+	uint8_t *tlv_ptr;
+	QDF_STATUS status;
+	wmi_ndp_responder_req_fixed_param *cmd;
+	uint32_t passphrase_len, service_name_len;
+	uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
+
+	vdev_id = wlan_vdev_get_id(req->vdev);
+	WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
+		 vdev_id, req->transaction_id,
+		 req->ndp_rsp,
+		 req->ndp_instance_id,
+		 req->ndp_info.ndp_app_info_len);
+
+	/*
+	 * WMI command expects 4 byte alligned len:
+	 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
+	 */
+	ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
+	ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
+	pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
+	passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
+	service_name_len =
+		qdf_roundup(req->service_name.service_name_len, 4);
+
+	/* allocated memory for fixed params as well as variable size data */
+	len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
+		+ pmk_len + passphrase_len + service_name_len;
+
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("wmi_buf_alloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+	cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN(
+				wmi_ndp_responder_req_fixed_param));
+	cmd->vdev_id = vdev_id;
+	cmd->transaction_id = req->transaction_id;
+	cmd->ndp_instance_id = req->ndp_instance_id;
+	cmd->rsp_code = req->ndp_rsp;
+	cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
+	cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
+	cmd->nan_pmk_len = req->pmk.pmk_len;
+	cmd->nan_csid = req->ncs_sk_type;
+	cmd->nan_passphrase_len = req->passphrase.passphrase_len;
+	cmd->nan_servicename_len = req->service_name.service_name_len;
+
+	tlv_ptr = (uint8_t *)&cmd[1];
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
+
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     req->ndp_info.ndp_app_info,
+		     req->ndp_info.ndp_app_info_len);
+
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
+		     cmd->nan_pmk_len);
+
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     req->passphrase.passphrase,
+		     cmd->nan_passphrase_len);
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
+
+	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
+	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
+		     req->service_name.service_name,
+		     cmd->nan_servicename_len);
+
+	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
+
+	WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
+		 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
+
+	WMI_LOGD("ndp_config len: %d",
+		 req->ndp_config.ndp_cfg_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			req->ndp_config.ndp_cfg,
+			req->ndp_config.ndp_cfg_len);
+
+	WMI_LOGD("ndp_app_info len: %d",
+		 req->ndp_info.ndp_app_info_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   req->ndp_info.ndp_app_info,
+			   req->ndp_info.ndp_app_info_len);
+
+	WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   req->pmk.pmk, cmd->nan_pmk_len);
+
+	WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   req->passphrase.passphrase,
+			   cmd->nan_passphrase_len);
+
+	WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   req->service_name.service_name,
+			   cmd->nan_servicename_len);
+
+	WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
+		 WMI_NDP_RESPONDER_REQ_CMDID);
+	status = wmi_unified_cmd_send(wmi_handle, buf, len,
+				      WMI_NDP_RESPONDER_REQ_CMDID);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
+		wmi_buf_free(buf);
+	}
+	return status;
+}
+
+static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
+				      struct nan_datapath_end_req *req)
+{
+	uint16_t len;
+	wmi_buf_t buf;
+	QDF_STATUS status;
+	uint32_t ndp_end_req_len, i;
+	wmi_ndp_end_req *ndp_end_req_lst;
+	wmi_ndp_end_req_fixed_param *cmd;
+
+	/* len of tlv following fixed param  */
+	ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
+	/* above comes out to 4 byte alligned already, no need of padding */
+	len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("Malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
+
+	cmd->transaction_id = req->transaction_id;
+
+	/* set tlv pointer to end of fixed param */
+	WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
+			ndp_end_req_len);
+
+	ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
+						WMI_TLV_HDR_SIZE);
+	for (i = 0; i < req->num_ndp_instances; i++) {
+		WMITLV_SET_HDR(&ndp_end_req_lst[i],
+				WMITLV_TAG_ARRAY_FIXED_STRUC,
+				(sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
+
+		ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
+	}
+
+	WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
+	status = wmi_unified_cmd_send(wmi_handle, buf, len,
+				   WMI_NDP_END_REQ_CMDID);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
+		wmi_buf_free(buf);
+	}
+
+	return status;
+}
+
+static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
+{
+	WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
+	wmi_ndp_initiator_rsp_event_fixed_param  *fixed_params;
+
+	event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
+	fixed_params = event->fixed_param;
+
+	*rsp = qdf_mem_malloc(sizeof(**rsp));
+	if (!(*rsp)) {
+		WMI_LOGE("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	(*rsp)->vdev =
+		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
+						     fixed_params->vdev_id,
+						     WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	(*rsp)->transaction_id = fixed_params->transaction_id;
+	(*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
+	(*rsp)->status = fixed_params->rsp_status;
+	(*rsp)->reason = fixed_params->reason_code;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_indication_event **rsp)
+{
+	WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
+	wmi_ndp_indication_event_fixed_param *fixed_params;
+
+	event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
+	fixed_params =
+		(wmi_ndp_indication_event_fixed_param *)event->fixed_param;
+
+	*rsp = qdf_mem_malloc(sizeof(**rsp));
+	if (!(*rsp)) {
+		WMI_LOGE("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	(*rsp)->vdev =
+		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
+						     fixed_params->vdev_id,
+						     WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+	(*rsp)->service_instance_id = fixed_params->service_instance_id;
+	(*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
+	(*rsp)->role = fixed_params->self_ndp_role;
+	(*rsp)->policy = fixed_params->accept_policy;
+
+	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
+				(*rsp)->peer_mac_addr.bytes);
+	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
+				(*rsp)->peer_discovery_mac_addr.bytes);
+
+	WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
+		"service_instance %d, ndp_instance %d, role %d, policy %d,\n"
+		"csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
+		 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
+		 fixed_params->service_instance_id,
+		 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
+		 fixed_params->accept_policy,
+		 fixed_params->nan_csid, fixed_params->nan_scid_len,
+		 (*rsp)->peer_mac_addr.bytes,
+		 (*rsp)->peer_discovery_mac_addr.bytes);
+
+	WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   &event->ndp_cfg, fixed_params->ndp_cfg_len);
+
+	WMI_LOGD("ndp_app_info - %d bytes",
+			fixed_params->ndp_app_info_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			&event->ndp_app_info, fixed_params->ndp_app_info_len);
+
+	(*rsp)->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
+	(*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
+	(*rsp)->ncs_sk_type = fixed_params->nan_csid;
+	(*rsp)->scid.scid_len = fixed_params->nan_scid_len;
+	qdf_mem_copy((*rsp)->ndp_config.ndp_cfg, event->ndp_cfg,
+		     (*rsp)->ndp_config.ndp_cfg_len);
+	qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
+		     (*rsp)->ndp_info.ndp_app_info_len);
+	qdf_mem_copy((*rsp)->scid.scid, event->ndp_scid, (*rsp)->scid.scid_len);
+	WMI_LOGD("scid hex dump:");
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+			   (*rsp)->scid.scid, (*rsp)->scid.scid_len);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_confirm_event **rsp)
+{
+	WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
+	wmi_ndp_confirm_event_fixed_param *fixed_params;
+
+	event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
+	fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
+	WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) recieved. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
+		 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
+		 fixed_params->ndp_instance_id, fixed_params->rsp_code,
+		 fixed_params->reason_code,
+		 fixed_params->num_active_ndps_on_peer);
+	WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+		&event->ndp_cfg, fixed_params->ndp_cfg_len);
+
+	WMI_LOGD("ndp_app_info - %d bytes",
+			fixed_params->ndp_app_info_len);
+	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
+		&event->ndp_app_info, fixed_params->ndp_app_info_len);
+
+	*rsp = qdf_mem_malloc(sizeof(**rsp));
+	if (!(*rsp)) {
+		WMI_LOGE("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	(*rsp)->vdev =
+		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
+						     fixed_params->vdev_id,
+						     WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+	(*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
+	(*rsp)->rsp_code = fixed_params->rsp_code;
+	(*rsp)->reason_code = fixed_params->reason_code;
+	(*rsp)->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
+	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
+				   (*rsp)->peer_ndi_mac_addr.bytes);
+	(*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
+	qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
+		     (*rsp)->ndp_info.ndp_app_info_len);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_responder_rsp **rsp)
+{
+	WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
+	wmi_ndp_responder_rsp_event_fixed_param  *fixed_params;
+
+	event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
+	fixed_params = event->fixed_param;
+
+	WMI_LOGD("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: %pM,transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
+		 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
+		 (*rsp)->peer_mac_addr.bytes, (*rsp)->transaction_id,
+		 (*rsp)->status, (*rsp)->reason, (*rsp)->create_peer);
+
+	*rsp = qdf_mem_malloc(sizeof(**rsp));
+	if (!(*rsp)) {
+		WMI_LOGE("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	(*rsp)->vdev =
+		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
+						     fixed_params->vdev_id,
+						     WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+	(*rsp)->transaction_id = fixed_params->transaction_id;
+	(*rsp)->reason = fixed_params->reason_code;
+	(*rsp)->status = fixed_params->rsp_status;
+	(*rsp)->create_peer = fixed_params->create_peer;
+	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
+				(*rsp)->peer_mac_addr.bytes);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
+			uint8_t *data, struct nan_datapath_end_rsp_event **rsp)
+{
+	WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
+	wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
+
+	event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
+	fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
+	WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
+		 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
+		 fixed_params->rsp_status, fixed_params->reason_code);
+
+	*rsp = qdf_mem_malloc(sizeof(**rsp));
+	if (!(*rsp)) {
+		WMI_LOGE("malloc failed");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	(*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
+			wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+	(*rsp)->transaction_id = fixed_params->transaction_id;
+	(*rsp)->reason = fixed_params->reason_code;
+	(*rsp)->status = fixed_params->rsp_status;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
+		uint8_t *data, struct nan_datapath_end_indication_event **rsp)
+{
+	uint32_t i, buf_size;
+	wmi_ndp_end_indication *ind;
+	struct qdf_mac_addr peer_addr;
+	WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
+
+	event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
+	ind = event->ndp_end_indication_list;
+
+	if (event->num_ndp_end_indication_list == 0) {
+		WMI_LOGE("Error: Event ignored, 0 ndp instances");
+		return -EINVAL;
+	}
+
+	(*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
+			wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
+	if (!(*rsp)->vdev) {
+		WMI_LOGE("vdev is null");
+		qdf_mem_free(*rsp);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	WMI_LOGD("number of ndp instances = %d",
+		 event->num_ndp_end_indication_list);
+	buf_size = sizeof(*rsp) + event->num_ndp_end_indication_list *
+			sizeof((*rsp)->ndp_map[0]);
+	*rsp = qdf_mem_malloc(buf_size);
+	if (!(*rsp)) {
+		WMI_LOGE("Failed to allocate memory");
+		return -ENOMEM;
+	}
+
+	(*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
+	for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
+		WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
+					   peer_addr.bytes);
+		WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
+			 i, ind[i].type, ind[i].reason_code,
+			 ind[i].ndp_instance_id,
+			 ind[i].num_active_ndps_on_peer);
+		/* Add each instance entry to the list */
+		(*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
+		(*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
+		WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
+			(*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
+		(*rsp)->ndp_map[i].num_active_ndp_sessions =
+			ind[i].num_active_ndps_on_peer;
+		(*rsp)->ndp_map[i].type = ind[i].type;
+		(*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
 /**
  * save_service_bitmap_tlv() - save service bitmap
  * @wmi_handle: wmi handle
@@ -20607,6 +21198,17 @@ struct wmi_ops tlv_ops =  {
 	.send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
 #endif
 	.send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
+#ifdef WLAN_FEATURE_NAN_CONVERGENCE
+	.send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
+	.send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
+	.send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
+	.extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
+	.extract_ndp_ind = extract_ndp_ind_tlv,
+	.extract_ndp_confirm = extract_ndp_confirm_tlv,
+	.extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
+	.extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
+	.extract_ndp_end_ind = extract_ndp_end_ind_tlv,
+#endif
 };
 
 /**

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff