dev.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. /**
  2. * This file contains definitions and data structures specific
  3. * to Marvell 802.11 NIC. It contains the Device Information
  4. * structure struct lbs_private..
  5. */
  6. #ifndef _LBS_DEV_H_
  7. #define _LBS_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 "hostcmd.h"
  15. extern struct ethtool_ops lbs_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 lbs_802_11_security {
  47. u8 WPAenabled;
  48. u8 WPA2enabled;
  49. u8 wep_enabled;
  50. u8 auth_mode;
  51. u32 key_mgmt;
  52. };
  53. /** Current Basic Service Set State Structure */
  54. struct current_bss_params {
  55. /** bssid */
  56. u8 bssid[ETH_ALEN];
  57. /** ssid */
  58. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  59. u8 ssid_len;
  60. /** band */
  61. u8 band;
  62. /** channel */
  63. u8 channel;
  64. /** zero-terminated array of supported data rates */
  65. u8 rates[MAX_RATES + 1];
  66. };
  67. /** sleep_params */
  68. struct sleep_params {
  69. uint16_t sp_error;
  70. uint16_t sp_offset;
  71. uint16_t sp_stabletime;
  72. uint8_t sp_calcontrol;
  73. uint8_t sp_extsleepclk;
  74. uint16_t sp_reserved;
  75. };
  76. /* Mesh statistics */
  77. struct lbs_mesh_stats {
  78. u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
  79. u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
  80. u32 fwd_drop_ttl; /* Fwd: TTL zero */
  81. u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
  82. u32 fwd_drop_noroute; /* Fwd: No route to Destination */
  83. u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
  84. u32 drop_blind; /* Rx: Dropped by blinding table */
  85. u32 tx_failed_cnt; /* Tx: Failed transmissions */
  86. };
  87. /** Private structure for the MV device */
  88. struct lbs_private {
  89. int mesh_open;
  90. int infra_open;
  91. int mesh_autostart_enabled;
  92. char name[DEV_NAME_LEN];
  93. void *card;
  94. struct net_device *dev;
  95. struct net_device_stats stats;
  96. struct net_device *mesh_dev; /* Virtual device */
  97. struct net_device *rtap_net_dev;
  98. struct iw_statistics wstats;
  99. struct lbs_mesh_stats mstats;
  100. struct dentry *debugfs_dir;
  101. struct dentry *debugfs_debug;
  102. struct dentry *debugfs_files[6];
  103. struct dentry *events_dir;
  104. struct dentry *debugfs_events_files[6];
  105. struct dentry *regs_dir;
  106. struct dentry *debugfs_regs_files[6];
  107. u32 mac_offset;
  108. u32 bbp_offset;
  109. u32 rf_offset;
  110. /* Download sent:
  111. bit0 1/0=data_sent/data_tx_done,
  112. bit1 1/0=cmd_sent/cmd_tx_done,
  113. all other bits reserved 0 */
  114. u8 dnld_sent;
  115. /** thread to service interrupts */
  116. struct task_struct *main_thread;
  117. wait_queue_head_t waitq;
  118. struct workqueue_struct *work_thread;
  119. struct work_struct mcast_work;
  120. /** Scanning */
  121. struct delayed_work scan_work;
  122. struct delayed_work assoc_work;
  123. struct work_struct sync_channel;
  124. /* remember which channel was scanned last, != 0 if currently scanning */
  125. int scan_channel;
  126. u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
  127. u8 scan_ssid_len;
  128. /** Hardware access */
  129. int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
  130. void (*reset_card) (struct lbs_private *priv);
  131. /* Wake On LAN */
  132. uint32_t wol_criteria;
  133. uint8_t wol_gpio;
  134. uint8_t wol_gap;
  135. /** Wlan adapter data structure*/
  136. /** STATUS variables */
  137. u32 fwrelease;
  138. u32 fwcapinfo;
  139. struct mutex lock;
  140. /* TX packet ready to be sent... */
  141. int tx_pending_len; /* -1 while building packet */
  142. u8 tx_pending_buf[LBS_UPLD_SIZE];
  143. /* protected by hard_start_xmit serialization */
  144. /** command-related variables */
  145. u16 seqnum;
  146. struct cmd_ctrl_node *cmd_array;
  147. /** Current command */
  148. struct cmd_ctrl_node *cur_cmd;
  149. int cur_cmd_retcode;
  150. /** command Queues */
  151. /** Free command buffers */
  152. struct list_head cmdfreeq;
  153. /** Pending command buffers */
  154. struct list_head cmdpendingq;
  155. wait_queue_head_t cmd_pending;
  156. /* Command responses sent from the hardware to the driver */
  157. u8 resp_idx;
  158. u8 resp_buf[2][LBS_UPLD_SIZE];
  159. u32 resp_len[2];
  160. /* Events sent from hardware to driver */
  161. struct kfifo *event_fifo;
  162. /* nickname */
  163. u8 nodename[16];
  164. /** spin locks */
  165. spinlock_t driver_lock;
  166. /** Timers */
  167. struct timer_list command_timer;
  168. int nr_retries;
  169. int cmd_timed_out;
  170. /** current ssid/bssid related parameters*/
  171. struct current_bss_params curbssparams;
  172. uint16_t mesh_tlv;
  173. u8 mesh_ssid[IW_ESSID_MAX_SIZE + 1];
  174. u8 mesh_ssid_len;
  175. /* IW_MODE_* */
  176. u8 mode;
  177. /* Scan results list */
  178. struct list_head network_list;
  179. struct list_head network_free_list;
  180. struct bss_descriptor *networks;
  181. u16 beacon_period;
  182. u8 beacon_enable;
  183. u8 adhoccreate;
  184. /** capability Info used in Association, start, join */
  185. u16 capability;
  186. /** MAC address information */
  187. u8 current_addr[ETH_ALEN];
  188. u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
  189. u32 nr_of_multicastmacaddr;
  190. /** 802.11 statistics */
  191. // struct cmd_DS_802_11_GET_STAT wlan802_11Stat;
  192. uint16_t enablehwauto;
  193. uint16_t ratebitmap;
  194. u8 txretrycount;
  195. /** Tx-related variables (for single packet tx) */
  196. struct sk_buff *currenttxskb;
  197. /** NIC Operation characteristics */
  198. u16 mac_control;
  199. u32 connect_status;
  200. u32 mesh_connect_status;
  201. u16 regioncode;
  202. s16 txpower_cur;
  203. s16 txpower_min;
  204. s16 txpower_max;
  205. /** POWER MANAGEMENT AND PnP SUPPORT */
  206. u8 surpriseremoved;
  207. u16 psmode; /* Wlan802_11PowermodeCAM=disable
  208. Wlan802_11PowermodeMAX_PSP=enable */
  209. u32 psstate;
  210. char ps_supported;
  211. u8 needtowakeup;
  212. struct assoc_request * pending_assoc_req;
  213. struct assoc_request * in_progress_assoc_req;
  214. /** Encryption parameter */
  215. struct lbs_802_11_security secinfo;
  216. /** WEP keys */
  217. struct enc_key wep_keys[4];
  218. u16 wep_tx_keyidx;
  219. /** WPA keys */
  220. struct enc_key wpa_mcast_key;
  221. struct enc_key wpa_unicast_key;
  222. /** WPA Information Elements*/
  223. u8 wpa_ie[MAX_WPA_IE_LEN];
  224. u8 wpa_ie_len;
  225. /** Requested Signal Strength*/
  226. u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
  227. u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
  228. u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
  229. u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
  230. u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
  231. u16 nextSNRNF;
  232. u16 numSNRNF;
  233. u8 radio_on;
  234. /** data rate stuff */
  235. u8 cur_rate;
  236. /** RF calibration data */
  237. #define MAX_REGION_CHANNEL_NUM 2
  238. /** region channel data */
  239. struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
  240. struct region_channel universal_channel[MAX_REGION_CHANNEL_NUM];
  241. /** 11D and Domain Regulatory Data */
  242. struct lbs_802_11d_domain_reg domainreg;
  243. struct parsed_region_chan_11d parsed_region_chan;
  244. /** FSM variable for 11d support */
  245. u32 enable11d;
  246. /** MISCELLANEOUS */
  247. struct lbs_offset_value offsetvalue;
  248. u32 monitormode;
  249. u8 fw_ready;
  250. };
  251. extern struct cmd_confirm_sleep confirm_sleep;
  252. /**
  253. * @brief Structure used to store information for each beacon/probe response
  254. */
  255. struct bss_descriptor {
  256. u8 bssid[ETH_ALEN];
  257. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  258. u8 ssid_len;
  259. u16 capability;
  260. u32 rssi;
  261. u32 channel;
  262. u16 beaconperiod;
  263. u32 atimwindow;
  264. /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
  265. u8 mode;
  266. /* zero-terminated array of supported data rates */
  267. u8 rates[MAX_RATES + 1];
  268. unsigned long last_scanned;
  269. union ieeetypes_phyparamset phyparamset;
  270. union IEEEtypes_ssparamset ssparamset;
  271. struct ieeetypes_countryinfofullset countryinfo;
  272. u8 wpa_ie[MAX_WPA_IE_LEN];
  273. size_t wpa_ie_len;
  274. u8 rsn_ie[MAX_WPA_IE_LEN];
  275. size_t rsn_ie_len;
  276. u8 mesh;
  277. struct list_head list;
  278. };
  279. /** Association request
  280. *
  281. * Encapsulates all the options that describe a specific assocation request
  282. * or configuration of the wireless card's radio, mode, and security settings.
  283. */
  284. struct assoc_request {
  285. #define ASSOC_FLAG_SSID 1
  286. #define ASSOC_FLAG_CHANNEL 2
  287. #define ASSOC_FLAG_BAND 3
  288. #define ASSOC_FLAG_MODE 4
  289. #define ASSOC_FLAG_BSSID 5
  290. #define ASSOC_FLAG_WEP_KEYS 6
  291. #define ASSOC_FLAG_WEP_TX_KEYIDX 7
  292. #define ASSOC_FLAG_WPA_MCAST_KEY 8
  293. #define ASSOC_FLAG_WPA_UCAST_KEY 9
  294. #define ASSOC_FLAG_SECINFO 10
  295. #define ASSOC_FLAG_WPA_IE 11
  296. unsigned long flags;
  297. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  298. u8 ssid_len;
  299. u8 channel;
  300. u8 band;
  301. u8 mode;
  302. u8 bssid[ETH_ALEN] __attribute__ ((aligned (2)));
  303. /** WEP keys */
  304. struct enc_key wep_keys[4];
  305. u16 wep_tx_keyidx;
  306. /** WPA keys */
  307. struct enc_key wpa_mcast_key;
  308. struct enc_key wpa_unicast_key;
  309. struct lbs_802_11_security secinfo;
  310. /** WPA Information Elements*/
  311. u8 wpa_ie[MAX_WPA_IE_LEN];
  312. u8 wpa_ie_len;
  313. /* BSS to associate with for infrastructure of Ad-Hoc join */
  314. struct bss_descriptor bss;
  315. };
  316. #endif