Selaa lähdekoodia

qcacld-3.0: Provide LP/VLP/SP valid freq list for curr country code

Add support to provide valid frequency list for provided power mode

Change-Id: I5855258402604c5ca20b9f0a3eaebe7412b7db4b
CRs-Fixed: 3103671
sheenam monga 3 vuotta sitten
vanhempi
sitoutus
8261fe17ac

+ 5 - 1
Kbuild

@@ -120,7 +120,7 @@ HDD_OBJS := 	$(HDD_SRC_DIR)/wlan_hdd_assoc.o \
 		$(HDD_SRC_DIR)/wlan_hdd_trace.o \
 		$(HDD_SRC_DIR)/wlan_hdd_tx_rx.o \
 		$(HDD_SRC_DIR)/wlan_hdd_wmm.o \
-		$(HDD_SRC_DIR)/wlan_hdd_wowl.o
+		$(HDD_SRC_DIR)/wlan_hdd_wowl.o\
 
 ifeq ($(CONFIG_WLAN_FEATURE_PERIODIC_STA_STATS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_periodic_sta_stats.o
@@ -415,6 +415,9 @@ endif
 ifeq ($(CONFIG_WLAN_BMISS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_bmiss.o
 endif
+ifeq ($(CONFIG_WLAN_FREQ_LIST), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_get_freq_for_pwr.o
+endif
 endif
 ifeq ($(CONFIG_WLAN_SYSFS_DP_STATS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_txrx_stats_console.o
@@ -3134,6 +3137,7 @@ cppflags-$(CONFIG_WLAN_THERMAL_MULTI_CLIENT_SUPPORT) += -DFEATURE_WPSS_THERMAL_M
 cppflags-$(CONFIG_WLAN_DUMP_IN_PROGRESS) += -DCONFIG_WLAN_DUMP_IN_PROGRESS
 cppflags-$(CONFIG_WLAN_BMISS) += -DCONFIG_WLAN_BMISS
 cppflags-$(CONFIG_WLAN_SYSFS_DP_STATS) += -DWLAN_SYSFS_DP_STATS
+cppflags-$(CONFIG_WLAN_FREQ_LIST) += -DCONFIG_WLAN_FREQ_LIST
 
 cppflags-$(CONFIG_WIFI_MONITOR_SUPPORT) += -DWIFI_MONITOR_SUPPORT
 cppflags-$(CONFIG_QCA_MONITOR_PKT_SUPPORT) += -DQCA_MONITOR_PKT_SUPPORT

+ 1 - 0
configs/default_defconfig

@@ -334,6 +334,7 @@ endif
 	CONFIG_WLAN_DL_MODES := y
 	CONFIG_WLAN_DUMP_IN_PROGRESS := y
 	CONFIG_WLAN_BMISS := y
+	CONFIG_WLAN_FREQ_LIST := y
 endif
 
 CONFIG_WLAN_POWER_DEBUG := y

+ 3 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -2318,6 +2318,9 @@ struct hdd_context {
 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
 	bool is_vdev_macaddr_dynamic_update_supported;
 #endif
+#ifdef CONFIG_WLAN_FREQ_LIST
+	uint8_t power_type;
+#endif
 };
 
 /**

+ 4 - 1
core/hdd/src/wlan_hdd_sysfs.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 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 copyright notice and this permission notice appear in all
@@ -81,6 +81,7 @@
 #include "wma_api.h"
 #include "wlan_hdd_eht.h"
 #include <wlan_hdd_sysfs_bmiss.h>
+#include <wlan_hdd_sysfs_get_freq_for_pwr.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -854,12 +855,14 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
 		hdd_sysfs_dp_swlm_create(driver_kobject);
 		hdd_sysfs_create_wakeup_logs_to_console();
 		hdd_sysfs_dp_txrx_stats_sysfs_create(driver_kobject);
+		hdd_sysfs_get_valid_freq_for_power_create(driver_kobject);
 	}
 }
 
 void hdd_destroy_sysfs_files(void)
 {
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
+		hdd_sysfs_get_valid_freq_for_power_destroy(driver_kobject);
 		hdd_sysfs_dp_txrx_stats_sysfs_destroy(driver_kobject);
 		hdd_sysfs_destroy_wakeup_logs_to_console();
 		hdd_sysfs_dp_swlm_destroy(driver_kobject);

+ 181 - 0
core/hdd/src/wlan_hdd_sysfs_get_freq_for_pwr.c

@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 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
+ * 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.
+ */
+
+/**
+ * DOC: wlan_hdd_sysfs_get_freq_for_pwr.c
+ *
+ * implementation for creating sysfs file valid_freq
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include <wlan_hdd_sysfs.h>
+#include "wlan_hdd_sysfs_get_freq_for_pwr.h"
+#include "osif_psoc_sync.h"
+#include "reg_services_public_struct.h"
+#include <wma_api.h>
+
+static ssize_t
+__hdd_sysfs_power_level_store(struct hdd_context *hdd_ctx,
+			      char const *buf, size_t count)
+{
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	char *sptr, *token;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(hdd_ctx))
+		return -EINVAL;
+
+	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 (!strncasecmp(token, "VLP", strlen("VLP")))
+		hdd_ctx->power_type = REG_VERY_LOW_POWER_AP;
+	else if (!strncasecmp(token, "LP", strlen("LP")))
+		hdd_ctx->power_type = REG_INDOOR_AP;
+	else if (!strncasecmp(token, "SP", strlen("SP")))
+		hdd_ctx->power_type = REG_STANDARD_POWER_AP;
+	else
+		hdd_ctx->power_type = REG_MAX_SUPP_AP_TYPE;
+
+	hdd_debug("power level %s(%d)", token,
+		  hdd_ctx->power_type);
+
+	return count;
+}
+
+static ssize_t
+wlan_hdd_sysfs_power_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 err_size;
+
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return 0;
+
+	err_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					   &psoc_sync);
+	if (err_size)
+		return err_size;
+
+	err_size = __hdd_sysfs_power_level_store(hdd_ctx, buf, count);
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return err_size;
+}
+
+static ssize_t
+__wlan_hdd_sysfs_freq_show(struct hdd_context *hdd_ctx,
+			   struct kobj_attribute *attr, char *buf)
+{
+	int ret = 0;
+	struct regulatory_channel chan_list[NUM_6GHZ_CHANNELS];
+	QDF_STATUS status;
+	uint32_t i;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(hdd_ctx))
+		return -EINVAL;
+
+	ret = scnprintf(buf, PAGE_SIZE, "freq list for power type %s\n",
+			wlan_reg_get_power_string(hdd_ctx->power_type));
+
+	if (!strcmp(wlan_reg_get_power_string(hdd_ctx->power_type), "INVALID"))
+		return -EINVAL;
+
+	status = wlan_reg_get_6g_ap_master_chan_list(
+						hdd_ctx->pdev,
+						hdd_ctx->power_type,
+						chan_list);
+
+	for (i = 0; i < NUM_6GHZ_CHANNELS; i++) {
+		if ((chan_list[i].state != CHANNEL_STATE_DISABLE) &&
+		    !(chan_list[i].chan_flags & REGULATORY_CHAN_DISABLED)) {
+			if ((PAGE_SIZE - ret) <= 0)
+				return ret;
+			ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+					"%d  ", chan_list[i].center_freq);
+		}
+	}
+	return ret;
+}
+
+static ssize_t wlan_hdd_sysfs_freq_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 err_size;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
+
+	err_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					   &psoc_sync);
+	if (err_size)
+		return err_size;
+
+	err_size = __wlan_hdd_sysfs_freq_show(hdd_ctx, attr, buf);
+
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return err_size;
+}
+
+static struct kobj_attribute valid_freq_attribute =
+__ATTR(valid_freq, 0664, wlan_hdd_sysfs_freq_show, wlan_hdd_sysfs_power_store);
+
+int hdd_sysfs_get_valid_freq_for_power_create(struct kobject *driver_kobject)
+{
+	int error;
+
+	error = sysfs_create_file(driver_kobject, &valid_freq_attribute.attr);
+	if (error)
+		hdd_err("could not create valid_freq sysfs file");
+
+	return error;
+}
+
+void
+hdd_sysfs_get_valid_freq_for_power_destroy(struct kobject *driver_kobject)
+{
+	if (!driver_kobject) {
+		hdd_err("could not get driver kobject!");
+		return;
+	}
+	sysfs_remove_file(driver_kobject, &valid_freq_attribute.attr);
+}

+ 61 - 0
core/hdd/src/wlan_hdd_sysfs_get_freq_for_pwr.h

@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 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 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.
+ */
+
+/**
+ * DOC: wlan_hdd_sysfs_get_freq_for_pwr.h
+ *
+ * implementation for creating sysfs file valid_freq that contains
+ * valid freq list for provided power type
+ */
+#ifndef _WLAN_HDD_SYSFS_FREQ_FOR_PWR_H
+#define _WLAN_HDD_SYSFS_FREQ_FOR_PWR_H
+#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_FREQ_LIST)
+/**
+ * hdd_sysfs_get_valid_freq_for_power_create() - API to create get_valid_freq
+ * @driver_kobject: sysfs driver kobject
+ *
+ * file path: /sys/kernel/wifi/valid_freq
+ *
+ * usage:
+ *      echo "VLP"/"LP"/"SP" > valid_freq
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_get_valid_freq_for_power_create(struct kobject *driver_kobject);
+
+/**
+ * hdd_sysfs_get_valid_freq_for_power_destroy() -
+ * API to destroy get_valid_freq sysfs
+ *
+ * Return: none
+ */
+void
+hdd_sysfs_get_valid_freq_for_power_destroy(struct kobject *driver_kobject);
+#else
+static inline int
+hdd_sysfs_get_valid_freq_for_power_create(struct kobject *driver_kobject)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_get_valid_freq_for_power_destroy(struct kobject *driver_kobject)
+{
+}
+#endif
+#endif