Browse Source

qcacld-3.0: Add sysfs support for traffic end indication

Add sysfs entry to configure status and dscp values
used by application for regular traffic and last packet
to mark traffic end.

Change-Id: Ib0e0aaf64e24da3b402b695840850b01c19a4991
CRs-Fixed: 3207451
nakul kachhwaha 2 years ago
parent
commit
55b4c8f1b5

+ 5 - 0
Kbuild

@@ -431,6 +431,10 @@ ifeq ($(CONFIG_DP_PKT_ADD_TIMESTAMP), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_add_timestamp.o
 endif
 
+ifeq ($(CONFIG_DP_TRAFFIC_END_INDICATION), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dp_traffic_end_indication.o
+endif
+
 ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_fw_state.o
 endif
@@ -3142,6 +3146,7 @@ cppflags-y +=	-DANI_OS_TYPE_ANDROID=6 \
 		-Werror\
 		-D__linux__
 
+cppflags-$(CONFIG_DP_TRAFFIC_END_INDICATION) += -DDP_TRAFFIC_END_INDICATION
 cppflags-$(CONFIG_THERMAL_STATS_SUPPORT) += -DTHERMAL_STATS_SUPPORT
 cppflags-$(CONFIG_PTT_SOCK_SVC_ENABLE) += -DPTT_SOCK_SVC_ENABLE
 cppflags-$(CONFIG_FEATURE_WLAN_WAPI) += -DFEATURE_WLAN_WAPI

+ 2 - 0
configs/default_defconfig

@@ -60,6 +60,7 @@ ifeq ($(CONFIG_CNSS_QCA6490), y)
 	ifeq ($(CONFIG_ARCH_LAHAINA), y)
 		CONFIG_WLAN_TSF_UPLINK_DELAY := y
 	endif
+	CONFIG_DP_TRAFFIC_END_INDICATION := y
 endif
 
 ifeq ($(CONFIG_CNSS_QCA6750), y)
@@ -85,6 +86,7 @@ ifeq ($(CONFIG_CNSS_QCA6750), y)
 		CONFIG_WLAN_TSF_UPLINK_DELAY := y
 	endif
 	CONFIG_WLAN_FEATURE_PEER_TXQ_FLUSH_CONF := y
+	CONFIG_DP_TRAFFIC_END_INDICATION := y
 endif
 
 ifeq (y,$(findstring y,$(CONFIG_CNSS_KIWI) $(CONFIG_CNSS_KIWI_V2)))

+ 2 - 0
configs/kiwi_v2_defconfig

@@ -34,3 +34,5 @@ CONFIG_FEATURE_COEX := y
 ifeq ($(CONFIG_FEATURE_COEX), y)
 CONFIG_WLAN_FEATURE_COEX_DBAM := y
 endif
+
+CONFIG_DP_TRAFFIC_END_INDICATION := y

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

@@ -1025,6 +1025,7 @@ struct wlm_multi_client_info_table {
  * @mon_adapter: hdd_adapter of monitor mode.
  * @set_mac_addr_req_ctx: Set MAC address command request context
  * @delta_qtime: delta between host qtime and monotonic time
+ * @traffic_end_ind_en: traffic end indication feature enable/disable
  */
 struct hdd_adapter {
 	/* Magic cookie for adapter sanity verification.  Note that this
@@ -1305,6 +1306,9 @@ struct hdd_adapter {
 	void *set_mac_addr_req_ctx;
 #endif
 	int64_t delta_qtime;
+#ifdef DP_TRAFFIC_END_INDICATION
+	bool traffic_end_ind_en;
+#endif
 };
 
 #define WLAN_HDD_GET_STATION_CTX_PTR(adapter) (&(adapter)->session.station)

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

@@ -86,6 +86,7 @@
 #include <wlan_hdd_sysfs_get_freq_for_pwr.h>
 #include <wlan_hdd_sysfs_dp_tx_delay_stats.h>
 #include <wlan_hdd_sysfs_wifi_features.h>
+#include <wlan_hdd_sysfs_dp_traffic_end_indication.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -845,11 +846,13 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_dl_modes_create(adapter);
 	hdd_sysfs_11be_rate_create(adapter);
 	hdd_sysfs_dp_tx_delay_stats_create(adapter);
+	hdd_sysfs_dp_traffic_end_indication_create(adapter);
 }
 
 static void
 hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 {
+	hdd_sysfs_dp_traffic_end_indication_destroy(adapter);
 	hdd_sysfs_dp_tx_delay_stats_destroy(adapter);
 	hdd_sysfs_11be_rate_destroy(adapter);
 	hdd_sysfs_dl_modes_destroy(adapter);

+ 212 - 0
core/hdd/src/wlan_hdd_sysfs_dp_traffic_end_indication.c

@@ -0,0 +1,212 @@
+/*
+ * 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_dp_traffic_end_indication.c
+ *
+ * implementation for creating sysfs files:
+ *
+ * dp_traffic_end_indication
+ */
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include "wlan_hdd_object_manager.h"
+#include <wlan_hdd_sysfs.h>
+#include <wlan_hdd_sysfs_dp_traffic_end_indication.h>
+#include <wlan_dp_ucfg_api.h>
+
+static ssize_t
+__hdd_sysfs_dp_traffic_end_indication_show(struct net_device *net_dev,
+					   char *buf)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct wlan_objmgr_vdev *vdev;
+	struct dp_traffic_end_indication info = {0};
+	QDF_STATUS status;
+	int ret;
+
+	if (hdd_validate_adapter(adapter))
+		return -EINVAL;
+
+	ret = wlan_hdd_validate_context(adapter->hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(adapter->hdd_ctx))
+		return -EINVAL;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_DP_ID);
+	if (!vdev)
+		return -EINVAL;
+
+	status = ucfg_dp_traffic_end_indication_get(vdev, &info);
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
+
+	if (!QDF_IS_STATUS_SUCCESS(status))
+		return -EINVAL;
+
+	hdd_debug("vdev_id:%u traffic end indication:%u defdscp:%u spldscp:%u",
+		  adapter->vdev_id, info.enabled,
+		  info.def_dscp, info.spl_dscp);
+
+	ret = scnprintf(buf, PAGE_SIZE, "%u %u %u\n",
+			info.enabled, info.def_dscp, info.def_dscp);
+	return ret;
+}
+
+static ssize_t
+hdd_sysfs_dp_traffic_end_indication_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 err_size;
+
+	err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
+	if (err_size)
+		return err_size;
+
+	err_size = __hdd_sysfs_dp_traffic_end_indication_show(net_dev, buf);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static ssize_t
+__hdd_sysfs_dp_traffic_end_indication_store(struct net_device *net_dev,
+					    const char *buf,
+					    size_t count)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct dp_traffic_end_indication info = {0};
+	struct wlan_objmgr_vdev *vdev;
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	char *sptr, *token;
+	uint8_t value, defdscp, spldscp;
+	int ret;
+
+	if (hdd_validate_adapter(adapter))
+		return -EINVAL;
+
+	ret = wlan_hdd_validate_context(adapter->hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(adapter->hdd_ctx))
+		return -EINVAL;
+
+	ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
+					      buf, count);
+	if (ret) {
+		hdd_err("invalid input");
+		return ret;
+	}
+
+	sptr = buf_local;
+	/* Enable/disable traffic end indication*/
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou8(token, 0, &value))
+		return -EINVAL;
+
+	/* Default DSCP Value */
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou8(token, 0, &defdscp))
+		return -EINVAL;
+
+	/* Special DSCP Value */
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou8(token, 0, &spldscp))
+		return -EINVAL;
+
+	if ((defdscp > 63) || (spldscp > 63)) {
+		hdd_err("invalid dscp value");
+		return -EINVAL;
+	}
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_DP_ID);
+	if (!vdev)
+		return -EINVAL;
+
+	info.enabled = !!value;
+	adapter->traffic_end_ind_en = info.enabled;
+	if (info.enabled) {
+		info.def_dscp = defdscp;
+		info.spl_dscp = spldscp;
+	} else {
+		info.def_dscp = 0;
+		info.spl_dscp = 0;
+	}
+
+	hdd_debug("vdev_id:%u traffic end indication:%u defdscp:%u spldscp:%u",
+		  adapter->vdev_id, value, defdscp, spldscp);
+
+	ucfg_dp_traffic_end_indication_set(vdev, info);
+	wlan_objmgr_vdev_release_ref(vdev, WLAN_DP_ID);
+
+	return count;
+}
+
+static ssize_t
+hdd_sysfs_dp_traffic_end_indication_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_dp_traffic_end_indication_store(net_dev,
+								 buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return errno_size;
+}
+
+static DEVICE_ATTR(dp_traffic_end_indication, 0660,
+		   hdd_sysfs_dp_traffic_end_indication_show,
+		   hdd_sysfs_dp_traffic_end_indication_store);
+
+int hdd_sysfs_dp_traffic_end_indication_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev,
+				   &dev_attr_dp_traffic_end_indication);
+	if (error)
+		hdd_err("could not create traffic_end_indication sysfs file");
+
+	return error;
+}
+
+void
+hdd_sysfs_dp_traffic_end_indication_destroy(struct hdd_adapter *adapter)
+{
+	device_remove_file(&adapter->dev->dev,
+			   &dev_attr_dp_traffic_end_indication);
+}

