1 /*
2 * Copyright (c) 2018, 2020-2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2023-2024 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 /**
21 * DOC: target_if_cp_stats.h
22 *
23 * This header file provide declarations required for Rx and Tx events from
24 * firmware
25 */
26
27 #ifndef __TARGET_IF_CP_STATS_H__
28 #define __TARGET_IF_CP_STATS_H__
29
30 #include <target_if.h>
31 #include <wlan_lmac_if_def.h>
32 #include <wlan_cp_stats_utils_api.h>
33
34 #ifdef QCA_SUPPORT_CP_STATS
35
36 /**
37 * target_if_cp_stats_get_rx_ops() - get rx ops
38 * @psoc: pointer to psoc object
39 *
40 * Return: pointer to rx ops
41 */
42 static inline struct wlan_lmac_if_cp_stats_rx_ops *
target_if_cp_stats_get_rx_ops(struct wlan_objmgr_psoc * psoc)43 target_if_cp_stats_get_rx_ops(struct wlan_objmgr_psoc *psoc)
44 {
45 struct wlan_lmac_if_rx_ops *rx_ops;
46
47 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
48 if (!rx_ops) {
49 cp_stats_err("rx_ops is NULL");
50 return NULL;
51 }
52
53 return &rx_ops->cp_stats_rx_ops;
54 }
55
56 /**
57 * target_if_cp_stats_get_tx_ops() - get tx ops
58 * @psoc: pointer to psoc object
59 *
60 * Return: pointer to tx ops
61 */
62 static inline struct wlan_lmac_if_cp_stats_tx_ops *
target_if_cp_stats_get_tx_ops(struct wlan_objmgr_psoc * psoc)63 target_if_cp_stats_get_tx_ops(struct wlan_objmgr_psoc *psoc)
64 {
65 struct wlan_lmac_if_tx_ops *tx_ops;
66
67 tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
68 if (!tx_ops) {
69 cp_stats_err("tx_ops is NULL");
70 return NULL;
71 }
72
73 return &tx_ops->cp_stats_tx_ops;
74 }
75
76 /**
77 * target_if_cp_stats_register_tx_ops() - define cp_stats lmac tx ops functions
78 * @tx_ops: pointer to lmac tx ops
79 *
80 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
81 */
82 QDF_STATUS
83 target_if_cp_stats_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
84
85 #ifdef WLAN_SUPPORT_LEGACY_CP_STATS_HANDLERS
86 /**
87 * target_if_cp_stats_register_legacy_event_handler() - Register handler
88 * specific to legacy components
89 * @psoc: pointer to psoc object
90 *
91 * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
92 * failure
93 */
94 QDF_STATUS
95 target_if_cp_stats_register_legacy_event_handler(struct wlan_objmgr_psoc *psoc);
96
97 /**
98 * target_if_cp_stats_unregister_legacy_event_handler() - Unregister handler
99 * specific to legacy components
100 * @psoc: pointer to psoc object
101 *
102 * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
103 * failure
104 */
105 QDF_STATUS
106 target_if_cp_stats_unregister_legacy_event_handler(
107 struct wlan_objmgr_psoc *psoc);
108 #else
109
110 static inline QDF_STATUS
target_if_cp_stats_register_legacy_event_handler(struct wlan_objmgr_psoc * psoc)111 target_if_cp_stats_register_legacy_event_handler(struct wlan_objmgr_psoc *psoc)
112 {
113 return QDF_STATUS_SUCCESS;
114 }
115
116 static inline QDF_STATUS
target_if_cp_stats_unregister_legacy_event_handler(struct wlan_objmgr_psoc * psoc)117 target_if_cp_stats_unregister_legacy_event_handler(
118 struct wlan_objmgr_psoc *psoc)
119 {
120 return QDF_STATUS_SUCCESS;
121 }
122 #endif /* WLAN_SUPPORT_LEGACY_CP_STATS_HANDLERS */
123
124 #ifdef WLAN_CHIPSET_STATS
125
126 /**
127 * target_if_cp_stats_is_service_cstats_enabled() - Interface to check and
128 * return whether FW support Chipset Stats logging or not
129 * @psoc: pointer to psoc object
130 * @is_fw_support_cstats: True if feature is supported by FW else False
131 *
132 * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
133 * failure
134 */
135 QDF_STATUS
136 target_if_cp_stats_is_service_cstats_enabled(struct wlan_objmgr_psoc *psoc,
137 bool *is_fw_support_cstats);
138 #else
139 static inline QDF_STATUS
target_if_cp_stats_is_service_cstats_enabled(struct wlan_objmgr_psoc * psoc,bool * is_fw_support_cstats)140 target_if_cp_stats_is_service_cstats_enabled(struct wlan_objmgr_psoc *psoc,
141 bool *is_fw_support_cstats)
142 {
143 return QDF_STATUS_E_NOSUPPORT;
144 }
145 #endif
146
147 #else
148 static inline QDF_STATUS
target_if_cp_stats_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)149 target_if_cp_stats_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
150 {
151 return QDF_STATUS_SUCCESS;
152 }
153 #endif /* QCA_SUPPORT_CP_STATS */
154
155 #endif /* __TARGET_IF_CP_STATS_H__ */
156