소스 검색

qcacmn: Add API to iterate over ML vdev list and call custom handler

Add API to iterate over ML vdev list and call custom handler

Change-Id: Ie5c16b085528eed64436c26d0ca9700700a86949
Himanshu Batra 3 년 전
부모
커밋
aab941747a
1개의 변경된 파일58개의 추가작업 그리고 1개의 파일을 삭제
  1. 58 1
      umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h

+ 58 - 1
umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. 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 above
@@ -24,6 +24,7 @@
 #include <qdf_types.h>
 #include <qdf_trace.h>
 #include "wlan_mlo_mgr_public_structs.h"
+#include <wlan_mlo_mgr_main.h>
 
 #define mlo_alert(format, args...) \
 		QDF_TRACE_FATAL(QDF_MODULE_ID_MLO, format, ## args)
@@ -332,5 +333,61 @@ mlo_process_link_set_active_resp(struct wlan_objmgr_psoc *psoc,
  * Return: QDF_STATUS
  */
 QDF_STATUS mlo_ser_set_link_req(struct mlo_link_set_active_req *req);
+
+/*
+ * API to have operation on ml vdevs
+ */
+typedef void (*mlo_vdev_ops_handler)(struct wlan_objmgr_vdev *vdev,
+				     void *arg);
+
+/*
+ * mlo_iterate_ml_vdev_list: Iterate on ML vdevs of MLD
+ *
+ * @vdev: vdev object
+ * @handler: the handler will be called for each object in ML list
+ * @arg: argument to be passed to handler
+ * @lock: Need to acquire lock or not
+ *
+ * Return: none
+ */
+static inline
+void mlo_iterate_ml_vdev_list(struct wlan_objmgr_vdev *vdev,
+			      mlo_vdev_ops_handler handler,
+			      void *arg, bool lock)
+{
+	struct wlan_mlo_dev_context *mlo_dev_ctx = NULL;
+	uint8_t i = 0;
+	QDF_STATUS status;
+
+	if (!vdev)
+		return;
+
+	mlo_dev_ctx = vdev->mlo_dev_ctx;
+	if (!mlo_dev_ctx || !(wlan_vdev_mlme_is_mlo_vdev(vdev)))
+		return;
+
+	if (lock)
+		mlo_dev_lock_acquire(mlo_dev_ctx);
+
+	for (i =  0; i < WLAN_UMAC_MLO_MAX_VDEVS; i++) {
+		if (!mlo_dev_ctx->wlan_vdev_list[i])
+			continue;
+
+		status = wlan_objmgr_vdev_try_get_ref(
+					mlo_dev_ctx->wlan_vdev_list[i],
+					WLAN_MLO_MGR_ID);
+		if (QDF_IS_STATUS_ERROR(status))
+			continue;
+
+		if (handler)
+			handler(mlo_dev_ctx->wlan_vdev_list[i], arg);
+
+		mlo_release_vdev_ref(mlo_dev_ctx->wlan_vdev_list[i]);
+	}
+
+	if (lock)
+		mlo_dev_lock_release(mlo_dev_ctx);
+}
+
 #endif
 #endif