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