Răsfoiți Sursa

qcacmn: Add API to get and increment ref count of valid bss peer

wlan_vdev_get_bsspeer() return bss peer without taking the ref count
of the peer and thus if peer is deleted after wlan_vdev_get_bsspeer()
returns a valid peer, the caller will have stale entry of the peer.

Thus add an API to get the BSS peer and increment the refcount if
peer is valid. With this the peer won't be deleted till the caller
release the ref count of the peer.

Change-Id: Ifb3b4de54f3aace359a35a821265c80119df1f50
CRs-Fixed: 2444996
Abhishek Singh 6 ani în urmă
părinte
comite
7528ff39ce

+ 14 - 0
umac/cmn_services/obj_mgr/inc/wlan_objmgr_vdev_obj.h

@@ -1398,6 +1398,20 @@ static inline struct wlan_objmgr_peer *wlan_vdev_get_bsspeer(
 	return vdev->vdev_objmgr.bss_peer;
 }
 
+/**
+ * wlan_objmgr_vdev_try_get_bsspeer() - get and increment ref count of BSS peer
+ * of VDEV
+ * @vdev: VDEV object
+ * @id:   Object Manager ref debug id
+ *
+ * API to get and increment ref count of BSS peer of VDEV
+ *
+ * Return:
+ * @peer: BSS peer pointer if bss peer is present and valid else NULL
+ */
+struct wlan_objmgr_peer *wlan_objmgr_vdev_try_get_bsspeer(
+					struct wlan_objmgr_vdev *vdev,
+					wlan_objmgr_ref_dbgid id);
 /**
  * wlan_vdev_get_ospriv() - get os priv pointer
  * @vdev: VDEV object

+ 22 - 0
umac/cmn_services/obj_mgr/src/wlan_objmgr_vdev_obj.c

@@ -762,6 +762,28 @@ QDF_STATUS wlan_objmgr_vdev_peer_detach(struct wlan_objmgr_vdev *vdev,
 	return QDF_STATUS_SUCCESS;
 }
 
+struct wlan_objmgr_peer *wlan_objmgr_vdev_try_get_bsspeer(
+					struct wlan_objmgr_vdev *vdev,
+					wlan_objmgr_ref_dbgid id)
+{
+	struct wlan_objmgr_peer *peer;
+	QDF_STATUS status = QDF_STATUS_E_EMPTY;
+
+	if (!vdev)
+		return NULL;
+
+	wlan_vdev_obj_lock(vdev);
+	peer = wlan_vdev_get_bsspeer(vdev);
+	if (peer)
+		status = wlan_objmgr_peer_try_get_ref(peer, id);
+	wlan_vdev_obj_unlock(vdev);
+
+	if (QDF_IS_STATUS_SUCCESS(status))
+		return peer;
+
+	return NULL;
+}
+
 void *wlan_objmgr_vdev_get_comp_private_obj(
 		struct wlan_objmgr_vdev *vdev,
 		enum wlan_umac_comp_id id)