dev.h 8.8 KB

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