1
0
Fork 0

staging: wilc1000: Add SDIO/SPI 802.11 driver

This driver is for the wilc1000 which is a single chip IEEE 802.11
b/g/n device.
The driver works together with cfg80211, which is the kernel side of
configuration management for wireless devices because the wilc1000
chipset is fullmac where the MLME is managed in hardware.

The driver worked from kernel version 2.6.38 and being now ported
to several others since then.
A TODO file is included as well in this commit.

Signed-off-by: Johnny Kim <johnny.kim@atmel.com>
Signed-off-by: Rachel Kim <rachel.kim@atmel.com>
Signed-off-by: Dean Lee <dean.lee@atmel.com>
Signed-off-by: Chris Park <chris.park@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Johnny Kim 2015-05-11 14:30:56 +09:00 committed by Greg Kroah-Hartman
parent 7d98c63edc
commit c5c77ba18e
56 changed files with 33704 additions and 0 deletions

View File

@ -110,4 +110,6 @@ source "drivers/staging/fbtft/Kconfig"
source "drivers/staging/fsl-mc/Kconfig"
source "drivers/staging/wilc1000/Kconfig"
endif # STAGING

View File

@ -47,3 +47,4 @@ obj-$(CONFIG_UNISYSSPAR) += unisys/
obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
obj-$(CONFIG_FB_TFT) += fbtft/
obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
obj-$(CONFIG_WILC1000) += wilc1000/

View File

@ -0,0 +1,55 @@
config WILC1000
tristate "WILC1000 support (WiFi only)"
---help---
This module only support IEEE 802.11n WiFi.
choice
prompt "Memory Allocation"
depends on WILC1000
default WILC1000_PREALLOCATE_AT_LOADING_DRIVER
config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
bool "Preallocate memory at loading driver"
---help---
This choice supports static allocation of the memory
for the receive buffer. The driver will allocate the RX buffer
during initial time. The driver will also free the buffer
by calling network device stop.
config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
bool "Dynamically allocate memory in real time"
---help---
This choice supports dynamic allocation of the memory
for the receive buffer. The driver will allocate the RX buffer
when it is required.
endchoice
choice
prompt "Bus Type"
depends on WILC1000
default WILC1000_SDIO
config WILC1000_SDIO
bool "SDIO support"
depends on MMC
---help---
This module adds support for the SDIO interface of adapters using
WILC chipset. Select this if your platform is using the SDIO bus.
config WILC1000_SPI
bool "SPI support"
---help---
This module adds support for the SPI interface of adapters using
WILC chipset. Select this if your platform is using the SPI bus.
endchoice
config WILC1000_HW_OOB_INTR
bool "Use out of band interrupt"
depends on WILC1000 && WILC1000_SDIO
default n
---help---
If your platform don't recognize SDIO IRQ, connect chipset external IRQ pin
and check this option. Or, Use this to get all interrupts including SDIO interrupts.

View File

@ -0,0 +1,41 @@
obj-$(CONFIG_WILC1000) += wilc1000.o
obj-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += wilc_exported_buf.o
ccflags-$(CONFIG_WILC1000_SDIO) += -DWILC_SDIO -DCOMPLEMENT_BOOT
ccflags-$(CONFIG_WILC1000_HW_OOB_INTR) += -DWILC_SDIO_IRQ_GPIO
ccflags-$(CONFIG_WILC1000_SPI) += -DWILC_SPI
ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \
-DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \
-DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\"
ccflags-y += -I$(src)/ -DEXPORT_SYMTAB -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \
-DPLL_WORKAROUND -DCONNECT_DIRECT -DAGING_ALG \
-DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \
-DWILC_PLATFORM=WILC_LINUXKERNEL -Wno-unused-function -DUSE_WIRELESS \
-DWILC_DEBUGFS
#ccflags-y += -DTCP_ACK_FILTER
ccflags-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += -DMEMORY_STATIC \
-DWILC_PREALLOC_AT_BOOT
ccflags-$(CONFIG_WILC1000_PREALLOCATE_AT_LOADING_DRIVER) += -DMEMORY_STATIC \
-DWILC_PREALLOC_AT_INSMOD
ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC
wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \
wilc_thread.o wilc_time.o wilc_timer.o coreconfigurator.o host_interface.o \
fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o
wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o
wilc1000-$(CONFIG_WILC1000_SPI) += linux_wlan_spi.o
WILC1000_SRC_VERSION = 10.0
PATCHLEVEL = 2
WILC1000_FW_VERSION = 0
ccflags-y += -D__DRIVER_VERSION__=\"$(WILC1000_SRC_VERSION).$(PATCHLEVEL)\"

View File

@ -0,0 +1,8 @@
TODO:
- remove the defined feature as kernel versions
- remove OS wrapper functions
- remove custom debug and tracing functions
- rework comments and function headers(also coding style)
- remove build warnings
- support soft-ap and p2p mode
- support resume/suspend function

View File

@ -0,0 +1,20 @@
/*!
* @file coreconfigsimulator.h
* @brief
* @author
* @sa coreconfigsimulator.c
* @date 1 Mar 2012
* @version 1.0
*/
#ifndef CORECONFIGSIMULATOR_H
#define CORECONFIGSIMULATOR_H
extern WILC_Sint32 CoreConfigSimulatorInit (void);
extern WILC_Sint32 CoreConfigSimulatorDeInit (void);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,498 @@
/*!
* @file coreconfigurator.h
* @brief
* @author
* @sa coreconfigurator.c
* @date 1 Mar 2012
* @version 1.0
*/
#ifndef CORECONFIGURATOR_H
#define CORECONFIGURATOR_H
#include "wilc_oswrapper.h"
#include "wilc_wlan_if.h"
/*****************************************************************************/
/* Constants */
/*****************************************************************************/
/* Number of WID Options Supported */
#define NUM_BASIC_SWITCHES 45
#define NUM_FHSS_SWITCHES 0
#define NUM_RSSI 5
#ifdef MAC_802_11N
#define NUM_11N_BASIC_SWITCHES 25
#define NUM_11N_HUT_SWITCHES 47
#else /* MAC_802_11N */
#define NUM_11N_BASIC_SWITCHES 0
#define NUM_11N_HUT_SWITCHES 0
#endif /* MAC_802_11N */
extern WILC_Uint16 g_num_total_switches;
#define MAC_HDR_LEN 24 /* No Address4 - non-ESS */
#define MAX_SSID_LEN 33
#define FCS_LEN 4
#define TIME_STAMP_LEN 8
#define BEACON_INTERVAL_LEN 2
#define CAP_INFO_LEN 2
#define STATUS_CODE_LEN 2
#define AID_LEN 2
#define IE_HDR_LEN 2
/* Operating Mode: SET */
#define SET_CFG 0
/* Operating Mode: GET */
#define GET_CFG 1
#define MAX_PACKET_BUFF_SIZE 1596
#define MAX_STRING_LEN 256
#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN
#define SURVEY_RESULT_LENGTH 44
#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN
#define STATUS_MSG_LEN 12
#define MAC_CONNECTED 1
#define MAC_DISCONNECTED 0
/*****************************************************************************/
/* Function Macros */
/*****************************************************************************/
#define MAKE_WORD16(lsb, msb) ((((WILC_Uint16)(msb) << 8) & 0xFF00) | (lsb))
#define MAKE_WORD32(lsw, msw) ((((WILC_Uint32)(msw) << 16) & 0xFFFF0000) | (lsw))
/*****************************************************************************/
/* Type Definitions */
/*****************************************************************************/
/* WID Data Types */
#if 0
typedef enum {
WID_CHAR = 0,
WID_SHORT = 1,
WID_INT = 2,
WID_STR = 3,
WID_ADR = 4,
WID_BIN = 5,
WID_IP = 6,
WID_UNDEF = 7,
WID_TYPE_FORCE_32BIT = 0xFFFFFFFF
} tenuWIDtype;
/* WLAN Identifiers */
typedef enum {
WID_NIL = -1,
/* EMAC Character WID list */
WID_BSS_TYPE = 0x0000,
WID_CURRENT_TX_RATE = 0x0001,
WID_CURRENT_CHANNEL = 0x0002,
WID_PREAMBLE = 0x0003,
WID_11G_OPERATING_MODE = 0x0004,
WID_STATUS = 0x0005,
WID_11G_PROT_MECH = 0x0006,
WID_SCAN_TYPE = 0x0007,
WID_PRIVACY_INVOKED = 0x0008,
WID_KEY_ID = 0x0009,
WID_QOS_ENABLE = 0x000A,
WID_POWER_MANAGEMENT = 0x000B,
WID_11I_MODE = 0x000C,
WID_AUTH_TYPE = 0x000D,
WID_SITE_SURVEY = 0x000E,
WID_LISTEN_INTERVAL = 0x000F,
WID_DTIM_PERIOD = 0x0010,
WID_ACK_POLICY = 0x0011,
WID_RESET = 0x0012,
WID_PCF_MODE = 0x0013,
WID_CFP_PERIOD = 0x0014,
WID_BCAST_SSID = 0x0015,
WID_PHY_TEST_PATTERN = 0x0016,
WID_DISCONNECT = 0x0016,
WID_READ_ADDR_SDRAM = 0x0017,
WID_TX_POWER_LEVEL_11A = 0x0018,
WID_REKEY_POLICY = 0x0019,
WID_SHORT_SLOT_ALLOWED = 0x001A,
WID_PHY_ACTIVE_REG = 0x001B,
WID_PHY_ACTIVE_REG_VAL = 0x001C,
WID_TX_POWER_LEVEL_11B = 0x001D,
WID_START_SCAN_REQ = 0x001E,
WID_RSSI = 0x001F,
WID_JOIN_REQ = 0x0020,
WID_ANTENNA_SELECTION = 0x0021,
WID_USER_CONTROL_ON_TX_POWER = 0x0027,
WID_MEMORY_ACCESS_8BIT = 0x0029,
WID_UAPSD_SUPPORT_AP = 0x002A,
WID_CURRENT_MAC_STATUS = 0x0031,
WID_AUTO_RX_SENSITIVITY = 0x0032,
WID_DATAFLOW_CONTROL = 0x0033,
WID_SCAN_FILTER = 0x0036,
WID_LINK_LOSS_THRESHOLD = 0x0037,
WID_AUTORATE_TYPE = 0x0038,
WID_CCA_THRESHOLD = 0x0039,
WID_802_11H_DFS_MODE = 0x003B,
WID_802_11H_TPC_MODE = 0x003C,
WID_DEVICE_READY = 0x003D,
WID_PM_NULL_FRAME_INTERVAL = 0x003E,
WID_PM_ACTIVITY_TIMER = 0x003F,
WID_PM_NULL_FRAME_WAIT_ENABLE = 0x0040,
WID_SCAN_WAIT_TIME = 0x0041,
WID_WSC_IE_EN = 0x0042,
WID_WPS_START = 0x0043,
WID_WPS_DEV_MODE = 0x0044,
WID_BT_COEXISTENCE = 0x0050,
WID_TRACKING_ROAMING = 0x0070,
WID_NUM_PKTS_FOR_RSSI_AVG = 0x0071,
WID_FHSS_SCAN_CHAN_INDEX = 0x0072,
WID_FHSS_SCAN_STEP_INDEX = 0x0073,
/* NMAC Character WID list */
WID_11N_PROT_MECH = 0x0080,
WID_11N_ERP_PROT_TYPE = 0x0081,
WID_11N_ENABLE = 0x0082,
WID_11N_OPERATING_MODE = 0x0083,
WID_11N_OBSS_NONHT_DETECTION = 0x0084,
WID_11N_HT_PROT_TYPE = 0x0085,
WID_11N_RIFS_PROT_ENABLE = 0x0086,
WID_11N_SMPS_MODE = 0x0087,
WID_11N_CURRENT_TX_MCS = 0x0088,
WID_11N_PRINT_STATS = 0x0089,
WID_HUT_FCS_CORRUPT_MODE = 0x008A,
WID_HUT_RESTART = 0x008B,
WID_HUT_TX_FORMAT = 0x008C,
WID_11N_SHORT_GI_20MHZ_ENABLE = 0x008D,
WID_HUT_BANDWIDTH = 0x008E,
WID_HUT_OP_BAND = 0x008F,
WID_HUT_STBC = 0x0090,
WID_HUT_ESS = 0x0091,
WID_HUT_ANTSET = 0x0092,
WID_HUT_HT_OP_MODE = 0x0093,
WID_HUT_RIFS_MODE = 0x0094,
WID_HUT_SMOOTHING_REC = 0x0095,
WID_HUT_SOUNDING_PKT = 0x0096,
WID_HUT_HT_CODING = 0x0097,
WID_HUT_TEST_DIR = 0x0098,
WID_HUT_CAPTURE_MODE = 0x0099,
WID_HUT_PHY_TEST_MODE = 0x009A,
WID_HUT_PHY_TEST_RATE_HI = 0x009B,
WID_HUT_PHY_TEST_RATE_LO = 0x009C,
WID_HUT_DISABLE_RXQ_REPLENISH = 0x009D,
WID_HUT_KEY_ORIGIN = 0x009E,
WID_HUT_BCST_PERCENT = 0x009F,
WID_HUT_GROUP_CIPHER_TYPE = 0x00A0,
WID_TX_ABORT_CONFIG = 0x00A1,
WID_HOST_DATA_IF_TYPE = 0x00A2,
WID_HOST_CONFIG_IF_TYPE = 0x00A3,
WID_HUT_TSF_TEST_MODE = 0x00A4,
WID_HUT_TSSI_VALUE = 0x00A5,
WID_HUT_PKT_TSSI_VALUE = 0x00A5,
WID_REG_TSSI_11B_VALUE = 0x00A6,
WID_REG_TSSI_11G_VALUE = 0x00A7,
WID_REG_TSSI_11N_VALUE = 0x00A8,
WID_TX_CALIBRATION = 0x00A9,
WID_DSCR_TSSI_11B_VALUE = 0x00AA,
WID_DSCR_TSSI_11G_VALUE = 0x00AB,
WID_DSCR_TSSI_11N_VALUE = 0x00AC,
WID_HUT_RSSI_EX = 0x00AD,
WID_HUT_ADJ_RSSI_EX = 0x00AE,
WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF,
WID_11N_TXOP_PROT_DISABLE = 0x00B0,
WID_TX_POWER_LEVEL_11N = 0x00B1,
WID_HUT_MGMT_PERCENT = 0x00B3,
WID_HUT_MGMT_BCST_PERCENT = 0x00B4,
WID_HUT_MGMT_ALLOW_HT = 0x00B5,
WID_HUT_UC_MGMT_TYPE = 0x00B6,
WID_HUT_BC_MGMT_TYPE = 0x00B7,
WID_HUT_11W_MFP_REQUIRED_TX = 0x00B8,
WID_HUT_11W_MFP_PEER_CAPABLE = 0x00B9,
WID_HUT_11W_TX_IGTK_ID = 0x00BA,
WID_11W_ENABLE = 0x00BB,
WID_11W_MGMT_PROT_REQ = 0x00BC,
WID_USER_SEC_CHANNEL_OFFSET = 0x00C0,
WID_2040_COEXISTENCE = 0x00C1,
WID_HUT_FC_TXOP_MOD = 0x00C2,
WID_HUT_FC_PROT_TYPE = 0x00C3,
WID_HUT_SEC_CCA_ASSERT = 0x00C4,
WID_2040_ENABLE = 0x00C5,
WID_2040_CURR_CHANNEL_OFFSET = 0x00C6,
WID_2040_40MHZ_INTOLERANT = 0x00C7,
/* Custom Character WID list */
WID_POWER_SAVE = 0x0100,
WID_WAKE_STATUS = 0x0101,
WID_WAKE_CONTROL = 0x0102,
WID_CCA_BUSY_START = 0x0103,
/* EMAC Short WID list */
WID_RTS_THRESHOLD = 0x1000,
WID_FRAG_THRESHOLD = 0x1001,
WID_SHORT_RETRY_LIMIT = 0x1002,
WID_LONG_RETRY_LIMIT = 0x1003,
WID_CFP_MAX_DUR = 0x1004,
WID_PHY_TEST_FRAME_LEN = 0x1005,
WID_BEACON_INTERVAL = 0x1006,
WID_MEMORY_ACCESS_16BIT = 0x1008,
WID_RX_SENSE = 0x100B,
WID_ACTIVE_SCAN_TIME = 0x100C,
WID_PASSIVE_SCAN_TIME = 0x100D,
WID_SITE_SURVEY_SCAN_TIME = 0x100E,
WID_JOIN_START_TIMEOUT = 0x100F,
WID_AUTH_TIMEOUT = 0x1010,
WID_ASOC_TIMEOUT = 0x1011,
WID_11I_PROTOCOL_TIMEOUT = 0x1012,
WID_EAPOL_RESPONSE_TIMEOUT = 0x1013,
WID_WPS_PASS_ID = 0x1017,
WID_WPS_CONFIG_METHOD = 0x1018,
WID_FHSS_INIT_SCAN_TIME = 0x1070,
WID_FHSS_ROAM_SCAN_TIME = 0x1071,
/* NMAC Short WID list */
WID_11N_RF_REG_VAL = 0x1080,
WID_HUT_FRAME_LEN = 0x1081,
WID_HUT_TXOP_LIMIT = 0x1082,
WID_HUT_SIG_QUAL_AVG = 0x1083,
WID_HUT_SIG_QUAL_AVG_CNT = 0x1084,
WID_11N_SIG_QUAL_VAL = 0x1085,
WID_HUT_RSSI_EX_COUNT = 0x1086,
WID_HUT_UC_MGMT_FRAME_LEN = 0x1088,
WID_HUT_BC_MGMT_FRAME_LEN = 0x1089,
/* Custom Short WID list */
WID_CCA_BUSY_STATUS = 0x1100,
/* EMAC Integer WID list */
WID_FAILED_COUNT = 0x2000,
WID_RETRY_COUNT = 0x2001,
WID_MULTIPLE_RETRY_COUNT = 0x2002,
WID_FRAME_DUPLICATE_COUNT = 0x2003,
WID_ACK_FAILURE_COUNT = 0x2004,
WID_RECEIVED_FRAGMENT_COUNT = 0x2005,
WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006,
WID_FCS_ERROR_COUNT = 0x2007,
WID_SUCCESS_FRAME_COUNT = 0x2008,
WID_PHY_TEST_PKT_CNT = 0x2009,
WID_HUT_TX_COUNT = 0x200A,
WID_TX_FRAGMENT_COUNT = 0x200B,
WID_TX_MULTICAST_FRAME_COUNT = 0x200C,
WID_RTS_SUCCESS_COUNT = 0x200D,
WID_RTS_FAILURE_COUNT = 0x200E,
WID_WEP_UNDECRYPTABLE_COUNT = 0x200F,
WID_REKEY_PERIOD = 0x2010,
WID_REKEY_PACKET_COUNT = 0x2011,
WID_1X_SERV_ADDR = 0x2012,
WID_STACK_IP_ADDR = 0x2013,
WID_STACK_NETMASK_ADDR = 0x2014,
WID_HW_RX_COUNT = 0x2015,
WID_MEMORY_ADDRESS = 0x201E,
WID_MEMORY_ACCESS_32BIT = 0x201F,
WID_RF_REG_VAL = 0x2021,
WID_FIRMWARE_INFO = 0x2023,
WID_DEV_OS_VERSION = 0x2025,
WID_ROAM_RSSI_THESHOLDS = 0x2070,
WID_TRACK_INTERVAL_SEC = 0x2071,
WID_FHSS_HOPPING_PARAMS = 0x2072,
WID_FHSS_HOP_DWELL_TIME = 0x2073,
/* NMAC Integer WID list */
WID_11N_PHY_ACTIVE_REG_VAL = 0x2080,
WID_HUT_NUM_TX_PKTS = 0x2081,
WID_HUT_TX_TIME_TAKEN = 0x2082,
WID_HUT_TX_TEST_TIME = 0x2083,
WID_HUT_LOG_INTERVAL = 0x2084,
/* EMAC String WID list */
WID_SSID = 0x3000,
WID_FIRMWARE_VERSION = 0x3001,
WID_OPERATIONAL_RATE_SET = 0x3002,
WID_BSSID = 0x3003,
#if 0
WID_WEP_KEY_VALUE0 = 0x3004,
#endif
WID_11I_PSK = 0x3008,
WID_11E_P_ACTION_REQ = 0x3009,
WID_1X_KEY = 0x300A,
WID_HARDWARE_VERSION = 0x300B,
WID_MAC_ADDR = 0x300C,
WID_HUT_DEST_ADDR = 0x300D,
/*WID_HUT_STATS = 0x300E,*/
WID_PHY_VERSION = 0x300F,
WID_SUPP_USERNAME = 0x3010,
WID_SUPP_PASSWORD = 0x3011,
WID_SITE_SURVEY_RESULTS = 0x3012,
WID_RX_POWER_LEVEL = 0x3013,
WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */
WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */
WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */
WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */
WID_ASSOC_RES_INFO = 0x3020,
/* NMAC String WID list */
WID_11N_P_ACTION_REQ = 0x3080,
WID_HUT_TEST_ID = 0x3081,
WID_PMKID_INFO = 0x3082,
/* Custom String WID list */
WID_FLASH_DATA = 0x3100,
WID_EEPROM_DATA = 0x3101,
WID_SERIAL_NUMBER = 0x3102,
/* EMAC Binary WID list */
WID_UAPSD_CONFIG = 0x4001,
WID_UAPSD_STATUS = 0x4002,
WID_AC_PARAMS_AP = 0x4003,
WID_AC_PARAMS_STA = 0x4004,
WID_NEWORK_INFO = 0x4005,
WID_WPS_CRED_LIST = 0x4006,
WID_PRIM_DEV_TYPE = 0x4007,
WID_STA_JOIN_INFO = 0x4008,
WID_CONNECTED_STA_LIST = 0x4009,
/* NMAC Binary WID list */
WID_11N_AUTORATE_TABLE = 0x4080,
WID_HUT_TX_PATTERN = 0x4081,
WID_HUT_STATS = 0x4082,
WID_HUT_LOG_STATS = 0x4083,
/*BugID_3746 WID to add IE to be added in next probe request*/
WID_INFO_ELEMENT_PROBE = 0x4085,
/*BugID_3746 WID to add IE to be added in next associate request*/
WID_INFO_ELEMENT_ASSOCIATE = 0x4086,
/* Miscellaneous WIDs */
WID_ALL = 0x7FFE,
WID_MAX = 0xFFFF
} tenuWIDid;
#endif
/* Status Codes for Authentication and Association Frames */
typedef enum {
SUCCESSFUL_STATUSCODE = 0,
UNSPEC_FAIL = 1,
UNSUP_CAP = 10,
REASOC_NO_ASOC = 11,
FAIL_OTHER = 12,
UNSUPT_ALG = 13,
AUTH_SEQ_FAIL = 14,
CHLNG_FAIL = 15,
AUTH_TIMEOUT = 16,
AP_FULL = 17,
UNSUP_RATE = 18,
SHORT_PREAMBLE_UNSUP = 19,
PBCC_UNSUP = 20,
CHANNEL_AGIL_UNSUP = 21,
SHORT_SLOT_UNSUP = 25,
OFDM_DSSS_UNSUP = 26,
CONNECT_STS_FORCE_16_BIT = 0xFFFF
} tenuConnectSts;
typedef struct {
WILC_Uint16 u16WIDid;
tenuWIDtype enuWIDtype;
WILC_Sint32 s32ValueSize;
WILC_Sint8 *ps8WidVal;
} tstrWID;
typedef struct {
WILC_Uint8 u8Full;
WILC_Uint8 u8Index;
WILC_Sint8 as8RSSI[NUM_RSSI];
} tstrRSSI;
/* This structure is used to support parsing of the received 'N' message */
typedef struct {
WILC_Sint8 s8rssi;
WILC_Uint16 u16CapInfo;
WILC_Uint8 au8ssid[MAX_SSID_LEN];
WILC_Uint8 u8SsidLen;
WILC_Uint8 au8bssid[6];
WILC_Uint16 u16BeaconPeriod;
WILC_Uint8 u8DtimPeriod;
WILC_Uint8 u8channel;
unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */
unsigned long u32TimeRcvdInScan;
WILC_Bool bNewNetwork;
#ifdef AGING_ALG
WILC_Uint8 u8Found;
#endif
#ifdef WILC_P2P
WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */
#endif
WILC_Uint8 *pu8IEs;
WILC_Uint16 u16IEsLen;
void *pJoinParams;
tstrRSSI strRssi;
WILC_Uint64 u64Tsf; /* time-stamp [Low and High 64 bit] */
} tstrNetworkInfo;
/* This structure is used to support parsing of the received Association Response frame */
typedef struct {
WILC_Uint16 u16capability;
WILC_Uint16 u16ConnectStatus;
WILC_Uint16 u16AssocID;
WILC_Uint8 *pu8RespIEs;
WILC_Uint16 u16RespIEsLen;
} tstrConnectRespInfo;
typedef struct {
WILC_Uint8 au8bssid[6];
WILC_Uint8 *pu8ReqIEs;
size_t ReqIEsLen;
WILC_Uint8 *pu8RespIEs;
WILC_Uint16 u16RespIEsLen;
WILC_Uint16 u16ConnectStatus;
} tstrConnectInfo;
typedef struct {
WILC_Uint16 u16reason;
WILC_Uint8 *ie;
size_t ie_len;
} tstrDisconnectNotifInfo;
#ifndef CONNECT_DIRECT
typedef struct wid_site_survey_reslts {
WILC_Char SSID[MAX_SSID_LEN];
WILC_Uint8 BssType;
WILC_Uint8 Channel;
WILC_Uint8 SecurityStatus;
WILC_Uint8 BSSID[6];
WILC_Char RxPower;
WILC_Uint8 Reserved;
} wid_site_survey_reslts_s;
#endif
extern WILC_Sint32 CoreConfiguratorInit(void);
extern WILC_Sint32 CoreConfiguratorDeInit(void);
extern WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs,
WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler);
extern WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo);
extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo);
extern WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen,
tstrConnectRespInfo **ppstrConnectRespInfo);
extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo);
#ifndef CONNECT_DIRECT
extern WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount);
extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults);
#endif
extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen);
extern void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length);
void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length);
void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length);
#endif

View File

@ -0,0 +1,142 @@
#include "wilc_oswrapper.h"
#include "fifo_buffer.h"
WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength)
{
WILC_Uint32 u32Error = 0;
tstrFifoHandler *pstrFifoHandler = WILC_MALLOC (sizeof (tstrFifoHandler));
if (pstrFifoHandler) {
WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler));
pstrFifoHandler->pu8Buffer = WILC_MALLOC (u32BufferLength);
if (pstrFifoHandler->pu8Buffer) {
tstrWILC_SemaphoreAttrs strSemBufferAttrs;
pstrFifoHandler->u32BufferLength = u32BufferLength;
WILC_memset (pstrFifoHandler->pu8Buffer, 0, u32BufferLength);
/* create semaphore */
WILC_SemaphoreFillDefault (&strSemBufferAttrs);
strSemBufferAttrs.u32InitCount = 1;
WILC_SemaphoreCreate(&pstrFifoHandler->SemBuffer, &strSemBufferAttrs);
*hBuffer = pstrFifoHandler;
} else {
*hBuffer = NULL;
u32Error = 1;
}
} else {
u32Error = 1;
}
return u32Error;
}
WILC_Uint32 FIFO_DeInit(tHANDLE hFifo)
{
WILC_Uint32 u32Error = 0;
tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
if (pstrFifoHandler) {
if (pstrFifoHandler->pu8Buffer) {
WILC_FREE (pstrFifoHandler->pu8Buffer);
} else {
u32Error = 1;
}
WILC_SemaphoreDestroy (&pstrFifoHandler->SemBuffer, WILC_NULL);
WILC_FREE (pstrFifoHandler);
} else {
u32Error = 1;
}
return u32Error;
}
WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead)
{
WILC_Uint32 u32Error = 0;
tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
if (pstrFifoHandler && pu32BytesRead) {
if (pstrFifoHandler->u32TotalBytes) {
if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) {
if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) {
*pu32BytesRead = pstrFifoHandler->u32TotalBytes;
} else {
*pu32BytesRead = u32BytesToRead;
}
if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) {
WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset,
*pu32BytesRead);
/* update read offset and total bytes */
pstrFifoHandler->u32ReadOffset += u32BytesToRead;
pstrFifoHandler->u32TotalBytes -= u32BytesToRead;
} else {
WILC_Uint32 u32FirstPart =
pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset;
WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset,
u32FirstPart);
WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer,
u32BytesToRead - u32FirstPart);
/* update read offset and total bytes */
pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart;
pstrFifoHandler->u32TotalBytes -= u32BytesToRead;
}
WILC_SemaphoreRelease (&pstrFifoHandler->SemBuffer, WILC_NULL);
} else {
u32Error = 1;
}
} else {
u32Error = 1;
}
} else {
u32Error = 1;
}
return u32Error;
}
WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite)
{
WILC_Uint32 u32Error = 0;
tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
if (pstrFifoHandler) {
if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) {
if ((pstrFifoHandler->u32TotalBytes + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength ||
bForceOverWrite) {
if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) {
if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) {
WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer,
u32BytesToWrite);
/* update read offset and total bytes */
pstrFifoHandler->u32WriteOffset += u32BytesToWrite;
pstrFifoHandler->u32TotalBytes += u32BytesToWrite;
} else {
WILC_Uint32 u32FirstPart =
pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset;
WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer,
u32FirstPart);
WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart,
u32BytesToWrite - u32FirstPart);
/* update read offset and total bytes */
pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart;
pstrFifoHandler->u32TotalBytes += u32BytesToWrite;
}
/* if data overwriten */
if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) {
/* adjust read offset to the oldest data available */
pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset;
/* data availabe is the buffer length */
pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength;
}
WILC_SemaphoreRelease(&pstrFifoHandler->SemBuffer, WILC_NULL);
}
} else {
u32Error = 1;
}
} else {
u32Error = 1;
}
} else {
u32Error = 1;
}
return u32Error;
}

View File

@ -0,0 +1,23 @@
#include "wilc_oswrapper.h"
#define tHANDLE void *
typedef struct {
WILC_Uint8 *pu8Buffer;
WILC_Uint32 u32BufferLength;
WILC_Uint32 u32WriteOffset;
WILC_Uint32 u32ReadOffset;
WILC_Uint32 u32TotalBytes;
WILC_SemaphoreHandle SemBuffer;
} tstrFifoHandler;
extern WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer,
WILC_Uint32 u32BufferLength);
extern WILC_Uint32 FIFO_DeInit(tHANDLE hFifo);
extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer,
WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead);
extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer,
WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
/*****************************************************************************/
/* */
/* Ittiam 802.11 MAC SOFTWARE */
/* */
/* ITTIAM SYSTEMS PVT LTD, BANGALORE */
/* COPYRIGHT(C) 2005 */
/* */
/* This program is proprietary to Ittiam Systems Private Limited and */
/* is protected under Indian Copyright Law as an unpublished work. Its use */
/* and disclosure is limited by the terms and conditions of a license */
/* agreement. It may not be copied or otherwise reproduced or disclosed to */
/* persons outside the licensee's organization except in accordance with the*/
/* terms and conditions of such an agreement. All copies and */
/* reproductions shall be the property of Ittiam Systems Private Limited and*/
/* must bear this notice in its entirety. */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* */
/* File Name : itypes.h */
/* */
/* Description : This file contains all the data type definitions for */
/* MAC implementation. */
/* */
/* List of Functions : None */
/* Issues / Problems : None */
/* */
/* Revision History : */
/* */
/* DD MM YYYY Author(s) Changes */
/* 01 05 2005 Ittiam Draft */
/* */
/*****************************************************************************/
#ifndef ITYPES_H
#define ITYPES_H
/*****************************************************************************/
/* Data Types */
/*****************************************************************************/
typedef int WORD32;
typedef short WORD16;
typedef char WORD8;
typedef unsigned int UWORD32;
typedef unsigned short UWORD16;
typedef unsigned char UWORD8;
/*****************************************************************************/
/* Enums */
/*****************************************************************************/
typedef enum {
BFALSE = 0,
BTRUE = 1
} BOOL_T;
#endif /* ITYPES_H */

