OSDN Git Service

Remove hopeless Windows ULONG/USHORT/UCHAR types
[android-x86/external-modules-rtl8723au.git] / include / drv_types.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 /*-------------------------------------------------------------------------------
21
22         For type defines and data structure defines
23
24 --------------------------------------------------------------------------------*/
25
26
27 #ifndef __DRV_TYPES_H__
28 #define __DRV_TYPES_H__
29
30 #include <drv_conf.h>
31 #include <osdep_service.h>
32 #include <wlan_bssdef.h>
33
34
35 enum _NIC_VERSION {
36
37         RTL8711_NIC,
38         RTL8712_NIC,
39         RTL8713_NIC,
40         RTL8716_NIC
41
42 };
43
44
45 typedef struct _ADAPTER _adapter, ADAPTER,*PADAPTER;
46
47 #ifdef CONFIG_80211N_HT
48 #include <rtw_ht.h>
49 #endif
50
51 #include <rtw_cmd.h>
52 #include <wlan_bssdef.h>
53 #include <rtw_xmit.h>
54 #include <rtw_recv.h>
55 #include <hal_intf.h>
56 #include <hal_com.h>
57 #include <rtw_qos.h>
58 #include <rtw_security.h>
59 #include <rtw_pwrctrl.h>
60 #include <rtw_io.h>
61 #include <rtw_eeprom.h>
62 #include <sta_info.h>
63 #include <rtw_mlme.h>
64 #include <rtw_debug.h>
65 #include <rtw_rf.h>
66 #include <rtw_event.h>
67 #include <rtw_led.h>
68 #include <rtw_mlme_ext.h>
69 #include <rtw_p2p.h>
70 #include <rtw_tdls.h>
71 #include <rtw_ap.h>
72
73 #ifdef CONFIG_WAPI_SUPPORT
74 #include <rtw_wapi.h>
75 #endif
76
77 #ifdef CONFIG_DRVEXT_MODULE
78 #include <drvext_api.h>
79 #endif
80
81 #ifdef CONFIG_BR_EXT
82 #include <rtw_br_ext.h>
83 #endif  // CONFIG_BR_EXT
84
85 #ifdef CONFIG_IOCTL_CFG80211
86         #include "ioctl_cfg80211.h"
87 #endif //CONFIG_IOCTL_CFG80211
88
89 #define SPEC_DEV_ID_NONE BIT(0)
90 #define SPEC_DEV_ID_DISABLE_HT BIT(1)
91 #define SPEC_DEV_ID_ENABLE_PS BIT(2)
92 #define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3)
93 #define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
94 #define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
95
96 struct specific_device_id{
97
98         u32             flags;
99
100         u16             idVendor;
101         u16             idProduct;
102
103 };
104
105 struct registry_priv
106 {
107         u8      chip_version;
108         u8      rfintfs;
109         u8      lbkmode;
110         u8      hci;
111         NDIS_802_11_SSID        ssid;
112         u8      network_mode;   //infra, ad-hoc, auto
113         u8      channel;//ad-hoc support requirement
114         u8      wireless_mode;//A, B, G, auto
115         u8      scan_mode;//active, passive
116         u8      radio_enable;
117         u8      preamble;//long, short, auto
118         u8      vrtl_carrier_sense;//Enable, Disable, Auto
119         u8      vcs_type;//RTS/CTS, CTS-to-self
120         u16     rts_thresh;
121         u16  frag_thresh;
122         u8      adhoc_tx_pwr;
123         u8      soft_ap;
124         u8      power_mgnt;
125         u8      ips_mode;
126         u8      smart_ps;
127         u8      long_retry_lmt;
128         u8      short_retry_lmt;
129         u16     busy_thresh;
130         u8      ack_policy;
131         u8      software_encrypt;
132         u8      software_decrypt;
133         #ifdef CONFIG_TX_EARLY_MODE
134         u8   early_mode;
135         #endif
136         u8      acm_method;
137           //UAPSD
138         u8      wmm_enable;
139         u8      uapsd_enable;
140         u8      uapsd_max_sp;
141         u8      uapsd_acbk_en;
142         u8      uapsd_acbe_en;
143         u8      uapsd_acvi_en;
144         u8      uapsd_acvo_en;
145
146         WLAN_BSSID_EX    dev_network;
147
148 #ifdef CONFIG_80211N_HT
149         u8      ht_enable;
150         u8      cbw40_enable;
151         u8      ampdu_enable;//for tx
152         u8      rx_stbc;
153         u8      ampdu_amsdu;//A-MPDU Supports A-MSDU is permitted
154 #endif
155         u8      lowrate_two_xmit;
156
157         u8      rf_config ;
158         u8      low_power ;
159
160         u8      wifi_spec;// !turbo_mode
161
162         u8      channel_plan;
163 #ifdef CONFIG_BT_COEXIST
164         u8      btcoex;
165         u8      bt_iso;
166         u8      bt_sco;
167         u8      bt_ampdu;
168 #endif
169         bool    bAcceptAddbaReq;
170
171         u8      antdiv_cfg;
172         u8      antdiv_type;
173
174         u8      usbss_enable;//0:disable,1:enable
175         u8      hwpdn_mode;//0:disable,1:enable,2:decide by EFUSE config
176         u8      hwpwrp_detect;//0:disable,1:enable
177
178         u8      hw_wps_pbc;//0:disable,1:enable
179
180 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
181         char    adaptor_info_caching_file_path[PATH_LENGTH_MAX];
182 #endif
183
184 #ifdef CONFIG_LAYER2_ROAMING
185         u8      max_roaming_times; // the max number driver will try to roaming
186 #endif
187
188 #ifdef CONFIG_IOL
189         u8 fw_iol; //enable iol without other concern
190 #endif
191
192 #ifdef CONFIG_DUALMAC_CONCURRENT
193         u8      dmsp;//0:disable,1:enable
194 #endif
195
196 #ifdef CONFIG_80211D
197         u8 enable80211d;
198 #endif
199
200         u8 ifname[16];
201         u8 if2name[16];
202
203         u8 notch_filter;
204
205 #ifdef CONFIG_SPECIAL_SETTING_FOR_FUNAI_TV
206         u8 force_ant;//0 normal,1 main,2 aux
207         u8 force_igi;//0 normal
208 #endif
209         u8 regulatory_tid;
210
211 };
212
213
214 //For registry parameters
215 #define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv,field))
216 #define RGTRY_SZ(field)   sizeof(((struct registry_priv*) 0)->field)
217 #define BSSID_OFT(field) ((u32)FIELD_OFFSET(WLAN_BSSID_EX,field))
218 #define BSSID_SZ(field)   sizeof(((PWLAN_BSSID_EX) 0)->field)
219
220 #define MAX_CONTINUAL_URB_ERR 4
221
222 #ifdef CONFIG_SDIO_HCI
223 #include <drv_types_sdio.h>
224 #define INTF_DATA SDIO_DATA
225 #elif defined(CONFIG_GSPI_HCI)
226 #include <drv_types_gspi.h>
227 #define INTF_DATA GSPI_DATA
228 #endif
229
230 #define GET_PRIMARY_ADAPTER(padapter) (((_adapter *)padapter)->dvobj->if1)
231
232 #define GET_IFACE_NUMS(padapter) (((_adapter *)padapter)->dvobj->iface_nums)
233 #define GET_ADAPTER(padapter, iface_id) (((_adapter *)padapter)->dvobj->padapters[iface_id])
234
235 enum _IFACE_ID {
236         IFACE_ID0, //maping to PRIMARY_ADAPTER
237         IFACE_ID1, //maping to SECONDARY_ADAPTER
238         IFACE_ID2,
239         IFACE_ID3,
240         IFACE_ID_MAX,
241 };
242
243 struct dvobj_priv
244 {
245         _adapter *if1; //PRIMARY_ADAPTER
246         _adapter *if2; //SECONDARY_ADAPTER
247
248         //for local/global synchronization
249         _mutex hw_init_mutex;
250         _mutex h2c_fwcmd_mutex;
251         _mutex setch_mutex;
252         _mutex setbw_mutex;
253
254         unsigned char   oper_channel; //saved channel info when call set_channel_bw
255         unsigned char   oper_bwmode;
256         unsigned char   oper_ch_offset;//PRIME_CHNL_OFFSET
257
258         _adapter *padapters[IFACE_ID_MAX];
259         u8 iface_nums; // total number of ifaces used runtime
260
261         //For 92D, DMDP have 2 interface.
262         u8      InterfaceNumber;
263         u8      NumInterfaces;
264
265         //In /Out Pipe information
266         int     RtInPipe[2];
267         int     RtOutPipe[3];
268         u8      Queue2Pipe[HW_QUEUE_ENTRY];//for out pipe mapping
269
270         u8      irq_alloc;
271
272 /*-------- below is for SDIO INTERFACE --------*/
273
274 #ifdef INTF_DATA
275         INTF_DATA intf_data;
276 #endif
277
278 /*-------- below is for USB INTERFACE --------*/
279
280 #ifdef CONFIG_USB_HCI
281
282         u8      nr_endpoint;
283         u8      ishighspeed;
284         u8      RtNumInPipes;
285         u8      RtNumOutPipes;
286         int     ep_num[5]; //endpoint number
287
288         int     RegUsbSS;
289
290         struct semaphore usb_suspend_sema;
291
292 #ifdef CONFIG_USB_VENDOR_REQ_MUTEX
293         _mutex  usb_vendor_req_mutex;
294 #endif
295
296 #ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
297         u8 * usb_alloc_vendor_req_buf;
298         u8 * usb_vendor_req_buf;
299 #endif
300
301         struct usb_interface *pusbintf;
302         struct usb_device *pusbdev;
303         ATOMIC_T continual_urb_error;
304 #endif//CONFIG_USB_HCI
305
306 /*-------- below is for PCIE INTERFACE --------*/
307
308 #ifdef CONFIG_PCI_HCI
309
310         struct pci_dev *ppcidev;
311
312         //PCI MEM map
313         unsigned long   pci_mem_end;    /* shared mem end       */
314         unsigned long   pci_mem_start;  /* shared mem start     */
315
316         //PCI IO map
317         unsigned long   pci_base_addr;  /* device I/O address   */
318
319         //PciBridge
320         struct pci_priv pcipriv;
321
322         u16     irqline;
323         u8      irq_enabled;
324         RT_ISR_CONTENT  isr_content;
325         _lock   irq_th_lock;
326
327         //ASPM
328         u8      const_pci_aspm;
329         u8      const_amdpci_aspm;
330         u8      const_hwsw_rfoff_d3;
331         u8      const_support_pciaspm;
332         // pci-e bridge */
333         u8      const_hostpci_aspm_setting;
334         // pci-e device */
335         u8      const_devicepci_aspm_setting;
336         u8      b_support_aspm; // If it supports ASPM, Offset[560h] = 0x40, otherwise Offset[560h] = 0x00.
337         u8      b_support_backdoor;
338         u8 bdma64;
339 #endif//CONFIG_PCI_HCI
340 };
341
342 static struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
343 {
344         /* todo: get interface type from dvobj and the return the dev accordingly */
345 #ifdef RTW_DVOBJ_CHIP_HW_TYPE
346 #endif
347
348 #ifdef CONFIG_USB_HCI
349         return &dvobj->pusbintf->dev;
350 #endif
351 #ifdef CONFIG_SDIO_HCI
352         return &dvobj->intf_data.func->dev;
353 #endif
354 #ifdef CONFIG_GSPI_HCI
355         return &dvobj->intf_data.func->dev;
356 #endif
357 #ifdef CONFIG_PCI_HCI
358         return &dvobj->ppcidev->dev;
359 #endif
360 }
361
362 enum _IFACE_TYPE {
363         IFACE_PORT0, //mapping to port0 for C/D series chips
364         IFACE_PORT1, //mapping to port1 for C/D series chip
365         MAX_IFACE_PORT,
366 };
367
368 enum _ADAPTER_TYPE {
369         PRIMARY_ADAPTER,
370         SECONDARY_ADAPTER,
371         MAX_ADAPTER,
372 };
373
374 typedef enum _DRIVER_STATE{
375         DRIVER_NORMAL = 0,
376         DRIVER_DISAPPEAR = 1,
377         DRIVER_REPLACE_DONGLE = 2,
378 }DRIVER_STATE;
379
380 #ifdef CONFIG_INTEL_PROXIM
381 struct proxim {
382         bool proxim_support;
383         bool proxim_on;
384
385         void *proximity_priv;
386         int (*proxim_rx)(_adapter *padapter,
387                 union recv_frame *precv_frame);
388         u8      (*proxim_get_var)(_adapter* padapter, u8 type);
389 };
390 #endif  //CONFIG_INTEL_PROXIM
391
392 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
393 typedef struct loopbackdata
394 {
395         struct semaphore        sema;
396         _thread_hdl_ lbkthread;
397         u8 bstop;
398         u32 cnt;
399         u16 size;
400         u16 txsize;
401         u8 txbuf[0x8000];
402         u16 rxsize;
403         u8 rxbuf[0x8000];
404         u8 msg[100];
405
406 }LOOPBACKDATA, *PLOOPBACKDATA;
407 #endif
408
409 struct _ADAPTER{
410         int     DriverState;// for disable driver using module, use dongle to replace module.
411         int     pid[3];//process id from UI, 0:wps, 1:hostapd, 2:dhcpcd
412         int     bDongle;//build-in module or external dongle
413         u16     chip_type;
414         u16     HardwareType;
415         u16     interface_type;//USB,SDIO,SPI,PCI
416
417         struct dvobj_priv *dvobj;
418         struct  mlme_priv mlmepriv;
419         struct  mlme_ext_priv mlmeextpriv;
420         struct  cmd_priv        cmdpriv;
421         struct  evt_priv        evtpriv;
422         //struct        io_queue        *pio_queue;
423         struct  io_priv iopriv;
424         struct  xmit_priv       xmitpriv;
425         struct  recv_priv       recvpriv;
426         struct  sta_priv        stapriv;
427         struct  security_priv   securitypriv;
428         struct  registry_priv   registrypriv;
429         struct  pwrctrl_priv    pwrctrlpriv;
430         struct  eeprom_priv eeprompriv;
431         struct  led_priv        ledpriv;
432 #if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST)
433         //Check BT status for BT Hung.
434         struct workqueue_struct *priv_checkbt_wq;
435         struct delayed_work checkbt_work;
436 #endif
437
438 #ifdef CONFIG_DRVEXT_MODULE
439         struct  drvext_priv     drvextpriv;
440 #endif
441
442 #ifdef CONFIG_AP_MODE
443         struct  hostapd_priv    *phostapdpriv;
444 #endif
445
446 #ifdef CONFIG_IOCTL_CFG80211
447 #ifdef CONFIG_P2P
448         struct cfg80211_wifidirect_info cfg80211_wdinfo;
449 #endif //CONFIG_P2P
450 #endif //CONFIG_IOCTL_CFG80211
451         u32     setband;
452 #ifdef CONFIG_P2P
453         struct wifidirect_info  wdinfo;
454 #endif //CONFIG_P2P
455
456 #ifdef CONFIG_TDLS
457         struct tdls_info        tdlsinfo;
458 #endif //CONFIG_TDLS
459
460 #ifdef CONFIG_WAPI_SUPPORT
461         u8      WapiSupport;
462         RT_WAPI_T       wapiInfo;
463 #endif
464
465
466 #ifdef CONFIG_WFD
467         struct wifi_display_info wfd_info;
468 #endif //CONFIG_WFD
469
470         PVOID                   HalData;
471         u32 hal_data_sz;
472         struct hal_ops  HalFunc;
473
474         s32     bDriverStopped;
475         s32     bSurpriseRemoved;
476         s32  bCardDisableWOHSM;
477
478         u32     IsrContent;
479         u32     ImrContent;
480
481         u8      EepromAddressSize;
482         u8      hw_init_completed;
483         u8      bDriverIsGoingToUnload;
484         u8      init_adpt_in_progress;
485         u8      bHaltInProgress;
486
487         _thread_hdl_ cmdThread;
488         _thread_hdl_ evtThread;
489         _thread_hdl_ xmitThread;
490         _thread_hdl_ recvThread;
491
492         void (*intf_start)(_adapter * adapter);
493         void (*intf_stop)(_adapter * adapter);
494
495         _nic_hdl pnetdev;
496
497         // used by rtw_rereg_nd_name related function
498         struct rereg_nd_name_data {
499                 _nic_hdl old_pnetdev;
500                 char old_ifname[IFNAMSIZ];
501                 u8 old_ips_mode;
502                 u8 old_bRegUseLed;
503         } rereg_nd_name_priv;
504
505         int bup;
506         struct net_device_stats stats;
507         struct iw_statistics iwstats;
508         struct proc_dir_entry *dir_dev;// for proc directory
509
510 #ifdef CONFIG_IOCTL_CFG80211
511         struct wireless_dev *rtw_wdev;
512 #endif //CONFIG_IOCTL_CFG80211
513         int net_closed;
514
515         u8 bFWReady;
516         u8 bBTFWReady;
517         u8 bReadPortCancel;
518         u8 bWritePortCancel;
519         u8 bRxRSSIDisplay;
520         //      Added by Albert 2012/10/26
521         //      The driver will show up the desired channel number when this flag is 1.
522         u8 bNotifyChannelChange;
523 #ifdef CONFIG_P2P
524         //      Added by Albert 2012/12/06
525         //      The driver will show the current P2P status when the upper application reads it.
526         u8 bShowGetP2PState;
527 #endif
528 #ifdef CONFIG_AUTOSUSPEND
529         u8      bDisableAutosuspend;
530 #endif
531
532         _adapter *pbuddy_adapter;
533
534 #if defined(CONFIG_CONCURRENT_MODE) || defined(CONFIG_DUALMAC_CONCURRENT)
535         u8 isprimary; //is primary adapter or not
536         //notes:
537         // if isprimary is true, the adapter_type value is 0, iface_id is IFACE_ID0 for PRIMARY_ADAPTER
538         // if isprimary is false, the adapter_type value is 1, iface_id is IFACE_ID1 for SECONDARY_ADAPTER
539         // refer to iface_id if iface_nums>2 and isprimary is false and the adapter_type value is 0xff.
540         u8 adapter_type;//used only in  two inteface case(PRIMARY_ADAPTER and SECONDARY_ADAPTER) .
541         u8 iface_type; //interface port type, it depends on HW port
542 #endif
543
544         //extend to support multi interface
545         //IFACE_ID0 is equals to PRIMARY_ADAPTER
546         //IFACE_ID1 is equals to SECONDARY_ADAPTER
547         u8 iface_id;
548
549 #ifdef CONFIG_DUALMAC_CONCURRENT
550         u8 DualMacConcurrent; // 1: DMSP 0:DMDP
551 #endif
552
553 #ifdef CONFIG_BR_EXT
554         _lock                                   br_ext_lock;
555         //unsigned int                  macclone_completed;
556         struct nat25_network_db_entry   *nethash[NAT25_HASH_SIZE];
557         int                             pppoe_connection_in_progress;
558         unsigned char                   pppoe_addr[MACADDRLEN];
559         unsigned char                   scdb_mac[MACADDRLEN];
560         unsigned char                   scdb_ip[4];
561         struct nat25_network_db_entry   *scdb_entry;
562         unsigned char                   br_mac[MACADDRLEN];
563         unsigned char                   br_ip[4];
564
565         struct br_ext_info              ethBrExtInfo;
566 #endif  // CONFIG_BR_EXT
567
568 #ifdef CONFIG_INTEL_PROXIM
569         /* intel Proximity, should be alloc mem
570          * in intel Proximity module and can only
571          * be used in intel Proximity mode */
572         struct proxim proximity;
573 #endif  //CONFIG_INTEL_PROXIM
574
575 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
576         PLOOPBACKDATA ploopback;
577 #endif
578
579         u8    fix_rate;
580
581         unsigned char     in_cta_test;
582
583 };
584
585 #define adapter_to_dvobj(adapter) (adapter->dvobj)
586
587 int rtw_handle_dualmac(_adapter *adapter, bool init);
588
589 __inline static u8 *myid(struct eeprom_priv *peepriv)
590 {
591         return (peepriv->mac_addr);
592 }
593
594
595 #endif //__DRV_TYPES_H__