Marco Hsu / WIFI_API
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nmi_wlan_if.h Source File

nmi_wlan_if.h

00001 ////////////////////////////////////////////////////////////////////////////
00002 //
00003 // Copyright (c) Newport Media Inc.  All rights reserved.
00004 //
00005 // Module Name:  nmi_wlan_if.h
00006 //
00007 //
00008 //////////////////////////////////////////////////////////////////////////////
00009 
00010 #ifndef NMI_WLAN_IF_H
00011 #define NMI_WLAN_IF_H
00012 
00013 #if defined(_LINUX_)
00014 
00015 #include <linux/slab.h>
00016 #include <linux/sched.h>
00017 #include <linux/delay.h>
00018 #include <linux/workqueue.h>
00019 #include <linux/interrupt.h>
00020 #include <linux/irq.h>
00021 #include <asm/gpio.h>
00022 #include <linux/kthread.h>
00023 #include <linux/firmware.h>
00024 #include <linux/string.h>
00025 #include <linux/delay.h>
00026 
00027 #include <linux/init.h>
00028 #include <linux/netdevice.h>
00029 #include <linux/etherdevice.h>
00030 #include <linux/module.h>
00031 #include <linux/kernel.h>
00032 #include <linux/skbuff.h>
00033 #include <linux/version.h>
00034 #include <linux/semaphore.h>
00035 
00036 #else
00037 
00038 #define SPI_RW_SEPARATE//Ryan
00039 //#include "os_api.h"
00040 //#include "IN_Message.h"
00041 //#include "tcpip_types.h"
00042 //#include "tcpip_api.h"
00043 //#include "app_tcp_if.h"
00044 //#include "wifisupp_api.h"
00045 #include "nmi_wifi_adapter.h"
00046 //#include "wifi_drv.h"
00047 //#include "nmi_os.h"
00048 //#include "nmi_config.h"//command by Tsungta
00049 
00050 #endif
00051 
00052 #include "nmi_type.h"
00053 
00054 #ifdef __SC6800H__
00055 #define BIG_ENDIAN
00056 #endif
00057 
00058 /********************************************
00059 
00060     Debug Flags
00061 
00062 ********************************************/
00063 
00064 #define N_INIT      0x00000001
00065 #define N_ERR           0x00000002
00066 #define N_TXQ           0x00000004
00067 #define N_INTR      0x00000008
00068 #define N_RXQ           0x00000010
00069 #define N_TRACE     0x00000020
00070 #define N_LIST      0x00000040
00071 #define N_SCAN      0x00000080
00072 #define N_JOIN      0x00000100
00073 #define N_WARN      0x00000200
00074 #define N_HIF           0x00000400
00075 #define N_BUS           0x00000800
00076 #define N_FW_STATE  0x00001000
00077 #define N_ALL           0xffffffff
00078 
00079 
00080 /********************************************
00081 
00082     Host SDIO Bus Interface Defines
00083 
00084 ********************************************/
00085 
00086 #define N_SDIO 0
00087 /**
00088     Note:
00089         Set the SDIO block size here. The max is 2k.
00090 **/
00091 #define NMI_SDIO_BLOCK_SIZE             512 
00092 
00093 typedef struct {
00094     u32 read_write:1;
00095     u32 function:3;
00096     u32 raw:1;
00097     u32 address:17;
00098     u32 data:8;
00099 } sdio_cmd52_t;
00100 
00101 typedef struct {
00102     struct {
00103         u32 read_write:1;
00104         u32 function:3;
00105         u32 block_mode:1;
00106         u32 increment:1;
00107         u32 address:17;
00108         u32 count:9;
00109     } bit;
00110     u8 *buffer;
00111     u32 block_size;
00112 } sdio_cmd53_t;
00113 
00114 /********************************************
00115 
00116     Host SPI Bus Interface Defines
00117 
00118 ********************************************/
00119 
00120 //#define SPI_RW_SEPARATE
00121 #define N_SPI 1
00122 #define SPI_DATA_PKT_SZ_256             256
00123 #define SPI_DATA_PKT_SZ_512             512
00124 #define SPI_DATA_PKT_SZ_1K              1024
00125 #define SPI_DATA_PKT_SZ_2K              (2 * 1024)
00126 #define SPI_DATA_PKT_SZ_4K              (4 * 1024)
00127 #define SPI_DATA_PKT_SZ_8K              (8 * 1024)
00128 /**
00129     
00130     Note:
00131         Set the SPI transfer size here. See above
00132 **/
00133 #define SPI_DATA_PKT_SZ                 SPI_DATA_PKT_SZ_4K//SPI_DATA_PKT_SZ_8K  
00134 
00135 /********************************************
00136 
00137     Wlan Interfaces Defines 
00138 
00139 ********************************************/
00140 
00141 #define MAX_SSID_LEN            33
00142 
00143 typedef enum {
00144     NO_SECURITY = 0,
00145     WEP_40 = 0x3,
00146     WEP_104 = 0x7,
00147     WPA_AES = 0x29,
00148     WPA_TKIP = 0x49,
00149     WPA_AES_TKIP = 0x69,        /* Aes or Tkip */
00150     WPA2_AES = 0x31,
00151     WPA2_TKIP = 0x51,
00152     WPA2_AES_TKIP = 0x71,   /* Aes or Tkip */
00153     WP2_WPA_AES = 0x39,     /* ksong add 2013.5.21 it is a wired value */
00154     WPA2_WPA_AES_TKIP = 0x79, /* ksong add 2013.5.13 */
00155 } SECURITY_T; 
00156 
00157 typedef enum {
00158     INFRASTRUCTURE  = 1,
00159     INDEPENDENT     = 2,
00160     ANY_BSS         = 3
00161 } BSSTYPE_T;
00162 
00163 typedef enum{
00164     PASSIVE_SCAN = 0,
00165     ACTIVE_SCAN  = 1,
00166     NUM_SCANTYPE
00167 } SCANTYPE_T;
00168 
00169 typedef enum{
00170     OPEN_SYSTEM = 1,
00171     SHARED_KEY = 2,
00172     ANY = 3
00173 } AUTHTYPE_T;
00174 
00175 typedef enum {
00176     NO_POWERSAVE     = 0,
00177     MIN_FAST_PS      = 1,
00178     MAX_FAST_PS      = 2,
00179     MIN_PSPOLL_PS    = 3,
00180     MAX_PSPOLL_PS    = 4
00181 } USER_PS_MODE_T;
00182 
00183 typedef enum{
00184     SUCCESS_MLMESTATUS  = 0,
00185     INVALID_MLMESTATUS  = 1,
00186     TIMEOUT             = 2,
00187     REFUSED             = 3,
00188     TOMANY_REQ          = 4,
00189     ALREADY_BSS         = 5
00190 } MLMESTATUS_T;
00191 
00192 typedef struct {
00193     int status;
00194     u8 bssid[6];
00195     u16 asoc_req_len;   
00196     u8 *asoc_req;
00197     u16 asoc_rsp_len;   
00198     u8 *asoc_rsp;
00199 } nmi_wl_join_rsp_t;
00200 
00201 typedef struct {
00202     int chan_no;
00203     u8 bssid[6];
00204     //u16 ssid_len;
00205     u8 ssid[33];
00206     BSSTYPE_T bss_type;
00207     AUTHTYPE_T auth_type;
00208     SECURITY_T sec_type;
00209     u8 *key;
00210     u8 key_len, key_idx;
00211     u16 beacon_period;
00212     void *priv;
00213     void (*join_callback_fun)(void *, nmi_wl_join_rsp_t *);
00214     void (*disconnect_callback_fun)(void *);
00215 } nmi_wl_join_t;
00216 
00217 typedef struct
00218 {
00219     u32 bss_type;
00220     u32   chan_no;
00221     u32  beacon_period;
00222     u32  cap_info;
00223     u8  bssid[8];
00224     u8  ssid[36];
00225     s32     rssi;
00226     u32  dot11i_info;
00227     u32  ht_capable;
00228     u32 max_rate;
00229     //u8 *ie;
00230     //u16 ie_len;
00231 } nmi_wl_bss_t;
00232 
00233 typedef struct {
00234     void *priv;
00235     SCANTYPE_T scan_type;
00236     BSSTYPE_T bss_type;
00237     u32 ssid_len;
00238     u8 ssid[32];
00239     u16 n_channel;
00240     u8 channel[14];
00241     u32 active_scan_time;
00242     u32 passive_scan_time;
00243     unsigned char *ie;
00244     u32 ie_len;
00245     void (*scan_callback_fun)(void *, nmi_wl_bss_t *, int, int);
00246 } nmi_wl_scan_t;
00247 
00248 typedef struct {
00249     SECURITY_T sec_type;
00250     u8 bssid[6];
00251     u8 key_index;
00252     int seq_len;
00253     u8 *seq;
00254     int key_len;
00255     u8 *key;
00256     int grp;
00257 
00258 } nmi_add_key_t;
00259 
00260 /* Atmel: 1-15-2015 */
00261 typedef struct {
00262     u8 password[64];
00263     u8 ssid[MAX_SSID_LEN];
00264     u8 psk[40]; 
00265 } pmk_cache_info_t;
00266 
00267 /********************************************
00268 
00269     Platform Interface Defines
00270 
00271 ********************************************/
00272 
00273 #define HOST_ID_ANDROID 0
00274 #define HOST_ID_RTOS 1
00275 
00276 typedef enum {
00277     TXQ_LOCK = 1,
00278     RXQ_LOCK,
00279     CFQ_LOCK,
00280     QRQ_LOCK,
00281     QSQ_LOCK,
00282     IO_LOCK,
00283 } LOCK_ID_T;
00284 
00285 typedef enum {
00286     HIF_WAIT = 1,
00287     RXQ_WAIT,
00288     SYNC_WAIT,
00289 } WAIT_ID_T;
00290 
00291 typedef struct {
00292     int type;
00293     union {
00294         struct {
00295             int external_intr_pin;
00296             int (*sdio_cmd52)(sdio_cmd52_t *);
00297             int (*sdio_cmd53)(sdio_cmd53_t *);
00298         } sdio;
00299         struct {
00300 #ifdef SPI_RW_SEPARATE
00301             int (*spi_io)(u8 *, u32, u8 *, u32);
00302 #else
00303             int (*spi_io)(u8 *, u8 *, u32);
00304 #endif
00305         } spi;
00306     } u;
00307 } nmi_wl_io_t;
00308 
00309 typedef struct {
00310     void (*print)(char *);
00311     void (*msleep)(u32);
00312     void *(*malloc)(u32);
00313     void (*free)(void *);
00314     void (*lock)(void *, LOCK_ID_T);
00315     void (*unlock)(void *, LOCK_ID_T);
00316     int (*wait)(void *, WAIT_ID_T, u32);
00317     void (*signal)(void *, WAIT_ID_T);
00318     u32 (*net_rx)(void *, u8 *, u32);
00319     void (*net_enable_irq)(void *);
00320     void (*net_tx_resume)(void *);
00321     void (*net_tx_stop)(void *);
00322     void (*net_link_up)(void *);
00323     void (*net_link_down)(void *);
00324     void (*power_up)(void *);
00325     void (*power_down)(void *);
00326     void (*rssi_fun)(s8);  
00327 } nmi_wl_plat_func_t;
00328 
00329 typedef struct {
00330     void *priv;
00331     u32 dbgflag;    
00332     u32 host_id;
00333     nmi_wl_plat_func_t fun;
00334     nmi_wl_io_t io;
00335 } nmi_wl_platform_t;
00336 
00337 typedef void (*free_txb_cb_fun_t)(void *, u8 *, u32);
00338 /* Atmel: 1-15-2015 */
00339 typedef void (*query_cb_fun_t)(u32, u32);
00340 
00341 typedef struct {
00342 //  int (*firmware_download)(u8 *, u32);
00343     int (*firmware_download)(const u8 *, u32);//Ryan
00344     int (*hw_start)(void);
00345     void (*hw_stop)(void);
00346     void (*host_trans)(void);
00347     void (*host_indicate_rx_isr)(void);
00348     void (*host_rx_trans)(void);
00349     void (*host_tx_trans)(void);
00350     int (*net_que_tx_frame)(void *, u8 *, u32, free_txb_cb_fun_t);
00351     void (*net_disp_rx_frame)(void);
00352     int (*wl_scan)(nmi_wl_scan_t *);
00353     int (*wl_join)(nmi_wl_join_t *);
00354     int (*wl_leave)(void);
00355     int (*wl_add_key)(nmi_add_key_t *);
00356     int (*wl_del_key)(nmi_add_key_t *);
00357     int (*wl_get_mac_addr)(void *);
00358     int (*wl_power_save_enable)(int);
00359     void (*wl_clean)(void); /* ksong add 2013.5.9 */
00360     void (*wl_sleep)(u32);   /* ksong add 2013-6-26 */
00361     void (*wl_wakeup)(void); /* ksong add 2013-6-26 */
00362 } nmi_wl_core_func_t;
00363 
00364 #if 1//Ryan
00365 typedef uint32 TCPIP_NETID_T;//Ryan
00366 
00367 struct nmi_wl_adp_t {
00368     
00369 //  void *hif_event;
00370 //  void *rxq_event;
00371 //  void *sync_event;
00372 
00373     nmi_wl_core_func_t core;
00374 
00375     uint8 mac_address[6];
00376 
00377     TCPIP_NETID_T  net_id;
00378 
00379     int quit;
00380 
00381     uint32 hif_thread_id;
00382     uint32 rxq_thread_id ;
00383 
00384     uint8 disconnect_req; /* disconnect request */
00385     uint8 already_on;     /*avoid re-enter the init and deinit function. */
00386     uint8 not_inform_app;  /* sometimes we do not need to inform app that connection is fail */
00387     NMI_WIFISUPP_SSID_CONFIG_T connect_info; /* Store the connect info */
00388     NMI_STATE_T state;  /* record the state */
00389     void *poll_dhcp_timer;  /* dhcp poll timer */
00390 };
00391 #endif
00392 
00393 extern int nmi_wl_core_init(nmi_wl_platform_t *, nmi_wl_core_func_t *, u8 *);
00394 
00395 /* Definitions for error constants. */
00396 
00397 #define ERR_OK          0    /* No error, everything OK. */
00398 #define ERR_MEM        -1    /* Out of memory error.     */
00399 #define ERR_BUF        -2    /* Buffer error.            */
00400 #define ERR_TIMEOUT    -3    /* Timeout.                 */
00401 #define ERR_RTE        -4    /* Routing problem.         */
00402 #define ERR_INPROGRESS -5    /* Operation in progress    */
00403 #define ERR_VAL        -6    /* Illegal value.           */
00404 #define ERR_WOULDBLOCK -7    /* Operation would block.   */
00405 #define ERR_USE        -8    /* Address in use.          */
00406 #define ERR_ISCONN     -9    /* Already connected.       */
00407 
00408 #define ERR_IS_FATAL(e) ((e) < ERR_ISCONN)
00409 
00410 #define ERR_ABRT       -10   /* Connection aborted.      */
00411 #define ERR_RST        -11   /* Connection reset.        */
00412 #define ERR_CLSD       -12   /* Connection closed.       */
00413 #define ERR_CONN       -13   /* Not connected.           */
00414 
00415 #define ERR_ARG        -14   /* Illegal argument.        */
00416 
00417 #define ERR_IF         -15   /* Low-level netif error    */
00418 
00419 #define NMI_PRINTF(...) DPRINT(N_ERR, __VA_ARGS__);//vDebugPrintf("\r\n"); vDebugPrintf(__VA_ARGS__); vDebugPrintf("\r\n");// vTaskDelay( 5 / portTICK_RATE_MS );//printk(__VA_ARGS__)
00420 
00421 typedef enum{
00422     WIFI_SCAN_DONE  = 1,
00423     WIFI_CONNECTED,
00424     WIFI_MAC_READY,
00425     WIFI_DISCONNECTED,//Tsungta     
00426 }tenuWiFiEventType;//Ryan
00427 
00428 #endif