View File

@ -0,0 +1,643 @@
/*!
* @file linux_mon.c
* @brief File Operations OS wrapper functionality
* @author mdaftedar
* @sa wilc_wfi_netdevice.h
* @date 01 MAR 2012
* @version 1.0
*/
#ifndef SIMULATION
#include "wilc_wfi_cfgoperations.h"
#include "linux_wlan_common.h"
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
#endif
#ifdef WILC_FULLY_HOSTING_AP
#include "wilc_host_ap.h"
#endif
#ifdef WILC_AP_EXTERNAL_MLME
#ifdef SIMULATION
#include "wilc_wfi_cfgoperations.h"
#endif
struct wilc_wfi_radiotap_hdr {
struct ieee80211_radiotap_header hdr;
u8 rate;
/* u32 channel; */
} __attribute__((packed));
struct wilc_wfi_radiotap_cb_hdr {
struct ieee80211_radiotap_header hdr;
u8 rate;
u8 dump;
u16 tx_flags;
/* u32 channel; */
} __attribute__((packed));
extern linux_wlan_t *g_linux_wlan;
static struct net_device *wilc_wfi_mon; /* global monitor netdev */
#ifdef SIMULATION
extern int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev);
#elif USE_WIRELESS
extern int mac_xmit(struct sk_buff *skb, struct net_device *dev);
#endif
WILC_Uint8 srcAdd[6];
WILC_Uint8 bssid[6];
WILC_Uint8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/**
* @brief WILC_WFI_monitor_rx
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive*/
#define IS_MANAGMEMENT 0x100
#define IS_MANAGMEMENT_CALLBACK 0x080
#define IS_MGMT_STATUS_SUCCES 0x040
#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size)
{
uint32_t header, pkt_offset;
struct sk_buff *skb = NULL;
struct wilc_wfi_radiotap_hdr *hdr;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n");
/* struct WILC_WFI_priv *priv = netdev_priv(dev); */
/* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
/* Bug 4601 */
if (wilc_wfi_mon == NULL)
return;
if (!netif_running(wilc_wfi_mon)) {
PRINT_INFO(HOSTAPD_DBG, "Monitor interface already RUNNING\n");
return;
}
/* Get WILC header */
memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
/* The packet offset field conain info about what type of managment frame */
/* we are dealing with and ack status */
pkt_offset = GET_PKT_OFFSET(header);
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
/* hostapd callback mgmt frame */
skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr));
if (skb == NULL) {
PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb");
return;
}
memcpy(skb_put(skb, size), buff, size);
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr));
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_present = cpu_to_le32(
(1 << IEEE80211_RADIOTAP_RATE) |
(1 << IEEE80211_RADIOTAP_TX_FLAGS));
cb_hdr->rate = 5; /* txrate->bitrate / 5; */
if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
/* success */
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
} else {
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
}
} else {
skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr));
if (skb == NULL) {
PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb");
return;
}
/* skb = skb_copy_expand(tx_skb, sizeof(*hdr), 0, GFP_ATOMIC); */
/* if (skb == NULL) */
/* return; */
memcpy(skb_put(skb, size), buff, size);
hdr = (struct wilc_wfi_radiotap_hdr *) skb_push(skb, sizeof(*hdr));
memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
/* hdr->hdr.it_pad = 0; */
hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr));
PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len);
hdr->hdr.it_present = cpu_to_le32
(1 << IEEE80211_RADIOTAP_RATE); /* | */
/* (1 << IEEE80211_RADIOTAP_CHANNEL)); */
PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present);
hdr->rate = 5; /* txrate->bitrate / 5; */
}
/* if(INFO || if(skb->data[9] == 0x00 || skb->data[9] == 0xb0))
* {
* for(i=0;i<skb->len;i++)
* PRINT_INFO(HOSTAPD_DBG,"Mon RxData[%d] = %02x\n",i,skb->data[i]);
* }*/
skb->dev = wilc_wfi_mon;
skb_set_mac_header(skb, 0);
skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->pkt_type = PACKET_OTHERHOST;
skb->protocol = htons(ETH_P_802_2);
memset(skb->cb, 0, sizeof(skb->cb));
netif_rx(skb);
}
struct tx_complete_mon_data {
int size;
void *buff;
};
static void mgmt_tx_complete(void *priv, int status)
{
/* struct sk_buff *skb2; */
/* struct wilc_wfi_radiotap_cb_hdr *cb_hdr; */
struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv;
WILC_Uint8 *buf = pv_data->buff;
if (status == 1) {
if (INFO || buf[0] == 0x10 || buf[0] == 0xb0)
PRINT_INFO(HOSTAPD_DBG, "Packet sent successfully - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff);
} else {
PRINT_INFO(HOSTAPD_DBG, "Couldn't send packet - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff);
}
/* //(skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 )
* {
* skb2 = dev_alloc_skb(pv_data->size+sizeof(struct wilc_wfi_radiotap_cb_hdr));
*
* memcpy(skb_put(skb2,pv_data->size),pv_data->buff, pv_data->size);
*
* cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr));
* memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
*
* cb_hdr->hdr.it_version = 0;//PKTHDR_RADIOTAP_VERSION;
*
* cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
*
* cb_hdr->hdr.it_present = cpu_to_le32(
* (1 << IEEE80211_RADIOTAP_RATE) |
* (1 << IEEE80211_RADIOTAP_TX_FLAGS));
*
* cb_hdr->rate = 5;//txrate->bitrate / 5;
* cb_hdr->tx_flags = 0x0004;
*
* skb2->dev = wilc_wfi_mon;
* skb_set_mac_header(skb2, 0);
* skb2->ip_summed = CHECKSUM_UNNECESSARY;
* skb2->pkt_type = PACKET_OTHERHOST;
* skb2->protocol = htons(ETH_P_802_2);
* memset(skb2->cb, 0, sizeof(skb2->cb));
*
* netif_rx(skb2);
* }*/
/* incase of fully hosting mode, the freeing will be done in response to the cfg packet */
#ifndef WILC_FULLY_HOSTING_AP
kfree(pv_data->buff);
kfree(pv_data);
#endif
}
static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
{
linux_wlan_t *nic;
struct tx_complete_mon_data *mgmt_tx = NULL;
if (dev == NULL) {
PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n");
return WILC_FAIL;
}
nic = netdev_priv(dev);
netif_stop_queue(dev);
mgmt_tx = (struct tx_complete_mon_data *)kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC);
if (mgmt_tx == NULL) {
PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
return WILC_FAIL;
}
#ifdef WILC_FULLY_HOSTING_AP
/* add space for the pointer to tx_complete_mon_data */
len += sizeof(struct tx_complete_mon_data *);
#endif
mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC);
if (mgmt_tx->buff == NULL) {
PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
return WILC_FAIL;
}
mgmt_tx->size = len;
#ifndef WILC_FULLY_HOSTING_AP
memcpy(mgmt_tx->buff, buf, len);
#else
memcpy(mgmt_tx->buff, buf, len - sizeof(struct tx_complete_mon_data *));
memcpy((mgmt_tx->buff) + (len - sizeof(struct tx_complete_mon_data *)), &mgmt_tx, sizeof(struct tx_complete_mon_data *));
/* filter data frames to handle it's PS */
if (filter_monitor_data_frames((mgmt_tx->buff), len) == WILC_TRUE) {
return;
}
#endif /* WILC_FULLY_HOSTING_AP */
g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, mgmt_tx_complete);
netif_wake_queue(dev);
return 0;
}
/**
* @brief WILC_WFI_mon_xmit
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct ieee80211_radiotap_header *rtap_hdr;
WILC_Uint32 rtap_len, i, ret = 0;
struct WILC_WFI_mon_priv *mon_priv;
struct sk_buff *skb2;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
/* Bug 4601 */
if (wilc_wfi_mon == NULL)
return WILC_FAIL;
/* if(skb->data[3] == 0x10 || skb->data[3] == 0xb0) */
mon_priv = netdev_priv(wilc_wfi_mon);
if (mon_priv == NULL) {
PRINT_ER("Monitor interface private structure is NULL\n");
return WILC_FAIL;
}
rtap_hdr = (struct ieee80211_radiotap_header *)skb->data;
rtap_len = ieee80211_get_radiotap_len(skb->data);
if (skb->len < rtap_len) {
PRINT_ER("Error in radiotap header\n");
return -1;
}
/* skip the radiotap header */
PRINT_INFO(HOSTAPD_DBG, "Radiotap len: %d\n", rtap_len);
if (INFO) {
for (i = 0; i < rtap_len; i++)
PRINT_INFO(HOSTAPD_DBG, "Radiotap_hdr[%d] %02x\n", i, skb->data[i]);
}
/* Skip the ratio tap header */
skb_pull(skb, rtap_len);
if (skb->data[0] == 0xc0)
PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n", skb->data[4], skb->data[5], skb->data[6], skb->data[7], skb->data[8], skb->data[9]);
if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) {
skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr));
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_present = cpu_to_le32(
(1 << IEEE80211_RADIOTAP_RATE) |
(1 << IEEE80211_RADIOTAP_TX_FLAGS));
cb_hdr->rate = 5; /* txrate->bitrate / 5; */
cb_hdr->tx_flags = 0x0004;
skb2->dev = wilc_wfi_mon;
skb_set_mac_header(skb2, 0);
skb2->ip_summed = CHECKSUM_UNNECESSARY;
skb2->pkt_type = PACKET_OTHERHOST;
skb2->protocol = htons(ETH_P_802_2);
memset(skb2->cb, 0, sizeof(skb2->cb));
netif_rx(skb2);
return 0;
}
skb->dev = mon_priv->real_ndev;
PRINT_INFO(HOSTAPD_DBG, "Skipping the radiotap header\n");
/* actual deliver of data is device-specific, and not shown here */
PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name);
PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name);
#ifdef SIMULATION
ret = WILC_WFI_Tx(skb, mon_priv->real_ndev);
#elif USE_WIRELESS
/* Identify if Ethernet or MAC header (data or mgmt) */
memcpy(srcAdd, &skb->data[10], 6);
memcpy(bssid, &skb->data[16], 6);
/* if source address and bssid fields are equal>>Mac header */
/*send it to mgmt frames handler */
if (!(memcmp(srcAdd, bssid, 6))) {
mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
dev_kfree_skb(skb);
} else
ret = mac_xmit(skb, mon_priv->real_ndev);
#endif
/* return NETDEV_TX_OK; */
return ret;
}
static const struct net_device_ops wilc_wfi_netdev_ops = {
.ndo_start_xmit = WILC_WFI_mon_xmit,
};
#ifdef WILC_FULLY_HOSTING_AP
/*
* @brief WILC_mgm_HOSTAPD_ACK
* @details report the status of transmitted mgmt frames to HOSTAPD
* @param[in] priv : pointer to tx_complete_mon_data struct
* bStatus : status of transmission
* @author Abd Al-Rahman Diab
* @date 9 May 2013
* @version 1.0
*/
void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus)
{
struct sk_buff *skb;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv;
WILC_Uint8 *buf = pv_data->buff;
/* len of the original frame without the added pointer at the tail */
WILC_Uint16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *);
/*if(bStatus == 1){
* if(INFO || buf[0] == 0x10 || buf[0] == 0xb0)
* PRINT_D(HOSTAPD_DBG,"Packet sent successfully - Size = %d - Address = %p.\n",u16len,pv_data->buff);
* }else{
* PRINT_D(HOSTAPD_DBG,"Couldn't send packet - Size = %d - Address = %p.\n",u16len,pv_data->buff);
* }
*/
/* (skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) */
{
skb = dev_alloc_skb(u16len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
memcpy(skb_put(skb, u16len), pv_data->buff, u16len);
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr));
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
cb_hdr->hdr.it_present = cpu_to_le32(
(1 << IEEE80211_RADIOTAP_RATE) |
(1 << IEEE80211_RADIOTAP_TX_FLAGS));
cb_hdr->rate = 5; /* txrate->bitrate / 5; */
if (WILC_TRUE == bStatus) {
/* success */
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
} else {
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
}
skb->dev = wilc_wfi_mon;
skb_set_mac_header(skb, 0);
skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->pkt_type = PACKET_OTHERHOST;
skb->protocol = htons(ETH_P_802_2);
memset(skb->cb, 0, sizeof(skb->cb));
netif_rx(skb);
}
/* incase of fully hosting mode, the freeing will be done in response to the cfg packet */
kfree(pv_data->buff);
kfree(pv_data);
}
#endif /* WILC_FULLY_HOSTING_AP */
/**
* @brief WILC_WFI_mon_setup
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
static void WILC_WFI_mon_setup(struct net_device *dev)
{
dev->netdev_ops = &wilc_wfi_netdev_ops;
/* dev->destructor = free_netdev; */
PRINT_INFO(CORECONFIG_DBG, "In Ethernet setup function\n");
ether_setup(dev);
dev->tx_queue_len = 0;
dev->type = ARPHRD_IEEE80211_RADIOTAP;
memset(dev->dev_addr, 0, ETH_ALEN);
#ifdef USE_WIRELESS
{
/* u8 * mac_add; */
unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x8f};
/* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
/* mac_add = (WILC_Uint8*)WILC_MALLOC(ETH_ALEN); */
/* status = host_int_get_MacAddress(priv->hWILCWFIDrv,mac_add); */
/* mac_add[ETH_ALEN-1]+=1; */
memcpy(dev->dev_addr, mac_add, ETH_ALEN);
}
#else
dev->dev_addr[0] = 0x12;
#endif
}
/**
* @brief WILC_WFI_init_mon_interface
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev)
{
WILC_Uint32 ret = WILC_SUCCESS;
struct WILC_WFI_mon_priv *priv;
/*If monitor interface is already initialized, return it*/
if (wilc_wfi_mon) {
return wilc_wfi_mon;
}
#if 0
wilc_wfi_mon = alloc_netdev(sizeof(struct WILC_WFI_mon_priv), name, WILC_WFI_mon_setup);
if (wilc_wfi_mon == NULL) {
PRINT_ER("Failed to allocate netdevice\n");
goto failed;
}
/* rtnl_lock(); */
PRINT_INFO(HOSTAPD_DBG, "Monitor interface name %s\n", wilc_wfi_mon->name);
ret = dev_alloc_name(wilc_wfi_mon, wilc_wfi_mon->name);
if (ret < 0)
goto failed_mon;
priv = netdev_priv(wilc_wfi_mon);
if (priv == NULL) {
PRINT_ER("private structure is NULL\n");
return WILC_FAIL;
}
priv->real_ndev = real_dev;
ret = register_netdevice(wilc_wfi_mon);
if (ret < 0) {
PRINT_ER("Failed to register netdevice\n");
goto failed_mon;
}
return WILC_SUCCESS;
/* rtnl_unlock(); */
failed:
return ret;
failed_mon:
/* rtnl_unlock(); */
free_netdev(wilc_wfi_mon);
return ret;
#endif
wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv));
if (!wilc_wfi_mon) {
PRINT_ER("failed to allocate memory\n");
return NULL;
}
wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP;
strncpy(wilc_wfi_mon->name, name, IFNAMSIZ);
wilc_wfi_mon->name[IFNAMSIZ - 1] = 0;
wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops;
ret = register_netdevice(wilc_wfi_mon);
if (ret) {
PRINT_ER(" register_netdevice failed (%d)\n", ret);
return NULL;
}
priv = netdev_priv(wilc_wfi_mon);
if (priv == NULL) {
PRINT_ER("private structure is NULL\n");
return NULL;
}
priv->real_ndev = real_dev;
return wilc_wfi_mon;
}
/**
* @brief WILC_WFI_deinit_mon_interface
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
int WILC_WFI_deinit_mon_interface()
{
bool rollback_lock = false;
if (wilc_wfi_mon != NULL) {
PRINT_D(HOSTAPD_DBG, "In Deinit monitor interface\n");
PRINT_D(HOSTAPD_DBG, "RTNL is being locked\n");
if (rtnl_is_locked()) {
rtnl_unlock();
rollback_lock = true;
}
PRINT_D(HOSTAPD_DBG, "Unregister netdev\n");
unregister_netdev(wilc_wfi_mon);
/* free_netdev(wilc_wfi_mon); */
if (rollback_lock) {
rtnl_lock();
rollback_lock = false;
}
wilc_wfi_mon = NULL;
}
return WILC_SUCCESS;
}
#endif /* WILC_AP_EXTERNAL_MLME */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
#ifndef LINUX_WLAN_COMMON_H
#define LINUX_WLAN_COMMON_H
enum debug_region {
Generic_debug = 0,
Hostapd_debug,
Hostinf_debug,
CFG80211_debug,
Coreconfig_debug,
Interrupt_debug,
TX_debug,
RX_debug,
Lock_debug,
Tcp_enhance,
/*Added by amr - BugID_4720*/
Spin_debug,
Init_debug,
Bus_debug,
Mem_debug,
Firmware_debug,
COMP = 0xFFFFFFFF,
};
#define GENERIC_DBG (1 << Generic_debug)
#define HOSTAPD_DBG (1 << Hostapd_debug)
#define HOSTINF_DBG (1 << Hostinf_debug)
#define CORECONFIG_DBG (1 << Coreconfig_debug)
#define CFG80211_DBG (1 << CFG80211_debug)
#define INT_DBG (1 << Interrupt_debug)
#define TX_DBG (1 << TX_debug)
#define RX_DBG (1 << RX_debug)
#define LOCK_DBG (1 << Lock_debug)
#define TCP_ENH (1 << Tcp_enhance)
/*Added by Amr - BugID_4720*/
#define SPIN_DEBUG (1 << Spin_debug)
#define INIT_DBG (1 << Init_debug)
#define BUS_DBG (1 << Bus_debug)
#define MEM_DBG (1 << Mem_debug)
#define FIRM_DBG (1 << Firmware_debug)
#if defined (WILC_DEBUGFS)
extern int wilc_debugfs_init(void);
extern void wilc_debugfs_remove(void);
extern atomic_t REGION;
extern atomic_t DEBUG_LEVEL;
#define DEBUG (1 << 0)
#define INFO (1 << 1)
#define WRN (1 << 2)
#define ERR (1 << 3)
#define PRINT_D(region, ...) do { \
if ((atomic_read(&DEBUG_LEVEL) & DEBUG) && ((atomic_read(&REGION)) & (region))) { \
printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_INFO(region, ...) do { \
if ((atomic_read(&DEBUG_LEVEL) & INFO) && ((atomic_read(&REGION)) & (region))) { \
printk("INFO [%s]", __FUNCTION__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_WRN(region, ...) do { \
if ((atomic_read(&DEBUG_LEVEL) & WRN) && ((atomic_read(&REGION)) & (region))) { \
printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_ER(...) do { \
if ((atomic_read(&DEBUG_LEVEL) & ERR)) { \
printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} \
} while (0)
#else
#define REGION (INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG)
#define DEBUG 1
#define INFO 0
#define WRN 0
#define PRINT_D(region, ...) do { if (DEBUG == 1 && ((REGION)&(region))) { \
printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_INFO(region, ...) do { if (INFO == 1 && ((REGION)&(region))) { \
printk("INFO [%s]", __FUNCTION__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_WRN(region, ...) do { if (WRN == 1 && ((REGION)&(region))) { \
printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} \
} while (0)
#define PRINT_ER(...) do { printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \
printk(__VA_ARGS__); \
} while (0)
#endif
#define FN_IN /* PRINT_D(">>> \n") */
#define FN_OUT /* PRINT_D("<<<\n") */
#ifdef MEMORY_STATIC
#define LINUX_RX_SIZE (96 * 1024)
#endif
#define LINUX_TX_SIZE (64 * 1024)
#define WILC_MULTICAST_TABLE_SIZE 8
#if defined (NM73131_0_BOARD)
#define MODALIAS "wilc_spi"
#define GPIO_NUM IRQ_WILC1000_GPIO
#elif defined (BEAGLE_BOARD)
#define SPI_CHANNEL 4
#if SPI_CHANNEL == 4
#define MODALIAS "wilc_spi4"
#define GPIO_NUM 162
#else
#define MODALIAS "wilc_spi3"
#define GPIO_NUM 133
#endif
#elif defined(PANDA_BOARD)
#define MODALIAS "WILC_SPI"
#define GPIO_NUM 139
#elif defined(PLAT_WMS8304) /* rachel */
#define MODALIAS "wilc_spi"
#define GPIO_NUM 139
#elif defined (PLAT_RKXXXX)
#define MODALIAS "WILC_IRQ"
#define GPIO_NUM RK30_PIN3_PD2 /* RK30_PIN3_PA1 */
/* RK30_PIN3_PD2 */
/* RK2928_PIN1_PA7 */
#elif defined(CUSTOMER_PLATFORM)
/*
TODO : specify MODALIAS name and GPIO number. This is certainly necessary for SPI interface.
*
* ex)
* #define MODALIAS "WILC_SPI"
* #define GPIO_NUM 139
*/
#else
/* base on SAMA5D3_Xplained Board */
#define MODALIAS "WILC_SPI"
#define GPIO_NUM 0x44
#endif
void linux_wlan_enable_irq(void);
#endif

View File

@ -0,0 +1,249 @@
#include "wilc_wfi_netdevice.h"
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/card.h>
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/host.h>
#if defined (NM73131_0_BOARD)
#define SDIO_MODALIAS "wilc_sdio"
#else
#define SDIO_MODALIAS "wilc1000_sdio"
#endif
#if defined (NM73131_0_BOARD)
#define MAX_SPEED 50000000
#elif defined(CUSTOMER_PLATFORM)
/* TODO : User have to stable bus clock as user's environment. */
#ifdef MAX_BUS_SPEED
#define MAX_SPEED MAX_BUS_SPEED
#else
#define MAX_SPEED 50000000
#endif
#else
#define MAX_SPEED (6 * 1000000) /* Max 50M */
#endif
struct sdio_func *local_sdio_func;
extern linux_wlan_t *g_linux_wlan;
extern int wilc_netdev_init(void);
extern int sdio_clear_int(void);
extern void wilc_handle_isr(void);
static unsigned int sdio_default_speed;
#define SDIO_VENDOR_ID_WILC 0x0296
#define SDIO_DEVICE_ID_WILC 0x5347
static const struct sdio_device_id wilc_sdio_ids[] = {
{ SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
};
static void wilc_sdio_interrupt(struct sdio_func *func)
{
#ifndef WILC_SDIO_IRQ_GPIO
sdio_release_host(func);
wilc_handle_isr();
sdio_claim_host(func);
#endif
}
int linux_sdio_cmd52(sdio_cmd52_t *cmd)
{
struct sdio_func *func = g_linux_wlan->wilc_sdio_func;
int ret;
u8 data;
sdio_claim_host(func);
func->num = cmd->function;
if (cmd->read_write) { /* write */
if (cmd->raw) {
sdio_writeb(func, cmd->data, cmd->address, &ret);
data = sdio_readb(func, cmd->address, &ret);
cmd->data = data;
} else {
sdio_writeb(func, cmd->data, cmd->address, &ret);
}
} else { /* read */
data = sdio_readb(func, cmd->address, &ret);
cmd->data = data;
}
sdio_release_host(func);
if (ret < 0) {
PRINT_ER("wilc_sdio_cmd52..failed, err(%d)\n", ret);
return 0;
}
return 1;
}
int linux_sdio_cmd53(sdio_cmd53_t *cmd)
{
struct sdio_func *func = g_linux_wlan->wilc_sdio_func;
int size, ret;
sdio_claim_host(func);
func->num = cmd->function;
func->cur_blksize = cmd->block_size;
if (cmd->block_mode)
size = cmd->count * cmd->block_size;
else
size = cmd->count;
if (cmd->read_write) { /* write */
ret = sdio_memcpy_toio(func, cmd->address, (void *)cmd->buffer, size);
} else { /* read */
ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, cmd->address, size);
}
sdio_release_host(func);
if (ret < 0) {
PRINT_ER("wilc_sdio_cmd53..failed, err(%d)\n", ret);
return 0;
}
return 1;
}
volatile int probe; /* COMPLEMENT_BOOT */
static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
{
PRINT_D(INIT_DBG, "probe function\n");
#ifdef COMPLEMENT_BOOT
if (local_sdio_func != NULL) {
local_sdio_func = func;
probe = 1;
PRINT_D(INIT_DBG, "local_sdio_func isn't NULL\n");
return 0;
}
#endif
PRINT_D(INIT_DBG, "Initializing netdev\n");
local_sdio_func = func;
if (wilc_netdev_init()) {
PRINT_ER("Couldn't initialize netdev\n");
return -1;
}
printk("Driver Initializing success\n");
return 0;
}
static void linux_sdio_remove(struct sdio_func *func)
{
/**
* TODO
**/
}
struct sdio_driver wilc_bus = {
.name = SDIO_MODALIAS,
.id_table = wilc_sdio_ids,
.probe = linux_sdio_probe,
.remove = linux_sdio_remove,
};
int enable_sdio_interrupt(void)
{
int ret = 0;
#ifndef WILC_SDIO_IRQ_GPIO
sdio_claim_host(local_sdio_func);
ret = sdio_claim_irq(local_sdio_func, wilc_sdio_interrupt);
sdio_release_host(local_sdio_func);
if (ret < 0) {
PRINT_ER("can't claim sdio_irq, err(%d)\n", ret);
ret = -EIO;
}
#endif
return ret;
}
void disable_sdio_interrupt(void)
{
#ifndef WILC_SDIO_IRQ_GPIO
int ret;
PRINT_D(INIT_DBG, "disable_sdio_interrupt IN\n");
sdio_claim_host(local_sdio_func);
ret = sdio_release_irq(local_sdio_func);
if (ret < 0) {
PRINT_ER("can't release sdio_irq, err(%d)\n", ret);
}
sdio_release_host(local_sdio_func);
PRINT_D(INIT_DBG, "disable_sdio_interrupt OUT\n");
#endif
}
static int linux_sdio_set_speed(int speed)
{
struct mmc_ios ios;
sdio_claim_host(local_sdio_func);
memcpy((void *)&ios, (void *)&local_sdio_func->card->host->ios, sizeof(struct mmc_ios));
local_sdio_func->card->host->ios.clock = speed;
ios.clock = speed;
local_sdio_func->card->host->ops->set_ios(local_sdio_func->card->host, &ios);
sdio_release_host(local_sdio_func);
PRINT_INFO(INIT_DBG, "@@@@@@@@@@@@ change SDIO speed to %d @@@@@@@@@\n", speed);
return 1;
}
static int linux_sdio_get_speed(void)
{
return local_sdio_func->card->host->ios.clock;
}
int linux_sdio_init(void *pv)
{
/**
* TODO :
**/
sdio_default_speed = linux_sdio_get_speed();
return 1;
}
void linux_sdio_deinit(void *pv)
{
/**
* TODO :
**/
sdio_unregister_driver(&wilc_bus);
}
int linux_sdio_set_max_speed(void)
{
return linux_sdio_set_speed(MAX_SPEED);
}
int linux_sdio_set_default_speed(void)
{
return linux_sdio_set_speed(sdio_default_speed);
}

View File

@ -0,0 +1,14 @@
extern struct sdio_func *local_sdio_func;
extern struct sdio_driver wilc_bus;
#include <linux/mmc/sdio_func.h>
int linux_sdio_init(void *);
void linux_sdio_deinit(void *);
int linux_sdio_cmd52(sdio_cmd52_t *cmd);
int linux_sdio_cmd53(sdio_cmd53_t *cmd);
int enable_sdio_interrupt(void);
void disable_sdio_interrupt(void);
int linux_sdio_set_max_speed(void);
int linux_sdio_set_default_speed(void);

View File

@ -0,0 +1,510 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
#include <linux/device.h>
#include <linux/spi/spi.h>
#include "linux_wlan_common.h"
#define USE_SPI_DMA 0 /* johnny add */
#ifdef WILC_ASIC_A0
#if defined(PLAT_PANDA_ES_OMAP4460)
#define MIN_SPEED 12000000
#define MAX_SPEED 24000000
#elif defined(PLAT_WMS8304)
#define MIN_SPEED 12000000
#define MAX_SPEED 24000000 /* 4000000 */
#elif defined(CUSTOMER_PLATFORM)
/*
TODO : define Clock speed under 48M.
*
* ex)
* #define MIN_SPEED 24000000
* #define MAX_SPEED 48000000
*/
#else
#define MIN_SPEED 24000000
#define MAX_SPEED 48000000
#endif
#else /* WILC_ASIC_A0 */
/* Limit clk to 6MHz on FPGA. */
#define MIN_SPEED 6000000
#define MAX_SPEED 6000000
#endif /* WILC_ASIC_A0 */
static uint32_t SPEED = MIN_SPEED;
struct spi_device *wilc_spi_dev;
void linux_spi_deinit(void *vp);
static int __init wilc_bus_probe(struct spi_device *spi)
{
PRINT_D(BUS_DBG, "spiModalias: %s\n", spi->modalias);
PRINT_D(BUS_DBG, "spiMax-Speed: %d\n", spi->max_speed_hz);
wilc_spi_dev = spi;
printk("Driver Initializing success\n");
return 0;
}
static int __exit wilc_bus_remove(struct spi_device *spi)
{
/* linux_spi_deinit(NULL); */
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id wilc1000_of_match[] = {
{ .compatible = "atmel,wilc_spi", },
{}
};
MODULE_DEVICE_TABLE(of, wilc1000_of_match);
#endif
struct spi_driver wilc_bus __refdata = {
.driver = {
.name = MODALIAS,
#ifdef CONFIG_OF
.of_match_table = wilc1000_of_match,
#endif
},
.probe = wilc_bus_probe,
.remove = __exit_p(wilc_bus_remove),
};
void linux_spi_deinit(void *vp)
{
spi_unregister_driver(&wilc_bus);
SPEED = MIN_SPEED;
PRINT_ER("@@@@@@@@@@@@ restore SPI speed to %d @@@@@@@@@\n", SPEED);
}
int linux_spi_init(void *vp)
{
int ret = 1;
static int called;
if (called == 0) {
called++;
if (&wilc_bus == NULL) {
PRINT_ER("wilc_bus address is NULL\n");
}
ret = spi_register_driver(&wilc_bus);
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#if defined(PLAT_WMS8304)
#define TXRX_PHASE_SIZE (4096)
#endif
#if defined (NM73131_0_BOARD)
int linux_spi_write(uint8_t *b, uint32_t len)
{
int ret;
if (len > 0 && b != NULL) {
struct spi_message msg;
PRINT_D(BUS_DBG, "Request writing %d bytes\n", len);
struct spi_transfer tr = {
.tx_buf = b,
.len = len,
.speed_hz = SPEED,
.delay_usecs = 0,
};
spi_message_init(&msg);
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
} else {
PRINT_ER("can't write data with the following length: %d\n", len);
PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#elif defined(TXRX_PHASE_SIZE)
int linux_spi_write(uint8_t *b, uint32_t len)
{
int ret;
if (len > 0 && b != NULL) {
int i = 0;
int blk = len / TXRX_PHASE_SIZE;
int remainder = len % TXRX_PHASE_SIZE;
char *r_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
if (!r_buffer) {
PRINT_ER("Failed to allocate memory for r_buffer\n");
}
if (blk) {
while (i < blk) {
struct spi_message msg;
struct spi_transfer tr = {
.tx_buf = b + (i * TXRX_PHASE_SIZE),
/* .rx_buf = NULL, */
.len = TXRX_PHASE_SIZE,
.speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
/*
* char *r_buffer = (char*) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
* if(! r_buffer){
* PRINT_ER("Failed to allocate memory for r_buffer\n");
* }
*/
tr.rx_buf = r_buffer;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
/* i += MJ_WRITE_SIZE; */
i++;
}
}
if (remainder) {
struct spi_message msg;
struct spi_transfer tr = {
.tx_buf = b + (blk * TXRX_PHASE_SIZE),
/* .rx_buf = NULL, */
.len = remainder,
.speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
/*
* char *r_buffer = (char*) kzalloc(remainder, GFP_KERNEL);
* if(! r_buffer){
* PRINT_ER("Failed to allocate memory for r_buffer\n");
* }
*/
tr.rx_buf = r_buffer;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
}
if (r_buffer)
kfree(r_buffer);
} else {
PRINT_ER("can't write data with the following length: %d\n", len);
PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#else
int linux_spi_write(uint8_t *b, uint32_t len)
{
int ret;
struct spi_message msg;
if (len > 0 && b != NULL) {
struct spi_transfer tr = {
.tx_buf = b,
/* .rx_buf = r_buffer, */
.len = len,
.speed_hz = SPEED,
.delay_usecs = 0,
};
char *r_buffer = (char *) kzalloc(len, GFP_KERNEL);
if (!r_buffer) {
PRINT_ER("Failed to allocate memory for r_buffer\n");
}
tr.rx_buf = r_buffer;
PRINT_D(BUS_DBG, "Request writing %d bytes\n", len);
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
/* [[johnny add */
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA;
/* ]] */
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
kfree(r_buffer);
} else {
PRINT_ER("can't write data with the following length: %d\n", len);
PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#endif
#if defined (NM73131_0_BOARD)
int linux_spi_read(unsigned char *rb, unsigned long rlen)
{
int ret;
if (rlen > 0) {
struct spi_message msg;
struct spi_transfer tr = {
.rx_buf = rb,
.len = rlen,
.speed_hz = SPEED,
.delay_usecs = 0,
};
spi_message_init(&msg);
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
} else {
PRINT_ER("can't read data with the following length: %ld\n", rlen);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#elif defined(TXRX_PHASE_SIZE)
int linux_spi_read(unsigned char *rb, unsigned long rlen)
{
int ret;
if (rlen > 0) {
int i = 0;
int blk = rlen / TXRX_PHASE_SIZE;
int remainder = rlen % TXRX_PHASE_SIZE;
char *t_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
if (!t_buffer) {
PRINT_ER("Failed to allocate memory for t_buffer\n");
}
if (blk) {
while (i < blk) {
struct spi_message msg;
struct spi_transfer tr = {
/* .tx_buf = NULL, */
.rx_buf = rb + (i * TXRX_PHASE_SIZE),
.len = TXRX_PHASE_SIZE,
.speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
tr.tx_buf = t_buffer;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
i++;
}
}
if (remainder) {
struct spi_message msg;
struct spi_transfer tr = {
/* .tx_buf = NULL, */
.rx_buf = rb + (blk * TXRX_PHASE_SIZE),
.len = remainder,
.speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
/*
* char *t_buffer = (char*) kzalloc(remainder, GFP_KERNEL);
* if(! t_buffer){
* PRINT_ER("Failed to allocate memory for t_buffer\n");
* }
*/
tr.tx_buf = t_buffer;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
}
if (t_buffer)
kfree(t_buffer);
} else {
PRINT_ER("can't read data with the following length: %ld\n", rlen);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#else
int linux_spi_read(unsigned char *rb, unsigned long rlen)
{
int ret;
if (rlen > 0) {
struct spi_message msg;
struct spi_transfer tr = {
/* .tx_buf = t_buffer, */
.rx_buf = rb,
.len = rlen,
.speed_hz = SPEED,
.delay_usecs = 0,
};
char *t_buffer = (char *) kzalloc(rlen, GFP_KERNEL);
if (!t_buffer) {
PRINT_ER("Failed to allocate memory for t_buffer\n");
}
tr.tx_buf = t_buffer;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
/* [[ johnny add */
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA;
/* ]] */
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
kfree(t_buffer);
} else {
PRINT_ER("can't read data with the following length: %ld\n", rlen);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
#endif
int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen)
{
int ret;
if (rlen > 0) {
struct spi_message msg;
struct spi_transfer tr = {
.rx_buf = rb,
.tx_buf = wb,
.len = rlen,
.speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
msg.spi = wilc_spi_dev;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
ret = spi_sync(wilc_spi_dev, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
} else {
PRINT_ER("can't read data with the following length: %d\n", rlen);
ret = -1;
}
/* change return value to match WILC interface */
(ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
int linux_spi_set_max_speed(void)
{
SPEED = MAX_SPEED;
PRINT_INFO(BUS_DBG, "@@@@@@@@@@@@ change SPI speed to %d @@@@@@@@@\n", SPEED);
return 1;
}

View File

@ -0,0 +1,14 @@
#ifndef LINUX_WLAN_SPI_H
#define LINUX_WLAN_SPI_H
#include <linux/spi/spi.h>
extern struct spi_device *wilc_spi_dev;
extern struct spi_driver wilc_bus;
int linux_spi_init(void *vp);
void linux_spi_deinit(void *vp);
int linux_spi_write(uint8_t *b, uint32_t len);
int linux_spi_read(uint8_t *rb, uint32_t rlen);
int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen);
int linux_spi_set_max_speed(void);
#endif

View File

@ -0,0 +1,185 @@
/*
* NewportMedia WiFi chipset driver test tools - wilc-debug
* Copyright (c) 2012 NewportMedia Inc.
* Author: SSW <sswd@wilcsemic.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#if defined(WILC_DEBUGFS)
#include <linux/module.h>
#include <linux/debugfs.h>
#include <linux/poll.h>
#include <linux/sched.h>
#include "wilc_wlan_if.h"
static struct dentry *wilc_dir;
/*
* --------------------------------------------------------------------------------
*/
#define DBG_REGION_ALL (GENERIC_DBG | HOSTAPD_DBG | HOSTINF_DBG | CORECONFIG_DBG | CFG80211_DBG | INT_DBG | TX_DBG | RX_DBG | LOCK_DBG | INIT_DBG | BUS_DBG | MEM_DBG)
#define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR)
atomic_t REGION = ATOMIC_INIT(INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG);
atomic_t DEBUG_LEVEL = ATOMIC_INIT(ERR);
/*
* --------------------------------------------------------------------------------
*/
static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos)
{
char buf[128];
int res = 0;
/* only allow read from start */
if (*ppos > 0)
return 0;
res = scnprintf(buf, sizeof(buf), "Debug Level: %x\n", atomic_read(&DEBUG_LEVEL));
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
{
char buffer[128] = {};
int flag = 0;
if (copy_from_user(buffer, buf, count)) {
return -EFAULT;
}
flag = buffer[0] - '0';
if (flag > 0) {
flag = DEBUG | ERR;
} else if (flag < 0) {
flag = 100;
}
if (flag > DBG_LEVEL_ALL) {
printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&DEBUG_LEVEL));
return -EFAULT;
}
atomic_set(&DEBUG_LEVEL, (int)flag);
if (flag == 0) {
printk("Debug-level disabled\n");
} else {
printk("Debug-level enabled\n");
}
return count;
}
static ssize_t wilc_debug_region_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos)
{
char buf[128];
int res = 0;
/* only allow read from start */
if (*ppos > 0)
return 0;
res = scnprintf(buf, sizeof(buf), "Debug region: %x\n", atomic_read(&REGION));
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
static ssize_t wilc_debug_region_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
{
char buffer[128] = {};
int flag;
if (copy_from_user(buffer, buf, count)) {
return -EFAULT;
}
flag = buffer[0] - '0';
if (flag > DBG_REGION_ALL) {
printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&REGION));
return -EFAULT;
}
atomic_set(&REGION, (int)flag);
printk("new debug-region is %x\n", atomic_read(&REGION));
return count;
}
/*
* --------------------------------------------------------------------------------
*/
#define FOPS(_open, _read, _write, _poll) { \
.owner = THIS_MODULE, \
.open = (_open), \
.read = (_read), \
.write = (_write), \
.poll = (_poll), \
}
struct wilc_debugfs_info_t {
const char *name;
int perm;
unsigned int data;
struct file_operations fops;
};
static struct wilc_debugfs_info_t debugfs_info[] = {
{ "wilc_debug_level", 0666, (DEBUG | ERR), FOPS(NULL, wilc_debug_level_read, wilc_debug_level_write, NULL), },
{ "wilc_debug_region", 0666, (INIT_DBG | GENERIC_DBG | CFG80211_DBG), FOPS(NULL, wilc_debug_region_read, wilc_debug_region_write, NULL), },
};
int wilc_debugfs_init(void)
{
int i;
struct dentry *debugfs_files;
struct wilc_debugfs_info_t *info;
wilc_dir = debugfs_create_dir("wilc_wifi", NULL);
if (wilc_dir == ERR_PTR(-ENODEV)) {
/* it's not error. the debugfs is just not being enabled. */
printk("ERR, kernel has built without debugfs support\n");
return 0;
}
if (!wilc_dir) {
printk("ERR, debugfs create dir\n");
return -1;
}
for (i = 0; i < ARRAY_SIZE(debugfs_info); i++) {
info = &debugfs_info[i];
debugfs_files = debugfs_create_file(info->name,
info->perm,
wilc_dir,
&info->data,
&info->fops);
if (!debugfs_files) {
printk("ERR fail to create the debugfs file, %s\n", info->name);
debugfs_remove_recursive(wilc_dir);
return -1;
}
}
return 0;
}
void wilc_debugfs_remove(void)
{
debugfs_remove_recursive(wilc_dir);
}
#endif

View File

@ -0,0 +1,84 @@
#ifndef __WILC_ERRORSUPPORT_H__
#define __WILC_ERRORSUPPORT_H__
/*!
* @file wilc_errorsupport.h
* @brief Error reporting and handling support
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 10 Aug 2010
* @version 1.0
*/
#include "linux_wlan_common.h"
/* Psitive Numbers to indicate sucess with special status */
#define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */
/* Generic success will return 0 */
#define WILC_SUCCESS 0 /** Generic success */
/* Negative numbers to indicate failures */
#define WILC_FAIL -100 /** Generic Fail */
#define WILC_BUSY -101 /** Busy with another operation*/
#define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/
#define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/
#define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/
#define WILC_NULL_PTR -105 /** null pointer is passed or used */
#define WILC_EMPTY -107
#define WILC_FULL -108
#define WILC_TIMEOUT -109
#define WILC_CANCELED -110 /** The required operation have been canceled by the user*/
#define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */
#define WILC_NOT_FOUND -113 /** Cant find the file to load */
#define WILC_NO_MEM -114
#define WILC_UNSUPPORTED_VERSION -115
#define WILC_FILE_EOF -116
/* Error type */
typedef WILC_Sint32 WILC_ErrNo;
#define WILC_IS_ERR(__status__) (__status__ < WILC_SUCCESS)
#define WILC_ERRORCHECK(__status__) do { \
if (WILC_IS_ERR(__status__)) { \
PRINT_ER("PRINT_ER(%d)\n", __status__); \
goto ERRORHANDLER; \
} \
} while (0)
#define WILC_ERRORREPORT(__status__, __err__) do { \
PRINT_ER("PRINT_ER(%d)\n", __err__); \
__status__ = __err__; \
goto ERRORHANDLER; \
} while (0)
#define WILC_NULLCHECK(__status__, __ptr__) do { \
if (__ptr__ == WILC_NULL) { \
WILC_ERRORREPORT(__status__, WILC_NULL_PTR); \
} \
} while (0)
#define WILC_CATCH(__status__) \
ERRORHANDLER: \
if (WILC_IS_ERR(__status__)) \
#ifdef CONFIG_WILC_ASSERTION_SUPPORT
/**
* @brief prints a diagnostic message and aborts the program
* @param[in] pcExpression The expression that triggered the assertion
* @param[in] pcFileName The name of the current source file.
* @param[in] u32LineNumber The line number in the current source file.
* @warning DO NOT CALL DIRECTLY. USE EQUIVALENT MACRO FUNCTION INSTEAD.
*/
void WILC_assert_INTERNAL(WILC_Char *pcExpression, WILC_Char *pcFileName, WILC_Uint32 u32LineNumber);
#define WILC_assert(__expression__) (void)(!!(__expression__) || (WILC_assert_INTERNAL((# __expression__), __WILC_FILE__, __WILC_LINE__), 0))
#else
#define WILC_assert(__expression__) ((void)0)
#endif
#endif

View File

@ -0,0 +1,123 @@
#ifndef __WILC_EVENT_H__
#define __WILC_EVENT_H__
/*!
* @file wilc_event.h
* @brief Event OS wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 10 Oct 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_EVENT_FEATURE
#error the feature CONFIG_WILC_EVENT_FEATURE must be supported to include this file
#endif
/*!
* @struct tstrWILC_TimerAttrs
* @brief Timer API options
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
typedef struct {
/* a dummy member to avoid compiler errors*/
WILC_Uint8 dummy;
#ifdef CONFIG_WILC_EVENT_TIMEOUT
/*!<
* Timeout for use with WILC_EventWait, 0 to return immediately and
* WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY
*/
WILC_Uint32 u32TimeOut;
#endif
} tstrWILC_EventAttrs;
/*!
* @brief Fills the WILC_TimerAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa WILC_TimerAttrs
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
static void WILC_EventFillDefault(tstrWILC_EventAttrs *pstrAttrs)
{
#ifdef CONFIG_WILC_EVENT_TIMEOUT
pstrAttrs->u32TimeOut = WILC_OS_INFINITY;
#endif
}
/*!
* @brief Creates a new Event
* @details the Event is an object that allows a thread to wait until an external
* event occuers, Event objects have 2 states, either TRIGGERED or
* UNTRIGGERED
* @param[out] pHandle handle to the newly created event object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_EventAttrs
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
WILC_ErrNo WILC_EventCreate(WILC_EventHandle *pHandle, tstrWILC_EventAttrs *pstrAttrs);
/*!
* @brief Destroys a given event
* @details This will destroy a given event freeing any resources used by it
* if there are any thread blocked by the WILC_EventWait call the the
* behaviour is undefined
* @param[in] pHandle handle to the event object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_EventAttrs
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
WILC_ErrNo WILC_EventDestroy(WILC_EventHandle *pHandle,
tstrWILC_EventAttrs *pstrAttrs);
/*!
* @brief Triggers a given event
* @details This function will set the given event into the TRIGGERED state,
* if the event is already in TRIGGERED, this function will have no
* effect
* @param[in] pHandle handle to the event object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_EventAttrs
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
WILC_ErrNo WILC_EventTrigger(WILC_EventHandle *pHandle,
tstrWILC_EventAttrs *pstrAttrs);
/*!
* @brief waits until a given event is triggered
* @details This function will block the calling thread until the event becomes
* in the TRIGGERED state. the call will retun the event into the
* UNTRIGGERED state upon completion
* if multible threads are waiting on the same event at the same time,
* behaviour is undefined
* @param[in] pHandle handle to the event object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_EventAttrs
* @author syounan
* @date 10 Oct 2010
* @version 1.0
*/
WILC_ErrNo WILC_EventWait(WILC_EventHandle *pHandle,
tstrWILC_EventAttrs *pstrAttrs);
#endif

View File

@ -0,0 +1,76 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#define LINUX_RX_SIZE (96 * 1024)
#define LINUX_TX_SIZE (64 * 1024)
#define WILC1000_FW_SIZE (4 * 1024)
#define DECLARE_WILC_BUFFER(name) \
void *exported_ ## name = NULL;
#define MALLOC_WILC_BUFFER(name, size) \
exported_ ## name = kmalloc(size, GFP_KERNEL); \
if (!exported_ ## name) { \
printk("fail to alloc: %s memory\n", exported_ ## name); \
return -ENOBUFS; \
}
#define FREE_WILC_BUFFER(name) \
kfree(exported_ ## name);
/*
* Add necessary buffer pointers
*/
DECLARE_WILC_BUFFER(g_tx_buf)
DECLARE_WILC_BUFFER(g_rx_buf)
DECLARE_WILC_BUFFER(g_fw_buf)
void *get_tx_buffer(void)
{
return exported_g_tx_buf;
}
EXPORT_SYMBOL(get_tx_buffer);
void *get_rx_buffer(void)
{
return exported_g_rx_buf;
}
EXPORT_SYMBOL(get_rx_buffer);
void *get_fw_buffer(void)
{
return exported_g_fw_buf;
}
EXPORT_SYMBOL(get_fw_buffer);
static int __init wilc_module_init(void)
{
printk("wilc_module_init\n");
/*
* alloc necessary memory
*/
MALLOC_WILC_BUFFER(g_tx_buf, LINUX_TX_SIZE)
MALLOC_WILC_BUFFER(g_rx_buf, LINUX_RX_SIZE)
MALLOC_WILC_BUFFER(g_fw_buf, WILC1000_FW_SIZE)
return 0;
}
static void __exit wilc_module_deinit(void)
{
printk("wilc_module_deinit\n");
FREE_WILC_BUFFER(g_tx_buf)
FREE_WILC_BUFFER(g_rx_buf)
FREE_WILC_BUFFER(g_fw_buf)
return;
}
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Tony Cho");
MODULE_DESCRIPTION("WILC1xxx Memory Manager");
pure_initcall(wilc_module_init);
module_exit(wilc_module_deinit);

View File

@ -0,0 +1,47 @@
#ifndef __WILC_LOG_H__
#define __WILC_LOG_H__
/* Errors will always get printed */
#define WILC_ERROR(...) do { WILC_PRINTF("(ERR)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \
WILC_PRINTF(__VA_ARGS__); \
} while (0)
/* Wraning only printed if verbosity is 1 or more */
#if (WILC_LOG_VERBOSITY_LEVEL > 0)
#define WILC_WARN(...) do { WILC_PRINTF("(WRN)"); \
WILC_PRINTF(__VA_ARGS__); \
} while (0)
#else
#define WILC_WARN(...) (0)
#endif
/* Info only printed if verbosity is 2 or more */
#if (WILC_LOG_VERBOSITY_LEVEL > 1)
#define WILC_INFO(...) do { WILC_PRINTF("(INF)"); \
WILC_PRINTF(__VA_ARGS__); \
} while (0)
#else
#define WILC_INFO(...) (0)
#endif
/* Debug is only printed if verbosity is 3 or more */
#if (WILC_LOG_VERBOSITY_LEVEL > 2)
#define WILC_DBG(...) do { WILC_PRINTF("(DBG)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \
WILC_PRINTF(__VA_ARGS__); \
} while (0)
#else
#define WILC_DBG(...) (0)
#endif
/* Function In/Out is only printed if verbosity is 4 or more */
#if (WILC_LOG_VERBOSITY_LEVEL > 3)
#define WILC_FN_IN do { WILC_PRINTF("(FIN) (%s:%d) \n", __WILC_FUNCTION__, __WILC_LINE__); } while (0)
#define WILC_FN_OUT(ret) do { WILC_PRINTF("(FOUT) (%s:%d) %d.\n", __WILC_FUNCTION__, __WILC_LINE__, (ret)); } while (0)
#else
#define WILC_FN_IN (0)
#define WILC_FN_OUT(ret) (0)
#endif
#endif

View File

@ -0,0 +1,63 @@
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_MEMORY_FEATURE
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
{
if (u32Size > 0) {
return kmalloc(u32Size, GFP_ATOMIC);
} else {
return WILC_NULL;
}
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
{
return kcalloc(u32Size, 1, GFP_KERNEL);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize,
tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
{
if (u32NewSize == 0) {
kfree(pvOldBlock);
return WILC_NULL;
} else if (pvOldBlock == WILC_NULL) {
return kmalloc(u32NewSize, GFP_KERNEL);
} else {
return krealloc(pvOldBlock, u32NewSize, GFP_KERNEL);
}
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
{
kfree(pvBlock);
}
#endif

View File

@ -0,0 +1,330 @@
#ifndef __WILC_MEMORY_H__
#define __WILC_MEMORY_H__
/*!
* @file wilc_memory.h
* @brief Memory OS wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 16 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_MEMORY_FEATURE
#error the feature CONFIG_WILC_MEMORY_FEATURE must be supported to include this file
#endif
/*!
* @struct tstrWILC_MemoryAttrs
* @brief Memory API options
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
typedef struct {
#ifdef CONFIG_WILC_MEMORY_POOLS
/*!< the allocation pool to use for this memory, NULL for system
* allocation. Default is NULL
*/
WILC_MemoryPoolHandle *pAllocationPool;
#endif
/* a dummy member to avoid compiler errors*/
WILC_Uint8 dummy;
} tstrWILC_MemoryAttrs;
/*!
* @brief Fills the tstrWILC_MemoryAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa tstrWILC_MemoryAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
static void WILC_MemoryFillDefault(tstrWILC_MemoryAttrs *pstrAttrs)
{
#ifdef CONFIG_WILC_MEMORY_POOLS
pstrAttrs->pAllocationPool = WILC_NULL;
#endif
}
/*!
* @brief Allocates a given size of bytes
* @param[in] u32Size size of memory in bytes to be allocated
* @param[in] strAttrs Optional attributes, NULL for default
* if not NULL, pAllocationPool should point to the pool to use for
* this allocation. if NULL memory will be allocated directly from
* the system
* @param[in] pcFileName file name of the calling code for debugging
* @param[in] u32LineNo line number of the calling code for debugging
* @return The new allocated block, NULL if allocation fails
* @note It is recommended to use of of the wrapper macros instead of
* calling this function directly
* @sa sttrWILC_MemoryAttrs
* @sa WILC_MALLOC
* @sa WILC_MALLOC_EX
* @sa WILC_NEW
* @sa WILC_NEW_EX
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
/*!
* @brief Allocates a given size of bytes and zero filling it
* @param[in] u32Size size of memory in bytes to be allocated
* @param[in] strAttrs Optional attributes, NULL for default
* if not NULL, pAllocationPool should point to the pool to use for
* this allocation. if NULL memory will be allocated directly from
* the system
* @param[in] pcFileName file name of the calling code for debugging
* @param[in] u32LineNo line number of the calling code for debugging
* @return The new allocated block, NULL if allocation fails
* @note It is recommended to use of of the wrapper macros instead of
* calling this function directly
* @sa sttrWILC_MemoryAttrs
* @sa WILC_CALLOC
* @sa WILC_CALLOC_EX
* @sa WILC_NEW_0
* @sa WILC_NEW_0_EX
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
/*!
* @brief Reallocates a given block to a new size
* @param[in] pvOldBlock the old memory block, if NULL then this function
* behaves as a new allocation function
* @param[in] u32NewSize size of the new memory block in bytes, if zero then
* this function behaves as a free function
* @param[in] strAttrs Optional attributes, NULL for default
* if pAllocationPool!=NULL and pvOldBlock==NULL, pAllocationPool
* should point to the pool to use for this allocation.
* if pAllocationPool==NULL and pvOldBlock==NULL memory will be
* allocated directly from the system
* if and pvOldBlock!=NULL, pAllocationPool will not be inspected
* and reallocation is done from the same pool as the original block
* @param[in] pcFileName file name of the calling code for debugging
* @param[in] u32LineNo line number of the calling code for debugging
* @return The new allocated block, possibly same as pvOldBlock
* @note It is recommended to use of of the wrapper macros instead of
* calling this function directly
* @sa sttrWILC_MemoryAttrs
* @sa WILC_REALLOC
* @sa WILC_REALLOC_EX
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize,
tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
/*!
* @brief Frees given block
* @param[in] pvBlock the memory block to be freed
* @param[in] strAttrs Optional attributes, NULL for default
* @param[in] pcFileName file name of the calling code for debugging
* @param[in] u32LineNo line number of the calling code for debugging
* @note It is recommended to use of of the wrapper macros instead of
* calling this function directly
* @sa sttrWILC_MemoryAttrs
* @sa WILC_FREE
* @sa WILC_FREE_EX
* @sa WILC_FREE_SET_NULL
* @sa WILC_FREE_IF_TRUE
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
/*!
* @brief Creates a new memory pool
* @param[out] pHandle the handle to the new Pool
* @param[in] u32PoolSize The pool size in bytes
* @param[in] strAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa sttrWILC_MemoryAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MemoryNewPool(WILC_MemoryPoolHandle *pHandle, WILC_Uint32 u32PoolSize,
tstrWILC_MemoryAttrs *strAttrs);
/*!
* @brief Deletes a memory pool, freeing all memory allocated from it as well
* @param[in] pHandle the handle to the deleted Pool
* @param[in] strAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa sttrWILC_MemoryAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MemoryDelPool(WILC_MemoryPoolHandle *pHandle, tstrWILC_MemoryAttrs *strAttrs);
#ifdef CONFIG_WILC_MEMORY_DEBUG
/*!
* @brief standrad malloc wrapper with custom attributes
*/
#define WILC_MALLOC_EX(__size__, __attrs__) \
(WILC_MemoryAlloc( \
(__size__), __attrs__, \
(WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__))
/*!
* @brief standrad calloc wrapper with custom attributes
*/
#define WILC_CALLOC_EX(__size__, __attrs__) \
(WILC_MemoryCalloc( \
(__size__), __attrs__, \
(WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__))
/*!
* @brief standrad realloc wrapper with custom attributes
*/
#define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \
(WILC_MemoryRealloc( \
(__ptr__), (__new_size__), __attrs__, \
(WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__))
/*!
* @brief standrad free wrapper with custom attributes
*/
#define WILC_FREE_EX(__ptr__, __attrs__) \
(WILC_MemoryFree( \
(__ptr__), __attrs__, \
(WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__))
#else
/*!
* @brief standrad malloc wrapper with custom attributes
*/
#define WILC_MALLOC_EX(__size__, __attrs__) \
(WILC_MemoryAlloc( \
(__size__), __attrs__, WILC_NULL, 0))
/*!
* @brief standrad calloc wrapper with custom attributes
*/
#define WILC_CALLOC_EX(__size__, __attrs__) \
(WILC_MemoryCalloc( \
(__size__), __attrs__, WILC_NULL, 0))
/*!
* @brief standrad realloc wrapper with custom attributes
*/
#define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \
(WILC_MemoryRealloc( \
(__ptr__), (__new_size__), __attrs__, WILC_NULL, 0))
/*!
* @brief standrad free wrapper with custom attributes
*/
#define WILC_FREE_EX(__ptr__, __attrs__) \
(WILC_MemoryFree( \
(__ptr__), __attrs__, WILC_NULL, 0))
#endif
/*!
* @brief Allocates a block (with custom attributes) of given type and number of
* elements
*/
#define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \
((__struct_type__ *)WILC_MALLOC_EX( \
sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__))
/*!
* @brief Allocates a block (with custom attributes) of given type and number of
* elements and Zero-fills it
*/
#define WILC_NEW_0_EX(__struct_type__, __n_structs__, __attrs__) \
((__struct_type__ *)WILC_CALLOC_EX( \
sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__))
/*!
* @brief Frees a block (with custom attributes), also setting the original pointer
* to NULL
*/
#define WILC_FREE_SET_NULL_EX(__ptr__, __attrs__) do { \
if (__ptr__ != WILC_NULL) { \
WILC_FREE_EX(__ptr__, __attrs__); \
__ptr__ = WILC_NULL; \
} \
} while (0)
/*!
* @brief Frees a block (with custom attributes) if the pointer expression evaluates
* to true
*/
#define WILC_FREE_IF_TRUE_EX(__ptr__, __attrs__) do { \
if (__ptr__ != WILC_NULL) { \
WILC_FREE_EX(__ptr__, __attrs__); \
} \
} while (0)
/*!
* @brief standrad malloc wrapper with default attributes
*/
#define WILC_MALLOC(__size__) \
WILC_MALLOC_EX(__size__, WILC_NULL)
/*!
* @brief standrad calloc wrapper with default attributes
*/
#define WILC_CALLOC(__size__) \
WILC_CALLOC_EX(__size__, WILC_NULL)
/*!
* @brief standrad realloc wrapper with default attributes
*/
#define WILC_REALLOC(__ptr__, __new_size__) \
WILC_REALLOC_EX(__ptr__, __new_size__, WILC_NULL)
/*!
* @brief standrad free wrapper with default attributes
*/
#define WILC_FREE(__ptr__) \
WILC_FREE_EX(__ptr__, WILC_NULL)
/*!
* @brief Allocates a block (with default attributes) of given type and number of
* elements
*/
#define WILC_NEW(__struct_type__, __n_structs__) \
WILC_NEW_EX(__struct_type__, __n_structs__, WILC_NULL)
/*!
* @brief Allocates a block (with default attributes) of given type and number of
* elements and Zero-fills it
*/
#define WILC_NEW_0(__struct_type__, __n_structs__) \
WILC_NEW_O_EX(__struct_type__, __n_structs__, WILC_NULL)
/*!
* @brief Frees a block (with default attributes), also setting the original pointer
* to NULL
*/
#define WILC_FREE_SET_NULL(__ptr__) \
WILC_FREE_SET_NULL_EX(__ptr__, WILC_NULL)
/*!
* @brief Frees a block (with default attributes) if the pointer expression evaluates
* to true
*/
#define WILC_FREE_IF_TRUE(__ptr__) \
WILC_FREE_IF_TRUE_EX(__ptr__, WILC_NULL)
#endif

View File

@ -0,0 +1,211 @@
#include "wilc_oswrapper.h"
#include <linux/spinlock.h>
#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle,
tstrWILC_MsgQueueAttrs *pstrAttrs)
{
tstrWILC_SemaphoreAttrs strSemAttrs;
WILC_SemaphoreFillDefault(&strSemAttrs);
strSemAttrs.u32InitCount = 0;
spin_lock_init(&pHandle->strCriticalSection);
if ((WILC_SemaphoreCreate(&pHandle->hSem, &strSemAttrs) == WILC_SUCCESS)) {
pHandle->pstrMessageList = NULL;
pHandle->u32ReceiversCount = 0;
pHandle->bExiting = WILC_FALSE;
return WILC_SUCCESS;
} else {
return WILC_FAIL;
}
}
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle,
tstrWILC_MsgQueueAttrs *pstrAttrs)
{
pHandle->bExiting = WILC_TRUE;
/* Release any waiting receiver thread. */
while (pHandle->u32ReceiversCount > 0) {
WILC_SemaphoreRelease(&(pHandle->hSem), WILC_NULL);
pHandle->u32ReceiversCount--;
}
WILC_SemaphoreDestroy(&pHandle->hSem, WILC_NULL);
while (pHandle->pstrMessageList != NULL) {
Message *pstrMessge = pHandle->pstrMessageList->pstrNext;
WILC_FREE(pHandle->pstrMessageList);
pHandle->pstrMessageList = pstrMessge;
}
return WILC_SUCCESS;
}
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle,
const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize,
tstrWILC_MsgQueueAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
unsigned long flags;
Message *pstrMessage = NULL;
if ((pHandle == NULL) || (u32SendBufferSize == 0) || (pvSendBuffer == NULL)) {
WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
}
if (pHandle->bExiting == WILC_TRUE) {
WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
}
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
/* construct a new message */
pstrMessage = WILC_NEW(Message, 1);
WILC_NULLCHECK(s32RetStatus, pstrMessage);
pstrMessage->u32Length = u32SendBufferSize;
pstrMessage->pstrNext = NULL;
pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize);
WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer);
WILC_memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);
/* add it to the message queue */
if (pHandle->pstrMessageList == NULL) {
pHandle->pstrMessageList = pstrMessage;
} else {
Message *pstrTailMsg = pHandle->pstrMessageList;
while (pstrTailMsg->pstrNext != NULL) {
pstrTailMsg = pstrTailMsg->pstrNext;
}
pstrTailMsg->pstrNext = pstrMessage;
}
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL);
WILC_CATCH(s32RetStatus)
{
/* error occured, free any allocations */
if (pstrMessage != NULL) {
if (pstrMessage->pvBuffer != NULL) {
WILC_FREE(pstrMessage->pvBuffer);
}
WILC_FREE(pstrMessage);
}
}
return s32RetStatus;
}
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize,
WILC_Uint32 *pu32ReceivedLength,
tstrWILC_MsgQueueAttrs *pstrAttrs)
{
Message *pstrMessage;
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
tstrWILC_SemaphoreAttrs strSemAttrs;
unsigned long flags;
if ((pHandle == NULL) || (u32RecvBufferSize == 0)
|| (pvRecvBuffer == NULL) || (pu32ReceivedLength == NULL)) {
WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
}
if (pHandle->bExiting == WILC_TRUE) {
WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
}
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
pHandle->u32ReceiversCount++;
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
WILC_SemaphoreFillDefault(&strSemAttrs);
#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT
if (pstrAttrs != WILC_NULL) {
strSemAttrs.u32TimeOut = pstrAttrs->u32Timeout;
}
#endif
s32RetStatus = WILC_SemaphoreAcquire(&(pHandle->hSem), &strSemAttrs);
if (s32RetStatus == WILC_TIMEOUT) {
/* timed out, just exit without consumeing the message */
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
pHandle->u32ReceiversCount--;
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
} else {
/* other non-timeout scenarios */
WILC_ERRORCHECK(s32RetStatus);
if (pHandle->bExiting) {
WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
}
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
pstrMessage = pHandle->pstrMessageList;
if (pstrMessage == NULL) {
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
}
/* check buffer size */
if (u32RecvBufferSize < pstrMessage->u32Length) {
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL);
WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW);
}
/* consume the message */
pHandle->u32ReceiversCount--;
WILC_memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length);
*pu32ReceivedLength = pstrMessage->u32Length;
pHandle->pstrMessageList = pstrMessage->pstrNext;
WILC_FREE(pstrMessage->pvBuffer);
WILC_FREE(pstrMessage);
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
}
WILC_CATCH(s32RetStatus)
{
}
return s32RetStatus;
}
#endif

View File

@ -0,0 +1,133 @@
#ifndef __WILC_MSG_QUEUE_H__
#define __WILC_MSG_QUEUE_H__
/*!
* @file wilc_msgqueue.h
* @brief Message Queue OS wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 30 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_MSG_QUEUE_FEATURE
#error the feature CONFIG_WILC_MSG_QUEUE_FEATURE must be supported to include this file
#endif
/*!
* @struct tstrWILC_MsgQueueAttrs
* @brief Message Queue API options
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
typedef struct {
#ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME
WILC_Char *pcName;
#endif
#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT
WILC_Uint32 u32Timeout;
#endif
/* a dummy member to avoid compiler errors*/
WILC_Uint8 dummy;
} tstrWILC_MsgQueueAttrs;
/*!
* @brief Fills the MsgQueueAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa WILC_TimerAttrs
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
static void WILC_MsgQueueFillDefault(tstrWILC_MsgQueueAttrs *pstrAttrs)
{
#ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME
pstrAttrs->pcName = WILC_NULL;
#endif
#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT
pstrAttrs->u32Timeout = WILC_OS_INFINITY;
#endif
}
/*!
* @brief Creates a new Message queue
* @details Creates a new Message queue, if the feature
* CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and pstrAttrs->pcName
* is not Null, then this message queue can be used for IPC with
* any other message queue having the same name in the system
* @param[in,out] pHandle handle to the message queue object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_MsgQueueAttrs
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle,
tstrWILC_MsgQueueAttrs *pstrAttrs);
/*!
* @brief Sends a message
* @details Sends a message, this API will block unil the message is
* actually sent or until it is timedout (as long as the feature
* CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
* is not set to WILC_OS_INFINITY), zero timeout is a valid value
* @param[in] pHandle handle to the message queue object
* @param[in] pvSendBuffer pointer to the data to send
* @param[in] u32SendBufferSize the size of the data to send
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_MsgQueueAttrs
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle,
const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize,
tstrWILC_MsgQueueAttrs *pstrAttrs);
/*!
* @brief Receives a message
* @details Receives a message, this API will block unil a message is
* received or until it is timedout (as long as the feature
* CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
* is not set to WILC_OS_INFINITY), zero timeout is a valid value
* @param[in] pHandle handle to the message queue object
* @param[out] pvRecvBuffer pointer to a buffer to fill with the received message
* @param[in] u32RecvBufferSize the size of the receive buffer
* @param[out] pu32ReceivedLength the length of received data
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_MsgQueueAttrs
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize,
WILC_Uint32 *pu32ReceivedLength,
tstrWILC_MsgQueueAttrs *pstrAttrs);
/*!
* @brief Destroys an existing Message queue
* @param[in] pHandle handle to the message queue object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa tstrWILC_MsgQueueAttrs
* @author syounan
* @date 30 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle,
tstrWILC_MsgQueueAttrs *pstrAttrs);
#endif

View File

@ -0,0 +1,55 @@
/*
* Automatically generated C config: don't edit
* Tue Aug 10 19:52:12 2010
*/
/* OSes supported */
#define WILC_WIN32 0
#define WILC_NU 1
#define WILC_MTK 2
#define WILC_LINUX 3
#define WILC_LINUXKERNEL 4
/* the current OS */
/* #define WILC_PLATFORM WILC_LINUXKERNEL */
/* Logs options */
#define WILC_LOGS_NOTHING 0
#define WILC_LOGS_WARN 1
#define WILC_LOGS_WARN_INFO 2
#define WILC_LOGS_WARN_INFO_DBG 3
#define WILC_LOGS_WARN_INFO_DBG_FN 4
#define WILC_LOGS_ALL 5
#define WILC_LOG_VERBOSITY_LEVEL WILC_LOGS_ALL
/* OS features supported */
#define CONFIG_WILC_THREAD_FEATURE 1
/* #define CONFIG_WILC_THREAD_SUSPEND_CONTROL 1 */
/* #define CONFIG_WILC_THREAD_STRICT_PRIORITY 1 */
#define CONFIG_WILC_SEMAPHORE_FEATURE 1
/* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */
#define CONFIG_WILC_SLEEP_FEATURE 1
#define CONFIG_WILC_SLEEP_HI_RES 1
#define CONFIG_WILC_TIMER_FEATURE 1
/* #define CONFIG_WILC_TIMER_PERIODIC 1 */
#define CONFIG_WILC_MEMORY_FEATURE 1
/* #define CONFIG_WILC_MEMORY_POOLS 1 */
/* #define CONFIG_WILC_MEMORY_DEBUG 1 */
/* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */
#define CONFIG_WILC_STRING_UTILS 1
#define CONFIG_WILC_MSG_QUEUE_FEATURE
/* #define CONFIG_WILC_MSG_QUEUE_IPC_NAME */
/* #define CONFIG_WILC_MSG_QUEUE_TIMEOUT */
/* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */
/* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */
/* #define CONFIG_WILC_FILE_OPERATIONS_PATH_API */
#define CONFIG_WILC_TIME_FEATURE
/* #define CONFIG_WILC_EVENT_FEATURE */
/* #define CONFIG_WILC_EVENT_TIMEOUT */
/* #define CONFIG_WILC_SOCKET_FEATURE */
/* #define CONFIG_WILC_MATH_OPERATIONS_FEATURE */
/* #define CONFIG_WILC_EXTENDED_FILE_OPERATIONS */
/* #define CONFIG_WILC_EXTENDED_STRING_OPERATIONS */
/* #define CONFIG_WILC_EXTENDED_TIME_OPERATIONS */

View File

@ -0,0 +1,133 @@
#ifndef __WILC_OSWRAPPER_H__
#define __WILC_OSWRAPPER_H__
/*!
* @file wilc_oswrapper.h
* @brief Top level OS Wrapper, include this file and it will include all
* other files as necessary
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
/* OS Wrapper interface version */
#define WILC_OSW_INTERFACE_VER 2
/* Integer Types */
typedef unsigned char WILC_Uint8;
typedef unsigned short WILC_Uint16;
typedef unsigned int WILC_Uint32;
typedef unsigned long long WILC_Uint64;
typedef signed char WILC_Sint8;
typedef signed short WILC_Sint16;
typedef signed int WILC_Sint32;
typedef signed long long WILC_Sint64;
/* Floating types */
typedef float WILC_Float;
typedef double WILC_Double;
/* Boolean type */
typedef enum {
WILC_FALSE = 0,
WILC_TRUE = 1
} WILC_Bool;
/* Character types */
typedef char WILC_Char;
typedef WILC_Uint16 WILC_WideChar;
#define WILC_OS_INFINITY (~((WILC_Uint32)0))
#define WILC_NULL ((void *)0)
/* standard min and max macros */
#define WILC_MIN(a, b) (((a) < (b)) ? (a) : (b))
#define WILC_MAX(a, b) (((a) > (b)) ? (a) : (b))
/* Os Configuration File */
#include "wilc_osconfig.h"
/* Platform specific include */
#if WILC_PLATFORM == WILC_WIN32
#include "wilc_platform.h"
#elif WILC_PLATFORM == WILC_NU
#include "wilc_platform.h"
#elif WILC_PLATFORM == WILC_MTK
#include "wilc_platform.h"
#elif WILC_PLATFORM == WILC_LINUX
#include "wilc_platform.h"
#elif WILC_PLATFORM == WILC_LINUXKERNEL
#include "wilc_platform.h"
#else
#error "OS not supported"
#endif
/* Logging Functions */
#include "wilc_log.h"
/* Error reporting and handling support */
#include "wilc_errorsupport.h"
/* Thread support */
#ifdef CONFIG_WILC_THREAD_FEATURE
#include "wilc_thread.h"
#endif
/* Semaphore support */
#ifdef CONFIG_WILC_SEMAPHORE_FEATURE
#include "wilc_semaphore.h"
#endif
/* Sleep support */
#ifdef CONFIG_WILC_SLEEP_FEATURE
#include "wilc_sleep.h"
#endif
/* Timer support */
#ifdef CONFIG_WILC_TIMER_FEATURE
#include "wilc_timer.h"
#endif
/* Memory support */
#ifdef CONFIG_WILC_MEMORY_FEATURE
#include "wilc_memory.h"
#endif
/* String Utilities */
#ifdef CONFIG_WILC_STRING_UTILS
#include "wilc_strutils.h"
#endif
/* Message Queue */
#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE
#include "wilc_msgqueue.h"
#endif
/* File operations */
#ifdef CONFIG_WILC_FILE_OPERATIONS_FEATURE
#include "wilc_fileops.h"
#endif
/* Time operations */
#ifdef CONFIG_WILC_TIME_FEATURE
#include "wilc_time.h"
#endif
/* Event support */
#ifdef CONFIG_WILC_EVENT_FEATURE
#include "wilc_event.h"
#endif
/* Socket operations */
#ifdef CONFIG_WILC_SOCKET_FEATURE
#include "wilc_socket.h"
#endif
/* Math operations */
#ifdef CONFIG_WILC_MATH_OPERATIONS_FEATURE
#include "wilc_math.h"
#endif
#endif

View File

@ -0,0 +1,181 @@
#ifndef __WILC_platfrom_H__
#define __WILC_platfrom_H__
/*!
* @file wilc_platform.h
* @brief platform specific file for Linux port
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 15 Dec 2010
* @version 1.0
*/
/******************************************************************
* Feature support checks
*******************************************************************/
/* CONFIG_WILC_THREAD_FEATURE is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY
#error This feature is not supported by this OS
#endif
/* CONFIG_WILC_SEMAPHORE_FEATURE is implemented */
/* remove the following block when implementing its feature
* #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT
* #error This feature is not supported by this OS
#endif*/
/* CONFIG_WILC_SLEEP_FEATURE is implemented */
/* remove the following block when implementing its feature */
/* #ifdef CONFIG_WILC_SLEEP_HI_RES */
/* #error This feature is not supported by this OS */
/* #endif */
/* CONFIG_WILC_TIMER_FEATURE is implemented */
/* CONFIG_WILC_TIMER_PERIODIC is implemented */
/* CONFIG_WILC_MEMORY_FEATURE is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_MEMORY_POOLS
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_MEMORY_DEBUG
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_ASSERTION_SUPPORT
#error This feature is not supported by this OS
#endif
/* CONFIG_WILC_STRING_UTILS is implemented */
/* CONFIG_WILC_MSG_QUEUE_FEATURE is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
/*#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT
* #error This feature is not supported by this OS
#endif*/
/* CONFIG_WILC_FILE_OPERATIONS_FEATURE is implemented */
/* CONFIG_WILC_FILE_OPERATIONS_STRING_API is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_FILE_OPERATIONS_PATH_API
#error This feature is not supported by this OS
#endif
/* CONFIG_WILC_TIME_FEATURE is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_TIME_CALENDER
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_EVENT_FEATURE
#error This feature is not supported by this OS
#endif
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_EVENT_TIMEOUT
#error This feature is not supported by this OS
#endif
/* CONFIG_WILC_MATH_OPERATIONS_FEATURE is implemented */
/* CONFIG_WILC_EXTENDED_FILE_OPERATIONS is implemented */
/* CONFIG_WILC_EXTENDED_STRING_OPERATIONS is implemented */
/* CONFIG_WILC_EXTENDED_TIME_OPERATIONS is implemented */
/* remove the following block when implementing its feature */
#ifdef CONFIG_WILC_SOCKET_FEATURE
#error This feature is not supported by this OS
#endif
/******************************************************************
* OS specific includes
*******************************************************************/
#define _XOPEN_SOURCE 600
#include <linux/kthread.h>
#include <linux/semaphore.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/stat.h>
#include <linux/time.h>
#include <linux/version.h>
#include "linux/string.h"
/******************************************************************
* OS specific types
*******************************************************************/
typedef struct task_struct *WILC_ThreadHandle;
typedef void *WILC_MemoryPoolHandle;
typedef struct semaphore WILC_SemaphoreHandle;
typedef struct timer_list WILC_TimerHandle;
/* Message Queue type is a structure */
typedef struct __Message_struct {
void *pvBuffer;
WILC_Uint32 u32Length;
struct __Message_struct *pstrNext;
} Message;
typedef struct __MessageQueue_struct {
WILC_SemaphoreHandle hSem;
spinlock_t strCriticalSection;
WILC_Bool bExiting;
WILC_Uint32 u32ReceiversCount;
Message *pstrMessageList;
} WILC_MsgQueueHandle;
/*Time represented in 64 bit format*/
typedef time_t WILC_Time;
/*******************************************************************
* others
********************************************************************/
/* Generic printf function */
#define __WILC_FILE__ __FILE__
#define __WILC_FUNCTION__ __FUNCTION__
#define __WILC_LINE__ __LINE__
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_SEMAPHORE_FEATURE
WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs)
{
tstrWILC_SemaphoreAttrs strDefaultAttrs;
if (pstrAttrs == WILC_NULL) {
WILC_SemaphoreFillDefault(&strDefaultAttrs);
pstrAttrs = &strDefaultAttrs;
}
sema_init(pHandle, pstrAttrs->u32InitCount);
return WILC_SUCCESS;
}
WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs)
{
/* nothing to be done ! */
return WILC_SUCCESS;
}
WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
#ifndef CONFIG_WILC_SEMAPHORE_TIMEOUT
while (down_interruptible(pHandle))
;
#else
if (pstrAttrs == WILC_NULL) {
down(pHandle);
} else {
s32RetStatus = down_timeout(pHandle, msecs_to_jiffies(pstrAttrs->u32TimeOut));
}
#endif
if (s32RetStatus == 0) {
return WILC_SUCCESS;
} else if (s32RetStatus == -ETIME) {
return WILC_TIMEOUT;
} else {
return WILC_FAIL;
}
return WILC_SUCCESS;
}
WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs)
{
up(pHandle);
return WILC_SUCCESS;
}
#endif

View File

@ -0,0 +1,115 @@
#ifndef __WILC_SEMAPHORE_H__
#define __WILC_SEMAPHORE_H__
/*!
* @file wilc_semaphore.h
* @brief Semaphore OS Wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 10 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_SEMAPHORE_FEATURE
#error the feature WILC_OS_FEATURE_SEMAPHORE must be supported to include this file
#endif
/*!
* @struct WILC_SemaphoreAttrs
* @brief Semaphore API options
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
typedef struct {
/*!<
* Initial count when the semaphore is created. default is 1
*/
WILC_Uint32 u32InitCount;
#ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT
/*!<
* Timeout for use with WILC_SemaphoreAcquire, 0 to return immediately and
* WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY
*/
WILC_Uint32 u32TimeOut;
#endif
} tstrWILC_SemaphoreAttrs;
/*!
* @brief Fills the WILC_SemaphoreAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa WILC_SemaphoreAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
static void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs)
{
pstrAttrs->u32InitCount = 1;
#ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT
pstrAttrs->u32TimeOut = WILC_OS_INFINITY;
#endif
}
/*!
* @brief Creates a new Semaphore object
* @param[out] pHandle handle to the newly created semaphore
* @param[in] pstrAttrs Optional attributes, NULL for defaults
* pstrAttrs->u32InitCount controls the initial count
* @return Error code indicating success/failure
* @sa WILC_SemaphoreAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs);
/*!
* @brief Destroyes an existing Semaphore, releasing any resources
* @param[in] pHandle handle to the semaphore object
* @param[in] pstrAttrs Optional attributes, NULL for defaults
* @return Error code indicating success/failure
* @sa WILC_SemaphoreAttrs
* @todo need to define behaviour if the semaphore delayed while it is pending
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs);
/*!
* @brief Acquire the Semaphore object
* @details This function will block until it can Acquire the given
* semaphore, if the feature WILC_OS_FEATURE_SEMAPHORE_TIMEOUT is
* eanbled a timeout value can be passed in pstrAttrs
* @param[in] pHandle handle to the semaphore object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating success/failure
* @sa WILC_SemaphoreAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs);
/*!
* @brief Release the Semaphore object
* @param[in] pHandle handle to the semaphore object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_SemaphoreAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle,
tstrWILC_SemaphoreAttrs *pstrAttrs);
#endif

View File

@ -0,0 +1,36 @@
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_SLEEP_FEATURE
/*
* @author mdaftedar
* @date 10 Aug 2010
* @version 1.0
*/
void WILC_Sleep(WILC_Uint32 u32TimeMilliSec)
{
if (u32TimeMilliSec <= 4000000) {
WILC_Uint32 u32Temp = u32TimeMilliSec * 1000;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)
usleep_range(u32Temp, u32Temp);
#else
udelay(u32Temp);
#endif
} else {
msleep(u32TimeMilliSec);
}
}
#endif
/* #ifdef CONFIG_WILC_SLEEP_HI_RES */
void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec)
{
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)
usleep_range(u32TimeMicoSec, u32TimeMicoSec);
#else
udelay(u32TimeMicoSec);
#endif
}
/* #endif */

View File

@ -0,0 +1,45 @@
#ifndef __WILC_SLEEP_H__
#define __WILC_SLEEP_H__
/*!
* @file wilc_sleep.h
* @brief Sleep OS Wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 10 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_SLEEP_FEATURE
#error the feature WILC_OS_FEATURE_SLEEP must be supported to include this file
#endif
/*!
* @brief forces the current thread to sleep until the given time has elapsed
* @param[in] u32TimeMilliSec Time to sleep in Milli seconds
* @sa WILC_SleepMicrosec
* @author syounan
* @date 10 Aug 2010
* @version 1.0
* @note This function offers a relatively innacurate and low resolution
* sleep, for accurate high resolution sleep use u32TimeMicoSec
*/
void WILC_Sleep(WILC_Uint32 u32TimeMilliSec);
#ifdef CONFIG_WILC_SLEEP_HI_RES
/*!
* @brief forces the current thread to sleep until the given time has elapsed
* @param[in] u32TimeMicoSec Time to sleep in Micro seconds
* @sa WILC_Sleep
* @author syounan
* @date 10 Aug 2010
* @version 1.0
* @note This function offers an acurare high resolution sleep, depends on
* the feature WILC_OS_FEATURE_SLEEP_HI_RES and may not be supported
* on all Operating Systems
*/
void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,431 @@
#define _CRT_SECURE_NO_DEPRECATE
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_STRING_UTILS
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count)
{
return memcmp(pvArg1, pvArg2, u32Count);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count)
{
memcpy(pvTarget, pvSource, u32Count);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count)
{
return memset(pvTarget, u8SetValue, u32Count);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource,
WILC_Uint32 u32Count)
{
return strncat(pcTarget, pcSource, u32Count);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource,
WILC_Uint32 u32Count)
{
return strncpy(pcTarget, pcSource, u32Count);
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2)
{
WILC_Sint32 s32Result;
if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) {
s32Result = 0;
} else if (pcStr1 == WILC_NULL) {
s32Result = -1;
} else if (pcStr2 == WILC_NULL) {
s32Result = 1;
} else {
s32Result = strcmp(pcStr1, pcStr2);
if (s32Result < 0) {
s32Result = -1;
} else if (s32Result > 0) {
s32Result = 1;
}
}
return s32Result;
}
WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
WILC_Uint32 u32Count)
{
WILC_Sint32 s32Result;
if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) {
s32Result = 0;
} else if (pcStr1 == WILC_NULL) {
s32Result = -1;
} else if (pcStr2 == WILC_NULL) {
s32Result = 1;
} else {
s32Result = strncmp(pcStr1, pcStr2, u32Count);
if (s32Result < 0) {
s32Result = -1;
} else if (s32Result > 0) {
s32Result = 1;
}
}
return s32Result;
}
/*
* @author syounan
* @date 1 Nov 2010
* @version 2.0
*/
WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2)
{
WILC_Sint32 s32Result;
if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) {
s32Result = 0;
} else if (pcStr1 == WILC_NULL) {
s32Result = -1;
} else if (pcStr2 == WILC_NULL) {
s32Result = 1;
} else {
WILC_Char cTestedChar1, cTestedChar2;
do {
cTestedChar1 = *pcStr1;
if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) {
/* turn a lower case character to an upper case one */
cTestedChar1 -= 32;
}
cTestedChar2 = *pcStr2;
if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) {
/* turn a lower case character to an upper case one */
cTestedChar2 -= 32;
}
pcStr1++;
pcStr2++;
} while ((cTestedChar1 == cTestedChar2)
&& (cTestedChar1 != 0)
&& (cTestedChar2 != 0));
if (cTestedChar1 > cTestedChar2) {
s32Result = 1;
} else if (cTestedChar1 < cTestedChar2) {
s32Result = -1;
} else {
s32Result = 0;
}
}
return s32Result;
}
/*!
* @author aabozaeid
* @date 8 Dec 2010
* @version 1.0
*/
WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
WILC_Uint32 u32Count)
{
WILC_Sint32 s32Result;
if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) {
s32Result = 0;
} else if (pcStr1 == WILC_NULL) {
s32Result = -1;
} else if (pcStr2 == WILC_NULL) {
s32Result = 1;
} else {
WILC_Char cTestedChar1, cTestedChar2;
do {
cTestedChar1 = *pcStr1;
if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) {
/* turn a lower case character to an upper case one */
cTestedChar1 -= 32;
}
cTestedChar2 = *pcStr2;
if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) {
/* turn a lower case character to an upper case one */
cTestedChar2 -= 32;
}
pcStr1++;
pcStr2++;
u32Count--;
} while ((u32Count > 0)
&& (cTestedChar1 == cTestedChar2)
&& (cTestedChar1 != 0)
&& (cTestedChar2 != 0));
if (cTestedChar1 > cTestedChar2) {
s32Result = 1;
} else if (cTestedChar1 < cTestedChar2) {
s32Result = -1;
} else {
s32Result = 0;
}
}
return s32Result;
}
/*!
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Uint32 WILC_strlen(const WILC_Char *pcStr)
{
return (WILC_Uint32)strlen(pcStr);
}
/*!
* @author bfahmy
* @date 28 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr)
{
return (WILC_Sint32)(simple_strtol(pcStr, NULL, 10));
}
/*
* @author syounan
* @date 1 Nov 2010
* @version 2.0
*/
WILC_ErrNo WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size,
const WILC_Char *pcFormat, ...)
{
va_list argptr;
va_start(argptr, pcFormat);
if (vsnprintf(pcTarget, u32Size, pcFormat, argptr) < 0) {
/* if turncation happens windows does not properly terminate strings */
pcTarget[u32Size - 1] = 0;
}
va_end(argptr);
/* I find no sane way of detecting errors in windows, so let it all succeed ! */
return WILC_SUCCESS;
}
#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS
/**
* @brief
* @details Searches for the first occurrence of the character c in the first n bytes
* of the string pointed to by the argument str.
* Returns a pointer pointing to the first matching character,
* or null if no match was found.
* @param[in]
* @return
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n)
{
return (WILC_Char *) memchr(str, c, (size_t)n);
}
/**
* @brief
* @details Searches for the first occurrence of the character c (an unsigned char)
* in the string pointed to by the argument str.
* The terminating null character is considered to be part of the string.
* Returns a pointer pointing to the first matching character,
* or null if no match was found.
* @param[in]
* @return
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c)
{
return strchr(str, c);
}
/**
* @brief
* @details Appends the string pointed to by str2 to the end of the string pointed to by str1.
* The terminating null character of str1 is overwritten.
* Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined.
* The argument str1 is returned.
* @param[in] WILC_Char* str1,
* @param[in] WILC_Char* str2,
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2)
{
return strcat(str1, str2);
}
/**
* @brief
* @details Copy pcSource to pcTarget
* @param[in] WILC_Char* pcTarget
* @param[in] const WILC_Char* pcSource
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource)
{
return strncpy(pcTarget, pcSource, strlen(pcSource));
}
/**
* @brief
* @details Finds the first sequence of characters in the string str1 that
* does not contain any character specified in str2.
* Returns the length of this first sequence of characters found that
* do not match with str2.
* @param[in] const WILC_Char *str1
* @param[in] const WILC_Char *str2
* @return WILC_Uint32
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2)
{
return (WILC_Uint32)strcspn(str1, str2);
}
#if 0
/**
* @brief
* @details Searches an internal array for the error number errnum and returns a pointer
* to an error message string.
* Returns a pointer to an error message string.
* @param[in] WILC_Sint32 errnum
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strerror(WILC_Sint32 errnum)
{
return strerror(errnum);
}
#endif
/**
* @brief
* @details Finds the first occurrence of the entire string str2
* (not including the terminating null character) which appears in the string str1.
* Returns a pointer to the first occurrence of str2 in str1.
* If no match was found, then a null pointer is returned.
* If str2 points to a string of zero length, then the argument str1 is returned.
* @param[in] const WILC_Char *str1
* @param[in] const WILC_Char *str2
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2)
{
return strstr(str1, str2);
}
#if 0
/**
* @brief
* @details Parses the C string str interpreting its content as a floating point
* number and returns its value as a double.
* If endptr is not a null pointer, the function also sets the value pointed
* by endptr to point to the first character after the number.
* @param[in] const WILC_Char* str
* @param[in] WILC_Char** endptr
* @return WILC_Double
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Double WILC_StringToDouble(const WILC_Char *str, WILC_Char **endptr)
{
return strtod (str, endptr);
}
#endif
/**
* @brief Parses the C string str interpreting its content as an unsigned integral
* number of the specified base, which is returned as an unsigned long int value.
* @details The function first discards as many whitespace characters as necessary
* until the first non-whitespace character is found.
* Then, starting from this character, takes as many characters as possible
* that are valid following a syntax that depends on the base parameter,
* and interprets them as a numerical value.
* Finally, a pointer to the first character following the integer
* representation in str is stored in the object pointed by endptr.
* @param[in] const WILC_Char *str
* @param[in] WILC_Char **endptr
* @param[in] WILC_Sint32 base
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_StringToUint32(const WILC_Char *str, WILC_Char **endptr, WILC_Sint32 base)
{
return simple_strtoul(str, endptr, base);
}
#endif
#endif

View File

@ -0,0 +1,412 @@
#ifndef __WILC_STRUTILS_H__
#define __WILC_STRUTILS_H__
/*!
* @file wilc_strutils.h
* @brief Basic string utilities
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 16 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_STRING_UTILS
#error the feature CONFIG_WILC_STRING_UTILS must be supported to include this file
#endif
/*!
* @brief Compares two memory buffers
* @param[in] pvArg1 pointer to the first memory location
* @param[in] pvArg2 pointer to the second memory location
* @param[in] u32Count the size of the memory buffers
* @return 0 if the 2 buffers are equal, 1 if pvArg1 is bigger than pvArg2,
* -1 if pvArg1 smaller than pvArg2
* @note this function repeats the functionality of standard memcmp
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count);
/*!
* @brief Internal implementation for memory copy
* @param[in] pvTarget the target buffer to which the data is copied into
* @param[in] pvSource pointer to the second memory location
* @param[in] u32Count the size of the data to copy
* @note this function should not be used directly, use WILC_memcpy instead
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count);
/*!
* @brief Copies the contents of a memory buffer into another
* @param[in] pvTarget the target buffer to which the data is copied into
* @param[in] pvSource pointer to the second memory location
* @param[in] u32Count the size of the data to copy
* @return WILC_SUCCESS if copy is successfully handeled
* WILC_FAIL if copy failed
* @note this function repeats the functionality of standard memcpy,
* however memcpy is undefined if the two buffers overlap but this
* implementation will check for overlap and report error
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count)
{
if (
(((WILC_Uint8 *)pvTarget <= (WILC_Uint8 *)pvSource)
&& (((WILC_Uint8 *)pvTarget + u32Count) > (WILC_Uint8 *)pvSource))
|| (((WILC_Uint8 *)pvSource <= (WILC_Uint8 *)pvTarget)
&& (((WILC_Uint8 *)pvSource + u32Count) > (WILC_Uint8 *)pvTarget))
) {
/* ovelapped memory, return Error */
return WILC_FAIL;
} else {
WILC_memcpy_INTERNAL(pvTarget, pvSource, u32Count);
return WILC_SUCCESS;
}
}
/*!
* @brief Sets the contents of a memory buffer with the given value
* @param[in] pvTarget the target buffer which contsnts will be set
* @param[in] u8SetValue the value to be used
* @param[in] u32Count the size of the memory buffer
* @return value of pvTarget
* @note this function repeats the functionality of standard memset
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count);
/*!
* @brief Concatenates the contents of 2 strings up to a given count
* @param[in] pcTarget the target string, its null character will be overwritten
* and contents of pcSource will be concatentaed to it
* @param[in] pcSource the source string the will be concatentaed
* @param[in] u32Count copying will proceed until a null character in pcSource
* is encountered or u32Count of bytes copied
* @return value of pcTarget
* @note this function repeats the functionality of standard strncat
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource,
WILC_Uint32 u32Count);
/*!
* @brief copies the contents of source string into the target string
* @param[in] pcTarget the target string buffer
* @param[in] pcSource the source string the will be copied
* @param[in] u32Count copying will proceed until a null character in pcSource
* is encountered or u32Count of bytes copied
* @return value of pcTarget
* @note this function repeats the functionality of standard strncpy
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource,
WILC_Uint32 u32Count);
/*!
* @brief Compares two strings
* @details Compares 2 strings reporting which is bigger, WILC_NULL is considered
* the smallest string, then a zero length string then all other
* strings depending on thier ascii characters order
* @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
* -1 if pcStr1 smaller than pcStr2
* @note this function repeats the functionality of standard strcmp
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2);
/*!
* @brief Compares two strings up to u32Count characters
* @details Compares 2 strings reporting which is bigger, WILC_NULL is considered
* the smallest string, then a zero length string then all other
* strings depending on thier ascii characters order with small case
* converted to uppder case
* @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] u32Count copying will proceed until a null character in pcStr1 or
* pcStr2 is encountered or u32Count of bytes copied
* @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
* -1 if pcStr1 smaller than pcStr2
* @author aabozaeid
* @date 7 Dec 2010
* @version 1.0
*/
WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
WILC_Uint32 u32Count);
/*!
* @brief Compares two strings ignoring the case of its latin letters
* @details Compares 2 strings reporting which is bigger, WILC_NULL is considered
* the smallest string, then a zero length string then all other
* strings depending on thier ascii characters order with small case
* converted to uppder case
* @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
* -1 if pcStr1 smaller than pcStr2
* @author syounan
* @date 1 Nov 2010
* @version 2.0
*/
WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2);
/*!
* @brief Compares two strings ignoring the case of its latin letters up to
* u32Count characters
* @details Compares 2 strings reporting which is bigger, WILC_NULL is considered
* the smallest string, then a zero length string then all other
* strings depending on thier ascii characters order with small case
* converted to uppder case
* @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller
* than any other non-NULL string (incliding zero lenght strings)
* @param[in] u32Count copying will proceed until a null character in pcStr1 or
* pcStr2 is encountered or u32Count of bytes copied
* @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
* -1 if pcStr1 smaller than pcStr2
* @author aabozaeid
* @date 7 Dec 2010
* @version 1.0
*/
WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
WILC_Uint32 u32Count);
/*!
* @brief gets the length of a string
* @param[in] pcStr the string
* @return the length
* @note this function repeats the functionality of standard strlen
* @author syounan
* @date 18 Aug 2010
* @version 1.0
*/
WILC_Uint32 WILC_strlen(const WILC_Char *pcStr);
/*!
* @brief convert string to integer
* @param[in] pcStr the string
* @return the value of string
* @note this function repeats the functionality of the libc atoi
* @author bfahmy
* @date 28 Aug 2010
* @version 1.0
*/
WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr);
/*!
* @brief print a formatted string into a buffer
* @param[in] pcTarget the buffer where the resulting string is written
* @param[in] u32Size size of the output beffer including the \0 terminating
* character
* @param[in] pcFormat format of the string
* @return number of character written or would have been written if the
* string were not truncated
* @note this function repeats the functionality of standard snprintf
* @author syounan
* @date 1 Nov 2010
* @version 2.0
*/
WILC_Sint32 WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size,
const WILC_Char *pcFormat, ...);
#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS
/**
* @brief
* @details Searches for the first occurrence of the character c in the first n bytes
* of the string pointed to by the argument str.
* Returns a pointer pointing to the first matching character,
* or null if no match was found.
* @param[in]
* @return
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n);
/**
* @brief
* @details Searches for the first occurrence of the character c (an unsigned char)
* in the string pointed to by the argument str.
* The terminating null character is considered to be part of the string.
* Returns a pointer pointing to the first matching character,
* or null if no match was found.
* @param[in]
* @return
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c);
/**
* @brief
* @details Appends the string pointed to by str2 to the end of the string pointed to by str1.
* The terminating null character of str1 is overwritten.
* Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined.
* The argument str1 is returned.
* @param[in] WILC_Char* str1,
* @param[in] WILC_Char* str2,
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2);
/**
* @brief
* @details Copy pcSource to pcTarget
* @param[in] WILC_Char* pcTarget
* @param[in] const WILC_Char* pcSource
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource);
/**
* @brief
* @details Finds the first sequence of characters in the string str1 that
* does not contain any character specified in str2.
* Returns the length of this first sequence of characters found that
* do not match with str2.
* @param[in] const WILC_Char *str1
* @param[in] const WILC_Char *str2
* @return WILC_Uint32
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2);
/**
* @brief
* @details Searches an internal array for the error number errnum and returns a pointer
* to an error message string.
* Returns a pointer to an error message string.
* @param[in] WILC_Sint32 errnum
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strerror(WILC_Sint32 errnum);
/**
* @brief
* @details Finds the first occurrence of the entire string str2
* (not including the terminating null character) which appears in the string str1.
* Returns a pointer to the first occurrence of str2 in str1.
* If no match was found, then a null pointer is returned.
* If str2 points to a string of zero length, then the argument str1 is returned.
* @param[in] const WILC_Char *str1
* @param[in] const WILC_Char *str2
* @return WILC_Char*
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2);
/**
* @brief
* @details Searches for the first occurrence of the character c (an unsigned char)
* in the string pointed to by the argument str.
* The terminating null character is considered to be part of the string.
* Returns a pointer pointing to the first matching character,
* or null if no match was found.
* @param[in]
* @return
* @note
* @author remil
* @date 3 Nov 2010
* @version 1.0
*/
WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c);
/**
* @brief
* @details Parses the C string str interpreting its content as a floating point
* number and returns its value as a double.
* If endptr is not a null pointer, the function also sets the value pointed
* by endptr to point to the first character after the number.
* @param[in] const WILC_Char* str
* @param[in] WILC_Char** endptr
* @return WILC_Double
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Double WILC_StringToDouble(const WILC_Char *str,
WILC_Char **endptr);
/**
* @brief Parses the C string str interpreting its content as an unsigned integral
* number of the specified base, which is returned as an unsigned long int value.
* @details The function first discards as many whitespace characters as necessary
* until the first non-whitespace character is found.
* Then, starting from this character, takes as many characters as possible
* that are valid following a syntax that depends on the base parameter,
* and interprets them as a numerical value.
* Finally, a pointer to the first character following the integer
* representation in str is stored in the object pointed by endptr.
* @param[in] const WILC_Char *str
* @param[in] WILC_Char **endptr
* @param[in] WILC_Sint32 base
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_StringToUint32(const WILC_Char *str,
WILC_Char **endptr,
WILC_Sint32 base);
#endif
#endif

View File

@ -0,0 +1,35 @@
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_THREAD_FEATURE
WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry,
void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs)
{
*pHandle = kthread_run((int (*)(void *))pfEntry, pvArg, "WILC_kthread");
if (IS_ERR(*pHandle)) {
return WILC_FAIL;
} else {
return WILC_SUCCESS;
}
}
WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle,
tstrWILC_ThreadAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
kthread_stop(*pHandle);
return s32RetStatus;
}
#endif

View File

@ -0,0 +1,153 @@
#ifndef __WILC_THREAD_H__
#define __WILC_THREAD_H__
/*!
* @file wilc_thread.h
* @brief Thread OS Wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 10 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_THREAD_FEATURE
#error the feature WILC_OS_FEATURE_THREAD must be supported to include this file
#endif
typedef void (*tpfWILC_ThreadFunction)(void *);
typedef enum {
#ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY
WILC_OS_THREAD_PIORITY_0 = 0,
WILC_OS_THREAD_PIORITY_1 = 1,
WILC_OS_THREAD_PIORITY_2 = 2,
WILC_OS_THREAD_PIORITY_3 = 3,
WILC_OS_THREAD_PIORITY_4 = 4,
#endif
WILC_OS_THREAD_PIORITY_HIGH = 0,
WILC_OS_THREAD_PIORITY_NORMAL = 2,
WILC_OS_THREAD_PIORITY_LOW = 4
} tenuWILC_ThreadPiority;
/*!
* @struct WILC_ThreadAttrs
* @brief Thread API options
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
typedef struct {
/*!<
* stack size for use with WILC_ThreadCreate, default is WILC_OS_THREAD_DEFAULT_STACK
*/
WILC_Uint32 u32StackSize;
/*!<
* piority for the thread, if WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined
* this value is strictly observed and can take a larger resolution
*/
tenuWILC_ThreadPiority enuPiority;
#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL
/*!
* if true the thread will be created suspended
*/
WILC_Bool bStartSuspended;
#endif
} tstrWILC_ThreadAttrs;
#define WILC_OS_THREAD_DEFAULT_STACK (10 * 1024)
/*!
* @brief Fills the WILC_ThreadAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa WILC_ThreadAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
static void WILC_ThreadFillDefault(tstrWILC_ThreadAttrs *pstrAttrs)
{
pstrAttrs->u32StackSize = WILC_OS_THREAD_DEFAULT_STACK;
pstrAttrs->enuPiority = WILC_OS_THREAD_PIORITY_NORMAL;
#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL
pstrAttrs->bStartSuspended = WILC_FALSE;
#endif
}
/*!
* @brief Creates a new thread
* @details if the feature WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL is
* defined and tstrWILC_ThreadAttrs.bStartSuspended is set to true
* the new thread will be created in suspended state, otherwise
* it will start executing immeadiately
* if the feature WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined
* piorities are strictly observed, otherwise the underlaying OS
* may not observe piorities
* @param[out] pHandle handle to the newly created thread object
* @param[in] pfEntry pointer to the entry point of the new thread
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_ThreadAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry,
void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs);
/*!
* @brief Destroys the Thread object
* @details This function is used for clean up and freeing any used resources
* This function will block until the destroyed thread exits cleanely,
* so, the thread code thould handle an exit case before this calling
* this function
* @param[in] pHandle handle to the thread object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_ThreadAttrs
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle,
tstrWILC_ThreadAttrs *pstrAttrs);
#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL
/*!
* @brief Suspends an executing Thread object
* @param[in] pHandle handle to the thread object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_ThreadAttrs
* @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_ThreadSuspend(WILC_ThreadHandle *pHandle,
tstrWILC_ThreadAttrs *pstrAttrs);
/*!
* @brief Resumes a suspened Thread object
* @param[in] pHandle handle to the thread object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_ThreadAttrs
* @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled
* @author syounan
* @date 10 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_ThreadResume(WILC_ThreadHandle *pHandle,
tstrWILC_ThreadAttrs *pstrAttrs);
#endif
#endif

View File

@ -0,0 +1,163 @@
#define _CRT_SECURE_NO_DEPRECATE
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_TIME_FEATURE
WILC_Uint32 WILC_TimeMsec(void)
{
WILC_Uint32 u32Time = 0;
struct timespec current_time;
current_time = current_kernel_time();
u32Time = current_time.tv_sec * 1000;
u32Time += current_time.tv_nsec / 1000000;
return u32Time;
}
#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS
/**
* @brief
* @details function returns the implementation's best approximation to the
* processor time used by the process since the beginning of an
* implementation-dependent time related only to the process invocation.
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_Clock()
{
}
/**
* @brief
* @details The difftime() function computes the difference between two calendar
* times (as returned by WILC_GetTime()): time1 - time0.
* @param[in] WILC_Time time1
* @param[in] WILC_Time time0
* @return WILC_Double
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0)
{
}
/**
* @brief
* @details The gmtime() function converts the time in seconds since
* the Epoch pointed to by timer into a broken-down time,
* expressed as Coordinated Universal Time (UTC).
* @param[in] const WILC_Time* timer
* @return WILC_tm*
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_tm *WILC_GmTime(const WILC_Time *timer)
{
}
/**
* @brief
* @details The localtime() function converts the time in seconds since
* the Epoch pointed to by timer into a broken-down time, expressed
* as a local time. The function corrects for the timezone and any
* seasonal time adjustments. Local timezone information is used as
* though localtime() calls tzset().
* @param[in] const WILC_Time* timer
* @return WILC_tm*
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_tm *WILC_LocalTime(const WILC_Time *timer)
{
}
/**
* @brief
* @details The mktime() function converts the broken-down time,
* expressed as local time, in the structure pointed to by timeptr,
* into a time since the Epoch value with the same encoding as that
* of the values returned by time(). The original values of the tm_wday
* and tm_yday components of the structure are ignored, and the original
* values of the other components are not restricted to the ranges described
* in the <time.h> entry.
* @param[in] WILC_tm* timer
* @return WILC_Time
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Time WILC_MkTime(WILC_tm *timer)
{
}
/**
* @brief
* @details The strftime() function places bytes into the array
* pointed to by s as controlled by the string pointed to by format.
* @param[in] WILC_Char* s
* @param[in] WILC_Uint32 maxSize
* @param[in] const WILC_Char* format
* @param[in] const WILC_tm* timptr
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_StringFormatTime(WILC_Char *s,
WILC_Uint32 maxSize,
const WILC_Char *format,
const WILC_tm *timptr)
{
}
/**
* @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch.
* @details The tloc argument points to an area where the return value is also stored.
* If tloc is a null pointer, no value is stored.
* @param[in] WILC_Time* tloc
* @return WILC_Time
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Time WILC_GetTime(WILC_Time *tloc)
{
}
#endif
#endif

View File

@ -0,0 +1,205 @@
#ifndef __WILC_TIME_H__
#define __WILC_TIME_H__
/*!
* @file wilc_time.h
* @brief Time retrival functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 2 Sep 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_TIME_FEATURE
#error the feature CONFIG_WILC_TIME_FEATURE must be supported to include this file
#endif
/*!
* @struct WILC_ThreadAttrs
* @brief Thread API options
* @author syounan
* @date 2 Sep 2010
* @version 1.0
*/
typedef struct {
/* a dummy type to prevent compile errors on empty structure*/
WILC_Uint8 dummy;
} tstrWILC_TimeAttrs;
typedef struct {
/*!< current year */
WILC_Uint16 u16Year;
/*!< current month */
WILC_Uint8 u8Month;
/*!< current day */
WILC_Uint8 u8Day;
/*!< current hour (in 24H format) */
WILC_Uint8 u8Hour;
/*!< current minute */
WILC_Uint8 u8Miute;
/*!< current second */
WILC_Uint8 u8Second;
} tstrWILC_TimeCalender;
/*!
* @brief returns the number of msec elapsed since system start up
* @return number of msec elapsed singe system start up
* @note since this returned value is 32 bit, the caller must handle
wraparounds in values every about 49 of continous operations
* @author syounan
* @date 2 Sep 2010
* @version 1.0
*/
WILC_Uint32 WILC_TimeMsec(void);
#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS
/**
* @brief
* @details function returns the implementation's best approximation to the
processor time used by the process since the beginning of an
implementation-dependent time related only to the process invocation.
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_Clock();
/**
* @brief
* @details The difftime() function computes the difference between two calendar
times (as returned by WILC_GetTime()): time1 - time0.
* @param[in] WILC_Time time1
* @param[in] WILC_Time time0
* @return WILC_Double
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0);
/**
* @brief
* @details The gmtime() function converts the time in seconds since
the Epoch pointed to by timer into a broken-down time,
expressed as Coordinated Universal Time (UTC).
* @param[in] const WILC_Time* timer
* @return WILC_tm*
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_tm *WILC_GmTime(const WILC_Time *timer);
/**
* @brief
* @details The localtime() function converts the time in seconds since
the Epoch pointed to by timer into a broken-down time, expressed
as a local time. The function corrects for the timezone and any
seasonal time adjustments. Local timezone information is used as
though localtime() calls tzset().
* @param[in] const WILC_Time* timer
* @return WILC_tm*
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_tm *WILC_LocalTime(const WILC_Time *timer);
/**
* @brief
* @details The mktime() function converts the broken-down time,
expressed as local time, in the structure pointed to by timeptr,
into a time since the Epoch value with the same encoding as that
of the values returned by time(). The original values of the tm_wday
and tm_yday components of the structure are ignored, and the original
values of the other components are not restricted to the ranges described
in the <time.h> entry.
* @param[in] WILC_tm* timer
* @return WILC_Time
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Time WILC_MkTime(WILC_tm *timer);
/**
* @brief
* @details The strftime() function places bytes into the array
pointed to by s as controlled by the string pointed to by format.
* @param[in] WILC_Char* s
* @param[in] WILC_Uint32 maxSize
* @param[in] const WILC_Char* format
* @param[in] const WILC_tm* timptr
* @return WILC_Uint32
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Uint32 WILC_StringFormatTime(WILC_Char *s,
WILC_Uint32 maxSize,
const WILC_Char *format,
const WILC_tm *timptr);
/**
* @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch.
* @details The tloc argument points to an area where the return value is also stored.
If tloc is a null pointer, no value is stored.
* @param[in] WILC_Time* tloc
* @return WILC_Time
* @note
* @author remil
* @date 11 Nov 2010
* @version 1.0
*/
WILC_Time WILC_GetTime(WILC_Time *tloc);
#endif
#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970
/*!
* @brief returns the number of seconds elapsed since 1970 (in UTC)
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return number of seconds elapsed since 1970 (in UTC)
* @sa tstrWILC_TimeAttrs
* @author syounan
* @date 2 Sep 2010
* @version 1.0
*/
WILC_Uint32 WILC_TimeUtcSince1970(tstrWILC_TimeAttrs *pstrAttrs);
#endif
#ifdef CONFIG_WILC_TIME_CALENDER
/*!
* @brief gets the current calender time
* @return number of seconds elapsed since 1970 (in UTC)
* @param[out] ptstrCalender calender structure to be filled with time
* @param[in] pstrAttrs Optional attributes, NULL for default
* @sa WILC_ThreadAttrs
* @author syounan
* @date 2 Sep 2010
* @version 1.0
*/
WILC_ErrNo WILC_TimeCalender(tstrWILC_TimeCalender *ptstrCalender,
tstrWILC_TimeAttrs *pstrAttrs);
#endif
#endif

