dev.h 8.9 KB

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