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 #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
;
52 struct wilc_wfi_wep_key
{
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
;
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), \
88 .max_antenna_gain = 0, \
92 static const struct ieee80211_channel wilc_2ghz_channels
[] = {
109 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
110 .bitrate = (_rate), \
111 .hw_value = (_hw_value), \
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)
131 struct wireless_dev wdev
;
132 struct cfg80211_scan_request
*scan_req
;
134 struct wilc_wfi_p2p_listen_params remain_on_ch_params
;
139 u8 associated_bss
[ETH_ALEN
];
140 struct sta_info assoc_stainfo
;
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
];
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
];
155 struct mutex scan_req_lock
;
156 bool p2p_listen_state
;
158 struct wilc_p2p_var p2p
;
168 #define MAX_TCP_SESSION 25
169 #define MAX_PENDING_ACKS 256
171 struct ack_session_info
{
179 struct pending_acks
{
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
];
190 u32 pending_acks_idx
;
199 struct frame_reg frame_reg
[NUM_REG_FRAME
];
200 struct net_device_stats netstats
;
203 struct host_if_drv
*hif_drv
;
204 struct net_device
*ndev
;
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
;
211 struct wilc_priv priv
;
212 struct list_head list
;
213 struct cfg80211_bss
*bss
;
218 const struct wilc_hif_func
*hif_func
;
221 struct gpio_desc
*gpio_irq
;
227 struct list_head vif_list
;
229 /* protect vif list */
230 struct mutex vif_mutex
;
231 struct srcu_struct srcu
;
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 */
243 /* lock to protect hif access */
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
;
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
;
262 u32 rx_buffer_offset
;
265 struct txq_entry_t txq_head
;
268 struct rxq_entry_t rxq_head
;
270 const struct firmware
*firmware
;
276 struct workqueue_struct
*hif_workqueue
;
277 enum chip_ps_states chip_ps_state
;
280 struct net_device
*monitor_dev
;
283 struct mutex deinit_lock
;
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
,