View File

@ -0,0 +1,51 @@
#include "wilc_oswrapper.h"
#ifdef CONFIG_WILC_TIMER_FEATURE
WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle,
tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
setup_timer(pHandle, (void(*)(unsigned long))pfCallback, 0);
return s32RetStatus;
}
WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle,
tstrWILC_TimerAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_FAIL;
if (pHandle != NULL) {
s32RetStatus = del_timer_sync(pHandle);
pHandle = NULL;
}
return s32RetStatus;
}
WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout,
void *pvArg, tstrWILC_TimerAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_FAIL;
if (pHandle != NULL) {
pHandle->data = (unsigned long)pvArg;
s32RetStatus = mod_timer(pHandle, (jiffies + msecs_to_jiffies(u32Timeout)));
}
return s32RetStatus;
}
WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle,
tstrWILC_TimerAttrs *pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_FAIL;
if (pHandle != NULL)
s32RetStatus = del_timer(pHandle);
return s32RetStatus;
}
#endif

View File

@ -0,0 +1,153 @@
#ifndef __WILC_TIMER_H__
#define __WILC_TIMER_H__
/*!
* @file wilc_timer.h
* @brief Timer (One Shot and Periodic) OS wrapper functionality
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 16 Aug 2010
* @version 1.0
*/
#ifndef CONFIG_WILC_TIMER_FEATURE
#error the feature CONFIG_WILC_TIMER_FEATURE must be supported to include this file
#endif
typedef void (*tpfWILC_TimerFunction)(void *);
/*!
* @struct tstrWILC_TimerAttrs
* @brief Timer API options
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
typedef struct {
/*!< if set to WILC_TRUE the callback function will be called
* periodically. */
#ifdef CONFIG_WILC_TIMER_PERIODIC
WILC_Bool bPeriodicTimer;
#endif
/* a dummy member to avoid compiler errors*/
WILC_Uint8 dummy;
} tstrWILC_TimerAttrs;
/*!
* @brief Fills the WILC_TimerAttrs with default parameters
* @param[out] pstrAttrs structure to be filled
* @sa WILC_TimerAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
static void WILC_TimerFillDefault(tstrWILC_TimerAttrs *pstrAttrs)
{
#ifdef CONFIG_WILC_TIMER_PERIODIC
pstrAttrs->bPeriodicTimer = WILC_FALSE;
#endif
}
/*!
* @brief Creates a new timer
* @details Timers are a useful utility to execute some callback function
* in the future.
* A timer object has 3 states : IDLE, PENDING and EXECUTING
* IDLE : initial timer state after creation, no execution for the
* callback function is planned
* PENDING : a request to execute the callback function is made
* using WILC_TimerStart.
* EXECUTING : the timer has expired and its callback is now
* executing, when execution is done the timer returns to PENDING
* if the feature CONFIG_WILC_TIMER_PERIODIC is enabled and
* the flag tstrWILC_TimerAttrs.bPeriodicTimer is set. otherwise the
* timer will return to IDLE
* @param[out] pHandle handle to the newly created timer object
* @param[in] pfEntry pointer to the callback function to be called when the
* timer expires
* the underlaying OS may put many restrictions on what can be
* called inside a timer's callback, as a general rule no blocking
* operations (IO or semaphore Acquision) should be perfomred
* It is recommended that the callback will be as short as possible
* and only flags other threads to do the actual work
* also it should be noted that the underlaying OS maynot give any
* guarentees on which contect this callback will execute in
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_TimerAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle,
tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs);
/*!
* @brief Destroys a given timer
* @details This will destroy a given timer freeing any resources used by it
* if the timer was PENDING Then must be cancelled as well(i.e.
* goes to IDLE, same effect as calling WILC_TimerCancel first)
* if the timer was EXECUTING then the callback will be allowed to
* finish first then all resources are freed
* @param[in] pHandle handle to the timer object
* @param[in] pstrAttrs Optional attributes, NULL for default
* @return Error code indicating sucess/failure
* @sa WILC_TimerAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle,
tstrWILC_TimerAttrs *pstrAttrs);
/*!
* @brief Starts a given timer
* @details This function will move the timer to the PENDING state until the
* given time expires (in msec) then the callback function will be
* executed (timer in EXECUTING state) after execution is dene the
* timer either goes to IDLE (if bPeriodicTimer==WILC_FALSE) or
* PENDING with same timeout value (if bPeriodicTimer==WILC_TRUE)
* @param[in] pHandle handle to the timer object
* @param[in] u32Timeout timeout value in msec after witch the callback
* function will be executed. Timeout value of 0 is not allowed for
* periodic timers
* @param[in] pstrAttrs Optional attributes, NULL for default,
* set bPeriodicTimer to run this timer as a periodic timer
* @return Error code indicating sucess/failure
* @sa WILC_TimerAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, void *pvArg,
tstrWILC_TimerAttrs *pstrAttrs);
/*!
* @brief Stops a given timer
* @details This function will move the timer to the IDLE state cancelling
* any sheduled callback execution.
* if this function is called on a timer already in the IDLE state
* it will have no effect.
* if this function is called on a timer in EXECUTING state
* (callback has already started) it will wait until executing is
* done then move the timer to the IDLE state (which is trivial
* work if the timer is non periodic)
* @param[in] pHandle handle to the timer object
* @param[in] pstrAttrs Optional attributes, NULL for default,
* @return Error code indicating sucess/failure
* @sa WILC_TimerAttrs
* @author syounan
* @date 16 Aug 2010
* @version 1.0
*/
WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle,
tstrWILC_TimerAttrs *pstrAttrs);
#endif

