0
0
Fork 0

bump driver version

This commit is contained in:
Daryl Ronningen 2023-10-12 16:37:43 -07:00
parent 15e9a9a80e
commit d5bdeb9503
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
53 changed files with 6970 additions and 5479 deletions

3
Kconfig Normal file
View file

@ -0,0 +1,3 @@
source "drivers/net/wireless/hugeic/hgic_smac/Kconfig"
source "drivers/net/wireless/hugeic/hgic_fmac/Kconfig"
source "drivers/net/wireless/hugeic/utils/Kconfig"

122
Makefile
View file

@ -13,7 +13,8 @@ CURRENT_PATH := $(shell pwd)
#FH8852
#ARCH := arm
#COMPILER := arm-fullhan-linux-uclibcgnueabi-
#LINUX_KERNEL_PATH := /home/matt/FH8852/FH8856_IPC_V1.1.0_20190125/board_support/kernel/linux-3.0.8
#LINUX_KERNEL_PATH := $(CURRENT_PATH)/../linux-3.0.8
#CFLAGS += -DFH8852 -DCONFIG_USB_ZERO_PACKET
#Hi3536d
#ARCH := arm
@ -29,101 +30,78 @@ CURRENT_PATH := $(shell pwd)
#MTK SDK
ARCH := mips
COMPILER := /opt/buildroot-gcc463/usr/bin/mipsel-linux-
LINUX_KERNEL_PATH := /home/dongyun/work/disk4/AH6001/RT288x_AHv1.2/source/linux-3.10.14.x
LINUX_KERNEL_PATH := $(CURRENT_PATH)/../source/linux-3.10.14.x
#Raspberry Pi
#ARCH := arm
#LINUX_KERNEL := $(shell uname -r)
#LINUX_KERNEL_PATH := /usr/src/linux-headers-$(LINUX_KERNEL)
#################################################################################################
#CFLAGS += -DCONFIG_HGIC_AH
#export CONFIG_HGIC_AH = y
CFLAGS += -DCONFIG_HGIC_AH
#CFLAGS += -DCONFIG_HGIC_2G
CFLAGS += -DCONFIG_HGIC_2G
export CONFIG_HGIC_2G = y
export CONFIG_HGIC_AH = y
#export CONFIG_HGIC_2G = y
#CFLAGS += -DCONFIG_HGIC_STABR
#export CONFIG_HGIC_STABR = y
CFLAGS += -DCONFIG_SDIO_REINIT
help:
@echo "-------------------------------------------------------------------------------------------------------------------"
@echo "--------------------------------------------------------------------------------------"
@echo "usage:"
@echo " make smac : compile SMAC driver. generate 3 ko files : hgics.ko, hgic_sdio.ko hgic_usb.ko."
@echo " make smac_usb : compile SMAC driver. generate 1 ko file : hgics_usb.ko (combined hgics.ko and hgic_usb.ko)."
@echo " make smac_sdio: compile SMAC driver. generate 1 ko file : hgics_sdio.ko (combined hgics.ko and hgic_sdio.ko)."
@echo " make smac : compile SMAC driver. support sdio/usb interface. generate hgics.ko"
@echo " make smac_usb : compile SMAC driver. only support usb interface. generate hgics.ko"
@echo " make smac_sdio: compile SMAC driver. only support sdio interface. generate hgics.ko"
@echo ""
@echo " make fmac : compile FMAC driver. generate 3 ko files : hgicf.ko, hgic_sdio.ko hgic_usb.ko."
@echo " make fmac_usb : compile FMAC driver. generate 1 ko file : hgicf_usb.ko (combined hgicf.ko and hgic_usb.ko)."
@echo " make fmac_sdio: compile FMAC driver. generate 1 ko file : hgicf_sdio.ko (combined hgicf.ko and hgic_sdio.ko)."
@echo " make fmac : compile FMAC driver. support sdio/usb interface. generate hgicf.ko"
@echo " make fmac_usb : compile FMAC driver. only support usb interface. generate hgicf.ko"
@echo " make fmac_sdio: compile FMAC driver. only support sdio interface. generate hgicf.ko"
@echo ""
@echo " make clean"
@echo "-------------------------------------------------------------------------------------------------------------------"
smac: prepare _smac _driver_smac
fmac: prepare _fmac _driver_fmac
smac_usb: prepare _smac_usb
smac_sdio: prepare _smac_sdio
fmac_usb: prepare _fmac_usb
fmac_sdio: prepare _fmac_sdio
@echo "--------------------------------------------------------------------------------------"
prepare:
mkdir -p ko
_fmac:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=hgicf EXTRA_CFLAGS=$(CFLAGS) modules
cp -f hgic_fmac/hgicf.ko ko/hgicf.ko
$(COMPILER)strip -g ko/hgicf.ko
_smac:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=hgics EXTRA_CFLAGS=$(CFLAGS) modules
smac: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=m CONFIG_HGIC_USB=y CONFIG_HGIC_SDIO=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIO -DCONFIG_HGIC_USB" modules
cp -f hgic_smac/hgics.ko ko/hgics.ko
$(COMPILER)strip -g ko/hgics.ko
_fmac_sdio:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=hgicf_sdio EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIOIN" modules
cp -f hgic_fmac/hgicf_sdio.ko ko/hgicf_sdio.ko
$(COMPILER)strip -g ko/hgicf_sdio.ko
smac_usb: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=m CONFIG_HGIC_USB=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_USB" modules
cp -f hgic_smac/hgics.ko ko/hgics.ko
$(COMPILER)strip -g ko/hgics.ko
_fmac_usb:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=hgicf_usb EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_USBIN" modules
cp -f hgic_fmac/hgicf_usb.ko ko/hgicf_usb.ko
$(COMPILER)strip -g ko/hgicf_usb.ko
smac_sdio: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=m CONFIG_HGIC_SDIO=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIO" modules
cp -f hgic_smac/hgics.ko ko/hgics.ko
$(COMPILER)strip -g ko/hgics.ko
_smac_sdio:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=hgics_sdio EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIOIN" modules
cp -f hgic_smac/hgics_sdio.ko ko/hgics_sdio.ko
$(COMPILER)strip -g ko/hgics_sdio.ko
fmac: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=m CONFIG_HGIC_USB=y CONFIG_HGIC_SDIO=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIO -DCONFIG_HGIC_USB" modules
cp -f hgic_fmac/hgicf.ko ko/hgicf.ko
$(COMPILER)strip -g ko/hgicf.ko
_smac_usb:
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_smac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICS=hgics_usb EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_USBIN" modules
cp -f hgic_smac/hgics_usb.ko ko/hgics_usb.ko
$(COMPILER)strip -g ko/hgics_usb.ko
fmac_usb: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=m CONFIG_HGIC_USB=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_USB" modules
cp -f hgic_fmac/hgicf.ko ko/hgicf.ko
$(COMPILER)strip -g ko/hgicf.ko
_driver_fmac:
cp -f hgic_fmac/Module.symvers utils/Module.symvers
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/utils ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) EXTRA_CFLAGS=$(CFLAGS) modules
cp -f utils/hgic_usb.ko ko/hgic_usb.ko
cp -f utils/hgic_sdio.ko ko/hgic_sdio.ko
$(COMPILER)strip -g ko/hgic_usb.ko
$(COMPILER)strip -g ko/hgic_sdio.ko
_driver_smac:
cp -f hgic_smac/Module.symvers utils/Module.symvers
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/utils ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) EXTRA_CFLAGS=$(CFLAGS) modules
cp -f utils/hgic_usb.ko ko/hgic_usb.ko
cp -f utils/hgic_sdio.ko ko/hgic_sdio.ko
$(COMPILER)strip -g ko/hgic_usb.ko
$(COMPILER)strip -g ko/hgic_sdio.ko
fmac_sdio: prepare
$(MAKE) -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH)/hgic_fmac ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) CONFIG_HGICF=m CONFIG_HGIC_SDIO=y EXTRA_CFLAGS="$(CFLAGS) -DCONFIG_HGIC_SDIO" modules
cp -f hgic_fmac/hgicf.ko ko/hgicf.ko
$(COMPILER)strip -g ko/hgicf.ko
clean:
rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order
cd hgic_fmac ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko Module.symvers modules.order
cd hgic_smac ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko Module.symvers modules.order
cd hgic_smac/umac ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd hgic_smac/umac/cfg80211 ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd hgic_smac/umac/mac80211 ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd utils ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko Module.symvers modules.order
rm -rf ko
@find ./ -name "*.o" | xargs rm -fv
@find ./ -name "*.ko" | xargs rm -fv
@find ./ -name "*.cmd" | xargs rm -fv
@find ./ -name "*.symvers" | xargs rm -fv
@find ./ -name "*.markers" | xargs rm -fv
@find ./ -name "*.order" | xargs rm -fv
@find ./ -name "*.mod.c" | xargs rm -fv
@rm -rf ko

3
Makefile.in Normal file
View file

@ -0,0 +1,3 @@
#this makefile is used to build driver with kernel
obj-$(CONFIG_HGICS) += hgic_smac/
obj-$(CONFIG_HGICF) += hgic_fmac/

5
build_ahtool.sh Normal file
View file

