浏览代码

qcacld-3.0: Add vendor command for Green AP power save mode

Introducing vendor command for Green AP power save mode.

Change-Id: I23b5c12ed3ca3c3b134c59e6c93df72a9072b174
CRs-Fixed: 3265087
VIJAY RAJ 2 年之前
父节点
当前提交
453bc8d113
共有 5 个文件被更改,包括 125 次插入1 次删除
  1. 2 0
      Kbuild
  2. 2 0
      configs/default_defconfig
  3. 4 1
      core/hdd/src/wlan_hdd_cfg80211.c
  4. 89 0
      core/hdd/src/wlan_hdd_green_ap.c
  5. 28 0
      core/hdd/src/wlan_hdd_green_ap.h

+ 2 - 0
Kbuild

@@ -3866,6 +3866,8 @@ cppflags-$(CONFIG_WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY) += -DWLAN_ENABLE_SOCIAL_C
 #Green AP feature
 cppflags-$(CONFIG_QCACLD_FEATURE_GREEN_AP) += -DWLAN_SUPPORT_GREEN_AP
 
+cppflags-$(CONFIG_QCACLD_FEATURE_GAP_LL_PS_MODE) += -DWLAN_SUPPORT_GAP_LL_PS_MODE
+
 cppflags-$(CONFIG_QCACLD_FEATURE_APF) += -DFEATURE_WLAN_APF
 
 cppflags-$(CONFIG_WLAN_FEATURE_SARV1_TO_SARV2) += -DWLAN_FEATURE_SARV1_TO_SARV2

+ 2 - 0
configs/default_defconfig

@@ -151,6 +151,7 @@ ifeq ($(CONFIG_DP_CON_MON_MSI_ENABLED), y)
 endif
 	CONFIG_QCA_WIFI_MONITOR_MODE_NO_MSDU_START_TLV_SUPPORT := y
 	CONFIG_WLAN_FEATURE_MCC_QUOTA := y
+	CONFIG_QCACLD_FEATURE_GAP_LL_PS_MODE := y
 	CONFIG_MON_ENABLE_DROP_FOR_NON_MON_PMAC := y
 	CONFIG_DP_WAR_INVALID_FIRST_MSDU_FLAG := y
 endif
@@ -403,6 +404,7 @@ CONFIG_WLAN_DISABLE_EXPORT_SYMBOL := y
 endif
 
 CONFIG_QCACLD_FEATURE_GREEN_AP := y
+
 #Flag to enable Android Packet Filtering
 CONFIG_QCACLD_FEATURE_APF := y
 

+ 4 - 1
core/hdd/src/wlan_hdd_cfg80211.c

@@ -86,6 +86,8 @@
 #include "wlan_hdd_ocb.h"
 #include "wlan_hdd_tsf.h"
 
+#include "wlan_hdd_green_ap.h"
+
 #include "wlan_hdd_subnet_detect.h"
 #include <wlan_hdd_regulatory.h>
 #include "wlan_hdd_lpass.h"
@@ -18429,7 +18431,6 @@ const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = {
 		vendor_command_policy(get_usable_channel_policy,
 				      QCA_WLAN_VENDOR_ATTR_MAX)
 	},
-
 	FEATURE_ACTIVE_TOS_VENDOR_COMMANDS
 	FEATURE_NAN_VENDOR_COMMANDS
 	FEATURE_FW_STATE_COMMANDS
