dev.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /**
  2. * This file contains definitions and data structures specific
  3. * to Marvell 802.11 NIC. It contains the Device Information
  4. * structure wlan_adapter.
  5. */
  6. #ifndef _WLAN_DEV_H_
  7. #define _WLAN_DEV_H_
  8. #include <linux/netdevice.h>
  9. #include <linux/wireless.h>
  10. #include <linux/ethtool.h>
  11. #include <linux/debugfs.h>
  12. #include <net/ieee80211.h>
  13. #include "defs.h"
  14. #include "scan.h"
  15. extern struct ethtool_ops libertas_ethtool_ops;
  16. #define MAX_BSSID_PER_CHANNEL 16
  17. #define NR_TX_QUEUE 3
  18. /* For the extended Scan */
  19. #define MAX_EXTENDED_SCAN_BSSID_LIST MAX_BSSID_PER_CHANNEL * \
  20. MRVDRV_MAX_CHANNEL_SIZE + 1
  21. #define MAX_REGION_CHANNEL_NUM 2
  22. /** Chan-freq-TxPower mapping table*/
  23. struct chan_freq_power {
  24. /** channel Number */
  25. u16 channel;
  26. /** frequency of this channel */
  27. u32 freq;
  28. /** Max allowed Tx power level */
  29. u16 maxtxpower;
  30. /** TRUE:channel unsupported; FLASE:supported*/
  31. u8 unsupported;
  32. };
  33. /** region-band mapping table*/
  34. struct region_channel {
  35. /** TRUE if this entry is valid */
  36. u8 valid;
  37. /** region code for US, Japan ... */
  38. u8 region;
  39. /** band B/G/A, used for BAND_CONFIG cmd */
  40. u8 band;
  41. /** Actual No. of elements in the array below */
  42. u8 nrcfp;
  43. /** chan-freq-txpower mapping table*/
  44. struct chan_freq_power *CFP;
  45. };
  46. struct wlan_802_11_security {
  47. u8 WPAenabled;
  48. u8 WPA2enabled;
  49. u8 wep_enabled;
  50. u8 auth_mode;
  51. };
  52. /** Current Basic Service Set State Structure */
  53. struct current_bss_params {
  54. /** bssid */
  55. u8 bssid[ETH_ALEN];
  56. /** ssid */
  57. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  58. u8 ssid_len;
  59. /** band */
  60. u8 band;
  61. /** channel */
  62. u8 channel;
  63. /** zero-terminated array of supported data rates */
  64. u8 rates[MAX_RATES + 1];
  65. };
  66. /** sleep_params */
  67. struct sleep_params {
  68. u16 sp_error;
  69. u16 sp_offset;
  70. u16 sp_stabletime;
  71. u8 sp_calcontrol;
  72. u8 sp_extsleepclk;
  73. u16 sp_reserved;
  74. };
  75. /* Mesh statistics */
  76. struct wlan_mesh_stats {
  77. u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
  78. u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
  79. u32 fwd_drop_ttl; /* Fwd: TTL zero */
  80. u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
  81. u32 fwd_drop_noroute; /* Fwd: No route to Destination */
  82. u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
  83. u32 drop_blind; /* Rx: Dropped by blinding table */
  84. u32 tx_failed_cnt; /* Tx: Failed transmissions */
  85. };
  86. /** Private structure for the MV device */
  87. struct _wlan_private {
  88. int open;
  89. int mesh_open;
  90. int infra_open;
  91. int mesh_autostart_enabled;
  92. __le16 boot2_version;
  93. char name[DEV_NAME_LEN];
  94. void *card;
  95. wlan_adapter *adapter;
  96. struct net_device *dev;
  97. struct net_device_stats stats;
  98. struct net_device *mesh_dev; /* Virtual device */
  99. struct net_device *rtap_net_dev;
  100. struct ieee80211_device *ieee;
  101. struct iw_statistics wstats;
  102. struct wlan_mesh_stats mstats;
  103. struct dentry *debugfs_dir;
  104. struct dentry *debugfs_debug;
  105. struct dentry *debugfs_files[6];
  106. struct dentry *events_dir;
  107. struct dentry *debugfs_events_files[6];
  108. struct dentry *regs_dir;
  109. struct dentry *debugfs_regs_files[6];
  110. u32 mac_offset;
  111. u32 bbp_offset;
  112. u32 rf_offset;
  113. /** Upload length */
  114. u32 upld_len;
  115. /* Upload buffer */
  116. u8 upld_buf[WLAN_UPLD_SIZE];
  117. /* Download sent:
  118. bit0 1/0=data_sent/data_tx_done,
  119. bit1 1/0=cmd_sent/cmd_tx_done,
  120. all other bits reserved 0 */
  121. u8 dnld_sent;
  122. struct device *hotplug_device;
  123. /** thread to service interrupts */
  124. struct task_struct *main_thread;
  125. wait_queue_head_t waitq;
  126. struct workqueue_struct *work_thread;
  127. struct delayed_work scan_work;
  128. struct delayed_work assoc_work;
  129. struct work_struct sync_channel;
  130. /** Hardware access */
  131. int (*hw_host_to_card) (wlan_private * priv, u8 type, u8 * payload, u16 nb);
  132. int (*hw_get_int_status) (wlan_private * priv, u8 *);
  133. int (*hw_read_event_cause) (wlan_private *);
  134. };
  135. /** Association request
  136. *
  137. * Encapsulates all the options that describe a specific assocation request
  138. * or configuration of the wireless card's radio, mode, and security settings.
  139. */
  140. struct assoc_request {
  141. #define ASSOC_FLAG_SSID 1
  142. #define ASSOC_FLAG_CHANNEL 2
  143. #define ASSOC_FLAG_BAND 3
  144. #define ASSOC_FLAG_MODE 4
  145. #define ASSOC_FLAG_BSSID 5
  146. #define ASSOC_FLAG_WEP_KEYS 6
  147. #define ASSOC_FLAG_WEP_TX_KEYIDX 7
  148. #define ASSOC_FLAG_WPA_MCAST_KEY 8
  149. #define ASSOC_FLAG_WPA_UCAST_KEY 9
  150. #define ASSOC_FLAG_SECINFO 10
  151. #define ASSOC_FLAG_WPA_IE 11
  152. unsigned long flags;
  153. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  154. u8 ssid_len;
  155. u8 channel;
  156. u8 band;
  157. u8 mode;
  158. u8 bssid[ETH_ALEN];
  159. /** WEP keys */
  160. struct enc_key wep_keys[4];
  161. u16 wep_tx_keyidx;
  162. /** WPA keys */
  163. struct enc_key wpa_mcast_key;
  164. struct enc_key wpa_unicast_key;
  165. struct wlan_802_11_security secinfo;
  166. /** WPA Information Elements*/
  167. u8 wpa_ie[MAX_WPA_IE_LEN];
  168. u8 wpa_ie_len;
  169. /* BSS to associate with for infrastructure of Ad-Hoc join */
  170. struct bss_descriptor bss;
  171. };
  172. /** Wlan adapter data structure*/
  173. struct _wlan_adapter {
  174. /** STATUS variables */
  175. u8 fwreleasenumber[4];
  176. u32 fwcapinfo;
  177. /* protected with big lock */
  178. struct mutex lock;
  179. u8 tmptxbuf[WLAN_UPLD_SIZE];
  180. /* protected by hard_start_xmit serialization */
  181. /** command-related variables */
  182. u16 seqnum;
  183. /* protected by big lock */
  184. struct cmd_ctrl_node *cmd_array;
  185. /** Current command */
  186. struct cmd_ctrl_node *cur_cmd;
  187. int cur_cmd_retcode;
  188. /** command Queues */
  189. /** Free command buffers */
  190. struct list_head cmdfreeq;
  191. /** Pending command buffers */
  192. struct list_head cmdpendingq;
  193. wait_queue_head_t cmd_pending;
  194. u8 nr_cmd_pending;
  195. /* command related variables protected by adapter->driver_lock */
  196. /** Async and Sync Event variables */
  197. u32 intcounter;
  198. u32 eventcause;
  199. u8 nodename[16]; /* nickname */
  200. /** spin locks */
  201. spinlock_t driver_lock;
  202. /** Timers */
  203. struct timer_list command_timer;
  204. /* TX queue used in PS mode */
  205. spinlock_t txqueue_lock;
  206. struct sk_buff *tx_queue_ps[NR_TX_QUEUE];
  207. unsigned int tx_queue_idx;
  208. u8 hisregcpy;
  209. /** current ssid/bssid related parameters*/
  210. struct current_bss_params curbssparams;
  211. /* IW_MODE_* */
  212. u8 mode;
  213. /* Scan results list */
  214. struct list_head network_list;
  215. struct list_head network_free_list;
  216. struct bss_descriptor *networks;
  217. u8 adhoccreate;
  218. /** capability Info used in Association, start, join */
  219. u16 capability;
  220. /** MAC address information */
  221. u8 current_addr[ETH_ALEN];
  222. u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
  223. u32 nr_of_multicastmacaddr;
  224. /** 802.11 statistics */
  225. // struct cmd_DS_802_11_GET_STAT wlan802_11Stat;
  226. u16 enablehwauto;
  227. u16 ratebitmap;
  228. u32 fragthsd;
  229. u32 rtsthsd;
  230. u8 txretrycount;
  231. /** Tx-related variables (for single packet tx) */
  232. struct sk_buff *currenttxskb;
  233. u16 TxLockFlag;
  234. /** NIC Operation characteristics */
  235. u16 currentpacketfilter;
  236. u32 connect_status;
  237. u16 regioncode;
  238. u16 txpowerlevel;
  239. /** POWER MANAGEMENT AND PnP SUPPORT */
  240. u8 surpriseremoved;
  241. u16 psmode; /* Wlan802_11PowermodeCAM=disable
  242. Wlan802_11PowermodeMAX_PSP=enable */
  243. u32 psstate;
  244. u8 needtowakeup;
  245. struct PS_CMD_ConfirmSleep libertas_ps_confirm_sleep;
  246. struct assoc_request * pending_assoc_req;
  247. struct assoc_request * in_progress_assoc_req;
  248. /** Encryption parameter */
  249. struct wlan_802_11_security secinfo;
  250. /** WEP keys */
  251. struct enc_key wep_keys[4];
  252. u16 wep_tx_keyidx;
  253. /** WPA keys */
  254. struct enc_key wpa_mcast_key;
  255. struct enc_key wpa_unicast_key;
  256. /** WPA Information Elements*/
  257. u8 wpa_ie[MAX_WPA_IE_LEN];
  258. u8 wpa_ie_len;
  259. /** Requested Signal Strength*/
  260. u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
  261. u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
  262. u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
  263. u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
  264. u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
  265. u16 nextSNRNF;
  266. u16 numSNRNF;
  267. u8 radioon;
  268. u32 preamble;
  269. /** data rate stuff */
  270. u8 cur_rate;
  271. u8 auto_rate;
  272. /** sleep_params */
  273. struct sleep_params sp;
  274. /** RF calibration data */
  275. #define MAX_REGION_CHANNEL_NUM 2
  276. /** region channel data */
  277. struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
  278. struct region_channel universal_channel[MAX_REGION_CHANNEL_NUM];
  279. /** 11D and Domain Regulatory Data */
  280. struct wlan_802_11d_domain_reg domainreg;
  281. struct parsed_region_chan_11d parsed_region_chan;
  282. /** FSM variable for 11d support */
  283. u32 enable11d;
  284. /** MISCELLANEOUS */
  285. u8 *prdeeprom;
  286. struct wlan_offset_value offsetvalue;
  287. struct cmd_ds_802_11_get_log logmsg;
  288. u32 monitormode;
  289. u8 fw_ready;
  290. u8 last_scanned_channel;
  291. };
  292. #endif /* _WLAN_DEV_H_ */