qcacld-3.0: Enable P2P component in CLD

P2P component related files moved from hostcmn to CLD, this change
adds initial functions, enables P2P in Kbuild.

Change-Id: I04102a5f3e59ded13ada15b1b417ae81c7a10e90
CRs-Fixed: 2361500
diff --git a/Kbuild b/Kbuild
index 4c87eaf..8383799 100644
--- a/Kbuild
+++ b/Kbuild
@@ -595,15 +595,13 @@
 ##########OS_IF #######
 OS_IF_DIR := $(WLAN_COMMON_ROOT)/os_if
 
-OS_IF_INC := -I$(WLAN_COMMON_INC)/os_if/linux \
+OS_IF_INC += -I$(WLAN_COMMON_INC)/os_if/linux \
             -I$(WLAN_COMMON_INC)/os_if/linux/scan/inc \
-            -I$(WLAN_COMMON_INC)/os_if/linux/p2p/inc \
             -I$(WLAN_COMMON_INC)/os_if/linux/spectral/inc \
             -I$(WLAN_COMMON_INC)/os_if/linux/tdls/inc \
             -I$(WLAN_COMMON_INC)/os_if/linux/crypto/inc
 
-OS_IF_OBJ := $(OS_IF_DIR)/linux/p2p/src/wlan_cfg80211_p2p.o \
-	     $(OS_IF_DIR)/linux/wlan_osif_request_manager.o \
+OS_IF_OBJ += $(OS_IF_DIR)/linux/wlan_osif_request_manager.o \
 	     $(OS_IF_DIR)/linux/crypto/src/wlan_nl_to_crypto_params.o
 
 ############ UMAC_DISP ############
@@ -955,22 +953,26 @@
 endif
 
 ############## UMAC P2P ###########
-P2P_DIR := umac/p2p
-P2P_CORE_DIR := $(P2P_DIR)/core
-P2P_CORE_SRC_DIR := $(P2P_CORE_DIR)/src
-P2P_CORE_OBJ_DIR := $(WLAN_COMMON_ROOT)/$(P2P_CORE_SRC_DIR)
+P2P_DIR := components/p2p
+P2P_CORE_OBJ_DIR := $(P2P_DIR)/core/src
 P2P_DISPATCHER_DIR := $(P2P_DIR)/dispatcher
 P2P_DISPATCHER_INC_DIR := $(P2P_DISPATCHER_DIR)/inc
-P2P_DISPATCHER_SRC_DIR := $(P2P_DISPATCHER_DIR)/src
-P2P_DISPATCHER_OBJ_DIR := $(WLAN_COMMON_ROOT)/$(P2P_DISPATCHER_SRC_DIR)
-UMAC_P2P_INC := -I$(WLAN_COMMON_INC)/$(P2P_DISPATCHER_INC_DIR) \
-		-I$(WLAN_COMMON_INC)/umac/scan/dispatcher/inc
-UMAC_P2P_OBJS := $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_ucfg_api.o \
-                 $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_tgt_api.o \
-                 $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_cfg.o \
-                 $(P2P_CORE_OBJ_DIR)/wlan_p2p_main.o \
-                 $(P2P_CORE_OBJ_DIR)/wlan_p2p_roc.o \
-                 $(P2P_CORE_OBJ_DIR)/wlan_p2p_off_chan_tx.o
+P2P_DISPATCHER_OBJ_DIR := $(P2P_DISPATCHER_DIR)/src
+P2P_OS_IF_INC := os_if/p2p/inc
+P2P_OS_IF_SRC := os_if/p2p/src
+P2P_TARGET_IF_INC := components/target_if/p2p/inc
+P2P_TARGET_IF_SRC := components/target_if/p2p/src
+P2P_INC := -I$(WLAN_ROOT)/$(P2P_DISPATCHER_INC_DIR) \
+	   -I$(WLAN_ROOT)/$(P2P_OS_IF_INC) \
+	   -I$(WLAN_ROOT)/$(P2P_TARGET_IF_INC)
+P2P_OBJS := $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_ucfg_api.o \
+	    $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_tgt_api.o \
+	    $(P2P_DISPATCHER_OBJ_DIR)/wlan_p2p_cfg.o \
+	    $(P2P_CORE_OBJ_DIR)/wlan_p2p_main.o \
+	    $(P2P_CORE_OBJ_DIR)/wlan_p2p_roc.o \
+	    $(P2P_CORE_OBJ_DIR)/wlan_p2p_off_chan_tx.o \
+	    $(P2P_OS_IF_SRC)/wlan_cfg80211_p2p.o \
+	    $(P2P_TARGET_IF_SRC)/target_if_p2p.o
 
 ###### UMAC POLICY MGR ########
 UMAC_POLICY_MGR_DIR := $(WLAN_COMMON_ROOT)/umac/cmn_services/policy_mgr
