License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[sfrench/cifs-2.6.git] / drivers / staging / wilc1000 / wilc_wfi_netdevice.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*!
3  *  @file       wilc_wfi_netdevice.h
4  *  @brief      Definitions for the network module
5  *  @author     mdaftedar
6  *  @date       01 MAR 2012
7  *  @version    1.0
8  */
9 #ifndef WILC_WFI_NETDEVICE
10 #define WILC_WFI_NETDEVICE
11
12 #define WILC_WFI_RX_INTR 0x0001
13 #define WILC_WFI_TX_INTR 0x0002
14
15 #define WILC_WFI_TIMEOUT 5
16 #define WILC_MAX_NUM_PMKIDS  16
17 #define PMKID_LEN  16
18 #define PMKID_FOUND 1
19  #define NUM_STA_ASSOCIATED 8
20
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/moduleparam.h>
24 #include <linux/sched.h>
25 #include <linux/kernel.h>
26 #include <linux/slab.h>
27 #include <linux/errno.h>
28 #include <linux/types.h>
29 #include <linux/interrupt.h>
30 #include <linux/time.h>
31 #include <linux/in.h>
32 #include <linux/netdevice.h>
33 #include <linux/etherdevice.h>
34 #include <linux/ip.h>
35 #include <linux/tcp.h>
36 #include <linux/skbuff.h>
37 #include <linux/ieee80211.h>
38 #include <net/cfg80211.h>
39 #include <net/ieee80211_radiotap.h>
40 #include <linux/if_arp.h>
41 #include <linux/in6.h>
42 #include <asm/checksum.h>
43 #include "host_interface.h"
44 #include "wilc_wlan.h"
45 #include <linux/wireless.h>
46 #include <linux/completion.h>
47 #include <linux/mutex.h>
48
49 #define FLOW_CONTROL_LOWER_THRESHOLD    128
50 #define FLOW_CONTROL_UPPER_THRESHOLD    256
51
52 enum stats_flags {
53         WILC_WFI_RX_PKT = BIT(0),
54         WILC_WFI_TX_PKT = BIT(1),
55 };
56
57 struct WILC_WFI_stats {
58         unsigned long rx_packets;
59         unsigned long tx_packets;
60         unsigned long rx_bytes;
61         unsigned long tx_bytes;
62         u64 rx_time;
63         u64 tx_time;
64
65 };
66
67 /*
68  * This structure is private to each device. It is used to pass
69  * packets in and out, so there is place for a packet
70  */
71
72 #define num_reg_frame 2
73
74 struct wilc_wfi_key {
75         u8 *key;
76         u8 *seq;
77         int key_len;
78         int seq_len;
79         u32 cipher;
80 };
81
82 struct wilc_wfi_wep_key {
83         u8 *key;
84         u8 key_len;
85         u8 key_idx;
86 };
87
88 struct sta_info {
89         u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
90 };
91
92 /*Parameters needed for host interface for  remaining on channel*/
93 struct wilc_wfi_p2pListenParams {
94         struct ieee80211_channel *pstrListenChan;
95         enum nl80211_channel_type tenuChannelType;
96         u32 u32ListenDuration;
97         u64 u64ListenCookie;
98         u32 u32ListenSessionID;
99 };
100
101 struct wilc_priv {
102         struct wireless_dev *wdev;
103         struct cfg80211_scan_request *pstrScanReq;
104
105         struct wilc_wfi_p2pListenParams strRemainOnChanParams;
106         u64 u64tx_cookie;
107
108         bool bCfgScanning;
109         u32 u32RcvdChCount;
110
111         u8 au8AssociatedBss[ETH_ALEN];
112         struct sta_info assoc_stainfo;
113         struct net_device_stats stats;
114         u8 monitor_flag;
115         int status;
116         struct WILC_WFI_packet *ppool;
117         struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
118         int rx_int_enabled;
119         int tx_packetlen;
120         u8 *tx_packetdata;
121         struct sk_buff *skb;
122         spinlock_t lock;
123         struct net_device *dev;
124         struct napi_struct napi;
125         struct host_if_drv *hif_drv;
126         struct host_if_pmkid_attr pmkid_list;
127         struct WILC_WFI_stats netstats;
128         u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
129         u8 WILC_WFI_wep_key_len[4];
130         /* The real interface that the monitor is on */
131         struct net_device *real_ndev;
132         struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
133         struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
134         u8 wilc_groupkey;
135         /* mutexes */
136         struct mutex scan_req_lock;
137         /*  */
138         bool gbAutoRateAdjusted;
139
140         bool bInP2PlistenState;
141
142 };
143
144 struct frame_reg {
145         u16 type;
146         bool reg;
147 };
148
149 struct wilc_vif {
150         u8 idx;
151         u8 iftype;
152         int monitor_flag;
153         int mac_opened;
154         struct frame_reg frame_reg[num_reg_frame];
155         struct net_device_stats netstats;
156         struct wilc *wilc;
157         u8 src_addr[ETH_ALEN];
158         u8 bssid[ETH_ALEN];
159         struct host_if_drv *hif_drv;
160         struct net_device *ndev;
161         u8 mode;
162         u8 ifc_id;
163 };
164
165 struct wilc {
166         const struct wilc_hif_func *hif_func;
167         int io_type;
168         int mac_status;
169         int gpio;
170         bool initialized;
171         int dev_irq_num;
172         int close;
173         u8 vif_num;
174         struct wilc_vif *vif[NUM_CONCURRENT_IFC];
175         u8 open_ifcs;
176
177         struct mutex txq_add_to_head_cs;
178         spinlock_t txq_spinlock;
179
180         struct mutex rxq_cs;
181         struct mutex hif_cs;
182
183         struct completion cfg_event;
184         struct completion sync_event;
185         struct completion txq_event;
186         struct completion txq_thread_started;
187
188         struct task_struct *txq_thread;
189
190         int quit;
191         int cfg_frame_in_use;
192         struct wilc_cfg_frame cfg_frame;
193         u32 cfg_frame_offset;
194         int cfg_seq_no;
195
196         u8 *rx_buffer;
197         u32 rx_buffer_offset;
198         u8 *tx_buffer;
199
200         unsigned long txq_spinlock_flags;
201
202         struct txq_entry_t *txq_head;
203         struct txq_entry_t *txq_tail;
204         int txq_entries;
205         int txq_exit;
206
207         struct rxq_entry_t *rxq_head;
208         struct rxq_entry_t *rxq_tail;
209         int rxq_entries;
210         int rxq_exit;
211
212         unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
213
214         const struct firmware *firmware;
215
216         struct device *dev;
217         bool suspend_event;
218
219         struct rf_info dummy_statistics;
220 };
221
222 struct WILC_WFI_mon_priv {
223         struct net_device *real_ndev;
224 };
225
226 int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif);
227
228 void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
229 void wilc_mac_indicate(struct wilc *wilc, int flag);
230 void wilc_netdev_cleanup(struct wilc *wilc);
231 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
232                      int gpio, const struct wilc_hif_func *ops);
233 void wilc1000_wlan_deinit(struct net_device *dev);
234 void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
235 int wilc_wlan_get_firmware(struct net_device *dev);
236 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
237
238 #endif