1 /* Copyright (c) 2015, 2018 The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions 5 * are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef __WIFI_HAL_WIFILOGGER_COMMAND_H__ 30 #define __WIFI_HAL_WIFILOGGER_COMMAND_H__ 31 32 #include "common.h" 33 #include "cpp_bindings.h" 34 #include "wifi_logger.h" 35 #include "wifilogger_diag.h" 36 37 #ifdef __cplusplus 38 extern "C" 39 { 40 #endif /* __cplusplus */ 41 42 #define POWER_EVENTS_RB_BUF_SIZE 2048 43 #define POWER_EVENTS_NUM_BUFS 4 44 45 #define CONNECTIVITY_EVENTS_RB_BUF_SIZE 4096 46 #define CONNECTIVITY_EVENTS_NUM_BUFS 4 47 48 #define PKT_STATS_RB_BUF_SIZE 4096 49 #define PKT_STATS_NUM_BUFS 32 50 51 #define DRIVER_PRINTS_RB_BUF_SIZE 4096 52 #define DRIVER_PRINTS_NUM_BUFS 128 53 54 #define FIRMWARE_PRINTS_RB_BUF_SIZE 32768 55 #define FIRMWARE_PRINTS_NUM_BUFS 16 56 57 #define LOGGER_RING_BUFFER (WIFI_LOGGER_CONNECT_EVENT_SUPPORTED \ 58 | WIFI_LOGGER_POWER_EVENT_SUPPORTED \ 59 | WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED) 60 61 enum rb_info_indices { 62 POWER_EVENTS_RB_ID = 0, 63 CONNECTIVITY_EVENTS_RB_ID = 1, 64 PKT_STATS_RB_ID = 2, 65 DRIVER_PRINTS_RB_ID = 3, 66 FIRMWARE_PRINTS_RB_ID = 4, 67 }; 68 69 typedef struct { 70 void (*on_firmware_memory_dump) (char *buffer, 71 int buffer_size); 72 73 } WifiLoggerCallbackHandler; 74 75 76 class WifiLoggerCommand : public WifiVendorCommand 77 { 78 private: 79 WifiLoggerCallbackHandler mHandler; 80 char *mVersion; 81 int mVersionLen; 82 u32 *mSupportedSet; 83 int mRequestId; 84 bool mWaitforRsp; 85 bool mMoreData; 86 WLAN_DRIVER_WAKE_REASON_CNT *mGetWakeStats; 87 public: 88 89 WifiLoggerCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 90 91 static WifiLoggerCommand* instance(wifi_handle handle); 92 virtual ~WifiLoggerCommand(); 93 94 // This function implements creation of WifiLogger specific Request 95 // based on the request type 96 virtual wifi_error create(); 97 virtual wifi_error requestEvent(); 98 virtual wifi_error requestResponse(); 99 virtual int handleResponse(WifiEvent &reply); 100 virtual int handleEvent(WifiEvent &event); 101 wifi_error setCallbackHandler(WifiLoggerCallbackHandler nHandler); 102 virtual void unregisterHandler(u32 subCmd); 103 104 /* Takes wait time in seconds. */ 105 virtual wifi_error timed_wait(u16 wait_time); 106 virtual void waitForRsp(bool wait); 107 virtual void setVersionInfo(char *buffer, int buffer_size); 108 virtual void setFeatureSet(u32 *support); 109 virtual void getWakeStatsRspParams( 110 WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt); 111 }; 112 void rb_timerhandler(hal_info *info); 113 wifi_error wifi_logger_ring_buffers_init(hal_info *info); 114 void wifi_logger_ring_buffers_deinit(hal_info *info); 115 void push_out_all_ring_buffers(hal_info *info); 116 void send_alert(hal_info *info, int reason_code); 117 #ifdef __cplusplus 118 } 119 #endif /* __cplusplus */ 120 #endif /* __WIFI_HAL_WIFILOGGER_COMMAND_H__ */ 121