1
2
3
4
5
6
7#ifndef WILC_WFI_NETDEVICE
8#define WILC_WFI_NETDEVICE
9
10#include <linux/tcp.h>
11#include <linux/ieee80211.h>
12#include <net/cfg80211.h>
13#include <net/ieee80211_radiotap.h>
14#include <linux/if_arp.h>
15#include <linux/gpio/consumer.h>
16
17#include "host_interface.h"
18#include "wilc_wlan.h"
19#include "wilc_wlan_cfg.h"
20
21#define FLOW_CONTROL_LOWER_THRESHOLD 128
22#define FLOW_CONTROL_UPPER_THRESHOLD 256
23
24#define WILC_MAX_NUM_PMKIDS 16
25#define PMKID_LEN 16
26#define PMKID_FOUND 1
27#define NUM_STA_ASSOCIATED 8
28
29#define NUM_REG_FRAME 2
30
31#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
32#define DEFAULT_LINK_SPEED 72
33
34#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
35
36struct wilc_wfi_stats {
37 unsigned long rx_packets;
38 unsigned long tx_packets;
39 unsigned long rx_bytes;
40 unsigned long tx_bytes;
41 u64 rx_time;
42 u64 tx_time;
43
44};
45
46struct wilc_wfi_key {
47 u8 *key;
48 u8 *seq;
49 int key_len;
50 int seq_len;
51 u32 cipher;
52};
53
54struct wilc_wfi_wep_key {
55 u8 *key;
56 u8 key_len;
57 u8 key_idx;
58};
59
60struct sta_info {
61 u8 sta_associated_bss[MAX_NUM_STA][ETH_ALEN];
62};
63
64
65struct wilc_wfi_p2p_listen_params {
66 struct ieee80211_channel *listen_ch;
67 u32 listen_duration;
68 u64 listen_cookie;
69 u32 listen_session_id;
70};
71
72struct wilc_p2p_var {
73 u8 local_random;
74 u8 recv_random;
75 bool is_wilc_ie;
76};
77
78struct wilc_priv {
79 struct wireless_dev *wdev;
80 struct cfg80211_scan_request *scan_req;
81
82 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
83 u64 tx_cookie;
84
85 bool cfg_scanning;
86 u32 rcvd_ch_cnt;
87
88 u8 associated_bss[ETH_ALEN];
89 struct sta_info assoc_stainfo;
90 struct sk_buff *skb;
91 struct net_device *dev;
92 struct host_if_drv *hif_drv;
93 struct host_if_pmkid_attr pmkid_list;
94 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
95 u8 wep_key_len[4];
96
97 struct net_device *real_ndev;
98 struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
99 struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
100 u8 wilc_groupkey;
101
102 struct mutex scan_req_lock;
103 bool p2p_listen_state;
104 struct timer_list aging_timer;
105 struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
106 int scanned_cnt;
107 struct wilc_p2p_var p2p;
108};
109
110struct frame_reg {
111 u16 type;
112 bool reg;
113};
114
115#define MAX_TCP_SESSION 25
116#define MAX_PENDING_ACKS 256
117
118struct ack_session_info {
119 u32 seq_num;
120 u32 bigger_ack_num;
121 u16 src_port;
122 u16 dst_port;
123 u16 status;
124};
125
126struct pending_acks {
127 u32 ack_num;
128 u32 session_index;
129 struct txq_entry_t *txqe;
130};
131
132struct tcp_ack_filter {
133 struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];
134 struct pending_acks pending_acks[MAX_PENDING_ACKS];
135 u32 pending_base;
136 u32 tcp_session;
137 u32 pending_acks_idx;
138 bool enabled;
139};
140
141struct wilc_vif {
142 u8 idx;
143 u8 iftype;
144 int monitor_flag;
145 int mac_opened;
146 struct frame_reg frame_reg[NUM_REG_FRAME];
147 struct net_device_stats netstats;
148 struct wilc *wilc;
149 u8 src_addr[ETH_ALEN];
150 u8 bssid[ETH_ALEN];
151 struct host_if_drv *hif_drv;
152 struct net_device *ndev;
153 u8 mode;
154 u8 ifc_id;
155 struct timer_list during_ip_timer;
156 bool obtaining_ip;
157 struct timer_list periodic_rssi;
158 struct rf_info periodic_stat;
159 struct tcp_ack_filter ack_filter;
160 bool connecting;
161};
162
163struct wilc {
164 const struct wilc_hif_func *hif_func;
165 int io_type;
166 s8 mac_status;
167 struct gpio_desc *gpio_irq;
168 bool initialized;
169 int dev_irq_num;
170 int close;
171 u8 vif_num;
172 struct wilc_vif *vif[NUM_CONCURRENT_IFC];
173 u8 open_ifcs;
174
175 struct mutex txq_add_to_head_cs;
176
177 spinlock_t txq_spinlock;
178
179 struct mutex rxq_cs;
180
181 struct mutex hif_cs;
182
183 struct completion cfg_event;
184 struct completion sync_event;
185 struct completion txq_event;
186 struct completion txq_thread_started;
187
188 struct task_struct *txq_thread;
189
190 int quit;
191 int cfg_frame_in_use;
192 struct wilc_cfg_frame cfg_frame;
193 u32 cfg_frame_offset;
194 int cfg_seq_no;
195
196 u8 *rx_buffer;
197 u32 rx_buffer_offset;
198 u8 *tx_buffer;
199
200 struct txq_entry_t txq_head;
201 int txq_entries;
202
203 struct rxq_entry_t rxq_head;
204
205 const struct firmware *firmware;
206
207 struct device *dev;
208 bool suspend_event;
209
210 bool enable_ps;
211 int clients_count;
212 struct workqueue_struct *hif_workqueue;
213 enum chip_ps_states chip_ps_state;
214 struct wilc_cfg cfg;
215 void *bus_data;
216};
217
218struct wilc_wfi_mon_priv {
219 struct net_device *real_ndev;
220};
221
222void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
223void wilc_mac_indicate(struct wilc *wilc);
224void wilc_netdev_cleanup(struct wilc *wilc);
225int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
226 const struct wilc_hif_func *ops);
227void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
228void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
229
230#endif
231