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 TCP_ACK_FILTER_LINK_SPEED_THRESH 54
28 #define DEFAULT_LINK_SPEED 72
30 #define TX_BACKOFF_WEIGHT_MS 1
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;
51 u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
54 /* Parameters needed for host interface for remaining on channel */
55 struct wilc_wfi_p2p_listen_params {
56 struct ieee80211_channel *listen_ch;
61 static const u32 wilc_cipher_suites[] = {
62 WLAN_CIPHER_SUITE_TKIP,
63 WLAN_CIPHER_SUITE_CCMP,
64 WLAN_CIPHER_SUITE_AES_CMAC
67 #define CHAN2G(_channel, _freq, _flags) { \
68 .band = NL80211_BAND_2GHZ, \
69 .center_freq = (_freq), \
70 .hw_value = (_channel), \
72 .max_antenna_gain = 0, \
76 static const struct ieee80211_channel wilc_2ghz_channels[] = {
93 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
95 .hw_value = (_hw_value), \
99 static struct ieee80211_rate wilc_bitrates[] = {
100 RATETAB_ENT(10, 0, 0),
101 RATETAB_ENT(20, 1, 0),
102 RATETAB_ENT(55, 2, 0),
103 RATETAB_ENT(110, 3, 0),
104 RATETAB_ENT(60, 9, 0),
105 RATETAB_ENT(90, 6, 0),
106 RATETAB_ENT(120, 7, 0),
107 RATETAB_ENT(180, 8, 0),
108 RATETAB_ENT(240, 9, 0),
109 RATETAB_ENT(360, 10, 0),
110 RATETAB_ENT(480, 11, 0),
111 RATETAB_ENT(540, 12, 0)
115 struct wireless_dev wdev;
116 struct cfg80211_scan_request *scan_req;
118 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
123 u8 associated_bss[ETH_ALEN];
124 struct sta_info assoc_stainfo;
126 struct net_device *dev;
127 struct host_if_drv *hif_drv;
128 struct wilc_pmkid_attr pmkid_list;
130 /* The real interface that the monitor is on */
131 struct net_device *real_ndev;
132 struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
133 struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
134 struct wilc_wfi_key *wilc_igtk[2];
138 struct mutex scan_req_lock;
139 bool p2p_listen_state;
145 #define MAX_TCP_SESSION 25
146 #define MAX_PENDING_ACKS 256
148 struct ack_session_info {
156 struct pending_acks {
159 struct txq_entry_t *txqe;
162 struct tcp_ack_filter {
163 struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];
164 struct pending_acks pending_acks[MAX_PENDING_ACKS];
167 u32 pending_acks_idx;
177 struct net_device_stats netstats;
180 struct host_if_drv *hif_drv;
181 struct net_device *ndev;
182 struct timer_list during_ip_timer;
183 struct timer_list periodic_rssi;
184 struct rf_info periodic_stat;
185 struct tcp_ack_filter ack_filter;
187 struct wilc_priv priv;
188 struct list_head list;
189 struct cfg80211_bss *bss;
190 struct cfg80211_external_auth_params auth;
193 struct wilc_tx_queue_status {
194 u8 buffer[AC_BUFFER_SIZE];
203 const struct wilc_hif_func *hif_func;
209 bool power_save_mode;
213 struct list_head vif_list;
215 /* protect vif list */
216 struct mutex vif_mutex;
217 struct srcu_struct srcu;
220 /* protect head of transmit queue */
221 struct mutex txq_add_to_head_cs;
223 /* protect txq_entry_t transmit queue */
224 spinlock_t txq_spinlock;
226 /* protect rxq_entry_t receiver queue */
229 /* lock to protect hif access */
232 struct completion cfg_event;
233 struct completion sync_event;
234 struct completion txq_event;
235 struct completion txq_thread_started;
237 struct task_struct *txq_thread;
241 /* lock to protect issue of wid command to firmware */
242 struct mutex cfg_cmd_lock;
243 struct wilc_cfg_frame cfg_frame;
244 u32 cfg_frame_offset;
248 u32 rx_buffer_offset;
252 struct txq_handle txq[NQUEUES];
255 struct wilc_tx_queue_status tx_q_limit;
256 struct rxq_entry_t rxq_head;
258 const struct firmware *firmware;
263 struct workqueue_struct *hif_workqueue;
266 struct net_device *monitor_dev;
269 struct mutex deinit_lock;
272 struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)];
273 struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)];
274 struct ieee80211_supported_band band;
275 u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)];
278 struct wilc_wfi_mon_priv {
279 struct net_device *real_ndev;
282 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
283 void wilc_mac_indicate(struct wilc *wilc);
284 void wilc_netdev_cleanup(struct wilc *wilc);
285 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth);
286 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, const u8 *bssid,
288 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
289 int vif_type, enum nl80211_iftype type,