Browse Source

qcacld-3.0: add wds mode sysfs functionality

Add support to configure wds_mode.

Change-Id: I19b7c797083a75d2aebf53d574484def5a4ec9e1
CRs-Fixed: 3563193
Bing Sun 1 year ago
parent
commit
25f5c0058e

+ 5 - 0
Kbuild

@@ -467,6 +467,10 @@ ifeq ($(CONFIG_WLAN_SYSFS_DFSNOL), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dfsnol.o
 endif
 
+ifeq ($(CONFIG_WLAN_SYSFS_WDS_MODE), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_wds_mode.o
+endif
+
 endif # CONFIG_WLAN_SYSFS
 
 ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
@@ -3649,6 +3653,7 @@ ccflags-$(CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM) += -DWLAN_PDEV_VDEV_SEND_MULTI
 ccflags-$(CONFIG_WLAN_SYSFS_LOG_BUFFER) += -DFEATURE_SYSFS_LOG_BUFFER
 ccflags-$(CONFIG_ENABLE_VALLOC_REPLACE_MALLOC) += -DENABLE_VALLOC_REPLACE_MALLOC
 ccflags-$(CONFIG_WLAN_SYSFS_DFSNOL) += -DCONFIG_WLAN_SYSFS_DFSNOL
+ccflags-$(CONFIG_WLAN_SYSFS_WDS_MODE) += -DFEATURE_SYSFS_WDS_MODE
 
 ifeq ($(CONFIG_LEAK_DETECTION), y)
 ccflags-y += \

+ 15 - 0
components/mlme/dispatcher/inc/wlan_mlme_api.h

@@ -3957,12 +3957,27 @@ bool wlan_mlme_is_multipass_sap(struct wlan_objmgr_psoc *psoc);
  */
 enum wlan_wds_mode
 wlan_mlme_get_wds_mode(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_mlme_set_wds_mode() - Set wds mode
+ * @psoc: pointer to psoc object
+ * @mode: wds mode to set
+ *
+ * Return: void
+ */
+void wlan_mlme_set_wds_mode(struct wlan_objmgr_psoc *psoc,
+			    enum wlan_wds_mode mode);
 #else
 static inline enum wlan_wds_mode
 wlan_mlme_get_wds_mode(struct wlan_objmgr_psoc *psoc)
 {
 	return WLAN_WDS_MODE_DISABLED;
 }
+
+static inline void wlan_mlme_set_wds_mode(struct wlan_objmgr_psoc *psoc,
+					  enum wlan_wds_mode mode)
+{
+}
 #endif
 
 #ifdef WLAN_SUPPORT_TWT

+ 13 - 0
components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h

@@ -5003,6 +5003,19 @@ ucfg_mlme_get_wds_mode(struct wlan_objmgr_psoc *psoc)
 	return wlan_mlme_get_wds_mode(psoc);
 }
 
+/**
+ * ucfg_mlme_set_wds_mode() - Set the configured WDS mode
+ * @psoc: pointer to psoc object
+ * @mode: wds mode to set
+ *
+ * Return: void
+ */
+static inline void
+ucfg_mlme_set_wds_mode(struct wlan_objmgr_psoc *psoc, uint32_t mode)
+{
+	wlan_mlme_set_wds_mode(psoc, mode);
+}
+
 #ifdef WLAN_FEATURE_SON
 /**
  * ucfg_mlme_get_vdev_max_mcs_idx() - Get max mcs idx of given vdev

+ 12 - 0
components/mlme/dispatcher/src/wlan_mlme_api.c

@@ -6112,6 +6112,18 @@ wlan_mlme_get_wds_mode(struct wlan_objmgr_psoc *psoc)
 
 	return mlme_obj->cfg.gen.wds_mode;
 }
+
+void wlan_mlme_set_wds_mode(struct wlan_objmgr_psoc *psoc,
+			    enum wlan_wds_mode mode)
+{
+	struct wlan_mlme_psoc_ext_obj *mlme_obj;
+
+	mlme_obj = mlme_get_psoc_ext_obj(psoc);
+	if (!mlme_obj)
+		return;
+	if (mode <= WLAN_WDS_MODE_MAX)
+		mlme_obj->cfg.gen.wds_mode = mode;
+}
 #endif
 
 bool wlan_mlme_is_sta_mon_conc_supported(struct wlan_objmgr_psoc *psoc)

+ 4 - 0
configs/config_to_feature.h

@@ -916,6 +916,10 @@
 #define WLAN_SYSFS_EHT_RATE (1)
 #endif
 
+#ifdef CONFIG_WLAN_SYSFS_WDS_MODE
+#define FEATURE_SYSFS_WDS_MODE (1)
+#endif
+
 #ifdef CONFIG_RX_PERFORMANCE
 #define RX_PERFORMANCE (1)
 #endif

+ 1 - 0
configs/default_defconfig

@@ -409,6 +409,7 @@ endif
 	CONFIG_DP_PKT_ADD_TIMESTAMP := y
 	CONFIG_WLAN_SYSFS_LOG_BUFFER := y
 	CONFIG_WLAN_SYSFS_DFSNOL := y
+	CONFIG_WLAN_SYSFS_WDS_MODE := y
 endif
 CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM := y
 CONFIG_WLAN_POWER_DEBUG := y

+ 3 - 0
core/hdd/src/wlan_hdd_sysfs.c

@@ -92,6 +92,7 @@
 #include <wlan_hdd_sysfs_runtime_pm.h>
 #include <wlan_hdd_sysfs_log_buffer.h>
 #include <wlan_hdd_sysfs_dfsnol.h>
+#include <wlan_hdd_sysfs_wds_mode.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -957,12 +958,14 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
 		hdd_sysfs_dp_pkt_add_ts_create(driver_kobject);
 		hdd_sysfs_runtime_pm_create(driver_kobject);
 		hdd_sysfs_log_buffer_create(driver_kobject);
+		hdd_sysfs_wds_mode_create(driver_kobject);
 	}
 }
 
 void hdd_destroy_sysfs_files(void)
 {
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
+		hdd_sysfs_wds_mode_destroy(driver_kobject);
 		hdd_sysfs_log_buffer_destroy(driver_kobject);
 		hdd_sysfs_runtime_pm_destroy(driver_kobject);
 		hdd_sysfs_dp_pkt_add_ts_destroy(driver_kobject);

+ 147 - 0
core/hdd/src/wlan_hdd_sysfs_wds_mode.c

@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2023 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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_psoc_sync.h"
+#include <wlan_hdd_sysfs.h>
+#include <wlan_hdd_sysfs_wds_mode.h>
+
+static ssize_t __hdd_sysfs_wds_mode_show(struct hdd_context *hdd_ctx,
+					 struct kobj_attribute *attr,
+					 char *buf)
+{
+	int ret = 0;
+
+	if (!hdd_ctx || !hdd_ctx->psoc) {
+		hdd_err_rl("invalid input");
+		return ret;
+	}
+
+	ret = scnprintf(buf, PAGE_SIZE, "%d",
+			ucfg_mlme_get_wds_mode(hdd_ctx->psoc));
+
+	return ret;
+}
+
+static ssize_t hdd_sysfs_wds_mode_show(struct kobject *kobj,
+				       struct kobj_attribute *attr,
+				       char *buf)
+{
+	struct osif_psoc_sync *psoc_sync;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	ssize_t errno_size;
+
+	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					     &psoc_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_wds_mode_show(hdd_ctx, attr, buf);
+
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return errno_size;
+}
+
+static ssize_t
+__hdd_sysfs_wds_mode_store(struct hdd_context *hdd_ctx,
+			   struct kobj_attribute *attr, const char *buf,
+			   size_t count)
+{
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	char *sptr, *token;
+	uint32_t value;
+	int ret = 0;
+
+	if (!hdd_ctx || !hdd_ctx->psoc) {
+		hdd_err_rl("invalid hdd ctx");
+		return ret;
+	}
+
+	ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
+					      buf, count);
+
+	if (ret) {
+		hdd_err_rl("invalid input");
+		return ret;
+	}
+
+	sptr = buf_local;
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou32(token, 0, &value))
+		return -EINVAL;
+
+	hdd_debug("wds_mode: %d", value);
+
+	ucfg_mlme_set_wds_mode(hdd_ctx->psoc, value);
+
+	return count;
+}
+
+static ssize_t
+hdd_sysfs_wds_mode_store(struct kobject *kobj,
+			 struct kobj_attribute *attr,
+			 char const *buf, size_t count)
+{
+	struct osif_psoc_sync *psoc_sync;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	ssize_t errno_size;
+
+	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					     &psoc_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_wds_mode_store(hdd_ctx, attr,
+						buf, count);
+
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return errno_size;
+}
+
+static struct kobj_attribute wds_mode_attribute =
+	__ATTR(wds_mode, 0664, hdd_sysfs_wds_mode_show,
+	       hdd_sysfs_wds_mode_store);
+
+int hdd_sysfs_wds_mode_create(struct kobject *driver_kobject)
+{
+	int error;
+
+	if (!driver_kobject) {
+		hdd_err("could not get driver kobject!");
+		return -EINVAL;
+	}
+
+	error = sysfs_create_file(driver_kobject,
+				  &wds_mode_attribute.attr);
+	if (error)
+		hdd_err("could not create wds_mode sysfs file");
+
+	return error;
+}
+
+void
+hdd_sysfs_wds_mode_destroy(struct kobject *driver_kobject)
+{
+	if (!driver_kobject) {
+		hdd_err("could not get driver kobject!");
+		return;
+	}
+	sysfs_remove_file(driver_kobject, &wds_mode_attribute.attr);
+}

+ 58 - 0
core/hdd/src/wlan_hdd_sysfs_wds_mode.h

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _WLAN_HDD_SYSFS_WDS_MODE_H
+#define _WLAN_HDD_SYSFS_WDS_MODE_H
+
+#if defined(WLAN_SYSFS) && defined(FEATURE_SYSFS_WDS_MODE)
+
+/**
+ * hdd_sysfs_wds_mode_create() - API to create wds mode sysfs file
+ * @driver_kobject: sysfs driver kobject
+ *
+ * file path: /sys/kernel/kiwi_v2/wds_mode
+ *
+ * usage:
+ *      echo [arg_0] > wds_mode
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_wds_mode_create(struct kobject *driver_kobject);
+
+/**
+ * hdd_sysfs_wds_mode_destroy() - destroy hdd wds mode sysfs node
+ * @driver_kobject: pointer to driver kobject
+ *
+ * Return: void
+ *
+ */
+void
+hdd_sysfs_wds_mode_destroy(struct kobject *driver_kobject);
+
+#else
+
+static inline int
+hdd_sysfs_wds_mode_create(struct kobject *driver_kobject)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_wds_mode_destroy(struct kobject *driver_kobject)
+{
+}
+#endif
+#endif

+ 2 - 1
core/wma/src/wma_main.c

@@ -294,7 +294,8 @@ static void wma_update_num_peers_tids(t_wma_handle *wma_handle,
 static void wma_set_peer_map_unmap_v2_config(struct wlan_objmgr_psoc *psoc,
 					     target_resource_config *tgt_cfg)
 {
-	tgt_cfg->peer_map_unmap_v2 = cfg_get(psoc, CFG_WDS_MODE) ? true : false;
+	tgt_cfg->peer_map_unmap_v2 =
+			wlan_mlme_get_wds_mode(psoc) ? true : false;
 }
 #else
 static void wma_set_peer_map_unmap_v2_config(struct wlan_objmgr_psoc *psoc,

+ 5 - 0
wlan_qcacld3_modules.bzl

@@ -1867,6 +1867,11 @@ _conditional_srcs = {
             "core/hdd/src/wlan_hdd_sysfs_dfsnol.c",
         ],
     },
+    "CONFIG_WLAN_SYSFS_WDS_MODE": {
+        True: [
+            "core/hdd/src/wlan_hdd_sysfs_wds_mode.c",
+        ],
+    },
     "CONFIG_WLAN_SYSFS_DP_STATS": {
         True: [
             "core/hdd/src/wlan_hdd_sysfs_txrx_stats_console.c",