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 <linux/ieee80211.h> 39 #include <net/cfg80211.h> 40 #include <net/ieee80211_radiotap.h> 41 #include <linux/if_arp.h> 42 #include <linux/in6.h> 43 #include <asm/checksum.h> 44 #include "host_interface.h" 45 #include "wilc_wlan.h" 46 #include <linux/wireless.h> 47 48 #define FLOW_CONTROL_LOWER_THRESHOLD 128 49 #define FLOW_CONTROL_UPPER_THRESHOLD 256 50 51 enum stats_flags { 52 WILC_WFI_RX_PKT = BIT(0), 53 WILC_WFI_TX_PKT = BIT(1), 54 }; 55 56 struct WILC_WFI_stats { 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 71 #define num_reg_frame 2 72 73 struct wilc_wfi_key { 74 u8 *key; 75 u8 *seq; 76 int key_len; 77 int seq_len; 78 u32 cipher; 79 }; 80 81 struct wilc_wfi_wep_key { 82 u8 *key; 83 u8 key_len; 84 u8 key_idx; 85 }; 86 87 struct sta_info { 88 u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN]; 89 }; 90 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; 95 u32 u32ListenDuration; 96 u64 u64ListenCookie; 97 u32 u32ListenSessionID; 98 }; 99 100 struct wilc_priv { 101 struct wireless_dev *wdev; 102 struct cfg80211_scan_request *pstrScanReq; 103 104 struct wilc_wfi_p2pListenParams strRemainOnChanParams; 105 u64 u64tx_cookie; 106 107 bool bCfgScanning; 108 u32 u32RcvdChCount; 109 110 u8 au8AssociatedBss[ETH_ALEN]; 111 struct sta_info assoc_stainfo; 112 struct net_device_stats stats; 113 u8 monitor_flag; 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; 124 struct host_if_drv *hWILCWFIDrv; 125 struct host_if_pmkid_attr pmkid_list; 126 struct WILC_WFI_stats netstats; 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]; 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 /* semaphores */ 136 struct semaphore SemHandleUpdateStats; 137 struct semaphore hSemScanReq; 138 /* */ 139 bool gbAutoRateAdjusted; 140 141 bool bInP2PlistenState; 142 143 }; 144 145 typedef struct { 146 u16 frame_type; 147 bool reg; 148 149 } struct_frame_reg; 150 151 struct wilc_vif { 152 u8 src_addr[ETH_ALEN]; 153 u8 bssid[ETH_ALEN]; 154 struct host_if_drv *hif_drv; 155 struct net_device *ndev; 156 }; 157 158 struct wilc { 159 int mac_status; 160 bool initialized; 161 #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) 162 unsigned short dev_irq_num; 163 #endif 164 int close; 165 u8 vif_num; 166 struct wilc_vif vif[NUM_CONCURRENT_IFC]; 167 u8 open_ifcs; 168 169 struct semaphore txq_add_to_head_cs; 170 spinlock_t txq_spinlock; 171 172 struct mutex rxq_cs; 173 struct mutex hif_cs; 174 175 struct semaphore cfg_event; 176 struct semaphore sync_event; 177 struct semaphore txq_event; 178 179 struct semaphore txq_thread_started; 180 181 struct task_struct *txq_thread; 182 183 unsigned char eth_src_address[NUM_CONCURRENT_IFC][6]; 184 185 const struct firmware *firmware; 186 187 #ifdef WILC_SDIO 188 struct sdio_func *wilc_sdio_func; 189 #else 190 struct spi_device *wilc_spidev; 191 #endif 192 }; 193 194 typedef struct { 195 u8 u8IfIdx; 196 u8 iftype; 197 int monitor_flag; 198 int mac_opened; 199 struct_frame_reg g_struct_frame_reg[num_reg_frame]; 200 struct net_device *wilc_netdev; 201 struct net_device_stats netstats; 202 struct wilc *wilc; 203 } perInterface_wlan_t; 204 205 struct WILC_WFI_mon_priv { 206 struct net_device *real_ndev; 207 }; 208 209 extern struct wilc *g_linux_wlan; 210 extern struct net_device *WILC_WFI_devs[]; 211 void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); 212 void linux_wlan_mac_indicate(struct wilc *wilc, int flag); 213 void linux_wlan_rx_complete(void); 214 void linux_wlan_dbg(u8 *buff); 215 int linux_wlan_lock_timeout(void *vp, u32 timeout); 216 void wl_wlan_cleanup(void); 217 int wilc_netdev_init(struct wilc **wilc); 218 void wilc1000_wlan_deinit(struct net_device *dev); 219 void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); 220 u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue); 221 #endif 222