@ -0,0 +1,5 @@
#! /bin/sh
rm -rf bin; mkdir bin
cd tools/ah_tool/;./build.sh;cd -
cp -fv tools/ah_tool/bin/* bin

View file

@ -1,50 +1,53 @@
2022/01/12
修改bugsdio remove过程中执行hgic_core_remove时可能会rx data此时会出现死机现象。
2023/08/04
1. 支持接口聚合收发功能此功能默认关闭1.x版本固件不支持聚合功能。
2. sleep流程调整sleep命令发送完成后立即设置sleep标识拦截后续所有的数据sleep命令的resp失败时再清除sleep标识。
3. 修复sdio remove流程低概率异常出错问题。
4. 修复detect_work功能异常造成驱动不执行reload流程。
5. 调整tx window最小值多预留1个window保证驱动命令可以发送。
-----------------------------------------------------
2022/01/10
固件下载功能优化在固件下载阶段屏蔽其它数据和cmd的发送, 避免干扰固件下载过程。
2023/06/08
添加 hgic_iwpriv_send_custmgmt 和 hgic_iwpriv_send_custmgmt2 API。支持发送自定义管理帧。
-----------------------------------------------------
2021/12/22
fmac: 新增eventHGIC_EVENT_UNPAIR_STA, 解除配对时固件产生此event。
新增tx maxcnt 命令,用于设置最大帧重传次数。
2023/05/31
set agg_cnt/get agg_cnt 修改,支持设置 tx agg 和 rx agg。
修复get signal错误
添加漫游参数,支持设置 漫游rssi切换差值 和 rssi 检测周期。
新增漫游成功事件: HGIC_EVENT_ROAM_CONECTED
添加 hgpriv hg0 open/close 命令
hgics_rx_sigfrm: reserve hgic_frm_hdr。
-----------------------------------------------------
2021/11/19
fmac: 添加AP隐藏功能 iwpriv hg0 set ap_hide 1
2023/05/06
fix bug: detect_work 被 tx_complete触发执行时hg->bus->reinit 可能为NULL造成驱动出错。
-----------------------------------------------------
2021/11/08
解决驱动卸载死机问题。
2023/04/26
fmac 添加 hgic_iwpriv_get_sta_info 接口。
-----------------------------------------------------
2021/11/01
fmac: 添加漫游功能设置接口。
2023/04/21
添加 hgic_iwpriv_set_max_tx_delay 接口设置最大tx busy delay时间超过就强行发送。
2023/04/14
tx fail 时触发 detect_work用于快速检测到模块复位。
fmac: needed_headroom 多预留4byte。
2023/4/11
test_app/iwpriv.c使用 blenc_mode 全局变量代替宏定义 BLE_ADVCFG, 支持动态切换BLE配网模式。
2023/4/7
iwpriv.c get bssid 同时返回AID信息。
2022/12/24
数据接收调整if_sdio/if_usb 使用预分配的buffer接收数据根据实际长度再copy到skb。
避免部分主控出现alloc skb fail。
2021/10/28
-----------------------------------------------------
2021/09/28
smac:
1. 修改bug remove 时 先 确保 alive_timer/alive_work/delay_init 已经停止运行
2. hgic_frm_hdr.tx_info : 清零
3. ETH_P_PAE 类型数据使用最高优先级
fmac:
1. 修改bug remove 时 先 确保 alive_timer/alive_work/delay_init 已经停止运行
驱动代码整理,解决大小端模式问题。
-----------------------------------------------------
2021/09/27
添加 macfilter/atcmd 命令接口。
-----------------------------------------------------
2021/09/23
1. 优化固件下载功能,减少对 memory 的需求。
2. 模块监测功能修改接口只要支持reinit就默认开启该功能用于监测是否需要重新下载固件。
-----------------------------------------------------
2021/09/13
get module_type 修改,定义了 struct hgic_module_hwinfo 结构体。
使用方法参考: hgic_fmac.c
-----------------------------------------------------
2021/08/26
添加 HGIC_HDR_TYPE_CMD2 和 HGIC_HDR_TYPE_EVENT2扩展 cmd id 和 event id 到 uint16.

Binary file not shown.

83
fmac.sh
View file

@ -1,83 +0,0 @@
#! /bin/sh
#interface name
IFNAME="hg0"
# ko file path
FMAC_KO_PATH="/lib/modules/3.10.14/kernel/drivers/net/wireless/hugeic/hgic_fmac/hgicf.ko"
USB_KO_PATH="/lib/modules/3.10.14/kernel/drivers/net/wireless/hugeic/utils/hgic_usb.ko"
SDIO_KO_PATH="/lib/modules/3.10.14/kernel/drivers/net/wireless/hugeic/utils/hgic_sdio.ko"
#read paramters from system.
AH_MODE=ap
AH_SSID=ah_test_ssid
AH_PSK=00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
AH_KEY_MGMT=NONE
AH_FREQ_START=7600
AH_FREQ_END=7680
AH_BSS_BW=8
AH_TX_MCS=255
AH_CHAN_LIST=
#set default values
[ -z "$AH_MODE" ] && AH_MODE="ap"
[ -z "$AH_FREQ_START" ] && AH_FREQ_START="7800"
[ -z "$AH_FREQ_END" ] && AH_FREQ_END="8000"
[ -z "$AH_BSS_BW" ] && AH_BSS_BW="8"
[ -z "$AH_TX_MCS" ] && AH_TX_MCS="7"
[ -z "$AH_CHANNEL" ] && AH_CHANNEL="1"
[ -z "$AH_ACS" ] && AH_ACS="0"
[ -z "$AH_ACS_TM" ] && AH_ACS_TM="10"
[ -z "$AH_TX_POWER" ] && AH_TX_POWER="1"
[ "$AH_MODE" == "sta" ] && AH_ACS="0"
[ "$AH_ACS" == "1" ] && AH_CHANNEL="1"
#insmod driver
ko_exist=$(lsmod|grep hgicf)
if [ -z "$ko_exist" ]; then
[ -n "$FMAC_KO_PATH" ] && insmod $FMAC_KO_PATH $ARG_IF_TEST
[ -n "$SDIO_KO_PATH" ] && insmod $SDIO_KO_PATH
[ -n "$USB_KO_PATH" ] && insmod $USB_KO_PATH
sleep 1
fi
#set param
CONN_STATE=$(cat /proc/hgic/conn_state|grep CONNECTED)
if [ -z "$CONN_STATE" ]; then
ifconfig $IFNAME down
iwpriv $IFNAME set freq_range=$AH_FREQ_START,$AH_FREQ_END,$AH_BSS_BW
iwpriv $IFNAME set mode=$AH_MODE
iwpriv $IFNAME set bss_bw=$AH_BSS_BW
iwpriv $IFNAME set tx_mcs=$AH_TX_MCS
iwpriv $IFNAME set tx_power=$AH_TX_POWER
iwpriv $IFNAME set channel=$AH_CHANNEL
iwpriv $IFNAME set acs="$AH_ACS,$AH_ACS_TM"
if [ x"$AH_KEY_MGMT" == "xWPA-PSK" ]; then
iwpriv $IFNAME set key_mgmt=WPA-PSK
iwpriv $IFNAME set wpa_psk=$AH_PSK
else
iwpriv $IFNAME set key_mgmt=NONE
fi
iwpriv $IFNAME set ssid=$AH_SSID
#save config
iwpriv $IFNAME save
[ "$AH_BSS_BW" == "1" ] && ifconfig $IFNAME mtu 380
fi
#up interface
ifconfig $IFNAME up
############################################################
# 可以设置驱动参数文件由驱动自动加载参数需要如下3个步骤
# 1. 生成参数文件:/etc/hgicf.conf内容如下
# freq_range=9000,9240,8
# mode=ap
# ssid=ah_test_ssid
# key_mgmt=WPA-PSK
# wpa_psk=00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
# [以上参数是最基本的参数设置,其他参数设置请参考 Linux开发指南]
#
# 2. insmod 驱动
# 3. ifconfig up 接口
###########################################################

594
hgic.h
View file

@ -10,6 +10,10 @@ extern "C" {
#define HGIC_CMD_START 0
#endif
#ifndef __packed
#define __packed __attribute__((packed))
#endif
typedef void (*hgic_init_cb)(void *args);
typedef void (*hgic_event_cb)(char *ifname, int event, int param1, int param2);
@ -17,7 +21,7 @@ struct hgic_bss_info {
unsigned char bssid[6];
unsigned char ssid[32];
unsigned char encrypt;
char signal;
signed char signal;
unsigned short freq;
};
@ -27,14 +31,19 @@ struct hgic_fw_info {
unsigned short chip_id;
unsigned short cpu_id;
unsigned char mac[6];
unsigned char resv[2];
unsigned int app_version;
unsigned int smt_dat;
};
struct hgic_sta_info {
unsigned char aid;
unsigned char ps:1;
unsigned char addr[6];
char rssi;
char evm;
signed char rssi;
signed char evm;
signed char tx_snr;
signed char rx_snr;
};
struct hgic_freqinfo {
@ -53,163 +62,440 @@ struct hgic_module_hwinfo{
};
};
struct hgic_txq_param {
unsigned short txop;
unsigned short cw_min;
unsigned short cw_max;
unsigned char aifs;
unsigned char acm;
};
struct hgic_mcast_txparam {
unsigned char dupcnt;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char clearch;
};
struct hgic_rx_info {
unsigned char band;
unsigned char mcs: 4, bw: 4;
char evm;
char signal;
unsigned short freq;
short freq_off;
unsigned char rx_flags;
unsigned char antenna;
unsigned char nss : 4, s1g_nss : 4;
unsigned char vht_flag : 3, s1g_flag : 5;
};
struct hgic_tx_info {
unsigned char band;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char antenna;
unsigned int tx_flags;
unsigned int tx_flags2;
};
struct bt_rx_info {
unsigned char channel; //current channel
unsigned char con_handle; //hci handle
signed char rssi;
unsigned char frm_type;
unsigned int rev;
};
/*data packet header*/
struct hgic_hdr {
unsigned short magic;
unsigned char type;
unsigned char ifidx: 4, flags: 4;
unsigned short length;
unsigned short cookie;
} __packed;
struct hgic_frm_hdr {
struct hgic_hdr hdr;
union {
struct hgic_rx_info rx_info;
struct hgic_tx_info tx_info;
unsigned char rev[24];
};
} __packed;
struct hgic_frm_hdr2 {
struct hgic_hdr hdr;
} __packed;
/*contro pakcet header*/
struct hgic_ctrl_hdr {
struct hgic_hdr hdr;
union {
struct {
unsigned char cmd_id;
short status;
} cmd;
struct {
unsigned short cmd_id;
short status;
} cmd2;
struct {
unsigned char event_id;
short value;
} event;
struct {
unsigned short event_id;
short value;
} event2;
struct {
unsigned char type;
} hci;
unsigned char info[4];
};
} __packed;
struct hgic_key_conf {
unsigned int cipher;
unsigned int flags;
unsigned char keyidx;
unsigned char keylen;
unsigned char key[0];
};
struct hgic_cca_ctl {
char start_th;
char mid_th;
char ed_th;
/* CCA auto adjustment.
* When the cca automatic adjustment takes effect, the
* above three parameters are invalid.
*/
char auto_en : 1;
};
struct hgic_acs_result{
unsigned int freq;//KHz
unsigned char sync_cnt;
signed char min;
signed char max;
signed char avg;
};
struct hgic_fallback_mcs {
unsigned char original_type;
unsigned char original_mcs;
unsigned char fallback_type;
unsigned char fallback_mcs;
};
#define HDR_CMDID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_CMD2? le16_to_cpu((ctl)->cmd2.cmd_id):(ctl)->cmd.cmd_id)
#define HDR_EVTID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_EVENT2?le16_to_cpu((ctl)->event2.event_id):(ctl)->event.event_id)
#define HDR_CMDID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD2;\
(ctl)->cmd2.cmd_id = cpu_to_le16(id);\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD;\
(ctl)->cmd.cmd_id = id;\
}
#define HDR_EVTID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT2;\
(ctl)->event2.event_id = cpu_to_le16(id);\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT;\
(ctl)->event.event_id = id;\
}
enum hgic_hdr_type {
HGIC_HDR_TYPE_ACK = 1,
HGIC_HDR_TYPE_FRM = 2,
HGIC_HDR_TYPE_CMD = 3,
HGIC_HDR_TYPE_EVENT = 4,
HGIC_HDR_TYPE_FIRMWARE = 5,
HGIC_HDR_TYPE_NLMSG = 6,
HGIC_HDR_TYPE_BOOTDL = 7,
HGIC_HDR_TYPE_TEST = 8,
HGIC_HDR_TYPE_FRM2 = 9,
HGIC_HDR_TYPE_TEST2 = 10,
HGIC_HDR_TYPE_SOFTFC = 11,
HGIC_HDR_TYPE_OTA = 12,
HGIC_HDR_TYPE_CMD2 = 13,
HGIC_HDR_TYPE_EVENT2 = 14,
HGIC_HDR_TYPE_BOOTDL_DATA = 15,
HGIC_HDR_TYPE_IFBR = 16,
HGIC_HDR_TYPE_BEACON = 17,
HGIC_HDR_TYPE_AGGFRM = 18,
HGIC_HDR_TYPE_BLUETOOTH = 19,
HGIC_HDR_TYPE_MAX,
};
enum hgic_cmd {
HGIC_CMD_DEV_OPEN = HGIC_CMD_START + 0x01, // 1
HGIC_CMD_DEV_CLOSE, // 2
HGIC_CMD_SET_MAC, // 3
HGIC_CMD_SET_SSID, // 4
HGIC_CMD_SET_BSSID, // 5
HGIC_CMD_SET_COUNTERY, // 6
HGIC_CMD_SET_CHANNEL, // 7
HGIC_CMD_SET_CENTER_FREQ, // 8
HGIC_CMD_SET_RTS_THRESHOLD, // 9
HGIC_CMD_SET_FRG_THRESHOLD, // 10
HGIC_CMD_SET_KEY_MGMT, // 11
HGIC_CMD_SET_WPA_PSK, // 12
HGIC_CMD_SET_KEY, // 13
HGIC_CMD_SCAN, // 14
HGIC_CMD_GET_SCAN_LIST, // 15
HGIC_CMD_SET_BSSID_FILTER, // 16
HGIC_CMD_DISCONNECT, // 17
HGIC_CMD_GET_BSSID, // 18
HGIC_CMD_SET_WBNAT, // 19
HGIC_CMD_GET_STATUS, // 20
HGIC_CMD_SET_LISTEN_INTERVAL, // 21
HGIC_CMD_SET_TX_POWER, // 22
HGIC_CMD_GET_TX_POWER, // 23
HGIC_CMD_SET_TX_LCOUNT, // 24
HGIC_CMD_SET_TX_SCOUNT, // 25
HGIC_CMD_ADD_STA, // 26
HGIC_CMD_REMOVE_STA, // 27
HGIC_CMD_SET_TX_BW, // 28
HGIC_CMD_SET_TX_MCS, // 29
HGIC_CMD_SET_FREQ_RANGE, // 30
HGIC_CMD_ACS_ENABLE, // 31
HGIC_CMD_SET_PRIMARY_CHAN, // 32
HGIC_CMD_SET_BG_RSSI, // 33
HGIC_CMD_SET_BSS_BW, // 34
HGIC_CMD_TESTMODE_CMD, // 35
HGIC_CMD_SET_AID, // 36
HGIC_CMD_GET_FW_STATE, // 37
HGIC_CMD_SET_TXQ_PARAM, // 38
HGIC_CMD_SET_CHAN_LIST, // 39
HGIC_CMD_GET_CONN_STATE, // 40
HGIC_CMD_SET_WORK_MODE, // 41
HGIC_CMD_SET_PAIRED_STATIONS, // 42
HGIC_CMD_GET_FW_INFO, // 43
HGIC_CMD_PAIRING, // 44
HGIC_CMD_GET_TEMPERATURE, // 45
HGIC_CMD_ENTER_SLEEP, // 46
HGIC_CMD_OTA, // 47
HGIC_CMD_GET_SSID, // 48
HGIC_CMD_GET_WPA_PSK, // 49
HGIC_CMD_GET_SIGNAL, // 50
HGIC_CMD_GET_TX_BITRATE, // 51
HGIC_CMD_SET_BEACON_INT, // 52
HGIC_CMD_GET_STA_LIST, // 53
HGIC_CMD_SAVE_CFG, // 54
HGIC_CMD_JOIN_GROUP, // 55
HGIC_CMD_SET_ETHER_TYPE, // 56
HGIC_CMD_GET_STA_COUNT, // 57
HGIC_CMD_SET_HEARTBEAT_INT, // 58
HGIC_CMD_SET_MCAST_KEY, // 59
HGIC_CMD_SET_AGG_CNT, // 60
HGIC_CMD_GET_AGG_CNT, // 61
HGIC_CMD_GET_BSS_BW , // 62
HGIC_CMD_GET_FREQ_RANGE, // 63
HGIC_CMD_GET_CHAN_LIST, // 64
HGIC_CMD_RADIO_ONOFF, // 65
HGIC_CMD_SET_PS_HEARTBEAT, // 66
HGIC_CMD_SET_WAKEUP_STA, // 67
HGIC_CMD_SET_PS_HEARTBEAT_RESP, // 68
HGIC_CMD_SET_PS_WAKEUP_DATA, // 69
HGIC_CMD_SET_PS_CONNECT, // 70
HGIC_CMD_SET_BSS_MAX_IDLE, // 71
HGIC_CMD_SET_WKIO_MODE, // 72
HGIC_CMD_SET_DTIM_PERIOD, // 73
HGIC_CMD_SET_PS_MODE, // 74
HGIC_CMD_LOAD_DEF, // 75
HGIC_CMD_DISASSOC_STA, // 76
HGIC_CMD_SET_APLOST_TIME, // 77
HGIC_CMD_GET_WAKEUP_REASON, // 78
HGIC_CMD_UNPAIR, // 79
HGIC_CMD_SET_AUTO_CHAN_SWITCH, // 80
HGIC_CMD_SET_REASSOC_WKHOST, // 81
HGIC_CMD_SET_WAKEUP_IO, // 82
HGIC_CMD_DBGINFO_OUTPUT, // 83
HGIC_CMD_SET_SYSDBG, // 84
HGIC_CMD_SET_AUTO_SLEEP_TIME, // 85
HGIC_CMD_GET_KEY_MGMT, // 86
HGIC_CMD_SET_PAIR_AUTOSTOP, // 87
HGIC_CMD_SET_SUPPER_PWR, // 88
HGIC_CMD_SET_REPEATER_SSID, // 89
HGIC_CMD_SET_REPEATER_PSK, // 90
HGIC_CMD_CFG_AUTO_SAVE, // 91
HGIC_CMD_SEND_CUST_MGMT, // 92
HGIC_CMD_GET_BATTERY_LEVEL, // 93
HGIC_CMD_SET_DCDC13, // 94
HGIC_CMD_SET_ACKTMO, // 95
HGIC_CMD_GET_MODULETYPE, // 96
HGIC_CMD_PA_PWRCTRL_DIS, // 97
HGIC_CMD_SET_DHCPC, // 98
HGIC_CMD_GET_DHCPC_RESULT, // 99
HGIC_CMD_SET_WKUPDATA_MASK, // 100
HGIC_CMD_GET_WKDATA_BUFF, // 101
HGIC_CMD_GET_DISASSOC_REASON, // 102
HGIC_CMD_SET_WKUPDATA_SAVEEN, // 103
HGIC_CMD_SET_CUST_DRIVER_DATA, // 104
HGIC_CMD_SET_MCAST_TXPARAM, // 105
HGIC_CMD_SET_STA_FREQINFO, // 106
HGIC_CMD_SET_RESET_STA, // 107
HGIC_CMD_SET_UART_FIXLEN, // 108
HGIC_CMD_GET_UART_FIXLEN, // 109
HGIC_CMD_SET_ANT_AUTO, // 110
HGIC_CMD_SET_ANT_SEL, // 111
HGIC_CMD_GET_ANT_SEL, // 112
HGIC_CMD_SET_WKUP_HOST_REASON, // 113
HGIC_CMD_SET_MAC_FILTER_EN, // 114
HGIC_CMD_SET_ATCMD, // 115
HGIC_CMD_SET_ROAMING, // 116
HGIC_CMD_SET_AP_HIDE, // 117
HGIC_CMD_SET_DUAL_ANT, // 118
HGIC_CMD_SET_MAX_TCNT, // 119
HGIC_CMD_SET_ASSERT_HOLDUP, // 120
HGIC_CMD_SET_AP_PSMODE_EN, // 121
HGIC_CMD_SET_DUPFILTER_EN, // 122
HGIC_CMD_SET_DIS_1V1_M2U, // 123
HGIC_CMD_DEV_OPEN = 1, /* fmac/smac */
HGIC_CMD_DEV_CLOSE = 2, /* fmac/smac */
HGIC_CMD_SET_MAC = 3, /* fmac/smac */
HGIC_CMD_SET_SSID = 4, /* fmac */
HGIC_CMD_SET_BSSID = 5, /* fmac */
HGIC_CMD_SET_COUNTERY = 6, /* fmac */
HGIC_CMD_SET_CHANNEL = 7, /* fmac */
HGIC_CMD_SET_CENTER_FREQ = 8, /* smac */
HGIC_CMD_SET_RTS_THRESHOLD = 9, /* smac */
HGIC_CMD_SET_FRG_THRESHOLD = 10, /* smac */
HGIC_CMD_SET_KEY_MGMT = 11, /* fmac */
HGIC_CMD_SET_WPA_PSK = 12, /* fmac */
HGIC_CMD_SET_KEY = 13, /* smac */
HGIC_CMD_SCAN = 14, /* fmac */
HGIC_CMD_GET_SCAN_LIST = 15, /* fmac */
HGIC_CMD_SET_BSSID_FILTER = 16, /* fmac */
HGIC_CMD_DISCONNECT = 17, /* fmac */
HGIC_CMD_GET_BSSID = 18, /* fmac */
HGIC_CMD_SET_WBNAT = 19, /* unused */
HGIC_CMD_GET_STATUS = 20, /* fmac */
HGIC_CMD_SET_LISTEN_INTERVAL = 21, /* smac */
HGIC_CMD_SET_TX_POWER = 22, /* fmac/smac */
HGIC_CMD_GET_TX_POWER = 23, /* fmac/smac */
HGIC_CMD_SET_TX_LCOUNT = 24, /* unused */
HGIC_CMD_SET_TX_SCOUNT = 25, /* unused */
HGIC_CMD_ADD_STA = 26, /* smac */
HGIC_CMD_REMOVE_STA = 27, /* smac */
HGIC_CMD_SET_TX_BW = 28, /* fmac */
HGIC_CMD_SET_TX_MCS = 29, /* fmac/smac */
HGIC_CMD_SET_FREQ_RANGE = 30, /* fmac */
HGIC_CMD_ACS_ENABLE = 31, /* fmac */
HGIC_CMD_SET_PRIMARY_CHAN = 32, /* fmac */
HGIC_CMD_SET_BG_RSSI = 33, /* fmac */
HGIC_CMD_SET_BSS_BW = 34, /* fmac/smac */
HGIC_CMD_TESTMODE_CMD = 35, /* fmac/smac */
HGIC_CMD_SET_AID = 36, /* smac */
HGIC_CMD_GET_FW_STATE = 37, /* unused */
HGIC_CMD_SET_TXQ_PARAM = 38, /* smac */
HGIC_CMD_SET_CHAN_LIST = 39, /* fmac */
HGIC_CMD_GET_CONN_STATE = 40, /* fmac */
HGIC_CMD_SET_WORK_MODE = 41, /* fmac */
HGIC_CMD_SET_PAIRED_STATIONS = 42, /* fmac */
HGIC_CMD_GET_FW_INFO = 43, /* fmac/smac */
HGIC_CMD_PAIRING = 44, /* fmac */
HGIC_CMD_GET_TEMPERATURE = 45, /* fmac/smac */
HGIC_CMD_ENTER_SLEEP = 46, /* fmac */
HGIC_CMD_OTA = 47, /* fmac */
HGIC_CMD_GET_SSID = 48, /* fmac */
HGIC_CMD_GET_WPA_PSK = 49, /* fmac */
HGIC_CMD_GET_SIGNAL = 50, /* fmac */
HGIC_CMD_GET_TX_BITRATE = 51, /* fmac */
HGIC_CMD_SET_BEACON_INT = 52, /* fmac */
HGIC_CMD_GET_STA_LIST = 53, /* fmac */
HGIC_CMD_SAVE_CFG = 54, /* fmac */
HGIC_CMD_JOIN_GROUP = 55, /* unused */
HGIC_CMD_SET_ETHER_TYPE = 56, /* unused */
HGIC_CMD_GET_STA_COUNT = 57, /* fmac */
HGIC_CMD_SET_HEARTBEAT_INT = 58, /* fmac */
HGIC_CMD_SET_MCAST_KEY = 59, /* unused */
HGIC_CMD_SET_AGG_CNT = 60, /* fmac/smac */
HGIC_CMD_GET_AGG_CNT = 61, /* fmac/smac */
HGIC_CMD_GET_BSS_BW = 62, /* fmac/smac */
HGIC_CMD_GET_FREQ_RANGE = 63, /* fmac */
HGIC_CMD_GET_CHAN_LIST = 64, /* fmac */
HGIC_CMD_RADIO_ONOFF = 65, /* fmac/smac */
HGIC_CMD_SET_PS_HEARTBEAT = 66, /* fmac */
HGIC_CMD_SET_WAKEUP_STA = 67, /* fmac */
HGIC_CMD_SET_PS_HEARTBEAT_RESP = 68, /* fmac */
HGIC_CMD_SET_PS_WAKEUP_DATA = 69, /* fmac */
HGIC_CMD_SET_PS_CONNECT = 70, /* fmac */
HGIC_CMD_SET_BSS_MAX_IDLE = 71, /* fmac */
HGIC_CMD_SET_WKIO_MODE = 72, /* fmac */
HGIC_CMD_SET_DTIM_PERIOD = 73, /* fmac */
HGIC_CMD_SET_PS_MODE = 74, /* fmac */
HGIC_CMD_LOAD_DEF = 75, /* fmac */
HGIC_CMD_DISASSOC_STA = 76, /* fmac */
HGIC_CMD_SET_APLOST_TIME = 77, /* fmac */
HGIC_CMD_GET_WAKEUP_REASON = 78, /* fmac */
HGIC_CMD_UNPAIR = 79, /* fmac */
HGIC_CMD_SET_AUTO_CHAN_SWITCH = 80, /* fmac */
HGIC_CMD_SET_REASSOC_WKHOST = 81, /* fmac */
HGIC_CMD_SET_WAKEUP_IO = 82, /* fmac */
HGIC_CMD_DBGINFO_OUTPUT = 83, /* fmac/smac */
HGIC_CMD_SET_SYSDBG = 84, /* fmac/smac */
HGIC_CMD_SET_AUTO_SLEEP_TIME = 85, /* fmac */
HGIC_CMD_GET_KEY_MGMT = 86, /* fmac */
HGIC_CMD_SET_PAIR_AUTOSTOP = 87, /* fmac */
HGIC_CMD_SET_SUPER_PWR = 88, /* fmac */
HGIC_CMD_SET_REPEATER_SSID = 89, /* fmac */
HGIC_CMD_SET_REPEATER_PSK = 90, /* fmac */
HGIC_CMD_CFG_AUTO_SAVE = 91, /* fmac */
HGIC_CMD_SEND_CUST_MGMT = 92, /* fmac */
HGIC_CMD_GET_BATTERY_LEVEL = 93, /* unused */
HGIC_CMD_SET_DCDC13 = 94, /* fmac */
HGIC_CMD_SET_ACKTMO = 95, /* fmac/smac */
HGIC_CMD_GET_MODULETYPE = 96, /* fmac/smac */
HGIC_CMD_PA_PWRCTRL_DIS = 97, /* fmac */
HGIC_CMD_SET_DHCPC = 98, /* fmac */
HGIC_CMD_GET_DHCPC_RESULT = 99, /* fmac */
HGIC_CMD_SET_WKUPDATA_MASK = 100, /* fmac */
HGIC_CMD_GET_WKDATA_BUFF = 101, /* fmac */
HGIC_CMD_GET_DISASSOC_REASON = 102, /* fmac */
HGIC_CMD_SET_WKUPDATA_SAVEEN = 103, /* fmac */
HGIC_CMD_SET_CUST_DRIVER_DATA = 104, /* fmac */
HGIC_CMD_SET_MCAST_TXPARAM = 105, /* unused */
HGIC_CMD_SET_STA_FREQINFO = 106, /* fmac */
HGIC_CMD_SET_RESET_STA = 107, /* fmac */
HGIC_CMD_SET_UART_FIXLEN = 108, /* unused */
HGIC_CMD_GET_UART_FIXLEN = 109, /* unused */
HGIC_CMD_SET_ANT_AUTO = 110, /* fmac */
HGIC_CMD_SET_ANT_SEL = 111, /* fmac */
HGIC_CMD_GET_ANT_SEL = 112, /* fmac */
HGIC_CMD_SET_WKUP_HOST_REASON = 113, /* fmac */
HGIC_CMD_SET_MAC_FILTER_EN = 114, /* unused */
HGIC_CMD_SET_ATCMD = 115, /* fmac/smac */
HGIC_CMD_SET_ROAMING = 116, /* fmac */
HGIC_CMD_SET_AP_HIDE = 117, /* fmac */
HGIC_CMD_SET_DUAL_ANT = 118, /* fmac */
HGIC_CMD_SET_MAX_TCNT = 119, /* fmac/smac */
HGIC_CMD_SET_ASSERT_HOLDUP = 120, /* fmac/smac */
HGIC_CMD_SET_AP_PSMODE_EN = 121, /* fmac */
HGIC_CMD_SET_DUPFILTER_EN = 122, /* fmac */
HGIC_CMD_SET_DIS_1V1_M2U = 123, /* fmac */
HGIC_CMD_SET_DIS_PSCONNECT = 124, /* fmac */
HGIC_CMD_SET_RTC = 125, /* fmac */
HGIC_CMD_GET_RTC = 126, /* fmac */
HGIC_CMD_SET_KICK_ASSOC = 127, /* fmac */
HGIC_CMD_START_ASSOC = 128, /* fmac */
HGIC_CMD_SET_AUTOSLEEP = 129, /* fmac */
HGIC_CMD_SEND_BLENC_DATA = 130, /* smac */
HGIC_CMD_SET_BLENC_EN = 131, /* smac */
HGIC_CMD_RESET = 132, /* fmac/smac */
HGIC_CMD_SET_HWSCAN = 133, /* smac */
HGIC_CMD_GET_TXQ_PARAM = 134, /* smac */
HGIC_CMD_SET_PROMISC = 135, /* smac */
HGIC_CMD_SET_USER_EDCA = 136, /* fmac */
HGIC_CMD_SET_FIX_TXRATE = 137, /* smac */
HGIC_CMD_SET_NAV_MAX = 138, /* smac */
HGIC_CMD_CLEAR_NAV = 139, /* smac */
HGIC_CMD_SET_CCA_PARAM = 140, /* smac */
HGIC_CMD_SET_TX_MODGAIN = 141, /* smac */
HGIC_CMD_GET_NAV = 142, /* smac */
HGIC_CMD_SET_BEACON_START = 143, /* smac */
HGIC_CMD_SET_BLE_OPEN = 144, /* smac */
HGIC_CMD_GET_MODE = 145, /* fmac */
HGIC_CMD_GET_BGRSSI = 146, /* fmac */
HGIC_CMD_SEND_BLENC_ADVDATA = 147, /* smac */
HGIC_CMD_SEND_BLENC_SCANRESP = 148, /* smac */
HGIC_CMD_SEND_BLENC_DEVADDR = 149, /* smac */
HGIC_CMD_SEND_BLENC_ADVINTERVAL = 150, /* smac */
HGIC_CMD_SEND_BLENC_STARTADV = 151, /* smac */
HGIC_CMD_SET_RTS_DURATION = 152, /* smac */
HGIC_CMD_STANDBY_CFG = 153, /* fmac */
HGIC_CMD_SET_CONNECT_PAIRONLY = 154, /* fmac */
HGIC_CMD_SET_DIFFCUST_CONN = 155, /* fmac */
HGIC_CMD_GET_CENTER_FREQ = 156, /* smac */
HGIC_CMD_SET_WAIT_PSMODE = 157, /* fmac */
HGIC_CMD_SET_AP_CHAN_SWITCH = 158, /* fmac */
HGIC_CMD_SET_CCA_FOR_CE = 159, /* fmac */
HGIC_CMD_SET_DISABLE_PRINT = 160, /* fmac/smac */
HGIC_CMD_SET_APEP_PADDING = 161, /* smac */
HGIC_CMD_GET_ACS_RESULT = 162, /* fmac/smac */
HGIC_CMD_GET_WIFI_STATUS_CODE = 163, /* fmac */
HGIC_CMD_GET_WIFI_REASON_CODE = 164, /* fmac */
HGIC_CMD_SET_WATCHDOG = 165, /* fmac/smac */
HGIC_CMD_SET_RETRY_FALLBACK_CNT = 166, /* smac */
HGIC_CMD_SET_FALLBACK_MCS = 167, /* smac */
HGIC_CMD_GET_XOSC_VALUE = 168, /* smac */
HGIC_CMD_SET_XOSC_VALUE = 169, /* smac */
HGIC_CMD_GET_FREQ_OFFSET = 170, /* smac */
HGIC_CMD_SET_CALI_PERIOD = 171, /* smac */
HGIC_CMD_SET_BLENC_ADVFILTER = 172, /* smac */
HGIC_CMD_SET_MAX_TX_DELAY = 173, /* smac */
HGIC_CMD_GET_STA_INFO = 174, /* fmac */
HGIC_CMD_SEND_MGMTFRAME = 175, /* fmac */
};
enum hgic_event {
HGIC_EVENT_STATE_CHG = 0x1, // 1
HGIC_EVENT_CH_SWICH, // 2
HGIC_EVENT_DISCONNECT_REASON, // 3
HGIC_EVENT_ASSOC_STATUS, // 4
HGIC_EVENT_SCANNING, // 5
HGIC_EVENT_SCAN_DONE, // 6
HGIC_EVENT_TX_BITRATE, // 7
HGIC_EVENT_PAIR_START, // 8
HGIC_EVENT_PAIR_SUCCESS, // 9
HGIC_EVENT_PAIR_DONE, // 10
HGIC_EVENT_CONECT_START, // 11
HGIC_EVENT_CONECTED, // 12
HGIC_EVENT_DISCONECTED, // 13
HGIC_EVENT_SIGNAL, // 14
HGIC_EVENT_DISCONNET_LOG, // 15
HGIC_EVENT_REQUEST_PARAM, // 16
HGIC_EVENT_TESTMODE_STATE, // 17
HGIC_EVENT_FWDBG_INFO, // 18
HGIC_EVENT_CUSTOMER_MGMT, // 19
HGIC_EVENT_SLEEP_FAIL, // 20
HGIC_EVENT_DHCPC_DONE, // 21
HGIC_EVENT_CONNECT_FAIL, // 22
HGIC_EVENT_CUST_DRIVER_DATA, // 23
HGIC_EVENT_UNPAIR_STA, // 24
HGIC_EVENT_STATE_CHG = 1,
HGIC_EVENT_CH_SWICH = 2,
HGIC_EVENT_DISCONNECT_REASON = 3,
HGIC_EVENT_ASSOC_STATUS = 4,
HGIC_EVENT_SCANNING = 5,
HGIC_EVENT_SCAN_DONE = 6,
HGIC_EVENT_TX_BITRATE = 7,
HGIC_EVENT_PAIR_START = 8,
HGIC_EVENT_PAIR_SUCCESS = 9,
HGIC_EVENT_PAIR_DONE = 10,
HGIC_EVENT_CONECT_START = 11,
HGIC_EVENT_CONECTED = 12,
HGIC_EVENT_DISCONECTED = 13,
HGIC_EVENT_SIGNAL = 14,
HGIC_EVENT_DISCONNET_LOG = 15,
HGIC_EVENT_REQUEST_PARAM = 16,
HGIC_EVENT_TESTMODE_STATE = 17,
HGIC_EVENT_FWDBG_INFO = 18,
HGIC_EVENT_CUSTOMER_MGMT = 19,
HGIC_EVENT_SLEEP_FAIL = 20,
HGIC_EVENT_DHCPC_DONE = 21,
HGIC_EVENT_CONNECT_FAIL = 22,
HGIC_EVENT_CUST_DRIVER_DATA = 23,
HGIC_EVENT_UNPAIR_STA = 24,
HGIC_EVENT_BLENC_DATA = 25,
HGIC_EVENT_HWSCAN_RESULT = 26,
HGIC_EVENT_EXCEPTION_INFO = 27,
HGIC_EVENT_DSLEEP_WAKEUP = 28,
HGIC_EVENT_STA_MIC_ERROR = 29,
HGIC_EVENT_ACS_DONE = 30,
HGIC_EVENT_FW_INIT_DONE = 31,
HGIC_EVENT_ROAM_CONECTED = 32,
HGIC_EVENT_MGMT_FRAME = 33,
};
extern int hgic_sdio_init(void);
extern void hgic_sdio_exit(void);
extern int hgic_usb_init(void);
extern void hgic_usb_exit(void);
enum hgicf_hw_state {
HGICF_HW_DISCONNECTED = 0,
HGICF_HW_DISABLED = 1,
HGICF_HW_INACTIVE = 2,
HGICF_HW_SCANNING = 3,
HGICF_HW_AUTHENTICATING = 4,
HGICF_HW_ASSOCIATING = 5,
HGICF_HW_ASSOCIATED = 6,
HGICF_HW_4WAY_HANDSHAKE = 7,
HGICF_HW_GROUP_HANDSHAKE = 8,
HGICF_HW_CONNECTED = 9,
};
enum HGIC_EXCEPTION_NUM{
HGIC_EXCEPTION_CPU_USED_OVERTOP = 1,
HGIC_EXCEPTION_HEAP_USED_OVERTOP = 2,
HGIC_EXCEPTION_WIFI_BUFFER_USED_OVERTOP = 3,
HGIC_EXCEPTION_TX_BLOCKED = 4,
HGIC_EXCEPTION_TXDELAY_TOOLONG = 5,
HGIC_EXCEPTION_STRONG_BGRSSI = 6,
HGIC_EXCEPTION_TEMPERATURE_OVERTOP = 7,
HGIC_EXCEPTION_WRONG_PASSWORD = 8,
};
struct hgic_exception_info {
int num;
union {
struct {
int max, avg, min;
} txdelay;
struct {
int max, avg, min;
} bgrssi;
struct {
int total, used;
} buffer_usage;
struct {
int total, used;
} heap_usage;
struct {
int temp;
} temperature;
} info;
};
struct hgic_dhcp_result {
unsigned int ipaddr, netmask, svrip, router, dns1, dns2;
};
#ifdef __RTOS__
struct firmware {

View file

@ -3,7 +3,7 @@
#include "hgic.h"
#include "version.h"
#define HGIC_VERSION "v1.3.0"
#define HGIC_VERSION "v2.2.1"
#ifndef SVN_VERSION
#error "SVN_VERSION undefined"
@ -13,7 +13,7 @@
printk("** HUGE-IC WLAN Card Driver("name") "HGIC_VERSION"-"SVN_VERSION"\r\n");\
}while(0)
#define HGIC_WDEV_ID_AP 0
#define HGIC_WDEV_ID_AP 2
#define HGIC_WDEV_ID_STA 1
#define HGIC_SCAN_MAX_NUM 32
@ -21,9 +21,10 @@
#define HGIC_HDR_RX_MAGIC 0x2B1A
#define HGIC_VENDOR_ID (0xA012)
#define HGIC_WLAN_AH_4001 (0x4001)
#define HGIC_WLAN_AH_4002 (0x4002)
#define HGIC_WLAN_AH_4102 (0x4102)
#define HGIC_WLAN_4002 (0x4002)
#define HGIC_WLAN_4104 (0x4104)
#define HGIC_WLAN_8400 (0x8400)
#define HGIC_CTRL_TIMEOUT 100
#define HGIC_CMD_PRIORITY 0
@ -37,9 +38,13 @@
#define hgic_enter() printk("enter %s\r\n", __FUNCTION__)
#define hgic_leave() printk("leave %s\r\n", __FUNCTION__)
#ifndef ARRAYSIZE
#define ARRAYSIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
#define HGIC_CMD_TIMEOUT 500
#define HGIC_TX_TIMEOUT 10
#define HGIC_ALIVE_TIMER 5000
#define HGIC_DETECT_TIMER 5000
enum hgic_bus_type {
HGIC_BUS_SDIO = 0x1,
@ -49,28 +54,6 @@ enum hgic_bus_type {
HGIC_BUS_SDSPI,
};
enum hgic_hdr_type {
HGIC_HDR_TYPE_ACK = 0x1,
HGIC_HDR_TYPE_FRM,
HGIC_HDR_TYPE_CMD,
HGIC_HDR_TYPE_EVENT,
HGIC_HDR_TYPE_FIRMWARE,
HGIC_HDR_TYPE_NLMSG,
HGIC_HDR_TYPE_BOOTDL,
HGIC_HDR_TYPE_TEST,
HGIC_HDR_TYPE_FRM2,
HGIC_HDR_TYPE_TEST2,
HGIC_HDR_TYPE_SOFTFC,
HGIC_HDR_TYPE_OTA,
HGIC_HDR_TYPE_CMD2,
HGIC_HDR_TYPE_EVENT2,
HGIC_HDR_TYPE_BOOTDL_DATA,
HGIC_HDR_TYPE_MAX,
};
enum hgic_hdr_flags2 {
HGIC_HDR_FLAGS2_AFT_BEACON = BIT(0),
};
@ -80,118 +63,21 @@ enum hgic_bus_flag {
HGIC_BUS_FLAGS_SLEEP,
HGIC_BUS_FLAGS_INBOOT,
HGIC_BUS_FLAGS_NOPOLL,
HGIC_BUS_FLAGS_SOFTFC,
HGIC_BUS_FLAGS_ERROR,
};
struct hgic_txq_param {
unsigned short txop;
unsigned short cw_min;
unsigned short cw_max;
unsigned char aifs;
unsigned char acm;
};
#define hgic_pick_values(pick_type, str, array, size) do{\
char *__ptr = NULL;\
memset(array, 0, size*sizeof(pick_type));\
if((str) && strlen((str)) > 0){\
while ((__ptr = strsep((char **)&(str), ",")) != NULL) {\
if (argcnt >= size) break;\
array[argcnt++] = (pick_type)simple_strtol(__ptr, 0, 0);\
}\
}\
}while(0)
struct hgic_mcast_txparam {
unsigned char dupcnt;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char clearch;
};
/*data packet header*/
struct hgic_hdr {
unsigned short magic;
unsigned char type;
unsigned char ifidx: 4, flags: 4;
unsigned short length;
unsigned short cookie;
} __packed;
struct hgic_rx_info {
unsigned char band;
unsigned char mcs: 4, bw: 4;
char evm;
char signal;
unsigned short freq;
s16 freq_off;
unsigned char rx_flags;
unsigned char antenna;
unsigned char nss : 4, s1g_nss : 4;
unsigned char vht_flag : 3, s1g_flag : 5;
};
struct hgic_tx_info {
unsigned char band;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char antenna;
unsigned int tx_flags;
unsigned int tx_flags2;
};
struct hgic_key_info {
unsigned int cipher;
unsigned char icv_len;
unsigned char iv_len;
unsigned char hw_key_idx;
unsigned char flags;
char keyidx;
unsigned char keylen;
unsigned char key[0];
};
struct hgic_frm_hdr {
struct hgic_hdr hdr;
union {
struct hgic_rx_info rx_info;
struct hgic_tx_info tx_info;
unsigned char rev[24];
};
} __packed;
struct hgic_frm_hdr2 {
struct hgic_hdr hdr;
} __packed;
#define HDR_CMDID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_CMD2?(ctl)->cmd2.cmd_id:(ctl)->cmd.cmd_id)
#define HDR_EVTID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_EVENT2?(ctl)->event2.event_id:(ctl)->event.event_id)
#define HDR_CMDID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD2;\
(ctl)->cmd2.cmd_id = id;\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD;\
(ctl)->cmd.cmd_id = id;\
}
#define HDR_EVTID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT2;\
(ctl)->event2.event_id = id;\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT;\
(ctl)->event.event_id = id;\
}
/*contro pakcet header*/
struct hgic_ctrl_hdr {
struct hgic_hdr hdr;
union {
struct {
unsigned char cmd_id;
short status;
} cmd;
struct {
unsigned short cmd_id;
short status;
} cmd2;
struct {
unsigned char event_id;
short value;
} event;
struct {
unsigned short event_id;
short value;
} event2;
unsigned char info[4];
};
} __packed;
//ack packet
struct hgic_dack_hdr {
@ -289,18 +175,17 @@ struct hgic_bus {
int bootdl_pktlen;
int bootdl_cksum;
int blk_size;
int (*probe)(void *dev, struct hgic_bus *bus);
int (*tx_packet)(void *bus, struct sk_buff *skb);
void (*tx_complete)(void *hg, struct sk_buff *skb, int success);
int (*rx_packet)(void *hg, struct sk_buff *skb, int len);
int (*rx_packet)(void *hg, u8 *data, int len);
int (*reinit)(void *bus);
void (*probe_post)(void *priv);
void (*remove)(void *priv);
int (*suspend)(void *priv);
int (*resume)(void *priv);
};
extern int hgic_core_probe(void *dev, struct hgic_bus *bus);
extern void hgic_core_probe_post(void *priv);
extern int hgic_core_remove(void *arg);
extern int hgic_core_suspend(void *hgobj);
extern int hgic_core_resume(void *hgobj);
#ifdef __RTOS__
#define ALLOC_ORDERED_WORKQUEUE alloc_ordered_workqueue
#define ALLOC_NETDEV_MQS alloc_netdev_mqs
@ -322,39 +207,51 @@ extern int hgic_core_resume(void *hgobj);
#define ALLOC_NETDEV_MQS(size,name,setup,txqs,rxqs) alloc_netdev_mqs(size,name,setup,txqs,rxqs)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,1)
#define _KERNEL_READ(fp, buff, size, off) kernel_read(fp, buff, size, off)
#define _KERNEL_WRITE(fp, buff, size, off) kernel_write(fp, buff, size, off)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,42)
#define _KERNEL_READ(fp, buff, size) ({ \
ssize_t __ret__ = 0; \
unsigned long long offset = 0;\
__ret__ = kernel_read(fp, buff, size, &offset); \
__ret__;\
})
#else
#define _KERNEL_READ(fp, buff, size, off) kernel_read(fp, 0, buff, size)
#define _KERNEL_WRITE(fp, buff, size, off) kernel_write(fp, buff, size, off)
#define _KERNEL_READ(fp, buff, size) kernel_read(fp, 0, buff, size)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
#define setup_timer(a, b, c) timer_setup(a, b, 0)
#define init_timer(...)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
#define ACCESS_OK(type, addr, size) access_ok(addr, size)
#define DEV_OPEN(x) dev_open(x, NULL)
#define DEV_OPEN(x) do { rtnl_lock(); dev_open(x, NULL); rtnl_unlock(); } while(0)
#define DEV_CLOSE(x) do { rtnl_lock(); dev_close(x); rtnl_unlock(); } while(0)
#else
#define ACCESS_OK(type, addr, size) access_ok(type, addr, size)
#define DEV_OPEN(x) dev_open(x)
#define DEV_OPEN(x) do { rtnl_lock(); dev_open(x); rtnl_unlock(); } while(0)
#define DEV_CLOSE(x) do { rtnl_lock(); dev_close(x); rtnl_unlock(); } while(0)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) && defined CONFIG_HGIC_2G
#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
#endif
#ifndef IEEE80211_NUM_ACS
#define IEEE80211_NUM_ACS 4
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) && defined CONFIG_HGIC_2G
#define vht_nss nss
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) && defined CONFIG_HGIC_2G
#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0)
#define proc_ops file_operations
#define proc_open open
@ -363,15 +260,18 @@ extern int hgic_core_resume(void *hgobj);
#define proc_write write
#define proc_release release
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
#define ieee80211_free_txskb(hw, skb) dev_kfree_skb_any(skb)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
#define RX_FLAG_MACTIME_START RX_FLAG_MACTIME_MPDU
#define IEEE80211_ITERATE_ACTIVE_INTERFACES_ATOMIC(hw, flags, iterator, vif) ieee80211_iterate_active_interfaces_atomic(hw, iterator, vif)
#else
#define IEEE80211_ITERATE_ACTIVE_INTERFACES_ATOMIC(hw, flags, iterator, vif) ieee80211_iterate_active_interfaces_atomic(hw, flags, iterator, vif)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
static inline void *__PDE_DATA(const struct inode *inode)
{
@ -383,4 +283,16 @@ static inline void *PDE_DATA(const struct inode *inode)
}
#endif
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0)
#define tasklet_hrtimer hrtimer
#define tasklet_hrtimer_cancel hrtimer_cancel
#define tasklet_hrtimer_start hrtimer_start
#endif
typedef int (*hgic_probe)(void *dev, struct hgic_bus *bus);
extern int hgic_sdio_init(hgic_probe probe, u32 max_pkt);
extern void hgic_sdio_exit(void);
extern int hgic_usb_init(hgic_probe probe, u32 max_pkt);
extern void hgic_usb_exit(void);
#endif