+ 66 - 0
core/hdd/src/wlan_hdd_sysfs_dp_traffic_end_indication.h

@@ -0,0 +1,66 @@
+/*
+ * 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_dp_traffic_end_indication.h
+ *
+ * implementation for creating sysfs files:
+ *
+ * dp_traffic_end_indication
+ */
+
+#ifndef _WLAN_HDD_SYSFS_DP_TRAFFIC_END_INDICATION_H
+#define _WLAN_HDD_SYSFS_DP_TRAFFIC_END_INDICATION_H
+
+#ifdef DP_TRAFFIC_END_INDICATION
+/**
+ * hdd_sysfs_dp_traffic_end_indication_create() - API to create dp tx data end
+ * indication related sysfs entry
+ * @adapter: hdd adapter
+ *
+ * file path: /sys/class/net/wlanxx/dp_traffic_end_indication
+ * This sysfs entry is created per adapter
+ *
+ * usage:
+ *      echo <0/1> <Default DSCP> <Special DSCP> > dp_traffic_end_indication
+ *
+ * Return: 0 on success and errno on failure
+ */
+int
+hdd_sysfs_dp_traffic_end_indication_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_dp_traffic_end_indication_destroy() - API to destroy dp traffic end
+ * indication related sysfs entry
+ * @adapter: hdd adapter
+ *
+ * Return: None
+ */
+void
+hdd_sysfs_dp_traffic_end_indication_destroy(struct hdd_adapter *adapter);
+#else
+static inline int
+hdd_sysfs_dp_traffic_end_indication_create(struct hdd_adapter *adapter)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_dp_traffic_end_indication_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif