瀏覽代碼

qcacmn: Add an API to get peer using mac from vdev

Add an API that iterates through the peer_list of a vdev
and gets peer using peer mac address.

Change-Id: I9b7edd3816a51ee89d68be4cc876155fa1a79049
Pavankumar Nandeshwar 5 年之前
父節點
當前提交
0336eb937e

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

@@ -1155,6 +1155,22 @@ static inline struct wlan_objmgr_peer *wlan_vdev_get_bsspeer(
 	return vdev->vdev_objmgr.bss_peer;
 }
 
+/**
+ * wlan_objmgr_vdev_find_peer_by_mac() - get a peer with given mac from vdev
+ * @vdev: VDEV object
+ * @peer_mac: mac address of the peer to be found
+ * @dbg_id: dbg_id of the module
+ *
+ * API to get and increment ref count of BSS peer of VDEV
+ *
+ * Return:
+ * @peer: peer pointer to the peer of the mac address
+ */
+struct wlan_objmgr_peer *
+wlan_objmgr_vdev_find_peer_by_mac(struct wlan_objmgr_vdev *vdev,
+				  uint8_t *peer_mac,
+				  wlan_objmgr_ref_dbgid dbg_id);
+
 /**
  * wlan_objmgr_vdev_try_get_bsspeer() - get and increment ref count of BSS peer
  * of VDEV

+ 55 - 2
umac/cmn_services/obj_mgr/src/wlan_objmgr_vdev_obj.c

@@ -504,8 +504,8 @@ QDF_STATUS wlan_objmgr_iterate_peerobj_list(
 
 	if (vdev->obj_state != WLAN_OBJ_STATE_CREATED) {
 		wlan_vdev_obj_unlock(vdev);
-		obj_mgr_err("VDEV is not in create state(:%d): vdev-id:%d",
-				vdev_id, vdev->obj_state);
+		obj_mgr_err("VDEV is not in create state:%d: vdev-id:%d",
+			    vdev->obj_state, vdev_id);
 		return QDF_STATUS_E_FAILURE;
 	}
 	wlan_objmgr_vdev_get_ref(vdev, dbg_id);
@@ -530,6 +530,59 @@ QDF_STATUS wlan_objmgr_iterate_peerobj_list(
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ ** APIs to get a peer with given mac in a vdev
+ */
+struct wlan_objmgr_peer *
+wlan_objmgr_vdev_find_peer_by_mac(struct wlan_objmgr_vdev *vdev,
+				  uint8_t *peer_mac,
+				  wlan_objmgr_ref_dbgid dbg_id)
+{
+	qdf_list_t *peer_list;
+	struct wlan_objmgr_peer *peer = NULL;
+	struct wlan_objmgr_peer *peer_next = NULL;
+	uint8_t vdev_id;
+
+	if (!vdev) {
+		obj_mgr_err("VDEV is NULL");
+		return NULL;
+	}
+	wlan_vdev_obj_lock(vdev);
+	vdev_id = wlan_vdev_get_id(vdev);
+
+	if (vdev->obj_state != WLAN_OBJ_STATE_CREATED) {
+		wlan_vdev_obj_unlock(vdev);
+		obj_mgr_err("VDEV is not in create state:%d: vdev-id:%d",
+			    vdev->obj_state, vdev_id);
+		return NULL;
+	}
+	wlan_objmgr_vdev_get_ref(vdev, dbg_id);
+	peer_list = &vdev->vdev_objmgr.wlan_peer_list;
+	/* Iterate through VDEV's peer list */
+	peer = wlan_vdev_peer_list_peek_head(peer_list);
+	while (peer) {
+		peer_next = wlan_peer_get_next_peer_of_vdev(peer_list,
+							    peer);
+		if (wlan_objmgr_peer_try_get_ref(peer, dbg_id) ==
+						 QDF_STATUS_SUCCESS) {
+			if (!WLAN_ADDR_EQ(peer_mac,
+					  wlan_peer_get_macaddr(peer))) {
+				wlan_objmgr_vdev_release_ref(vdev,
+							     dbg_id);
+				wlan_vdev_obj_unlock(vdev);
+				return peer;
+			}
+			wlan_objmgr_peer_release_ref(peer, dbg_id);
+		}
+		peer = peer_next;
+	}
+	wlan_objmgr_vdev_release_ref(vdev, dbg_id);
+	wlan_vdev_obj_unlock(vdev);
+	return NULL;
+}
+
+qdf_export_symbol(wlan_objmgr_vdev_find_peer_by_mac);
+
 /**
  * wlan_obj_vdev_populate_logically_del_peerlist() - get peer
  * from vdev peer list