wilc_wfi_netdevice.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. #define WILC_WFI_RX_INTR 0x0001
  11. #define WILC_WFI_TX_INTR 0x0002
  12. #define WILC_WFI_TIMEOUT 5
  13. #define WILC_MAX_NUM_PMKIDS 16
  14. #define PMKID_LEN 16
  15. #define PMKID_FOUND 1
  16. #define NUM_STA_ASSOCIATED 8
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/moduleparam.h>
  20. #include <linux/sched.h>
  21. #include <linux/kernel.h>
  22. #include <linux/slab.h>
  23. #include <linux/errno.h>
  24. #include <linux/types.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/time.h>
  27. #include <linux/in.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/etherdevice.h>
  30. #include <linux/ip.h>
  31. #include <linux/tcp.h>
  32. #include <linux/skbuff.h>
  33. #include <linux/ieee80211.h>
  34. #include <net/cfg80211.h>
  35. #include <linux/ieee80211.h>
  36. #include <net/cfg80211.h>
  37. #include <net/ieee80211_radiotap.h>
  38. #include <linux/if_arp.h>
  39. #include <linux/in6.h>
  40. #include <asm/checksum.h>
  41. #include "host_interface.h"
  42. #include "wilc_wlan.h"
  43. #include <linux/wireless.h>
  44. #define FLOW_CONTROL_LOWER_THRESHOLD 128
  45. #define FLOW_CONTROL_UPPER_THRESHOLD 256
  46. enum stats_flags {
  47. WILC_WFI_RX_PKT = BIT(0),
  48. WILC_WFI_TX_PKT = BIT(1),
  49. };
  50. struct WILC_WFI_stats {
  51. unsigned long rx_packets;
  52. unsigned long tx_packets;
  53. unsigned long rx_bytes;
  54. unsigned long tx_bytes;
  55. u64 rx_time;
  56. u64 tx_time;
  57. };
  58. /*
  59. * This structure is private to each device. It is used to pass
  60. * packets in and out, so there is place for a packet
  61. */
  62. #define num_reg_frame 2
  63. struct wilc_wfi_key {
  64. u8 *key;
  65. u8 *seq;
  66. int key_len;
  67. int seq_len;
  68. u32 cipher;
  69. };
  70. struct wilc_wfi_wep_key {
  71. u8 *key;
  72. u8 key_len;
  73. u8 key_idx;
  74. };
  75. struct sta_info {
  76. u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
  77. };
  78. /*Parameters needed for host interface for remaining on channel*/
  79. struct wilc_wfi_p2pListenParams {
  80. struct ieee80211_channel *pstrListenChan;
  81. enum nl80211_channel_type tenuChannelType;
  82. u32 u32ListenDuration;
  83. u64 u64ListenCookie;
  84. u32 u32ListenSessionID;
  85. };
  86. struct wilc_priv {
  87. struct wireless_dev *wdev;
  88. struct cfg80211_scan_request *pstrScanReq;
  89. struct wilc_wfi_p2pListenParams strRemainOnChanParams;
  90. u64 u64tx_cookie;
  91. bool bCfgScanning;
  92. u32 u32RcvdChCount;
  93. u8 au8AssociatedBss[ETH_ALEN];
  94. struct sta_info assoc_stainfo;
  95. struct net_device_stats stats;
  96. u8 monitor_flag;
  97. int status;
  98. struct WILC_WFI_packet *ppool;
  99. struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
  100. int rx_int_enabled;
  101. int tx_packetlen;
  102. u8 *tx_packetdata;
  103. struct sk_buff *skb;
  104. spinlock_t lock;
  105. struct net_device *dev;
  106. struct napi_struct napi;
  107. struct host_if_drv *hWILCWFIDrv;
  108. struct host_if_pmkid_attr pmkid_list;
  109. struct WILC_WFI_stats netstats;
  110. u8 WILC_WFI_wep_default;
  111. u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
  112. u8 WILC_WFI_wep_key_len[4];
  113. /* The real interface that the monitor is on */
  114. struct net_device *real_ndev;
  115. struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
  116. struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
  117. u8 wilc_groupkey;
  118. /* semaphores */
  119. struct semaphore SemHandleUpdateStats;
  120. struct semaphore hSemScanReq;
  121. /* */
  122. bool gbAutoRateAdjusted;
  123. bool bInP2PlistenState;
  124. };
  125. typedef struct {
  126. u16 frame_type;
  127. bool reg;
  128. } struct_frame_reg;
  129. struct wilc_vif {
  130. u8 src_addr[ETH_ALEN];
  131. u8 bssid[ETH_ALEN];
  132. struct host_if_drv *hif_drv;
  133. struct net_device *ndev;
  134. };
  135. struct wilc {
  136. int mac_status;
  137. bool initialized;
  138. #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
  139. unsigned short dev_irq_num;
  140. #endif
  141. int close;
  142. u8 vif_num;
  143. struct wilc_vif vif[NUM_CONCURRENT_IFC];
  144. u8 open_ifcs;
  145. struct semaphore txq_add_to_head_cs;
  146. spinlock_t txq_spinlock;
  147. struct mutex rxq_cs;
  148. struct mutex hif_cs;
  149. struct semaphore cfg_event;
  150. struct semaphore sync_event;
  151. struct semaphore txq_event;
  152. struct semaphore txq_thread_started;
  153. struct task_struct *txq_thread;
  154. unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
  155. const struct firmware *firmware;
  156. #ifdef WILC_SDIO
  157. struct sdio_func *wilc_sdio_func;
  158. #else
  159. struct spi_device *wilc_spidev;
  160. #endif
  161. };
  162. typedef struct {
  163. u8 u8IfIdx;
  164. u8 iftype;
  165. int monitor_flag;
  166. int mac_opened;
  167. struct_frame_reg g_struct_frame_reg[num_reg_frame];
  168. struct net_device *wilc_netdev;
  169. struct net_device_stats netstats;
  170. struct wilc *wilc;
  171. } perInterface_wlan_t;
  172. struct WILC_WFI_mon_priv {
  173. struct net_device *real_ndev;
  174. };
  175. extern struct wilc *g_linux_wlan;
  176. extern struct net_device *WILC_WFI_devs[];
  177. void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
  178. void linux_wlan_mac_indicate(struct wilc *wilc, int flag);
  179. void linux_wlan_rx_complete(void);
  180. void linux_wlan_dbg(u8 *buff);
  181. int linux_wlan_lock_timeout(void *vp, u32 timeout);
  182. void wl_wlan_cleanup(void);
  183. int wilc_netdev_init(struct wilc **wilc);
  184. void wilc1000_wlan_deinit(struct net_device *dev);
  185. void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
  186. u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue);
  187. #endif