1 /*
2 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 /**
20 * DOC: wlan_hdd_mcc_quota.h
21 *
22 * WLAN Host Device Driver MCC quota feature interface definitions
23 *
24 */
25 #ifndef WLAN_HDD_MCC_QUOTA_H
26 #define WLAN_HDD_MCC_QUOTA_H
27 #include "qdf_types.h"
28 #include "qdf_status.h"
29 #include "qca_vendor.h"
30 #include <net/cfg80211.h>
31
32 struct hdd_context;
33 struct hdd_adapter;
34 struct wlan_objmgr_psoc;
35
36 #ifdef WLAN_FEATURE_MCC_QUOTA
37 extern const struct nla_policy
38 set_mcc_quota_policy[QCA_WLAN_VENDOR_ATTR_MCC_QUOTA_MAX + 1];
39
40 /**
41 * wlan_hdd_set_mcc_adaptive_sched() - Enable or disable MCC adaptive scheduling
42 * @psoc: psoc context
43 * @enable: Enable (true) or disable (false)
44 *
45 * Return: 0 for success, Non zero failure code for errors
46 */
47 int wlan_hdd_set_mcc_adaptive_sched(struct wlan_objmgr_psoc *psoc,
48 bool enable);
49
50 /**
51 * wlan_hdd_cfg80211_set_mcc_quota() - Set user MCC quota to the target
52 * @wiphy: Wireless info object
53 * @wdev: Wireless dev object
54 * @attr: Command attributes
55 * @attr_len: Length of attributes
56 *
57 * Return: 0 on success, negative errno on failure
58 */
59 int wlan_hdd_cfg80211_set_mcc_quota(struct wiphy *wiphy,
60 struct wireless_dev *wdev,
61 const void *attr,
62 int attr_len);
63
64 #define FEATURE_MCC_QUOTA_VENDOR_COMMANDS \
65 { \
66 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
67 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MCC_QUOTA, \
68 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,\
69 .doit = wlan_hdd_cfg80211_set_mcc_quota, \
70 vendor_command_policy(set_mcc_quota_policy, \
71 QCA_WLAN_VENDOR_ATTR_MCC_QUOTA_MAX) \
72 },
73
74 #define FEATURE_MCC_QUOTA_VENDOR_EVENTS \
75 [QCA_NL80211_VENDOR_SUBCMD_MCC_QUOTA_INDEX] = { \
76 .vendor_id = QCA_NL80211_VENDOR_ID, \
77 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MCC_QUOTA, \
78 },
79
80 /**
81 * wlan_hdd_apply_user_mcc_quota() - Apply the user MCC quota to the target
82 * @adapter: pointer to HDD adapter object
83 *
84 * Return: 0 on success, errno for error
85 */
86 int wlan_hdd_apply_user_mcc_quota(struct hdd_adapter *adapter);
87
88 /**
89 * wlan_hdd_register_mcc_quota_event_callback() - Register hdd callback to get
90 * mcc quota event.
91 * @hdd_ctx: pointer to hdd context
92 *
93 * Return: void
94 */
95 void wlan_hdd_register_mcc_quota_event_callback(struct hdd_context *hdd_ctx);
96 #else /* WLAN_FEATURE_MCC_QUOTA */
97 #define FEATURE_MCC_QUOTA_VENDOR_COMMANDS
98 #define FEATURE_MCC_QUOTA_VENDOR_EVENTS
99
wlan_hdd_apply_user_mcc_quota(struct hdd_adapter * adapter)100 static inline int wlan_hdd_apply_user_mcc_quota(struct hdd_adapter *adapter)
101 {
102 return 0;
103 }
104
wlan_hdd_set_mcc_adaptive_sched(struct wlan_objmgr_psoc * psoc,bool enable)105 static inline int wlan_hdd_set_mcc_adaptive_sched(struct wlan_objmgr_psoc *psoc,
106 bool enable)
107 {
108 return 0;
109 }
110
111 static inline void
wlan_hdd_register_mcc_quota_event_callback(struct hdd_context * hdd_ctx)112 wlan_hdd_register_mcc_quota_event_callback(struct hdd_context *hdd_ctx)
113 {
114 }
115 #endif /* WLAN_FEATURE_MCC_QUOTA */
116 #endif /* WLAN_HDD_MCC_QUOTA_H */
117