1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
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>
21 #define FLOW_CONTROL_LOWER_THRESHOLD 128
22 #define FLOW_CONTROL_UPPER_THRESHOLD 256
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 struct wilc_wfi_stats {
33 unsigned long rx_packets;
34 unsigned long tx_packets;
35 unsigned long rx_bytes;
36 unsigned long tx_bytes;
50 struct wilc_wfi_wep_key {
57 u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
60 /* Parameters needed for host interface for remaining on channel */
61 struct wilc_wfi_p2p_listen_params {
62 struct ieee80211_channel *listen_ch;
67 static const u32 wilc_cipher_suites[] = {
68 WLAN_CIPHER_SUITE_WEP40,
69 WLAN_CIPHER_SUITE_WEP104,
70 WLAN_CIPHER_SUITE_TKIP,
71 WLAN_CIPHER_SUITE_CCMP,
72 WLAN_CIPHER_SUITE_AES_CMAC
75 #define CHAN2G(_channel, _freq, _flags) { \
76 .band = NL80211_BAND_2GHZ, \
77 .center_freq = (_freq), \
78 .hw_value = (_channel), \
80 .max_antenna_gain = 0, \
84 static const struct ieee80211_channel wilc_2ghz_channels[] = {
101 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
102 .bitrate = (_rate), \
103 .hw_value = (_hw_value), \
107 static struct ieee80211_rate wilc_bitrates[] = {
108 RATETAB_ENT(10, 0, 0),
109 RATETAB_ENT(20, 1, 0),
110 RATETAB_ENT(55, 2, 0),
111 RATETAB_ENT(110, 3, 0),
112 RATETAB_ENT(60, 9, 0),
113 RATETAB_ENT(90, 6, 0),
114 RATETAB_ENT(120, 7, 0),
115 RATETAB_ENT(180, 8, 0),
116 RATETAB_ENT(240, 9, 0),
117 RATETAB_ENT(360, 10, 0),
118 RATETAB_ENT(480, 11, 0),
119 RATETAB_ENT(540, 12, 0)
123 struct wireless_dev wdev;
124 struct cfg80211_scan_request *scan_req;
126 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
131 u8 associated_bss[ETH_ALEN];
132 struct sta_info assoc_stainfo;
134 struct net_device *dev;
135 struct host_if_drv *hif_drv;
136 struct wilc_pmkid_attr pmkid_list;
137 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
140 /* The real interface that the monitor is on */
141 struct net_device *real_ndev;
142 struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
143 struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
147 struct mutex scan_req_lock;
148 bool p2p_listen_state;
159 #define MAX_TCP_SESSION 25
160 #define MAX_PENDING_ACKS 256
162 struct ack_session_info {
170 struct pending_acks {
173 struct txq_entry_t *txqe;
176 struct tcp_ack_filter {
177 struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];
178 struct pending_acks pending_acks[MAX_PENDING_ACKS];
181 u32 pending_acks_idx;
190 struct frame_reg frame_reg[NUM_REG_FRAME];
191 struct net_device_stats netstats;
194 struct host_if_drv *hif_drv;
195 struct net_device *ndev;
197 struct timer_list during_ip_timer;
198 struct timer_list periodic_rssi;
199 struct rf_info periodic_stat;
200 struct tcp_ack_filter ack_filter;
202 struct wilc_priv priv;
203 struct list_head list;
204 struct cfg80211_bss *bss;
209 const struct wilc_hif_func *hif_func;
217 struct list_head vif_list;
219 /* protect vif list */
220 struct mutex vif_mutex;
221 struct srcu_struct srcu;
224 /* protect head of transmit queue */
225 struct mutex txq_add_to_head_cs;
227 /* protect txq_entry_t transmit queue */
228 spinlock_t txq_spinlock;
230 /* protect rxq_entry_t receiver queue */
233 /* lock to protect hif access */
236 struct completion cfg_event;
237 struct completion sync_event;
238 struct completion txq_event;
239 struct completion txq_thread_started;
241 struct task_struct *txq_thread;
245 /* lock to protect issue of wid command to firmware */
246 struct mutex cfg_cmd_lock;
247 struct wilc_cfg_frame cfg_frame;
248 u32 cfg_frame_offset;
252 u32 rx_buffer_offset;
255 struct txq_entry_t txq_head;
258 struct rxq_entry_t rxq_head;
260 const struct firmware *firmware;
266 struct workqueue_struct *hif_workqueue;
267 enum chip_ps_states chip_ps_state;
270 struct net_device *monitor_dev;
273 struct mutex deinit_lock;
276 struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)];
277 struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)];
278 struct ieee80211_supported_band band;
279 u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)];
282 struct wilc_wfi_mon_priv {
283 struct net_device *real_ndev;
286 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
287 void wilc_mac_indicate(struct wilc *wilc);
288 void wilc_netdev_cleanup(struct wilc *wilc);
289 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
290 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
291 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
292 int vif_type, enum nl80211_iftype type,