Răsfoiți Sursa

qcacld-3.0: Add sysfs entry for enablertscts

Add the sysfs entry for enablertscts.
Previously these commands would be queried via iwpriv
--> iwpriv wlan0 enablertscts [0/1/2]
it is now changed to support via sysfs:
--> echo [0/1/2] > /sys/class/net/wlanxx/rts_cts

Change-Id: I9df4e0c678cc9221b3cc95c4d2058a4516438bc3
CRs-Fixed: 2689897
Min Liu 4 ani în urmă
părinte
comite
c9112061fb

+ 4 - 0
Kbuild

@@ -312,6 +312,9 @@ endif
 ifeq ($(CONFIG_WLAN_SET_RADAR), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_radar.o
 endif
+ifeq ($(CONFIG_WLAN_SYSFS_RTS_CTS), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_rts_cts.o
+endif
 ifeq ($(CONFIG_WLAN_TXRX_FW_STATS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_txrx_fw_stats.o
 endif
@@ -2581,6 +2584,7 @@ cppflags-$(CONFIG_WLAN_GTX_BW_MASK) += -DCONFIG_WLAN_GTX_BW_MASK
 cppflags-$(CONFIG_WLAN_SET_SCAN_CFG) += -DCONFIG_WLAN_SET_SCAN_CFG
 cppflags-$(CONFIG_WLAN_SET_MON_CHAN) += -DCONFIG_WLAN_SET_MON_CHAN
 cppflags-$(CONFIG_WLAN_SET_RADAR) += -DCONFIG_WLAN_SET_RADAR
+cppflags-$(CONFIG_WLAN_SYSFS_RTS_CTS) += -DWLAN_SYSFS_RTS_CTS
 cppflags-$(CONFIG_WLAN_TXRX_FW_STATS) += -DCONFIG_WLAN_TXRX_FW_STATS
 cppflags-$(CONFIG_WLAN_TXRX_STATS) += -DCONFIG_WLAN_TXRX_STATS
 cppflags-$(CONFIG_WLAN_SET_DP_TRACE) += -DCONFIG_WLAN_SET_DP_TRACE

+ 1 - 0
configs/default_defconfig

@@ -193,6 +193,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y)
 	CONFIG_WLAN_SET_SCAN_CFG := y
 	CONFIG_WLAN_SET_MON_CHAN := y
 	CONFIG_WLAN_SET_RADAR := y
+	CONFIG_WLAN_SYSFS_RTS_CTS := y
 	CONFIG_WLAN_TXRX_FW_STATS := y
 	CONFIG_WLAN_TXRX_STATS := y
 	CONFIG_WLAN_SET_DP_TRACE := y

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

@@ -59,6 +59,7 @@
 #include <wlan_hdd_sysfs_set_scan_cfg.h>
 #include <wlan_hdd_sysfs_set_mon_chan.h>
 #include <wlan_hdd_sysfs_set_radar.h>
+#include <wlan_hdd_sysfs_rts_cts.h>
 #include <wlan_hdd_sysfs_txrx_fw_stats.h>
 #include <wlan_hdd_sysfs_txrx_stats.h>
 #include <wlan_hdd_sysfs_set_dp_trace.h>
@@ -652,6 +653,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_get_stats_create(adapter);
 	hdd_sysfs_txrx_fw_st_rst_create(adapter);
 	hdd_sysfs_gtx_bw_mask_create(adapter);
+	hdd_sysfs_rts_cts_create(adapter);
 	hdd_sysfs_txrx_fw_stats_create(adapter);
 	hdd_sysfs_txrx_stats_create(adapter);
 	hdd_sysfs_get_range_ext_create(adapter);
@@ -669,6 +671,7 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_get_range_ext_destroy(adapter);
 	hdd_sysfs_txrx_stats_destroy(adapter);
 	hdd_sysfs_txrx_fw_stats_destroy(adapter);
+	hdd_sysfs_rts_cts_destroy(adapter);
 	hdd_sysfs_gtx_bw_mask_destroy(adapter);
 	hdd_sysfs_txrx_fw_st_rst_destroy(adapter);
 	hdd_sysfs_get_stats_destroy(adapter);
@@ -703,6 +706,7 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_gtx_bw_mask_create(adapter);
 	hdd_sysfs_dcm_create(adapter);
 	hdd_sysfs_set_radar_create(adapter);
+	hdd_sysfs_rts_cts_create(adapter);
 	hdd_sysfs_txrx_fw_stats_create(adapter);
 	hdd_sysfs_txrx_stats_create(adapter);
 	hdd_sysfs_get_temp_create(adapter);
@@ -714,6 +718,7 @@ hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_get_temp_destroy(adapter);
 	hdd_sysfs_txrx_stats_destroy(adapter);
 	hdd_sysfs_txrx_fw_stats_destroy(adapter);
+	hdd_sysfs_rts_cts_destroy(adapter);
 	hdd_sysfs_set_radar_destroy(adapter);
 	hdd_sysfs_dcm_destroy(adapter);
 	hdd_sysfs_gtx_bw_mask_destroy(adapter);

+ 145 - 0
core/hdd/src/wlan_hdd_sysfs_rts_cts.c

@@ -0,0 +1,145 @@
+/*
+ * 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_rts_cts.c
+ *
+ * implementation for creating sysfs file rts_cts
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include <wlan_hdd_sysfs.h>
+#include "wlan_hdd_sysfs_rts_cts.h"
+#include <wlan_mlme_ucfg_api.h>
+#include <cfg_ucfg_api.h>
+#include <cfg_mlme_threshold.h>
+#include <wma_api.h>
+
+static ssize_t
+__hdd_sysfs_rts_cts_store(struct net_device *net_dev,
+			  char const *buf, size_t count)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	struct hdd_context *hdd_ctx;
+	char *sptr, *token;
+	uint32_t rts_threshold;
+	QDF_STATUS status;
+	int value, ret;
+
+	if (hdd_validate_adapter(adapter)) {
+		hdd_err_rl("adapter validate fail");
+		return -EINVAL;
+	}
+
+	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	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 (kstrtou32(token, 0, &value))
+		return -EINVAL;
+
+	switch (value) {
+	case HDD_SYSFS_RTS_CTS_ENABLE:
+		status = ucfg_mlme_get_rts_threshold(hdd_ctx->psoc,
+						     &rts_threshold);
+		if (QDF_IS_STATUS_ERROR(status)) {
+			hdd_err_rl("Get rts threshold failed, status %d",
+				   status);
+			return -EINVAL;
+		}
+		break;
+	case HDD_SYSFS_RTS_CTS_DISABLE:
+	case HDD_SYSFS_CTS_ENABLE:
+		rts_threshold = cfg_max(CFG_RTS_THRESHOLD);
+		break;
+	default:
+		hdd_err_rl("invalid value %d", value);
+		return -EINVAL;
+	}
+
+	ret = wma_cli_set_command(adapter->vdev_id,
+				  WMI_VDEV_PARAM_ENABLE_RTSCTS,
+				  value, VDEV_CMD);
+	if (ret) {
+		hdd_err_rl("Failed to set firmware, ret %d", ret);
+		return ret;
+	}
+
+	status = ucfg_mlme_set_rts_threshold(hdd_ctx->psoc, rts_threshold);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		hdd_err_rl("Set rts threshold failed, status %d", status);
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static ssize_t
+hdd_sysfs_rts_cts_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_rts_cts_store(net_dev, buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return errno_size;
+}
+
+static DEVICE_ATTR(rts_cts, 0220,
+		   NULL, hdd_sysfs_rts_cts_store);
+
+int hdd_sysfs_rts_cts_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev, &dev_attr_rts_cts);
+	if (error)
+		hdd_err("could not create rts_cts sysfs file");
+
+	return error;
+}
+
+void hdd_sysfs_rts_cts_destroy(struct hdd_adapter *adapter)
+{
+	device_remove_file(&adapter->dev->dev, &dev_attr_rts_cts);
+}

+ 65 - 0
core/hdd/src/wlan_hdd_sysfs_rts_cts.h

@@ -0,0 +1,65 @@
+/*
+ * 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_rts_cts.h
+ *
+ * implementation for creating sysfs file rts_cts
+ */
+
+#ifndef _WLAN_HDD_SYSFS_RTS_CTS_H
+#define _WLAN_HDD_SYSFS_RTS_CTS_H
+
+#if defined(WLAN_SYSFS) && defined(WLAN_SYSFS_RTS_CTS)
+
+#define HDD_SYSFS_RTS_CTS_DISABLE 0
+#define HDD_SYSFS_RTS_CTS_ENABLE  1
+#define HDD_SYSFS_CTS_ENABLE      2
+
+/**
+ * hdd_sysfs_rts_cts_create() - API to create rts_cts
+ * @adapter: hdd adapter
+ *
+ * this file is created per adapter.
+ * file path: /sys/class/net/wlanxx/rts_cts
+ *                (wlanxx is adapter name)
+ * usage:
+ *      echo [value] > rts_cts
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_rts_cts_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_rts_cts_destroy() - API to destroy rts_cts
+ * @adapter: pointer to adapter
+ *
+ * Return: none
+ */
+void hdd_sysfs_rts_cts_destroy(struct hdd_adapter *adapter);
+#else
+static inline int
+hdd_sysfs_rts_cts_create(struct hdd_adapter *adapter)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_rts_cts_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif /* #ifndef _WLAN_HDD_SYSFS_RTS_CTS_H */