dev.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 "defs.h"
  9. #include "host.h"
  10. #include <linux/kfifo.h>
  11. /* sleep_params */
  12. struct sleep_params {
  13. uint16_t sp_error;
  14. uint16_t sp_offset;
  15. uint16_t sp_stabletime;
  16. uint8_t sp_calcontrol;
  17. uint8_t sp_extsleepclk;
  18. uint16_t sp_reserved;
  19. };
  20. /* Mesh statistics */
  21. struct lbs_mesh_stats {
  22. u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
  23. u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
  24. u32 fwd_drop_ttl; /* Fwd: TTL zero */
  25. u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
  26. u32 fwd_drop_noroute; /* Fwd: No route to Destination */
  27. u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
  28. u32 drop_blind; /* Rx: Dropped by blinding table */
  29. u32 tx_failed_cnt; /* Tx: Failed transmissions */
  30. };
  31. /* Private structure for the MV device */
  32. struct lbs_private {
  33. /* Basic networking */
  34. struct net_device *dev;
  35. u32 connect_status;
  36. struct work_struct mcast_work;
  37. u32 nr_of_multicastmacaddr;
  38. u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
  39. /* CFG80211 */
  40. struct wireless_dev *wdev;
  41. bool wiphy_registered;
  42. struct cfg80211_scan_request *scan_req;
  43. u8 assoc_bss[ETH_ALEN];
  44. u8 disassoc_reason;
  45. /* Mesh */
  46. struct net_device *mesh_dev; /* Virtual device */
  47. #ifdef CONFIG_LIBERTAS_MESH
  48. struct lbs_mesh_stats mstats;
  49. uint16_t mesh_tlv;
  50. u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
  51. u8 mesh_ssid_len;
  52. #endif
  53. /* Debugfs */
  54. struct dentry *debugfs_dir;
  55. struct dentry *debugfs_debug;
  56. struct dentry *debugfs_files[6];
  57. struct dentry *events_dir;
  58. struct dentry *debugfs_events_files[6];
  59. struct dentry *regs_dir;
  60. struct dentry *debugfs_regs_files[6];
  61. /* Hardware debugging */
  62. u32 mac_offset;
  63. u32 bbp_offset;
  64. u32 rf_offset;
  65. /* Power management */
  66. u16 psmode;
  67. u32 psstate;
  68. u8 needtowakeup;
  69. /* Deep sleep */
  70. int is_deep_sleep;
  71. int deep_sleep_required;
  72. int is_auto_deep_sleep_enabled;
  73. int wakeup_dev_required;
  74. int is_activity_detected;
  75. int auto_deep_sleep_timeout; /* in ms */
  76. wait_queue_head_t ds_awake_q;
  77. struct timer_list auto_deepsleep_timer;
  78. /* Host sleep*/
  79. int is_host_sleep_configured;
  80. int is_host_sleep_activated;
  81. wait_queue_head_t host_sleep_q;
  82. /* Hardware access */
  83. void *card;
  84. bool iface_running;
  85. u8 fw_ready;
  86. u8 surpriseremoved;
  87. u8 setup_fw_on_resume;
  88. int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
  89. void (*reset_card) (struct lbs_private *priv);
  90. int (*power_save) (struct lbs_private *priv);
  91. int (*power_restore) (struct lbs_private *priv);
  92. int (*enter_deep_sleep) (struct lbs_private *priv);
  93. int (*exit_deep_sleep) (struct lbs_private *priv);
  94. int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
  95. /* Adapter info (from EEPROM) */
  96. u32 fwrelease;
  97. u32 fwcapinfo;
  98. u16 regioncode;
  99. u8 current_addr[ETH_ALEN];
  100. u8 copied_hwaddr;
  101. /* Command download */
  102. u8 dnld_sent;
  103. /* bit0 1/0=data_sent/data_tx_done,
  104. bit1 1/0=cmd_sent/cmd_tx_done,
  105. all other bits reserved 0 */
  106. u16 seqnum;
  107. struct cmd_ctrl_node *cmd_array;
  108. struct cmd_ctrl_node *cur_cmd;
  109. struct list_head cmdfreeq; /* free command buffers */
  110. struct list_head cmdpendingq; /* pending command buffers */
  111. struct timer_list command_timer;
  112. int cmd_timed_out;
  113. /* Command responses sent from the hardware to the driver */
  114. u8 resp_idx;
  115. u8 resp_buf[2][LBS_UPLD_SIZE];
  116. u32 resp_len[2];
  117. /* Events sent from hardware to driver */
  118. struct kfifo event_fifo;
  119. /* thread to service interrupts */
  120. struct task_struct *main_thread;
  121. wait_queue_head_t waitq;
  122. struct workqueue_struct *work_thread;
  123. /* Encryption stuff */
  124. u8 authtype_auto;
  125. u8 wep_tx_key;
  126. u8 wep_key[4][WLAN_KEY_LEN_WEP104];
  127. u8 wep_key_len[4];
  128. /* Wake On LAN */
  129. uint32_t wol_criteria;
  130. uint8_t wol_gpio;
  131. uint8_t wol_gap;
  132. bool ehs_remove_supported;
  133. /* Transmitting */
  134. int tx_pending_len; /* -1 while building packet */
  135. u8 tx_pending_buf[LBS_UPLD_SIZE];
  136. /* protected by hard_start_xmit serialization */
  137. u8 txretrycount;
  138. struct sk_buff *currenttxskb;
  139. struct timer_list tx_lockup_timer;
  140. /* Locks */
  141. struct mutex lock;
  142. spinlock_t driver_lock;
  143. /* NIC/link operation characteristics */
  144. u16 mac_control;
  145. u8 radio_on;
  146. u8 cur_rate;
  147. u8 channel;
  148. s16 txpower_cur;
  149. s16 txpower_min;
  150. s16 txpower_max;
  151. /* Scanning */
  152. struct delayed_work scan_work;
  153. int scan_channel;
  154. /* Queue of things waiting for scan completion */
  155. wait_queue_head_t scan_q;
  156. /* Whether the scan was initiated internally and not by cfg80211 */
  157. bool internal_scan;
  158. };
  159. extern struct cmd_confirm_sleep confirm_sleep;
  160. /* Check if there is an interface active. */
  161. static inline int lbs_iface_active(struct lbs_private *priv)
  162. {
  163. int r;
  164. r = netif_running(priv->dev);
  165. if (priv->mesh_dev)
  166. r |= netif_running(priv->mesh_dev);
  167. return r;
  168. }
  169. #endif