Эх сурвалжийг харах

qcacld-3.0: Add sysfs replacement for dfsnol command

WEXT ioctls are no longer supported by the wlan driver.
So, add a sysfs replacement to setdfsnol and getdfsnol commands.

file path: sys/class/net/wlanxx/dfsnol
	where wlanxx is the adapter interface

usage:	echo arg_0 > /sys/class/net/wlanxx/dfsnol
	cat /sys/class/net/wlanxx/dfsnol

Change-Id: Ia8475b5c6ef39142def38eab0e777840af885c33
CRs-Fixed: 3431517
Aditya Kodukula 2 жил өмнө
parent
commit
b4d34e5284

+ 5 - 1
Kbuild

@@ -487,6 +487,10 @@ ifeq ($(CONFIG_WLAN_SYSFS_LOG_BUFFER), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_log_buffer.o
 endif
 
+ifeq ($(CONFIG_WLAN_SYSFS_DFSNOL), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dfsnol.o
+endif
+
 endif # CONFIG_WLAN_SYSFS
 
 ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
@@ -3515,8 +3519,8 @@ cppflags-$(CONFIG_MONITOR_MODULARIZED_ENABLE) += -DMONITOR_MODULARIZED_ENABLE
 cppflags-$(CONFIG_DP_PKT_ADD_TIMESTAMP) += -DCONFIG_DP_PKT_ADD_TIMESTAMP
 cppflags-$(CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM) += -DWLAN_PDEV_VDEV_SEND_MULTI_PARAM
 cppflags-$(CONFIG_WLAN_SYSFS_LOG_BUFFER) += -DFEATURE_SYSFS_LOG_BUFFER
-
 cppflags-$(CONFIG_ENABLE_VALLOC_REPLACE_MALLOC) += -DENABLE_VALLOC_REPLACE_MALLOC
+cppflags-$(CONFIG_WLAN_SYSFS_DFSNOL) += -DCONFIG_WLAN_SYSFS_DFSNOL
 
 ifeq ($(CONFIG_LEAK_DETECTION), y)
 cppflags-y += \

+ 1 - 0
configs/default_defconfig

@@ -397,6 +397,7 @@ endif
 	CONFIG_WLAN_FREQ_LIST := y
 	CONFIG_DP_PKT_ADD_TIMESTAMP := y
 	CONFIG_WLAN_SYSFS_LOG_BUFFER := y
+	CONFIG_WLAN_SYSFS_DFSNOL := y
 endif
 CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM := y
 CONFIG_WLAN_POWER_DEBUG := y

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

@@ -91,6 +91,7 @@
 #include <wlan_hdd_sysfs_direct_link_ut_cmd.h>
 #include <wlan_hdd_sysfs_runtime_pm.h>
 #include <wlan_hdd_sysfs_log_buffer.h>
+#include <wlan_hdd_sysfs_dfsnol.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -870,11 +871,13 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_dp_tx_delay_stats_create(adapter);
 	hdd_sysfs_dp_traffic_end_indication_create(adapter);
 	hdd_sysfs_direct_link_ut_cmd_create(adapter);
+	hdd_sysfs_dfsnol_create(adapter);
 }
 
 static void
 hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 {
+	hdd_sysfs_dfsnol_destroy(adapter);
 	hdd_sysfs_direct_link_ut_destroy(adapter);
 	hdd_sysfs_dp_traffic_end_indication_destroy(adapter);
 	hdd_sysfs_dp_tx_delay_stats_destroy(adapter);

+ 170 - 0
core/hdd/src/wlan_hdd_sysfs_dfsnol.c

@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+/**
+ * DOC: wlan_hdd_sysfs_dfsnol.c
+ *
+ * Implementation for creating sysfs file dfsnol
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include "wlan_dfs_utils_api.h"
+#include <wlan_hdd_sysfs.h>
+#include <wlan_hdd_sysfs_dfsnol.h>
+
+static ssize_t
+__hdd_sysfs_dfsnol_show(struct net_device *net_dev, char *buf)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct hdd_context *hdd_ctx;
+	struct wlan_objmgr_pdev *pdev;
+	int ret;
+
+	if (hdd_validate_adapter(adapter))
+		return -EINVAL;
+
+	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(hdd_ctx))
+		return -EINVAL;
+
+	pdev = hdd_ctx->pdev;
+	if (!pdev) {
+		hdd_err("null pdev");
+		return -EINVAL;
+	}
+
+	utils_dfs_print_nol_channels(pdev);
+	return scnprintf(buf, PAGE_SIZE, "DFS NOL Info written to dmesg log\n");
+}
+
+static ssize_t
+hdd_sysfs_dfsnol_show(struct device *dev,
+		      struct device_attribute *attr, char *buf)
+{
+	struct net_device *net_dev = container_of(dev, struct net_device, dev);
+	struct osif_vdev_sync *vdev_sync;
+	ssize_t errno_size;
+
+	errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_dfsnol_show(net_dev, buf);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return errno_size;
+}
+
+static ssize_t
+__hdd_sysfs_dfsnol_store(struct net_device *net_dev,
+			 char const *buf, size_t count)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct hdd_context *hdd_ctx;
+	struct sap_context *sap_ctx;
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	char *sptr, *token;
+	eSapDfsNolType set_value;
+	int ret;
+	QDF_STATUS status;
+
+	if (hdd_validate_adapter(adapter))
+		return -EINVAL;
+
+	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(hdd_ctx))
+		return -EINVAL;
+
+	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter);
+	if (!sap_ctx) {
+		hdd_err_rl("Null SAP Context");
+		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;
+	hdd_nofl_debug("set_dfsnol: count %zu buf_local:(%s) net_devname %s",
+		       count, buf_local, net_dev->name);
+
+	/* Get set_value */
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou32(token, 0, &set_value))
+		return -EINVAL;
+
+	status = wlansap_set_dfs_nol(sap_ctx, set_value);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		hdd_err_rl("Unable to set_dfsnol val %d", set_value);
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static ssize_t
+hdd_sysfs_dfsnol_store(struct device *dev, struct device_attribute *attr,
+		       char const *buf, size_t count)
+{
+	struct net_device *net_dev = container_of(dev, struct net_device, dev);
+	struct osif_vdev_sync *vdev_sync;
+	ssize_t errno_size;
+
+	errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_dfsnol_store(net_dev, buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return errno_size;
+}
+
+static DEVICE_ATTR(dfsnol, 0660, hdd_sysfs_dfsnol_show,
+		   hdd_sysfs_dfsnol_store);
+
+int hdd_sysfs_dfsnol_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev, &dev_attr_dfsnol);
+	if (error)
+		hdd_err_rl("could not create dfsnol sysfs file");
+
+	return error;
+}
+
+void hdd_sysfs_dfsnol_destroy(struct hdd_adapter *adapter)
+{
+	device_remove_file(&adapter->dev->dev, &dev_attr_dfsnol);
+}

