1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __WIFI_HAL_LLSTATSCOMMAND_H__ 18 #define __WIFI_HAL_LLSTATSCOMMAND_H__ 19 20 #include <stdint.h> 21 #include <fcntl.h> 22 #include <sys/socket.h> 23 #include <netlink/genl/genl.h> 24 #include <netlink/genl/family.h> 25 #include <netlink/genl/ctrl.h> 26 #include <linux/rtnetlink.h> 27 #include <netpacket/packet.h> 28 #include <linux/filter.h> 29 #include <linux/errqueue.h> 30 31 #include <linux/pkt_sched.h> 32 #include <netlink/object-api.h> 33 #include <netlink/netlink.h> 34 #include <netlink/socket.h> 35 #include <netlink-types.h> 36 #include <net/if.h> 37 38 #include "nl80211_copy.h" 39 #include "common.h" 40 #include "cpp_bindings.h" 41 #include "link_layer_stats.h" 42 #include "vendor_definitions.h" 43 44 #ifdef __GNUC__ 45 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b)))) 46 #define STRUCT_PACKED __attribute__ ((packed)) 47 #else 48 #define PRINTF_FORMAT(a,b) 49 #define STRUCT_PACKED 50 #endif 51 #include "qca-vendor.h" 52 53 #ifdef __cplusplus 54 extern "C" 55 { 56 #endif /* __cplusplus */ 57 58 /* Response and Event Callbacks */ 59 typedef struct { 60 /* Various Events Callback */ 61 void (*on_link_stats_results) (wifi_request_id id, 62 wifi_iface_stat *iface_stat, 63 int num_radios, 64 wifi_radio_stat *radio_stat); 65 } LLStatsCallbackHandler; 66 67 typedef struct{ 68 u32 stats_clear_rsp_mask; 69 u8 stop_rsp; 70 } LLStatsClearRspParams; 71 72 typedef struct{ 73 wifi_iface_stat *iface_stat; 74 int num_radios; 75 wifi_radio_stat *radio_stat; 76 } LLStatsResultsParams; 77 78 typedef enum{ 79 eLLStatsSetParamsInvalid = 0, 80 eLLStatsClearRspParams, 81 } eLLStatsRspRarams; 82 83 class LLStatsCommand: public WifiVendorCommand 84 { 85 private: 86 static LLStatsCommand *mLLStatsCommandInstance; 87 88 LLStatsClearRspParams mClearRspParams; 89 90 LLStatsResultsParams mResultsParams; 91 92 LLStatsCallbackHandler mHandler; 93 94 wifi_request_id mRequestId; 95 96 LLStatsCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 97 98 public: 99 static LLStatsCommand* instance(wifi_handle handle); 100 101 virtual ~LLStatsCommand(); 102 103 // This function implements creation of LLStats specific Request 104 // based on the request type 105 virtual int create(); 106 107 virtual void setSubCmd(u32 subcmd); 108 109 virtual void initGetContext(u32 reqid); 110 111 virtual int requestResponse(); 112 113 virtual int handleResponse(WifiEvent &reply); 114 115 virtual int handleEvent(WifiEvent &event); 116 117 virtual int setCallbackHandler(LLStatsCallbackHandler nHandler, u32 event); 118 119 virtual void unregisterHandler(u32 subCmd); 120 121 virtual void getClearRspParams(u32 *stats_clear_rsp_mask, u8 *stop_rsp); 122 }; 123 124 #ifdef __cplusplus 125 } 126 #endif /* __cplusplus */ 127 #endif 128