1 /*
2 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #if !defined(WLAN_HDD_GREEN_AP_H)
21 #define WLAN_HDD_GREEN_AP_H
22
23 #include "qdf_types.h"
24 #include "qca_vendor.h"
25 #include <net/netlink.h>
26 #include <osif_vdev_sync.h>
27 #include "wlan_lmac_if_def.h"
28 #include "wlan_objmgr_pdev_obj.h"
29 #include "wlan_green_ap_api.h"
30
31 struct hdd_context;
32
33 #ifdef WLAN_SUPPORT_GREEN_AP
34
35 /**
36 * hdd_green_ap_add_sta() - Notify Green AP on STA association
37 * @hdd_ctx: Global HDD context
38 *
39 * Call this function when new node is associated
40 *
41 * Return: void
42 */
43 void hdd_green_ap_add_sta(struct hdd_context *hdd_ctx);
44
45 /**
46 * hdd_green_ap_del_sta() - Notify Green AP on STA disassociation
47 * @hdd_ctx: Global HDD context
48 *
49 * Call this function when new node is disassociated
50 *
51 * Return: void
52 */
53 void hdd_green_ap_del_sta(struct hdd_context *hdd_ctx);
54
55 /**
56 * hdd_green_ap_enable_egap() - Enable Enhanced Green AP
57 * @hdd_ctx: Global HDD context
58 *
59 * This function will enable the Enhanced Green AP feature if it is supported
60 * by the Green AP component.
61 *
62 * Return: 0 on success, negative errno on any failure
63 */
64 int hdd_green_ap_enable_egap(struct hdd_context *hdd_ctx);
65
66 /**
67 * hdd_green_ap_start_state_mc() - to start green AP state mc based on
68 * present concurrency and state of green AP state machine.
69 * @hdd_ctx: hdd context
70 * @mode: device mode
71 * @is_session_start: BSS start/stop
72 *
73 * Return: 0 on success, negative errno on any failure
74 */
75 int hdd_green_ap_start_state_mc(struct hdd_context *hdd_ctx,
76 enum QDF_OPMODE mode, bool is_session_start);
77
78 #else /* WLAN_SUPPORT_GREEN_AP */
79 static inline
hdd_green_ap_add_sta(struct hdd_context * hdd_ctx)80 void hdd_green_ap_add_sta(struct hdd_context *hdd_ctx)
81 {
82 }
83
84 static inline
hdd_green_ap_del_sta(struct hdd_context * hdd_ctx)85 void hdd_green_ap_del_sta(struct hdd_context *hdd_ctx)
86 {
87 }
88
89 static inline
hdd_green_ap_enable_egap(struct hdd_context * hdd_ctx)90 int hdd_green_ap_enable_egap(struct hdd_context *hdd_ctx)
91 {
92 return 0;
93 }
94
95 static inline
hdd_green_ap_start_state_mc(struct hdd_context * hdd_ctx,enum QDF_OPMODE mode,bool is_session_start)96 int hdd_green_ap_start_state_mc(struct hdd_context *hdd_ctx,
97 enum QDF_OPMODE mode, bool is_session_start)
98 {
99 return 0;
100 }
101
102 #endif /* WLAN_SUPPORT_GREEN_AP */
103
104 #ifdef WLAN_SUPPORT_GAP_LL_PS_MODE
105
106 extern const struct nla_policy
107 wlan_hdd_sap_low_pwr_mode[QCA_WLAN_VENDOR_ATTR_DOZED_AP_MAX + 1];
108
109 #define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_COMMANDS \
110 { \
111 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
112 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DOZED_AP, \
113 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
114 WIPHY_VENDOR_CMD_NEED_NETDEV | \
115 WIPHY_VENDOR_CMD_NEED_RUNNING, \
116 .doit = wlan_hdd_enter_sap_low_pwr_mode, \
117 vendor_command_policy(wlan_hdd_sap_low_pwr_mode, \
118 QCA_WLAN_VENDOR_ATTR_MAX) \
119 },
120
121 #define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_EVENT \
122 [QCA_NL80211_VENDOR_SUBCMD_DOZED_AP_INDEX] = { \
123 .vendor_id = QCA_NL80211_VENDOR_ID, \
124 .subcmd = QCA_NL80211_VENDOR_SUBCMD_DOZED_AP, \
125 },
126
127 int
128 wlan_hdd_enter_sap_low_pwr_mode(struct wiphy *wiphy,
129 struct wireless_dev *wdev,
130 const void *data, int data_len);
131
132 QDF_STATUS wlan_hdd_send_green_ap_ll_ps_event(
133 struct wlan_objmgr_vdev *vdev,
134 struct wlan_green_ap_ll_ps_event_param *ll_ps_event_param);
135
136 QDF_STATUS green_ap_register_hdd_callback(struct wlan_objmgr_pdev *pdev,
137 struct green_ap_hdd_callback *hdd_cback);
138
139 #else
140 #define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_COMMANDS
141
142 #define FEATURE_GREEN_AP_LOW_LATENCY_PWR_SAVE_EVENT
143 #endif
144
145 #endif /* !defined(WLAN_HDD_GREEN_AP_H) */
146