@@ -18445,6 +18446,8 @@ const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = {
 	FEATURE_AVOID_FREQ_EXT_VENDOR_COMMANDS
 	FEATURE_MDNS_OFFLOAD_VENDOR_COMMANDS
 
+	FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_COMMANDS
+
 #ifdef WLAN_FEATURE_PKT_CAPTURE
 	FEATURE_MONITOR_MODE_VENDOR_COMMANDS
 #endif

+ 89 - 0
core/hdd/src/wlan_hdd_green_ap.c

@@ -24,11 +24,13 @@
  *
  */
 
+#include <net/cfg80211.h>
 #include <wlan_hdd_green_ap.h>
 #include <wlan_hdd_main.h>
 #include <wlan_policy_mgr_api.h>
 #include <wlan_green_ap_ucfg_api.h>
 #include "wlan_mlme_ucfg_api.h"
+#include <osif_vdev_sync.h>
 
 /**
  * hdd_green_ap_check_enable() - to check whether to enable green ap or not
@@ -187,3 +189,90 @@ int hdd_green_ap_start_state_mc(struct hdd_context *hdd_ctx,
 	}
 	return ret;
 }
+
+#ifdef WLAN_SUPPORT_GAP_LL_PS_MODE
+const struct nla_policy
+wlan_hdd_sap_low_pwr_mode[QCA_WLAN_VENDOR_ATTR_DOZED_AP_MAX + 1] = {
+	[QCA_WLAN_VENDOR_ATTR_DOZED_AP_STATE] = {.type = NLA_U8},
+};
+
+/**
+ * __wlan_hdd_enter_sap_low_pwr_mode() - Green AP low latency power
+ * save mode
+ * vendor command
+ * @wiphy: wiphy device pointer
+ * @wdev: wireless device pointer
+ * @data: Vendor command data buffer
+ * @data_len: Buffer length
+ *
+ * Return: 0 for Success and negative value for failure
+ */
+static int
+__wlan_hdd_enter_sap_low_pwr_mode(struct wiphy *wiphy,
+				  struct wireless_dev *wdev,
+				  const void *data, int data_len)
+{
+	uint8_t lp_flags;
+	QDF_STATUS status;
+	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
+	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev);
+	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_DOZED_AP_MAX + 1];
+
+	hdd_enter_dev(wdev->netdev);
+
+	if (wlan_cfg80211_nla_parse(tb,
+				    QCA_WLAN_VENDOR_ATTR_DOZED_AP_MAX,
+				    data, data_len,
+				    wlan_hdd_sap_low_pwr_mode)) {
+		hdd_err("Invalid ATTR");
+		return -EINVAL;
+	}
+
+	if (!tb[QCA_WLAN_VENDOR_ATTR_DOZED_AP_STATE]) {
+		hdd_err("low power flag is not present");
+		return -EINVAL;
+	}
+
+	lp_flags =
+		nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_DOZED_AP_STATE]);
+
+	if (lp_flags > QCA_WLAN_DOZED_AP_ENABLE) {
+		hdd_err("Invalid state received");
+		return -EINVAL;
+	}
+
+	hdd_debug("state: %s",
+		  lp_flags == QCA_WLAN_DOZED_AP_ENABLE ? "ENABLE" : "DISABLE");
+
+	status = ucfg_green_ap_ll_ps(hdd_ctx->pdev, adapter->vdev, lp_flags,
+				     adapter->session.ap.sap_config.beacon_int);
+	if (status != QDF_STATUS_SUCCESS) {
+		hdd_err("unable to send low latency power save cmd");
+		return -EINVAL;
+	}
+
+	hdd_exit();
+
+	return 0;
+}
+
+int
+wlan_hdd_enter_sap_low_pwr_mode(struct wiphy *wiphy,
+				struct wireless_dev *wdev,
+				const void *data, int data_len)
+{
+	int errno;
+	struct osif_vdev_sync *vdev_sync;
+
+	errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync);
+	if (errno)
+		return errno;
+
+	errno = __wlan_hdd_enter_sap_low_pwr_mode(wiphy, wdev,
+						  data, data_len);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return 0;
+}
+#endif

+ 28 - 0
core/hdd/src/wlan_hdd_green_ap.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
+ * 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
@@ -20,6 +21,8 @@
 #define WLAN_HDD_GREEN_AP_H
 
 #include "qdf_types.h"
+#include "qca_vendor.h"
+#include <net/netlink.h>
 
 struct hdd_context;
 
@@ -94,4 +97,29 @@ int hdd_green_ap_start_state_mc(struct hdd_context *hdd_ctx,
 
 #endif /* WLAN_SUPPORT_GREEN_AP */
 
+#ifdef WLAN_SUPPORT_GAP_LL_PS_MODE
+
+extern const struct nla_policy
+wlan_hdd_sap_low_pwr_mode[QCA_WLAN_VENDOR_ATTR_DOZED_AP_MAX + 1];
+
+#define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_COMMANDS			\
+{									\
+	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
+	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DOZED_AP,		\
+	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				\
+		WIPHY_VENDOR_CMD_NEED_NETDEV |				\
+		WIPHY_VENDOR_CMD_NEED_RUNNING,				\
+	.doit = wlan_hdd_enter_sap_low_pwr_mode,			\
+	vendor_command_policy(wlan_hdd_sap_low_pwr_mode,		\
+			      QCA_WLAN_VENDOR_ATTR_MAX)			\
+},
+
+int
+wlan_hdd_enter_sap_low_pwr_mode(struct wiphy *wiphy,
+				struct wireless_dev *wdev,
+				const void *data, int data_len);
+#else
+#define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_COMMANDS
+#endif
+
 #endif /* !defined(WLAN_HDD_GREEN_AP_H) */