1 /*
2  * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "whd_debug.h"
19 #include "whd_int.h"
20 #include "bus_protocols/whd_bus_protocol_interface.h"
21 
22 /******************************************************
23 *             Constants
24 ******************************************************/
25 
26 /******************************************************
27 *             Structures
28 ******************************************************/
29 
30 /******************************************************
31 *             Variables
32 ******************************************************/
33 
34 /******************************************************
35 *             Function definitions
36 ******************************************************/
whd_init_stats(whd_driver_t whd_driver)37 void whd_init_stats(whd_driver_t whd_driver)
38 {
39     memset(&whd_driver->whd_stats, 0, sizeof(whd_driver->whd_stats) );
40 }
41 
whd_print_stats(whd_driver_t whd_driver,whd_bool_t reset_after_print)42 uint32_t whd_print_stats(whd_driver_t whd_driver, whd_bool_t reset_after_print)
43 {
44     CHECK_DRIVER_NULL(whd_driver);
45 
46     WPRINT_MACRO( ("WHD Stats.. \n"
47                    "tx_total:%" PRIu32 ", rx_total:%" PRIu32 ", tx_no_mem:%" PRIu32 ", rx_no_mem:%" PRIu32 "\n"
48                    "tx_fail:%" PRIu32 ", no_credit:%" PRIu32 ", flow_control:%" PRIu32 "\n",
49                    whd_driver->whd_stats.tx_total, whd_driver->whd_stats.rx_total,
50                    whd_driver->whd_stats.tx_no_mem, whd_driver->whd_stats.rx_no_mem,
51                    whd_driver->whd_stats.tx_fail, whd_driver->whd_stats.no_credit,
52                    whd_driver->whd_stats.flow_control) );
53 
54     if (reset_after_print == WHD_TRUE)
55     {
56         memset(&whd_driver->whd_stats, 0, sizeof(whd_driver->whd_stats) );
57     }
58 
59     CHECK_RETURN(whd_bus_print_stats(whd_driver, reset_after_print) );
60     return WHD_SUCCESS;
61 }
62 
63