treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / staging / wilc1000 / netdev.h
blobd5f7a6037fbc5021df89b8d4bd4851d03571cdb0
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
4 * All rights reserved.
5 */
7 #ifndef WILC_NETDEV_H
8 #define WILC_NETDEV_H
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>
17 #include "hif.h"
18 #include "wlan.h"
19 #include "wlan_cfg.h"
21 #define FLOW_CONTROL_LOWER_THRESHOLD 128
22 #define FLOW_CONTROL_UPPER_THRESHOLD 256
24 #define PMKID_FOUND 1
25 #define NUM_STA_ASSOCIATED 8
27 #define NUM_REG_FRAME 2
29 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
30 #define DEFAULT_LINK_SPEED 72
32 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
34 struct wilc_wfi_stats {
35 unsigned long rx_packets;
36 unsigned long tx_packets;
37 unsigned long rx_bytes;
38 unsigned long tx_bytes;
39 u64 rx_time;
40 u64 tx_time;
44 struct wilc_wfi_key {
45 u8 *key;
46 u8 *seq;
47 int key_len;
48 int seq_len;
49 u32 cipher;
52 struct wilc_wfi_wep_key {
53 u8 *key;
54 u8 key_len;
55 u8 key_idx;
58 struct sta_info {
59 u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
62 /* Parameters needed for host interface for remaining on channel */
63 struct wilc_wfi_p2p_listen_params {
64 struct ieee80211_channel *listen_ch;
65 u32 listen_duration;
66 u64 listen_cookie;
69 struct wilc_p2p_var {
70 u8 local_random;
71 u8 recv_random;
72 bool is_wilc_ie;
75 static const u32 wilc_cipher_suites[] = {
76 WLAN_CIPHER_SUITE_WEP40,
77 WLAN_CIPHER_SUITE_WEP104,
78 WLAN_CIPHER_SUITE_TKIP,
79 WLAN_CIPHER_SUITE_CCMP,
80 WLAN_CIPHER_SUITE_AES_CMAC
83 #define CHAN2G(_channel, _freq, _flags) { \
84 .band = NL80211_BAND_2GHZ, \
85 .center_freq = (_freq), \
86 .hw_value = (_channel), \
87 .flags = (_flags), \
88 .max_antenna_gain = 0, \
89 .max_power = 30, \
92 static const struct ieee80211_channel wilc_2ghz_channels[] = {
93 CHAN2G(1, 2412, 0),
94 CHAN2G(2, 2417, 0),
95 CHAN2G(3, 2422, 0),
96 CHAN2G(4, 2427, 0),
97 CHAN2G(5, 2432, 0),
98 CHAN2G(6, 2437, 0),
99 CHAN2G(7, 2442, 0),
100 CHAN2G(8, 2447, 0),
101 CHAN2G(9, 2452, 0),
102 CHAN2G(10, 2457, 0),
103 CHAN2G(11, 2462, 0),
104 CHAN2G(12, 2467, 0),
105 CHAN2G(13, 2472, 0),
106 CHAN2G(14, 2484, 0)
109 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
110 .bitrate = (_rate), \
111 .hw_value = (_hw_value), \
112 .flags = (_flags), \
115 static struct ieee80211_rate wilc_bitrates[] = {
116 RATETAB_ENT(10, 0, 0),
117 RATETAB_ENT(20, 1, 0),
118 RATETAB_ENT(55, 2, 0),
119 RATETAB_ENT(110, 3, 0),
120 RATETAB_ENT(60, 9, 0),
121 RATETAB_ENT(90, 6, 0),
122 RATETAB_ENT(120, 7, 0),
123 RATETAB_ENT(180, 8, 0),
124 RATETAB_ENT(240, 9, 0),
125 RATETAB_ENT(360, 10, 0),
126 RATETAB_ENT(480, 11, 0),
127 RATETAB_ENT(540, 12, 0)
130 struct wilc_priv {
131 struct wireless_dev wdev;
132 struct cfg80211_scan_request *scan_req;
134 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
135 u64 tx_cookie;
137 bool cfg_scanning;
139 u8 associated_bss[ETH_ALEN];
140 struct sta_info assoc_stainfo;
141 struct sk_buff *skb;
142 struct net_device *dev;
143 struct host_if_drv *hif_drv;
144 struct wilc_pmkid_attr pmkid_list;
145 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
146 u8 wep_key_len[4];
148 /* The real interface that the monitor is on */
149 struct net_device *real_ndev;
150 struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
151 struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
152 u8 wilc_groupkey;
154 /* mutexes */
155 struct mutex scan_req_lock;
156 bool p2p_listen_state;
157 int scanned_cnt;
158 struct wilc_p2p_var p2p;
160 u64 inc_roc_cookie;
163 struct frame_reg {
164 u16 type;
165 bool reg;
168 #define MAX_TCP_SESSION 25
169 #define MAX_PENDING_ACKS 256
171 struct ack_session_info {
172 u32 seq_num;
173 u32 bigger_ack_num;
174 u16 src_port;
175 u16 dst_port;
176 u16 status;
179 struct pending_acks {
180 u32 ack_num;
181 u32 session_index;
182 struct txq_entry_t *txqe;
185 struct tcp_ack_filter {
186 struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];
187 struct pending_acks pending_acks[MAX_PENDING_ACKS];
188 u32 pending_base;
189 u32 tcp_session;
190 u32 pending_acks_idx;
191 bool enabled;
194 struct wilc_vif {
195 u8 idx;
196 u8 iftype;
197 int monitor_flag;
198 int mac_opened;
199 struct frame_reg frame_reg[NUM_REG_FRAME];
200 struct net_device_stats netstats;
201 struct wilc *wilc;
202 u8 bssid[ETH_ALEN];
203 struct host_if_drv *hif_drv;
204 struct net_device *ndev;
205 u8 mode;
206 struct timer_list during_ip_timer;
207 struct timer_list periodic_rssi;
208 struct rf_info periodic_stat;
209 struct tcp_ack_filter ack_filter;
210 bool connecting;
211 struct wilc_priv priv;
212 struct list_head list;
213 struct cfg80211_bss *bss;
216 struct wilc {
217 struct wiphy *wiphy;
218 const struct wilc_hif_func *hif_func;
219 int io_type;
220 s8 mac_status;
221 struct gpio_desc *gpio_irq;
222 struct clk *rtc_clk;
223 bool initialized;
224 int dev_irq_num;
225 int close;
226 u8 vif_num;
227 struct list_head vif_list;
229 /* protect vif list */
230 struct mutex vif_mutex;
231 struct srcu_struct srcu;
232 u8 open_ifcs;
234 /* protect head of transmit queue */
235 struct mutex txq_add_to_head_cs;
237 /* protect txq_entry_t transmit queue */
238 spinlock_t txq_spinlock;
240 /* protect rxq_entry_t receiver queue */
241 struct mutex rxq_cs;
243 /* lock to protect hif access */
244 struct mutex hif_cs;
246 struct completion cfg_event;
247 struct completion sync_event;
248 struct completion txq_event;
249 struct completion txq_thread_started;
251 struct task_struct *txq_thread;
253 int quit;
255 /* lock to protect issue of wid command to firmware */
256 struct mutex cfg_cmd_lock;
257 struct wilc_cfg_frame cfg_frame;
258 u32 cfg_frame_offset;
259 u8 cfg_seq_no;
261 u8 *rx_buffer;
262 u32 rx_buffer_offset;
263 u8 *tx_buffer;
265 struct txq_entry_t txq_head;
266 int txq_entries;
268 struct rxq_entry_t rxq_head;
270 const struct firmware *firmware;
272 struct device *dev;
273 bool suspend_event;
275 int clients_count;
276 struct workqueue_struct *hif_workqueue;
277 enum chip_ps_states chip_ps_state;
278 struct wilc_cfg cfg;
279 void *bus_data;
280 struct net_device *monitor_dev;
282 /* deinit lock */
283 struct mutex deinit_lock;
284 u8 sta_ch;
285 u8 op_ch;
286 struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)];
287 struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)];
288 struct ieee80211_supported_band band;
289 u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)];
292 struct wilc_wfi_mon_priv {
293 struct net_device *real_ndev;
296 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
297 void wilc_mac_indicate(struct wilc *wilc);
298 void wilc_netdev_cleanup(struct wilc *wilc);
299 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
300 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
301 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
302 int vif_type, enum nl80211_iftype type,
303 bool rtnl_locked);
304 #endif