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 <net/if.h> 36 37 #include "nl80211_copy.h" 38 #include "common.h" 39 #include "cpp_bindings.h" 40 #include "link_layer_stats.h" 41 42 #ifdef __GNUC__ 43 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b)))) 44 #define STRUCT_PACKED __attribute__ ((packed)) 45 #else 46 #define PRINTF_FORMAT(a,b) 47 #define STRUCT_PACKED 48 #endif 49 50 #ifdef __cplusplus 51 extern "C" 52 { 53 #endif /* __cplusplus */ 54 55 typedef struct{ 56 u32 stats_clear_rsp_mask; 57 u8 stop_rsp; 58 } LLStatsClearRspParams; 59 60 typedef struct{ 61 wifi_iface_stat *iface_stat; 62 int num_radios; 63 wifi_radio_stat *radio_stat; 64 } LLStatsResultsParams; 65 66 typedef enum{ 67 eLLStatsSetParamsInvalid = 0, 68 eLLStatsClearRspParams, 69 } eLLStatsRspRarams; 70 71 class LLStatsCommand: public WifiVendorCommand 72 { 73 private: 74 static LLStatsCommand *mLLStatsCommandInstance; 75 76 LLStatsClearRspParams mClearRspParams; 77 78 LLStatsResultsParams mResultsParams; 79 80 wifi_stats_result_handler mHandler; 81 82 wifi_request_id mRequestId; 83 84 u32 mRadioStatsSize; 85 86 u8 mNumRadios; 87 88 LLStatsCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 89 90 public: 91 static LLStatsCommand* instance(wifi_handle handle); 92 93 virtual ~LLStatsCommand(); 94 95 // This function implements creation of LLStats specific Request 96 // based on the request type 97 virtual wifi_error create(); 98 99 virtual void setSubCmd(u32 subcmd); 100 101 virtual void initGetContext(u32 reqid); 102 103 virtual wifi_error requestResponse(); 104 105 virtual wifi_error notifyResponse(); 106 107 virtual int handleResponse(WifiEvent &reply); 108 109 virtual void getClearRspParams(u32 *stats_clear_rsp_mask, u8 *stop_rsp); 110 111 virtual wifi_error get_wifi_iface_stats(wifi_iface_stat *stats, 112 struct nlattr **tb_vendor); 113 114 virtual void setHandler(wifi_stats_result_handler handler); 115 116 virtual void clearStats(); 117 }; 118 119 #ifdef __cplusplus 120 } 121 #endif /* __cplusplus */ 122 #endif 123