dev.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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 "defs.h"
  13. #include "host.h"
  14. extern const struct ethtool_ops lbs_ethtool_ops;
  15. #define MAX_BSSID_PER_CHANNEL 16
  16. #define NR_TX_QUEUE 3
  17. /* For the extended Scan */
  18. #define MAX_EXTENDED_SCAN_BSSID_LIST MAX_BSSID_PER_CHANNEL * \
  19. MRVDRV_MAX_CHANNEL_SIZE + 1
  20. #define MAX_REGION_CHANNEL_NUM 2
  21. /** Chan-freq-TxPower mapping table*/
  22. struct chan_freq_power {
  23. /** channel Number */
  24. u16 channel;
  25. /** frequency of this channel */
  26. u32 freq;
  27. /** Max allowed Tx power level */
  28. u16 maxtxpower;
  29. /** TRUE:channel unsupported; FLASE:supported*/
  30. u8 unsupported;
  31. };
  32. /** region-band mapping table*/
  33. struct region_channel {
  34. /** TRUE if this entry is valid */
  35. u8 valid;
  36. /** region code for US, Japan ... */
  37. u8 region;
  38. /** band B/G/A, used for BAND_CONFIG cmd */
  39. u8 band;
  40. /** Actual No. of elements in the array below */
  41. u8 nrcfp;
  42. /** chan-freq-txpower mapping table*/
  43. struct chan_freq_power *CFP;
  44. };
  45. struct lbs_802_11_security {
  46. u8 WPAenabled;
  47. u8 WPA2enabled;
  48. u8 wep_enabled;
  49. u8 auth_mode;
  50. u32 key_mgmt;
  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. uint16_t sp_error;
  69. uint16_t sp_offset;
  70. uint16_t sp_stabletime;
  71. uint8_t sp_calcontrol;
  72. uint8_t sp_extsleepclk;
  73. uint16_t sp_reserved;
  74. };
  75. /* Mesh statistics */
  76. struct lbs_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 lbs_private {
  88. struct wireless_dev *wdev;
  89. int mesh_open;
  90. int mesh_fw_ver;
  91. int infra_open;
  92. int mesh_autostart_enabled;
  93. char name[DEV_NAME_LEN];
  94. void *card;
  95. struct net_device *dev;
  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. /** Deep sleep flag */
  111. int is_deep_sleep;
  112. /** Auto deep sleep enabled flag */
  113. int is_auto_deep_sleep_enabled;
  114. /** Device wakeup required flag */
  115. int wakeup_dev_required;
  116. /** Auto deep sleep flag*/
  117. int is_activity_detected;
  118. /** Auto deep sleep timeout (in miliseconds) */
  119. int auto_deep_sleep_timeout;
  120. /** Deep sleep wait queue */
  121. wait_queue_head_t ds_awake_q;
  122. /* Download sent:
  123. bit0 1/0=data_sent/data_tx_done,
  124. bit1 1/0=cmd_sent/cmd_tx_done,
  125. all other bits reserved 0 */
  126. u8 dnld_sent;
  127. /** thread to service interrupts */
  128. struct task_struct *main_thread;
  129. wait_queue_head_t waitq;
  130. struct workqueue_struct *work_thread;
  131. struct work_struct mcast_work;
  132. /** Scanning */
  133. struct delayed_work scan_work;
  134. struct delayed_work assoc_work;
  135. struct work_struct sync_channel;
  136. /* remember which channel was scanned last, != 0 if currently scanning */
  137. int scan_channel;
  138. u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
  139. u8 scan_ssid_len;
  140. /** Hardware access */
  141. int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
  142. void (*reset_card) (struct lbs_private *priv);
  143. int (*enter_deep_sleep) (struct lbs_private *priv);
  144. int (*exit_deep_sleep) (struct lbs_private *priv);
  145. int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
  146. /* Wake On LAN */
  147. uint32_t wol_criteria;
  148. uint8_t wol_gpio;
  149. uint8_t wol_gap;
  150. /** Wlan adapter data structure*/
  151. /** STATUS variables */
  152. u32 fwrelease;
  153. u32 fwcapinfo;
  154. struct mutex lock;
  155. /* TX packet ready to be sent... */
  156. int tx_pending_len; /* -1 while building packet */
  157. u8 tx_pending_buf[LBS_UPLD_SIZE];
  158. /* protected by hard_start_xmit serialization */
  159. /** command-related variables */
  160. u16 seqnum;
  161. struct cmd_ctrl_node *cmd_array;
  162. /** Current command */
  163. struct cmd_ctrl_node *cur_cmd;
  164. int cur_cmd_retcode;
  165. /** command Queues */
  166. /** Free command buffers */
  167. struct list_head cmdfreeq;
  168. /** Pending command buffers */
  169. struct list_head cmdpendingq;
  170. wait_queue_head_t cmd_pending;
  171. /* Command responses sent from the hardware to the driver */
  172. u8 resp_idx;
  173. u8 resp_buf[2][LBS_UPLD_SIZE];
  174. u32 resp_len[2];
  175. /* Events sent from hardware to driver */
  176. struct kfifo *event_fifo;
  177. /* nickname */
  178. u8 nodename[16];
  179. /** spin locks */
  180. spinlock_t driver_lock;
  181. /** Timers */
  182. struct timer_list command_timer;
  183. struct timer_list auto_deepsleep_timer;
  184. int nr_retries;
  185. int cmd_timed_out;
  186. /** current ssid/bssid related parameters*/
  187. struct current_bss_params curbssparams;
  188. uint16_t mesh_tlv;
  189. u8 mesh_ssid[IW_ESSID_MAX_SIZE + 1];
  190. u8 mesh_ssid_len;
  191. /* IW_MODE_* */
  192. u8 mode;
  193. /* Scan results list */
  194. struct list_head network_list;
  195. struct list_head network_free_list;
  196. struct bss_descriptor *networks;
  197. u16 beacon_period;
  198. u8 beacon_enable;
  199. u8 adhoccreate;
  200. /** capability Info used in Association, start, join */
  201. u16 capability;
  202. /** MAC address information */
  203. u8 current_addr[ETH_ALEN];
  204. u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
  205. u32 nr_of_multicastmacaddr;
  206. /** 802.11 statistics */
  207. // struct cmd_DS_802_11_GET_STAT wlan802_11Stat;
  208. uint16_t enablehwauto;
  209. uint16_t ratebitmap;
  210. u8 txretrycount;
  211. /** Tx-related variables (for single packet tx) */
  212. struct sk_buff *currenttxskb;
  213. /** NIC Operation characteristics */
  214. u16 mac_control;
  215. u32 connect_status;
  216. u32 mesh_connect_status;
  217. u16 regioncode;
  218. s16 txpower_cur;
  219. s16 txpower_min;
  220. s16 txpower_max;
  221. /** POWER MANAGEMENT AND PnP SUPPORT */
  222. u8 surpriseremoved;
  223. u16 psmode; /* Wlan802_11PowermodeCAM=disable
  224. Wlan802_11PowermodeMAX_PSP=enable */
  225. u32 psstate;
  226. u8 needtowakeup;
  227. struct assoc_request * pending_assoc_req;
  228. struct assoc_request * in_progress_assoc_req;
  229. /** Encryption parameter */
  230. struct lbs_802_11_security secinfo;
  231. /** WEP keys */
  232. struct enc_key wep_keys[4];
  233. u16 wep_tx_keyidx;
  234. /** WPA keys */
  235. struct enc_key wpa_mcast_key;
  236. struct enc_key wpa_unicast_key;
  237. /*
  238. * In theory, the IE is limited to the IE length, 255,
  239. * but in practice 64 bytes are enough.
  240. */
  241. #define MAX_WPA_IE_LEN 64
  242. /** WPA Information Elements*/
  243. u8 wpa_ie[MAX_WPA_IE_LEN];
  244. u8 wpa_ie_len;
  245. /** Requested Signal Strength*/
  246. u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
  247. u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
  248. u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
  249. u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
  250. u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
  251. u16 nextSNRNF;
  252. u16 numSNRNF;
  253. u8 radio_on;
  254. /** data rate stuff */
  255. u8 cur_rate;
  256. /** RF calibration data */
  257. #define MAX_REGION_CHANNEL_NUM 2
  258. /** region channel data */
  259. struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
  260. /** MISCELLANEOUS */
  261. struct lbs_offset_value offsetvalue;
  262. u32 monitormode;
  263. u8 fw_ready;
  264. };
  265. extern struct cmd_confirm_sleep confirm_sleep;
  266. /**
  267. * @brief Structure used to store information for each beacon/probe response
  268. */
  269. struct bss_descriptor {
  270. u8 bssid[ETH_ALEN];
  271. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  272. u8 ssid_len;
  273. u16 capability;
  274. u32 rssi;
  275. u32 channel;
  276. u16 beaconperiod;
  277. __le16 atimwindow;
  278. /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
  279. u8 mode;
  280. /* zero-terminated array of supported data rates */
  281. u8 rates[MAX_RATES + 1];
  282. unsigned long last_scanned;
  283. union ieee_phy_param_set phy;
  284. union ieee_ss_param_set ss;
  285. u8 wpa_ie[MAX_WPA_IE_LEN];
  286. size_t wpa_ie_len;
  287. u8 rsn_ie[MAX_WPA_IE_LEN];
  288. size_t rsn_ie_len;
  289. u8 mesh;
  290. struct list_head list;
  291. };
  292. /** Association request
  293. *
  294. * Encapsulates all the options that describe a specific assocation request
  295. * or configuration of the wireless card's radio, mode, and security settings.
  296. */
  297. struct assoc_request {
  298. #define ASSOC_FLAG_SSID 1
  299. #define ASSOC_FLAG_CHANNEL 2
  300. #define ASSOC_FLAG_BAND 3
  301. #define ASSOC_FLAG_MODE 4
  302. #define ASSOC_FLAG_BSSID 5
  303. #define ASSOC_FLAG_WEP_KEYS 6
  304. #define ASSOC_FLAG_WEP_TX_KEYIDX 7
  305. #define ASSOC_FLAG_WPA_MCAST_KEY 8
  306. #define ASSOC_FLAG_WPA_UCAST_KEY 9
  307. #define ASSOC_FLAG_SECINFO 10
  308. #define ASSOC_FLAG_WPA_IE 11
  309. unsigned long flags;
  310. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  311. u8 ssid_len;
  312. u8 channel;
  313. u8 band;
  314. u8 mode;
  315. u8 bssid[ETH_ALEN] __attribute__ ((aligned (2)));
  316. /** WEP keys */
  317. struct enc_key wep_keys[4];
  318. u16 wep_tx_keyidx;
  319. /** WPA keys */
  320. struct enc_key wpa_mcast_key;
  321. struct enc_key wpa_unicast_key;
  322. struct lbs_802_11_security secinfo;
  323. /** WPA Information Elements*/
  324. u8 wpa_ie[MAX_WPA_IE_LEN];
  325. u8 wpa_ie_len;
  326. /* BSS to associate with for infrastructure of Ad-Hoc join */
  327. struct bss_descriptor bss;
  328. };
  329. #endif