View File

@ -0,0 +1,34 @@
/* ////////////////////////////////////////////////////////////////////////// */
/* */
/* Copyright (c) Atmel Corporation. All rights reserved. */
/* */
/* Module Name: wilc_type.h */
/* */
/* */
/* //////////////////////////////////////////////////////////////////////////// */
#ifndef WILC_TYPE_H
#define WILC_TYPE_H
/********************************************
*
* Type Defines
*
********************************************/
#ifdef WIN32
typedef char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#else
#ifdef _linux_
/*typedef unsigned char uint8_t;
* typedef unsigned short uint16_t;
* typedef unsigned long uint32_t;*/
#include <stdint.h>
#else
#include "wilc_oswrapper.h"
#endif
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,134 @@
/*!
* @file wilc_wfi_cfgoperations.h
* @brief Definitions for the network module
* @author syounan
* @sa wilc_oswrapper.h top level OS wrapper file
* @date 31 Aug 2010
* @version 1.0
*/
#ifndef NM_WFI_CFGOPERATIONS
#define NM_WFI_CFGOPERATIONS
#include "wilc_wfi_netdevice.h"
#ifdef WILC_FULLY_HOSTING_AP
#include "wilc_host_ap.h"
#endif
/* The following macros describe the bitfield map used by the firmware to determine its 11i mode */
#define NO_ENCRYPT 0
#define ENCRYPT_ENABLED (1 << 0)
#define WEP (1 << 1)
#define WEP_EXTENDED (1 << 2)
#define WPA (1 << 3)
#define WPA2 (1 << 4)
#define AES (1 << 5)
#define TKIP (1 << 6)
#ifdef WILC_P2P
/* #define USE_SUPPLICANT_GO_INTENT */
/*Public action frame index IDs*/
#define FRAME_TYPE_ID 0
#define ACTION_CAT_ID 24
#define ACTION_SUBTYPE_ID 25
#define P2P_PUB_ACTION_SUBTYPE 30
/*Public action frame Attribute IDs*/
#define ACTION_FRAME 0xd0
#define GO_INTENT_ATTR_ID 0x04
#define CHANLIST_ATTR_ID 0x0b
#define OPERCHAN_ATTR_ID 0x11
#ifdef USE_SUPPLICANT_GO_INTENT
#define GROUP_BSSID_ATTR_ID 0x07
#endif
#define PUB_ACTION_ATTR_ID 0x04
#define P2PELEM_ATTR_ID 0xdd
/*Public action subtype values*/
#define GO_NEG_REQ 0x00
#define GO_NEG_RSP 0x01
#define GO_NEG_CONF 0x02
#define P2P_INV_REQ 0x03
#define P2P_INV_RSP 0x04
#define PUBLIC_ACT_VENDORSPEC 0x09
#define GAS_INTIAL_REQ 0x0a
#define GAS_INTIAL_RSP 0x0b
#define INVALID_CHANNEL 0
#ifdef USE_SUPPLICANT_GO_INTENT
#define SUPPLICANT_GO_INTENT 6
#define GET_GO_INTENT(a) (((a) >> 1) & 0x0f)
#define GET_TIE_BREAKER(a) (((a)) & 0x01)
#else
/* #define FORCE_P2P_CLIENT */
#endif
#endif
#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
#define SCAN_RESULT_EXPIRE (40 * HZ)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30)
static const u32 cipher_suites[] = {
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
WLAN_CIPHER_SUITE_AES_CMAC,
};
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
static const struct ieee80211_txrx_stypes
wilc_wfi_cfg80211_mgmt_types[NL80211_IFTYPE_MAX] = {
[NL80211_IFTYPE_STATION] = {
.tx = 0xffff,
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
},
[NL80211_IFTYPE_AP] = {
.tx = 0xffff,
.rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
BIT(IEEE80211_STYPE_DISASSOC >> 4) |
BIT(IEEE80211_STYPE_AUTH >> 4) |
BIT(IEEE80211_STYPE_DEAUTH >> 4) |
BIT(IEEE80211_STYPE_ACTION >> 4)
},
[NL80211_IFTYPE_P2P_CLIENT] = {
.tx = 0xffff,
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
BIT(IEEE80211_STYPE_DISASSOC >> 4) |
BIT(IEEE80211_STYPE_AUTH >> 4) |
BIT(IEEE80211_STYPE_DEAUTH >> 4)
}
};
#endif
/* Time to stay on the channel */
#define WILC_WFI_DWELL_PASSIVE 100
#define WILC_WFI_DWELL_ACTIVE 40
struct wireless_dev *WILC_WFI_CfgAlloc(void);
struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net);
void WILC_WFI_WiphyFree(struct net_device *net);
int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed);
int WILC_WFI_DeInitHostInt(struct net_device *net);
int WILC_WFI_InitHostInt(struct net_device *net);
void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
int WILC_WFI_deinit_mon_interface(void);
struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev);
#ifdef TCP_ENHANCEMENTS
#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
#define DEFAULT_LINK_SPEED 72
extern void Enable_TCP_ACK_Filter(WILC_Bool value);
#endif
#endif