2
hgic_fmac/Kconfig Normal file
View file

@ -0,0 +1,2 @@
config HGICF
tristate " HUGE-IC FullMac WLAN Driver"

View file

@ -1,23 +1,15 @@
$(CONFIG_HGICF)-objs += cfg.o
$(CONFIG_HGICF)-objs += ctrl.o
$(CONFIG_HGICF)-objs += core.o
$(CONFIG_HGICF)-objs += event.o
$(CONFIG_HGICF)-objs += procfs.o
$(CONFIG_HGICF)-objs += ../utils/fwdl.o
$(CONFIG_HGICF)-objs += ../utils/utils.o
$(CONFIG_HGICF)-objs += ../utils/fwctrl.o
$(CONFIG_HGICF)-objs += ../utils/ota.o
$(CONFIG_HGICF)-objs += ../utils/fwinfo.o
ifeq ($(CONFIG_HGICF), hgicf_sdio)
$(CONFIG_HGICF)-objs += ../utils/if_sdio.o
obj-m += hgicf_sdio.o
else ifeq ($(CONFIG_HGICF), hgicf_usb)
$(CONFIG_HGICF)-objs += ../utils/if_usb.o
obj-m += hgicf_usb.o
else
obj-m += hgicf.o
endif
hgicf-objs += ctrl.o
hgicf-objs += core.o
hgicf-objs += event.o
hgicf-objs += procfs.o
hgicf-objs += ../utils/fwdl.o
hgicf-objs += ../utils/utils.o
hgicf-objs += ../utils/fwctrl.o
hgicf-objs += ../utils/ota.o
hgicf-objs += ../utils/fwinfo.o
hgicf-objs += ../utils/iwpriv.o
hgicf-$(CONFIG_HGIC_SDIO) += ../utils/if_sdio.o
hgicf-$(CONFIG_HGIC_USB) += ../utils/if_usb.o
obj-$(CONFIG_HGICF) += hgicf.o

File diff suppressed because it is too large Load diff

View file