@@ -1019,12 +1021,10 @@
 TARGET_IF_INC := -I$(WLAN_COMMON_INC)/target_if/core/inc \
 		 -I$(WLAN_COMMON_INC)/target_if/core/src \
 		 -I$(WLAN_COMMON_INC)/target_if/init_deinit/inc \
-		 -I$(WLAN_COMMON_INC)/target_if/p2p/inc \
 		 -I$(WLAN_COMMON_INC)/target_if/regulatory/inc \
 		 -I$(WLAN_COMMON_INC)/target_if/tdls/inc
 
 TARGET_IF_OBJ := $(TARGET_IF_DIR)/core/src/target_if_main.o \
-		$(TARGET_IF_DIR)/p2p/src/target_if_p2p.o \
 		$(TARGET_IF_DIR)/regulatory/src/target_if_reg.o \
 		$(TARGET_IF_DIR)/tdls/src/target_if_tdls.o \
 		$(TARGET_IF_DIR)/init_deinit/src/init_cmd_api.o \
@@ -1702,7 +1702,7 @@
 INCS +=		$(UMAC_OBJMGR_INC)
 INCS +=		$(UMAC_MGMT_TXRX_INC)
 INCS +=		$(PMO_INC)
-INCS +=		$(UMAC_P2P_INC)
+INCS +=		$(P2P_INC)
 INCS +=		$(UMAC_POLICY_MGR_INC)
 INCS +=		$(TARGET_INC)
 INCS +=		$(UMAC_TDLS_INC)
@@ -1791,7 +1791,7 @@
 OBJS +=		$(UMAC_MGMT_TXRX_OBJS)
 OBJS +=		$(UMAC_TDLS_OBJS)
 OBJS +=		$(PMO_OBJS)
-OBJS +=		$(UMAC_P2P_OBJS)
+OBJS +=		$(P2P_OBJS)
 OBJS +=		$(UMAC_POLICY_MGR_OBJS)
 OBJS +=		$(WLAN_LOGGING_OBJS)
 OBJS +=		$(NLINK_OBJS)
diff --git a/components/p2p/core/src/wlan_p2p_main.h b/components/p2p/core/src/wlan_p2p_main.h
index 61921d9..2f5a5bc 100644
--- a/components/p2p/core/src/wlan_p2p_main.h
+++ b/components/p2p/core/src/wlan_p2p_main.h
@@ -29,6 +29,7 @@
 #include <qdf_list.h>
 #include <qdf_lock.h>
 #include <qdf_idr.h>
+#include <qdf_mc_timer.h>
 
 #define MAX_QUEUE_LENGTH 20
 #define P2P_NOA_ATTR_IND 0x1090
diff --git a/components/p2p/dispatcher/inc/wlan_p2p_tgt_api.h b/components/p2p/dispatcher/inc/wlan_p2p_tgt_api.h
index 0ca2074..f5938d6 100644
--- a/components/p2p/dispatcher/inc/wlan_p2p_tgt_api.h
+++ b/components/p2p/dispatcher/inc/wlan_p2p_tgt_api.h
@@ -33,6 +33,7 @@
 struct p2p_lo_event;
 struct mgmt_rx_event_params;
 enum mgmt_frame_type;
+struct p2p_set_mac_filter_evt;
 
 #ifdef FEATURE_P2P_LISTEN_OFFLOAD
 
diff --git a/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h b/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h
index da39720..4f1c4d3 100644
--- a/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h
+++ b/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h
@@ -34,6 +34,7 @@
 struct p2p_ps_config;
 struct p2p_lo_start;
 struct p2p_lo_event;
+struct p2p_protocol_callbacks;
 
 /**
  * p2p_rx_callback() - Callback for rx mgmt frame
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 6ff9c89..870a986 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -143,6 +143,7 @@
 #include "qc_sap_ioctl.h"
 #include "wlan_mlme_main.h"
 #include "wlan_p2p_cfg_api.h"
+#include "wlan_cfg80211_p2p.h"
 #include "wlan_tdls_cfg_api.h"
 #include <wlan_hdd_rssi_monitor.h>
 #include "wlan_mlme_ucfg_api.h"
@@ -13016,8 +13017,14 @@
 	if (QDF_IS_STATUS_ERROR(status))
 		goto action_oui_deinit;
 
+	status = ucfg_p2p_init();
+	if (QDF_IS_STATUS_ERROR(status))
+		goto nan_deinit;
+
 	return QDF_STATUS_SUCCESS;
 
+nan_deinit:
+	nan_deinit();
 action_oui_deinit:
 	ucfg_action_oui_deinit();
 ipa_deinit:
@@ -13046,6 +13053,7 @@
 static void hdd_component_deinit(void)
 {
 	/* deinitialize non-converged components */
