Home | History | Annotate | Download | only in wifi_hal
      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 #include "vendor_definitions.h"
     37 
     38 #ifdef __cplusplus
     39 extern "C"
     40 {
     41 #endif /* __cplusplus */
     42 
     43 #define POWER_EVENTS_RB_BUF_SIZE 2048
     44 #define POWER_EVENTS_NUM_BUFS    4
     45 
     46 #define CONNECTIVITY_EVENTS_RB_BUF_SIZE 4096
     47 #define CONNECTIVITY_EVENTS_NUM_BUFS    4
     48 
     49 #define PKT_STATS_RB_BUF_SIZE 4096
     50 #define PKT_STATS_NUM_BUFS    32
     51 
     52 #define DRIVER_PRINTS_RB_BUF_SIZE 4096
     53 #define DRIVER_PRINTS_NUM_BUFS    128
     54 
     55 #define FIRMWARE_PRINTS_RB_BUF_SIZE 32768
     56 #define FIRMWARE_PRINTS_NUM_BUFS    16
     57 
     58 #define LOGGER_RING_BUFFER (WIFI_LOGGER_CONNECT_EVENT_SUPPORTED \
     59                             | WIFI_LOGGER_POWER_EVENT_SUPPORTED \
     60                             | WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED)
     61 
     62 enum rb_info_indices {
     63     POWER_EVENTS_RB_ID = 0,
     64     CONNECTIVITY_EVENTS_RB_ID = 1,
     65     PKT_STATS_RB_ID = 2,
     66     DRIVER_PRINTS_RB_ID = 3,
     67     FIRMWARE_PRINTS_RB_ID = 4,
     68 };
     69 
     70 typedef struct {
     71   void (*on_firmware_memory_dump) (char *buffer,
     72                                    int buffer_size);
     73 
     74 } WifiLoggerCallbackHandler;
     75 
     76 
     77 class WifiLoggerCommand : public WifiVendorCommand
     78 {
     79 private:
     80     WifiLoggerCallbackHandler mHandler;
     81     char                      *mVersion;
     82     int                       mVersionLen;
     83     u32                       *mSupportedSet;
     84     int                       mRequestId;
     85     bool                      mWaitforRsp;
     86     bool                      mMoreData;
     87     WLAN_DRIVER_WAKE_REASON_CNT *mGetWakeStats;
     88 public:
     89 
     90     WifiLoggerCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd);
     91 
     92     static WifiLoggerCommand* instance(wifi_handle handle);
     93     virtual ~WifiLoggerCommand();
     94 
     95     // This function implements creation of WifiLogger specific Request
     96     // based on  the request type
     97     virtual wifi_error create();
     98     virtual wifi_error requestEvent();
     99     virtual wifi_error requestResponse();
    100     virtual int handleResponse(WifiEvent &reply);
    101     virtual int handleEvent(WifiEvent &event);
    102     wifi_error setCallbackHandler(WifiLoggerCallbackHandler nHandler);
    103     virtual void unregisterHandler(u32 subCmd);
    104 
    105     /* Takes wait time in seconds. */
    106     virtual wifi_error timed_wait(u16 wait_time);
    107     virtual void waitForRsp(bool wait);
    108     virtual void setVersionInfo(char *buffer, int buffer_size);
    109     virtual void setFeatureSet(u32 *support);
    110     virtual void getWakeStatsRspParams(
    111                     WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt);
    112 };
    113 void rb_timerhandler(hal_info *info);
    114 wifi_error wifi_logger_ring_buffers_init(hal_info *info);
    115 void wifi_logger_ring_buffers_deinit(hal_info *info);
    116 void push_out_all_ring_buffers(hal_info *info);
    117 void send_alert(hal_info *info, int reason_code);
    118 #ifdef __cplusplus
    119 }
    120 #endif /* __cplusplus */
    121 #endif /* __WIFI_HAL_WIFILOGGER_COMMAND_H__ */
    122