1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 /*-------------------------------------------------------------------------------
8 
9 	For type defines and data structure defines
10 
11 --------------------------------------------------------------------------------*/
12 
13 
14 #ifndef __DRV_TYPES_H__
15 #define __DRV_TYPES_H__
16 
17 #include <linux/version.h>
18 #include <linux/sched/signal.h>
19 #include <autoconf.h>
20 #include <basic_types.h>
21 #include <osdep_service.h>
22 #include <rtw_byteorder.h>
23 #include <wlan_bssdef.h>
24 #include <wifi.h>
25 #include <ieee80211.h>
26 
27 enum _NIC_VERSION {
28 
29 	RTL8711_NIC,
30 	RTL8712_NIC,
31 	RTL8713_NIC,
32 	RTL8716_NIC
33 
34 };
35 
36 #include <rtw_rf.h>
37 
38 #include <rtw_ht.h>
39 
40 #ifdef CONFIG_INTEL_WIDI
41 #include <rtw_intel_widi.h>
42 #endif
43 
44 #include <rtw_cmd.h>
45 #include <cmd_osdep.h>
46 #include <rtw_security.h>
47 #include <rtw_xmit.h>
48 #include <xmit_osdep.h>
49 #include <rtw_recv.h>
50 
51 #include <recv_osdep.h>
52 #include <rtw_efuse.h>
53 #include <hal_intf.h>
54 #include <hal_com.h>
55 #include <rtw_qos.h>
56 #include <rtw_pwrctrl.h>
57 #include <rtw_mlme.h>
58 #include <mlme_osdep.h>
59 #include <rtw_io.h>
60 #include <rtw_ioctl.h>
61 #include <rtw_ioctl_set.h>
62 #include <osdep_intf.h>
63 #include <rtw_eeprom.h>
64 #include <sta_info.h>
65 #include <rtw_event.h>
66 #include <rtw_mlme_ext.h>
67 #include <rtw_ap.h>
68 #include <rtw_efuse.h>
69 #include <rtw_version.h>
70 #include <rtw_odm.h>
71 
72 #include "ioctl_cfg80211.h"
73 
74 #include <linux/ip.h>
75 #include <linux/if_ether.h>
76 #include <ethernet.h>
77 
78 #define SPEC_DEV_ID_NONE BIT(0)
79 #define SPEC_DEV_ID_DISABLE_HT BIT(1)
80 #define SPEC_DEV_ID_ENABLE_PS BIT(2)
81 #define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3)
82 #define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
83 #define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
84 
85 struct specific_device_id{
86 
87 	u32 	flags;
88 
89 	u16 	idVendor;
90 	u16 	idProduct;
91 
92 };
93 
94 struct registry_priv
95 {
96 	u8 chip_version;
97 	u8 rfintfs;
98 	u8 lbkmode;
99 	u8 hci;
100 	struct ndis_802_11_ssid	ssid;
101 	u8 network_mode;	/* infra, ad-hoc, auto */
102 	u8 channel;/* ad-hoc support requirement */
103 	u8 wireless_mode;/* A, B, G, auto */
104 	u8 scan_mode;/* active, passive */
105 	u8 radio_enable;
106 	u8 preamble;/* long, short, auto */
107 	u8 vrtl_carrier_sense;/* Enable, Disable, Auto */
108 	u8 vcs_type;/* RTS/CTS, CTS-to-self */
109 	u16 rts_thresh;
110 	u16  frag_thresh;
111 	u8 adhoc_tx_pwr;
112 	u8 soft_ap;
113 	u8 power_mgnt;
114 	u8 ips_mode;
115 	u8 smart_ps;
116 	u8   usb_rxagg_mode;
117 	u8 long_retry_lmt;
118 	u8 short_retry_lmt;
119 	u16 busy_thresh;
120 	u8 ack_policy;
121 	u8  mp_dm;
122 	u8 software_encrypt;
123 	u8 software_decrypt;
124 	u8 acm_method;
125 	  /* UAPSD */
126 	u8 wmm_enable;
127 	u8 uapsd_enable;
128 	u8 uapsd_max_sp;
129 	u8 uapsd_acbk_en;
130 	u8 uapsd_acbe_en;
131 	u8 uapsd_acvi_en;
132 	u8 uapsd_acvo_en;
133 
134 	struct wlan_bssid_ex    dev_network;
135 
136 	u8 ht_enable;
137 	/*  0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160MHz */
138 	/*  2.4G use bit 0 ~ 3, 5G use bit 4 ~ 7 */
139 	/*  0x21 means enable 2.4G 40MHz & 5G 80MHz */
140 	u8 bw_mode;
141 	u8 ampdu_enable;/* for tx */
142 	u8 rx_stbc;
143 	u8 ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */
144 	/*  Short GI support Bit Map */
145 	/*  BIT0 - 20MHz, 1: support, 0: non-support */
146 	/*  BIT1 - 40MHz, 1: support, 0: non-support */
147 	/*  BIT2 - 80MHz, 1: support, 0: non-support */
148 	/*  BIT3 - 160MHz, 1: support, 0: non-support */
149 	u8 short_gi;
150 	/*  BIT0: Enable VHT LDPC Rx, BIT1: Enable VHT LDPC Tx, BIT4: Enable HT LDPC Rx, BIT5: Enable HT LDPC Tx */
151 	u8 ldpc_cap;
152 	/*  BIT0: Enable VHT STBC Rx, BIT1: Enable VHT STBC Tx, BIT4: Enable HT STBC Rx, BIT5: Enable HT STBC Tx */
153 	u8 stbc_cap;
154 	/*  BIT0: Enable VHT Beamformer, BIT1: Enable VHT Beamformee, BIT4: Enable HT Beamformer, BIT5: Enable HT Beamformee */
155 	u8 beamform_cap;
156 
157 	u8 lowrate_two_xmit;
158 
159 	u8 rf_config ;
160 	u8 low_power ;
161 
162 	u8 wifi_spec;/*  !turbo_mode */
163 
164 	u8 channel_plan;
165 
166 	u8 btcoex;
167 	u8 bt_iso;
168 	u8 bt_sco;
169 	u8 bt_ampdu;
170 	s8	ant_num;
171 
172 	/* false:Reject AP's Add BA req, true:accept AP's Add BA req */
173 	bool	accept_addba_req;
174 
175 	u8 antdiv_cfg;
176 	u8 antdiv_type;
177 
178 	u8 usbss_enable;/* 0:disable, 1:enable */
179 	u8 hwpdn_mode;/* 0:disable, 1:enable, 2:decide by EFUSE config */
180 	u8 hwpwrp_detect;/* 0:disable, 1:enable */
181 
182 	u8 hw_wps_pbc;/* 0:disable, 1:enable */
183 
184 	u8 max_roaming_times; /*  the max number driver will try to roaming */
185 
186 	u8 enable80211d;
187 
188 	u8 ifname[16];
189 
190 	u8 notch_filter;
191 
192 	/* define for tx power adjust */
193 	u8 RegEnableTxPowerLimit;
194 	u8 RegEnableTxPowerByRate;
195 	u8 RegPowerBase;
196 	u8 RegPwrTblSel;
197 	s8	TxBBSwing_2G;
198 	s8	TxBBSwing_5G;
199 	u8 AmplifierType_2G;
200 	u8 AmplifierType_5G;
201 	u8 bEn_RFE;
202 	u8 RFE_Type;
203 	u8  check_fw_ps;
204 
205 	u8 load_phy_file;
206 	u8 RegDecryptCustomFile;
207 
208 #ifdef CONFIG_MULTI_VIR_IFACES
209 	u8 ext_iface_num;/* primary/secondary iface is excluded */
210 #endif
211 	u8 qos_opt_enable;
212 
213 	u8 hiq_filter;
214 };
215 
216 
217 /* For registry parameters */
218 #define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
219 #define RGTRY_SZ(field)   sizeof(((struct registry_priv*) 0)->field)
220 #define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
221 #define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *) 0)->field)
222 
223 #include <drv_types_sdio.h>
224 #define INTF_DATA SDIO_DATA
225 
226 #define is_primary_adapter(adapter) (1)
227 #define get_iface_type(adapter) (IFACE_PORT0)
228 #define GET_PRIMARY_ADAPTER(padapter) (((struct adapter *)padapter)->dvobj->if1)
229 #define GET_IFACE_NUMS(padapter) (((struct adapter *)padapter)->dvobj->iface_nums)
230 #define GET_ADAPTER(padapter, iface_id) (((struct adapter *)padapter)->dvobj->padapters[iface_id])
231 
232 #ifdef CONFIG_DBG_COUNTER
233 
234 struct rx_logs {
235 	u32 intf_rx;
236 	u32 intf_rx_err_recvframe;
237 	u32 intf_rx_err_skb;
238 	u32 intf_rx_report;
239 	u32 core_rx;
240 	u32 core_rx_pre;
241 	u32 core_rx_pre_ver_err;
242 	u32 core_rx_pre_mgmt;
243 	u32 core_rx_pre_mgmt_err_80211w;
244 	u32 core_rx_pre_mgmt_err;
245 	u32 core_rx_pre_ctrl;
246 	u32 core_rx_pre_ctrl_err;
247 	u32 core_rx_pre_data;
248 	u32 core_rx_pre_data_wapi_seq_err;
249 	u32 core_rx_pre_data_wapi_key_err;
250 	u32 core_rx_pre_data_handled;
251 	u32 core_rx_pre_data_err;
252 	u32 core_rx_pre_data_unknown;
253 	u32 core_rx_pre_unknown;
254 	u32 core_rx_enqueue;
255 	u32 core_rx_dequeue;
256 	u32 core_rx_post;
257 	u32 core_rx_post_decrypt;
258 	u32 core_rx_post_decrypt_wep;
259 	u32 core_rx_post_decrypt_tkip;
260 	u32 core_rx_post_decrypt_aes;
261 	u32 core_rx_post_decrypt_wapi;
262 	u32 core_rx_post_decrypt_hw;
263 	u32 core_rx_post_decrypt_unknown;
264 	u32 core_rx_post_decrypt_err;
265 	u32 core_rx_post_defrag_err;
266 	u32 core_rx_post_portctrl_err;
267 	u32 core_rx_post_indicate;
268 	u32 core_rx_post_indicate_in_oder;
269 	u32 core_rx_post_indicate_reoder;
270 	u32 core_rx_post_indicate_err;
271 	u32 os_indicate;
272 	u32 os_indicate_ap_mcast;
273 	u32 os_indicate_ap_forward;
274 	u32 os_indicate_ap_self;
275 	u32 os_indicate_err;
276 	u32 os_netif_ok;
277 	u32 os_netif_err;
278 };
279 
280 struct tx_logs {
281 	u32 os_tx;
282 	u32 os_tx_err_up;
283 	u32 os_tx_err_xmit;
284 	u32 os_tx_m2u;
285 	u32 os_tx_m2u_ignore_fw_linked;
286 	u32 os_tx_m2u_ignore_self;
287 	u32 os_tx_m2u_entry;
288 	u32 os_tx_m2u_entry_err_xmit;
289 	u32 os_tx_m2u_entry_err_skb;
290 	u32 os_tx_m2u_stop;
291 	u32 core_tx;
292 	u32 core_tx_err_pxmitframe;
293 	u32 core_tx_err_brtx;
294 	u32 core_tx_upd_attrib;
295 	u32 core_tx_upd_attrib_adhoc;
296 	u32 core_tx_upd_attrib_sta;
297 	u32 core_tx_upd_attrib_ap;
298 	u32 core_tx_upd_attrib_unknown;
299 	u32 core_tx_upd_attrib_dhcp;
300 	u32 core_tx_upd_attrib_icmp;
301 	u32 core_tx_upd_attrib_active;
302 	u32 core_tx_upd_attrib_err_ucast_sta;
303 	u32 core_tx_upd_attrib_err_ucast_ap_link;
304 	u32 core_tx_upd_attrib_err_sta;
305 	u32 core_tx_upd_attrib_err_link;
306 	u32 core_tx_upd_attrib_err_sec;
307 	u32 core_tx_ap_enqueue_warn_fwstate;
308 	u32 core_tx_ap_enqueue_warn_sta;
309 	u32 core_tx_ap_enqueue_warn_nosta;
310 	u32 core_tx_ap_enqueue_warn_link;
311 	u32 core_tx_ap_enqueue_warn_trigger;
312 	u32 core_tx_ap_enqueue_mcast;
313 	u32 core_tx_ap_enqueue_ucast;
314 	u32 core_tx_ap_enqueue;
315 	u32 intf_tx;
316 	u32 intf_tx_pending_ac;
317 	u32 intf_tx_pending_fw_under_survey;
318 	u32 intf_tx_pending_fw_under_linking;
319 	u32 intf_tx_pending_xmitbuf;
320 	u32 intf_tx_enqueue;
321 	u32 core_tx_enqueue;
322 	u32 core_tx_enqueue_class;
323 	u32 core_tx_enqueue_class_err_sta;
324 	u32 core_tx_enqueue_class_err_nosta;
325 	u32 core_tx_enqueue_class_err_fwlink;
326 	u32 intf_tx_direct;
327 	u32 intf_tx_direct_err_coalesce;
328 	u32 intf_tx_dequeue;
329 	u32 intf_tx_dequeue_err_coalesce;
330 	u32 intf_tx_dump_xframe;
331 	u32 intf_tx_dump_xframe_err_txdesc;
332 	u32 intf_tx_dump_xframe_err_port;
333 };
334 
335 struct int_logs {
336 	u32 all;
337 	u32 err;
338 	u32 tbdok;
339 	u32 tbder;
340 	u32 bcnderr;
341 	u32 bcndma;
342 	u32 bcndma_e;
343 	u32 rx;
344 	u32 rx_rdu;
345 	u32 rx_fovw;
346 	u32 txfovw;
347 	u32 mgntok;
348 	u32 highdok;
349 	u32 bkdok;
350 	u32 bedok;
351 	u32 vidok;
352 	u32 vodok;
353 };
354 
355 #endif /*  CONFIG_DBG_COUNTER */
356 
357 struct debug_priv {
358 	u32 dbg_sdio_free_irq_error_cnt;
359 	u32 dbg_sdio_alloc_irq_error_cnt;
360 	u32 dbg_sdio_free_irq_cnt;
361 	u32 dbg_sdio_alloc_irq_cnt;
362 	u32 dbg_sdio_deinit_error_cnt;
363 	u32 dbg_sdio_init_error_cnt;
364 	u32 dbg_suspend_error_cnt;
365 	u32 dbg_suspend_cnt;
366 	u32 dbg_resume_cnt;
367 	u32 dbg_resume_error_cnt;
368 	u32 dbg_deinit_fail_cnt;
369 	u32 dbg_carddisable_cnt;
370 	u32 dbg_carddisable_error_cnt;
371 	u32 dbg_ps_insuspend_cnt;
372 	u32 dbg_dev_unload_inIPS_cnt;
373 	u32 dbg_wow_leave_ps_fail_cnt;
374 	u32 dbg_scan_pwr_state_cnt;
375 	u32 dbg_downloadfw_pwr_state_cnt;
376 	u32 dbg_fw_read_ps_state_fail_cnt;
377 	u32 dbg_leave_ips_fail_cnt;
378 	u32 dbg_leave_lps_fail_cnt;
379 	u32 dbg_h2c_leave32k_fail_cnt;
380 	u32 dbg_diswow_dload_fw_fail_cnt;
381 	u32 dbg_enwow_dload_fw_fail_cnt;
382 	u32 dbg_ips_drvopen_fail_cnt;
383 	u32 dbg_poll_fail_cnt;
384 	u32 dbg_rpwm_toogle_cnt;
385 	u32 dbg_rpwm_timeout_fail_cnt;
386 	u64 dbg_rx_fifo_last_overflow;
387 	u64 dbg_rx_fifo_curr_overflow;
388 	u64 dbg_rx_fifo_diff_overflow;
389 	u64 dbg_rx_ampdu_drop_count;
390 	u64 dbg_rx_ampdu_forced_indicate_count;
391 	u64 dbg_rx_ampdu_loss_count;
392 	u64 dbg_rx_dup_mgt_frame_drop_count;
393 	u64 dbg_rx_ampdu_window_shift_cnt;
394 };
395 
396 struct rtw_traffic_statistics {
397 	/*  tx statistics */
398 	u64	tx_bytes;
399 	u64	tx_pkts;
400 	u64	tx_drop;
401 	u64	cur_tx_bytes;
402 	u64	last_tx_bytes;
403 	u32 cur_tx_tp; /*  Tx throughput in MBps. */
404 
405 	/*  rx statistics */
406 	u64	rx_bytes;
407 	u64	rx_pkts;
408 	u64	rx_drop;
409 	u64	cur_rx_bytes;
410 	u64	last_rx_bytes;
411 	u32 cur_rx_tp; /*  Rx throughput in MBps. */
412 };
413 
414 struct cam_ctl_t {
415 	_lock lock;
416 	u64 bitmap;
417 };
418 
419 struct cam_entry_cache {
420 	u16 ctrl;
421 	u8 mac[ETH_ALEN];
422 	u8 key[16];
423 };
424 
425 #define KEY_FMT "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
426 #define KEY_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5], \
427 	((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \
428 	((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15]
429 
430 struct dvobj_priv
431 {
432 	/*-------- below is common data --------*/
433 	struct adapter *if1; /* PRIMARY_ADAPTER */
434 	struct adapter *if2; /* SECONDARY_ADAPTER */
435 
436 	s32	processing_dev_remove;
437 
438 	struct debug_priv drv_dbg;
439 
440 	/* for local/global synchronization */
441 	/*  */
442 	_lock	lock;
443 	int macid[NUM_STA];
444 
445 	_mutex hw_init_mutex;
446 	_mutex h2c_fwcmd_mutex;
447 	_mutex setch_mutex;
448 	_mutex setbw_mutex;
449 
450 	unsigned char oper_channel; /* saved channel info when call set_channel_bw */
451 	unsigned char oper_bwmode;
452 	unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */
453 	unsigned long on_oper_ch_time;
454 
455 	struct adapter *padapters;
456 
457 	struct cam_ctl_t cam_ctl;
458 	struct cam_entry_cache cam_cache[TOTAL_CAM_ENTRY];
459 
460 	/* For 92D, DMDP have 2 interface. */
461 	u8 InterfaceNumber;
462 	u8 NumInterfaces;
463 
464 	/* In /Out Pipe information */
465 	int	RtInPipe[2];
466 	int	RtOutPipe[4];
467 	u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
468 
469 	u8 irq_alloc;
470 	atomic_t continual_io_error;
471 
472 	atomic_t disable_func;
473 
474 	struct pwrctrl_priv pwrctl_priv;
475 
476 	struct rtw_traffic_statistics	traffic_stat;
477 
478 /*-------- below is for SDIO INTERFACE --------*/
479 
480 #ifdef INTF_DATA
481 	INTF_DATA intf_data;
482 #endif
483 };
484 
485 #define dvobj_to_pwrctl(dvobj) (&(dvobj->pwrctl_priv))
486 #define pwrctl_to_dvobj(pwrctl) container_of(pwrctl, struct dvobj_priv, pwrctl_priv)
487 
dvobj_to_dev(struct dvobj_priv * dvobj)488 __inline static struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
489 {
490 	/* todo: get interface type from dvobj and the return the dev accordingly */
491 #ifdef RTW_DVOBJ_CHIP_HW_TYPE
492 #endif
493 
494 	return &dvobj->intf_data.func->dev;
495 }
496 
497 struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj);
498 
499 enum _IFACE_TYPE {
500 	IFACE_PORT0, /* mapping to port0 for C/D series chips */
501 	IFACE_PORT1, /* mapping to port1 for C/D series chip */
502 	MAX_IFACE_PORT,
503 };
504 
505 enum ADAPTER_TYPE {
506 	PRIMARY_ADAPTER,
507 	SECONDARY_ADAPTER,
508 	MAX_ADAPTER = 0xFF,
509 };
510 
511 typedef enum _DRIVER_STATE{
512 	DRIVER_NORMAL = 0,
513 	DRIVER_DISAPPEAR = 1,
514 	DRIVER_REPLACE_DONGLE = 2,
515 }DRIVER_STATE;
516 
517 struct adapter {
518 	int	DriverState;/*  for disable driver using module, use dongle to replace module. */
519 	int	pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
520 	int	bDongle;/* build-in module or external dongle */
521 
522 	struct dvobj_priv *dvobj;
523 	struct	mlme_priv mlmepriv;
524 	struct	mlme_ext_priv mlmeextpriv;
525 	struct	cmd_priv cmdpriv;
526 	struct	evt_priv evtpriv;
527 	/* struct	io_queue	*pio_queue; */
528 	struct	io_priv iopriv;
529 	struct	xmit_priv xmitpriv;
530 	struct	recv_priv recvpriv;
531 	struct	sta_priv stapriv;
532 	struct	security_priv securitypriv;
533 	_lock   security_key_mutex; /*  add for CONFIG_IEEE80211W, none 11w also can use */
534 	struct	registry_priv registrypriv;
535 	struct	eeprom_priv eeprompriv;
536 
537 	struct	hostapd_priv *phostapdpriv;
538 
539 	u32 setband;
540 
541 	void *		HalData;
542 	u32 hal_data_sz;
543 	struct hal_ops	HalFunc;
544 
545 	s32	bDriverStopped;
546 	s32	bSurpriseRemoved;
547 	s32  bCardDisableWOHSM;
548 
549 	u32 IsrContent;
550 	u32 ImrContent;
551 
552 	u8 EepromAddressSize;
553 	u8 hw_init_completed;
554 	u8 bDriverIsGoingToUnload;
555 	u8 init_adpt_in_progress;
556 	u8 bHaltInProgress;
557 
558 	void *cmdThread;
559 	void *evtThread;
560 	void *xmitThread;
561 	void *recvThread;
562 
563 	u32 (*intf_init)(struct dvobj_priv *dvobj);
564 	void (*intf_deinit)(struct dvobj_priv *dvobj);
565 	int (*intf_alloc_irq)(struct dvobj_priv *dvobj);
566 	void (*intf_free_irq)(struct dvobj_priv *dvobj);
567 
568 
569 	void (*intf_start)(struct adapter * adapter);
570 	void (*intf_stop)(struct adapter * adapter);
571 
572 	_nic_hdl pnetdev;
573 	char old_ifname[IFNAMSIZ];
574 
575 	/*  used by rtw_rereg_nd_name related function */
576 	struct rereg_nd_name_data {
577 		_nic_hdl old_pnetdev;
578 		char old_ifname[IFNAMSIZ];
579 		u8 old_ips_mode;
580 		u8 old_bRegUseLed;
581 	} rereg_nd_name_priv;
582 
583 	int bup;
584 	struct net_device_stats stats;
585 	struct iw_statistics iwstats;
586 	struct proc_dir_entry *dir_dev;/*  for proc directory */
587 	struct proc_dir_entry *dir_odm;
588 
589 	struct wireless_dev *rtw_wdev;
590 	struct rtw_wdev_priv wdev_data;
591 
592 	int net_closed;
593 
594 	u8 netif_up;
595 
596 	u8 bFWReady;
597 	u8 bBTFWReady;
598 	u8 bLinkInfoDump;
599 	u8 bRxRSSIDisplay;
600 	/* 	Added by Albert 2012/10/26 */
601 	/* 	The driver will show up the desired channel number when this flag is 1. */
602 	u8 bNotifyChannelChange;
603 
604 	/* pbuddystruct adapter is used only in  two inteface case, (iface_nums =2 in struct dvobj_priv) */
605 	/* PRIMARY ADAPTER's buddy is SECONDARY_ADAPTER */
606 	/* SECONDARY_ADAPTER's buddy is PRIMARY_ADAPTER */
607 	/* for iface_id > SECONDARY_ADAPTER(IFACE_ID1), refer to padapters[iface_id]  in struct dvobj_priv */
608 	/* and their pbuddystruct adapter is PRIMARY_ADAPTER. */
609 	/* for PRIMARY_ADAPTER(IFACE_ID0) can directly refer to if1 in struct dvobj_priv */
610 	struct adapter *pbuddy_adapter;
611 
612 	/* extend to support multi interface */
613        /* IFACE_ID0 is equals to PRIMARY_ADAPTER */
614        /* IFACE_ID1 is equals to SECONDARY_ADAPTER */
615 	u8 iface_id;
616 
617 	/* for debug purpose */
618 	u8 fix_rate;
619 	u8 driver_vcs_en; /* Enable = 1, Disable = 0 driver control vrtl_carrier_sense for tx */
620 	u8 driver_vcs_type;/* force 0:disable VCS, 1:RTS-CTS, 2:CTS-to-self when vcs_en = 1. */
621 	u8 driver_ampdu_spacing;/* driver control AMPDU Density for peer sta's rx */
622 	u8 driver_rx_ampdu_factor;/* 0xff: disable drv ctrl, 0:8k, 1:16k, 2:32k, 3:64k; */
623 
624 	unsigned char     in_cta_test;
625 
626 #ifdef CONFIG_DBG_COUNTER
627 	struct rx_logs rx_logs;
628 	struct tx_logs tx_logs;
629 	struct int_logs int_logs;
630 #endif
631 };
632 
633 #define adapter_to_dvobj(adapter) (adapter->dvobj)
634 #define adapter_to_pwrctl(adapter) (dvobj_to_pwrctl(adapter->dvobj))
635 #define adapter_wdev_data(adapter) (&((adapter)->wdev_data))
636 
637 /*  */
638 /*  Function disabled. */
639 /*  */
640 #define DF_TX_BIT		BIT0
641 #define DF_RX_BIT		BIT1
642 #define DF_IO_BIT		BIT2
643 
644 /* define RTW_DISABLE_FUNC(padapter, func) (atomic_add(&adapter_to_dvobj(padapter)->disable_func, (func))) */
645 /* define RTW_ENABLE_FUNC(padapter, func) (atomic_sub(&adapter_to_dvobj(padapter)->disable_func, (func))) */
RTW_DISABLE_FUNC(struct adapter * padapter,int func_bit)646 __inline static void RTW_DISABLE_FUNC(struct adapter *padapter, int func_bit)
647 {
648 	int	df = atomic_read(&adapter_to_dvobj(padapter)->disable_func);
649 	df |= func_bit;
650 	atomic_set(&adapter_to_dvobj(padapter)->disable_func, df);
651 }
652 
RTW_ENABLE_FUNC(struct adapter * padapter,int func_bit)653 __inline static void RTW_ENABLE_FUNC(struct adapter *padapter, int func_bit)
654 {
655 	int	df = atomic_read(&adapter_to_dvobj(padapter)->disable_func);
656 	df &= ~(func_bit);
657 	atomic_set(&adapter_to_dvobj(padapter)->disable_func, df);
658 }
659 
660 #define RTW_IS_FUNC_DISABLED(padapter, func_bit) (atomic_read(&adapter_to_dvobj(padapter)->disable_func) & (func_bit))
661 
662 #define RTW_CANNOT_IO(padapter) \
663 			((padapter)->bSurpriseRemoved || \
664 			 RTW_IS_FUNC_DISABLED((padapter), DF_IO_BIT))
665 
666 #define RTW_CANNOT_RX(padapter) \
667 			((padapter)->bDriverStopped || \
668 			 (padapter)->bSurpriseRemoved || \
669 			 RTW_IS_FUNC_DISABLED((padapter), DF_RX_BIT))
670 
671 #define RTW_CANNOT_TX(padapter) \
672 			((padapter)->bDriverStopped || \
673 			 (padapter)->bSurpriseRemoved || \
674 			 RTW_IS_FUNC_DISABLED((padapter), DF_TX_BIT))
675 
676 #ifdef CONFIG_GPIO_API
677 int rtw_get_gpio(struct net_device *netdev, int gpio_num);
678 int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh);
679 int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput);
680 #endif
681 
682 #ifdef CONFIG_WOWLAN
683 int rtw_suspend_wow(struct adapter *padapter);
684 int rtw_resume_process_wow(struct adapter *padapter);
685 #endif
686 
myid(struct eeprom_priv * peepriv)687 static inline u8 *myid(struct eeprom_priv *peepriv)
688 {
689 	return peepriv->mac_addr;
690 }
691 
692 /*  HCI Related header file */
693 #include <sdio_osintf.h>
694 #include <sdio_ops.h>
695 #include <sdio_hal.h>
696 
697 #include <rtw_btcoex.h>
698 
699 void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
700 void rtw_indicate_wx_assoc_event(struct adapter *padapter);
701 void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
702 void indicate_wx_scan_complete_event(struct adapter *padapter);
703 int rtw_change_ifname(struct adapter *padapter, const char *ifname);
704 
705 extern char *rtw_phy_file_path;
706 extern char *rtw_initmac;
707 extern int rtw_mc2u_disable;
708 extern int rtw_ht_enable;
709 extern u32 g_wait_hiq_empty;
710 extern u8 g_fwdl_wintint_rdy_fail;
711 extern u8 g_fwdl_chksum_fail;
712 
713 #endif /* __DRV_TYPES_H__ */
714