1bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif/* Copyright (c) 2015, The Linux Foundation. All rights reserved. 2bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * 3bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * Redistribution and use in source and binary forms, with or without 4bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * modification, are permitted provided that the following conditions 5bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * are met: 6bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * * Redistributions of source code must retain the above copyright 7bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * notice, this list of conditions and the following disclaimer. 8bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * * Redistributions in binary form must reproduce the above 9bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * copyright notice, this list of conditions and the following 10bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * disclaimer in the documentation and/or other materials provided 11bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * with the distribution. 12bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * * Neither the name of The Linux Foundation nor the names of its 13bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * contributors may be used to endorse or promote products derived 14bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * from this software without specific prior written permission. 15bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * 16bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif */ 28bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 29bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#ifndef __WIFI_HAL_WIFILOGGER_COMMAND_H__ 305c63f6a5f46ca95fe003bac5cfae2fc74a0b22a7Subhani Shaik#define __WIFI_HAL_WIFILOGGER_COMMAND_H__ 31bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 32bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#include "common.h" 33bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#include "cpp_bindings.h" 34bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#include "wifi_logger.h" 3576cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#include "wifilogger_diag.h" 36bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#include "vendor_definitions.h" 37bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 38bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#ifdef __cplusplus 39bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaifextern "C" 40bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif{ 41bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#endif /* __cplusplus */ 42bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 4376cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define POWER_EVENTS_RB_BUF_SIZE 2048 4476cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define POWER_EVENTS_NUM_BUFS 4 4576cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik 4676cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define CONNECTIVITY_EVENTS_RB_BUF_SIZE 4096 4776cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define CONNECTIVITY_EVENTS_NUM_BUFS 4 4876cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik 4976cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define PKT_STATS_RB_BUF_SIZE 4096 5076cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik#define PKT_STATS_NUM_BUFS 32 5176cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik 522e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam#define DRIVER_PRINTS_RB_BUF_SIZE 4096 532e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam#define DRIVER_PRINTS_NUM_BUFS 128 542e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam 552e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam#define FIRMWARE_PRINTS_RB_BUF_SIZE 4096 562e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam#define FIRMWARE_PRINTS_NUM_BUFS 128 572e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam 5876cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaikenum rb_info_indices { 5976cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik POWER_EVENTS_RB_ID = 0, 6076cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik CONNECTIVITY_EVENTS_RB_ID = 1, 612e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam PKT_STATS_RB_ID = 2, 622e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam DRIVER_PRINTS_RB_ID = 3, 632e1716c72278e0c1f9165c65e7017551c6e6eb26Amarnath Hullur Subramanyam FIRMWARE_PRINTS_RB_ID = 4, 6476cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik}; 65bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 66bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaiftypedef struct { 67a3646e05955c1ff9681ea5769d0f45a3f4da28f9Subhani Shaik void (*on_firmware_memory_dump) (char *buffer, 68a3646e05955c1ff9681ea5769d0f45a3f4da28f9Subhani Shaik int buffer_size); 69a3646e05955c1ff9681ea5769d0f45a3f4da28f9Subhani Shaik 70bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif} WifiLoggerCallbackHandler; 71bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 72bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 73bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaifclass WifiLoggerCommand : public WifiVendorCommand 74bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif{ 75bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaifprivate: 76bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif WifiLoggerCallbackHandler mHandler; 77d8ed4ebe4c7e317ae378e297d61ad236d0a2a079Amarnath Hullur Subramanyam char *mVersion; 78d8ed4ebe4c7e317ae378e297d61ad236d0a2a079Amarnath Hullur Subramanyam int mVersionLen; 7976cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik u32 *mSupportedSet; 80a3646e05955c1ff9681ea5769d0f45a3f4da28f9Subhani Shaik int mRequestId; 81bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif bool mWaitforRsp; 82a3646e05955c1ff9681ea5769d0f45a3f4da28f9Subhani Shaik bool mMoreData; 83e07632b3a892c6e927a7fb2bce7e39b9f2a01281Amarnath Hullur Subramanyam WLAN_DRIVER_WAKE_REASON_CNT *mGetWakeStats; 84bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaifpublic: 85bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 86bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif WifiLoggerCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 87bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 88bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif static WifiLoggerCommand* instance(wifi_handle handle); 89bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual ~WifiLoggerCommand(); 90bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 91bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif // This function implements creation of WifiLogger specific Request 92bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif // based on the request type 93bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int create(); 94bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int requestEvent(); 95bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int requestResponse(); 96bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int handleResponse(WifiEvent &reply); 97bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int handleEvent(WifiEvent &event); 98bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif int setCallbackHandler(WifiLoggerCallbackHandler nHandler); 99bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual void unregisterHandler(u32 subCmd); 100bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif 101bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif /* Takes wait time in seconds. */ 102bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual int timed_wait(u16 wait_time); 103bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif virtual void waitForRsp(bool wait); 104d8ed4ebe4c7e317ae378e297d61ad236d0a2a079Amarnath Hullur Subramanyam virtual void setVersionInfo(char *buffer, int buffer_size); 10576cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaik virtual void setFeatureSet(u32 *support); 106e07632b3a892c6e927a7fb2bce7e39b9f2a01281Amarnath Hullur Subramanyam virtual void getWakeStatsRspParams( 107e07632b3a892c6e927a7fb2bce7e39b9f2a01281Amarnath Hullur Subramanyam WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt); 108bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif}; 10976cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaikvoid rb_timerhandler(hal_info *info); 11076cff4cb3188c57d6043ead1932135346d1eb624Subhani Shaikwifi_error wifi_logger_ring_buffers_init(hal_info *info); 1110b89754a29ef5fe71f79330afc351e027026bf69Amarnath Hullur Subramanyamvoid wifi_logger_ring_buffers_deinit(hal_info *info); 112063058fd392c1b473c003ba33ca7f4eeef418a0cAmarnath Hullur Subramanyamvoid push_out_all_ring_buffers(hal_info *info); 113063058fd392c1b473c003ba33ca7f4eeef418a0cAmarnath Hullur Subramanyamvoid send_alert(hal_info *info, int reason_code); 114bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#ifdef __cplusplus 115bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif} 116bb264a2fe0376f88af5e27ae8daa6112749f1e59Ahmad Kholaif#endif /* __cplusplus */ 1175c63f6a5f46ca95fe003bac5cfae2fc74a0b22a7Subhani Shaik#endif /* __WIFI_HAL_WIFILOGGER_COMMAND_H__ */ 118