Prechádzať zdrojové kódy

qcacld-3.0: Add a sysfs replacement for getChannel

As part of WEXT replacement, replace getChannel with a sysfs file.
This feature can be controlled using configuration flag
CONFIG_WLAN_SYSFS_GET_CHANNEL

file path: /sys/class/net/wlanxx/get_channel
	where wlanxx is adapter name

example command: cat /sys/class/net/wlan1/get_channel
	output: Channel number: 1

Change-Id: I3040af3d19eb83a819ca83cdbb74a70acd041698
CRs-Fixed: 2681803
Bapiraju Alla 5 rokov pred
rodič
commit
367572ad55

+ 4 - 0
Kbuild

@@ -259,6 +259,9 @@ endif
 
 ifeq ($(CONFIG_WLAN_SYSFS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs.o
+ifeq ($(CONFIG_WLAN_SYSFS_GET_CHANNEL), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_get_channel.o
+endif
 ifeq ($(CONFIG_WLAN_SET_FW_MODE_CFG), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_fw_mode_cfg.o
 endif
@@ -2655,6 +2658,7 @@ cppflags-$(CONFIG_DFS_FCC_TYPE4_DURATION_CHECK) += -DDFS_FCC_TYPE4_DURATION_CHEC
 endif
 
 cppflags-$(CONFIG_WLAN_SYSFS) += -DWLAN_SYSFS
+cppflags-$(CONFIG_WLAN_SYSFS_GET_CHANNEL) += -DWLAN_SYSFS_GET_CHANNEL
 cppflags-$(CONFIG_FEATURE_BECN_STATS) += -DWLAN_FEATURE_BEACON_RECEPTION_STATS
 
 cppflags-$(CONFIG_WLAN_SYSFS_CONNECT_INFO) += -DWLAN_SYSFS_CONNECT_INFO

+ 1 - 0
configs/default_defconfig

@@ -176,6 +176,7 @@ CONFIG_WLAN_SYSFS := y
 
 ifeq ($(CONFIG_WLAN_SYSFS), y)
 	CONFIG_WLAN_SYSFS_GET_STA_INFO := y
+	CONFIG_WLAN_SYSFS_GET_CHANNEL := y
 	CONFIG_WLAN_SET_FW_MODE_CFG := y
 	CONFIG_WLAN_REASSOC := y
 	CONFIG_WLAN_SYSFS_CONNECT_INFO := y

+ 61 - 0
core/hdd/inc/wlan_hdd_sysfs_get_channel.h

@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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_channel.h
+ *
+ * implementation for creating sysfs file get_channel
+ */
+
+#ifndef _WLAN_HDD_SYSFS_GET_CHANNEL_H
+#define _WLAN_HDD_SYSFS_GET_CHANNEL_H
+
+#if defined(WLAN_SYSFS) && defined(WLAN_SYSFS_GET_CHANNEL)
+/**
+ * hdd_sysfs_get_channel_interface_create() - API to create get_channel sysfs
+ * @adapter: pointer to adapter
+ *
+ * this file is created for SAP adapter.
+ * file path: /sys/class/net/wlanxx/get_channel
+ *	where wlanxx is adapter name
+ *
+ * usage:
+ *      cat /sys/class/net/wlanxx/get_channel
+ *
+ * Return: none
+ */
+void hdd_sysfs_get_channel_interface_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_get_channel_interface_destroy() - API to destroy get_channel
+ * @adapter: pointer to adapter
+ *
+ * Return: none
+ */
+void hdd_sysfs_get_channel_interface_destroy(struct hdd_adapter *adapter);
+
+#else
+static inline
+void hdd_sysfs_get_channel_interface_create(struct hdd_adapter *adapter)
+{
+}
+
+static inline
+void hdd_sysfs_get_channel_interface_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif /* #ifndef _WLAN_HDD_SYSFS_GET_CHANNEL_H */

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

@@ -38,6 +38,7 @@
 #endif
 #include "osif_sync.h"
 #include "wlan_hdd_sysfs_get_sta_info.h"
+#include "wlan_hdd_sysfs_get_channel.h"
 #include <wlan_hdd_sysfs_set_fw_mode_cfg.h>
 #include <wlan_hdd_sysfs_reassoc.h>
 #include "wlan_hdd_sysfs_crash_inject.h"
@@ -662,6 +663,7 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
 static void
 hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 {
+	hdd_sysfs_get_channel_interface_create(adapter);
 	hdd_sysfs_get_sta_info_interface_create(adapter);
 	hdd_sysfs_crash_inject_create(adapter);
 	hdd_sysfs_suspend_create(adapter);
@@ -687,6 +689,7 @@ hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_suspend_destroy(adapter);
 	hdd_sysfs_crash_inject_destroy(adapter);
 	hdd_sysfs_get_sta_info_interface_destroy(adapter);
+	hdd_sysfs_get_channel_interface_destroy(adapter);
 }
 
 static void

+ 95 - 0
core/hdd/src/wlan_hdd_sysfs_get_channel.c

@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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_channel.c
+ *
+ * implementation for creating sysfs file get_channel
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include "wlan_hdd_sysfs_get_channel.h"
+
+static ssize_t __show_channel_number(struct net_device *net_dev, char *buf)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct hdd_context *hdd_ctx;
+	struct hdd_ap_ctx *ap_ctx;
+	int chan_num = 0;
+	int ret_val;
+
+	hdd_enter_dev(net_dev);
+
+	ret_val = hdd_validate_adapter(adapter);
+	if (0 != ret_val)
+		goto exit;
+
+	if (adapter->device_mode != QDF_SAP_MODE)
+		goto exit;
+
+	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	ret_val = wlan_hdd_validate_context(hdd_ctx);
+	if (0 != ret_val)
+		goto exit;
+
+	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
+	if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) {
+		chan_num = wlan_reg_freq_to_chan(hdd_ctx->pdev,
+						 ap_ctx->operating_chan_freq);
+		ret_val = scnprintf(buf, PAGE_SIZE, "%s    getchannel:%d\n",
+				    net_dev->name, chan_num);
+	}
+
+exit:
+	hdd_exit();
+	return ret_val;
+}
+
+static ssize_t show_channel_number(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 err_size;
+
+	err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
+	if (err_size)
+		return err_size;
+
+	err_size = __show_channel_number(net_dev, buf);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static DEVICE_ATTR(get_channel, 0444, show_channel_number, NULL);
+
+void hdd_sysfs_get_channel_interface_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev, &dev_attr_get_channel);
+	if (error)
+		hdd_err("Could not create get_channel sysfs file");
+}
+
+void hdd_sysfs_get_channel_interface_destroy(struct hdd_adapter *adapter)
+{
+	device_remove_file(&adapter->dev->dev, &dev_attr_get_channel);
+}