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 
9 #include "mesh.h"
10 #include "defs.h"
11 #include "host.h"
12 
13 #include <linux/kfifo.h>
14 
15 /** sleep_params */
16 struct sleep_params {
17 	uint16_t sp_error;
18 	uint16_t sp_offset;
19 	uint16_t sp_stabletime;
20 	uint8_t  sp_calcontrol;
21 	uint8_t  sp_extsleepclk;
22 	uint16_t sp_reserved;
23 };
24 
25 
26 /** Private structure for the MV device */
27 struct lbs_private {
28 
29 	/* Basic networking */
30 	struct net_device *dev;
31 	u32 connect_status;
32 	struct work_struct mcast_work;
33 	u32 nr_of_multicastmacaddr;
34 	u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
35 
36 	/* CFG80211 */
37 	struct wireless_dev *wdev;
38 	bool wiphy_registered;
39 	bool stopping;
40 	struct cfg80211_scan_request *scan_req;
41 	u8 assoc_bss[ETH_ALEN];
42 	u8 disassoc_reason;
43 
44 	/* Mesh */
45 	struct net_device *mesh_dev; /* Virtual device */
46 #ifdef CONFIG_LIBERTAS_MESH
47 	u32 mesh_connect_status;
48 	struct lbs_mesh_stats mstats;
49 	int mesh_open;
50 	uint16_t mesh_tlv;
51 	u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
52 	u8 mesh_ssid_len;
53 #endif
54 
55 	/* Debugfs */
56 	struct dentry *debugfs_dir;
57 	struct dentry *debugfs_debug;
58 	struct dentry *debugfs_files[6];
59 	struct dentry *events_dir;
60 	struct dentry *debugfs_events_files[6];
61 	struct dentry *regs_dir;
62 	struct dentry *debugfs_regs_files[6];
63 
64 	/* Hardware debugging */
65 	u32 mac_offset;
66 	u32 bbp_offset;
67 	u32 rf_offset;
68 
69 	/* Power management */
70 	u16 psmode;
71 	u32 psstate;
72 	u8 needtowakeup;
73 
74 	/* Deep sleep */
75 	int is_deep_sleep;
76 	int deep_sleep_required;
77 	int is_auto_deep_sleep_enabled;
78 	int wakeup_dev_required;
79 	int is_activity_detected;
80 	int auto_deep_sleep_timeout; /* in ms */
81 	wait_queue_head_t ds_awake_q;
82 	struct timer_list auto_deepsleep_timer;
83 
84 	/* Host sleep*/
85 	int is_host_sleep_configured;
86 	int is_host_sleep_activated;
87 	wait_queue_head_t host_sleep_q;
88 
89 	/* Hardware access */
90 	void *card;
91 	u8 fw_ready;
92 	u8 surpriseremoved;
93 	u8 setup_fw_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 (*enter_deep_sleep) (struct lbs_private *priv);
97 	int (*exit_deep_sleep) (struct lbs_private *priv);
98 	int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
99 
100 	/* Adapter info (from EEPROM) */
101 	u32 fwrelease;
102 	u32 fwcapinfo;
103 	u16 regioncode;
104 	u8 current_addr[ETH_ALEN];
105 	u8 copied_hwaddr;
106 
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 
120 	/* Command responses sent from the hardware to the driver */
121 	u8 resp_idx;
122 	u8 resp_buf[2][LBS_UPLD_SIZE];
123 	u32 resp_len[2];
124 
125 	/* Events sent from hardware to driver */
126 	struct kfifo event_fifo;
127 
128 	/** thread to service interrupts */
129 	struct task_struct *main_thread;
130 	wait_queue_head_t waitq;
131 	struct workqueue_struct *work_thread;
132 
133 	/** Encryption stuff */
134 	u8 authtype_auto;
135 	u8 wep_tx_key;
136 	u8 wep_key[4][WLAN_KEY_LEN_WEP104];
137 	u8 wep_key_len[4];
138 
139 	/* Wake On LAN */
140 	uint32_t wol_criteria;
141 	uint8_t wol_gpio;
142 	uint8_t wol_gap;
143 	bool ehs_remove_supported;
144 
145 	/* Transmitting */
146 	int tx_pending_len;		/* -1 while building packet */
147 	u8 tx_pending_buf[LBS_UPLD_SIZE];
148 	/* protected by hard_start_xmit serialization */
149 	u8 txretrycount;
150 	struct sk_buff *currenttxskb;
151 
152 	/* Locks */
153 	struct mutex lock;
154 	spinlock_t driver_lock;
155 
156 	/* NIC/link operation characteristics */
157 	u16 mac_control;
158 	u8 radio_on;
159 	u8 cur_rate;
160 	u8 channel;
161 	s16 txpower_cur;
162 	s16 txpower_min;
163 	s16 txpower_max;
164 
165 	/** Scanning */
166 	struct delayed_work scan_work;
167 	int scan_channel;
168 	/* Queue of things waiting for scan completion */
169 	wait_queue_head_t scan_q;
170 	/* Whether the scan was initiated internally and not by cfg80211 */
171 	bool internal_scan;
172 	unsigned long last_scan;
173 };
174 
175 extern struct cmd_confirm_sleep confirm_sleep;
176 
177 #endif
178