Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 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 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 11 | #define WILC_WFI_RX_INTR 0x0001 |
12 | #define WILC_WFI_TX_INTR 0x0002 | ||||
13 | |||||
Chaehyun Lim | 30b2ba09 | 2015-10-02 16:41:15 +0900 | [diff] [blame] | 14 | #define WILC_WFI_TIMEOUT 5 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 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> | ||||
Chaehyun Lim | 30b2ba09 | 2015-10-02 16:41:15 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
26 | #include <linux/errno.h> | ||||
27 | #include <linux/types.h> | ||||
28 | #include <linux/interrupt.h> | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 29 | #include <linux/time.h> |
30 | #include <linux/in.h> | ||||
Chaehyun Lim | 30b2ba09 | 2015-10-02 16:41:15 +0900 | [diff] [blame] | 31 | #include <linux/netdevice.h> |
32 | #include <linux/etherdevice.h> | ||||
33 | #include <linux/ip.h> | ||||
34 | #include <linux/tcp.h> | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 35 | #include <linux/skbuff.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 36 | #include <linux/ieee80211.h> |
37 | #include <net/cfg80211.h> | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 38 | #include <linux/ieee80211.h> |
39 | #include <net/cfg80211.h> | ||||
40 | #include <net/ieee80211_radiotap.h> | ||||
41 | #include <linux/if_arp.h> | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 42 | #include <linux/in6.h> |
43 | #include <asm/checksum.h> | ||||
44 | #include "host_interface.h" | ||||
45 | #include "wilc_wlan.h" | ||||
Chaehyun Lim | 30b2ba09 | 2015-10-02 16:41:15 +0900 | [diff] [blame] | 46 | #include <linux/wireless.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 47 | |
48 | #define FLOW_CONTROL_LOWER_THRESHOLD 128 | ||||
49 | #define FLOW_CONTROL_UPPER_THRESHOLD 256 | ||||
50 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 51 | enum stats_flags { |
Anish Bhatt | ffda203 | 2015-09-29 12:15:49 -0700 | [diff] [blame] | 52 | WILC_WFI_RX_PKT = BIT(0), |
53 | WILC_WFI_TX_PKT = BIT(1), | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 54 | }; |
55 | |||||
56 | struct WILC_WFI_stats { | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 57 | unsigned long rx_packets; |
58 | unsigned long tx_packets; | ||||
59 | unsigned long rx_bytes; | ||||
60 | unsigned long tx_bytes; | ||||
61 | u64 rx_time; | ||||
62 | u64 tx_time; | ||||
63 | |||||
64 | }; | ||||
65 | |||||
66 | /* | ||||
67 | * This structure is private to each device. It is used to pass | ||||
68 | * packets in and out, so there is place for a packet | ||||
69 | */ | ||||
70 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 71 | #define num_reg_frame 2 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 72 | |
73 | struct wilc_wfi_key { | ||||
74 | u8 *key; | ||||
75 | u8 *seq; | ||||
76 | int key_len; | ||||
77 | int seq_len; | ||||
78 | u32 cipher; | ||||
79 | }; | ||||
Sunghoon Cho | 36901b6 | 2015-06-26 15:48:15 +0900 | [diff] [blame] | 80 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 81 | struct wilc_wfi_wep_key { |
82 | u8 *key; | ||||
83 | u8 key_len; | ||||
84 | u8 key_idx; | ||||
85 | }; | ||||
86 | |||||
87 | struct sta_info { | ||||
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 88 | u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 89 | }; |
90 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 91 | /*Parameters needed for host interface for remaining on channel*/ |
92 | struct wilc_wfi_p2pListenParams { | ||||
93 | struct ieee80211_channel *pstrListenChan; | ||||
94 | enum nl80211_channel_type tenuChannelType; | ||||
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 95 | u32 u32ListenDuration; |
Chaehyun Lim | 57b298f | 2015-06-11 14:35:56 +0900 | [diff] [blame] | 96 | u64 u64ListenCookie; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 97 | u32 u32ListenSessionID; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 98 | }; |
99 | |||||
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 100 | struct wilc_priv { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 101 | struct wireless_dev *wdev; |
102 | struct cfg80211_scan_request *pstrScanReq; | ||||
103 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 104 | struct wilc_wfi_p2pListenParams strRemainOnChanParams; |
Chaehyun Lim | 57b298f | 2015-06-11 14:35:56 +0900 | [diff] [blame] | 105 | u64 u64tx_cookie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 106 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 107 | bool bCfgScanning; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 108 | u32 u32RcvdChCount; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 109 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 110 | u8 au8AssociatedBss[ETH_ALEN]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 111 | struct sta_info assoc_stainfo; |
112 | struct net_device_stats stats; | ||||
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 113 | u8 monitor_flag; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 114 | int status; |
115 | struct WILC_WFI_packet *ppool; | ||||
116 | struct WILC_WFI_packet *rx_queue; /* List of incoming packets */ | ||||
117 | int rx_int_enabled; | ||||
118 | int tx_packetlen; | ||||
119 | u8 *tx_packetdata; | ||||
120 | struct sk_buff *skb; | ||||
121 | spinlock_t lock; | ||||
122 | struct net_device *dev; | ||||
123 | struct napi_struct napi; | ||||
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 124 | struct host_if_drv *hWILCWFIDrv; |
Leo Kim | a949f90 | 2015-10-05 15:25:44 +0900 | [diff] [blame] | 125 | struct host_if_pmkid_attr pmkid_list; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 126 | struct WILC_WFI_stats netstats; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 127 | u8 WILC_WFI_wep_default; |
128 | u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104]; | ||||
129 | u8 WILC_WFI_wep_key_len[4]; | ||||
Sunghoon Cho | 70e59d9 | 2015-06-26 15:48:16 +0900 | [diff] [blame] | 130 | /* The real interface that the monitor is on */ |
131 | struct net_device *real_ndev; | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 132 | struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA]; |
133 | struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; | ||||
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 134 | u8 wilc_groupkey; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 135 | /* semaphores */ |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 136 | struct semaphore SemHandleUpdateStats; |
137 | struct semaphore hSemScanReq; | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 138 | /* */ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 139 | bool gbAutoRateAdjusted; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 140 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 141 | bool bInP2PlistenState; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 142 | |
143 | }; | ||||
144 | |||||
145 | typedef struct { | ||||
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 146 | u16 frame_type; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 147 | bool reg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 148 | |
149 | } struct_frame_reg; | ||||
150 | |||||
Tony Cho | 1a08bc4 | 2015-10-14 20:46:32 +0900 | [diff] [blame] | 151 | struct wilc_vif { |
Tony Cho | 7e7fa47 | 2015-10-20 14:26:48 +0900 | [diff] [blame] | 152 | u8 src_addr[ETH_ALEN]; |
Tony Cho | 7201cd2 | 2015-10-20 14:26:49 +0900 | [diff] [blame] | 153 | u8 bssid[ETH_ALEN]; |
Tony Cho | 3134a57 | 2015-10-20 14:26:50 +0900 | [diff] [blame] | 154 | struct host_if_drv *hif_drv; |
Tony Cho | 817f3fb | 2015-10-20 14:26:51 +0900 | [diff] [blame] | 155 | struct net_device *ndev; |
Tony Cho | 1a08bc4 | 2015-10-14 20:46:32 +0900 | [diff] [blame] | 156 | }; |
Tony Cho | f61c5af | 2015-10-14 20:46:30 +0900 | [diff] [blame] | 157 | |
158 | struct wilc { | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 159 | int mac_status; |
Tony Cho | 080f11b | 2015-10-20 14:26:45 +0900 | [diff] [blame] | 160 | bool initialized; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 161 | #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) |
162 | unsigned short dev_irq_num; | ||||
163 | #endif | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 164 | int close; |
Tony Cho | c1b30f6 | 2015-10-20 14:26:46 +0900 | [diff] [blame] | 165 | u8 vif_num; |
Tony Cho | 8259a53 | 2015-10-20 14:26:47 +0900 | [diff] [blame] | 166 | struct wilc_vif vif[NUM_CONCURRENT_IFC]; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 167 | u8 open_ifcs; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 168 | |
Greg Kroah-Hartman | 642768e | 2015-09-03 19:56:21 -0700 | [diff] [blame] | 169 | struct semaphore txq_add_to_head_cs; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 170 | spinlock_t txq_spinlock; |
171 | |||||
172 | struct mutex rxq_cs; | ||||
173 | struct mutex hif_cs; | ||||
174 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 175 | struct semaphore cfg_event; |
176 | struct semaphore sync_event; | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 177 | struct semaphore txq_event; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 178 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 179 | struct semaphore txq_thread_started; |
180 | |||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 181 | struct task_struct *txq_thread; |
182 | |||||
183 | unsigned char eth_src_address[NUM_CONCURRENT_IFC][6]; | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 184 | |
Tony Cho | 8b8ad7b | 2015-10-20 14:26:53 +0900 | [diff] [blame] | 185 | const struct firmware *firmware; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 186 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 187 | #ifdef WILC_SDIO |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 188 | struct sdio_func *wilc_sdio_func; |
189 | #else | ||||
190 | struct spi_device *wilc_spidev; | ||||
191 | #endif | ||||
Tony Cho | f61c5af | 2015-10-14 20:46:30 +0900 | [diff] [blame] | 192 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 193 | |
194 | typedef struct { | ||||
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 195 | u8 u8IfIdx; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 196 | u8 iftype; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 197 | int monitor_flag; |
198 | int mac_opened; | ||||
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 199 | struct_frame_reg g_struct_frame_reg[num_reg_frame]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 200 | struct net_device *wilc_netdev; |
201 | struct net_device_stats netstats; | ||||
Glen Lee | 38b3001d | 2015-10-20 17:13:51 +0900 | [diff] [blame] | 202 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 203 | } perInterface_wlan_t; |
204 | |||||
205 | struct WILC_WFI_mon_priv { | ||||
206 | struct net_device *real_ndev; | ||||
207 | }; | ||||
Sunghoon Cho | 1d1c5b2 | 2015-06-17 14:42:36 +0900 | [diff] [blame] | 208 | |
Tony Cho | f61c5af | 2015-10-14 20:46:30 +0900 | [diff] [blame] | 209 | extern struct wilc *g_linux_wlan; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 210 | extern struct net_device *WILC_WFI_devs[]; |
Glen Lee | 6361167 | 2015-09-24 18:14:52 +0900 | [diff] [blame] | 211 | void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset); |
Glen Lee | 64f2b71 | 2015-10-27 18:27:43 +0900 | [diff] [blame] | 212 | void linux_wlan_mac_indicate(struct wilc *wilc, int flag); |
Glen Lee | c0cadaa | 2015-09-24 18:14:54 +0900 | [diff] [blame] | 213 | void linux_wlan_rx_complete(void); |
Glen Lee | ef2b784 | 2015-09-24 18:14:55 +0900 | [diff] [blame] | 214 | void linux_wlan_dbg(u8 *buff); |
Glen Lee | b002e20 | 2015-09-24 18:15:05 +0900 | [diff] [blame] | 215 | int linux_wlan_lock_timeout(void *vp, u32 timeout); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 216 | void wl_wlan_cleanup(void); |
Tony Cho | 12ba541 | 2015-10-20 14:26:56 +0900 | [diff] [blame] | 217 | int wilc_netdev_init(struct wilc **wilc); |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 218 | void wilc1000_wlan_deinit(struct net_device *dev); |
Glen Lee | 11f4b2e | 2015-10-27 18:27:51 +0900 | [diff] [blame^] | 219 | void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 220 | #endif |