Merge tag 'iio-for-4.4a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio...
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wfi_netdevice.h
1 /*!
2  *  @file       wilc_wfi_netdevice.h
3  *  @brief      Definitions for the network module
4  *  @author     mdaftedar
5  *  @date       01 MAR 2012
6  *  @version    1.0
7  */
8 #ifndef WILC_WFI_NETDEVICE
9 #define WILC_WFI_NETDEVICE
10
11 /* These are the flags in the statusword */
12 #define WILC_WFI_RX_INTR 0x0001
13 #define WILC_WFI_TX_INTR 0x0002
14
15 /* Default timeout period */
16 #define WILC_WFI_TIMEOUT 5   /* In jiffies */
17 #define WILC_MAX_NUM_PMKIDS  16
18 #define PMKID_LEN  16
19 #define PMKID_FOUND 1
20  #define NUM_STA_ASSOCIATED 8
21
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/moduleparam.h>
25 #include <linux/sched.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h> /* kmalloc() */
28 #include <linux/errno.h>  /* error codes */
29 #include <linux/types.h>  /* size_t */
30 #include <linux/interrupt.h> /* mark_bh */
31 #include <linux/time.h>
32 #include <linux/in.h>
33 #include <linux/netdevice.h>   /* struct device, and other headers */
34 #include <linux/etherdevice.h> /* eth_type_trans */
35 #include <linux/ip.h>          /* struct iphdr */
36 #include <linux/tcp.h>         /* struct tcphdr */
37 #include <linux/skbuff.h>
38 #include <linux/ieee80211.h>
39 #include <net/cfg80211.h>
40 #include <linux/ieee80211.h>
41 #include <net/cfg80211.h>
42 #include <net/ieee80211_radiotap.h>
43 #include <linux/if_arp.h>
44 #include <linux/in6.h>
45 #include <asm/checksum.h>
46 #include "host_interface.h"
47 #include "wilc_wlan.h"
48 #include <linux/wireless.h>     /* tony, 2013-06-12 */
49
50 #define FLOW_CONTROL_LOWER_THRESHOLD    128
51 #define FLOW_CONTROL_UPPER_THRESHOLD    256
52
53 /*iftype*/
54 enum stats_flags {
55         WILC_WFI_RX_PKT = 1 << 0,
56         WILC_WFI_TX_PKT = 1 << 1,
57 };
58
59 struct WILC_WFI_stats {
60         unsigned long rx_packets;
61         unsigned long tx_packets;
62         unsigned long rx_bytes;
63         unsigned long tx_bytes;
64         u64 rx_time;
65         u64 tx_time;
66
67 };
68
69 /*
70  * This structure is private to each device. It is used to pass
71  * packets in and out, so there is place for a packet
72  */
73
74 #define num_reg_frame 2
75
76 struct wilc_wfi_key {
77         u8 *key;
78         u8 *seq;
79         int key_len;
80         int seq_len;
81         u32 cipher;
82 };
83
84 struct wilc_wfi_wep_key {
85         u8 *key;
86         u8 key_len;
87         u8 key_idx;
88 };
89
90 struct sta_info {
91         u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
92 };
93
94 /*Parameters needed for host interface for  remaining on channel*/
95 struct wilc_wfi_p2pListenParams {
96         struct ieee80211_channel *pstrListenChan;
97         enum nl80211_channel_type tenuChannelType;
98         u32 u32ListenDuration;
99         u64 u64ListenCookie;
100         u32 u32ListenSessionID;
101 };
102
103 struct wilc_priv {
104         struct wireless_dev *wdev;
105         struct cfg80211_scan_request *pstrScanReq;
106
107         struct wilc_wfi_p2pListenParams strRemainOnChanParams;
108         u64 u64tx_cookie;
109
110         bool bCfgScanning;
111         u32 u32RcvdChCount;
112
113         u8 au8AssociatedBss[ETH_ALEN];
114         struct sta_info assoc_stainfo;
115         struct net_device_stats stats;
116         u8 monitor_flag;
117         int status;
118         struct WILC_WFI_packet *ppool;
119         struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
120         int rx_int_enabled;
121         int tx_packetlen;
122         u8 *tx_packetdata;
123         struct sk_buff *skb;
124         spinlock_t lock;
125         struct net_device *dev;
126         struct napi_struct napi;
127         tstrWILC_WFIDrv *hWILCWFIDrv;
128         WILC_WFIDrvHandle hWILCWFIDrv_2;
129         tstrHostIFpmkidAttr pmkid_list;
130         struct WILC_WFI_stats netstats;
131         u8 WILC_WFI_wep_default;
132         u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
133         u8 WILC_WFI_wep_key_len[4];
134         /* The real interface that the monitor is on */
135         struct net_device *real_ndev;
136         struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
137         struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
138         u8 wilc_groupkey;
139         /* semaphores */
140         struct semaphore SemHandleUpdateStats;
141         struct semaphore hSemScanReq;
142         /*  */
143         bool gbAutoRateAdjusted;
144
145         bool bInP2PlistenState;
146
147 };
148
149 typedef struct {
150         u16 frame_type;
151         bool reg;
152
153 } struct_frame_reg;
154
155 typedef struct {
156         u8 aSrcAddress[ETH_ALEN];
157         u8 aBSSID[ETH_ALEN];
158         tstrWILC_WFIDrv *drvHandler;
159         struct net_device *wilc_netdev;
160 } tstrInterfaceInfo;
161 typedef struct {
162         int mac_status;
163         int wilc1000_initialized;
164         #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
165         unsigned short dev_irq_num;
166         #endif
167         wilc_wlan_oup_t oup;
168         int close;
169         u8 u8NoIfcs;
170         tstrInterfaceInfo strInterfaceInfo[NUM_CONCURRENT_IFC];
171         u8 open_ifcs;
172
173         struct semaphore txq_add_to_head_cs;
174         spinlock_t txq_spinlock;
175
176         struct mutex rxq_cs;
177         struct mutex hif_cs;
178
179         struct semaphore cfg_event;
180         struct semaphore sync_event;
181         struct semaphore txq_event;
182
183         struct semaphore txq_thread_started;
184
185         struct task_struct *txq_thread;
186
187         unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
188         /* unsigned char eth_dst_address[6]; */
189
190         const struct firmware *wilc_firmware;
191
192         struct net_device *real_ndev;
193 #ifdef WILC_SDIO
194         int already_claim;
195         struct sdio_func *wilc_sdio_func;
196 #else
197         struct spi_device *wilc_spidev;
198 #endif
199
200 } linux_wlan_t;
201
202 typedef struct {
203         u8 u8IfIdx;
204         u8 iftype;
205         int monitor_flag;
206         int mac_opened;
207         struct_frame_reg g_struct_frame_reg[num_reg_frame];
208         struct net_device *wilc_netdev;
209         struct net_device_stats netstats;
210
211 } perInterface_wlan_t;
212
213 struct WILC_WFI_mon_priv {
214         struct net_device *real_ndev;
215 };
216
217 extern linux_wlan_t *g_linux_wlan;
218 extern struct net_device *WILC_WFI_devs[];
219 void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset);
220 void linux_wlan_mac_indicate(int flag);
221 void linux_wlan_rx_complete(void);
222 void linux_wlan_dbg(u8 *buff);
223 int linux_wlan_lock_timeout(void *vp, u32 timeout);
224
225 #endif