+	ucfg_p2p_deinit();
 	nan_deinit();
 	ucfg_action_oui_deinit();
 	ipa_deinit();
@@ -13079,8 +13087,13 @@
 	if (QDF_IS_STATUS_ERROR(status))
 		goto err_plcy_mgr;
 
+	status = ucfg_p2p_psoc_open(psoc);
+	if (QDF_IS_STATUS_ERROR(status))
+		goto err_p2p;
 	return status;
 
+err_p2p:
+	ucfg_p2p_psoc_close(psoc);
 err_plcy_mgr:
 	ucfg_pmo_psoc_close(psoc);
 err_pmo:
@@ -13093,6 +13106,7 @@
 
 void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc)
 {
+	ucfg_p2p_psoc_close(psoc);
 	ucfg_policy_mgr_psoc_close(psoc);
 	ucfg_pmo_psoc_close(psoc);
 	ucfg_fwol_psoc_close(psoc);
@@ -13104,10 +13118,12 @@
 	ocb_psoc_enable(psoc);
 	disa_psoc_enable(psoc);
 	nan_psoc_enable(psoc);
+	p2p_psoc_enable(psoc);
 }
 
 void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc)
 {
+	p2p_psoc_disable(psoc);
 	nan_psoc_disable(psoc);
 	disa_psoc_disable(psoc);
 	ocb_psoc_disable(psoc);
diff --git a/os_if/p2p/inc/wlan_cfg80211_p2p.h b/os_if/p2p/inc/wlan_cfg80211_p2p.h
index 1c8484b..9e7a947 100644
--- a/os_if/p2p/inc/wlan_cfg80211_p2p.h
+++ b/os_if/p2p/inc/wlan_cfg80211_p2p.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
@@ -30,24 +30,24 @@
 struct ieee80211_channel;
 
 /**
- * wlan_p2p_start() - start p2p component
+ * p2p_psoc_enable() - psoc API to enable p2p component
  * @psoc: soc object
  *
- * This function used to start P2P component and register events.
+ * This function used to enable P2P component and register events.
  *
  * Return: QDF_STATUS_SUCCESS - in case of success
  */
-QDF_STATUS wlan_p2p_start(struct wlan_objmgr_psoc *psoc);
+QDF_STATUS p2p_psoc_enable(struct wlan_objmgr_psoc *psoc);
 
 /**
- * wlan_p2p_stop() - stop p2p component
+ * p2p_psoc_disable() - psoc API to disable p2p component
  * @psoc: soc object
  *
- * This function used to stop P2P component and unregister events.
+ * This function used to disable P2P component and unregister events.
  *
  * Return: QDF_STATUS_SUCCESS - in case of success
  */
-QDF_STATUS wlan_p2p_stop(struct wlan_objmgr_psoc *psoc);
+QDF_STATUS p2p_psoc_disable(struct wlan_objmgr_psoc *psoc);
 
 /**
  * wlan_cfg80211_roc() - API to process cfg80211 roc request
diff --git a/os_if/p2p/src/wlan_cfg80211_p2p.c b/os_if/p2p/src/wlan_cfg80211_p2p.c
index e4911ae..009b3e8 100644
--- a/os_if/p2p/src/wlan_cfg80211_p2p.c
+++ b/os_if/p2p/src/wlan_cfg80211_p2p.c
@@ -319,7 +319,7 @@
 	wlan_objmgr_vdev_release_ref(vdev, WLAN_P2P_ID);
 }
 
-QDF_STATUS wlan_p2p_start(struct wlan_objmgr_psoc *psoc)
+QDF_STATUS p2p_psoc_enable(struct wlan_objmgr_psoc *psoc)
 {
 	struct p2p_start_param start_param;
 
@@ -339,7 +339,7 @@
 	return ucfg_p2p_psoc_start(psoc, &start_param);
 }
 
-QDF_STATUS wlan_p2p_stop(struct wlan_objmgr_psoc *psoc)
+QDF_STATUS p2p_psoc_disable(struct wlan_objmgr_psoc *psoc)
 {
 	if (!psoc) {
 		cfg80211_err("psoc null");