+ 62 - 0
core/hdd/src/wlan_hdd_sysfs_dfsnol.h

@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/**
+ * DOC: wlan_hdd_sysfs_dfsnol.h
+ *
+ * implementation for creating sysfs file dfsnol
+ */
+
+#ifndef _WLAN_HDD_SYSFS_DFSNOL_H
+#define _WLAN_HDD_SYSFS_DFSNOL_H
+
+#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_SYSFS_DFSNOL)
+/**
+ * hdd_sysfs_dfsnol_create() - API to create dfsnol sysfs file
+ * (for sap mode only)
+ * @adapter: hdd adapter
+ *
+ * this file is created per adapter.
+ * file path: /sys/class/net/wlanxx/dfsnol
+ *                (wlanxx is adapter name)
+ * usage:
+ *      echo [arg_0] > /sys/class/net/wlanxx/dfsnol
+ *      cat /sys/class/net/wlanxx/dfsnol
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_dfsnol_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_dfsnol_destroy() - API to destroy dfsnol sysfs file
+ * @adapter: pointer to adapter
+ *
+ * Return: none
+ */
+void hdd_sysfs_dfsnol_destroy(struct hdd_adapter *adapter);
+#else
+static inline int
+hdd_sysfs_dfsnol_create(struct hdd_adapter *adapter)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_dfsnol_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif /* #ifndef _WLAN_HDD_SYSFS_DFSNOL_H */