View File

@ -0,0 +1,960 @@
/*!
* @file wilc_wfi_netdevice.c
* @brief File Operations OS wrapper functionality
* @author mdaftedar
* @sa wilc_wfi_netdevice.h
* @date 01 MAR 2012
* @version 1.0
*/
#ifdef SIMULATION
#include "wilc_wfi_cfgoperations.h"
#include "host_interface.h"
MODULE_AUTHOR("Mai Daftedar");
MODULE_LICENSE("Dual BSD/GPL");
struct net_device *WILC_WFI_devs[2];
/*
* Transmitter lockup simulation, normally disabled.
*/
static int lockup;
module_param(lockup, int, 0);
static int timeout = WILC_WFI_TIMEOUT;
module_param(timeout, int, 0);
/*
* Do we run in NAPI mode?
*/
static int use_napi ;
module_param(use_napi, int, 0);
/*
* A structure representing an in-flight packet.
*/
struct WILC_WFI_packet {
struct WILC_WFI_packet *next;
struct net_device *dev;
int datalen;
u8 data[ETH_DATA_LEN];
};
int pool_size = 8;
module_param(pool_size, int, 0);
static void WILC_WFI_TxTimeout(struct net_device *dev);
static void (*WILC_WFI_Interrupt)(int, void *, struct pt_regs *);
/**
* @brief WILC_WFI_SetupPool
* @details Set up a device's packet pool.
* @param[in] struct net_device *dev : Network Device Pointer
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_SetupPool(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
int i;
struct WILC_WFI_packet *pkt;
priv->ppool = NULL;
for (i = 0; i < pool_size; i++) {
pkt = kmalloc (sizeof (struct WILC_WFI_packet), GFP_KERNEL);
if (pkt == NULL) {
PRINT_D(RX_DBG, "Ran out of memory allocating packet pool\n");
return;
}
pkt->dev = dev;
pkt->next = priv->ppool;
priv->ppool = pkt;
}
}
/**
* @brief WILC_WFI_TearDownPool
* @details Internal cleanup function that's called after the network device
* driver is unregistered
* @param[in] struct net_device *dev : Network Device Driver
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_TearDownPool(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
struct WILC_WFI_packet *pkt;
while ((pkt = priv->ppool)) {
priv->ppool = pkt->next;
kfree (pkt);
/* FIXME - in-flight packets ? */
}
}
/**
* @brief WILC_WFI_GetTxBuffer
* @details Buffer/pool management
* @param[in] net_device *dev : Network Device Driver Structure
* @return struct WILC_WFI_packet
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
struct WILC_WFI_packet *WILC_WFI_GetTxBuffer(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
unsigned long flags;
struct WILC_WFI_packet *pkt;
spin_lock_irqsave(&priv->lock, flags);
pkt = priv->ppool;
priv->ppool = pkt->next;
if (priv->ppool == NULL) {
PRINT_INFO(RX_DBG, "Pool empty\n");
netif_stop_queue(dev);
}
spin_unlock_irqrestore(&priv->lock, flags);
return pkt;
}
/**
* @brief WILC_WFI_ReleaseBuffer
* @details Buffer/pool management
* @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_ReleaseBuffer(struct WILC_WFI_packet *pkt)
{
unsigned long flags;
struct WILC_WFI_priv *priv = netdev_priv(pkt->dev);
spin_lock_irqsave(&priv->lock, flags);
pkt->next = priv->ppool;
priv->ppool = pkt;
spin_unlock_irqrestore(&priv->lock, flags);
if (netif_queue_stopped(pkt->dev) && pkt->next == NULL)
netif_wake_queue(pkt->dev);
}
/**
* @brief WILC_WFI_EnqueueBuf
* @details Enqueuing packets in an RX buffer queue
* @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet
* @param[in] net_device *dev : Network Device Driver Structure
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_EnqueueBuf(struct net_device *dev, struct WILC_WFI_packet *pkt)
{
unsigned long flags;
struct WILC_WFI_priv *priv = netdev_priv(dev);
spin_lock_irqsave(&priv->lock, flags);
pkt->next = priv->rx_queue; /* FIXME - misorders packets */
priv->rx_queue = pkt;
spin_unlock_irqrestore(&priv->lock, flags);
}
/**
* @brief WILC_WFI_DequeueBuf
* @details Dequeuing packets from the RX buffer queue
* @param[in] net_device *dev : Network Device Driver Structure
* @return WILC_WFI_packet *pkt : Structure holding in-flight pac
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
struct WILC_WFI_packet *WILC_WFI_DequeueBuf(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
struct WILC_WFI_packet *pkt;
unsigned long flags;
spin_lock_irqsave(&priv->lock, flags);
pkt = priv->rx_queue;
if (pkt != NULL)
priv->rx_queue = pkt->next;
spin_unlock_irqrestore(&priv->lock, flags);
return pkt;
}
/**
* @brief WILC_WFI_RxInts
* @details Enable and disable receive interrupts.
* @param[in] net_device *dev : Network Device Driver Structure
* @param[in] enable : Enable/Disable flag
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
static void WILC_WFI_RxInts(struct net_device *dev, int enable)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
priv->rx_int_enabled = enable;
}
/**
* @brief WILC_WFI_Open
* @details Open Network Device Driver, called when the network
* interface is opened. It starts the interface's transmit queue.
* @param[in] net_device *dev : Network Device Driver Structure
* @param[in] enable : Enable/Disable flag
* @return int : Returns 0 upon success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Open(struct net_device *dev)
{
/* request_region(), request_irq(), .... (like fops->open) */
/*
* Assign the hardware address of the board: use "\0SNULx", where
* x is 0 or 1. The first byte is '\0' to avoid being a multicast
* address (the first byte of multicast addrs is odd).
*/
memcpy(dev->dev_addr, "\0WLAN0", ETH_ALEN);
if (dev == WILC_WFI_devs[1])
dev->dev_addr[ETH_ALEN - 1]++; /* \0SNUL1 */
WILC_WFI_InitHostInt(dev);
netif_start_queue(dev);
return 0;
}
/**
* @brief WILC_WFI_Release
* @details Release Network Device Driver, called when the network
* interface is stopped or brought down. This function marks
* the network driver as not being able to transmit
* @param[in] net_device *dev : Network Device Driver Structure
* @return int : Return 0 on Success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Release(struct net_device *dev)
{
/* release ports, irq and such -- like fops->close */
netif_stop_queue(dev); /* can't transmit any more */
return 0;
}
/**
* @brief WILC_WFI_Config
* @details Configuration changes (passed on by ifconfig)
* @param[in] net_device *dev : Network Device Driver Structure
* @param[in] struct ifmap *map : Contains the ioctl implementation for the
* network driver.
* @return int : Return 0 on Success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Config(struct net_device *dev, struct ifmap *map)
{
if (dev->flags & IFF_UP) /* can't act on a running interface */
return -EBUSY;
/* Don't allow changing the I/O address */
if (map->base_addr != dev->base_addr) {
PRINT_D(RX_DBG, KERN_WARNING "WILC_WFI: Can't change I/O address\n");
return -EOPNOTSUPP;
}
/* Allow changing the IRQ */
if (map->irq != dev->irq) {
dev->irq = map->irq;
/* request_irq() is delayed to open-time */
}
/* ignore other fields */
return 0;
}
/**
* @brief WILC_WFI_Rx
* @details Receive a packet: retrieve, encapsulate and pass over to upper
* levels
* @param[in] net_device *dev : Network Device Driver Structure
* @param[in] WILC_WFI_packet :
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_Rx(struct net_device *dev, struct WILC_WFI_packet *pkt)
{
int i;
struct sk_buff *skb;
struct WILC_WFI_priv *priv = netdev_priv(dev);
s8 rssi;
/*
* The packet has been retrieved from the transmission
* medium. Build an skb around it, so upper layers can handle it
*/
skb = dev_alloc_skb(pkt->datalen + 2);
if (!skb) {
if (printk_ratelimit())
PRINT_D(RX_DBG, "WILC_WFI rx: low on mem - packet dropped\n");
priv->stats.rx_dropped++;
goto out;
}
skb_reserve(skb, 2); /* align IP on 16B boundary */
memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen);
if (priv->monitor_flag) {
PRINT_INFO(RX_DBG, "In monitor device name %s\n", dev->name);
priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy);
PRINT_D(RX_DBG, "VALUE PASSED IN OF HRWD %p\n", priv->hWILCWFIDrv);
/* host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); */
if (INFO) {
for (i = 14; i < skb->len; i++)
PRINT_INFO(RX_DBG, "RXdata[%d] %02x\n", i, skb->data[i]);
}
WILC_WFI_monitor_rx(dev, skb);
return;
}
#if 0
PRINT_D(RX_DBG, "In RX NORMAl Device name %s\n", dev->name);
/* Write metadata, and then pass to the receive level */
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT);
netif_rx(skb);
#endif
out:
return;
}
/**
* @brief WILC_WFI_Poll
* @details The poll implementation
* @param[in] struct napi_struct *napi :
* @param[in] int budget :
* @return int : Return 0 on Success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
static int WILC_WFI_Poll(struct napi_struct *napi, int budget)
{
int npackets = 0;
struct sk_buff *skb;
struct WILC_WFI_priv *priv = container_of(napi, struct WILC_WFI_priv, napi);
struct net_device *dev = priv->dev;
struct WILC_WFI_packet *pkt;
while (npackets < budget && priv->rx_queue) {
pkt = WILC_WFI_DequeueBuf(dev);
skb = dev_alloc_skb(pkt->datalen + 2);
if (!skb) {
if (printk_ratelimit())
PRINT_D(RX_DBG, "WILC_WFI: packet dropped\n");
priv->stats.rx_dropped++;
WILC_WFI_ReleaseBuffer(pkt);
continue;
}
skb_reserve(skb, 2); /* align IP on 16B boundary */
memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen);
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
netif_receive_skb(skb);
/* Maintain stats */
npackets++;
WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT);
WILC_WFI_ReleaseBuffer(pkt);
}
/* If we processed all packets, we're done; tell the kernel and re-enable ints */
if (npackets < budget) {
napi_complete(napi);
WILC_WFI_RxInts(dev, 1);
}
return npackets;
}
/**
* @brief WILC_WFI_Poll
* @details The typical interrupt entry point
* @param[in] struct napi_struct *napi :
* @param[in] int budget :
* @return int : Return 0 on Success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
static void WILC_WFI_RegularInterrupt(int irq, void *dev_id, struct pt_regs *regs)
{
int statusword;
struct WILC_WFI_priv *priv;
struct WILC_WFI_packet *pkt = NULL;
/*
* As usual, check the "device" pointer to be sure it is
* really interrupting.
* Then assign "struct device *dev"
*/
struct net_device *dev = (struct net_device *)dev_id;
/* ... and check with hw if it's really ours */
/* paranoid */
if (!dev)
return;
/* Lock the device */
priv = netdev_priv(dev);
spin_lock(&priv->lock);
/* retrieve statusword: real netdevices use I/O instructions */
statusword = priv->status;
priv->status = 0;
if (statusword & WILC_WFI_RX_INTR) {
/* send it to WILC_WFI_rx for handling */
pkt = priv->rx_queue;
if (pkt) {
priv->rx_queue = pkt->next;
WILC_WFI_Rx(dev, pkt);
}
}
if (statusword & WILC_WFI_TX_INTR) {
/* a transmission is over: free the skb */
WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT);
dev_kfree_skb(priv->skb);
}
/* Unlock the device and we are done */
spin_unlock(&priv->lock);
if (pkt)
WILC_WFI_ReleaseBuffer(pkt); /* Do this outside the lock! */
return;
}
/**
* @brief WILC_WFI_NapiInterrupt
* @details A NAPI interrupt handler
* @param[in] irq:
* @param[in] dev_id:
* @param[in] pt_regs:
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
static void WILC_WFI_NapiInterrupt(int irq, void *dev_id, struct pt_regs *regs)
{
int statusword;
struct WILC_WFI_priv *priv;
/*
* As usual, check the "device" pointer for shared handlers.
* Then assign "struct device *dev"
*/
struct net_device *dev = (struct net_device *)dev_id;
/* ... and check with hw if it's really ours */
/* paranoid */
if (!dev)
return;
/* Lock the device */
priv = netdev_priv(dev);
spin_lock(&priv->lock);
/* retrieve statusword: real netdevices use I/O instructions */
statusword = priv->status;
priv->status = 0;
if (statusword & WILC_WFI_RX_INTR) {
WILC_WFI_RxInts(dev, 0); /* Disable further interrupts */
napi_schedule(&priv->napi);
}
if (statusword & WILC_WFI_TX_INTR) {
/* a transmission is over: free the skb */
WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT);
dev_kfree_skb(priv->skb);
}
/* Unlock the device and we are done */
spin_unlock(&priv->lock);
return;
}
/**
* @brief MI_WFI_HwTx
* @details Transmit a packet (low level interface)
* @param[in] buf:
* @param[in] len:
* @param[in] net_device *dev:
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev)
{
/*
* This function deals with hw details. This interface loops
* back the packet to the other WILC_WFI interface (if any).
* In other words, this function implements the WILC_WFI behaviour,
* while all other procedures are rather device-independent
*/
struct iphdr *ih;
struct net_device *dest;
struct WILC_WFI_priv *priv;
u32 *saddr, *daddr;
struct WILC_WFI_packet *tx_buffer;
/* I am paranoid. Ain't I? */
if (len < sizeof(struct ethhdr) + sizeof(struct iphdr)) {
PRINT_D(RX_DBG, "WILC_WFI: Hmm... packet too short (%i octets)\n",
len);
return;
}
if (0) { /* enable this conditional to look at the data */
int i;
PRINT_D(RX_DBG, "len is %i", len);
for (i = 14; i < len; i++)
PRINT_D(RX_DBG, "TXdata[%d] %02x\n", i, buf[i] & 0xff);
/* PRINT_D(RX_DBG, "\n"); */
}
/*
* Ethhdr is 14 bytes, but the kernel arranges for iphdr
* to be aligned (i.e., ethhdr is unaligned)
*/
ih = (struct iphdr *)(buf + sizeof(struct ethhdr));
saddr = &ih->saddr;
daddr = &ih->daddr;
((u8 *)saddr)[2] ^= 1; /* change the third octet (class C) */
((u8 *)daddr)[2] ^= 1;
ih->check = 0; /* and rebuild the checksum (ip needs it) */
ih->check = ip_fast_csum((unsigned char *)ih, ih->ihl);
if (dev == WILC_WFI_devs[0])
PRINT_D(RX_DBG, "%08x:%05i --> %08x:%05i\n",
ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source),
ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest));
else
PRINT_D(RX_DBG, "%08x:%05i <-- %08x:%05i\n",
ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest),
ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source));
/*
* Ok, now the packet is ready for transmission: first simulate a
* receive interrupt on the twin device, then a
* transmission-done on the transmitting device
*/
dest = WILC_WFI_devs[dev == WILC_WFI_devs[0] ? 1 : 0];
priv = netdev_priv(dest);
tx_buffer = WILC_WFI_GetTxBuffer(dev);
tx_buffer->datalen = len;
memcpy(tx_buffer->data, buf, len);
WILC_WFI_EnqueueBuf(dest, tx_buffer);
if (priv->rx_int_enabled) {
priv->status |= WILC_WFI_RX_INTR;
WILC_WFI_Interrupt(0, dest, NULL);
}
priv = netdev_priv(dev);
priv->tx_packetlen = len;
priv->tx_packetdata = buf;
priv->status |= WILC_WFI_TX_INTR;
if (lockup && ((priv->stats.tx_packets + 1) % lockup) == 0) {
/* Simulate a dropped transmit interrupt */
netif_stop_queue(dev);
PRINT_D(RX_DBG, "Simulate lockup at %ld, txp %ld\n", jiffies,
(unsigned long) priv->stats.tx_packets);
} else
WILC_WFI_Interrupt(0, dev, NULL);
}
/**
* @brief WILC_WFI_Tx
* @details Transmit a packet (called by the kernel)
* @param[in] sk_buff *skb:
* @param[in] net_device *dev:
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev)
{
int len;
char *data, shortpkt[ETH_ZLEN];
struct WILC_WFI_priv *priv = netdev_priv(dev);
/* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
/* if(priv->monitor_flag) */
/* mac80211_hwsim_monitor_rx(skb); */
data = skb->data;
len = skb->len;
if (len < ETH_ZLEN) {
memset(shortpkt, 0, ETH_ZLEN);
memcpy(shortpkt, skb->data, skb->len);
len = ETH_ZLEN;
data = shortpkt;
}
dev->trans_start = jiffies; /* save the timestamp */
/* Remember the skb, so we can free it at interrupt time */
priv->skb = skb;
/* actual deliver of data is device-specific, and not shown here */
WILC_WFI_HwTx(data, len, dev);
return 0; /* Our simple device can not fail */
}
/**
* @brief WILC_WFI_TxTimeout
* @details Deal with a transmit timeout.
* @param[in] net_device *dev:
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_TxTimeout(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
PRINT_D(RX_DBG, "Transmit timeout at %ld, latency %ld\n", jiffies,
jiffies - dev->trans_start);
/* Simulate a transmission interrupt to get things moving */
priv->status = WILC_WFI_TX_INTR;
WILC_WFI_Interrupt(0, dev, NULL);
priv->stats.tx_errors++;
netif_wake_queue(dev);
return;
}
/**
* @brief WILC_WFI_Ioctl
* @details Ioctl commands
* @param[in] net_device *dev:
* @param[in] ifreq *rq
* @param[in] cmd:
* @return int : Return 0 on Success
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
PRINT_D(RX_DBG, "ioctl\n");
return 0;
}
/**
* @brief WILC_WFI_Stat
* @details Return statistics to the caller
* @param[in] net_device *dev:
* @return WILC_WFI_Stats : Return net_device_stats stucture with the
* network device driver private data contents.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
struct net_device_stats *WILC_WFI_Stats(struct net_device *dev)
{
struct WILC_WFI_priv *priv = netdev_priv(dev);
return &priv->stats;
}
/**
* @brief WILC_WFI_RebuildHeader
* @details This function is called to fill up an eth header, since arp is not
* available on the interface
* @param[in] sk_buff *skb:
* @return int : Return 0 on Success
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_RebuildHeader(struct sk_buff *skb)
{
struct ethhdr *eth = (struct ethhdr *) skb->data;
struct net_device *dev = skb->dev;
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
memcpy(eth->h_dest, dev->dev_addr, dev->addr_len);
eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */
return 0;
}
/**
* @brief WILC_WFI_RebuildHeader
* @details This function is called to fill up an eth header, since arp is not
* available on the interface
* @param[in] sk_buff *skb:
* @param[in] struct net_device *dev:
* @param[in] unsigned short type:
* @param[in] const void *saddr,
* @param[in] const void *daddr:
* @param[in] unsigned int len
* @return int : Return 0 on Success
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_Header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *daddr, const void *saddr,
unsigned int len)
{
struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
eth->h_proto = htons(type);
memcpy(eth->h_source, saddr ? saddr : dev->dev_addr, dev->addr_len);
memcpy(eth->h_dest, daddr ? daddr : dev->dev_addr, dev->addr_len);
eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */
return dev->hard_header_len;
}
/**
* @brief WILC_WFI_ChangeMtu
* @details The "change_mtu" method is usually not needed.
* If you need it, it must be like this.
* @param[in] net_device *dev : Network Device Driver Structure
* @param[in] new_mtu :
* @return int : Returns 0 on Success.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_ChangeMtu(struct net_device *dev, int new_mtu)
{
unsigned long flags;
struct WILC_WFI_priv *priv = netdev_priv(dev);
spinlock_t *lock = &priv->lock;
/* check ranges */
if ((new_mtu < 68) || (new_mtu > 1500))
return -EINVAL;
/*
* Do anything you need, and the accept the value
*/
spin_lock_irqsave(lock, flags);
dev->mtu = new_mtu;
spin_unlock_irqrestore(lock, flags);
return 0; /* success */
}
static const struct header_ops WILC_WFI_header_ops = {
.create = WILC_WFI_Header,
.rebuild = WILC_WFI_RebuildHeader,
.cache = NULL, /* disable caching */
};
static const struct net_device_ops WILC_WFI_netdev_ops = {
.ndo_open = WILC_WFI_Open,
.ndo_stop = WILC_WFI_Release,
.ndo_set_config = WILC_WFI_Config,
.ndo_start_xmit = WILC_WFI_Tx,
.ndo_do_ioctl = WILC_WFI_Ioctl,
.ndo_get_stats = WILC_WFI_Stats,
.ndo_change_mtu = WILC_WFI_ChangeMtu,
.ndo_tx_timeout = WILC_WFI_TxTimeout,
};
/**
* @brief WILC_WFI_Init
* @details The init function (sometimes called probe).
* It is invoked by register_netdev()
* @param[in] net_device *dev:
* @return NONE
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_Init(struct net_device *dev)
{
struct WILC_WFI_priv *priv;
/*
* Then, assign other fields in dev, using ether_setup() and some
* hand assignments
*/
ether_setup(dev); /* assign some of the fields */
/* 1- Allocate space */
dev->netdev_ops = &WILC_WFI_netdev_ops;
dev->header_ops = &WILC_WFI_header_ops;
dev->watchdog_timeo = timeout;
/* keep the default flags, just add NOARP */
dev->flags |= IFF_NOARP;
dev->features |= NETIF_F_NO_CSUM;
/*
* Then, initialize the priv field. This encloses the statistics
* and a few private fields.
*/
priv = netdev_priv(dev);
memset(priv, 0, sizeof(struct WILC_WFI_priv));
priv->dev = dev;
netif_napi_add(dev, &priv->napi, WILC_WFI_Poll, 2);
/* The last parameter above is the NAPI "weight". */
spin_lock_init(&priv->lock);
WILC_WFI_RxInts(dev, 1); /* enable receive interrupts */
WILC_WFI_SetupPool(dev);
}
/**
* @brief WILC_WFI_Stat
* @details Return statistics to the caller
* @param[in] net_device *dev:
* @return WILC_WFI_Stats : Return net_device_stats stucture with the
* network device driver private data contents.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
void WILC_WFI_Cleanup(void)
{
int i;
struct WILC_WFI_priv *priv[2];
/*if(hwsim_mon!=NULL)
* {
* PRINT_D(RX_DBG, "Freeing monitor interface\n");
* unregister_netdev(hwsim_mon);
* free_netdev(hwsim_mon);
* }*/
for (i = 0; i < 2; i++) {
priv[i] = netdev_priv(WILC_WFI_devs[i]);
if (WILC_WFI_devs[i]) {
PRINT_D(RX_DBG, "Unregistering\n");
unregister_netdev(WILC_WFI_devs[i]);
WILC_WFI_TearDownPool(WILC_WFI_devs[i]);
free_netdev(WILC_WFI_devs[i]);
PRINT_D(RX_DBG, "[NETDEV]Stopping interface\n");
WILC_WFI_DeInitHostInt(WILC_WFI_devs[i]);
WILC_WFI_WiphyFree(WILC_WFI_devs[i]);
}
}
/* unregister_netdev(hwsim_mon); */
WILC_WFI_deinit_mon_interface();
return;
}
void StartConfigSim(void);
/**
* @brief WILC_WFI_Stat
* @details Return statistics to the caller
* @param[in] net_device *dev:
* @return WILC_WFI_Stats : Return net_device_stats stucture with the
* network device driver private data contents.
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
int WILC_WFI_InitModule(void)
{
int result, i, ret = -ENOMEM;
struct WILC_WFI_priv *priv[2], *netpriv;
struct wireless_dev *wdev;
WILC_WFI_Interrupt = use_napi ? WILC_WFI_NapiInterrupt : WILC_WFI_RegularInterrupt;
char buf[IFNAMSIZ];
for (i = 0; i < 2; i++) {
/* Allocate the net devices */
WILC_WFI_devs[i] = alloc_netdev(sizeof(struct WILC_WFI_priv), "wlan%d",
WILC_WFI_Init);
if (WILC_WFI_devs[i] == NULL)
goto out;
/* priv[i] = netdev_priv(WILC_WFI_devs[i]); */
wdev = WILC_WFI_WiphyRegister(WILC_WFI_devs[i]);
WILC_WFI_devs[i]->ieee80211_ptr = wdev;
netpriv = netdev_priv(WILC_WFI_devs[i]);
netpriv->dev->ieee80211_ptr = wdev;
netpriv->dev->ml_priv = netpriv;
wdev->netdev = netpriv->dev;
/*Registering the net device*/
result = register_netdev(WILC_WFI_devs[i]);
if (result)
PRINT_D(RX_DBG, "WILC_WFI: error %i registering device \"%s\"\n",
result, WILC_WFI_devs[i]->name);
else
ret = 0;
}
/*init atmel driver */
priv[0] = netdev_priv(WILC_WFI_devs[0]);
priv[1] = netdev_priv(WILC_WFI_devs[1]);
if (priv[1]->dev->ieee80211_ptr->wiphy->interface_modes && BIT(NL80211_IFTYPE_MONITOR)) {
/* snprintf(buf, IFNAMSIZ, "mon.%s", priv[1]->dev->name); */
/* WILC_WFI_init_mon_interface(); */
/* priv[1]->monitor_flag = 1; */
}
priv[0]->bCfgScanning = WILC_FALSE;
priv[0]->u32RcvdChCount = 0;
WILC_memset(priv[0]->au8AssociatedBss, 0xFF, ETH_ALEN);
/* ret = host_int_init(&priv[0]->hWILCWFIDrv); */
/*copy handle to the other driver*/
/* priv[1]->hWILCWFIDrv = priv[0]->hWILCWFIDrv; */
if (ret) {
PRINT_ER("Error Init Driver\n");
}
out:
if (ret)
WILC_WFI_Cleanup();
return ret;
}
module_init(WILC_WFI_InitModule);
module_exit(WILC_WFI_Cleanup);
#endif

