dev.h 5.2 KB

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