1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 /** 28 * @file cdp_txrx_host_stats.h 29 * @brief Define the host data path stats API functions 30 * called by the host control SW and the OS interface module 31 */ 32 #ifndef _CDP_TXRX_HOST_STATS_H_ 33 #define _CDP_TXRX_HOST_STATS_H_ 34 #include "cdp_txrx_handle.h" 35 /** 36 * cdp_host_stats_get: cdp call to get host stats 37 * @soc: SOC handle 38 * @req: Requirement type 39 * 40 * return: 0 for Success, Failure returns error message 41 */ 42 static inline int cdp_host_stats_get(ol_txrx_soc_handle soc, 43 struct cdp_vdev *vdev, 44 struct ol_txrx_stats_req *req) 45 { 46 if (!soc || !soc->ops) { 47 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 48 "%s: Invalid Instance", __func__); 49 QDF_BUG(0); 50 return 0; 51 } 52 53 if (!soc->ops->host_stats_ops || 54 !soc->ops->host_stats_ops->txrx_host_stats_get) 55 return 0; 56 57 return soc->ops->host_stats_ops->txrx_host_stats_get(vdev, req); 58 } 59 60 /** 61 * cdp_host_stats_clr: cdp call to clear host stats 62 * @vdev: vdev handle 63 * 64 * return: void 65 */ 66 static inline void 67 cdp_host_stats_clr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 68 { 69 if (!soc || !soc->ops) { 70 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 71 "%s: Invalid Instance", __func__); 72 QDF_BUG(0); 73 return; 74 } 75 76 if (!soc->ops->host_stats_ops || 77 !soc->ops->host_stats_ops->txrx_host_stats_clr) 78 return; 79 80 soc->ops->host_stats_ops->txrx_host_stats_clr(vdev); 81 } 82 83 static inline void 84 cdp_host_ce_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 85 { 86 if (!soc || !soc->ops) { 87 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 88 "%s: Invalid Instance", __func__); 89 QDF_BUG(0); 90 return; 91 } 92 93 if (!soc->ops->host_stats_ops || 94 !soc->ops->host_stats_ops->txrx_host_ce_stats) 95 return; 96 97 soc->ops->host_stats_ops->txrx_host_ce_stats(vdev); 98 } 99 100 static inline int cdp_stats_publish 101 (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 102 struct ol_txrx_stats *buf) 103 { 104 if (!soc || !soc->ops) { 105 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 106 "%s: Invalid Instance", __func__); 107 QDF_BUG(0); 108 return 0; 109 } 110 111 if (!soc->ops->host_stats_ops || 112 !soc->ops->host_stats_ops->txrx_stats_publish) 113 return 0; 114 115 return soc->ops->host_stats_ops->txrx_stats_publish(pdev, buf); 116 } 117 118 /** 119 * @brief Enable enhanced stats functionality. 120 * 121 * @param pdev - the physical device object 122 * @return - void 123 */ 124 static inline void 125 cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 126 { 127 if (!soc || !soc->ops) { 128 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 129 "%s: Invalid Instance", __func__); 130 QDF_BUG(0); 131 return; 132 } 133 134 if (!soc->ops->host_stats_ops || 135 !soc->ops->host_stats_ops->txrx_enable_enhanced_stats) 136 return; 137 138 soc->ops->host_stats_ops->txrx_enable_enhanced_stats 139 (pdev); 140 } 141 142 /** 143 * @brief Disable enhanced stats functionality. 144 * 145 * @param pdev - the physical device object 146 * @return - void 147 */ 148 static inline void 149 cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 150 { 151 if (!soc || !soc->ops) { 152 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 153 "%s: Invalid Instance", __func__); 154 QDF_BUG(0); 155 return; 156 } 157 158 if (!soc->ops->host_stats_ops || 159 !soc->ops->host_stats_ops->txrx_disable_enhanced_stats) 160 return; 161 162 soc->ops->host_stats_ops->txrx_disable_enhanced_stats 163 (pdev); 164 } 165 166 /** 167 * @brief Get the desired stats from the message. 168 * 169 * @param pdev - the physical device object 170 * @param stats_base - stats buffer recieved from FW 171 * @param type - stats type. 172 * @return - pointer to requested stat identified by type 173 */ 174 static inline uint32_t *cdp_get_stats_base 175 (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 176 uint32_t *stats_base, uint32_t msg_len, uint8_t type) 177 { 178 if (!soc || !soc->ops) { 179 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 180 "%s: Invalid Instance", __func__); 181 QDF_BUG(0); 182 return 0; 183 } 184 185 if (!soc->ops->host_stats_ops || 186 !soc->ops->host_stats_ops->txrx_get_stats_base) 187 return 0; 188 189 return (uint32_t *)soc->ops->host_stats_ops->txrx_get_stats_base 190 (pdev, stats_base, msg_len, type); 191 } 192 193 static inline void 194 cdp_tx_print_tso_stats(ol_txrx_soc_handle soc, 195 struct cdp_vdev *vdev) 196 { 197 if (!soc || !soc->ops) { 198 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 199 "%s: Invalid Instance", __func__); 200 QDF_BUG(0); 201 return; 202 } 203 204 if (!soc->ops->host_stats_ops || 205 !soc->ops->host_stats_ops->tx_print_tso_stats) 206 return; 207 208 soc->ops->host_stats_ops->tx_print_tso_stats(vdev); 209 } 210 211 static inline void 212 cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 213 { 214 if (!soc || !soc->ops) { 215 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 216 "%s: Invalid Instance", __func__); 217 QDF_BUG(0); 218 return; 219 } 220 221 if (!soc->ops->host_stats_ops || 222 !soc->ops->host_stats_ops->tx_rst_tso_stats) 223 return; 224 225 soc->ops->host_stats_ops->tx_rst_tso_stats(vdev); 226 } 227 228 static inline void 229 cdp_tx_print_sg_stats(ol_txrx_soc_handle soc, 230 struct cdp_vdev *vdev) 231 { 232 if (!soc || !soc->ops) { 233 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 234 "%s: Invalid Instance", __func__); 235 QDF_BUG(0); 236 return; 237 } 238 239 if (!soc->ops->host_stats_ops || 240 !soc->ops->host_stats_ops->tx_print_sg_stats) 241 return; 242 243 soc->ops->host_stats_ops->tx_print_sg_stats(vdev); 244 } 245 246 static inline void 247 cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 248 { 249 if (!soc || !soc->ops) { 250 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 251 "%s: Invalid Instance", __func__); 252 QDF_BUG(0); 253 return; 254 } 255 256 if (!soc->ops->host_stats_ops || 257 !soc->ops->host_stats_ops->tx_rst_sg_stats) 258 return; 259 260 soc->ops->host_stats_ops->tx_rst_sg_stats(vdev); 261 } 262 263 static inline void 264 cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc, 265 struct cdp_vdev *vdev) 266 { 267 if (!soc || !soc->ops) { 268 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 269 "%s: Invalid Instance", __func__); 270 QDF_BUG(0); 271 return; 272 } 273 274 if (!soc->ops->host_stats_ops || 275 !soc->ops->host_stats_ops->print_rx_cksum_stats) 276 return; 277 278 soc->ops->host_stats_ops->print_rx_cksum_stats(vdev); 279 } 280 281 static inline void 282 cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 283 { 284 if (!soc || !soc->ops) { 285 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 286 "%s: Invalid Instance", __func__); 287 QDF_BUG(0); 288 return; 289 } 290 291 if (!soc->ops->host_stats_ops || 292 !soc->ops->host_stats_ops->rst_rx_cksum_stats) 293 return; 294 295 soc->ops->host_stats_ops->rst_rx_cksum_stats(vdev); 296 } 297 298 static inline A_STATUS 299 cdp_host_me_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 300 { 301 if (!soc || !soc->ops) { 302 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 303 "%s: Invalid Instance", __func__); 304 QDF_BUG(0); 305 return 0; 306 } 307 308 if (!soc->ops->host_stats_ops || 309 !soc->ops->host_stats_ops->txrx_host_me_stats) 310 return 0; 311 312 return soc->ops->host_stats_ops->txrx_host_me_stats(vdev); 313 } 314 315 static inline void cdp_per_peer_stats 316 (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, char *addr) 317 { 318 if (!soc || !soc->ops) { 319 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 320 "%s: Invalid Instance", __func__); 321 QDF_BUG(0); 322 return; 323 } 324 325 if (!soc->ops->host_stats_ops || 326 !soc->ops->host_stats_ops->txrx_per_peer_stats) 327 return; 328 329 soc->ops->host_stats_ops->txrx_per_peer_stats 330 (pdev, addr); 331 } 332 333 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc, 334 struct cdp_vdev *vdev, 335 struct ol_txrx_stats_req *req) 336 { 337 if (!soc || !soc->ops) { 338 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 339 "%s: Invalid Instance", __func__); 340 QDF_BUG(0); 341 return 0; 342 } 343 344 if (!soc->ops->host_stats_ops || 345 !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats) 346 return 0; 347 348 return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats 349 (vdev, req); 350 } 351 352 static inline void 353 cdp_print_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 354 { 355 if (!soc || !soc->ops) { 356 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 357 "%s: Invalid Instance", __func__); 358 QDF_BUG(0); 359 return; 360 } 361 362 if (!soc->ops->host_stats_ops || 363 !soc->ops->host_stats_ops->print_lro_stats) 364 return; 365 366 soc->ops->host_stats_ops->print_lro_stats(vdev); 367 } 368 369 static inline void 370 cdp_reset_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 371 { 372 if (!soc || !soc->ops) { 373 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 374 "%s: Invalid Instance", __func__); 375 QDF_BUG(0); 376 return; 377 } 378 379 if (!soc->ops->host_stats_ops || 380 !soc->ops->host_stats_ops->reset_lro_stats) 381 return; 382 383 soc->ops->host_stats_ops->reset_lro_stats(vdev); 384 } 385 386 static inline void cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc, 387 struct cdp_pdev *pdev, uint8_t *mac, uint32_t caps) 388 { 389 if (!soc || !soc->ops) { 390 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 391 "%s: Invalid Instance", __func__); 392 QDF_BUG(0); 393 return; 394 } 395 396 if (!soc->ops->host_stats_ops || 397 !soc->ops->host_stats_ops->get_fw_peer_stats) 398 return; 399 400 soc->ops->host_stats_ops->get_fw_peer_stats 401 (pdev, mac, caps); 402 } 403 404 static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc, 405 struct cdp_pdev *pdev, 406 void *data, uint32_t data_len) 407 { 408 if (soc->ops->host_stats_ops->get_htt_stats) 409 return soc->ops->host_stats_ops->get_htt_stats 410 (pdev, data, data_len); 411 return; 412 } 413 414 /** 415 * @brief Parse the stats header and get the payload from the message. 416 * 417 * @param pdev - the physical device object 418 * @param msg_word - stats buffer recieved from FW 419 * @param msg_len - length of the message 420 * @param type - place holder for parsed message type 421 * @param status - place holder for parsed message status 422 * @return - pointer to received stat payload 423 */ 424 425 #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS) 426 uint32_t *ol_txrx_get_en_stats_base(struct cdp_pdev *pdev, uint32_t *msg_word, 427 uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type, enum htt_cmn_t2h_en_stats_status *status); 428 #endif 429 #endif /* _CDP_TXRX_HOST_STATS_H_ */ 430