View File

@ -0,0 +1,277 @@
/*!
* @file wilc_wfi_netdevice.h
* @brief Definitions for the network module
* @author mdaftedar
* @date 01 MAR 2012
* @version 1.0
*/
#ifndef WILC_WFI_NETDEVICE
#define WILC_WFI_NETDEVICE
/* These are the flags in the statusword */
#define WILC_WFI_RX_INTR 0x0001
#define WILC_WFI_TX_INTR 0x0002
/* Default timeout period */
#define WILC_WFI_TIMEOUT 5 /* In jiffies */
#define WILC_MAX_NUM_PMKIDS 16
#define PMKID_LEN 16
#define PMKID_FOUND 1
#define NUM_STA_ASSOCIATED 8
#include <linux/module.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/slab.h> /* kmalloc() */
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */
#include <linux/interrupt.h> /* mark_bh */
#include <linux/time.h>
#include <linux/in.h>
#include <linux/netdevice.h> /* struct device, and other headers */
#include <linux/etherdevice.h> /* eth_type_trans */
#include <linux/ip.h> /* struct iphdr */
#include <linux/tcp.h> /* struct tcphdr */
#include <linux/skbuff.h>
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <net/ieee80211_radiotap.h>
#include <linux/if_arp.h>
#include <linux/in6.h>
#include <asm/checksum.h>
#include "host_interface.h"
#include "wilc_wlan.h"
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30)
#include <net/wireless.h>
#else
#include <linux/wireless.h> /* tony, 2013-06-12 */
#endif
#define FLOW_CONTROL_LOWER_THRESHOLD 128
#define FLOW_CONTROL_UPPER_THRESHOLD 256
/*iftype*/
enum stats_flags {
WILC_WFI_RX_PKT = 1 << 0,
WILC_WFI_TX_PKT = 1 << 1,
};
struct WILC_WFI_stats {
unsigned long rx_packets;
unsigned long tx_packets;
unsigned long rx_bytes;
unsigned long tx_bytes;
u64 rx_time;
u64 tx_time;
};
/*
* This structure is private to each device. It is used to pass
* packets in and out, so there is place for a packet
*/
#define RX_BH_KTHREAD 0
#define RX_BH_WORK_QUEUE 1
#define RX_BH_THREADED_IRQ 2
#define num_reg_frame 2
/*
* If you use RX_BH_WORK_QUEUE on LPC3131: You may lose the first interrupt on
* LPC3131 which is important to get the MAC start status when you are blocked inside
* linux_wlan_firmware_download() which blocks mac_open().
*/
#if defined (NM73131_0_BOARD)
#define RX_BH_TYPE RX_BH_KTHREAD
#elif defined (PANDA_BOARD)
#define RX_BH_TYPE RX_BH_THREADED_IRQ
#else
#define RX_BH_TYPE RX_BH_KTHREAD
#endif
struct wilc_wfi_key {
u8 *key;
u8 *seq;
int key_len;
int seq_len;
u32 cipher;
};
struct wilc_wfi_wep_key {
u8 *key;
u8 key_len;
u8 key_idx;
};
struct sta_info {
WILC_Uint8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
};
#ifdef WILC_P2P
/*Parameters needed for host interface for remaining on channel*/
struct wilc_wfi_p2pListenParams {
struct ieee80211_channel *pstrListenChan;
enum nl80211_channel_type tenuChannelType;
WILC_Uint32 u32ListenDuration;
WILC_Uint64 u64ListenCookie;
WILC_Uint32 u32ListenSessionID;
};
#endif /*WILC_P2P*/
struct WILC_WFI_priv {
struct wireless_dev *wdev;
struct cfg80211_scan_request *pstrScanReq;
#ifdef WILC_P2P
struct wilc_wfi_p2pListenParams strRemainOnChanParams;
WILC_Uint64 u64tx_cookie;
#endif
WILC_Bool bCfgScanning;
WILC_Uint32 u32RcvdChCount;
WILC_Uint8 au8AssociatedBss[ETH_ALEN];
struct sta_info assoc_stainfo;
struct net_device_stats stats;
WILC_Uint8 monitor_flag;
int status;
struct WILC_WFI_packet *ppool;
struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
int rx_int_enabled;
int tx_packetlen;
u8 *tx_packetdata;
struct sk_buff *skb;
spinlock_t lock;
struct net_device *dev;
struct napi_struct napi;
WILC_WFIDrvHandle hWILCWFIDrv;
WILC_WFIDrvHandle hWILCWFIDrv_2;
tstrHostIFpmkidAttr pmkid_list;
struct WILC_WFI_stats netstats;
WILC_Uint8 WILC_WFI_wep_default;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
#define WLAN_KEY_LEN_WEP104 13
#endif
WILC_Uint8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
WILC_Uint8 WILC_WFI_wep_key_len[4];
struct net_device *real_ndev; /* The real interface that the monitor is on */
struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
WILC_Uint8 wilc_groupkey;
/* semaphores */
WILC_SemaphoreHandle SemHandleUpdateStats;
WILC_SemaphoreHandle hSemScanReq;
/* */
WILC_Bool gbAutoRateAdjusted;
WILC_Bool bInP2PlistenState;
};
typedef struct {
WILC_Uint16 frame_type;
WILC_Bool reg;
} struct_frame_reg;
#define NUM_CONCURRENT_IFC 2
typedef struct {
uint8_t aSrcAddress[ETH_ALEN];
uint8_t aBSSID[ETH_ALEN];
uint32_t drvHandler;
struct net_device *wilc_netdev;
} tstrInterfaceInfo;
typedef struct {
int mac_status;
int wilc1000_initialized;
#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
unsigned short dev_irq_num;
#endif
wilc_wlan_oup_t oup;
int close;
uint8_t u8NoIfcs;
tstrInterfaceInfo strInterfaceInfo[NUM_CONCURRENT_IFC];
uint8_t open_ifcs;
struct mutex txq_cs;
/*Added by Amr - BugID_4720*/
struct mutex txq_add_to_head_cs;
spinlock_t txq_spinlock;
struct mutex rxq_cs;
struct mutex hif_cs;
/* struct mutex txq_event; */
struct semaphore rxq_event;
struct semaphore cfg_event;
struct semaphore sync_event;
struct semaphore txq_event;
/* struct completion txq_event; */
#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
struct work_struct rx_work_queue;
#elif (RX_BH_TYPE == RX_BH_KTHREAD)
struct task_struct *rx_bh_thread;
struct semaphore rx_sem;
#endif
struct semaphore rxq_thread_started;
struct semaphore txq_thread_started;
struct task_struct *rxq_thread;
struct task_struct *txq_thread;
unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
/* unsigned char eth_dst_address[6]; */
const struct firmware *wilc_firmware; /* Bug 4703 */
struct net_device *real_ndev;
#ifdef WILC_SDIO
int already_claim;
struct sdio_func *wilc_sdio_func;
#else
struct spi_device *wilc_spidev;
#endif
} linux_wlan_t;
typedef struct {
uint8_t u8IfIdx;
WILC_Uint8 iftype;
int monitor_flag;
int mac_opened;
#ifdef WILC_P2P
struct_frame_reg g_struct_frame_reg[num_reg_frame];
#endif
struct net_device *wilc_netdev;
struct net_device_stats netstats;
} perInterface_wlan_t;
struct WILC_WFI_mon_priv {
struct net_device *real_ndev;
};
extern struct net_device *WILC_WFI_devs[];
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,321 @@
#ifndef WILC_WLAN_H
#define WILC_WLAN_H
#include "wilc_type.h"
#define ISWILC1000(id) (((id & 0xfffff000) == 0x100000) ? 1 : 0)
/********************************************
*
* Mac eth header length
*
********************************************/
#define DRIVER_HANDLER_SIZE 4
#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */
#define SUB_MSDU_HEADER_LENGTH 14
#define SNAP_HDR_LEN 8
#define ETHERNET_HDR_LEN 14
#define WORD_ALIGNMENT_PAD 0
#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + SUB_MSDU_HEADER_LENGTH + \
SNAP_HDR_LEN - ETHERNET_HDR_LEN + WORD_ALIGNMENT_PAD)
/*Bug3959: transmitting mgmt frames received from host*/
#define HOST_HDR_OFFSET 4
#define ETHERNET_HDR_LEN 14
#define IP_HDR_LEN 20
#define IP_HDR_OFFSET ETHERNET_HDR_LEN
#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
#define UDP_HDR_LEN 8
#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN)
#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \
ETH_CONFIG_PKT_HDR_LEN)
#define ACTION 0xD0
#define PROBE_REQ 0x40
#ifdef WILC_FULLY_HOSTING_AP
#define FH_TX_HOST_HDR_OFFSET 24
#endif
/********************************************
*
* Endian Conversion
*
********************************************/
#define BYTE_SWAP(val) ((((val) & 0x000000FF) << 24) + \
(((val) & 0x0000FF00) << 8) + \
(((val) & 0x00FF0000) >> 8) + \
(((val) & 0xFF000000) >> 24))
/********************************************
*
* Register Defines
*
********************************************/
#define WILC_PERIPH_REG_BASE 0x1000
/*BugID_5137*/
#define WILC_CHANGING_VIR_IF (0x108c)
#define WILC_CHIPID (WILC_PERIPH_REG_BASE)
#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400)
#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c)
#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70)
#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74)
#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78)
#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80)
#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84)
#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88)
#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428)
#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
#define WILC_INTR_ENABLE (WILC_INTR_REG_BASE)
#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4)
#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30)
#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40)
#define WILC_VMM_TBL_SIZE 64
#define WILC_VMM_TX_TBL_BASE (0x150400)
#define WILC_VMM_RX_TBL_BASE (0x150500)
#define WILC_VMM_BASE 0x150000
#define WILC_VMM_CORE_CTL (WILC_VMM_BASE)
#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4)
#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10)
#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14)
#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040)
#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44)
#define WILC_SPI_REG_BASE 0xe800
#define WILC_SPI_CTL (WILC_SPI_REG_BASE)
#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4)
#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8)
#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc)
#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10)
#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20)
#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24)
#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c)
#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - WILC_SPI_REG_BASE)
#define WILC_AHB_DATA_MEM_BASE 0x30000
#define WILC_AHB_SHARE_MEM_BASE 0xd0000
#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE /* Bug 4477 fix */
#define WILC_VMM_TBL_RX_SHADOW_SIZE (256) /* Bug 4477 fix */
#define WILC_GP_REG_0 0x149c
#define WILC_GP_REG_1 0x14a0
#define rHAVE_SDIO_IRQ_GPIO_BIT (0)
#define rHAVE_USE_PMU_BIT (1)
#define rHAVE_SLEEP_CLK_SRC_RTC_BIT (2)
#define rHAVE_SLEEP_CLK_SRC_XO_BIT (3)
#define rHAVE_EXT_PA_INV_TX_RX_BIT (4)
#define rHAVE_LEGACY_RF_SETTINGS_BIT (5)
#define rHAVE_XTAL_24_BIT (6)
#define rHAVE_DISABLE_WILC_UART_BIT (7)
#define WILC_HAVE_SDIO_IRQ_GPIO (1 << rHAVE_SDIO_IRQ_GPIO_BIT)
#define WILC_HAVE_USE_PMU (1 << rHAVE_USE_PMU_BIT)
#define WILC_HAVE_SLEEP_CLK_SRC_RTC (1 << rHAVE_SLEEP_CLK_SRC_RTC_BIT)
#define WILC_HAVE_SLEEP_CLK_SRC_XO (1 << rHAVE_SLEEP_CLK_SRC_XO_BIT)
#define WILC_HAVE_EXT_PA_INV_TX_RX (1 << rHAVE_EXT_PA_INV_TX_RX_BIT)
#define WILC_HAVE_LEGACY_RF_SETTINGS (1 << rHAVE_LEGACY_RF_SETTINGS_BIT)
#define WILC_HAVE_XTAL_24 (1 << rHAVE_XTAL_24_BIT)
#define WILC_HAVE_DISABLE_WILC_UART (1 << rHAVE_DISABLE_WILC_UART_BIT)
/********************************************
*
* Wlan Defines
*
********************************************/
#define WILC_CFG_PKT 1
#define WILC_NET_PKT 0
/*Bug3959: transmitting mgmt frames received from host*/
#ifdef WILC_AP_EXTERNAL_MLME
#define WILC_MGMT_PKT 2
#ifdef WILC_FULLY_HOSTING_AP
#define WILC_FH_DATA_PKT 4
#endif
#endif /*WILC_AP_EXTERNAL_MLME*/
#define WILC_CFG_SET 1
#define WILC_CFG_QUERY 0
#define WILC_CFG_RSP 1
#define WILC_CFG_RSP_STATUS 2
#define WILC_CFG_RSP_SCAN 3
#ifdef WILC_SDIO
#define WILC_PLL_TO 4
#else
#define WILC_PLL_TO 2
#endif
#define ABORT_INT (1 << 31)
/*******************************************/
/* E0 and later Interrupt flags. */
/*******************************************/
/*******************************************/
/* E0 and later Interrupt flags. */
/* IRQ Status word */
/* 15:0 = DMA count in words. */
/* 16: INT0 flag */
/* 17: INT1 flag */
/* 18: INT2 flag */
/* 19: INT3 flag */
/* 20: INT4 flag */
/* 21: INT5 flag */
/*******************************************/
#define IRG_FLAGS_OFFSET 16
#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1)
#define INT_0 (1 << (IRG_FLAGS_OFFSET))
#define INT_1 (1 << (IRG_FLAGS_OFFSET + 1))
#define INT_2 (1 << (IRG_FLAGS_OFFSET + 2))
#define INT_3 (1 << (IRG_FLAGS_OFFSET + 3))
#define INT_4 (1 << (IRG_FLAGS_OFFSET + 4))
#define INT_5 (1 << (IRG_FLAGS_OFFSET + 5))
#define MAX_NUM_INT (6)
/*******************************************/
/* E0 and later Interrupt flags. */
/* IRQ Clear word */
/* 0: Clear INT0 */
/* 1: Clear INT1 */
/* 2: Clear INT2 */
/* 3: Clear INT3 */
/* 4: Clear INT4 */
/* 5: Clear INT5 */
/* 6: Select VMM table 1 */
/* 7: Select VMM table 2 */
/* 8: Enable VMM */
/*******************************************/
#define CLR_INT0 (1 << 0)
#define CLR_INT1 (1 << 1)
#define CLR_INT2 (1 << 2)
#define CLR_INT3 (1 << 3)
#define CLR_INT4 (1 << 4)
#define CLR_INT5 (1 << 5)
#define SEL_VMM_TBL0 (1 << 6)
#define SEL_VMM_TBL1 (1 << 7)
#define EN_VMM (1 << 8)
#define DATA_INT_EXT INT_0
#define PLL_INT_EXT INT_1
#define SLEEP_INT_EXT INT_2
#define ALL_INT_EXT (DATA_INT_EXT | PLL_INT_EXT | SLEEP_INT_EXT)
#define NUM_INT_EXT (3)
#define DATA_INT_CLR CLR_INT0
#define PLL_INT_CLR CLR_INT1
#define SLEEP_INT_CLR CLR_INT2
#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM)
#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM)
/*time for expiring the semaphores of cfg packets*/
#define CFG_PKTS_TIMEOUT 2000
/********************************************
*
* Debug Type
*
********************************************/
typedef void (*wilc_debug_func)(uint32_t, char *, ...);
/********************************************
*
* Tx/Rx Queue Structure
*
********************************************/
struct txq_entry_t {
struct txq_entry_t *next;
struct txq_entry_t *prev;
int type;
int tcp_PendingAck_index;
uint8_t *buffer;
int buffer_size;
void *priv;
int status;
void (*tx_complete_func)(void *, int);
};
struct rxq_entry_t {
struct rxq_entry_t *next;
uint8_t *buffer;
int buffer_size;
};
/********************************************
*
* Host IF Structure
*
********************************************/
typedef struct {
int (*hif_init)(wilc_wlan_inp_t *, wilc_debug_func);
int (*hif_deinit)(void *);
int (*hif_read_reg)(uint32_t, uint32_t *);
int (*hif_write_reg)(uint32_t, uint32_t);
int (*hif_block_rx)(uint32_t, uint8_t *, uint32_t);
int (*hif_block_tx)(uint32_t, uint8_t *, uint32_t);
int (*hif_sync)(void);
int (*hif_clear_int)(void);
int (*hif_read_int)(uint32_t *);
int (*hif_clear_int_ext)(uint32_t);
int (*hif_read_size)(uint32_t *);
int (*hif_block_tx_ext)(uint32_t, uint8_t *, uint32_t);
int (*hif_block_rx_ext)(uint32_t, uint8_t *, uint32_t);
int (*hif_sync_ext)(int);
void (*hif_set_max_bus_speed)(void);
void (*hif_set_default_bus_speed)(void);
} wilc_hif_func_t;
/********************************************
*
* Configuration Structure
*
********************************************/
#define MAX_CFG_FRAME_SIZE 1468
typedef struct {
uint8_t ether_header[14];
uint8_t ip_header[20];
uint8_t udp_header[8];
uint8_t wid_header[8];
uint8_t frame[MAX_CFG_FRAME_SIZE];
} wilc_cfg_frame_t;
typedef struct {
int (*wlan_tx)(uint8_t *, uint32_t, wilc_tx_complete_func_t);
} wilc_wlan_cfg_func_t;
typedef struct {
int type;
uint32_t seq_no;
} wilc_cfg_rsp_t;
typedef struct {
int (*cfg_wid_set)(uint8_t *, uint32_t, uint16_t, uint8_t *, int);
int (*cfg_wid_get)(uint8_t *, uint32_t, uint16_t);
int (*cfg_wid_get_val)(uint16_t, uint8_t *, uint32_t);
int (*rx_indicate)(uint8_t *, int, wilc_cfg_rsp_t *);
int (*cfg_init)(wilc_debug_func);
} wilc_cfg_func_t;
#endif

