blob: aa30de932ca48b179acd404c5e0e2aae94d0993d [file] [log] [blame]
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001/*!
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
39#include <linux/ieee80211.h>
40#include <net/cfg80211.h>
41
42#include <linux/ieee80211.h>
43#include <net/cfg80211.h>
44#include <net/ieee80211_radiotap.h>
45#include <linux/if_arp.h>
46
47
48#include <linux/in6.h>
49#include <asm/checksum.h>
50#include "host_interface.h"
51#include "wilc_wlan.h"
52#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30)
53#include <net/wireless.h>
54#else
55#include <linux/wireless.h> /* tony, 2013-06-12 */
56#endif
57
58
59#define FLOW_CONTROL_LOWER_THRESHOLD 128
60#define FLOW_CONTROL_UPPER_THRESHOLD 256
61
62/*iftype*/
63
64
65enum stats_flags {
66 WILC_WFI_RX_PKT = 1 << 0,
67 WILC_WFI_TX_PKT = 1 << 1,
68};
69
70struct WILC_WFI_stats {
71
72 unsigned long rx_packets;
73 unsigned long tx_packets;
74 unsigned long rx_bytes;
75 unsigned long tx_bytes;
76 u64 rx_time;
77 u64 tx_time;
78
79};
80
81/*
82 * This structure is private to each device. It is used to pass
83 * packets in and out, so there is place for a packet
84 */
85
86#define RX_BH_KTHREAD 0
87#define RX_BH_WORK_QUEUE 1
88#define RX_BH_THREADED_IRQ 2
89#define num_reg_frame 2
90/*
91 * If you use RX_BH_WORK_QUEUE on LPC3131: You may lose the first interrupt on
92 * LPC3131 which is important to get the MAC start status when you are blocked inside
93 * linux_wlan_firmware_download() which blocks mac_open().
94 */
95#if defined (NM73131_0_BOARD)
96 #define RX_BH_TYPE RX_BH_KTHREAD
97#elif defined (PANDA_BOARD)
98 #define RX_BH_TYPE RX_BH_THREADED_IRQ
99#else
100 #define RX_BH_TYPE RX_BH_KTHREAD
101#endif
102
103struct wilc_wfi_key {
104 u8 *key;
105 u8 *seq;
106 int key_len;
107 int seq_len;
108 u32 cipher;
109};
110struct wilc_wfi_wep_key {
111 u8 *key;
112 u8 key_len;
113 u8 key_idx;
114};
115
116struct sta_info {
117 WILC_Uint8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
118};
119
120#ifdef WILC_P2P
121/*Parameters needed for host interface for remaining on channel*/
122struct wilc_wfi_p2pListenParams {
123 struct ieee80211_channel *pstrListenChan;
124 enum nl80211_channel_type tenuChannelType;
125 WILC_Uint32 u32ListenDuration;
126 WILC_Uint64 u64ListenCookie;
127 WILC_Uint32 u32ListenSessionID;
128};
129
130#endif /*WILC_P2P*/
131
132struct WILC_WFI_priv {
133 struct wireless_dev *wdev;
134 struct cfg80211_scan_request *pstrScanReq;
135
136 #ifdef WILC_P2P
137 struct wilc_wfi_p2pListenParams strRemainOnChanParams;
138 WILC_Uint64 u64tx_cookie;
139
140 #endif
141
142 WILC_Bool bCfgScanning;
143 WILC_Uint32 u32RcvdChCount;
144
145
146
147 WILC_Uint8 au8AssociatedBss[ETH_ALEN];
148 struct sta_info assoc_stainfo;
149 struct net_device_stats stats;
150 WILC_Uint8 monitor_flag;
151 int status;
152 struct WILC_WFI_packet *ppool;
153 struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
154 int rx_int_enabled;
155 int tx_packetlen;
156 u8 *tx_packetdata;
157 struct sk_buff *skb;
158 spinlock_t lock;
159 struct net_device *dev;
160 struct napi_struct napi;
161 WILC_WFIDrvHandle hWILCWFIDrv;
162 WILC_WFIDrvHandle hWILCWFIDrv_2;
163 tstrHostIFpmkidAttr pmkid_list;
164 struct WILC_WFI_stats netstats;
165 WILC_Uint8 WILC_WFI_wep_default;
166#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
167#define WLAN_KEY_LEN_WEP104 13
168#endif
169 WILC_Uint8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
170 WILC_Uint8 WILC_WFI_wep_key_len[4];
171 struct net_device *real_ndev; /* The real interface that the monitor is on */
172 struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
173 struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
174 WILC_Uint8 wilc_groupkey;
175 /* semaphores */
176 WILC_SemaphoreHandle SemHandleUpdateStats;
177 WILC_SemaphoreHandle hSemScanReq;
178 /* */
179 WILC_Bool gbAutoRateAdjusted;
180
181 WILC_Bool bInP2PlistenState;
182
183};
184
185typedef struct {
186 WILC_Uint16 frame_type;
187 WILC_Bool reg;
188
189} struct_frame_reg;
190
191
192#define NUM_CONCURRENT_IFC 2
193typedef struct {
194 uint8_t aSrcAddress[ETH_ALEN];
195 uint8_t aBSSID[ETH_ALEN];
196 uint32_t drvHandler;
197 struct net_device *wilc_netdev;
198} tstrInterfaceInfo;
199typedef struct {
200 int mac_status;
201 int wilc1000_initialized;
202
203
204 #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
205 unsigned short dev_irq_num;
206 #endif
207 wilc_wlan_oup_t oup;
208 int close;
209 uint8_t u8NoIfcs;
210 tstrInterfaceInfo strInterfaceInfo[NUM_CONCURRENT_IFC];
211 uint8_t open_ifcs;
212 struct mutex txq_cs;
213
214 /*Added by Amr - BugID_4720*/
215 struct mutex txq_add_to_head_cs;
216 spinlock_t txq_spinlock;
217
218 struct mutex rxq_cs;
219 struct mutex hif_cs;
220
221 /* struct mutex txq_event; */
222 struct semaphore rxq_event;
223 struct semaphore cfg_event;
224 struct semaphore sync_event;
225
226 struct semaphore txq_event;
227 /* struct completion txq_event; */
228
229#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
230 struct work_struct rx_work_queue;
231#elif (RX_BH_TYPE == RX_BH_KTHREAD)
232 struct task_struct *rx_bh_thread;
233 struct semaphore rx_sem;
234#endif
235
236
237
238 struct semaphore rxq_thread_started;
239 struct semaphore txq_thread_started;
240
241 struct task_struct *rxq_thread;
242 struct task_struct *txq_thread;
243
244 unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
245 /* unsigned char eth_dst_address[6]; */
246
247 const struct firmware *wilc_firmware; /* Bug 4703 */
248
249 struct net_device *real_ndev;
250#ifdef WILC_SDIO
251 int already_claim;
252 struct sdio_func *wilc_sdio_func;
253#else
254 struct spi_device *wilc_spidev;
255#endif
256
257} linux_wlan_t;
258
259typedef struct {
260 uint8_t u8IfIdx;
261 WILC_Uint8 iftype;
262 int monitor_flag;
263 int mac_opened;
264 #ifdef WILC_P2P
265 struct_frame_reg g_struct_frame_reg[num_reg_frame];
266 #endif
267 struct net_device *wilc_netdev;
268 struct net_device_stats netstats;
269
270} perInterface_wlan_t;
271
272struct WILC_WFI_mon_priv {
273 struct net_device *real_ndev;
274};
275extern struct net_device *WILC_WFI_devs[];
276
277#endif