#ifndef _HGIC_FMAC_H_ #define _HGIC_FMAC_H_ #ifndef __RTOS__ #include #endif #include #include #include #include "../hgic_def.h" #include "../utils/utils.h" #include "../utils/fwdl.h" #include "../utils/fwctrl.h" #include "procfs.h" #include "../utils/ota.h" #define FWEVNTQ_SIZE (128) enum hgicf_dev_flags { HGICF_DEV_FLAGS_INITED, HGICF_DEV_FLAGS_RUNNING, HGICF_DEV_FLAGS_SUSPEND, HGICF_DEV_FLAGS_BOOTDL, }; enum hgicf_state { HGICF_STATE_NONE = 0, HGICF_STATE_START, HGICF_STATE_FW_LD, HGICF_STATE_STOP, HGICF_STATE_PAUSE, HGICF_STATE_QUEUE_STOPPED, }; enum hgicf_hw_state { HGICF_HW_DISCONNECTED, HGICF_HW_DISABLED, HGICF_HW_INACTIVE, HGICF_HW_SCANNING, HGICF_HW_AUTHENTICATING, HGICF_HW_ASSOCIATING, HGICF_HW_ASSOCIATED, HGICF_HW_4WAY_HANDSHAKE, HGICF_HW_GROUP_HANDSHAKE, HGICF_HW_CONNECTED, }; struct hgicf_wdev; struct hgicf_vif { u8 fwifidx; unsigned long state; struct net_device *ndev; struct hgicf_wdev *hg; int hw_state; char hw_ssid[32]; char hw_bssid[ETH_ALEN]; int disconnect_reason; int assoc_status_code; }; struct hgicf_status { u32 tx_bitrate; s8 signal; s8 evm; s8 pair_state; u8 conntect_fail; }; struct hgicf_wdev { void *dev; u32 dev_id; unsigned long flags; u16 data_cookie; u16 ctrl_cookie; u16 rx_cookie; spinlock_t lock; struct hgic_fw_info fwinfo; struct hgic_bus *bus; struct hgicf_vif *ap; struct hgicf_vif *sta; struct sk_buff_head tx_dataq; struct work_struct tx_work; struct work_struct delay_init; /*delay init work*/ struct work_struct alive_work; struct workqueue_struct *tx_wq; struct delayed_work status_work; /*status print work*/ struct hgic_fwctrl ctrl; struct hgic_bootdl bootdl; struct hgicf_procfs proc; struct hgicf_status status; struct timer_list alive_tmr; unsigned long last_rx; /*if test*/ struct work_struct test_work; u32 test_rx_len, test_tx_len; u32 test_jiff, if_test; /*soft fc*/ int soft_fc; atomic_t txwnd; struct completion txwnd_cp; #ifndef __RTOS__ struct sk_buff_head custmgmt_q; struct sk_buff_head dbginfo_q; struct sk_buff_head cust_driverdata_q; #endif struct hgic_ota ota; u8 pairing_sta[6]; u8 *paired_stas; u32 paired_stas_cnt; u8 radio_off; #ifndef __RTOS__ struct { u8 buf[FWEVNTQ_SIZE]; u8 wpos, rpos; struct semaphore sema; }evtq; struct { u32 ipaddr, netmask, svrip, router, dns1, dns2; }dhcpc; #endif }; struct hgicf_hw_status { uint32_t rssi; uint32_t per; } __packed; extern void hgic_print_hex(char *buf, int len); extern char *hgicf_hw_state(int state); u16 hgicf_data_cookie(struct hgicf_wdev *hg); #ifndef __RTOS__ #define FWEVTQ_NPOS(evtq,pos) ((((evtq)->pos)+1 >= FWEVNTQ_SIZE) ? (0) : (((evtq)->pos)+1)) #define FWEVTQ_EMPTY(evtq) ((evtq)->wpos == (evtq)->rpos) #define FWEVTQ_FULL(evtq) (FWEVTQ_NPOS(evtq, wpos) == (evtq)->rpos) #define FWEVTQ_COUNT(evtq) (((evtq)->rpos <= (evtq)->wpos)?\ ((evtq)->wpos - (evtq)->rpos):\ (FWEVNTQ_SIZE-(evtq)->rpos + (evtq)->wpos)) #define FWEVTQ_GET(evtq, val) do{\ if(!FWEVTQ_EMPTY(evtq)){\ val = (evtq)->buf[(evtq)->rpos];\ (evtq)->rpos = FWEVTQ_NPOS((evtq), rpos);\ }\ } while(0) #define FWEVTQ_SET(evtq, val) do{\ if(FWEVTQ_FULL(evtq)){\ (evtq)->rpos = FWEVTQ_NPOS((evtq), rpos);\ }\ (evtq)->buf[(evtq)->wpos] = val;\ (evtq)->wpos = FWEVTQ_NPOS((evtq), wpos);\ } while (0) #endif #endif