dev.h 8.3 KB

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