1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
7 #ifndef WILC_WFI_NETDEVICE
8 #define WILC_WFI_NETDEVICE
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 "host_interface.h"
18 #include "wilc_wlan.h"
20 #define FLOW_CONTROL_LOWER_THRESHOLD 128
21 #define FLOW_CONTROL_UPPER_THRESHOLD 256
23 #define WILC_MAX_NUM_PMKIDS 16
26 #define NUM_STA_ASSOCIATED 8
28 #define NUM_REG_FRAME 2
30 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
31 #define DEFAULT_LINK_SPEED 72
33 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
35 struct wilc_wfi_stats {
36 unsigned long rx_packets;
37 unsigned long tx_packets;
38 unsigned long rx_bytes;
39 unsigned long tx_bytes;
53 struct wilc_wfi_wep_key {
60 u8 sta_associated_bss[MAX_NUM_STA][ETH_ALEN];
63 /*Parameters needed for host interface for remaining on channel*/
64 struct wilc_wfi_p2p_listen_params {
65 struct ieee80211_channel *listen_ch;
68 u32 listen_session_id;
72 struct wireless_dev *wdev;
73 struct cfg80211_scan_request *scan_req;
75 struct wilc_wfi_p2p_listen_params remain_on_ch_params;
81 u8 associated_bss[ETH_ALEN];
82 struct sta_info assoc_stainfo;
84 struct net_device *dev;
85 struct host_if_drv *hif_drv;
86 struct host_if_pmkid_attr pmkid_list;
87 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
89 /* The real interface that the monitor is on */
90 struct net_device *real_ndev;
91 struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
92 struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
95 struct mutex scan_req_lock;
96 bool p2p_listen_state;
110 struct frame_reg frame_reg[NUM_REG_FRAME];
111 struct net_device_stats netstats;
113 u8 src_addr[ETH_ALEN];
115 struct host_if_drv *hif_drv;
116 struct net_device *ndev;
122 const struct wilc_hif_func *hif_func;
125 struct gpio_desc *gpio_irq;
130 struct wilc_vif *vif[NUM_CONCURRENT_IFC];
132 /*protect head of transmit queue*/
133 struct mutex txq_add_to_head_cs;
134 /*protect txq_entry_t transmit queue*/
135 spinlock_t txq_spinlock;
136 /*protect rxq_entry_t receiver queue*/
138 /* lock to protect hif access */
141 struct completion cfg_event;
142 struct completion sync_event;
143 struct completion txq_event;
144 struct completion txq_thread_started;
146 struct task_struct *txq_thread;
149 int cfg_frame_in_use;
150 struct wilc_cfg_frame cfg_frame;
151 u32 cfg_frame_offset;
155 u32 rx_buffer_offset;
158 struct txq_entry_t txq_head;
161 struct rxq_entry_t rxq_head;
163 const struct firmware *firmware;
168 struct rf_info dummy_statistics;
171 struct wilc_wfi_mon_priv {
172 struct net_device *real_ndev;
175 void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
176 void wilc_mac_indicate(struct wilc *wilc);
177 void wilc_netdev_cleanup(struct wilc *wilc);
178 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
179 const struct wilc_hif_func *ops);
180 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
181 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);