@ -1,13 +0,0 @@
#ifndef _HGICF_CFG_H_
#define _HGICF_CFG_H_
#ifndef __RTOS__
int hgicf_ioctl_set_proc(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_get_proc(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_stat(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_e2p(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_scan(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_savecfg(struct net_device *dev, struct iwreq *wrqin);
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,6 @@
#include "hgicf.h"
#include "ctrl.h"
#include "cfg.h"
#include "event.h"
/* cmd id, Odd : get (world access), even : set (root access) */
@ -28,6 +27,40 @@ struct iw_priv_args hgicf_privtab[] = {
{HG_PRIV_IOCTL_SAVE, IW_PRIV_TYPE_CHAR | 1024, 0, "save"},
};
int hgicf_ioctl_set_proc(struct net_device *dev, struct iwreq *wrqin)
{
struct hgicf_vif *vif = (struct hgicf_vif *)netdev_priv(dev);
return hgic_iwpriv_set_proc(&(vif->hg->ctrl), vif->fwifidx, wrqin);
}
int hgicf_ioctl_get_proc(struct net_device *dev, struct iwreq *wrqin)
{
struct hgicf_vif *vif = (struct hgicf_vif *)netdev_priv(dev);
return hgic_iwpriv_get_proc(&(vif->hg->ctrl), vif->fwifidx, wrqin);
}
int hgicf_ioctl_stat(struct net_device *dev, struct iwreq *wrqin)
{
return 0;
}
int hgicf_ioctl_e2p(struct net_device *dev, struct iwreq *wrqin)
{
return 0;
}
int hgicf_ioctl_savecfg(struct net_device *dev, struct iwreq *wrqin)
{
struct hgicf_vif *vif = (struct hgicf_vif *)netdev_priv(dev);
return hgic_fwctrl_save_cfg(&(vif->hg->ctrl), vif->fwifidx);
}
int hgicf_ioctl_scan(struct net_device *dev, struct iwreq *wrqin)
{
struct hgicf_vif *vif = (struct hgicf_vif *)netdev_priv(dev);
return hgic_fwctrl_scan(&(vif->hg->ctrl), vif->fwifidx);
}
int hgicf_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
int ret = 0;

View file

@ -6,6 +6,14 @@
int hgicf_ioctl(struct net_device *dev, u32 cmd, u32 param1, u32 param2);
#else
int hgicf_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
#endif
int hgicf_ioctl_set_proc(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_get_proc(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_stat(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_e2p(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_savecfg(struct net_device *dev, struct iwreq *wrqin);
int hgicf_ioctl_scan(struct net_device *dev, struct iwreq *wrqin);
#endif
#endif

View file

@ -21,176 +21,54 @@
#endif
#include "hgicf.h"
#include "../utils/fwctrl.h"
#include "cfg.h"
#include "event.h"
char *hgicf_hw_state(int state)
{
switch (state) {
case HGICF_HW_DISCONNECTED:
return "Disconnect";
case HGICF_HW_DISABLED:
return "DISABLED";
case HGICF_HW_INACTIVE:
return "INACTIVE";
case HGICF_HW_SCANNING:
return "SCANNING";
case HGICF_HW_AUTHENTICATING:
return "AUTHENTICATING";
case HGICF_HW_ASSOCIATING:
return "ASSOCIATING";
case HGICF_HW_ASSOCIATED:
return "ASSOCIATED";
case HGICF_HW_4WAY_HANDSHAKE:
return "4WAY_HANDSHAKE";
case HGICF_HW_GROUP_HANDSHAKE:
return "GROUP_HANDSHAKE";
case HGICF_HW_CONNECTED:
return "CONNECTED";
default:
return "Unknown";
}
}
#define HGIC_EVENT_MAX (16)
int hgicf_rx_fw_event(struct hgicf_wdev *hg, struct sk_buff *skb)
void hgicf_rx_fw_event(struct hgic_fwctrl *ctrl, struct sk_buff *skb)
{
char drop = 1;
char drop = 0;
char *data = NULL;
u32 data_len;
u32 evt_id = 0;
struct hgic_ctrl_hdr *evt = NULL;
struct hgicf_vif *vif = NULL;
struct hgicf_wdev *hg = container_of(ctrl, struct hgicf_wdev, ctrl);
if (skb == NULL || skb->dev == NULL || skb->len < sizeof(struct hgic_ctrl_hdr)) {
if (skb == NULL || skb->len < sizeof(struct hgic_ctrl_hdr)) {
dev_kfree_skb(skb);
return -1;
return;
}
vif = (struct hgicf_vif *)netdev_priv(skb->dev);
evt = (struct hgic_ctrl_hdr *)skb->data;
skb_pull(skb, sizeof(struct hgic_ctrl_hdr));
data = skb->data;
data = (char *)(evt + 1);
data_len = skb->len - sizeof(struct hgic_ctrl_hdr);
evt_id = HDR_EVTID(evt);
//hgic_dbg("event id:%d\r\n", evt->event.event_id);
switch (evt_id) {
case HGIC_EVENT_STATE_CHG:
vif->hw_state = data[0];
switch (vif->hw_state) {
case HGICF_HW_CONNECTED:
memcpy(vif->hw_bssid, data + 1, ETH_ALEN);
break;
default:
break;
}
break;
case HGIC_EVENT_DISCONNECT_REASON:
memcpy(&vif->disconnect_reason, data, sizeof(int));
break;
case HGIC_EVENT_ASSOC_STATUS:
memcpy(&vif->assoc_status_code, data, sizeof(int));
break;
case HGIC_EVENT_SCANNING:
hgicf_event(hg, skb->dev->name, HGIC_EVENT_SCANNING, 0, 0);
break;
case HGIC_EVENT_SCAN_DONE:
hgicf_event(hg, skb->dev->name, HGIC_EVENT_SCAN_DONE, 0, 0);
break;
case HGIC_EVENT_TX_BITRATE:
hg->status.tx_bitrate = get_unaligned_le32((u8 *)(evt + 1));
hgicf_event(hg, skb->dev->name, HGIC_EVENT_TX_BITRATE, hg->status.tx_bitrate, 0);
break;
case HGIC_EVENT_PAIR_START:
hg->status.pair_state = 0;
memset(hg->pairing_sta, 0, 6);
hgicf_event(hg, skb->dev->name, HGIC_EVENT_PAIR_START, 0, 0);
break;
case HGIC_EVENT_PAIR_SUCCESS:
hg->status.pair_state = 1;
if(skb->len >= 6) memcpy(hg->pairing_sta, data, 6);
hgicf_event(hg, skb->dev->name, HGIC_EVENT_PAIR_SUCCESS, (long)hg->pairing_sta, 0);
break;
case HGIC_EVENT_PAIR_DONE:
hg->paired_stas_cnt = (evt->hdr.length - sizeof(struct hgic_ctrl_hdr)) / 6;
if (hg->paired_stas) {
kfree(hg->paired_stas);
}
hg->paired_stas = kzalloc(evt->hdr.length, GFP_KERNEL);
if (hg->paired_stas) {
memcpy(hg->paired_stas, data, hg->paired_stas_cnt * 6);
}
hgicf_event(hg, skb->dev->name, HGIC_EVENT_PAIR_DONE, (long)hg->paired_stas, (long)hg->paired_stas_cnt);
break;
case HGIC_EVENT_CONECT_START:
vif->hw_state = HGICF_HW_ASSOCIATING;
hgicf_event(hg, skb->dev->name, HGIC_EVENT_CONECT_START, 0, 0);
break;
case HGIC_EVENT_CONECTED:
vif->hw_state = HGICF_HW_CONNECTED;
hgicf_event(hg, skb->dev->name, HGIC_EVENT_CONECTED, (long)skb->data, skb->len);
break;
case HGIC_EVENT_DISCONECTED:
vif->hw_state = HGICF_HW_DISCONNECTED;
hgicf_event(hg, skb->dev->name, HGIC_EVENT_DISCONECTED, (long)skb->data, skb->len);
break;
case HGIC_EVENT_SIGNAL:
hg->status.signal = (s8)data[0];
hg->status.evm = (s8)data[1];
hgicf_event(hg, skb->dev->name, HGIC_EVENT_SIGNAL, hg->status.signal, hg->status.evm);
break;
case HGIC_EVENT_FWDBG_INFO:
hgicf_event(hg, skb->dev->name, HGIC_EVENT_FWDBG_INFO, (long)skb->data, skb->len);
#ifndef __RTOS__
printk("%s", skb->data);
if (skb_queue_len(&hg->dbginfo_q) > 4) {
kfree_skb(skb_dequeue(&hg->dbginfo_q));
}
skb_queue_tail(&hg->dbginfo_q, skb);
drop = 0;
#endif
break;
case HGIC_EVENT_REQUEST_PARAM:
schedule_work(&hg->ctrl.flush_work);
break;
case HGIC_EVENT_CUSTOMER_MGMT:
hgic_dbg("rx mgmt from %pM, %d bytes\r\n", data, skb->len - 6);
hgicf_event(hg, skb->dev->name, HGIC_EVENT_CUSTOMER_MGMT, (long)skb->data, skb->len);
#ifndef __RTOS__
if (skb_queue_len(&hg->custmgmt_q) > 16) {
kfree_skb(skb_dequeue(&hg->custmgmt_q));
}
skb_queue_tail(&hg->custmgmt_q, skb);
drop = 0;
#endif
break;
case HGIC_EVENT_CUST_DRIVER_DATA:
hgicf_event(hg, skb->dev->name, HGIC_EVENT_CUST_DRIVER_DATA, (long)skb->data, skb->len);
#ifndef __RTOS__
if (skb_queue_len(&hg->cust_driverdata_q) > 16) {
kfree_skb(skb_dequeue(&hg->cust_driverdata_q));
}
skb_queue_tail(&hg->cust_driverdata_q, skb);
drop = 0;
#endif
break;
case HGIC_EVENT_DHCPC_DONE:
#ifndef __RTOS__
memcpy(&hg->dhcpc, skb->data, sizeof(hg->dhcpc));
#endif
hgicf_event(hg, skb->dev->name, HGIC_EVENT_DHCPC_DONE, (long)skb->data, skb->len);
break;
case HGIC_EVENT_CONNECT_FAIL:
hg->status.conntect_fail = data[0];
hgicf_event(hg, skb->dev->name, HGIC_EVENT_CONNECT_FAIL, data[0], 0);
break;
case HGIC_EVENT_UNPAIR_STA:
hgic_dbg("unpair sta: %pM\r\n", data);
hgicf_event(hg, skb->dev->name, HGIC_EVENT_UNPAIR_STA, data, 0);
drop = 1;
printk(data);
break;
default:
break;
}
if (drop) { dev_kfree_skb(skb); }
return 0;
}
#ifdef __RTOS__
hgicf_event(hg, hg->vif->ndev->name, evt_id, data, data_len);
dev_kfree_skb(skb);
#else
if (!drop) {
if (skb_queue_len(&hg->evt_list) > HGIC_EVENT_MAX) {
kfree_skb(skb_dequeue(&hg->evt_list));
hgic_err("event list is full (max %d), drop old event\r\n", HGIC_EVENT_MAX);
}
skb_queue_tail(&hg->evt_list, skb);
up(&hg->evt_sema);
} else {
dev_kfree_skb(skb);
}
#endif
}

View file

@ -2,7 +2,7 @@
#ifndef _HGICF_EVENT_H_
#define _HGICF_EVENT_H_
int hgicf_rx_fw_event(struct hgicf_wdev *hg, struct sk_buff *skb);
void hgicf_rx_fw_event(struct hgic_fwctrl *ctrl, struct sk_buff *skb);
void hgicf_event(struct hgicf_wdev *hg, char *name, int event, int param1, int param2);
#endif

View file

@ -12,8 +12,9 @@
#include "../utils/utils.h"
#include "../utils/fwdl.h"
#include "../utils/fwctrl.h"
#include "procfs.h"
#include "../utils/iwpriv.h"
#include "../utils/ota.h"
#include "procfs.h"
#define FWEVNTQ_SIZE (128)
enum hgicf_dev_flags {
@ -32,31 +33,14 @@ enum hgicf_state {
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;
u32 opened;
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 net_device_stats stats;
};
struct hgicf_status {
@ -65,6 +49,10 @@ struct hgicf_status {
s8 evm;
s8 pair_state;
u8 conntect_fail;
u32 detect_tmr;
u32 tx_ctrl;
u32 tx_data;
u32 tx_fail;
};
struct hgicf_wdev {
@ -74,22 +62,22 @@ struct hgicf_wdev {
u16 data_cookie;
u16 ctrl_cookie;
u16 rx_cookie;
u8 fw_state;
spinlock_t lock;
char *conf_file;
struct hgic_fw_info fwinfo;
struct hgic_bus *bus;
struct hgicf_vif *ap;
struct hgicf_vif *sta;
struct hgicf_vif *vif;
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 work_struct detect_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;
struct timer_list detect_tmr;
unsigned long last_rx;
/*if test*/
struct work_struct test_work;
@ -97,27 +85,15 @@ struct hgicf_wdev {
u32 test_jiff, if_test;
/*soft fc*/
int soft_fc;
int proc_dev;
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;
struct sk_buff_head evt_list;
struct semaphore evt_sema;
#endif
};
@ -127,30 +103,5 @@ struct hgicf_hw_status {
} __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

File diff suppressed because it is too large Load diff

View file

@ -17,38 +17,12 @@ struct hgicf_wdev;
#define HGIC_TESTMODE_BUFF_SIZE (4096)
struct hgicf_procfs {
struct proc_dir_entry *rootdir;
struct proc_dir_entry *tx_bitrate;
struct proc_dir_entry *testmode;
struct proc_dir_entry *status;
struct proc_dir_entry *signal;
struct proc_dir_entry *evm;
struct proc_dir_entry *conn_state;
u8 testmode_buf[HGIC_TESTMODE_BUFF_SIZE];
struct proc_dir_entry *ota;
struct proc_dir_entry *temp;
struct proc_dir_entry *sleep;
struct proc_dir_entry *iwpriv;
u8 iwpriv_buf[4096];
struct proc_dir_entry *paired_stas;
struct proc_dir_entry *radio_off;
struct proc_dir_entry *sta_count;
struct proc_dir_entry *wakeup;
struct proc_dir_entry *wakeup_data;
struct proc_dir_entry *heartbeat;
struct proc_dir_entry *heartbeat_resp;
struct proc_dir_entry *pair_state;
struct proc_dir_entry *fw_ver;
struct proc_dir_entry *wkreason;
u32 iwpriv_result;
struct proc_dir_entry *fwevent;
struct proc_dir_entry *mgmt;
struct proc_dir_entry *battery_level;
struct proc_dir_entry *fwdbginfo;
struct proc_dir_entry *pairing_sta;
struct proc_dir_entry *dhcpc;
struct proc_dir_entry *wkdata_buff;
struct proc_dir_entry *wkdata_mask;
struct proc_dir_entry *cust_driverdata;
struct proc_dir_entry *freqinfo;
};
void hgicf_create_procfs(struct hgicf_wdev *hg);

2
hgtest
View file

@ -1,2 +0,0 @@
#!/bin/sh
echo $1 > /proc/hgic/testmode;cat /proc/hgic/testmode

View file

@ -0,0 +1,14 @@
1. copy driver files to drivers/net/wireless/hugeic.
2. cd drivers/net/wireless/hugeic
cp Makefile.in Makefile
3. modify drivers/net/wireless/Kconfig, add new line:
source "drivers/net/wireless/hugeic/Kconfig"
4. modify drivers/net/wireless/Makefile, add new line:
obj-$(CONFIG_HGICS) += hugeic/
or
obj-$(CONFIG_HGICF) += hugeic/
5. run make menuconfig and select hugeic wifi driver.

2
iwpriv
View file

@ -1,2 +0,0 @@
#!/bin/sh
echo $* > /proc/hgic/iwpriv;cat /proc/hgic/iwpriv

View file

@ -1,34 +0,0 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
编译fmac驱动
1.修改Makefile: 修改编译器相关设置。
例如 mtk 编译环境下:
#MTK SDK
ARCH := mips
COMPILER := /opt/buildroot-gcc463/usr/bin/mipsel-linux-
LINUX_KERNEL_PATH := /home/dongyun/work/disk4/RT288x_AHv1.2/source/linux-3.10.14.x
2. 执行: make fmac
常见编译错误处理:
1. error implicit declaration of function 'PDE_DATA'
该编译错误是由于Linux kernel版本差异proc fs 缺失了 PDE_DATA 小函数。
遇到此error请打开 hgic_fmac/procfs.f 文件,查看下面这段代码,如果 LINUX_VERSION_CODE 不满足条件则修改一下version code判断条件。
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,36)
static inline struct proc_dir_entry *PDE(const struct inode *inode)
{
return PROC_I(inode)->pde;
}
static inline void *PDE_DATA(const struct inode *inode)
{
return PDE(inode)->data;
}
#endif
hgicf.conf : fmac驱动参数文件ap模式
fmac.sh : fmac驱动启动脚本。
hgtest : 测试模式tool用于发送测试模式命令。
iwpriv : 泰芯专用的iwpriv工具。原系统如果没有iwpriv命令则可以使用此工具。

38
tools/ah_tool/build.sh Normal file
View file

@ -0,0 +1,38 @@
#! /bin/sh
###########################################################################
export PATH=$PATH:/opt/buildroot-gcc463/usr/bin
ARCH=mipsel-linux
COMPILER=/opt/buildroot-gcc463/usr/bin/mipsel-linux
###########################################################################
#
rm -rf bin
mkdir lib bin
# if [ ! -d libnl-3.2.25 ]; then
# tar xfz ../libnl-3.2.25.tar.gz
# cd libnl-3.2.25
# ./configure CFLAGS="-ffunction-sections -fdata-sections" --host=${ARCH} --prefix=$(pwd)/lib --enable-shared --enable-static CC=${COMPILER}-gcc
# make clean;make;cd -
# fi
# cp -fv libnl-3.2.25/lib/.libs/libnl-3.a lib/libnl-3.a
# cp -fv libnl-3.2.25/lib/.libs/libnl-genl-3.a lib/libnl-genl-3.a
#
cd ../test_app;make clean;make CC=${COMPILER}-gcc all;cd -
mv -fv ../test_app/bin/* bin/
#
# cd hostapd-2.6/hostapd
# make clean; make CC=${COMPILER}-gcc STRIP=${COMPILER}-strip; cd -
# cp -fv hostapd-2.6/hostapd/hostapd bin/hostapd
# cp -fv hostapd-2.6/hostapd/hostapd_cli bin/hostapd_cli
#
# cd wpa_supplicant-2.6/wpa_supplicant
# make clean; make CC=${COMPILER}-gcc STRIP=${COMPILER}-strip; cd -
# cp -fv wpa_supplicant-2.6/wpa_supplicant/wpa_supplicant bin/wpa_supplicant
# cp -fv wpa_supplicant-2.6/wpa_supplicant/wpa_passphrase bin/wpa_passphrase
# cp -fv wpa_supplicant-2.6/wpa_supplicant/wpa_cli bin/wpa_cli

36
tools/test_app/Makefile Normal file
View file

@ -0,0 +1,36 @@
EXEC = hgota libnetat hgics hgicf hgpriv
CFLAGS += -D__linux__
LDFLAGS += -lm
all: $(EXEC)
$(shell rm -rf bin; mkdir bin)
for i in $(EXEC) ; do mv -fv $$i bin/$$i ; done
tcp_test: tcp_test.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
dsleep_test: dsleep_test.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
hgota: libota.o hgota.o fwinfo.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ libota.o hgota.o fwinfo.o $(LDLIBS)
hguevent: hguevent.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
libnetat: libnetat.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
hgics: hgics.o blenc.o hgics_blenc.o hgics_relay.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ hgics.o hgics_blenc.o hgics_relay.o blenc.o $(LDLIBS)
hgicf: hgicf.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
hgpriv: hgpriv.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o

541
tools/test_app/hgic.h Normal file
View file

@ -0,0 +1,541 @@
#ifndef _HUGE_IC_H_
#define _HUGE_IC_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __RTOS__
#define HGIC_CMD_START 100
#else
#define HGIC_CMD_START 0
#endif
#ifndef __packed
#define __packed __attribute__((packed))
#endif
typedef void (*hgic_init_cb)(void *args);
typedef void (*hgic_event_cb)(char *ifname, int event, int param1, int param2);
struct hgic_bss_info {
unsigned char bssid[6];
unsigned char ssid[32];
unsigned char encrypt;
signed char signal;
unsigned short freq;
};
struct hgic_fw_info {
unsigned int version;
unsigned int svn_version;
unsigned short chip_id;
unsigned short cpu_id;
unsigned char mac[6];
unsigned char resv[2];
unsigned int app_version;
unsigned int smt_dat;
};
struct hgic_sta_info {
unsigned char aid;
unsigned char ps:1;
unsigned char addr[6];
signed char rssi;
signed char evm;
signed char tx_snr;
signed char rx_snr;
};
struct hgic_freqinfo {
unsigned char bss_bw, chan_cnt;
unsigned short freq_start, freq_end;
unsigned short chan_list[16];
};
struct hgic_module_hwinfo{
union{
struct{
unsigned char type;
unsigned char saw:1, rev:7;
};
unsigned short v;
};
};
struct hgic_txq_param {
unsigned short txop;
unsigned short cw_min;
unsigned short cw_max;
unsigned char aifs;
unsigned char acm;
};
struct hgic_mcast_txparam {
unsigned char dupcnt;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char clearch;
};
struct hgic_rx_info {
unsigned char band;
unsigned char mcs: 4, bw: 4;
char evm;
char signal;
unsigned short freq;
short freq_off;
unsigned char rx_flags;
unsigned char antenna;
unsigned char nss : 4, s1g_nss : 4;
unsigned char vht_flag : 3, s1g_flag : 5;
};
struct hgic_tx_info {
unsigned char band;
unsigned char tx_bw;
unsigned char tx_mcs;
unsigned char antenna;
unsigned int tx_flags;
unsigned int tx_flags2;
};
struct bt_rx_info {
unsigned char channel; //current channel
unsigned char con_handle; //hci handle
signed char rssi;
unsigned char frm_type;
unsigned int rev;
};
/*data packet header*/
struct hgic_hdr {
unsigned short magic;
unsigned char type;
unsigned char ifidx: 4, flags: 4;
unsigned short length;
unsigned short cookie;
} __packed;
struct hgic_frm_hdr {
struct hgic_hdr hdr;
union {
struct hgic_rx_info rx_info;
struct hgic_tx_info tx_info;
unsigned char rev[24];
};
} __packed;
struct hgic_frm_hdr2 {
struct hgic_hdr hdr;
} __packed;
/*contro pakcet header*/
struct hgic_ctrl_hdr {
struct hgic_hdr hdr;
union {
struct {
unsigned char cmd_id;
short status;
} cmd;
struct {
unsigned short cmd_id;
short status;
} cmd2;
struct {
unsigned char event_id;
short value;
} event;
struct {
unsigned short event_id;
short value;
} event2;
struct {
unsigned char type;
} hci;
unsigned char info[4];
};
} __packed;
struct hgic_key_conf {
unsigned int cipher;
unsigned int flags;
unsigned char keyidx;
unsigned char keylen;
unsigned char key[0];
};
struct hgic_cca_ctl {
char start_th;
char mid_th;
char ed_th;
/* CCA auto adjustment.
* When the cca automatic adjustment takes effect, the
* above three parameters are invalid.
*/
char auto_en : 1;
};
struct hgic_acs_result{
unsigned int freq;//KHz
unsigned char sync_cnt;
signed char min;
signed char max;
signed char avg;
};
struct hgic_fallback_mcs {
unsigned char original_type;
unsigned char original_mcs;
unsigned char fallback_type;
unsigned char fallback_mcs;
};
#define HDR_CMDID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_CMD2? le16_to_cpu((ctl)->cmd2.cmd_id):(ctl)->cmd.cmd_id)
#define HDR_EVTID(ctl) ((ctl)->hdr.type==HGIC_HDR_TYPE_EVENT2?le16_to_cpu((ctl)->event2.event_id):(ctl)->event.event_id)
#define HDR_CMDID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD2;\
(ctl)->cmd2.cmd_id = cpu_to_le16(id);\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_CMD;\
(ctl)->cmd.cmd_id = id;\
}
#define HDR_EVTID_SET(ctl, id) if(id>255){\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT2;\
(ctl)->event2.event_id = cpu_to_le16(id);\
}else{\
(ctl)->hdr.type =HGIC_HDR_TYPE_EVENT;\
(ctl)->event.event_id = id;\
}
enum hgic_hdr_type {
HGIC_HDR_TYPE_ACK = 1,
HGIC_HDR_TYPE_FRM = 2,
HGIC_HDR_TYPE_CMD = 3,
HGIC_HDR_TYPE_EVENT = 4,
HGIC_HDR_TYPE_FIRMWARE = 5,
HGIC_HDR_TYPE_NLMSG = 6,
HGIC_HDR_TYPE_BOOTDL = 7,
HGIC_HDR_TYPE_TEST = 8,
HGIC_HDR_TYPE_FRM2 = 9,
HGIC_HDR_TYPE_TEST2 = 10,
HGIC_HDR_TYPE_SOFTFC = 11,
HGIC_HDR_TYPE_OTA = 12,
HGIC_HDR_TYPE_CMD2 = 13,
HGIC_HDR_TYPE_EVENT2 = 14,
HGIC_HDR_TYPE_BOOTDL_DATA = 15,
HGIC_HDR_TYPE_IFBR = 16,
HGIC_HDR_TYPE_BEACON = 17,
HGIC_HDR_TYPE_AGGFRM = 18,
HGIC_HDR_TYPE_BLUETOOTH = 19,
HGIC_HDR_TYPE_MAX,
};
enum hgic_cmd {
HGIC_CMD_DEV_OPEN = 1, /* fmac/smac */
HGIC_CMD_DEV_CLOSE = 2, /* fmac/smac */
HGIC_CMD_SET_MAC = 3, /* fmac/smac */
HGIC_CMD_SET_SSID = 4, /* fmac */
HGIC_CMD_SET_BSSID = 5, /* fmac */
HGIC_CMD_SET_COUNTERY = 6, /* fmac */
HGIC_CMD_SET_CHANNEL = 7, /* fmac */
HGIC_CMD_SET_CENTER_FREQ = 8, /* smac */
HGIC_CMD_SET_RTS_THRESHOLD = 9, /* smac */
HGIC_CMD_SET_FRG_THRESHOLD = 10, /* smac */
HGIC_CMD_SET_KEY_MGMT = 11, /* fmac */
HGIC_CMD_SET_WPA_PSK = 12, /* fmac */
HGIC_CMD_SET_KEY = 13, /* smac */
HGIC_CMD_SCAN = 14, /* fmac */
HGIC_CMD_GET_SCAN_LIST = 15, /* fmac */
HGIC_CMD_SET_BSSID_FILTER = 16, /* fmac */
HGIC_CMD_DISCONNECT = 17, /* fmac */
HGIC_CMD_GET_BSSID = 18, /* fmac */
HGIC_CMD_SET_WBNAT = 19, /* unused */
HGIC_CMD_GET_STATUS = 20, /* fmac */
HGIC_CMD_SET_LISTEN_INTERVAL = 21, /* smac */
HGIC_CMD_SET_TX_POWER = 22, /* fmac/smac */
HGIC_CMD_GET_TX_POWER = 23, /* fmac/smac */
HGIC_CMD_SET_TX_LCOUNT = 24, /* unused */
HGIC_CMD_SET_TX_SCOUNT = 25, /* unused */
HGIC_CMD_ADD_STA = 26, /* smac */
HGIC_CMD_REMOVE_STA = 27, /* smac */
HGIC_CMD_SET_TX_BW = 28, /* fmac */
HGIC_CMD_SET_TX_MCS = 29, /* fmac/smac */
HGIC_CMD_SET_FREQ_RANGE = 30, /* fmac */
HGIC_CMD_ACS_ENABLE = 31, /* fmac */
HGIC_CMD_SET_PRIMARY_CHAN = 32, /* fmac */
HGIC_CMD_SET_BG_RSSI = 33, /* fmac */
HGIC_CMD_SET_BSS_BW = 34, /* fmac/smac */
HGIC_CMD_TESTMODE_CMD = 35, /* fmac/smac */
HGIC_CMD_SET_AID = 36, /* smac */
HGIC_CMD_GET_FW_STATE = 37, /* unused */
HGIC_CMD_SET_TXQ_PARAM = 38, /* smac */
HGIC_CMD_SET_CHAN_LIST = 39, /* fmac */
HGIC_CMD_GET_CONN_STATE = 40, /* fmac */
HGIC_CMD_SET_WORK_MODE = 41, /* fmac */
HGIC_CMD_SET_PAIRED_STATIONS = 42, /* fmac */
HGIC_CMD_GET_FW_INFO = 43, /* fmac/smac */
HGIC_CMD_PAIRING = 44, /* fmac */
HGIC_CMD_GET_TEMPERATURE = 45, /* fmac/smac */
HGIC_CMD_ENTER_SLEEP = 46, /* fmac */
HGIC_CMD_OTA = 47, /* fmac */
HGIC_CMD_GET_SSID = 48, /* fmac */
HGIC_CMD_GET_WPA_PSK = 49, /* fmac */
HGIC_CMD_GET_SIGNAL = 50, /* fmac */
HGIC_CMD_GET_TX_BITRATE = 51, /* fmac */
HGIC_CMD_SET_BEACON_INT = 52, /* fmac */
HGIC_CMD_GET_STA_LIST = 53, /* fmac */
HGIC_CMD_SAVE_CFG = 54, /* fmac */
HGIC_CMD_JOIN_GROUP = 55, /* unused */
HGIC_CMD_SET_ETHER_TYPE = 56, /* unused */
HGIC_CMD_GET_STA_COUNT = 57, /* fmac */
HGIC_CMD_SET_HEARTBEAT_INT = 58, /* fmac */
HGIC_CMD_SET_MCAST_KEY = 59, /* unused */
HGIC_CMD_SET_AGG_CNT = 60, /* fmac/smac */
HGIC_CMD_GET_AGG_CNT = 61, /* fmac/smac */
HGIC_CMD_GET_BSS_BW = 62, /* fmac/smac */
HGIC_CMD_GET_FREQ_RANGE = 63, /* fmac */
HGIC_CMD_GET_CHAN_LIST = 64, /* fmac */
HGIC_CMD_RADIO_ONOFF = 65, /* fmac/smac */
HGIC_CMD_SET_PS_HEARTBEAT = 66, /* fmac */
HGIC_CMD_SET_WAKEUP_STA = 67, /* fmac */
HGIC_CMD_SET_PS_HEARTBEAT_RESP = 68, /* fmac */
HGIC_CMD_SET_PS_WAKEUP_DATA = 69, /* fmac */
HGIC_CMD_SET_PS_CONNECT = 70, /* fmac */
HGIC_CMD_SET_BSS_MAX_IDLE = 71, /* fmac */
HGIC_CMD_SET_WKIO_MODE = 72, /* fmac */
HGIC_CMD_SET_DTIM_PERIOD = 73, /* fmac */
HGIC_CMD_SET_PS_MODE = 74, /* fmac */
HGIC_CMD_LOAD_DEF = 75, /* fmac */
HGIC_CMD_DISASSOC_STA = 76, /* fmac */
HGIC_CMD_SET_APLOST_TIME = 77, /* fmac */
HGIC_CMD_GET_WAKEUP_REASON = 78, /* fmac */
HGIC_CMD_UNPAIR = 79, /* fmac */
HGIC_CMD_SET_AUTO_CHAN_SWITCH = 80, /* fmac */
HGIC_CMD_SET_REASSOC_WKHOST = 81, /* fmac */
HGIC_CMD_SET_WAKEUP_IO = 82, /* fmac */
HGIC_CMD_DBGINFO_OUTPUT = 83, /* fmac/smac */
HGIC_CMD_SET_SYSDBG = 84, /* fmac/smac */
HGIC_CMD_SET_AUTO_SLEEP_TIME = 85, /* fmac */
HGIC_CMD_GET_KEY_MGMT = 86, /* fmac */
HGIC_CMD_SET_PAIR_AUTOSTOP = 87, /* fmac */
HGIC_CMD_SET_SUPER_PWR = 88, /* fmac */
HGIC_CMD_SET_REPEATER_SSID = 89, /* fmac */
HGIC_CMD_SET_REPEATER_PSK = 90, /* fmac */
HGIC_CMD_CFG_AUTO_SAVE = 91, /* fmac */
HGIC_CMD_SEND_CUST_MGMT = 92, /* fmac */
HGIC_CMD_GET_BATTERY_LEVEL = 93, /* unused */
HGIC_CMD_SET_DCDC13 = 94, /* fmac */
HGIC_CMD_SET_ACKTMO = 95, /* fmac/smac */
HGIC_CMD_GET_MODULETYPE = 96, /* fmac/smac */
HGIC_CMD_PA_PWRCTRL_DIS = 97, /* fmac */
HGIC_CMD_SET_DHCPC = 98, /* fmac */
HGIC_CMD_GET_DHCPC_RESULT = 99, /* fmac */
HGIC_CMD_SET_WKUPDATA_MASK = 100, /* fmac */
HGIC_CMD_GET_WKDATA_BUFF = 101, /* fmac */
HGIC_CMD_GET_DISASSOC_REASON = 102, /* fmac */
HGIC_CMD_SET_WKUPDATA_SAVEEN = 103, /* fmac */
HGIC_CMD_SET_CUST_DRIVER_DATA = 104, /* fmac */
HGIC_CMD_SET_MCAST_TXPARAM = 105, /* unused */
HGIC_CMD_SET_STA_FREQINFO = 106, /* fmac */
HGIC_CMD_SET_RESET_STA = 107, /* fmac */
HGIC_CMD_SET_UART_FIXLEN = 108, /* unused */
HGIC_CMD_GET_UART_FIXLEN = 109, /* unused */
HGIC_CMD_SET_ANT_AUTO = 110, /* fmac */
HGIC_CMD_SET_ANT_SEL = 111, /* fmac */
HGIC_CMD_GET_ANT_SEL = 112, /* fmac */
HGIC_CMD_SET_WKUP_HOST_REASON = 113, /* fmac */
HGIC_CMD_SET_MAC_FILTER_EN = 114, /* unused */
HGIC_CMD_SET_ATCMD = 115, /* fmac/smac */
HGIC_CMD_SET_ROAMING = 116, /* fmac */
HGIC_CMD_SET_AP_HIDE = 117, /* fmac */
HGIC_CMD_SET_DUAL_ANT = 118, /* fmac */
HGIC_CMD_SET_MAX_TCNT = 119, /* fmac/smac */
HGIC_CMD_SET_ASSERT_HOLDUP = 120, /* fmac/smac */
HGIC_CMD_SET_AP_PSMODE_EN = 121, /* fmac */
HGIC_CMD_SET_DUPFILTER_EN = 122, /* fmac */
HGIC_CMD_SET_DIS_1V1_M2U = 123, /* fmac */
HGIC_CMD_SET_DIS_PSCONNECT = 124, /* fmac */
HGIC_CMD_SET_RTC = 125, /* fmac */
HGIC_CMD_GET_RTC = 126, /* fmac */
HGIC_CMD_SET_KICK_ASSOC = 127, /* fmac */
HGIC_CMD_START_ASSOC = 128, /* fmac */
HGIC_CMD_SET_AUTOSLEEP = 129, /* fmac */
HGIC_CMD_SEND_BLENC_DATA = 130, /* smac */
HGIC_CMD_SET_BLENC_EN = 131, /* smac */
HGIC_CMD_RESET = 132, /* fmac/smac */
HGIC_CMD_SET_HWSCAN = 133, /* smac */
HGIC_CMD_GET_TXQ_PARAM = 134, /* smac */
HGIC_CMD_SET_PROMISC = 135, /* smac */
HGIC_CMD_SET_USER_EDCA = 136, /* fmac */
HGIC_CMD_SET_FIX_TXRATE = 137, /* smac */
HGIC_CMD_SET_NAV_MAX = 138, /* smac */
HGIC_CMD_CLEAR_NAV = 139, /* smac */
HGIC_CMD_SET_CCA_PARAM = 140, /* smac */
HGIC_CMD_SET_TX_MODGAIN = 141, /* smac */
HGIC_CMD_GET_NAV = 142, /* smac */
HGIC_CMD_SET_BEACON_START = 143, /* smac */
HGIC_CMD_SET_BLE_OPEN = 144, /* smac */
HGIC_CMD_GET_MODE = 145, /* fmac */
HGIC_CMD_GET_BGRSSI = 146, /* fmac */
HGIC_CMD_SEND_BLENC_ADVDATA = 147, /* smac */
HGIC_CMD_SEND_BLENC_SCANRESP = 148, /* smac */
HGIC_CMD_SEND_BLENC_DEVADDR = 149, /* smac */
HGIC_CMD_SEND_BLENC_ADVINTERVAL = 150, /* smac */
HGIC_CMD_SEND_BLENC_STARTADV = 151, /* smac */
HGIC_CMD_SET_RTS_DURATION = 152, /* smac */
HGIC_CMD_STANDBY_CFG = 153, /* fmac */
HGIC_CMD_SET_CONNECT_PAIRONLY = 154, /* fmac */
HGIC_CMD_SET_DIFFCUST_CONN = 155, /* fmac */
HGIC_CMD_GET_CENTER_FREQ = 156, /* smac */
HGIC_CMD_SET_WAIT_PSMODE = 157, /* fmac */
HGIC_CMD_SET_AP_CHAN_SWITCH = 158, /* fmac */
HGIC_CMD_SET_CCA_FOR_CE = 159, /* fmac */
HGIC_CMD_SET_DISABLE_PRINT = 160, /* fmac/smac */
HGIC_CMD_SET_APEP_PADDING = 161, /* smac */
HGIC_CMD_GET_ACS_RESULT = 162, /* fmac/smac */
HGIC_CMD_GET_WIFI_STATUS_CODE = 163, /* fmac */
HGIC_CMD_GET_WIFI_REASON_CODE = 164, /* fmac */
HGIC_CMD_SET_WATCHDOG = 165, /* fmac/smac */
HGIC_CMD_SET_RETRY_FALLBACK_CNT = 166, /* smac */
HGIC_CMD_SET_FALLBACK_MCS = 167, /* smac */
HGIC_CMD_GET_XOSC_VALUE = 168, /* smac */
HGIC_CMD_SET_XOSC_VALUE = 169, /* smac */
HGIC_CMD_GET_FREQ_OFFSET = 170, /* smac */
HGIC_CMD_SET_CALI_PERIOD = 171, /* smac */
HGIC_CMD_SET_BLENC_ADVFILTER = 172, /* smac */
HGIC_CMD_SET_MAX_TX_DELAY = 173, /* smac */
HGIC_CMD_GET_STA_INFO = 174, /* fmac */
HGIC_CMD_SEND_MGMTFRAME = 175, /* fmac */
};
enum hgic_event {
HGIC_EVENT_STATE_CHG = 1,
HGIC_EVENT_CH_SWICH = 2,
HGIC_EVENT_DISCONNECT_REASON = 3,
HGIC_EVENT_ASSOC_STATUS = 4,
HGIC_EVENT_SCANNING = 5,
HGIC_EVENT_SCAN_DONE = 6,
HGIC_EVENT_TX_BITRATE = 7,
HGIC_EVENT_PAIR_START = 8,
HGIC_EVENT_PAIR_SUCCESS = 9,
HGIC_EVENT_PAIR_DONE = 10,
HGIC_EVENT_CONECT_START = 11,
HGIC_EVENT_CONECTED = 12,
HGIC_EVENT_DISCONECTED = 13,
HGIC_EVENT_SIGNAL = 14,
HGIC_EVENT_DISCONNET_LOG = 15,
HGIC_EVENT_REQUEST_PARAM = 16,
HGIC_EVENT_TESTMODE_STATE = 17,
HGIC_EVENT_FWDBG_INFO = 18,
HGIC_EVENT_CUSTOMER_MGMT = 19,
HGIC_EVENT_SLEEP_FAIL = 20,
HGIC_EVENT_DHCPC_DONE = 21,
HGIC_EVENT_CONNECT_FAIL = 22,
HGIC_EVENT_CUST_DRIVER_DATA = 23,
HGIC_EVENT_UNPAIR_STA = 24,
HGIC_EVENT_BLENC_DATA = 25,
HGIC_EVENT_HWSCAN_RESULT = 26,
HGIC_EVENT_EXCEPTION_INFO = 27,
HGIC_EVENT_DSLEEP_WAKEUP = 28,
HGIC_EVENT_STA_MIC_ERROR = 29,
HGIC_EVENT_ACS_DONE = 30,
HGIC_EVENT_FW_INIT_DONE = 31,
HGIC_EVENT_ROAM_CONECTED = 32,
HGIC_EVENT_MGMT_FRAME = 33,
};
enum hgicf_hw_state {
HGICF_HW_DISCONNECTED = 0,
HGICF_HW_DISABLED = 1,
HGICF_HW_INACTIVE = 2,
HGICF_HW_SCANNING = 3,
HGICF_HW_AUTHENTICATING = 4,
HGICF_HW_ASSOCIATING = 5,
HGICF_HW_ASSOCIATED = 6,
HGICF_HW_4WAY_HANDSHAKE = 7,
HGICF_HW_GROUP_HANDSHAKE = 8,
HGICF_HW_CONNECTED = 9,
};
enum HGIC_EXCEPTION_NUM{
HGIC_EXCEPTION_CPU_USED_OVERTOP = 1,
HGIC_EXCEPTION_HEAP_USED_OVERTOP = 2,
HGIC_EXCEPTION_WIFI_BUFFER_USED_OVERTOP = 3,
HGIC_EXCEPTION_TX_BLOCKED = 4,
HGIC_EXCEPTION_TXDELAY_TOOLONG = 5,
HGIC_EXCEPTION_STRONG_BGRSSI = 6,
HGIC_EXCEPTION_TEMPERATURE_OVERTOP = 7,
HGIC_EXCEPTION_WRONG_PASSWORD = 8,
};
struct hgic_exception_info {
int num;
union {
struct {
int max, avg, min;
} txdelay;
struct {
int max, avg, min;
} bgrssi;
struct {
int total, used;
} buffer_usage;
struct {
int total, used;
} heap_usage;
struct {
int temp;
} temperature;
} info;
};
struct hgic_dhcp_result {
unsigned int ipaddr, netmask, svrip, router, dns1, dns2;
};
#ifdef __RTOS__
struct firmware {
unsigned char *data;
unsigned int size;
};
int request_firmware(const struct firmware **fw, const char *name, void *dev);
void release_firmware(struct firmware *fw);
extern int hgicf_init(void);
extern int hgicf_cmd(char *ifname, unsigned int cmd, unsigned int param1, unsigned int param2);
extern int hgics_init(void);
extern void hgics_exit(void);
extern int wpas_init(void);
extern int wpas_start(char *ifname);
extern int wpas_stop(char *ifname);
extern int wpas_cli(char *ifname, char *cmd, char *reply_buff, int reply_len);
extern int wpas_passphrase(char *ssid, char *passphrase, char psk[32]);
extern int hapd_init(void);
extern int hapd_start(char *ifname);
extern int hapd_stop(char *ifname);
extern int hapd_cli(char *ifname, char *cmd, char *reply_buff, int reply_len);
extern void hgic_param_iftest(int iftest);
extern const char *hgic_param_ifname(const char *name);
extern char *hgic_param_fwfile(const char *fw);
extern int hgic_param_ifcount(int count);
extern void hgic_param_initcb(hgic_init_cb cb);
extern void hgic_param_eventcb(hgic_event_cb cb);
extern int hgic_ota_start(char *ifname, char *fw_name);
void hgic_raw_init(void);
int hgic_raw_send(char *dest, char *data, int len);
int hgic_raw_rcev(char *buf, int size, char *src);
#ifdef HGIC_SMAC
#include "umac_config.h"
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

199
tools/test_app/hgicf.c Normal file
View file

@ -0,0 +1,199 @@
/**
******************************************************************************
* @file hgicf.c
* @author HUGE-IC Application Team
* @version V1.0.0
* @date 2021-06-23
* @brief hgic fmac driver daemon.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2022 HUGE-IC</center></h2>
*
******************************************************************************
*/
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <poll.h>
#include "hgic.h"
#include "iwpriv.c"
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
#define IFNAME "hg0"
static void hgic_test_read_wakeupdata()
{
int i = 0;
char *buff = malloc(4096);
do {
i = hgic_iwpriv_read_wkdata_buff(IFNAME, buff, 4096);
if (i > 0) {
buff[i] = 0;
printf("get wkdata, len:%d, %s\r\n", i, buff + 42);
}
} while (i > 0);
free(buff);
}
int hgicf_fwevent_parse(u8 *event_data, u32 event_len)
{
int i = 0;
u32 data_len = 0;
u32 evt_id = 0;
char *data = NULL;
char *buff;
struct hgic_exception_info *exp;
struct hgic_dhcp_result *dhcpc;
struct hgic_ctrl_hdr *evt = (struct hgic_ctrl_hdr *)event_data;
data = (char *)(evt + 1);
data_len = event_len - sizeof(struct hgic_ctrl_hdr);
evt_id = HDR_EVTID(evt);
printf("recv firmware event %d\r\n", evt_id);
buff = malloc(4096);
if (buff == NULL) {
return -1;
}
switch (evt_id) {
case HGIC_EVENT_SCANNING:
printf("start scan ...\r\n");
break;
case HGIC_EVENT_SCAN_DONE:
printf("scan done!\r\n");
hgic_iwpriv_get_scan_list(IFNAME, buff, 4096);
printf("%s\r\n", buff);
break;
case HGIC_EVENT_TX_BITRATE:
printf("estimate tx bitrate:%dKbps\r\n", *(unsigned int *)data);
break;
case HGIC_EVENT_PAIR_START:
printf("start pairing ...\r\n");
break;
case HGIC_EVENT_PAIR_SUCCESS:
printf("pairing success! ["MACSTR"]\r\n", MACARG(data));
hgic_iwpriv_set_pairing(IFNAME, 0); //stop pair
break;
case HGIC_EVENT_PAIR_DONE:
printf("pairing done!\r\n");
for(i=0; i*6 < data_len;i++){
printf(" sta%d:"MACSTR"\r\n", i, MACARG(data+6*i));
}
break;
case HGIC_EVENT_CONECT_START:
printf("start connecting ...\r\n");
break;
case HGIC_EVENT_CONECTED:
printf("new sta "MACSTR" connected!\r\n", MACARG(data));
hgic_test_read_wakeupdata();
break;
case HGIC_EVENT_ROAM_CONECTED:
printf("roam success to "MACSTR"!\r\n", MACARG(data));
break;
case HGIC_EVENT_DISCONECTED:
printf("sta "MACSTR" disconnected, reason_code=%d\r\n", MACARG(data), get_unaligned_le16(data+6));
break;
case HGIC_EVENT_SIGNAL:
printf("signal changed: rssi:%d, evm:%d\r\n", (signed char)data[0], (signed char)data[1]);
break;
case HGIC_EVENT_CUSTOMER_MGMT:
printf("rx customer mgmt frame from "MACSTR", %d bytes \r\n", MACARG(data), data_len-6);
break;
case HGIC_EVENT_DHCPC_DONE:
dhcpc = (struct hgic_dhcp_result *)data;
printf("fw dhcpc result: ipaddr:"IPSTR", netmask:"IPSTR", svrip:"IPSTR", router:"IPSTR", dns:"IPSTR"/"IPSTR"\r\n",
IPARG(dhcpc->ipaddr), IPARG(dhcpc->netmask), IPARG(dhcpc->svrip),
IPARG(dhcpc->router), IPARG(dhcpc->dns1), IPARG(dhcpc->dns2));
break;
case HGIC_EVENT_CONNECT_FAIL:
printf("connect fail, status_code=%d\r\n", get_unaligned_le16(data));
break;
case HGIC_EVENT_CUST_DRIVER_DATA:
printf("rx customer driver data %d bytes\r\n", data_len);
break;
case HGIC_EVENT_UNPAIR_STA:
printf("unpair sta:"MACSTR"\r\n", MACARG(data));
break;
case HGIC_EVENT_EXCEPTION_INFO:
exp = (struct hgic_exception_info *)data;
switch(exp->num){
case HGIC_EXCEPTION_TX_BLOCKED:
printf("*wireless tx blocked, maybe need reset wifi module*\r\n");
break;
case HGIC_EXCEPTION_TXDELAY_TOOLONG:
printf("*wireless txdelay too loog, %d:%d:%d *\r\n",
exp->info.txdelay.max, exp->info.txdelay.min, exp->info.txdelay.avg);
break;
case HGIC_EXCEPTION_STRONG_BGRSSI:
printf("*detect strong backgroud noise. %d:%d:%d *\r\n",
exp->info.bgrssi.max, exp->info.bgrssi.min, exp->info.bgrssi.avg);
break;
case HGIC_EXCEPTION_TEMPERATURE_OVERTOP:
printf("*chip temperature too overtop: %d *\r\n", exp->info.temperature.temp);
break;
case HGIC_EXCEPTION_WRONG_PASSWORD:
printf("*password maybe is wrong *\r\n");
break;
}
break;
}
free(buff);
}
int main(int argc, char *argv[])
{
int ret = 0;
int fd = -1;
u8 *buff = malloc(4096);
HGIC = "hgicf";
if (buff == NULL) {
printf("malloc fail\r\n");
return -1;
}
__open:
fd = open("/proc/hgicf/fwevnt", O_RDONLY);
if (fd == -1) {
//printf("open /proc/hgicf/fwevnt fail\r\n");
sleep(1);
goto __open;
}
while (1) {
ret = read(fd, buff, 4096);
if (ret > 0) {
hgicf_fwevent_parse(buff, ret);
}else if(ret < 0){
close(fd);
goto __open;
}
}
close(fd);
free(buff);
return 0;
}

84
tools/test_app/hgpriv.c Normal file
View file

@ -0,0 +1,84 @@
/**
******************************************************************************
* @file hgics.c
* @author HUGE-IC Application Team
* @version V1.0.0
* @date 2022-05-18
* @brief hgic smac driver daemon.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2022 HUGE-IC</center></h2>
*
******************************************************************************
*/
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <poll.h>
#include "hgic.h"
#include "iwpriv.c"
int main(int argc, char *argv[])
{
int fd = -1;
int i = 0;
int len = 0;
char cmd[512];
char *buff;
int ret = 0;
if (argc < 2) {
return -1;
}
buff = malloc(4096);
if (buff == NULL) {
printf("no mem\r\n");
return -1;
}
fd = open("/proc/hgics/iwpriv", O_RDONLY);
if (fd != -1) {
HGIC = "hgics";
} else {
fd = open("/proc/hgicf/iwpriv", O_RDONLY);
if (fd != -1) {
HGIC = "hgicf";
} else {
printf("open iwpriv file fail\r\n");
free(buff);
return -1;
}
}
close(fd);
for (i = 1; i < argc; i++) {
len += sprintf(cmd + len, "%s ", argv[i]);
}
cmd[len - 1] = 0;
memset(buff, 0, 4096);
ret = hgic_iwpriv_do(cmd, 0, 0, buff, 4096);
printf("RESP:%d\r\n%s\r\n", ret, buff);
free(buff);
return 0;
}

1399
tools/test_app/iwpriv.c Normal file

File diff suppressed because it is too large Load diff

254
tools/test_app/libnetat.c Normal file
View file

@ -0,0 +1,254 @@
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <poll.h>
#include <time.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <linux/if.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#define MAC2STR(a) (a)[0]&0xff, (a)[1]&0xff, (a)[2]&0xff, (a)[3]&0xff, (a)[4]&0xff, (a)[5]&0xff
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#define NETAT_BUFF_SIZE (1024)
#define NETAT_PORT (56789)
enum WNB_NETAT_CMD {
WNB_NETAT_CMD_SCAN_REQ = 1,
WNB_NETAT_CMD_SCAN_RESP,
WNB_NETAT_CMD_AT_REQ,
WNB_NETAT_CMD_AT_RESP,
};
struct wnb_netat_cmd {
char cmd;
char len[2];
char dest[6];
char src[6];
char data[0];
};
struct netat_mgr {
int sock;
char dest[6];
char cookie[6];
char recvbuf[NETAT_BUFF_SIZE];
} libnetat;
static void random_bytes(char *buff, int len)
{
int i = 0;
srand(time(NULL));
for (i = 0; i < len; i++) {
buff[i] = (char)(rand() & 0xff);
}
}
static int sock_send(int sock, char *data, int len)
{
int addr_len = sizeof(struct sockaddr_in);
struct sockaddr_in dest;
memset(&dest, 0, sizeof(struct sockaddr_in));
dest.sin_family = AF_INET;
dest.sin_addr.s_addr = INADDR_BROADCAST;
dest.sin_port = htons(NETAT_PORT);
return sendto(sock, data, len, 0, (struct sockaddr *)&dest, addr_len);
}
static int sock_recv(int sock, struct sockaddr_in *dest, char *data, int len, int tmo)
{
int ret = 0;
fd_set rfd;
struct timeval timeout;
int addr_len = sizeof(struct sockaddr_in);
FD_ZERO(&rfd);
FD_SET(sock, &rfd);
timeout.tv_sec = 0;
timeout.tv_usec = tmo * 1000;
ret = select(sock + 1, &rfd, NULL, NULL, &timeout);
if (ret > 0 && FD_ISSET(sock, &rfd)) {
ret = recvfrom(sock, data, len, 0, (struct sockaddr *)dest, &addr_len);
}
//printf("sock_recv, len=%d\r\n", ret);
return ret;
}
static void netat_scan(void)
{
struct wnb_netat_cmd scan;
random_bytes(libnetat.cookie, 6);
memset(&scan, 0, sizeof(scan));
scan.cmd = WNB_NETAT_CMD_SCAN_REQ;
memset(scan.dest, 0xff, 6);
memcpy(scan.src, libnetat.cookie, 6);
sock_send(libnetat.sock, (char *)&scan, sizeof(scan));
}
static void netat_send(char *atcmd)
{
unsigned short len = strlen(atcmd);
struct wnb_netat_cmd *cmd = (struct wnb_netat_cmd *)malloc(strlen(atcmd) + sizeof(struct wnb_netat_cmd));
if (cmd) {
random_bytes(libnetat.cookie, 6);
len = htons(len);
memset(cmd, 0, sizeof(struct wnb_netat_cmd));
cmd->cmd = WNB_NETAT_CMD_AT_REQ;
memcpy(cmd->len, &len, 2);
memcpy(cmd->dest, libnetat.dest, 6);
memcpy(cmd->src, libnetat.cookie, 6);
memcpy(cmd->data, atcmd, strlen(atcmd));
sock_send(libnetat.sock, (char *)cmd, strlen(atcmd) + sizeof(struct wnb_netat_cmd));
free(cmd);
//printf("send atcmd: %s\r\n", atcmd);
}
}
static int netat_recv(char *buff, int len, int tmo)
{
int ret;
int off = 0;
struct sockaddr_in from;
struct wnb_netat_cmd *cmd;
do {
memset(libnetat.recvbuf, 0, NETAT_BUFF_SIZE);
ret = sock_recv(libnetat.sock, &from, libnetat.recvbuf, NETAT_BUFF_SIZE, tmo);
if (ret >= sizeof(struct wnb_netat_cmd)) {
cmd = (struct wnb_netat_cmd *)libnetat.recvbuf;
//printf("recv type=%d\r\n", cmd->cmd);
if (memcmp(cmd->dest, libnetat.cookie, 6) == 0) {
switch (cmd->cmd) {
case WNB_NETAT_CMD_SCAN_RESP:
memcpy(libnetat.dest, cmd->src, 6);
break;
case WNB_NETAT_CMD_AT_RESP:
if (buff) {
strncpy(buff + off, cmd->data, ret - sizeof(struct wnb_netat_cmd));
off += (ret - sizeof(struct wnb_netat_cmd));
} else {
printf("%s\r\n", cmd->data);
}
break;
default:
break;
}
}
}
} while (ret > 0);
if (buff) { buff[off] = 0; }
}
int libnetat_init(char *ifname)
{
int on = 1;
struct sockaddr_in local_addr;
struct ifreq req;
memset(libnetat.dest, 0xff, 6);
libnetat.sock = socket(AF_INET, SOCK_DGRAM, 0);
if (libnetat.sock < 0) {
printf("create udp socket error:[%d:%s]\n", errno, strerror(errno));
return -1;
}
memset(&local_addr, 0, sizeof(struct sockaddr_in));
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
local_addr.sin_port = htons(NETAT_PORT);
if (setsockopt(libnetat.sock, SOL_SOCKET, SO_BROADCAST, (const char *)&on, sizeof(on)) < 0) {
close(libnetat.sock);
libnetat.sock = 0;
return -1;
}
strcpy(req.ifr_name, ifname);
if (setsockopt(libnetat.sock, SOL_SOCKET, SO_BINDTODEVICE, (const char *)&req, sizeof(req)) < 0) {
close(libnetat.sock);
libnetat.sock = 0;
return -1;
}
if (bind(libnetat.sock, (struct sockaddr *)&local_addr, sizeof(struct sockaddr_in)) < 0) {
printf("udp bind error:[%d:%s]\n", errno, strerror(errno));
close(libnetat.sock);
return -1;
}
netat_scan();
netat_recv(NULL, 0, 1);
return 0;
}
int libnetat_send(char *atcmd, char *resp_buff, int buf_size)
{
if (libnetat.sock == 0) {
printf("libnetat is not inited!\r\n");
return -1;
}
if (libnetat.dest[0] & 0x1) {
netat_scan();
netat_recv(NULL, 0, 100);
}
if (libnetat.dest[0] & 0x1) {
printf("not detect device!\r\r");
return -1;
}
netat_send(atcmd);
return netat_recv(resp_buff, buf_size, 10);
}
#if 1 //sample code
int main(int argc, char *argv[])
{
char *ifname = NULL;
char input[256];
char response[1024];
if (argc == 2) {
ifname = argv[1];
} else {
printf("please input interface name!\n");
return -1;
}
if (libnetat_init(ifname)) {
printf("libnetat init fail, inteface:%s\r\n", ifname);
return -1;
}
while (1) {
memset(input, 0, sizeof(input));
printf("\r\n>:");
fflush(stdin);
fgets(input, sizeof(input), stdin);
if (strlen(input) > 0) {
if (strncmp(input, "at", 2) == 0 || strncmp(input, "AT", 2) == 0) {
libnetat_send(input, response, sizeof(response));
printf("%s", response);
}
}
}
}
#endif

11
utils/Kconfig Normal file
View file

@ -0,0 +1,11 @@
config HGIC_USB
bool " Support USB interface"
depends on USB && (HGICS||HGICF)
config HGIC_SDIO
bool " Support SDIO interface"
depends on MMC && (HGICS||HGICF)
config SDIO_REINIT
bool " Support Re-init SDIO interface"
depends on HGIC_SDIO

View file

@ -1,5 +0,0 @@
obj-m += hgic_usb.o
obj-m += hgic_sdio.o
hgic_usb-objs += if_usb.o
hgic_sdio-objs += if_sdio.o

107
utils/bluetooth.c Normal file
View file

@ -0,0 +1,107 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/skbuff.h>
#ifdef CONFIG_BT
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include "../hgic_def.h"
#include "fwdl.h"
#include "fwctrl.h"
#include "utils.h"
static int hgic_hcidev_open(struct hci_dev *hdev)
{
struct hgic_fwctrl *ctrl = hci_get_drvdata(hdev);
if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) {
return 0;
}
hgic_fwctrl_ble_open(ctrl, 1, 1);
return 0;
}
static int hgic_hcidev_flush(struct hci_dev *hdev)
{
return 0;
}
static int hgic_hcidev_close(struct hci_dev *hdev)
{
struct hgic_fwctrl *ctrl = hci_get_drvdata(hdev);
if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) {
return 0;
}
hgic_fwctrl_ble_open(ctrl, 1, 0);
return 0;
}
static int hgic_hcidev_send_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct hgic_fwctrl *ctrl;
hgic_dbg("send bt data, type:%d len %d", bt_cb(skb)->pkt_type, skb->len);
if (!hdev) {
hgic_err("skb->dev is NULLs\r\n");
return -ENODEV;
}
if (!test_bit(HCI_RUNNING, &hdev->flags)) {
hgic_err("bt device is not running\r\n");
return -EBUSY;
}
switch (bt_cb(skb)->pkt_type) {
case HCI_COMMAND_PKT:
hdev->stat.cmd_tx++;
break;
case HCI_ACLDATA_PKT:
hdev->stat.acl_tx++;
break;
case HCI_SCODATA_PKT:
hdev->stat.sco_tx++;
break;
};
ctrl = hci_get_drvdata(hdev);
hgic_fwctrl_send_hci_data(ctrl, bt_cb(skb)->pkt_type, skb->data, skb->len);
kfree_skb(skb);
return 0;
}
static int hgic_hcidev_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
{
return -ENOIOCTLCMD;
}
int hgic_hcidev_init(struct hgic_fwctrl *ctrl, struct hci_dev *hci)
{
int ret = -1;
if (hci) {
hci->bus = (ctrl->bus->type == HGIC_BUS_USB) ? HCI_USB :
(ctrl->bus->type == HGIC_BUS_SDIO ? HCI_SDIO : 0);
hci_set_drvdata(hci, ctrl);
SET_HCIDEV_DEV(hci, ctrl->dev);
hci->open = hgic_hcidev_open;
hci->close = hgic_hcidev_close;
hci->flush = hgic_hcidev_flush;
hci->send = hgic_hcidev_send_frame;
hci->ioctl = hgic_hcidev_ioctl;
ret = hci_register_dev(hci);
}
return ret;
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -15,32 +15,6 @@ struct hgic_cmd_response {
struct sk_buff *skb;
};
struct hgic_fwctrl_params {
u8 *country_code;
u8 *ssid;
u8 *bssid;
u8 *bssid_filter;
u8 *key_mgmt;
u8 *wpa_psk;
u8 *mcast_key;
u8 *mode;
u8 *mac_addr;
u8 *paired_stas;
u8 *chan_list;
u8 channel, chan_bw, bss_bw, tx_mcs, tx_bw;
u16 rts_threshold, frag_threshold;
u16 freq_start, freq_end;
u16 listen_interval;
u16 center_freq;
u16 beacon_int;
u16 ethertype;
u8 acs: 2, acs_tmo: 6;
u8 chan_cnt, txpower, primary_chan, agg_cnt;
u8 ps_mode, wkio_mode, ps_connect, ps_connect_roundup;
u32 dtim_period, bss_max_idle;
u16 aplost_time;
};
struct hgic_fwctrl {
struct device *dev;
u16 cookie;
@ -50,9 +24,12 @@ struct hgic_fwctrl {
struct sk_buff_head txq; /*fw ctrl packet tx queue*/
struct work_struct work; /*fw ctrl rx packet process work*/
struct workqueue_struct *wq;
struct hgic_fwctrl_params param;
struct work_struct flush_work;
u8 qc_mode;
u8 radio_onoff;
struct hgic_fw_info *fwinfo;
struct hgic_bus *bus;
void (*schedule)(struct hgic_fwctrl *ctrl);
void (*rx_event)(struct hgic_fwctrl *ctrl, struct sk_buff *skb);
};
/*
@ -68,129 +45,189 @@ int hgic_fwctrl_set_bytes(struct hgic_fwctrl *ctrl, int cmd_id, char *data, int
*/
u16 hgic_ctrl_cookie(struct hgic_fwctrl *ctrl);
struct sk_buff *hgic_fwctrl_send_data(struct hgic_fwctrl *ctrl, struct sk_buff *skb, struct hgic_cmd_response *resp, u32 timeout);
int hgic_fwctrl_do_cmd(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id, u8 *in, u32 in_len, u8 *out, u32 out_size);
int hgic_fwctrl_set_byte(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id, u8 val);
int hgic_fwctrl_set_int_val(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id, u32 val);
int hgic_fwctrl_get_int_val(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id);
short hgic_fwctrl_get_short_val(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id);
int hgic_fwctrl_set_bytes(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id, u8 *data, u32 len);
int hgic_fwctrl_get_bytes(struct hgic_fwctrl *ctrl, u8 ifidx, u32 cmd_id, u8 *buff, u32 len);
void hgic_fwctrl_init(struct hgic_fwctrl *ctrl, void *dev);
void hgic_fwctrl_init(struct hgic_fwctrl *ctrl, void *dev, struct hgic_bus *bus);
void hgic_fwctrl_release(struct hgic_fwctrl *ctrl);
void hgic_fwctrl_rx(struct hgic_fwctrl *ctrl, struct sk_buff *skb);
void hgic_rx_fw_event(struct hgic_fwctrl *ctrl, struct sk_buff *skb);
void hgic_schedule(struct hgic_fwctrl *ctrl);
void hgic_fwctrl_rx(struct hgic_fwctrl *ctrl, u8 *data, int len);
void hgic_fwctrl_flush_param(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_testmode_cmd(struct hgic_fwctrl *ctrl, u8 *cmd, u32 size);
int hgic_fwctrl_get_status(struct hgic_fwctrl *ctrl, u8 *buff, u32 len);
int hgic_fwctrl_get_conn_state(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_get_fwinfo(struct hgic_fwctrl *ctrl, struct hgic_fw_info *info);
int hgic_fwctrl_set_countryregion(struct hgic_fwctrl *ctrl, u8 *country_code);
int hgic_fwctrl_set_ssid(struct hgic_fwctrl *ctrl, u8 *ssid);
int hgic_fwctrl_set_bssid(struct hgic_fwctrl *ctrl, u8 *bssid);
int hgic_fwctrl_set_channel(struct hgic_fwctrl *ctrl, u32 channel);
int hgic_fwctrl_set_bssid_filter(struct hgic_fwctrl *ctrl, u8 *filter);
int hgic_fwctrl_set_rts_threshold(struct hgic_fwctrl *ctrl, u32 rts_threshold);
int hgic_fwctrl_set_frag_threshold(struct hgic_fwctrl *ctrl, u32 frag_threshold);
int hgic_fwctrl_set_key_mgmt(struct hgic_fwctrl *ctrl, u8 *key_mgmt);
int hgic_fwctrl_set_wpa_psk(struct hgic_fwctrl *ctrl, u8 *psk);
int hgic_fwctrl_set_wbnat(struct hgic_fwctrl *ctrl, u32 enable);
int hgic_fwctrl_set_freq_range(struct hgic_fwctrl *ctrl, u32 freq_start, u32 freq_end, u32 bss_bw);
int hgic_fwctrl_set_bss_bw(struct hgic_fwctrl *ctrl, u8 bss_bw);
int hgic_fwctrl_set_tx_bw(struct hgic_fwctrl *ctrl, u8 tx_bw);
int hgic_fwctrl_set_tx_mcs(struct hgic_fwctrl *ctrl, u8 tx_mcs);
int hgic_fwctrl_set_acs(struct hgic_fwctrl *ctrl, u8 acs, u8 acs_tm);
int hgic_fwctrl_set_bgrssi(struct hgic_fwctrl *ctrl, u8 bgrssi);
int hgic_fwctrl_set_chan_list(struct hgic_fwctrl *ctrl, u16 *chan_list, u32 cnt);
int hgic_fwctrl_set_mode(struct hgic_fwctrl *ctrl, u8 *mode);
int hgic_fwctrl_set_paired_stas(struct hgic_fwctrl *ctrl, u8 *stas, u32 len);
int hgic_fwctrl_set_pairing(struct hgic_fwctrl *ctrl, u8 start);
int hgic_fwctrl_open_dev(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_close_dev(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_txpower(struct hgic_fwctrl *ctrl, u32 tx_power);
int hgic_fwctrl_get_txpower(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_listen_interval(struct hgic_fwctrl *ctrl, u32 listen_interval);
int hgic_fwctrl_set_center_freq(struct hgic_fwctrl *ctrl, u32 channel);
int hgic_fwctrl_set_tx_count(struct hgic_fwctrl *ctrl, u32 short_frm_tx_count, u32 long_frm_tx_count);
int hgic_fwctrl_set_key(struct hgic_fwctrl *ctrl, u8 cmd, u16 aid, u8 *key, u8 len);
int hgic_fwctrl_add_sta(struct hgic_fwctrl *ctrl, u16 aid, u8 *addr);
int hgic_fwctrl_del_sta(struct hgic_fwctrl *ctrl, u32 aid);
int hgic_fwctrl_set_primary_chan(struct hgic_fwctrl *ctrl, u8 primary_chan);
int hgic_fwctrl_set_aid(struct hgic_fwctrl *ctrl, u32 aid);
int hgic_fwctrl_set_mac(struct hgic_fwctrl *ctrl, u8 *mac);
int hgic_fwctrl_get_scan_list(struct hgic_fwctrl *ctrl, u8 *buff, u32 size);
int hgic_fwctrl_scan(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_txq_param(struct hgic_fwctrl *ctrl, u8 *txq, u32 size);
int hgic_fwctrl_testmode_cmd(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *cmd, u32 size);
int hgic_fwctrl_get_status(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *buff, u32 len);
int hgic_fwctrl_get_conn_state(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_fwinfo(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_fw_info *info);
int hgic_fwctrl_set_countryregion(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *country_code);
int hgic_fwctrl_set_ssid(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *ssid);
int hgic_fwctrl_set_bssid(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *bssid);
int hgic_fwctrl_set_channel(struct hgic_fwctrl *ctrl, u8 ifidx, u32 channel);
int hgic_fwctrl_set_bssid_filter(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *filter);
int hgic_fwctrl_set_rts_threshold(struct hgic_fwctrl *ctrl, u8 ifidx, u32 rts_threshold);
int hgic_fwctrl_set_frag_threshold(struct hgic_fwctrl *ctrl, u8 ifidx, u32 frag_threshold);
int hgic_fwctrl_set_key_mgmt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *key_mgmt);
int hgic_fwctrl_set_wpa_psk(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *psk);
int hgic_fwctrl_set_wbnat(struct hgic_fwctrl *ctrl, u8 ifidx, u32 enable);
int hgic_fwctrl_set_freq_range(struct hgic_fwctrl *ctrl, u8 ifidx, u32 freq_start, u32 freq_end, u32 bss_bw);
int hgic_fwctrl_set_bss_bw(struct hgic_fwctrl *ctrl, u8 ifidx, u8 bss_bw);
int hgic_fwctrl_set_tx_bw(struct hgic_fwctrl *ctrl, u8 ifidx, u8 tx_bw);
int hgic_fwctrl_set_tx_mcs(struct hgic_fwctrl *ctrl, u8 ifidx, u8 tx_mcs);
int hgic_fwctrl_set_acs(struct hgic_fwctrl *ctrl, u8 ifidx, u8 acs, u8 acs_tm);
int hgic_fwctrl_set_bgrssi(struct hgic_fwctrl *ctrl, u8 ifidx, u8 bgrssi);
int hgic_fwctrl_set_chan_list(struct hgic_fwctrl *ctrl, u8 ifidx, u16 *chan_list, u32 cnt);
int hgic_fwctrl_set_mode(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *mode);
int hgic_fwctrl_set_paired_stas(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *stas, u32 len);
int hgic_fwctrl_set_pairing(struct hgic_fwctrl *ctrl, u8 ifidx, u32 start);
int hgic_fwctrl_open_dev(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_close_dev(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_txpower(struct hgic_fwctrl *ctrl, u8 ifidx, u32 tx_power);
int hgic_fwctrl_get_txpower(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_listen_interval(struct hgic_fwctrl *ctrl, u8 ifidx, u32 listen_interval);
int hgic_fwctrl_set_center_freq(struct hgic_fwctrl *ctrl, u8 ifidx, u32 channel);
int hgic_fwctrl_set_tx_count(struct hgic_fwctrl *ctrl, u8 ifidx, u32 short_frm_tx_count, u32 long_frm_tx_count);
int hgic_fwctrl_set_key(struct hgic_fwctrl *ctrl, u8 ifidx, u8 cmd, u8 *addr, u8 *key, u8 len);
int hgic_fwctrl_add_sta(struct hgic_fwctrl *ctrl, u8 ifidx, u16 aid, u8 *addr);
int hgic_fwctrl_del_sta(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_primary_chan(struct hgic_fwctrl *ctrl, u8 ifidx, u8 primary_chan);
int hgic_fwctrl_set_aid(struct hgic_fwctrl *ctrl, u8 ifidx, u32 aid);
int hgic_fwctrl_set_mac(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *mac_addr);
int hgic_fwctrl_get_scan_list(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *buff, u32 size);
int hgic_fwctrl_scan(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_txq_param(struct hgic_fwctrl *ctrl, u8 ifidx, u8 ac, struct hgic_txq_param *param);
int hgic_fwctrl_set_user_edca(struct hgic_fwctrl *ctrl, u8 ifidx, u8 ac, struct hgic_txq_param *param);
int hgic_fwctrl_get_temperature(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_enter_sleep(struct hgic_fwctrl *ctrl, u8 sleep);
int hgic_fwctrl_get_sta_list(struct hgic_fwctrl *ctrl, struct hgic_sta_info *sta_list, u32 size);
int hgic_fwctrl_set_beacon_int(struct hgic_fwctrl *ctrl, u32 beacon_int);
int hgic_fwctrl_get_ssid(struct hgic_fwctrl *ctrl, u8 *ssid, u32 size);
int hgic_fwctrl_get_wpapsk(struct hgic_fwctrl *ctrl, u8 *psk, u32 size);
int hgic_fwctrl_save_cfg(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_join_group(struct hgic_fwctrl *ctrl, u8 *addr, u8 aid);
int hgic_fwctrl_set_ethertype(struct hgic_fwctrl *ctrl, u16 type);
int hgic_fwctrl_get_sta_count(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_get_bss_bw(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_get_freq_range(struct hgic_fwctrl *ctrl, u32 *freq_start, u32 *freq_end, u32 *bss_bw);
int hgic_fwctrl_get_chan_list(struct hgic_fwctrl *ctrl, u16 *chan_list, u16 count);
int hgic_fwctrl_get_agg_cnt(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_agg_cnt(struct hgic_fwctrl *ctrl, u8 agg_cnt);
int hgic_fwctrl_set_ps_addr(struct hgic_fwctrl *ctrl, u32 dport);
int hgic_fwctrl_wakeup_sta(struct hgic_fwctrl *ctrl, u8 *addr);
int hgic_fwctrl_set_ps_heartbeat(struct hgic_fwctrl *ctrl, u32 ipaddr, u32 dport, u32 period, u32 hb_tmo);
int hgic_fwctrl_set_ps_heartbeat_resp(struct hgic_fwctrl *ctrl, u8 *data, u32 size);
int hgic_fwctrl_set_ps_wakeup_data(struct hgic_fwctrl *ctrl, u8 *data, u32 size);
int hgic_fwctrl_set_ps_connect(struct hgic_fwctrl *ctrl, u8 period, u8 roundup);
int hgic_fwctrl_set_ps_connect_count(struct hgic_fwctrl *ctrl, u8 try_cnt);
int hgic_fwctrl_set_ps_connect_time(struct hgic_fwctrl *ctrl, u32 time);
int hgic_fwctrl_get_ps_connect(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_get_ps_connect_count(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_get_ps_connect_time(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_radio_onoff(struct hgic_fwctrl *ctrl, u8 onoff);
int hgic_fwctrl_set_bss_max_idle(struct hgic_fwctrl *ctrl, u32 max_idle);
int hgic_fwctrl_set_wkio_mode(struct hgic_fwctrl *ctrl, u8 mode);
int hgic_fwctrl_set_ps_mode(struct hgic_fwctrl *ctrl, u8 mode);
int hgic_fwctrl_set_load_def(struct hgic_fwctrl *ctrl, u8 rst);
int hgic_fwctrl_disassoc_sta(struct hgic_fwctrl *ctrl, u8 *addr);
int hgic_fwctrl_set_dtim_period(struct hgic_fwctrl *ctrl, u32 period);
int hgic_fwctrl_set_aplost_time(struct hgic_fwctrl *ctrl, u32 aplost_time);
int hgic_fwctrl_get_wkreason(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_unpair(struct hgic_fwctrl *ctrl, u8 *addr);
int hgic_fwctrl_set_auto_chswitch(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_mcast_key(struct hgic_fwctrl *ctrl, u8 *mcast_key);
int hgic_fwctrl_set_reassoc_wkhost(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_wakeup_io(struct hgic_fwctrl *ctrl, u8 io, u8 edge);
int hgic_fwctrl_set_dbginfo_output(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_sysdbg(struct hgic_fwctrl *ctrl, u8 *cmd);
int hgic_fwctrl_set_autosleep_time(struct hgic_fwctrl *ctrl, u8 time);
int hgic_fwctrl_get_key_mgmt(struct hgic_fwctrl *ctrl, u8 *ssid, u32 size);
int hgic_fwctrl_get_bssid(struct hgic_fwctrl *ctrl, u8 *bssid);
int hgic_fwctrl_set_supper_pwr(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_repeater_ssid(struct hgic_fwctrl *ctrl, u8 *ssid);
int hgic_fwctrl_set_repeater_psk(struct hgic_fwctrl *ctrl, u8 *wpa_psk);
int hgic_fwctrl_set_auto_save(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_pair_autostop(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_send_cust_mgmt(struct hgic_fwctrl *ctrl, u8 *data, u32 len);
int hgic_fwctrl_get_battery_level(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_dcdc13v(struct hgic_fwctrl *ctrl, u8 enable);
int hgic_fwctrl_set_acktmo(struct hgic_fwctrl *ctrl, u32 tmo);
int hgic_fwctrl_get_module_type(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_pa_pwrctl_dis(struct hgic_fwctrl *ctrl, u8 dis);
int hgic_fwctrl_set_dhcpc(struct hgic_fwctrl *ctrl, u8 en);
int hgic_fwctrl_get_dhcpc_result(struct hgic_fwctrl *ctrl, u8* buff, int len);
int hgic_fwctrl_set_wkdata_mask(struct hgic_fwctrl *ctrl, u16 offset, u8 *mask, u8 mask_len);
int hgic_fwctrl_get_wkdata_buff(struct hgic_fwctrl *ctrl, u8* buff, int len);
int hgic_fwctrl_get_disassoc_reason(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_wkdata_save(struct hgic_fwctrl *ctrl, u8 save);
int hgic_fwctrl_set_cust_driver_data(struct hgic_fwctrl *ctrl, u8 *data, u32 len);
int hgic_fwctrl_set_mcast_txparam(struct hgic_fwctrl *ctrl, struct hgic_mcast_txparam *param);
int hgic_fwctrl_set_freqinfo(struct hgic_fwctrl *ctrl, u8 *data, u32 len);
int hgic_fwctrl_reset_sta(struct hgic_fwctrl *ctrl, u8 *addr);
int hgic_fwctrl_set_ant_auto(struct hgic_fwctrl *ctrl, u8 en);
int hgic_fwctrl_select_ant(struct hgic_fwctrl *ctrl, u8 ant);
int hgic_fwctrl_get_ant_sel(struct hgic_fwctrl *ctrl);
int hgic_fwctrl_set_wkhost_reasons(struct hgic_fwctrl *ctrl, u8 *reasons, u8 len);
int hgic_fwctrl_set_mac_filter(struct hgic_fwctrl *ctrl, u8 en);
int hgic_fwctrl_set_atcmd(struct hgic_fwctrl *ctrl, char *atcmd);
int hgic_fwctrl_set_roaming(struct hgic_fwctrl *ctrl, u8 en, u8 same_freq);
int hgic_fwctrl_set_ap_hide(struct hgic_fwctrl *ctrl, u8 hide);
int hgic_fwctrl_set_frm_tx_maxcnt(struct hgic_fwctrl *ctrl, u8 txcnt);
int hgic_fwctrl_set_assert_holdup(struct hgic_fwctrl *ctrl, u8 holdup);
int hgic_fwctrl_enter_sleep(struct hgic_fwctrl *ctrl, u8 ifidx, u16 sleep, u32 sleep_ms);
int hgic_fwctrl_get_sta_list(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_sta_info *sta_list, u32 size);
int hgic_fwctrl_set_beacon_int(struct hgic_fwctrl *ctrl, u8 ifidx, u32 beacon_int);
int hgic_fwctrl_get_ssid(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *ssid, u32 size);
int hgic_fwctrl_get_mode(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *mode, u32 size);
int hgic_fwctrl_get_wpapsk(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *psk, u32 size);
int hgic_fwctrl_save_cfg(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_join_group(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr, u8 aid);
int hgic_fwctrl_set_ethertype(struct hgic_fwctrl *ctrl, u8 ifidx, u16 type);
int hgic_fwctrl_get_sta_count(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_bss_bw(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_freq_range(struct hgic_fwctrl *ctrl, u8 ifidx, u32 *freq_start, u32 *freq_end, u32 *bss_bw);
int hgic_fwctrl_get_chan_list(struct hgic_fwctrl *ctrl, u8 ifidx, u16 *chan_list, u16 count);
int hgic_fwctrl_get_agg_cnt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *agg, u8 size);
int hgic_fwctrl_set_agg_cnt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 agg[2]);
int hgic_fwctrl_set_ps_addr(struct hgic_fwctrl *ctrl, u8 ifidx, u32 dport);
int hgic_fwctrl_wakeup_sta(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_ps_heartbeat(struct hgic_fwctrl *ctrl, u8 ifidx, u32 ipaddr, u32 dport, u32 period, u32 hb_tmo);
int hgic_fwctrl_set_ps_heartbeat_resp(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 size);
int hgic_fwctrl_set_ps_wakeup_data(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 size);
int hgic_fwctrl_set_ps_connect(struct hgic_fwctrl *ctrl, u8 ifidx, u8 period, u8 roundup);
int hgic_fwctrl_set_ps_connect_count(struct hgic_fwctrl *ctrl, u8 ifidx, u8 try_cnt);
int hgic_fwctrl_set_ps_connect_time(struct hgic_fwctrl *ctrl, u8 ifidx, u32 time);
int hgic_fwctrl_get_ps_connect(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_ps_connect_count(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_ps_connect_time(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_radio_onoff(struct hgic_fwctrl *ctrl, u8 ifidx, u8 onoff);
int hgic_fwctrl_set_bss_max_idle(struct hgic_fwctrl *ctrl, u8 ifidx, u32 max_idle);
int hgic_fwctrl_set_wkio_mode(struct hgic_fwctrl *ctrl, u8 ifidx, u8 mode);
int hgic_fwctrl_set_ps_mode(struct hgic_fwctrl *ctrl, u8 ifidx, u8 mode);
int hgic_fwctrl_set_load_def(struct hgic_fwctrl *ctrl, u8 ifidx, u8 rst);
int hgic_fwctrl_disassoc_sta(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_dtim_period(struct hgic_fwctrl *ctrl, u8 ifidx, u32 period);
int hgic_fwctrl_set_aplost_time(struct hgic_fwctrl *ctrl, u8 ifidx, u32 aplost_time);
int hgic_fwctrl_get_wkreason(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_unpair(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_auto_chswitch(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_mcast_key(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *mcast_key);
int hgic_fwctrl_set_reassoc_wkhost(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_wakeup_io(struct hgic_fwctrl *ctrl, u8 ifidx, u8 io, u8 edge);
int hgic_fwctrl_set_dbginfo_output(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_sysdbg(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *cmd);
int hgic_fwctrl_set_autosleep_time(struct hgic_fwctrl *ctrl, u8 ifidx, u8 time);
int hgic_fwctrl_get_key_mgmt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *ssid, u32 size);
int hgic_fwctrl_get_bssid(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *bssid, u32 len);
int hgic_fwctrl_set_super_pwr(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_repeater_ssid(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *ssid);
int hgic_fwctrl_set_repeater_psk(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *wpa_psk);
int hgic_fwctrl_set_auto_save(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_pair_autostop(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_send_cust_mgmt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_send_mgmtframe(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_get_battery_level(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_dcdc13v(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_acktmo(struct hgic_fwctrl *ctrl, u8 ifidx, u32 tmo);
int hgic_fwctrl_get_module_type(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_pa_pwrctl_dis(struct hgic_fwctrl *ctrl, u8 ifidx, u8 dis);
int hgic_fwctrl_set_dhcpc(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_get_dhcpc_result(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *buff, int len);
int hgic_fwctrl_set_wkdata_mask(struct hgic_fwctrl *ctrl, u8 ifidx, u16 offset, u8 *mask, u8 mask_len);
int hgic_fwctrl_get_wkdata_buff(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *buff, int len);
int hgic_fwctrl_get_disassoc_reason(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_wkdata_save(struct hgic_fwctrl *ctrl, u8 ifidx, u8 save);
int hgic_fwctrl_set_cust_driver_data(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_set_mcast_txparam(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_mcast_txparam *param);
int hgic_fwctrl_set_freqinfo(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_reset_sta(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_ant_auto(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_select_ant(struct hgic_fwctrl *ctrl, u8 ifidx, u8 ant);
int hgic_fwctrl_get_ant_sel(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_wkhost_reasons(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *reasons, u8 len);
int hgic_fwctrl_set_mac_filter(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_set_atcmd(struct hgic_fwctrl *ctrl, u8 ifidx, char *atcmd);
int hgic_fwctrl_set_roaming(struct hgic_fwctrl *ctrl, u8 ifidx, s8 *vals, u8 count);
int hgic_fwctrl_set_ap_hide(struct hgic_fwctrl *ctrl, u8 ifidx, u8 hide);
int hgic_fwctrl_set_frm_tx_maxcnt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 txcnt);
int hgic_fwctrl_set_assert_holdup(struct hgic_fwctrl *ctrl, u8 ifidx, u8 holdup);
int hgic_fwctrl_set_ap_psmode_en(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_set_dupfilter_en(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_set_1v1_m2u_dis(struct hgic_fwctrl *ctrl, u8 ifidx, u8 dis);
int hgic_fwctrl_set_psconnect_dis(struct hgic_fwctrl *ctrl, u8 ifidx, u8 dis);
int hgic_fwctrl_set_blenc_en(struct hgic_fwctrl *ctrl, u8 ifidx, u8 data[3]);
int hgic_fwctrl_blenc_send_data(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_reset(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_hwscan(struct hgic_fwctrl *ctrl, u8 ifidx, u16 period, u16 interval, u16 chan, u16 max);
int hgic_fwctrl_get_txq_param(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_txq_param param[4]);
int hgic_fwctrl_set_promisc(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_fix_txrate(struct hgic_fwctrl *ctrl, u8 ifidx, u32 txrate);
int hgic_fwctrl_set_nav_max(struct hgic_fwctrl *ctrl, u8 ifidx, u32 nav_max);
int hgic_fwctrl_clear_nav(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_cca_param(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_cca_ctl *cca);
int hgic_fwctrl_set_tx_modulation_gain(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *gain_table, u32 size);
int hgic_fwctrl_get_nav(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_send_hci_data(struct hgic_fwctrl *ctrl, u8 type, u8 *data, u32 len);
int hgic_fwctrl_set_beacon_start(struct hgic_fwctrl *ctrl, u8 ifidx, u8 start);
int hgic_fwctrl_ble_open(struct hgic_fwctrl *ctrl, u8 ifidx, u8 open);
int hgic_fwctrl_get_bgrssi(struct hgic_fwctrl *ctrl, u8 ifidx, u8 channel, s8 resp[3]);
int hgic_fwctrl_blenc_set_advdata(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_blenc_set_scanresp(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *data, u32 len);
int hgic_fwctrl_blenc_set_devaddr(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_blenc_set_advinterval(struct hgic_fwctrl *ctrl, u8 ifidx, u32 interval);
int hgic_fwctrl_blenc_start_adv(struct hgic_fwctrl *ctrl, u8 ifidx, u32 en);
int hgic_fwctrl_set_rts_duration(struct hgic_fwctrl *ctrl, u8 ifidx, int duration);
int hgic_fwctrl_set_disable_print(struct hgic_fwctrl *ctrl, u8 ifidx, int dis);
int hgic_fwctrl_set_conn_paironly(struct hgic_fwctrl *ctrl, u8 ifidx, int en);
int hgic_fwctrl_get_center_freq(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_wait_psmode(struct hgic_fwctrl *ctrl, u8 ifidx, u8 wait_psmode);
int hgic_fwctrl_set_diffcust_conn(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_set_ap_chan_switch(struct hgic_fwctrl *ctrl, u8 ifidx, u8 chan, u8 counter);
int hgic_fwctrl_set_cca_for_ce(struct hgic_fwctrl *ctrl, u8 ifidx, u8 en);
int hgic_fwctrl_set_standby(struct hgic_fwctrl *ctrl, u8 ifidx, u8 channel, u32 sleep_period);
int hgic_fwctrl_set_rtc(struct hgic_fwctrl *ctrl, u8 ifidx, u32 rtc);
int hgic_fwctrl_get_rtc(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *rtc);
int hgic_fwctrl_set_apep_padding(struct hgic_fwctrl *ctrl, u8 ifidx, int en);
int hgic_fwctrl_get_reason_code(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_status_code(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_get_acs_result(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_acs_result *result, u8 size);
int hgic_fwctrl_set_watchdog(struct hgic_fwctrl *ctrl, u8 ifidx, u8 enable);
int hgic_fwctrl_set_retry_fallback_cnt(struct hgic_fwctrl *ctrl, u8 ifidx, u8 cnt);
int hgic_fwctrl_set_fallback_mcs(struct hgic_fwctrl *ctrl, u8 ifidx, struct hgic_fallback_mcs *mcs);
int hgic_fwctrl_get_xosc(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_xosc(struct hgic_fwctrl *ctrl, u8 ifidx, int xosc);
int hgic_fwctrl_get_freq_offset(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *addr);
int hgic_fwctrl_set_freq_cali_period(struct hgic_fwctrl *ctrl, u8 ifidx, u16 cali_period);
int hgic_fwctrl_set_blenc_adv_filter(struct hgic_fwctrl *ctrl, u8 ifidx, u32 filter);
int hgic_fwctrl_set_max_tx_delay(struct hgic_fwctrl *ctrl, u8 ifidx, u32 tmo);
int hgic_fwctrl_get_sta_info(struct hgic_fwctrl *ctrl, u8 ifidx, u8 *mac, struct hgic_sta_info *info);
int hgic_fwctrl_get_signal(struct hgic_fwctrl *ctrl, u8 ifidx);
int hgic_fwctrl_set_heartbeat_int(struct hgic_fwctrl *ctrl, u8 ifidx, u32 val);
#endif

View file

@ -14,9 +14,9 @@
#endif
#include "../hgic_def.h"
#include "fwinfo.h"
#include "fwctrl.h"
#include "fwdl.h"
#include "fwinfo.h"
#include "utils.h"
#define BOOT_CMD_KEY "@huge-ic"
@ -37,7 +37,7 @@ u32 hgic_bootdl_init(struct hgic_bootdl *hg_fwdl, struct hgic_bus *bus, struct h
{
if (hg_fwdl == NULL) {
printk("%s:%d:Input para error!\n", __FUNCTION__, __LINE__);
return EINVAL;
return -EINVAL;
}
hgic_dbg("Enter ...\n");
@ -65,6 +65,7 @@ static struct sk_buff *hgic_bootdl_alloc_cmd_skb(struct hgic_bootdl *hg, u8 cmd_
return skb;
}
cmd_hdr = (struct hgic_bootdl_cmd_hdr *)skb->data;
memset(cmd_hdr, 0, sizeof(struct hgic_bootdl_cmd_hdr));
cmd_hdr->cmd = cmd_id;
cmd_hdr->cmd_len = 12;
cmd_hdr->cmd_flag = hg->checksum_mode;
@ -111,15 +112,13 @@ struct sk_buff *hgic_bootdl_send_cmd(struct hgic_bootdl *hg_fwdl, struct sk_buff
struct hgic_bootdl_cmd_hdr *hdr = NULL;
struct hgic_cmd_response resp;
hdr = (struct hgic_bootdl_cmd_hdr *)skb->data;
hdr->hdr.magic = HGIC_HDR_TX_MAGIC;
hdr->hdr.type = HGIC_HDR_TYPE_BOOTDL;
hdr->hdr.length = skb->len;
hdr->hdr.cookie = hgic_ctrl_cookie(hg_fwdl->ctrl);
//printk("hg_fwdl->ctrl=%p\r\n", hg_fwdl->ctrl);
memset(&resp, 0, sizeof(resp));
resp.cookie = hdr->hdr.cookie;
resp.cookie = hgic_ctrl_cookie(hg_fwdl->ctrl);
hdr = (struct hgic_bootdl_cmd_hdr *)skb->data;
hdr->hdr.magic = cpu_to_le16(HGIC_HDR_TX_MAGIC);
hdr->hdr.length = cpu_to_le16(skb->len);
hdr->hdr.cookie = cpu_to_le16(resp.cookie);
hdr->hdr.type = HGIC_HDR_TYPE_BOOTDL;
hg_fwdl->last_cookie = resp.cookie;
return hgic_fwctrl_send_data(hg_fwdl->ctrl, skb, &resp, timeout);
}
@ -129,11 +128,12 @@ struct sk_buff *hgic_bootdl_send_data(struct hgic_bootdl *hg_fwdl, struct sk_buf
struct hgic_bootdl_cmd_hdr *hdr = NULL;
struct hgic_cmd_response resp;
hdr = (struct hgic_bootdl_cmd_hdr *)skb_push(skb, sizeof(struct hgic_bootdl_cmd_hdr));
hdr->hdr.magic = HGIC_HDR_TX_MAGIC;
hdr->hdr.type = HGIC_HDR_TYPE_BOOTDL_DATA;
memset(&resp, 0, sizeof(struct hgic_cmd_response));
resp.cookie = hg_fwdl->last_cookie;
hdr = (struct hgic_bootdl_cmd_hdr *)skb_push(skb, sizeof(struct hgic_bootdl_cmd_hdr));
memset(hdr, 0, sizeof(struct hgic_bootdl_cmd_hdr));
hdr->hdr.magic = cpu_to_le16(HGIC_HDR_TX_MAGIC);
hdr->hdr.type = HGIC_HDR_TYPE_BOOTDL_DATA;
return hgic_fwctrl_send_data(hg_fwdl->ctrl, skb, &resp, timeout);
}
@ -199,7 +199,7 @@ static int hgic_bootdl_send_fw(struct hgic_bootdl *hg, struct sk_buff *skb, u32
if (skb == NULL || hg == NULL) {
hgic_dbg("input para error\n");
return EINVAL;
return -EINVAL;
}
resp_skb = hgic_bootdl_send_data(hg, skb, tmo);
@ -215,7 +215,7 @@ static int hgic_bootdl_send_fw(struct hgic_bootdl *hg, struct sk_buff *skb, u32
return ret;
} else {
hgic_dbg("send fw data error, no resp!\n");
return EFAULT;
return -EFAULT;
}
}
@ -232,6 +232,7 @@ static int hgic_bootdl_send_cmd_tmo(struct hgic_bootdl *hg,
unsigned char cmd = 0;
if (hg == NULL || skb == NULL) {
if(skb) kfree_skb(skb);
return -EINVAL;
}
@ -266,11 +267,11 @@ int hgic_bootdl_cmd_enter(struct hgic_bootdl *hg)
skb = hgic_bootdl_alloc_cmd_skb(hg, HG_BOOTDL_CMD_ENTER);
if (skb) {
cmd_hdr = (struct hgic_bootdl_cmd_hdr *)skb->data;
memcpy((void *)cmd_hdr->addr, (void *)BOOT_CMD_KEY, sizeof(cmd_hdr->addr));
memcpy((void *)cmd_hdr->addr, (void *)BOOT_CMD_KEY, BOOT_CMD_KEY_SIZE);
cmd_hdr->check = hgic_bootdl_cmd_check_val(hg->checksum_mode, (u8 *)&cmd_hdr->cmd, 11);
} else {
hgic_err("malloc skb failed!\n");
return ENOMEM;
return -ENOMEM;
}
ret = hgic_bootdl_send_cmd_tmo(hg, skb, HG_BOOTDL_CMD_NORMAL_TMO, NULL);
if (ret == 0 || ret == HG_BOOTDL_RSP_ERR_IN_FW) {
@ -304,7 +305,7 @@ static int hgic_bootdl_cmd_write_memory(struct hgic_bootdl *hg, u32 write_addr,
cmd_hdr->check = hgic_bootdl_cmd_check_val(hg->checksum_mode, (u8 *)&cmd_hdr->cmd, 11);
} else {
hgic_dbg("malloc skb failed!\n");
return ENOMEM;
return -ENOMEM;
}
return hgic_bootdl_send_cmd_tmo(hg, skb, HG_BOOTDL_CMD_NORMAL_TMO, NULL);
}
@ -335,7 +336,7 @@ static int hgic_bootdl_cmd_run(struct hgic_bootdl *hg)
cmd_hdr->check = hgic_bootdl_cmd_check_val(hg->checksum_mode, (u8 *)&cmd_hdr->cmd, 11);
} else {
hgic_dbg("malloc skb failed!\n");
return ENOMEM;
return -ENOMEM;
}
return hgic_bootdl_send_cmd_tmo(hg, skb, HG_BOOTDL_CMD_NORMAL_TMO, NULL);
}
@ -343,17 +344,10 @@ static int hgic_bootdl_cmd_run(struct hgic_bootdl *hg)
static unsigned int hgic_bootdl_fragment_proc(struct hgic_bootdl *hg, unsigned int copy_len)
{
unsigned int xfer_len = 0;
unsigned int blk = 0;
if (hg->bus->type == HGIC_BUS_SDIO) {
if (copy_len < hg->frag_size) {
blk = copy_len / hg->bus->blk_size;
if (blk) {
xfer_len = blk * hg->bus->blk_size;
} else {
//xfer_len = copy_len;
xfer_len = ALIGN(copy_len, 4);
}
xfer_len = ALIGN(copy_len, hg->bus->blk_size);
} else {
xfer_len = hg->frag_size;
}
@ -368,14 +362,14 @@ int hgic_bootdl_download(struct hgic_bootdl *hg, const char *fw_path)
int ret = 0;
struct sk_buff *skb = NULL;
u32 write_addr = 0;
u32 copy_len = 0;
s32 copy_len = 0;
u32 xfer_len = 0;
u32 addr_offset = 0;
char *data = NULL;
if (hg == NULL || fw_path == NULL) {
printk("%s,%d:input para error!\n", __FUNCTION__, __LINE__);
return EINVAL;
return -EINVAL;
}
hgic_enter();
@ -388,7 +382,7 @@ int hgic_bootdl_download(struct hgic_bootdl *hg, const char *fw_path)
copy_len = hg->fw_info.fw_len;
write_addr = hg->fw_info.write_addr;
data = (char *)(hg->fw->data + hg->fw_info.hdr_len);
while (copy_len) {
while (copy_len > 0) {
//xfer_len = copy_len > hg->frag_size ? hg->frag_size : copy_len;
xfer_len = hgic_bootdl_fragment_proc(hg, copy_len);
skb = dev_alloc_skb(xfer_len + sizeof(struct hgic_bootdl_cmd_hdr));
@ -423,6 +417,8 @@ int hgic_bootdl_download(struct hgic_bootdl *hg, const char *fw_path)
ret = hgic_bootdl_cmd_run(hg);
if (ret) {
printk("%s: Cmd run failed:%d\r\n", __FUNCTION__, ret);
} else {
hgic_dbg("Cmd run success!\n");
}
__finish:
if (hg->fw) {

View file

@ -75,7 +75,6 @@ struct hgic_bootdl {
u8 checksum_mode;
u16 last_cookie;
u32 frag_size;
//struct sk_buff_head fw_dataq;
struct hgic_bus *bus;
struct hgic_fwctrl *ctrl;
struct firmware *fw;

File diff suppressed because it is too large Load diff

View file

@ -41,11 +41,19 @@
#define SDIO_INIT_STATUS_ADDR 0x04
#define SDIO_INIT_STATUS_ADDR2 0x48
#define SDIO_TRANS_COUNT_ADDR2 0x49
#define SDIO_INIT_STATUS_DATA_READY 0x01
#define SDIO_BUSY_ADDR2 0x4c
#define HGIC_PKT_MAX_LEN (8*1024)
#define SDIO_INIT_STATUS_DATA_READY BIT(0)
#define SDIO_INIT_STATUS_BUSY BIT(3)
#define SDIO_STATUS_STOP BIT(0)
#define SDIO_STATUS_ERROR BIT(1)
#define SDIO_TX_HEADROM (4)
static hgic_probe probe_hdl = NULL;
static u32 max_pkt_len = HGIC_PKT_MAX_LEN;
struct hgic_sdio {
struct sdio_func_t *func;
u32 status;
@ -53,13 +61,16 @@ struct hgic_sdio {
u32 trans_cnt_addr; /*sdio data length register address*/
u32 int_status_addr; /*interrupt status register address*/
struct hgic_bus bus;
u32 rx_retry;
u8 rx_retry;
u8 busypd;
struct completion busy;
u8 *rxbuf;
};
const struct sdio_device_id_t hgic_sdio_wdev_ids[] = {
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4001)},
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4002)},
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4102)},
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_4002)},
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_4104)},
{SDIO_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_8400)},
{ /* end: all zeroes */ },
};
@ -80,7 +91,7 @@ const struct sdio_device_id_t hgic_sdio_wdev_ids[] = {
#define SDIO_CAP_POLL(func) ((func)->card->host->caps & MMC_CAP_NEEDS_POLL)
#define HOST_SPI_CRC(func, crc) (func)->card->host->use_spi_crc=crc
#define mmc_card_disable_cd(c) (1)
//#define mmc_card_disable_cd(c) (1)
#define hgic_card_disable_cd(func) mmc_card_disable_cd((func)->card)
#define hgic_card_set_highspeed(func) mmc_card_set_highspeed((func)->card)
#define hgic_host_is_spi(func) mmc_host_is_spi((func)->card->host)
@ -120,6 +131,11 @@ static inline int hgic_mmc_send_cmd(struct sdio_func_t *func, struct mmc_command
{
return mmc_wait_for_cmd(func->card->host, cmd, retries);
}
static inline void hgic_mmc_set_blk_size(struct sdio_func_t *func, unsigned int blk_size)
{
func->card->host->max_blk_size = blk_size;
func->card->host->ops->set_ios(func->card->host, &func->card->host->ios);
}
#endif
static int hgic_mmc_io_rw_direct(struct sdio_func_t *func, int write, unsigned fn,
@ -382,14 +398,14 @@ static int hgic_sdio_set_wire_width(struct sdio_func_t *func)
return 1;
}
static u32 hgic_sdio_select_card(struct sdio_func_t *func)
static u32 hgic_sdio_select_card(struct sdio_func_t *func, u32 rca)
{
int err;
struct mmc_command_t cmd = {0};
cmd.opcode = MMC_SELECT_CARD;
if (func) {
cmd.arg = hgic_func_rca(func) << 16;
cmd.arg = rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
} else {
cmd.arg = 0;
@ -436,11 +452,12 @@ static int hgic_mmc_spi_set_crc(struct sdio_func_t *func, int use_crc)
static int hgic_sdio_reinit_card(struct sdio_func_t *func)
{
#ifdef CONFIG_SDIO_REINIT
int i = 3;
u32 ocr = 0;
u32 rca = 0;
int retry = 0;
struct hgic_sdio *sdiodev = sdio_get_drvdata(func);
u32 rca = 0;
hgic_enter();
__RETRY:
@ -457,10 +474,15 @@ __RETRY:
i = 5;
ocr = 0;
rca = 0;
hgic_mmc_set_clock(func, 400000);
hgic_mmc_set_timing(func, MMC_TIMING_LEGACY);
hgic_mmc_set_bus_width(func, MMC_BUS_WIDTH_1);
if (!hgic_sdio_get_card_addr(func, (u32 *)&rca)) {
hgic_sdio_select_card(func, rca);
}
hgic_sdio_reset(func);
hgic_sdio_go_idle(func);
hgic_mmc_send_if_cond(func, ocr);
@ -468,7 +490,8 @@ __RETRY:
if (hgic_send_io_op_cond(func, 0, (u32 *)&ocr)) {
goto __RETRY;
}
if (hgic_send_io_op_cond(func, hgic_card_ocr(func), (u32 *)&ocr)) {
if (hgic_send_io_op_cond(func, ocr, (u32 *)&ocr)) {
goto __RETRY;
}
@ -477,11 +500,10 @@ __RETRY:
goto __RETRY;
}
} else {
rca = hgic_func_rca(func);
if (hgic_sdio_get_card_addr(func, (u32 *)&rca)) {
goto __RETRY;
}
if (hgic_sdio_select_card(func)) {
if (hgic_sdio_select_card(func, rca)) {
goto __RETRY;
}
if (hgic_sdio_disable_cd(func) < 0) {
@ -495,6 +517,8 @@ __RETRY:
hgic_mmc_set_clock(func, hgic_card_highspeed(func) ? 50000000 : hgic_card_max_clock(func));
hgic_mmc_set_timing(func, MMC_TIMING_SD_HS);
hgic_mmc_set_blk_size(func, SDIO_BLOCK_SIZE);
if (hgic_sdio_set_wire_width(func) < 0) {
goto __RETRY;
}
@ -507,11 +531,13 @@ __RETRY:
if (sdio_enable_func(func)) {
goto __RETRY;
}
hgic_leave();
#ifndef __RTOS__
if (func->card->host->sdio_irq_thread) {
wake_up_process(func->card->host->sdio_irq_thread);
}
#endif
hgic_leave();
#endif
return 0;
}
@ -532,7 +558,10 @@ static int hgic_sdio_readb(struct sdio_func_t *func, u32 addr, int *err)
int retry = 2;
val = sdio_readb(func, addr, err);
if (val == 0) { *err = -1; } //if read 0, try again.
//if (val == 0) {
// *err = -1;
//}
while (*err && retry-- > 0) {
val = sdio_readb(func, addr, err);
}
@ -581,6 +610,7 @@ static int hgic_sdio_abort(struct sdio_func_t *func)
hgic_sdio_writeb(&func0, 1, 6, &err_ret);
return err_ret;
}
static int hgic_sdio_read_cccr(struct sdio_func_t *func, u8 *pending)
{
int ret = 0;
@ -591,20 +621,44 @@ static int hgic_sdio_read_cccr(struct sdio_func_t *func, u8 *pending)
return ret;
}
static u32 hgic_sdio_data_len(struct hgic_sdio *sdiodev)
static u32 hgic_sdio_get_datalen(struct hgic_sdio *sdiodev, u8 addr)
{
int err = 0;
u32 len = 0;
u8 ret = 0;
u16 addr = test_bit(HGIC_BUS_FLAGS_INBOOT, &sdiodev->bus.flags) ?
sdiodev->trans_cnt_addr : SDIO_TRANS_COUNT_ADDR2;
ret = hgic_sdio_readb(sdiodev->func, addr, &err);
if (err) { return 0xffffffff; }
if (err) {
return 0xffffffff;
}
len = ret;
ret = hgic_sdio_readb(sdiodev->func, addr + 1, &err);
if (err) { return 0xffffffff; }
if (err) {
return 0xffffffff;
}
len |= ret << 8;
return len;
}
static u32 hgic_sdio_data_len(struct hgic_sdio *sdiodev)
{
int ret = 0;
u32 len = 0;
if (!test_bit(HGIC_BUS_FLAGS_INBOOT, &sdiodev->bus.flags)) {
if(sdiodev->bus.dev_id == HGIC_WLAN_4002){
len = hgic_sdio_get_datalen(sdiodev, SDIO_TRANS_COUNT_ADDR2);
}else{
len = sdio_readb(sdiodev->func, SDIO_TRANS_COUNT_ADDR2, &ret);
len = len * SDIO_BLOCK_SIZE;
}
}
if (len == 0 || len == 0xffffffff) {
len = hgic_sdio_get_datalen(sdiodev, sdiodev->trans_cnt_addr);
}
if (len == 0) {
if (test_bit(HGIC_BUS_FLAGS_INBOOT, &sdiodev->bus.flags)) {
@ -617,8 +671,7 @@ static u32 hgic_sdio_data_len(struct hgic_sdio *sdiodev)
return len;
}
static int hgic_sdio_is_data_ready(struct hgic_sdio *sdiodev, struct sdio_func_t *func)
static u32 hgic_sdio_int_status(struct hgic_sdio *sdiodev, struct sdio_func_t *func)
{
int ret = 0;
u8 pending = 0;
@ -627,9 +680,7 @@ static int hgic_sdio_is_data_ready(struct hgic_sdio *sdiodev, struct sdio_func_t
ret = hgic_sdio_read_cccr(func, &pending);
if (!ret && (pending & 02)) {
int_status1 = sdio_readb(func, sdiodev->int_status_addr, &ret);
if (ret) { int_status1 = sdio_readb(func, sdiodev->int_status_addr, &ret); }
int_status1 &= SDIO_INIT_STATUS_DATA_READY;
int_status1 = hgic_sdio_readb(func, sdiodev->int_status_addr, &ret);
if (!ret && !int_status1 && !test_bit(HGIC_BUS_FLAGS_INBOOT, &sdiodev->bus.flags)) {
int_status2 = hgic_sdio_readb(func, SDIO_INIT_STATUS_ADDR2, &ret);
if (int_status1 != int_status2) {
@ -637,7 +688,9 @@ static int hgic_sdio_is_data_ready(struct hgic_sdio *sdiodev, struct sdio_func_t
int_status1 = int_status2;
}
}
if (!int_status1) { hgic_sdio_abort(func); }
if (!int_status1) {
hgic_sdio_abort(func);
}
}
return int_status1;
}
@ -647,15 +700,16 @@ static void hgic_sdio_interrupt(struct sdio_func_t *func)
int ret = 0;
u32 len = 0;
int read_more = 0;
struct sk_buff *skb = NULL;
u32 int_status;
struct hgic_sdio *sdiodev = sdio_get_drvdata(func);
if (sdiodev == NULL || (sdiodev->status&SDIO_STATUS_STOP) || test_bit(HGIC_BUS_FLAGS_SLEEP, &sdiodev->bus.flags)) {
if (sdiodev == NULL || (sdiodev->status & SDIO_STATUS_STOP)) {
return;
}
read_more = sdiodev->rx_retry;
do {
if (hgic_sdio_is_data_ready(sdiodev, func)) {
int_status = hgic_sdio_int_status(sdiodev, func);
if (int_status & SDIO_INIT_STATUS_DATA_READY) {
read_more = sdiodev->rx_retry;
len = hgic_sdio_data_len(sdiodev);
if (len == 0xFFFFFFFF) {
@ -664,65 +718,101 @@ static void hgic_sdio_interrupt(struct sdio_func_t *func)
hgic_sdio_reinit_card(func);
return;
} else if (len > 0) {
skb = dev_alloc_skb(len);
if (skb == NULL) {
hgic_err("no memory\r\n");
if (len > max_pkt_len){
hgic_err("len error: %d, max:%d\r\n", len, max_pkt_len);
hgic_sdio_abort(func);
return;
}
ret = hgic_sdio_copy_fromio(sdiodev->func, skb->data,
sdiodev->data_addr, len);
ret = hgic_sdio_copy_fromio(sdiodev->func, sdiodev->rxbuf, sdiodev->data_addr, len);
if (ret) {
dev_kfree_skb(skb);
hgic_err("sdio_copy_fromio err!, ret:%d\r\n", ret);
return;
}
ret = sdiodev->bus.rx_packet(sdiodev->bus.bus_priv, skb, len);
ret = sdiodev->bus.rx_packet(sdiodev->bus.bus_priv, sdiodev->rxbuf, len);
if (ret) {
hgic_sdio_abort(func);
}
} else {
hgic_sdio_abort(func);
}
} else if (read_more > 0) {
}
if ((int_status & SDIO_INIT_STATUS_BUSY) && sdiodev->busypd) {
//printk("*\r\n");
complete(&sdiodev->busy);
}
if (int_status == 0 && read_more > 0) {
udelay(20);
}
} while (!ret && read_more-- > 0);
}
static int hgic_sdio_is_busy(struct hgic_sdio *sdiodev)
{
int err = 0;
u8 val = 0;
val = hgic_sdio_readb(sdiodev->func, SDIO_BUSY_ADDR2, &err);
if(err) hgic_sdio_reinit_card(sdiodev->func);
return (err || (val & 0x01)) ? 1 : 0;
}
static int hgic_sdio_tx_packet(void *bus, struct sk_buff *skb)
{
int ret = 0;
int busy = 1;
struct list_head *head;
struct hgic_sdio *sdiodev = container_of(bus, struct hgic_sdio, bus);
int len = skb->len > SDIO_BLOCK_SIZE ? ALIGN(skb->len, SDIO_BLOCK_SIZE) : ALIGN(skb->len, 4);
#ifndef __RTOS__
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
head = &sdiodev->func->card->host->wq.head;
#else
head = &sdiodev->func->card->host->wq.task_list;
#endif
if (!list_empty(head) /*|| (!SDIO_CAP_IRQ(sdiodev->func) && time_after(jiffies, sdiodev->last_rxtick + msecs_to_jiffies(100)))*/) {
schedule();
}
#endif
sdio_claim_host(sdiodev->func);
if ((sdiodev->status & SDIO_STATUS_STOP) || test_bit(HGIC_BUS_FLAGS_SLEEP, &sdiodev->bus.flags)) {
sdiodev->bus.tx_complete(sdiodev->bus.bus_priv, skb, 0);
sdio_release_host(sdiodev->func);
return -1;
}
while (busy && !test_bit(HGIC_BUS_FLAGS_SOFTFC, &sdiodev->bus.flags)) {
busy = hgic_sdio_is_busy(sdiodev);
if (busy) {
sdiodev->busypd = 1;
sdio_release_host(sdiodev->func);
wait_for_completion_timeout(&sdiodev->busy, msecs_to_jiffies(10));
sdio_claim_host(sdiodev->func);
sdiodev->busypd = 0;
if ((sdiodev->status & SDIO_STATUS_STOP) || test_bit(HGIC_BUS_FLAGS_SLEEP, &sdiodev->bus.flags)) {
sdiodev->bus.tx_complete(sdiodev->bus.bus_priv, skb, 0);
sdio_release_host(sdiodev->func);
return -1;
}
}
}
ret = hgic_sdio_copy_toio(sdiodev->func, sdiodev->data_addr, skb->data, len);
sdio_release_host(sdiodev->func);
sdiodev->bus.tx_complete(sdiodev->bus.bus_priv, skb, !ret);
return ret;
}
static struct hgic_bus hgic_ifbus_sdio = {
.type = HGIC_BUS_SDIO,
.drv_tx_headroom = SDIO_TX_HEADROM,
.tx_packet = hgic_sdio_tx_packet,
.reinit = hgic_sdio_reinit,
.bootdl_pktlen = 32704,
.bootdl_cksum = HGIC_BUS_BOOTDL_CHECK_0XFD,
};
static int hgic_sdio_enable(struct sdio_func_t *func)
{
int ret;
hgic_dbg("Enter\n");
sdio_claim_host(func);
hgic_mmc_set_blk_size(func, SDIO_BLOCK_SIZE);
ret = sdio_set_block_size(func, SDIO_BLOCK_SIZE);
if (ret) {
hgic_err("Set sdio block size %d failed: %d)\n", SDIO_BLOCK_SIZE, ret);
@ -735,6 +825,7 @@ static int hgic_sdio_enable(struct sdio_func_t *func)
}
ret = sdio_enable_func(func);
if (ret) {
sdio_release_irq(func);
hgic_err("enable sdio function failed: %d)\n", ret);
goto out;
}
@ -745,7 +836,7 @@ out:
return ret;
}
int hgic_sdio_probe(struct sdio_func_t *func, const struct sdio_device_id_t *id)
static int hgic_sdio_probe(struct sdio_func_t *func, const struct sdio_device_id_t *id)
{
int ret = 0;
struct hgic_sdio *sdiodev = NULL;
@ -760,24 +851,41 @@ int hgic_sdio_probe(struct sdio_func_t *func, const struct sdio_device_id_t *id)
return -ENOMEM;
}
sdiodev->rxbuf = kmalloc(max_pkt_len, GFP_KERNEL);
if (sdiodev->rxbuf == NULL) {
hgic_err("alloc rxbuf fail, size:%d\r\n", max_pkt_len);
goto __failed;
}
hgic_dbg("new sdio card: vendor:%x, id:%x\n", id->vendor_id, id->device_id);
sdiodev->func = func;
sdiodev->data_addr = SDIO_DATA_ADDR;
sdiodev->trans_cnt_addr = SDIO_TRANS_COUNT_ADDR;
sdiodev->int_status_addr = SDIO_INIT_STATUS_ADDR;
sdiodev->status = SDIO_STATUS_STOP;
sdiodev->bus = hgic_ifbus_sdio;
//sdiodev->status = SDIO_STATUS_STOP;
sdiodev->bus.type = HGIC_BUS_SDIO;
sdiodev->bus.drv_tx_headroom = SDIO_TX_HEADROM;
sdiodev->bus.tx_packet = hgic_sdio_tx_packet;
#ifdef CONFIG_SDIO_REINIT
sdiodev->bus.reinit = hgic_sdio_reinit;
#endif
sdiodev->bus.bootdl_pktlen = 32704;
sdiodev->bus.bootdl_cksum = HGIC_BUS_BOOTDL_CHECK_0XFD;
sdiodev->bus.probe = probe_hdl;
sdiodev->bus.dev_id = id->device_id;
sdiodev->bus.blk_size = SDIO_BLOCK_SIZE;
sdiodev->rx_retry = SDIO_CAP_IRQ(func) ? 0 : 5;
init_completion(&sdiodev->busy);
if (!SDIO_CAP_POLL(func)) {
set_bit(HGIC_BUS_FLAGS_NOPOLL, &sdiodev->bus.flags);
}
if (hgic_host_is_spi(func)) {
sdiodev->bus.bootdl_pktlen = 4096;
}
hgic_core_probe(FUNC_DEV(func), &sdiodev->bus);
sdiodev->bus.probe(FUNC_DEV(func), &sdiodev->bus);
if (sdiodev->bus.bus_priv == NULL) {
hgic_err("err\r\n");
goto __failed;
@ -789,21 +897,28 @@ int hgic_sdio_probe(struct sdio_func_t *func, const struct sdio_device_id_t *id)
goto __failed;
}
sdiodev->status &= ~SDIO_STATUS_STOP;
hgic_core_probe_post(sdiodev->bus.bus_priv);
//sdiodev->status &= ~SDIO_STATUS_STOP;
if (sdiodev->bus.probe_post) {
sdiodev->bus.probe_post(sdiodev->bus.bus_priv);
}
hgic_dbg("ok\n");
return ret;
__failed:
hgic_dbg("failed\n");
sdio_set_drvdata(func, NULL);
hgic_core_remove(sdiodev->bus.bus_priv);
if (sdiodev->bus.remove) {
sdiodev->bus.remove(sdiodev->bus.bus_priv);
}
if (sdiodev->rxbuf) {
kfree(sdiodev->rxbuf);
}
kfree(sdiodev);
hgic_dbg("failed 2\n");
return ret;
}
void hgic_sdio_remove(struct sdio_func_t *func)
static void hgic_sdio_remove(struct sdio_func_t *func)
{
struct hgic_sdio *sdiodev = NULL;
@ -817,9 +932,17 @@ void hgic_sdio_remove(struct sdio_func_t *func)
sdio_release_irq(func);
sdio_release_host(func);
hgic_dbg("remove ... 2\n");
hgic_core_remove(sdiodev->bus.bus_priv);
if (sdiodev->bus.remove) {
sdiodev->bus.remove(sdiodev->bus.bus_priv);
}
hgic_dbg("remove ... 3\n");
sdio_claim_host(func);
#ifdef __RTOS__
deinit_completion(&sdiodev->busy);
#endif
if (sdiodev->rxbuf) {
kfree(sdiodev->rxbuf);
}
sdio_set_drvdata(func, NULL);
kfree(sdiodev);
sdio_release_host(func);
@ -834,10 +957,9 @@ static int hgic_sdio_suspend(struct device *dev)
int ret = 0;
struct sdio_func_t *func = dev_to_sdio_func(dev);
struct hgic_sdio *sdiodev = (struct hgic_sdio *)sdio_get_drvdata(func);
ret = hgic_core_suspend(sdiodev->bus.bus_priv);
sdio_claim_host(func);
ret = sdio_release_irq(func);
sdio_release_host(func);
if (sdiodev->bus.suspend) {
ret = sdiodev->bus.suspend(sdiodev->bus.bus_priv);
}
return ret;
}
static int hgic_sdio_resume(struct device *dev)
@ -845,10 +967,9 @@ static int hgic_sdio_resume(struct device *dev)
int ret = 0;
struct sdio_func_t *func = dev_to_sdio_func(dev);
struct hgic_sdio *sdiodev = (struct hgic_sdio *)sdio_get_drvdata(func);
sdio_claim_host(func);
ret = sdio_claim_irq(func, hgic_sdio_interrupt);
sdio_release_host(func);
ret = hgic_core_resume(sdiodev->bus.bus_priv);
if (sdiodev->bus.resume) {
ret = sdiodev->bus.resume(sdiodev->bus.bus_priv);
}
return ret;
}
static const struct dev_pm_ops hgic_sdio_pm_ops = {
@ -856,6 +977,7 @@ static const struct dev_pm_ops hgic_sdio_pm_ops = {
.resume = hgic_sdio_resume,
};
#endif
#ifdef SDIO_DRIVER_EXT
extern struct sdio_driver_t hgic_sdio_driver;
#else
@ -872,11 +994,15 @@ static struct sdio_driver_t hgic_sdio_driver = {
};
#endif
int __init hgic_sdio_init(void)
int __init hgic_sdio_init(hgic_probe probe, u32 max_pkt)
{
int ret;
hgic_dbg("Enter\n");
hgic_dbg("Enter, max_pkt_len = %d\n", max_pkt_len);
probe_hdl = probe;
if(max_pkt > HGIC_PKT_MAX_LEN){
max_pkt_len = max_pkt;
}
ret = sdio_register_driver(&hgic_sdio_driver);
hgic_dbg("Leave\n");
return ret;
@ -889,11 +1015,3 @@ void __exit hgic_sdio_exit(void)
hgic_dbg("Leave\n");
}
#ifndef CONFIG_HGIC_SDIOIN
module_init(hgic_sdio_init);
module_exit(hgic_sdio_exit);
MODULE_DESCRIPTION("HUGE-IC WLAN Driver");
MODULE_AUTHOR("Dongyun");
MODULE_LICENSE("GPL");
#endif

View file

@ -14,21 +14,23 @@
#include "../hgic_def.h"
#include "utils.h"
#define HGIC_PKT_MAX_LEN 2048
#define HGIC_TX_URB_CNT 64
#define HGIC_RX_URB_CNT 64
#define HGIC_PKT_MAX_LEN (2*1024+512)
#define HGIC_TX_URB_CNT 16
#define HGIC_RX_URB_CNT 32
#define HGIC_USB_STATUS_STOP BIT(0)
#define HGIC_USB_STATUS_ERR BIT(1)
#define HGIC_USB_BUF_FLAG_USED 0x00000001
#define HGIC_USB_BUF_FLAG_USED BIT(0)
#define HGIC_USB_BUF_FLAG_RX BIT(1)
#define USB_TX_HEADROM 4
struct hgic_usb_buf {
struct list_head list;
struct hgic_usb *usbdev;
struct urb *urb;
struct sk_buff *skb;
void *data;
int flag;
};
@ -47,16 +49,30 @@ struct hgic_usb {
static int txq_cnt = HGIC_TX_URB_CNT;
static int rxq_cnt = HGIC_RX_URB_CNT;
static hgic_probe probe_hdl = NULL;
static u32 max_pkt_len = HGIC_PKT_MAX_LEN;
static const struct usb_device_id hgic_usb_wdev_ids[] = {
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4001) },
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4002) },
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_AH_4102) },
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_4002) },
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_4104) },
{ USB_DEVICE(HGIC_VENDOR_ID, HGIC_WLAN_8400)},
{ /* end: all zeroes */ },
};
MODULE_DEVICE_TABLE(usb, hgic_usb_wdev_ids);
static void hgic_usb_receive(struct urb *urb);
static void hgic_usb_cancle(struct hgic_usb *usbdev)
{
unsigned long flags;
struct hgic_usb_buf *buf, *n;
spin_lock_irqsave(&usbdev->qlock, flags);
list_for_each_entry_safe(buf, n, &usbdev->used, list) {
usb_unlink_urb(buf->urb);
}
spin_unlock_irqrestore(&usbdev->qlock, flags);
}
static void hgic_usb_free(struct hgic_usb *usbdev)
{
unsigned long flags;
@ -66,25 +82,32 @@ static void hgic_usb_free(struct hgic_usb *usbdev)
list_for_each_entry_safe(buf, n, &usbdev->tx_freeq, list) {
list_del(&buf->list);
usb_free_urb(buf->urb);
if(buf->data){
hgic_err("skb is not free??\r\n");
kfree_skb(buf->data);
buf->data = NULL;
}
kfree(buf);
//hgic_dbg("free usb tx buff\r\n");
}
list_for_each_entry_safe(buf, n, &usbdev->rx_freeq, list) {
list_del(&buf->list);
kfree(buf->data);
usb_free_urb(buf->urb);
kfree(buf);
//hgic_dbg("free usb rx buff\r\n");
}
list_for_each_entry_safe(buf, n, &usbdev->used, list) {
usb_kill_urb(buf->urb);
list_del(&buf->list);
if (buf->flag & HGIC_USB_BUF_FLAG_RX) {
kfree(buf->data);
}
usb_free_urb(buf->urb);
kfree(buf);
}
spin_unlock_irqrestore(&usbdev->qlock, flags);
}
static int hgic_usb_qinit(struct hgic_usb *usb, struct list_head *q, int qsize)
static int hgic_usb_qinit(struct hgic_usb *usb, struct list_head *q, int qsize, u8 rx)
{
int i = 0;
struct hgic_usb_buf *buf = NULL;
@ -92,12 +115,22 @@ static int hgic_usb_qinit(struct hgic_usb *usb, struct list_head *q, int qsize)
for (i = 0; i < qsize; i++) {
buf = kzalloc(sizeof(struct hgic_usb_buf), GFP_ATOMIC);
if (buf == NULL) {
hgic_err("alloc fail, i=%d\r\n", i);
break;
}
buf->usbdev = usb;
buf->urb = usb_alloc_urb(0, GFP_KERNEL);
if (buf->urb) {
if (rx) {
buf->data = kmalloc(max_pkt_len, GFP_KERNEL);
if (buf->data == NULL) {
kfree(buf);
hgic_err("alloc fail, len=%d\r\n", max_pkt_len);
break;
}
buf->flag |= HGIC_USB_BUF_FLAG_RX;
}
list_add_tail(&buf->list, q);
} else {
kfree(buf);
@ -107,7 +140,7 @@ static int hgic_usb_qinit(struct hgic_usb *usb, struct list_head *q, int qsize)
return i;
}
struct hgic_usb_buf *hgic_usb_deq(struct hgic_usb *usbdev, struct list_head *q)
static struct hgic_usb_buf *hgic_usb_deq(struct hgic_usb *usbdev, struct list_head *q)
{
struct hgic_usb_buf *buf = NULL;
unsigned long flags;
@ -123,12 +156,11 @@ struct hgic_usb_buf *hgic_usb_deq(struct hgic_usb *usbdev, struct list_head *q)
return buf;
}
void hgic_usb_enq(struct hgic_usb_buf *buf, struct list_head *q)
static void hgic_usb_enq(struct hgic_usb_buf *buf, struct list_head *q)
{
unsigned long flags;
spin_lock_irqsave(&buf->usbdev->qlock, flags);
buf->skb = NULL;
buf->flag &= ~HGIC_USB_BUF_FLAG_USED;
list_del(&buf->list);
list_add_tail(&buf->list, q);
@ -139,21 +171,20 @@ static int hgic_usb_submit_rx_urb(struct hgic_usb_buf *buf)
{
int ret = -1;
buf->skb = dev_alloc_skb(HGIC_PKT_MAX_LEN);
if (!buf->skb) {
hgic_err("alloc skb failed\r\n");
if (buf->usbdev->status & (HGIC_USB_STATUS_STOP | HGIC_USB_STATUS_ERR)) {
hgic_usb_enq(buf, &buf->usbdev->rx_freeq);
return -1;
}
usb_fill_bulk_urb(buf->urb, buf->usbdev->udev,
usb_rcvbulkpipe(buf->usbdev->udev, buf->usbdev->ep_in),
buf->skb->data, HGIC_PKT_MAX_LEN, hgic_usb_receive, buf);
buf->data, max_pkt_len, hgic_usb_receive, buf);
ret = usb_submit_urb(buf->urb, GFP_ATOMIC);
if (ret) {
hgic_err("submit rx urb failed: %d\n", ret);
dev_kfree_skb_any(buf->skb);
hgic_err("submit rx urb %p failed: %d\n", buf->urb, ret);
hgic_usb_enq(buf, &buf->usbdev->rx_freeq);
buf->usbdev->status |= HGIC_USB_STATUS_ERR;
hgic_usb_cancle(buf->usbdev);
return -1;
}
return 0;
@ -177,27 +208,29 @@ static void hgic_usb_receive(struct urb *urb)
{
struct hgic_usb_buf *buf = (struct hgic_usb_buf *)urb->context;
if (buf->usbdev->status & (HGIC_USB_STATUS_STOP | HGIC_USB_STATUS_ERR)) {
dev_kfree_skb_any(buf->skb);
//hgic_enter();
if (buf->usbdev->status & HGIC_USB_STATUS_STOP) {
hgic_usb_enq(buf, &buf->usbdev->rx_freeq);
hgic_err("STOP, drop data, status=%x\r\n", buf->usbdev->status);
return;
}
if (urb->actual_length > 0) {
buf->usbdev->bus.rx_packet(buf->usbdev->bus.bus_priv, buf->skb, urb->actual_length);
} else {
dev_kfree_skb_any(buf->skb);
buf->usbdev->bus.rx_packet(buf->usbdev->bus.bus_priv, buf->data, urb->actual_length);
}
hgic_usb_submit_rx_urb(buf);
//hgic_leave();
}
static void hgic_usb_tx_complete(struct urb *urb)
{
struct hgic_usb_buf *buf = (struct hgic_usb_buf *)urb->context;
//hgic_skip_padding(buf->skb);
buf->usbdev->bus.tx_complete(buf->usbdev->bus.bus_priv, buf->skb, !urb->status);
hgic_usb_enq(buf, &buf->usbdev->tx_freeq);
up(&buf->usbdev->tx_sema);
struct hgic_usb *usbdev = buf->usbdev;
usbdev->bus.tx_complete(usbdev->bus.bus_priv, (struct sk_buff *)buf->data, !urb->status);
buf->data = NULL;
hgic_usb_enq(buf, &usbdev->tx_freeq);
up(&usbdev->tx_sema);
}
static int hgic_usb_tx_packet(void *bus, struct sk_buff *skb)
@ -207,9 +240,10 @@ static int hgic_usb_tx_packet(void *bus, struct sk_buff *skb)
struct hgic_usb_buf *buf = NULL;
struct hgic_usb *usbdev = container_of(bus, struct hgic_usb, bus);
if ((len & (usbdev->ep_out_size - 1)) == 0) {
len += 4;
}
#ifdef CONFIG_USB_ZERO_PACKET
if (IS_ALIGNED(len, usbdev->ep_out_size)) len += 4;
#endif
if (usbdev->status & (HGIC_USB_STATUS_STOP | HGIC_USB_STATUS_ERR)) {
ret = -EIO;
goto __fail;
@ -221,16 +255,19 @@ static int hgic_usb_tx_packet(void *bus, struct sk_buff *skb)
goto __fail;
}
if (usbdev->status & (HGIC_USB_STATUS_STOP | HGIC_USB_STATUS_ERR)) {
ret = -EIO;
goto __fail;
}
buf = hgic_usb_deq(usbdev, &usbdev->tx_freeq);
if (buf == NULL) {
ret = -ENOMEM;
goto __fail;
}
buf->skb = skb;
usb_fill_bulk_urb(buf->urb, usbdev->udev,
usb_sndbulkpipe(usbdev->udev, usbdev->ep_out),
skb->data, len, /*ALIGN(skb->len, 4)*/
hgic_usb_tx_complete, buf);
buf->data = skb;
usb_fill_bulk_urb(buf->urb, usbdev->udev, usb_sndbulkpipe(usbdev->udev, usbdev->ep_out),
skb->data, len, hgic_usb_tx_complete, buf);
buf->urb->transfer_flags |= URB_ZERO_PACKET;
ret = usb_submit_urb(buf->urb, GFP_ATOMIC);
if (ret) {
@ -242,20 +279,13 @@ static int hgic_usb_tx_packet(void *bus, struct sk_buff *skb)
__fail:
if (buf) {
buf->data = NULL;
hgic_usb_enq(buf, &usbdev->tx_freeq);
}
usbdev->bus.tx_complete(usbdev->bus.bus_priv, skb, 0);
return ret;
}
static struct hgic_bus hgic_bus_usb = {
.type = HGIC_BUS_USB,
.drv_tx_headroom = USB_TX_HEADROM,
.tx_packet = hgic_usb_tx_packet,
.bootdl_pktlen = 2048,
.bootdl_cksum = HGIC_BUS_BOOTDL_CHECK_0XFD,
};
static int hgic_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
int i = 0;
@ -273,11 +303,16 @@ static int hgic_usb_probe(struct usb_interface *intf, const struct usb_device_id
return -ENOMEM;
}
memset(usbdev, 0, sizeof(struct hgic_usb));
usbdev->udev = udev;
usbdev->bus = hgic_bus_usb;
usbdev->bus.type = HGIC_BUS_USB;
usbdev->bus.dev_id = id->idProduct;
usbdev->status = HGIC_USB_STATUS_STOP;
usbdev->bus.drv_tx_headroom = USB_TX_HEADROM;
usbdev->bus.tx_packet = hgic_usb_tx_packet;
usbdev->bus.bootdl_pktlen = 2048;
usbdev->bus.bootdl_cksum = HGIC_BUS_BOOTDL_CHECK_0XFD;
usbdev->bus.probe = probe_hdl;
//usbdev->status = HGIC_USB_STATUS_STOP;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
@ -297,30 +332,36 @@ static int hgic_usb_probe(struct usb_interface *intf, const struct usb_device_id
INIT_LIST_HEAD(&usbdev->tx_freeq);
INIT_LIST_HEAD(&usbdev->rx_freeq);
INIT_LIST_HEAD(&usbdev->used);
ret = hgic_usb_qinit(usbdev, &usbdev->tx_freeq, txq_cnt);
ret = hgic_usb_qinit(usbdev, &usbdev->tx_freeq, txq_cnt, 0);
sema_init(&usbdev->tx_sema, ret);
hgic_dbg("usb txq:%d\r\n", ret);
ret = hgic_usb_qinit(usbdev, &usbdev->rx_freeq, rxq_cnt);
ret = hgic_usb_qinit(usbdev, &usbdev->rx_freeq, rxq_cnt, 1);
hgic_dbg("usb rxq:%d\r\n", ret);
hgic_core_probe(&udev->dev, &usbdev->bus);
usbdev->bus.probe(&udev->dev, &usbdev->bus);
if (!usbdev->bus.bus_priv) {
ret = -ENOMEM;
goto __failed;
}
usb_get_dev(udev);
usb_set_intfdata(intf, usbdev);
//usbdev->status &= ~HGIC_USB_STATUS_STOP;
ret = hgic_usb_submit_rx_urbs(usbdev);
if (ret) {
goto __failed;
}
usb_get_dev(udev);
usb_set_intfdata(intf, usbdev);
usbdev->status &= ~HGIC_USB_STATUS_STOP;
hgic_core_probe_post(usbdev->bus.bus_priv);
if (usbdev->bus.probe_post) {
usbdev->bus.probe_post(usbdev->bus.bus_priv);
}
return ret;
__failed:
hgic_core_remove(usbdev->bus.bus_priv);
if (usbdev->bus.remove) {
usbdev->bus.remove(usbdev->bus.bus_priv);
}
hgic_usb_free(usbdev);
kfree(usbdev);
return -1;
@ -329,14 +370,18 @@ __failed:
static void hgic_usb_disconnect(struct usb_interface *intf)
{
struct hgic_usb *usbdev = usb_get_intfdata(intf);
hgic_dbg("hgic_usb_disconnect>>>>\r\n");
hgic_dbg("Enter\n");
if (usbdev) {
usbdev->status |= HGIC_USB_STATUS_STOP;
hgic_core_remove(usbdev->bus.bus_priv);
up(&usbdev->tx_sema);
if (usbdev->bus.remove) {
usbdev->bus.remove(usbdev->bus.bus_priv);
}
hgic_usb_free(usbdev);
kfree(usbdev);
usb_set_intfdata(intf, NULL);
}
hgic_dbg("Leave\n");
}
static struct usb_driver hgic_usb_driver = {
@ -349,11 +394,15 @@ static struct usb_driver hgic_usb_driver = {
.supports_autosuspend = 1,
};
int __init hgic_usb_init(void)
int __init hgic_usb_init(hgic_probe probe, u32 max_pkt)
{
int ret = 0;
hgic_dbg("Enter\n");
hgic_dbg("Enter, max_pkt_len = %d\n", max_pkt_len);
probe_hdl = probe;
if(max_pkt > HGIC_PKT_MAX_LEN){
max_pkt_len = max_pkt;
}
ret = usb_register(&hgic_usb_driver);
if (ret) {
hgic_err("driver register failed: %d\n", ret);
@ -368,11 +417,4 @@ void __exit hgic_usb_exit(void)
usb_deregister(&hgic_usb_driver);
hgic_dbg("Leave\n");
}
#ifndef CONFIG_HGIC_USBIN
module_init(hgic_usb_init);
module_exit(hgic_usb_exit);
MODULE_DESCRIPTION("HUGE-IC WLAN Driver");
MODULE_AUTHOR("Dongyun");
MODULE_LICENSE("GPL");
#endif

1684
utils/iwpriv.c Normal file

File diff suppressed because it is too large Load diff

11
utils/iwpriv.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef _HGICF_CFG_H_
#define _HGICF_CFG_H_
#ifndef __RTOS__
int hgic_iwpriv_set_proc(struct hgic_fwctrl *ctrl, u8 ifidx, struct iwreq *wrqin);
int hgic_iwpriv_get_proc(struct hgic_fwctrl *ctrl, u8 ifidx, struct iwreq *wrqin);
int hgic_iwpriv_dump(struct hgic_fwctrl *ctrl, struct iwreq *wrqin);
#endif
#endif

View file

@ -42,14 +42,14 @@ static struct sk_buff *hgic_ota_send_packet_tmo(struct hgic_ota *ota, struct sk_
struct hgic_cmd_response resp;
struct hgic_hdr *hdr = NULL;
resp.cookie = hgic_ctrl_cookie(ota->ctrl);
memset(&resp, 0, sizeof(resp));
hdr = (struct hgic_hdr *)skb_push(skb, sizeof(struct hgic_hdr));
hdr->magic = HGIC_HDR_TX_MAGIC;
hdr->magic = cpu_to_le16(HGIC_HDR_TX_MAGIC);
hdr->length = cpu_to_le16(skb->len);
hdr->cookie = cpu_to_le16(resp.cookie);
hdr->type = HGIC_HDR_TYPE_OTA;
hdr->ifidx = HGIC_WDEV_ID_STA;
hdr->length = skb->len;
hdr->cookie = hgic_ctrl_cookie(ota->ctrl);
memset(&resp, 0, sizeof(resp));
resp.cookie = hdr->cookie;
hgic_fwctrl_send_data(ota->ctrl, skb, &resp, tmo);
return resp.skb;
}
@ -89,7 +89,7 @@ s32 hgic_ota_init(struct hgic_ota *ota, struct hgic_fwctrl *ctrl, struct hgic_fw
static s32 hgic_ota_fill_hdr(struct hgic_ota *ota, struct sk_buff *skb, u32 offset)
{
struct hgic_ota_hdr *hdr = NULL;
u32 payload_len = 0;
u16 payload_len = 0;
if (ota == NULL || skb == NULL || skb->len > ota->frag_size) {
hgic_err("Input para error!\r\n");
@ -103,12 +103,12 @@ static s32 hgic_ota_fill_hdr(struct hgic_ota *ota, struct sk_buff *skb, u32 offs
hdr = (struct hgic_ota_hdr *)skb_push(skb, sizeof(struct hgic_ota_hdr));
memset(hdr, 0, sizeof(struct hgic_ota_hdr));
hdr->chipid = ota->ori_fw_info->chip_id;
hdr->len = payload_len;
hdr->tot_len = ota->fw_len;
hdr->off = offset;
hdr->version = ota->ori_fw_info->version;
hdr->checksum = hgic_ota_check_sum(hdr->data, hdr->len);
hdr->chipid = cpu_to_le16(ota->ori_fw_info->chip_id);
hdr->len = cpu_to_le16(payload_len);
hdr->tot_len = cpu_to_le32(ota->fw_len);
hdr->off = cpu_to_le32(offset);
hdr->version = cpu_to_le32(ota->ori_fw_info->version);
hdr->checksum = cpu_to_le16(hgic_ota_check_sum(hdr->data, hdr->len));
return 0;
}
@ -271,8 +271,8 @@ s32 hgic_ota_send_fw(struct hgic_ota *ota, char *fw_name, u32 tmo)
skb_pull(resp, sizeof(struct hgic_hdr));
hdr = (struct hgic_ota_hdr *)resp->data;
if (hdr->err_code) {
hgic_err("Responce Error:Error code:%d\n", hdr->err_code);
ret = hdr->err_code;
hgic_err("Responce Error:Error code:%d\n", le16_to_cpu(hdr->err_code));
ret = le16_to_cpu(hdr->err_code);
goto __failed;
} else {
hgic_dbg("OTA write to flash success!\n");

View file

@ -21,22 +21,12 @@
#define STATBUF_SIZE (64*1024)
#define SAFE_DIV(a, b) (((b) == 0) ? 0 : ((a) / (b)))
int hgic_skip_padding(struct sk_buff *skb)
int hgic_skip_padding(u8* data)
{
int i = 0;
for (i = 0; i < 3 && skb->data[i] == 0xFF; i++);
if (i) {
if (skb->len > 0) {
skb_pull(skb, i);
} else {
skb->data += i;
skb->tail += i;
}
}
for (i = 0; i < 3 && data[i] == 0xFF; i++);
return i;
}
EXPORT_SYMBOL(hgic_skip_padding);
#if 0
int hgic_aligned_padding(struct sk_buff *skb)
@ -55,7 +45,6 @@ int hgic_aligned_padding(struct sk_buff *skb)
}
return count;
}
EXPORT_SYMBOL(hgic_aligned_padding);
#endif
void hgic_print_hex(char *buf, int len)
@ -69,7 +58,6 @@ void hgic_print_hex(char *buf, int len)
}
printk("\r\n\r\n");
}
EXPORT_SYMBOL(hgic_print_hex);
int hgic_config_read_int(char *conf, char *field)
{
@ -79,7 +67,6 @@ int hgic_config_read_int(char *conf, char *field)
}
return 0;
}
EXPORT_SYMBOL(hgic_config_read_int);
int hgic_config_read_str(char *conf, char *field, char *str, int size)
{
@ -94,7 +81,6 @@ int hgic_config_read_str(char *conf, char *field, char *str, int size)
}
return -1;
}
EXPORT_SYMBOL(hgic_config_read_str);
int hgic_config_read_u32_array(char *conf, char *field, u32 *arr, int count)
{
@ -124,7 +110,6 @@ int hgic_config_read_u32_array(char *conf, char *field, u32 *arr, int count)
return cnt;
}
EXPORT_SYMBOL(hgic_config_read_u32_array);
int hgic_config_read_u16_array(char *conf, char *field, u16 *arr, int count)
{
@ -154,10 +139,10 @@ int hgic_config_read_u16_array(char *conf, char *field, u16 *arr, int count)
return cnt;
}
EXPORT_SYMBOL(hgic_config_read_u16_array);
void hgic_clear_queue(struct sk_buff_head *q)
{
#if 0
ulong flags = 0;
struct sk_buff *skb = NULL;
struct sk_buff *tmp = NULL;
@ -170,6 +155,13 @@ void hgic_clear_queue(struct sk_buff_head *q)
}
}
spin_unlock_irqrestore(&q->lock, flags);
#else
struct sk_buff *skb = skb_dequeue(q);
while(skb){
kfree_skb(skb);
skb = skb_dequeue(q);
}
#endif
}
int hgic_hex2num(char c)
@ -183,47 +175,48 @@ int hgic_hex2num(char c)
if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
return -1;
return 0;
}
int hgic_hex2byte(const char *hex)
{
int a, b;
a = hgic_hex2num(*hex++);
if (a < 0) {
return -1;
}
b = hgic_hex2num(*hex++);
if (b < 0) {
return -1;
}
return (a << 4) | b;
}
int hgic_pick_macaddr(char *mac_str, u8 *addr)
{
int i = 0;
int val = 0;
const char *ptr = (const char *)mac_str;
char tmp[20];
char *ptr = tmp;
char *p = tmp;
memset(addr, 0, 6);
while (ptr && i < 6 && strlen(mac_str) >= 17) {
if (i < 5 && ptr[2] != ':') { break; }
val = hgic_hex2byte(ptr);
if (val < 0) { break; }
addr[i++] = (u8)val;
ptr += 3;
memcpy(tmp, mac_str, 17);
while (ptr && *ptr && i < 6) {
p = strchr(ptr, ':');
if(p) *p++ = 0;
addr[i++] = hgic_hex2byte(ptr);
ptr = p;
}
return (i == 6);
}
void hgic_strip_tail(char *str, u32 len)
{
u32 i = len - 1;
while (str[i] == '\r' || str[i] == '\n') {
str[i--] = 0;
}
}
#if defined(__RTOS__) && defined(HGIC_SMAC)
int umac_config_read(const char *name, char *buff, int size)
{
int ret = 0;
struct umac_config *cfg = sys_get_umaccfg();
struct hgics_config *cfg = sys_get_umaccfg();
struct net_device *ndev = net_device_get_by_name(name);
if (ndev == NULL) {
@ -246,7 +239,7 @@ int umac_config_read(const char *name, char *buff, int size)
int umac_config_write(const char *name, char *buff, int size)
{
int ret = 0;
struct umac_config *cfg = sys_get_umaccfg();
struct hgics_config *cfg = sys_get_umaccfg();
struct net_device *ndev = net_device_get_by_name(name);
PRINTF("write %s:\r\n%s\r\n", name, buff);

View file

@ -165,7 +165,7 @@ struct hgic_fwstat {
};
char *hgic_fwstat_print(u8 *stat_buf);
int hgic_skip_padding(struct sk_buff *skb);
int hgic_skip_padding(u8 *data);
int hgic_aligned_padding(struct sk_buff *skb);
void hgic_print_hex(char *buf, int len);
int hgic_config_read_u32_array(char *conf, char *field, u32 *arr, int count);
@ -174,6 +174,8 @@ int hgic_config_read_str(char *conf, char *field, char *str, int size);
int hgic_config_read_int(char *conf, char *field);
void hgic_clear_queue(struct sk_buff_head *q);
int hgic_hex2num(char c);
void hgic_strip_tail(char *str, u32 len);
int hgic_hex2byte(const char *hex);
int hgic_pick_macaddr(char *mac_str, u8 *addr);

View file

@ -1 +1 @@
#define SVN_VERSION "14988"
#define SVN_VERSION "24338"