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