wlan-ap-Telecominfraproject/feeds/ipq95xx/iw/patches/615-01-iw-Add-support-to-handle-streaming-stats-in-target.patch
John Crispin 460050a114 ipq50xx: add CIF WF-198 support
Signed-off-by: John Crispin <john@phrozen.org>
2024-02-28 18:56:21 +01:00

148 lines
5.0 KiB
Diff

From 741fa523d6dd195195a9b7514a9583699f43ba3a Mon Sep 17 00:00:00 2001
From: Nagarajan Maran <quic_nmaran@quicinc.com>
Date: Wed, 7 Jun 2023 12:26:25 +0530
Subject: [PATCH] iw: Add support to handle streaming stats in target.
Signed-off-by: Nagarajan Maran <quic_nmaran@quicinc.com>
---
iw.h | 13 +++++++-
sawf_stats.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 1 deletion(-)
create mode 100644 sawf_stats.c
--- a/iw.h
+++ b/iw.h
@@ -79,7 +79,8 @@ enum qca_nl80211_vendor_subcmds {
QCA_NL80211_VENDOR_SUBCMD_SAWF_DEF_Q_MAP_REP = 209,
QCA_NL80211_VENDOR_SUBCMD_TELEMETRY_SLA_THERSHOLD_CFG = 210,
QCA_NL80211_VENDOR_SUBCMD_TELEMETRY_SLA_SAMPLES_COLLECTION_CFG = 211,
- QCA_NL80211_VENDOR_SUBCMD_TELEMETRY_SLA_BREACH_DETECTION_CFG = 212
+ QCA_NL80211_VENDOR_SUBCMD_TELEMETRY_SLA_BREACH_DETECTION_CFG = 212,
+ QCA_NL80211_VENDOR_SUBCMD_SAWF_STREAMING_STATS = 213,
QCA_NL80211_VENDOR_SUBCMD_SAWF_SLA_BREACH = 214,
};
/* Attributes for data used by
@@ -95,6 +96,17 @@ enum qca_wlan_vendor_attr_config {
QCA_WLAN_VENDOR_ATTR_CONFIG_AFTER_LAST - 1,
};
+enum ath12k_vendor_attr_sawf_streaming {
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_BASIC_STATS = 1,
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_EXTND_STATS = 2,
+ QCA_WLAN_VENDOR_ATTR_MLO_LINK_ID = 3,
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_MAX =
+ QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_AFTER_LAST - 1,
+};
+
enum ath12k_vendor_attr_sawf_def_q_map {
QCA_WLAN_VENDOR_ATTR_SAWF_DEF_Q_MAP_INVALID = 0,
QCA_WLAN_VENDOR_ATTR_SAWF_DEF_Q_MAP_SVC_ID = 1,
--- /dev/null
+++ b/sawf_stats.c
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include <arpa/inet.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+#define OUI_QCA 0x001374
+#define STREAMING_STATS_MIN_ARGUMENTS 1
+#define STREAMING_STATS_MAX_ARGUMENTS 3
+#define STREAMING_STATS_MAX_VALUE 3
+#define STREAMING_STATS_BASIC_EN_EXTND_DIS 1
+#define STREAMING_STATS_BASIC_DIS_EXTND_EN 2
+
+
+SECTION(streaming_stats);
+
+static int handle_streaming_stats(struct nl80211_state *state,
+ struct nl_msg *msg, int argc, char **argv,
+ enum id_input id)
+{
+ struct nlattr *stats;
+ unsigned long value;
+ uint8_t basic_stats = 0, extnd_stats = 0, link_id;
+ char *end;
+
+ if (argc < STREAMING_STATS_MIN_ARGUMENTS ||
+ argc > STREAMING_STATS_MAX_ARGUMENTS)
+ goto err;
+
+ errno = 0;
+ value = strtoul(argv[0], &end, 10);
+ if (*end != '\0' || value > STREAMING_STATS_MAX_VALUE || errno == ERANGE)
+ goto err;
+ argc--;
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
+ QCA_NL80211_VENDOR_SUBCMD_SAWF_STREAMING_STATS);
+
+ stats = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+ if (!stats)
+ return -ENOBUFS;
+
+ if (value & STREAMING_STATS_BASIC_EN_EXTND_DIS)
+ basic_stats = 1;
+ if (value & STREAMING_STATS_BASIC_DIS_EXTND_EN)
+ extnd_stats = 1;
+
+ nla_put_u8(msg, QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_BASIC_STATS, basic_stats);
+ nla_put_u8(msg, QCA_WLAN_VENDOR_ATTR_SAWF_STREAMING_EXTND_STATS, extnd_stats);
+
+ if (argc) {
+ argc--;
+ if (!strcmp(argv[1], "-l") || !argc)
+ goto err;
+ errno = 0;
+ link_id = strtoul(argv[2], &end, 10);
+ if (*end != '\0' || value > MAX_MLD_LINK || errno == ERANGE) {
+ goto err;
+ }
+ nla_put_u8(msg, QCA_WLAN_VENDOR_ATTR_MLO_LINK_ID, link_id);
+ }
+
+ nla_nest_end(msg, stats);
+ return 0;
+
+err:
+ printf("Invalid SAWF streaming stats command format: Usage\n");
+ printf("iw dev <devname> streaming_stats configure <value> [-l <link_id>]\n");
+ printf("\t value: 0 - Disable both Basic and Extended stats\n");
+ printf("\t value: 1 - Enable Basic and Disable Extended stats\n");
+ printf("\t value: 2 - Disable Basic and Enable Extended stats\n");
+ printf("\t value: 3 - Enable both Basic and Extended stats\n");
+ return -EINVAL;
+}
+
+COMMAND(streaming_stats, handle, "<value> [-l <link_id>]", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_streaming_stats, ".");