Эх сурвалжийг харах

qcacld-3.0: Add peer create/destroy notification support in DP component

Add peer create/destroy notification support in DP component, so that
DP component gets notified for obj mgr peer creation/destroy.
DP component can use this notifications for its own
peer info maintenance.

Change-Id: I5277a986967c88619b7644d633d84a9bafc9bfbc
CRs-Fixed: 3173476
Karthik Kantamneni 3 жил өмнө
parent
commit
b5d890bd89

+ 24 - 0
components/dp/core/inc/wlan_dp_main.h

@@ -134,6 +134,30 @@ struct wlan_dp_intf*
 dp_get_intf_by_macaddr(struct wlan_dp_psoc_context *dp_ctx,
 		       struct qdf_mac_addr *addr);
 
+/**
+ * dp_peer_obj_create_notification(): dp peer create handler
+ * @peer: peer which is going to created by objmgr
+ * @arg: argument for vdev create handler
+ *
+ * Register this api with objmgr to detect peer is created
+ *
+ * Return: QDF_STATUS status in case of success else return error
+ */
+QDF_STATUS
+dp_peer_obj_create_notification(struct wlan_objmgr_peer *peer, void *arg);
+
+/**
+ * dp_peer_obj_destroy_notification(): dp peer delete handler
+ * @peer: peer which is going to delete by objmgr
+ * @arg: argument for vdev delete handler
+ *
+ * Register this api with objmgr to detect peer is deleted
+ *
+ * Return: QDF_STATUS status in case of success else return error
+ */
+QDF_STATUS
+dp_peer_obj_destroy_notification(struct wlan_objmgr_peer *peer, void *arg);
+
 /**
  * dp_vdev_obj_destroy_notification() - Free per DP vdev object
  * @vdev: vdev context

+ 20 - 0
components/dp/core/inc/wlan_dp_objmgr.h

@@ -43,6 +43,26 @@
 #define dp_comp_psoc_get_ref(psoc) wlan_objmgr_psoc_try_get_ref(psoc, WLAN_DP_ID)
 #define dp_comp_psoc_put_ref(psoc) wlan_objmgr_psoc_release_ref(psoc, WLAN_DP_ID)
 
+/**
+ * dp_get_peer_priv_obj: get DP priv object from peer object
+ * @peer: pointer to peer object
+ *
+ * Return: pointer to DP peer private object
+ */
+static inline struct wlan_dp_sta_info *
+dp_get_peer_priv_obj(struct wlan_objmgr_peer *peer)
+{
+	struct wlan_dp_sta_info *peer_info;
+
+	peer_info = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_COMP_DP);
+	if (!peer_info) {
+		dp_err("peer is null");
+		return NULL;
+	}
+
+	return peer_info;
+}
+
 /**
  * dp_get_vdev_priv_obj() - Wrapper to retrieve vdev priv obj
  * @vdev: vdev pointer

+ 52 - 0
components/dp/core/src/wlan_dp_main.c

@@ -760,6 +760,58 @@ void dp_mic_init_work(struct wlan_dp_intf *dp_intf)
 	dp_intf->mic_work.info = NULL;
 }
 
+QDF_STATUS
+dp_peer_obj_create_notification(struct wlan_objmgr_peer *peer, void *arg)
+{
+	struct wlan_dp_sta_info *sta_info;
+	QDF_STATUS status;
+
+	sta_info = qdf_mem_malloc(sizeof(*sta_info));
+	if (!sta_info)
+		return QDF_STATUS_E_NOMEM;
+
+	status = wlan_objmgr_peer_component_obj_attach(peer, WLAN_COMP_DP,
+						       sta_info,
+						       QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		dp_err("DP peer attach failed");
+		qdf_mem_free(sta_info);
+	}
+
+	qdf_mem_copy(sta_info->sta_mac.bytes, peer->macaddr,
+		     QDF_MAC_ADDR_SIZE);
+	sta_info->pending_eap_frm_type = 0;
+	sta_info->dhcp_phase = DHCP_PHASE_ACK;
+	sta_info->dhcp_nego_status = DHCP_NEGO_STOP;
+
+	dp_info("sta info crated mac:" QDF_MAC_ADDR_FMT,
+		       QDF_MAC_ADDR_REF(&sta_info->sta_mac));
+
+	return status;
+}
+
+QDF_STATUS
+dp_peer_obj_destroy_notification(struct wlan_objmgr_peer *peer, void *arg)
+{
+	struct wlan_dp_sta_info *sta_info;
+	QDF_STATUS status;
+
+	sta_info = dp_get_peer_priv_obj(peer);
+	if (!sta_info) {
+		dp_err("DP_peer_obj is NULL");
+		return QDF_STATUS_E_FAULT;
+	}
+
+	status = wlan_objmgr_peer_component_obj_detach(peer, WLAN_COMP_DP,
+						       sta_info);
+	if (QDF_IS_STATUS_ERROR(status))
+		dp_err("DP peer detach failed");
+
+	qdf_mem_free(sta_info);
+
+	return status;
+}
+
 QDF_STATUS
 dp_vdev_obj_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
 {

+ 41 - 1
components/dp/dispatcher/src/wlan_dp_ucfg_api.c

@@ -179,7 +179,33 @@ QDF_STATUS ucfg_dp_init(void)
 		dp_err("Failed to register vdev destroy handler");
 		goto fail_destroy_vdev;
 	}
-	return status;
+
+	status = wlan_objmgr_register_peer_create_handler(
+		WLAN_COMP_DP,
+		dp_peer_obj_create_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		dp_err("wlan_objmgr_register_peer_create_handler failed");
+		goto fail_create_peer;
+	}
+
+	status = wlan_objmgr_register_peer_destroy_handler(
+		WLAN_COMP_DP,
+		dp_peer_obj_destroy_notification,
+		NULL);
+	if (QDF_IS_STATUS_ERROR(status))
+		dp_err("wlan_objmgr_register_peer_destroy_handler failed");
+	else
+		return QDF_STATUS_SUCCESS;
+
+	wlan_objmgr_unregister_peer_create_handler(WLAN_COMP_DP,
+					dp_peer_obj_create_notification,
+					NULL);
+
+fail_create_peer:
+	wlan_objmgr_unregister_vdev_destroy_handler(WLAN_COMP_DP,
+					dp_vdev_obj_destroy_notification,
+					NULL);
 
 fail_destroy_vdev:
 	wlan_objmgr_unregister_vdev_create_handler(
@@ -215,6 +241,20 @@ QDF_STATUS ucfg_dp_deinit(void)
 
 	dp_info("DP module dispatcher deinit");
 
+	/* de-register peer delete handler functions. */
+	status = wlan_objmgr_unregister_peer_destroy_handler(
+				WLAN_COMP_DP,
+				dp_peer_obj_destroy_notification, NULL);
+	if (QDF_IS_STATUS_ERROR(status))
+		dp_err("Failed to unregister DP peer destroy handler: %d", status);
+
+	/* de-register peer create handler functions. */
+	status = wlan_objmgr_unregister_peer_create_handler(
+				WLAN_COMP_DP,
+				dp_peer_obj_create_notification, NULL);
+	if (QDF_IS_STATUS_ERROR(status))
+		dp_err("Failed to unregister DP peer create handler: %d", status);
+
 	status = wlan_objmgr_unregister_vdev_destroy_handler(
 				WLAN_COMP_DP,
 				dp_vdev_obj_destroy_notification,