View File

@ -0,0 +1,643 @@
/* ////////////////////////////////////////////////////////////////////////// */
/* */
/* Copyright (c) Atmel Corporation. All rights reserved. */
/* */
/* Module Name: wilc_wlan_cfg.c */
/* */
/* */
/* ///////////////////////////////////////////////////////////////////////// */
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
#include "wilc_wlan_cfg.h"
#include "coreconfigurator.h"
#ifdef WILC_FULLY_HOSTING_AP
#include "wilc_host_ap.h"
void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus);
#endif
/********************************************
*
* Global Data
*
********************************************/
typedef struct {
wilc_debug_func dPrint;
int mac_status;
uint8_t mac_address[7];
uint8_t ip_address[5];
uint8_t bssid[7];
uint8_t ssid[34];
uint8_t firmware_version[129];
uint8_t supp_rate[24];
uint8_t wep_key[28];
uint8_t i_psk[66];
uint8_t hardwareProductVersion[33];
uint8_t phyversion[17];
uint8_t supp_username[21];
uint8_t supp_password[64];
uint8_t assoc_req[256];
uint8_t assoc_rsp[256];
uint8_t firmware_info[8];
uint8_t scan_result[256];
uint8_t scan_result1[256];
} wilc_mac_cfg_t;
static wilc_mac_cfg_t g_mac;
static wilc_cfg_byte_t g_cfg_byte[] = {
{WID_BSS_TYPE, 0},
{WID_CURRENT_TX_RATE, 0},
{WID_CURRENT_CHANNEL, 0},
{WID_PREAMBLE, 0},
{WID_11G_OPERATING_MODE, 0},
{WID_STATUS, 0},
{WID_SCAN_TYPE, 0},
{WID_KEY_ID, 0},
{WID_QOS_ENABLE, 0},
{WID_POWER_MANAGEMENT, 0},
{WID_11I_MODE, 0},
{WID_AUTH_TYPE, 0},
{WID_SITE_SURVEY, 0},
{WID_LISTEN_INTERVAL, 0},
{WID_DTIM_PERIOD, 0},
{WID_ACK_POLICY, 0},
{WID_BCAST_SSID, 0},
{WID_REKEY_POLICY, 0},
{WID_SHORT_SLOT_ALLOWED, 0},
{WID_START_SCAN_REQ, 0},
{WID_RSSI, 0},
{WID_LINKSPEED, 0},
{WID_AUTO_RX_SENSITIVITY, 0},
{WID_DATAFLOW_CONTROL, 0},
{WID_SCAN_FILTER, 0},
{WID_11N_PROT_MECH, 0},
{WID_11N_ERP_PROT_TYPE, 0},
{WID_11N_ENABLE, 0},
{WID_11N_OPERATING_MODE, 0},
{WID_11N_OBSS_NONHT_DETECTION, 0},
{WID_11N_HT_PROT_TYPE, 0},
{WID_11N_RIFS_PROT_ENABLE, 0},
{WID_11N_SMPS_MODE, 0},
{WID_11N_CURRENT_TX_MCS, 0},
{WID_11N_SHORT_GI_ENABLE, 0},
{WID_RIFS_MODE, 0},
{WID_TX_ABORT_CONFIG, 0},
{WID_11N_IMMEDIATE_BA_ENABLED, 0},
{WID_11N_TXOP_PROT_DISABLE, 0},
{WID_NIL, 0}
};
static wilc_cfg_hword_t g_cfg_hword[] = {
{WID_LINK_LOSS_THRESHOLD, 0},
{WID_RTS_THRESHOLD, 0},
{WID_FRAG_THRESHOLD, 0},
{WID_SHORT_RETRY_LIMIT, 0},
{WID_LONG_RETRY_LIMIT, 0},
{WID_BEACON_INTERVAL, 0},
{WID_RX_SENSE, 0},
{WID_ACTIVE_SCAN_TIME, 0},
{WID_PASSIVE_SCAN_TIME, 0},
{WID_SITE_SURVEY_SCAN_TIME, 0},
{WID_JOIN_START_TIMEOUT, 0},
{WID_AUTH_TIMEOUT, 0},
{WID_ASOC_TIMEOUT, 0},
{WID_11I_PROTOCOL_TIMEOUT, 0},
{WID_EAPOL_RESPONSE_TIMEOUT, 0},
{WID_11N_SIG_QUAL_VAL, 0},
{WID_CCA_THRESHOLD, 0},
{WID_NIL, 0}
};
static wilc_cfg_word_t g_cfg_word[] = {
{WID_FAILED_COUNT, 0},
{WID_RETRY_COUNT, 0},
{WID_MULTIPLE_RETRY_COUNT, 0},
{WID_FRAME_DUPLICATE_COUNT, 0},
{WID_ACK_FAILURE_COUNT, 0},
{WID_RECEIVED_FRAGMENT_COUNT, 0},
{WID_MCAST_RECEIVED_FRAME_COUNT, 0},
{WID_FCS_ERROR_COUNT, 0},
{WID_SUCCESS_FRAME_COUNT, 0},
{WID_TX_FRAGMENT_COUNT, 0},
{WID_TX_MULTICAST_FRAME_COUNT, 0},
{WID_RTS_SUCCESS_COUNT, 0},
{WID_RTS_FAILURE_COUNT, 0},
{WID_WEP_UNDECRYPTABLE_COUNT, 0},
{WID_REKEY_PERIOD, 0},
{WID_REKEY_PACKET_COUNT, 0},
{WID_HW_RX_COUNT, 0},
{WID_GET_INACTIVE_TIME, 0},
{WID_NIL, 0}
};
static wilc_cfg_str_t g_cfg_str[] = {
{WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */
{WID_FIRMWARE_VERSION, g_mac.firmware_version},
{WID_OPERATIONAL_RATE_SET, g_mac.supp_rate},
{WID_BSSID, g_mac.bssid}, /* 6 bytes */
{WID_WEP_KEY_VALUE, g_mac.wep_key}, /* 27 bytes */
{WID_11I_PSK, g_mac.i_psk}, /* 65 bytes */
/* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */
{WID_HARDWARE_VERSION, g_mac.hardwareProductVersion},
{WID_MAC_ADDR, g_mac.mac_address},
{WID_PHY_VERSION, g_mac.phyversion},
{WID_SUPP_USERNAME, g_mac.supp_username},
{WID_SUPP_PASSWORD, g_mac.supp_password},
{WID_SITE_SURVEY_RESULTS, g_mac.scan_result},
{WID_SITE_SURVEY_RESULTS, g_mac.scan_result1},
/* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */
{WID_ASSOC_REQ_INFO, g_mac.assoc_req},
{WID_ASSOC_RES_INFO, g_mac.assoc_rsp},
/* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */
{WID_FIRMWARE_INFO, g_mac.firmware_version},
{WID_IP_ADDRESS, g_mac.ip_address},
{WID_NIL, NULL}
};
/********************************************
*
* Configuration Functions
*
********************************************/
static int wilc_wlan_cfg_set_byte(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t val8)
{
uint8_t *buf;
if ((offset + 4) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
buf[2] = 1;
buf[3] = val8;
return 4;
}
static int wilc_wlan_cfg_set_hword(uint8_t *frame, uint32_t offset, uint16_t id, uint16_t val16)
{
uint8_t *buf;
if ((offset + 5) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
buf[2] = 2;
buf[3] = (uint8_t)val16;
buf[4] = (uint8_t)(val16 >> 8);
return 5;
}
static int wilc_wlan_cfg_set_word(uint8_t *frame, uint32_t offset, uint16_t id, uint32_t val32)
{
uint8_t *buf;
if ((offset + 7) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
buf[2] = 4;
buf[3] = (uint8_t)val32;
buf[4] = (uint8_t)(val32 >> 8);
buf[5] = (uint8_t)(val32 >> 16);
buf[6] = (uint8_t)(val32 >> 24);
return 7;
}
static int wilc_wlan_cfg_set_str(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *str, uint32_t size)
{
uint8_t *buf;
if ((offset + size + 3) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
buf[2] = (uint8_t)size;
if ((str != NULL) && (size != 0))
memcpy(&buf[3], str, size);
return (size + 3);
}
static int wilc_wlan_cfg_set_bin(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *b, uint32_t size)
{
uint8_t *buf;
uint32_t i;
uint8_t checksum = 0;
if ((offset + size + 5) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
buf[2] = (uint8_t)size;
buf[3] = (uint8_t)(size >> 8);
if ((b != NULL) && (size != 0)) {
memcpy(&buf[4], b, size);
for (i = 0; i < size; i++) {
checksum += buf[i + 4];
}
}
buf[size + 4] = checksum;
return (size + 5);
}
/********************************************
*
* Configuration Response Functions
*
********************************************/
static void wilc_wlan_parse_response_frame(uint8_t *info, int size)
{
uint32_t wid, len = 0, i = 0;
static int seq;
while (size > 0) {
i = 0;
wid = info[0] | (info[1] << 8);
#ifdef BIG_ENDIAN
wid = BYTE_SWAP(wid);
#endif
PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++);
switch ((wid >> 12) & 0x7) {
case WID_CHAR:
do {
if (g_cfg_byte[i].id == WID_NIL)
break;
if (g_cfg_byte[i].id == wid) {
g_cfg_byte[i].val = info[3];
break;
}
i++;
} while (1);
len = 2;
break;
case WID_SHORT:
do {
if (g_cfg_hword[i].id == WID_NIL)
break;
if (g_cfg_hword[i].id == wid) {
#ifdef BIG_ENDIAN
g_cfg_hword[i].val = (info[3] << 8) | (info[4]);
#else
g_cfg_hword[i].val = info[3] | (info[4] << 8);
#endif
break;
}
i++;
} while (1);
len = 3;
break;
case WID_INT:
do {
if (g_cfg_word[i].id == WID_NIL)
break;
if (g_cfg_word[i].id == wid) {
#ifdef BIG_ENDIAN
g_cfg_word[i].val = (info[3] << 24) | (info[4] << 16) | (info[5] << 8) | (info[6]);
#else
g_cfg_word[i].val = info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24);
#endif
break;
}
i++;
} while (1);
len = 5;
break;
case WID_STR:
do {
if (g_cfg_str[i].id == WID_NIL)
break;
if (g_cfg_str[i].id == wid) {
if (wid == WID_SITE_SURVEY_RESULTS) {
static int toggle;
PRINT_INFO(GENERIC_DBG, "Site survey results received[%d]\n",
size);
PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]toggle[%d]\n", size, toggle);
i += toggle;
toggle ^= 1;
}
memcpy(g_cfg_str[i].str, &info[2], (info[2] + 1));
break;
}
i++;
} while (1);
len = 1 + info[2];
break;
default:
break;
}
size -= (2 + len);
info += (2 + len);
}
return;
}
static int wilc_wlan_parse_info_frame(uint8_t *info, int size)
{
wilc_mac_cfg_t *pd = (wilc_mac_cfg_t *)&g_mac;
uint32_t wid, len;
int type = WILC_CFG_RSP_STATUS;
wid = info[0] | (info[1] << 8);
#if 0
#ifdef BIG_ENDIAN
wid = BYTE_SWAP(wid);
#endif
#endif
len = info[2];
PRINT_INFO(GENERIC_DBG, "Status Len = %d Id= %d\n", len, wid);
if ((len == 1) && (wid == WID_STATUS)) {
pd->mac_status = info[3];
type = WILC_CFG_RSP_STATUS;
}
return type;
}
#if 0
static int wilc_wlan_parse_network_frame(uint8_t *info, int size)
{
wilc_mac_cfg_t *priv = (wilc_mac_cfg_t *)&g_mac;
uint32_t wid, len;
wid = info[0] | (info[1] << 8);
len = info[2] | (info[3] << 8);
/**
* Review: this message is only for AP mode.
* TBD
**/
if (wid == WID_NETWORK_INFO) { /* not send by the firmware */
}
return;
}
#endif
/********************************************
*
* Configuration Exported Functions
*
********************************************/
static int wilc_wlan_cfg_set_wid(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *buf, int size)
{
uint8_t type = (id >> 12) & 0xf;
int ret = 0;
if (type == 0) { /* byte command */
if (size >= 1)
ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf);
} else if (type == 1) { /* half word command */
if (size >= 2)
ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((uint16_t *)buf));
} else if (type == 2) { /* word command */
if (size >= 4)
ret = wilc_wlan_cfg_set_word(frame, offset, id, *((uint32_t *)buf));
} else if (type == 3) { /* string command */
ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size);
} else if (type == 4) { /* binary command */
ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size);
} else {
g_mac.dPrint(N_ERR, "illegal id\n");
}
return ret;
}
static int wilc_wlan_cfg_get_wid(uint8_t *frame, uint32_t offset, uint16_t id)
{
uint8_t *buf;
if ((offset + 2) >= MAX_CFG_FRAME_SIZE)
return 0;
buf = &frame[offset];
buf[0] = (uint8_t)id;
buf[1] = (uint8_t)(id >> 8);
return 2;
}
static int wilc_wlan_cfg_get_wid_value(uint16_t wid, uint8_t *buffer, uint32_t buffer_size)
{
uint32_t type = (wid >> 12) & 0xf;
int i, ret = 0;
if (wid == WID_STATUS) {
*((uint32_t *)buffer) = g_mac.mac_status;
return 4;
}
i = 0;
if (type == 0) { /* byte command */
do {
if (g_cfg_byte[i].id == WID_NIL)
break;
if (g_cfg_byte[i].id == wid) {
memcpy(buffer, &g_cfg_byte[i].val, 1);
ret = 1;
break;
}
i++;
} while (1);
} else if (type == 1) { /* half word command */
do {
if (g_cfg_hword[i].id == WID_NIL)
break;
if (g_cfg_hword[i].id == wid) {
memcpy(buffer, &g_cfg_hword[i].val, 2);
ret = 2;
break;
}
i++;
} while (1);
} else if (type == 2) { /* word command */
do {
if (g_cfg_word[i].id == WID_NIL)
break;
if (g_cfg_word[i].id == wid) {
memcpy(buffer, &g_cfg_word[i].val, 4);
ret = 4;
break;
}
i++;
} while (1);
} else if (type == 3) { /* string command */
do {
if (g_cfg_str[i].id == WID_NIL)
break;
if (g_cfg_str[i].id == wid) {
uint32_t size = g_cfg_str[i].str[0];
if (buffer_size >= size) {
if (g_cfg_str[i].id == WID_SITE_SURVEY_RESULTS) {
static int toggle;
PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]\n",
size);
i += toggle;
toggle ^= 1;
}
memcpy(buffer, &g_cfg_str[i].str[1], size);
ret = size;
}
break;
}
i++;
} while (1);
} else {
g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid);
}
return ret;
}
static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *rsp)
{
int ret = 1;
uint8_t msg_type;
uint8_t msg_id;
uint16_t msg_len;
#ifdef WILC_FULLY_HOSTING_AP
WILC_Uint32 *ptru32Frame;
WILC_Bool bStatus = frame[2];
#ifdef BIG_ENDIAN
ptru32Frame = (frame[4] << 24) | (frame[5] << 16) | (frame[6] << 8) | frame[7];
#else
ptru32Frame = (frame[7] << 24) | (frame[6] << 16) | (frame[5] << 8) | frame[4];
#endif /* BIG_ENDIAN */
#endif /* WILC_FULLY_HOSTING_AP */
msg_type = frame[0];
msg_id = frame[1]; /* seq no */
#ifdef BIG_ENDIAN
msg_len = (frame[2] << 8) | frame[3];
#else
msg_len = (frame[3] << 8) | frame[2];
#endif
frame += 4;
size -= 4;
/**
* The valid types of response messages are 'R' (Response), 'I' (Information), and 'N' (Network Information)
**/
switch (msg_type) {
case 'R':
wilc_wlan_parse_response_frame(frame, size);
rsp->type = WILC_CFG_RSP;
rsp->seq_no = msg_id;
break;
case 'I':
rsp->type = wilc_wlan_parse_info_frame(frame, size);
rsp->seq_no = msg_id;
/*call host interface info parse as well*/
PRINT_INFO(RX_DBG, "Info message received\n");
GnrlAsyncInfoReceived(frame - 4, size + 4);
break;
case 'L':
#ifndef SWITCH_LOG_TERMINAL
PRINT_ER("Unexpected firmware log message received \n");
#else
PRINT_D(FIRM_DBG, "\nFIRMWARE LOGS :\n<<\n%s\n>>\n", frame);
break;
#endif
#if 1
case 'N':
NetworkInfoReceived(frame - 4, size + 4);
rsp->type = 0;
break;
#endif
/*bug3819:*/
case 'S':
PRINT_INFO(RX_DBG, "Scan Notification Received \n");
host_int_ScanCompleteReceived(frame - 4, size + 4);
break;
#ifdef WILC_FULLY_HOSTING_AP
case 'T':
PRINT_INFO(RX_DBG, "TBTT Notification Received \n");
process_tbtt_isr();
break;
case 'A':
PRINT_INFO(RX_DBG, "HOSTAPD ACK Notification Received \n");
WILC_mgm_HOSTAPD_ACK(ptru32Frame, bStatus);
break;
#endif
default:
PRINT_INFO(RX_DBG, "Receive unknown message type[%d-%d-%d-%d-%d-%d-%d-%d]\n",
frame[0], frame[1], frame[2], frame[3], frame[4],
frame[5], frame[6], frame[7]);
rsp->type = 0;
rsp->seq_no = msg_id;
ret = 0;
break;
}
return ret;
}
static int wilc_wlan_cfg_init(wilc_debug_func func)
{
memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t));
g_mac.dPrint = func;
return 1;
}
wilc_cfg_func_t mac_cfg = {
wilc_wlan_cfg_set_wid,
wilc_wlan_cfg_get_wid,
wilc_wlan_cfg_get_wid_value,
wilc_wlan_cfg_indicate_rx,
wilc_wlan_cfg_init,
};

View File

@ -0,0 +1,33 @@
/* ////////////////////////////////////////////////////////////////////////// */
/* */
/* Copyright (c) Atmel Corporation. All rights reserved. */
/* */
/* Module Name: wilc_wlan_cfg.h */
/* */
/* */
/* ///////////////////////////////////////////////////////////////////////// */
#ifndef WILC_WLAN_CFG_H
#define WILC_WLAN_CFG_H
typedef struct {
uint16_t id;
uint16_t val;
} wilc_cfg_byte_t;
typedef struct {
uint16_t id;
uint16_t val;
} wilc_cfg_hword_t;
typedef struct {
uint32_t id;
uint32_t val;
} wilc_cfg_word_t;
typedef struct {
uint32_t id;
uint8_t *str;
} wilc_cfg_str_t;
#endif

View File

