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