dev.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 country_code[IEEE80211_COUNTRY_STRING_LEN];
  46. u8 disassoc_reason;
  47. /* Mesh */
  48. struct net_device *mesh_dev; /* Virtual device */
  49. #ifdef CONFIG_LIBERTAS_MESH
  50. struct lbs_mesh_stats mstats;
  51. uint16_t mesh_tlv;
  52. u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
  53. u8 mesh_ssid_len;
  54. u8 mesh_channel;
  55. #endif
  56. /* Debugfs */
  57. struct dentry *debugfs_dir;
  58. struct dentry *debugfs_debug;
  59. struct dentry *debugfs_files[6];
  60. struct dentry *events_dir;
  61. struct dentry *debugfs_events_files[6];
  62. struct dentry *regs_dir;
  63. struct dentry *debugfs_regs_files[6];
  64. /* Hardware debugging */
  65. u32 mac_offset;
  66. u32 bbp_offset;
  67. u32 rf_offset;
  68. /* Power management */
  69. u16 psmode;
  70. u32 psstate;
  71. u8 needtowakeup;
  72. /* Deep sleep */
  73. int is_deep_sleep;
  74. int deep_sleep_required;
  75. int is_auto_deep_sleep_enabled;
  76. int wakeup_dev_required;
  77. int is_activity_detected;
  78. int auto_deep_sleep_timeout; /* in ms */
  79. wait_queue_head_t ds_awake_q;
  80. struct timer_list auto_deepsleep_timer;
  81. /* Host sleep*/
  82. int is_host_sleep_configured;
  83. int is_host_sleep_activated;
  84. wait_queue_head_t host_sleep_q;
  85. /* Hardware access */
  86. void *card;
  87. bool iface_running;
  88. u8 fw_ready;
  89. u8 surpriseremoved;
  90. u8 setup_fw_on_resume;
  91. int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
  92. void (*reset_card) (struct lbs_private *priv);
  93. int (*power_save) (struct lbs_private *priv);
  94. int (*power_restore) (struct lbs_private *priv);
  95. int (*enter_deep_sleep) (struct lbs_private *priv);
  96. int (*exit_deep_sleep) (struct lbs_private *priv);
  97. int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
  98. /* Adapter info (from EEPROM) */
  99. u32 fwrelease;
  100. u32 fwcapinfo;
  101. u16 regioncode;
  102. u8 current_addr[ETH_ALEN];
  103. u8 copied_hwaddr;
  104. /* Command download */
  105. u8 dnld_sent;
  106. /* bit0 1/0=data_sent/data_tx_done,
  107. bit1 1/0=cmd_sent/cmd_tx_done,
  108. all other bits reserved 0 */
  109. u16 seqnum;
  110. struct cmd_ctrl_node *cmd_array;
  111. struct cmd_ctrl_node *cur_cmd;
  112. struct list_head cmdfreeq; /* free command buffers */
  113. struct list_head cmdpendingq; /* pending command buffers */
  114. struct timer_list command_timer;
  115. int cmd_timed_out;
  116. /* Command responses sent from the hardware to the driver */
  117. u8 resp_idx;
  118. u8 resp_buf[2][LBS_UPLD_SIZE];
  119. u32 resp_len[2];
  120. /* Events sent from hardware to driver */
  121. struct kfifo event_fifo;
  122. /* thread to service interrupts */
  123. struct task_struct *main_thread;
  124. wait_queue_head_t waitq;
  125. struct workqueue_struct *work_thread;
  126. /* Encryption stuff */
  127. u8 authtype_auto;
  128. u8 wep_tx_key;
  129. u8 wep_key[4][WLAN_KEY_LEN_WEP104];
  130. u8 wep_key_len[4];
  131. /* Wake On LAN */
  132. uint32_t wol_criteria;
  133. uint8_t wol_gpio;
  134. uint8_t wol_gap;
  135. bool ehs_remove_supported;
  136. /* Transmitting */
  137. int tx_pending_len; /* -1 while building packet */
  138. u8 tx_pending_buf[LBS_UPLD_SIZE];
  139. /* protected by hard_start_xmit serialization */
  140. u8 txretrycount;
  141. struct sk_buff *currenttxskb;
  142. struct timer_list tx_lockup_timer;
  143. /* Locks */
  144. struct mutex lock;
  145. spinlock_t driver_lock;
  146. /* NIC/link operation characteristics */
  147. u16 mac_control;
  148. u8 radio_on;
  149. u8 cur_rate;
  150. u8 channel;
  151. s16 txpower_cur;
  152. s16 txpower_min;
  153. s16 txpower_max;
  154. /* Scanning */
  155. struct delayed_work scan_work;
  156. int scan_channel;
  157. /* Queue of things waiting for scan completion */
  158. wait_queue_head_t scan_q;
  159. /* Whether the scan was initiated internally and not by cfg80211 */
  160. bool internal_scan;
  161. /* Firmware load */
  162. u32 fw_model;
  163. wait_queue_head_t fw_waitq;
  164. struct device *fw_device;
  165. const struct firmware *helper_fw;
  166. const struct lbs_fw_table *fw_table;
  167. const struct lbs_fw_table *fw_iter;
  168. lbs_fw_cb fw_callback;
  169. };
  170. extern struct cmd_confirm_sleep confirm_sleep;
  171. /* Check if there is an interface active. */
  172. static inline int lbs_iface_active(struct lbs_private *priv)
  173. {
  174. int r;
  175. r = netif_running(priv->dev);
  176. if (priv->mesh_dev)
  177. r |= netif_running(priv->mesh_dev);
  178. return r;
  179. }
  180. #endif