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