@ -0,0 +1,991 @@
/* ////////////////////////////////////////////////////////////////////////// */
/* */
/* Copyright (c) Atmel Corporation. All rights reserved. */
/* */
/* Module Name: wilc_wlan_if.h */
/* */
/* */
/* ///////////////////////////////////////////////////////////////////////// */
#ifndef WILC_WLAN_IF_H
#define WILC_WLAN_IF_H
/*bug 3887: [AP] Allow Management frames to be passed to the host*/
#define WILC_AP_EXTERNAL_MLME
#define WILC_P2P
#define TCP_ENHANCEMENTS
/* #define MEMORY_STATIC */
/* #define WILC_FULLY_HOSTING_AP */
/* #define USE_OLD_SPI_SW */
#include "wilc_type.h"
#include "linux_wlan_common.h"
/********************************************
*
* Debug Flags
*
********************************************/
#define N_INIT 0x00000001
#define N_ERR 0x00000002
#define N_TXQ 0x00000004
#define N_INTR 0x00000008
#define N_RXQ 0x00000010
/********************************************
*
* Host Interface Defines
*
********************************************/
#define HIF_SDIO (0)
#define HIF_SPI (1 << 0)
#define HIF_SDIO_GPIO_IRQ (1 << 2)
/********************************************
*
* Tx/Rx Buffer Size Defines
*
********************************************/
#define CE_TX_BUFFER_SIZE (64 * 1024)
#define CE_RX_BUFFER_SIZE (384 * 1024)
/********************************************
*
* Wlan Interface Defines
*
********************************************/
typedef struct {
uint32_t read_write: 1;
uint32_t function: 3;
uint32_t raw: 1;
uint32_t address: 17;
uint32_t data: 8;
} sdio_cmd52_t;
typedef struct {
/* struct { */
uint32_t read_write: 1;
uint32_t function: 3;
uint32_t block_mode: 1;
uint32_t increment: 1;
uint32_t address: 17;
uint32_t count: 9;
/* } bit; */
uint8_t *buffer;
uint32_t block_size;
} sdio_cmd53_t;
typedef struct {
void (*os_sleep)(uint32_t);
void (*os_atomic_sleep)(uint32_t);
void (*os_debug)(uint8_t *);
void *(*os_malloc)(uint32_t);
void *(*os_malloc_atomic)(uint32_t);
void (*os_free)(void *);
void (*os_lock)(void *);
void (*os_unlock)(void *);
int (*os_wait)(void *, WILC_Uint32);
void (*os_signal)(void *);
void (*os_enter_cs)(void *);
void (*os_leave_cs)(void *);
/*Added by Amr - BugID_4720*/
void (*os_spin_lock)(void *, unsigned long *);
void (*os_spin_unlock)(void *, unsigned long *);
} wilc_wlan_os_func_t;
typedef struct {
int io_type;
int (*io_init)(void *);
void (*io_deinit)(void *);
union {
struct {
int (*sdio_cmd52)(sdio_cmd52_t *);
int (*sdio_cmd53)(sdio_cmd53_t *);
int (*sdio_set_max_speed)(void);
int (*sdio_set_default_speed)(void);
} sdio;
struct {
int (*spi_max_speed)(void);
int (*spi_tx)(uint8_t *, uint32_t);
int (*spi_rx)(uint8_t *, uint32_t);
int (*spi_trx)(uint8_t *, uint8_t *, uint32_t);
} spi;
} u;
} wilc_wlan_io_func_t;
typedef struct {
void (*rx_indicate)(uint8_t *, uint32_t, uint32_t);
void (*rx_complete)(void);
} wilc_wlan_net_func_t;
typedef struct {
void (*mac_indicate)(int);
} wilc_wlan_indicate_func_t;
#define WILC_MAC_INDICATE_STATUS 0x1
#define WILC_MAC_STATUS_INIT -1
#define WILC_MAC_STATUS_READY 0
#define WILC_MAC_STATUS_CONNECT 1
#define WILC_MAC_INDICATE_SCAN 0x2
typedef struct {
void *os_private;
void *hif_critical_section;
uint32_t tx_buffer_size;
void *txq_critical_section;
/*Added by Amr - BugID_4720*/
void *txq_add_to_head_critical_section;
void *txq_spin_lock;
void *txq_wait_event;
#if defined(MEMORY_STATIC)
uint32_t rx_buffer_size;
#endif
void *rxq_critical_section;
void *rxq_wait_event;
void *cfg_wait_event;
} wilc_wlan_os_context_t;
typedef struct {
wilc_wlan_os_context_t os_context;
wilc_wlan_os_func_t os_func;
wilc_wlan_io_func_t io_func;
wilc_wlan_net_func_t net_func;
wilc_wlan_indicate_func_t indicate_func;
} wilc_wlan_inp_t;
#if 0
typedef struct {
int start;
uint32_t id;
void *buffer;
uint32_t buffer_size;
int commit;
} wilc_wlan_cfg_set_t;
typedef struct {
int start;
uint32_t id;
int commit;
} wilc_wlan_cfg_get_t;
typedef struct {
uint32_t id;
void *buffer;
uint32_t buffer_size;
} wilc_wlan_cfg_val_t;
#endif
struct tx_complete_data {
#ifdef WILC_FULLY_HOSTING_AP
struct tx_complete_data *next;
#endif
int size;
void *buff;
uint8_t *pBssid;
struct sk_buff *skb;
};
typedef void (*wilc_tx_complete_func_t)(void *, int);
#define WILC_TX_ERR_NO_BUF (-2)
typedef struct {
int (*wlan_firmware_download)(const uint8_t *, uint32_t);
int (*wlan_start)(void);
int (*wlan_stop)(void);
int (*wlan_add_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
int (*wlan_handle_tx_que)(uint32_t *);
void (*wlan_handle_rx_que)(void);
void (*wlan_handle_rx_isr)(void);
void (*wlan_cleanup)(void);
int (*wlan_cfg_set)(int, uint32_t, uint8_t *, uint32_t, int, uint32_t);
int (*wlan_cfg_get)(int, uint32_t, int, uint32_t);
int (*wlan_cfg_get_value)(uint32_t, uint8_t *, uint32_t);
/*Bug3959: transmitting mgmt frames received from host*/
#if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P)
int (*wlan_add_mgmt_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
#ifdef WILC_FULLY_HOSTING_AP
int (*wlan_add_data_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
#endif
#endif
} wilc_wlan_oup_t;
/********************************************
*
* Wlan Configuration ID
*
********************************************/
#define MAX_SSID_LEN 33
#define MAX_RATES_SUPPORTED 12
#define INFINITE_SLEEP_TIME ((WILC_Uint32)0xFFFFFFFF)
#ifdef WILC_PARSE_SCAN_IN_HOST
typedef enum {
SUPP_RATES_IE = 1,
EXT_SUPP_RATES_IE = 50,
HT_CAPABILITY_IE = 45,
RSN_IE = 48,
WPA_IE = 221,
WMM_IE = 221,
#ifdef WILC_P2P
P2P_IE = 221,
#endif
} BEACON_IE;
#endif
typedef enum {
INFRASTRUCTURE = 0,
INDEPENDENT,
AP,
} BSSTYPE_T;
typedef enum {
RATE_AUTO = 0,
RATE_1MB = 1,
RATE_2MB = 2,
RATE_5MB = 5,
RATE_6MB = 6,
RATE_9MB = 9,
RATE_11MB = 11,
RATE_12MB = 12,
RATE_18MB = 18,
RATE_24MB = 24,
RATE_26MB = 36,
RATE_48MB = 48,
RATE_54MB = 54
} TX_RATE_T;
typedef enum {
B_ONLY_MODE = 0, /* basic rate: 1, 2 Mbps, otherwise: 5, 11 Mbps */
G_ONLY_MODE, /* basic rate: 6, 12, 24 Mbps, otherwise: 9, 18, 36, 48, 54 Mbps */
G_MIXED_11B_1_MODE, /* basic rate: 1, 2, 5.5, 11 Mbps, otherwise: all on */
G_MIXED_11B_2_MODE, /* basic rate: 1, 2, 5, 11, 6, 12, 24 Mbps, otherwise: all on */
} G_OPERATING_MODE_T;
typedef enum {
G_SHORT_PREAMBLE = 0, /* Short Preamble */
G_LONG_PREAMBLE = 1, /* Long Preamble */
G_AUTO_PREAMBLE = 2, /* Auto Preamble Selection */
} G_PREAMBLE_T;
#define MAC_CONNECTED 1
#define MAC_DISCONNECTED 0
/*bug3819: */
#define SCAN_DONE TRUE
typedef enum {
PASSIVE_SCAN = 0,
ACTIVE_SCAN = 1,
} SCANTYPE_T;
typedef enum {
NO_POWERSAVE = 0,
MIN_FAST_PS = 1,
MAX_FAST_PS = 2,
MIN_PSPOLL_PS = 3,
MAX_PSPOLL_PS = 4
} USER_PS_MODE_T;
typedef enum {
CHIP_WAKEDUP = 0,
CHIP_SLEEPING_AUTO = 1,
CHIP_SLEEPING_MANUAL = 2
} CHIP_PS_STATE_T;
typedef enum {
ACQUIRE_ONLY = 0,
ACQUIRE_AND_WAKEUP = 1,
} BUS_ACQUIRE_T;
typedef enum {
RELEASE_ONLY = 0,
RELEASE_ALLOW_SLEEP = 1,
} BUS_RELEASE_T;
typedef enum {
NO_SECURITY = 0,
WEP_40 = 0x3,
WEP_104 = 0x7,
WPA_AES = 0x29,
WPA_TKIP = 0x49,
WPA_AES_TKIP = 0x69, /* Aes or Tkip */
WPA2_AES = 0x31,
WPA2_TKIP = 0x51,
WPA2_AES_TKIP = 0x71, /* Aes or Tkip */
} SECURITY_T;
typedef enum {
OPEN_SYSTEM = 1,
SHARED_KEY = 2,
ANY = 3,
IEEE8021 = 5
} AUTHTYPE_T;
typedef enum {
SITE_SURVEY_1CH = 0,
SITE_SURVEY_ALL_CH = 1,
SITE_SURVEY_OFF = 2
} SITE_SURVEY_T;
typedef enum {
NORMAL_ACK = 0,
NO_ACK,
} ACK_POLICY_T;
typedef enum {
DONT_RESET = 0,
DO_RESET = 1,
NO_REQUEST = 2,
} RESET_REQ_T;
typedef enum {
REKEY_DISABLE = 1,
REKEY_TIME_BASE,
REKEY_PKT_BASE,
REKEY_TIME_PKT_BASE
} RSNA_REKEY_POLICY_T;
typedef enum {
FILTER_NO = 0x00,
FILTER_AP_ONLY = 0x01,
FILTER_STA_ONLY = 0x02
} SCAN_CLASS_FITLER_T;
typedef enum {
PRI_HIGH_RSSI = 0x00,
PRI_LOW_RSSI = 0x04,
PRI_DETECT = 0x08
} SCAN_PRI_T;
typedef enum {
CH_FILTER_OFF = 0x00,
CH_FILTER_ON = 0x10
} CH_FILTER_T;
typedef enum {
AUTO_PROT = 0, /* Auto */
NO_PROT, /* Do not use any protection */
ERP_PROT, /* Protect all ERP frame exchanges */
HT_PROT, /* Protect all HT frame exchanges */
GF_PROT, /* Protect all GF frame exchanges */
} N_PROTECTION_MODE_T;
typedef enum {
G_SELF_CTS_PROT,
G_RTS_CTS_PROT,
} G_PROTECTION_MODE_T;
typedef enum {
HT_MIXED_MODE = 1,
HT_ONLY_20MHZ_MODE,
HT_ONLY_20_40MHZ_MODE,
} N_OPERATING_MODE_T;
typedef enum {
NO_DETECT = 0,
DETECT_ONLY = 1,
DETECT_PROTECT = 2,
DETECT_PROTECT_REPORT = 3,
} N_OBSS_DETECTION_T;
typedef enum {
RTS_CTS_NONHT_PROT = 0, /* RTS-CTS at non-HT rate */
FIRST_FRAME_NONHT_PROT, /* First frame at non-HT rate */
LSIG_TXOP_PROT, /* LSIG TXOP Protection */
FIRST_FRAME_MIXED_PROT, /* First frame at Mixed format */
} N_PROTECTION_TYPE_T;
typedef enum {
STATIC_MODE = 1,
DYNAMIC_MODE = 2,
MIMO_MODE = 3, /* power save disable */
} N_SMPS_MODE_T;
typedef enum {
DISABLE_SELF_CTS,
ENABLE_SELF_CTS,
DISABLE_TX_ABORT,
ENABLE_TX_ABORT,
HW_TRIGGER_ABORT,
SW_TRIGGER_ABORT,
} TX_ABORT_OPTION_T;
typedef enum {
WID_CHAR = 0,
WID_SHORT = 1,
WID_INT = 2,
WID_STR = 3,
WID_BIN_DATA = 4,
WID_BIN = 5,
WID_IP = 6,
WID_ADR = 7,
WID_UNDEF = 8,
WID_TYPE_FORCE_32BIT = 0xFFFFFFFF
} WID_TYPE_T, tenuWIDtype;
typedef enum {
WID_NIL = 0xffff,
/* BSS Type */
/* -------------------------------------------------------------- */
/* Configuration : Infrastructure Independent Access Point */
/* Values to set : 0 1 2 */
/* -------------------------------------------------------------- */
WID_BSS_TYPE = 0x0000,
/* Transmit Rate */
/* -------------------------------------------------------------- */
/* Configuration : 1 2 5.5 11 6 9 12 18 24 36 48 54 */
/* Values to set : 1 2 5 11 6 9 12 18 24 36 48 54 */
/* -------------------------------------------------------------- */
WID_CURRENT_TX_RATE = 0x0001,
/* Channel */
/* ------------------------------------------------------------------- */
/* Configuration(g) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
/* Values to set : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
/* -------------------------------------------------------------------- */
WID_CURRENT_CHANNEL = 0x0002,
/* Preamble */
/* -------------------------------------------------------------- */
/* Configuration : short long Auto */
/* Values to set : 0 1 2 */
/* -------------------------------------------------------------- */
WID_PREAMBLE = 0x0003,
/* 11g operating mode (ignored if 11g not present) */
/* -------------------------------------------------------------- */
/* Configuration : HighPerf Compat(RSet #1) Compat(RSet #2) */
/* Values to set : 1 2 3 */
/* -------------------------------------------------------------- */
WID_11G_OPERATING_MODE = 0x0004,
/* Mac status (response only) */
/* -------------------------------------------------------------- */
/* Configuration : disconnect connect */
/* Values to get : 0 1 */
/* -------------------------------------------------------------- */
WID_STATUS = 0x0005,
/* Scan type */
/* -------------------------------------------------------------- */
/* Configuration : Passive Scanning Active Scanning */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_SCAN_TYPE = 0x0007,
/* Key Id (WEP default key Id) */
/* -------------------------------------------------------------- */
/* Configuration : Any value between 0 to 3 */
/* Values to set : Same value. Default is 0 */
/* -------------------------------------------------------------- */
WID_KEY_ID = 0x0009,
/* QoS Enable */
/* -------------------------------------------------------------- */
/* Configuration : QoS Disable WMM Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_QOS_ENABLE = 0x000A,
/* Power Management */
/* ------------------------------------------------------------------ */
/* Configuration : NO_POWERSAVE MIN_POWERSAVE MAX_POWERSAVE */
/* Values to set : 0 1 2 */
/* ------------------------------------------------------------------ */
WID_POWER_MANAGEMENT = 0x000B,
/* WEP/802 11I Configuration */
/* ------------------------------------------------------------------ */
/* Configuration : Disable WP40 WP104 WPA-AES WPA-TKIP RSN-AES RSN-TKIP */
/* Values (0x) : 00 03 07 29 49 31 51 */
/* */
/* Configuration : WPA-AES+TKIP RSN-AES+TKIP */
/* Values (0x) : 69 71 */
/* ------------------------------------------------------------------ */
WID_11I_MODE = 0x000C,
/* WEP Configuration: Used in BSS STA mode only when WEP is enabled */
/* ------------------------------------------------------------------ */
/* Configuration : Open System Shared Key Any Type | 802.1x Auth */
/* Values (0x) : 01 02 03 | BIT2 */
/* ------------------------------------------------------------------ */
WID_AUTH_TYPE = 0x000D,
/* Site Survey Type */
/* -------------------------------------------------------------- */
/* Configuration : Values to set */
/* Survey 1 Channel : 0 */
/* survey all Channels : 1 */
/* Disable Site Survey : 2 */
/* -------------------------------------------------------------- */
WID_SITE_SURVEY = 0x000E,
/* Listen Interval */
/* -------------------------------------------------------------- */
/* Configuration : Any value between 1 to 255 */
/* Values to set : Same value. Default is 3 */
/* -------------------------------------------------------------- */
WID_LISTEN_INTERVAL = 0x000F,
/* DTIM Period */
/* -------------------------------------------------------------- */
/* Configuration : Any value between 1 to 255 */
/* Values to set : Same value. Default is 3 */
/* -------------------------------------------------------------- */
WID_DTIM_PERIOD = 0x0010,
/* ACK Policy */
/* -------------------------------------------------------------- */
/* Configuration : Normal Ack No Ack */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_ACK_POLICY = 0x0011,
/* Reset MAC (Set only) */
/* -------------------------------------------------------------- */
/* Configuration : Don't Reset Reset No Request */
/* Values to set : 0 1 2 */
/* -------------------------------------------------------------- */
WID_RESET = 0x0012,
/* Broadcast SSID Option: Setting this will adhere to "" SSID element */
/* ------------------------------------------------------------------ */
/* Configuration : Enable Disable */
/* Values to set : 1 0 */
/* ------------------------------------------------------------------ */
WID_BCAST_SSID = 0x0015,
/* Disconnect (Station) */
/* ------------------------------------------------------------------ */
/* Configuration : Association ID */
/* Values to set : Association ID */
/* ------------------------------------------------------------------ */
WID_DISCONNECT = 0x0016,
/* 11a Tx Power Level */
/* -------------------------------------------------------------------- */
/* Configuration : Sets TX Power (Higher the value greater the power) */
/* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/
/* -------------------------------------------------------------------- */
WID_TX_POWER_LEVEL_11A = 0x0018,
/* Group Key Update Policy Selection */
/* -------------------------------------------------------------------- */
/* Configuration : Disabled timeBased packetBased timePacketBased */
/* Values to set : 1 2 3 4 */
/* -------------------------------------------------------------------- */
WID_REKEY_POLICY = 0x0019,
/* Allow Short Slot */
/* -------------------------------------------------------------- */
/* Configuration : Disallow Short Slot Allow Short Slot */
/* (Enable Only Long Slot) (Enable Short Slot if applicable)*/
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_SHORT_SLOT_ALLOWED = 0x001A,
WID_PHY_ACTIVE_REG = 0x001B,
/* 11b Tx Power Level */
/* -------------------------------------------------------------------- */
/* Configuration : Sets TX Power (Higher the value greater the power) */
/* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/
/* -------------------------------------------------------------------- */
WID_TX_POWER_LEVEL_11B = 0x001D,
/* Scan Request */
/* -------------------------------------------------------------------- */
/* Configuration : Request default scan */
/* Values to set : 0 */
/* -------------------------------------------------------------------- */
WID_START_SCAN_REQ = 0x001E,
/* Rssi (get only) */
/* -------------------------------------------------------------------- */
/* Configuration : */
/* Values to get : Rssi value */
/* -------------------------------------------------------------------- */
WID_RSSI = 0x001F,
/* Join Request */
/* -------------------------------------------------------------------- */
/* Configuration : Request to join */
/* Values to set : index of scan result */
/* -------------------------------------------------------------------- */
WID_JOIN_REQ = 0x0020,
WID_LINKSPEED = 0x0026,
/* Enable User Control of TX Power */
/* -------------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------------- */
WID_USER_CONTROL_ON_TX_POWER = 0x0027,
WID_MEMORY_ACCESS_8BIT = 0x0029,
/* Enable Auto RX Sensitivity feature */
/* -------------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------------- */
WID_AUTO_RX_SENSITIVITY = 0x0032,
/* Receive Buffer Based Ack */
/* -------------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------------- */
WID_DATAFLOW_CONTROL = 0x0033,
/* Scan Filter */
/* -------------------------------------------------------------------- */
/* Configuration : Class No filter AP only Station Only */
/* Values to set : 0 1 2 */
/* Configuration : Priority High Rssi Low Rssi Detect */
/* Values to set : 0 0x4 0x08 */
/* Configuration : Channel filter off filter on */
/* Values to set : 0 0x10 */
/* -------------------------------------------------------------------- */
WID_SCAN_FILTER = 0x0036,
/* Link Loss Threshold (measure in the beacon period) */
/* -------------------------------------------------------------------- */
/* Configuration : Any value between 10 and 254 (Set to 255 to disable it) */
/* Values to set : Same value. Default is 10 */
/* -------------------------------------------------------------------- */
WID_LINK_LOSS_THRESHOLD = 0x0037,
/*BugID_4978*/
WID_ABORT_RUNNING_SCAN = 0x003E,
/* NMAC Character WID list */
WID_WPS_START = 0x0043,
/* Protection mode for MAC */
/* -------------------------------------------------------------- */
/* Configuration : Auto No protection ERP HT GF */
/* Values to set : 0 1 2 3 4 */
/* -------------------------------------------------------------- */
WID_11N_PROT_MECH = 0x0080,
/* ERP Protection type for MAC */
/* -------------------------------------------------------------- */
/* Configuration : Self-CTS RTS-CTS */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_11N_ERP_PROT_TYPE = 0x0081,
/* HT Option Enable */
/* -------------------------------------------------------------- */
/* Configuration : HT Enable HT Disable */
/* Values to set : 1 0 */
/* -------------------------------------------------------------- */
WID_11N_ENABLE = 0x0082,
/* 11n Operating mode (Note that 11g operating mode will also be */
/* used in addition to this, if this is set to HT Mixed mode) */
/* -------------------------------------------------------------- */
/* Configuration : HT Mixed HT Only-20MHz HT Only-20/40MHz */
/* Values to set : 1 2 3 */
/* -------------------------------------------------------------- */
WID_11N_OPERATING_MODE = 0x0083,
/* 11n OBSS non-HT STA Detection flag */
/* -------------------------------------------------------------- */
/* Configuration : Do not detect */
/* Values to set : 0 */
/* Configuration : Detect, do not protect or report */
/* Values to set : 1 */
/* Configuration : Detect, protect and do not report */
/* Values to set : 2 */
/* Configuration : Detect, protect and report to other BSS */
/* Values to set : 3 */
/* -------------------------------------------------------------- */
WID_11N_OBSS_NONHT_DETECTION = 0x0084,
/* 11n HT Protection Type */
/* -------------------------------------------------------------- */
/* Configuration : RTS-CTS First Frame Exchange at non-HT-rate */
/* Values to set : 0 1 */
/* Configuration : LSIG TXOP First Frame Exchange in Mixed Fmt */
/* Values to set : 2 3 */
/* -------------------------------------------------------------- */
WID_11N_HT_PROT_TYPE = 0x0085,
/* 11n RIFS Protection Enable Flag */
/* -------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_11N_RIFS_PROT_ENABLE = 0x0086,
/* SMPS Mode */
/* -------------------------------------------------------------- */
/* Configuration : Static Dynamic MIMO (Power Save Disabled) */
/* Values to set : 1 2 3 */
/* -------------------------------------------------------------- */
WID_11N_SMPS_MODE = 0x0087,
/* Current transmit MCS */
/* -------------------------------------------------------------- */
/* Configuration : MCS Index for data rate */
/* Values to set : 0 to 7 */
/* -------------------------------------------------------------- */
WID_11N_CURRENT_TX_MCS = 0x0088,
WID_11N_PRINT_STATS = 0x0089,
/* 11n Short GI Enable Flag */
/* -------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_11N_SHORT_GI_ENABLE = 0x008D,
/* 11n RIFS Enable Flag */
/* -------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_RIFS_MODE = 0x0094,
/* TX Abort Feature */
/* -------------------------------------------------------------- */
/* Configuration : Disable Self CTS Enable Self CTS */
/* Values to set : 0 1 */
/* Configuration : Disable TX Abort Enable TX Abort */
/* Values to set : 2 3 */
/* Configuration : Enable HW TX Abort Enable SW TX Abort */
/* Values to set : 4 5 */
/* -------------------------------------------------------------- */
WID_TX_ABORT_CONFIG = 0x00A1,
WID_REG_TSSI_11B_VALUE = 0x00A6,
WID_REG_TSSI_11G_VALUE = 0x00A7,
WID_REG_TSSI_11N_VALUE = 0x00A8,
WID_TX_CALIBRATION = 0x00A9,
WID_DSCR_TSSI_11B_VALUE = 0x00AA,
WID_DSCR_TSSI_11G_VALUE = 0x00AB,
WID_DSCR_TSSI_11N_VALUE = 0x00AC,
/* Immediate Block-Ack Support */
/* -------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 0 1 */
/* -------------------------------------------------------------- */
WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF,
/* TXOP Disable Flag */
/* -------------------------------------------------------------- */
/* Configuration : Disable Enable */
/* Values to set : 1 0 */
/* -------------------------------------------------------------- */
WID_11N_TXOP_PROT_DISABLE = 0x00B0,
WID_TX_POWER_LEVEL_11N = 0x00B1,
/* Custom Character WID list */
WID_PC_TEST_MODE = 0x00C8,
/*bug3819: */
/* SCAN Complete notification WID*/
WID_SCAN_COMPLETE = 0x00C9,
#ifdef WILC_AP_EXTERNAL_MLME
WID_DEL_BEACON = 0x00CA,
#endif
WID_LOGTerminal_Switch = 0x00CD,
/* EMAC Short WID list */
/* RTS Threshold */
/* -------------------------------------------------------------- */
/* Configuration : Any value between 256 to 2347 */
/* Values to set : Same value. Default is 2347 */
/* -------------------------------------------------------------- */
WID_RTS_THRESHOLD = 0x1000,
/* Fragmentation Threshold */
/* -------------------------------------------------------------- */
/* Configuration : Any value between 256 to 2346 */
/* Values to set : Same value. Default is 2346 */
/* -------------------------------------------------------------- */
WID_FRAG_THRESHOLD = 0x1001,
WID_SHORT_RETRY_LIMIT = 0x1002,
WID_LONG_RETRY_LIMIT = 0x1003,
WID_BEACON_INTERVAL = 0x1006,
WID_MEMORY_ACCESS_16BIT = 0x1008,
WID_RX_SENSE = 0x100B,
WID_ACTIVE_SCAN_TIME = 0x100C,
WID_PASSIVE_SCAN_TIME = 0x100D,
WID_SITE_SURVEY_SCAN_TIME = 0x100E,
WID_JOIN_START_TIMEOUT = 0x100F,
WID_AUTH_TIMEOUT = 0x1010,
WID_ASOC_TIMEOUT = 0x1011,
WID_11I_PROTOCOL_TIMEOUT = 0x1012,
WID_EAPOL_RESPONSE_TIMEOUT = 0x1013,
/* NMAC Short WID list */
WID_11N_SIG_QUAL_VAL = 0x1085,
WID_CCA_THRESHOLD = 0x1087,
/* Custom Short WID list */
/* EMAC Integer WID list */
WID_FAILED_COUNT = 0x2000,
WID_RETRY_COUNT = 0x2001,
WID_MULTIPLE_RETRY_COUNT = 0x2002,
WID_FRAME_DUPLICATE_COUNT = 0x2003,
WID_ACK_FAILURE_COUNT = 0x2004,
WID_RECEIVED_FRAGMENT_COUNT = 0x2005,
WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006,
WID_FCS_ERROR_COUNT = 0x2007,
WID_SUCCESS_FRAME_COUNT = 0x2008,
WID_HUT_TX_COUNT = 0x200A,
WID_TX_FRAGMENT_COUNT = 0x200B,
WID_TX_MULTICAST_FRAME_COUNT = 0x200C,
WID_RTS_SUCCESS_COUNT = 0x200D,
WID_RTS_FAILURE_COUNT = 0x200E,
WID_WEP_UNDECRYPTABLE_COUNT = 0x200F,
WID_REKEY_PERIOD = 0x2010,
WID_REKEY_PACKET_COUNT = 0x2011,
WID_1X_SERV_ADDR = 0x2012,
WID_STACK_IP_ADDR = 0x2013,
WID_STACK_NETMASK_ADDR = 0x2014,
WID_HW_RX_COUNT = 0x2015,
WID_MEMORY_ADDRESS = 0x201E,
WID_MEMORY_ACCESS_32BIT = 0x201F,
WID_RF_REG_VAL = 0x2021,
/* NMAC Integer WID list */
WID_11N_PHY_ACTIVE_REG_VAL = 0x2080,
/* Custom Integer WID list */
WID_GET_INACTIVE_TIME = 0x2084,
WID_SET_DRV_HANDLER = 0X2085,
WID_SET_OPERATION_MODE = 0X2086,
/* EMAC String WID list */
WID_SSID = 0x3000,
WID_FIRMWARE_VERSION = 0x3001,
WID_OPERATIONAL_RATE_SET = 0x3002,
WID_BSSID = 0x3003,
WID_WEP_KEY_VALUE = 0x3004,
WID_11I_PSK = 0x3008,
WID_11E_P_ACTION_REQ = 0x3009,
WID_1X_KEY = 0x300A,
WID_HARDWARE_VERSION = 0x300B,
WID_MAC_ADDR = 0x300C,
WID_HUT_DEST_ADDR = 0x300D,
WID_PHY_VERSION = 0x300F,
WID_SUPP_USERNAME = 0x3010,
WID_SUPP_PASSWORD = 0x3011,
WID_SITE_SURVEY_RESULTS = 0x3012,
WID_RX_POWER_LEVEL = 0x3013,
WID_DEL_ALL_RX_BA = 0x3014,
WID_SET_STA_MAC_INACTIVE_TIME = 0x3017,
WID_ADD_WEP_KEY = 0x3019,
WID_REMOVE_WEP_KEY = 0x301A,
WID_ADD_PTK = 0x301B,
WID_ADD_RX_GTK = 0x301C,
WID_ADD_TX_GTK = 0x301D,
WID_REMOVE_KEY = 0x301E,
WID_ASSOC_REQ_INFO = 0x301F,
WID_ASSOC_RES_INFO = 0x3020,
WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */
WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */
WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */
WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */
/* NMAC String WID list */
WID_11N_P_ACTION_REQ = 0x3080,
WID_HUT_TEST_ID = 0x3081,
WID_PMKID_INFO = 0x3082,
WID_FIRMWARE_INFO = 0x3083,
#ifdef WILC_P2P
WID_REGISTER_FRAME = 0x3084,
#endif
WID_DEL_ALL_STA = 0x3085,
#ifdef WILC_P2P
WID_REMAIN_ON_CHAN = 0x3996,
#endif
/*BugID_4156*/
WID_SSID_PROBE_REQ = 0x3997,
/*BugID_4124 WID to trigger modified Join Request using SSID and BSSID instead of bssListIdx (used by WID_JOIN_REQ)*/
WID_JOIN_REQ_EXTENDED = 0x3998,
/* BugID 4951: WID toset IP address in firmware */
WID_IP_ADDRESS = 0x3999,
/* Custom String WID list */
/* EMAC Binary WID list */
WID_UAPSD_CONFIG = 0x4001,
WID_UAPSD_STATUS = 0x4002,
WID_WMM_AP_AC_PARAMS = 0x4003,
WID_WMM_STA_AC_PARAMS = 0x4004,
WID_NETWORK_INFO = 0x4005,
WID_STA_JOIN_INFO = 0x4006,
WID_CONNECTED_STA_LIST = 0x4007,
/* NMAC Binary WID list */
WID_11N_AUTORATE_TABLE = 0x4080,
/*Added here by Amr - BugID 4134*/
WID_SCAN_CHANNEL_LIST = 0x4084,
/*BugID_3746 WID to add IE to be added in next probe request*/
WID_INFO_ELEMENT_PROBE = 0x4085,
/*BugID_3746 WID to add IE to be added in next associate request*/
WID_INFO_ELEMENT_ASSOCIATE = 0x4086,
WID_ADD_STA = 0X4087,
WID_REMOVE_STA = 0X4088,
WID_EDIT_STA = 0X4089,
WID_ADD_BEACON = 0x408a,
/* BugID 5108 */
WID_SETUP_MULTICAST_FILTER = 0x408b,
/* Miscellaneous WIDs */
WID_ALL = 0x7FFE,
WID_MAX = 0xFFFF
} WID_T;
int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup);
void wilc_bus_set_max_speed(void);
void wilc_bus_set_default_speed(void);
uint32_t wilc_get_chipid(uint8_t update);
#endif