dev.h 5.0 KB

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