wifi: add marvell 88W8977 wifi module driver

Change-Id: Ia1e254e2c084621141d837be385d9198962be1cd
Signed-off-by: Qiang Wu <xianlee.wu@rock-chips.com>
This commit is contained in:
Qiang Wu
2018-04-16 15:52:31 +08:00
committed by Tao Huang
parent 120d153592
commit 623da8f83a
146 changed files with 189842 additions and 0 deletions

View File

@@ -37,5 +37,6 @@ source "drivers/net/wireless/rockchip_wlan/rtl8723bu/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723cs/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723ds/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8822be/Kconfig"
source "drivers/net/wireless/rockchip_wlan/mvl88w8977/Kconfig"
endif # WL_ROCKCHIP

View File

@@ -9,5 +9,6 @@ obj-$(CONFIG_RTL8723BU) += rtl8723bu/
obj-$(CONFIG_RTL8723CS) += rtl8723cs/
obj-$(CONFIG_RTL8723DS) += rtl8723ds/
obj-$(CONFIG_RTL8822BE) += rtl8822be/
obj-$(CONFIG_MVL88W8977) += mvl88w8977/
obj-$(CONFIG_WL_ROCKCHIP) += wifi_sys/rkwifi_sys_iface.o
obj-$(CONFIG_WL_ROCKCHIP) += rkwifi/rk_wifi_config.o

View File

@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
config MVL88W8977
tristate "Marvell 88W8977 SDIO WiFi"
---help---
Help message of MVL88W8977

View File

@@ -0,0 +1,567 @@
# File: Makefile
#
# Copyright (C) 2008-2017, Marvell International Ltd.
#
# This software file (the "File") is distributed by Marvell International
# Ltd. under the terms of the GNU General Public License Version 2, June 1991
# (the "License"). You may use, redistribute and/or modify this File in
# accordance with the terms and conditions of the License, a copy of which
# is available by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
# worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# A copy of the GPL is available in file gpl-2.0.txt accompanying in this
# deliverables.
#
# THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
# IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
# ARE EXPRESSLY DISCLAIMED. The License provides additional details about
# this warranty disclaimer.
COMPATDIR=/lib/modules/$(KERNELVERSION_X86)/build/compat-wireless-3.2-rc1-1/include
CC= $(CROSS_COMPILE)gcc -I$(COMPATDIR)
LD= $(CROSS_COMPILE)ld
BACKUP= /root/backup
YMD= `date +%Y%m%d%H%M`
ifneq ($(COMPAT_VERSION_CODE),)
DRV_DIR ?= $(shell pwd)
export DRV_DIR
COMPAT_VERSION=$(shell echo $(COMPAT_VERSION_CODE) | awk -F '.' '{print $$1}')
COMPAT_PATCHLEVEL=$(shell echo $(COMPAT_VERSION_CODE) | awk -F '.' '{print $$2}')
COMPAT_SUBLEVEL=$(shell echo $(COMPAT_VERSION_CODE) | awk -F '.' '{print $$3}')
DECL_HEADER_FILE=$(DRV_DIR)/mlinux/moal_main.h
$(shell sed -i 's/COMPAT_VERSION_CODE KERNEL_VERSION.*/COMPAT_VERSION_CODE KERNEL_VERSION(\
$(COMPAT_VERSION), $(COMPAT_PATCHLEVEL), $(COMPAT_SUBLEVEL))/g' $(DECL_HEADER_FILE))
endif
#############################################################################
# Configuration Options
#############################################################################
# Debug Option
# DEBUG LEVEL n/1/2:
# n: NO DEBUG
# 1: Only PRINTM(MMSG,...), PRINTM(MFATAL,...), ...
# 2: All PRINTM()
CONFIG_DEBUG=1
# Proc debug file
CONFIG_PROC_DEBUG=y
# Enable STA mode support
CONFIG_STA_SUPPORT=y
# Enable uAP mode support
CONFIG_UAP_SUPPORT=y
# Enable WIFIDIRECT support
CONFIG_WIFI_DIRECT_SUPPORT=y
# Enable WIFIDISPLAY support
CONFIG_WIFI_DISPLAY_SUPPORT=y
# Re-association in driver
CONFIG_REASSOCIATION=y
# Manufacturing firmware support
CONFIG_MFG_CMD_SUPPORT=y
# OpenWrt support
CONFIG_OPENWRT_SUPPORT=n
# Big-endian platform
CONFIG_BIG_ENDIAN=n
# Enable driver based authenticator
CONFIG_DRV_EMBEDDED_AUTHENTICATOR=y
# Enable driver based supplicant
CONFIG_DRV_EMBEDDED_SUPPLICANT=y
ifeq ($(CONFIG_DRV_EMBEDDED_SUPPLICANT), y)
CONFIG_EMBEDDED_SUPP_AUTH=y
else
ifeq ($(CONFIG_DRV_EMBEDDED_AUTHENTICATOR), y)
CONFIG_EMBEDDED_SUPP_AUTH=y
endif
endif
# Enable SDIO multi-port Tx aggregation
CONFIG_SDIO_MULTI_PORT_TX_AGGR=y
# Enable SDIO multi-port Rx aggregation
CONFIG_SDIO_MULTI_PORT_RX_AGGR=y
# SDIO suspend/resume
CONFIG_SDIO_SUSPEND_RESUME=y
# DFS testing support
CONFIG_DFS_TESTING_SUPPORT=y
# Multi-channel support
CONFIG_MULTI_CHAN_SUPPORT=y
CONFIG_ANDROID_KERNEL=y
#32bit app over 64bit kernel support
CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT=n
#############################################################################
# Select Platform Tools
#############################################################################
KERNELDIR := ./../../../../../
CURRENT_DIR := $(shell pwd)
MODEXT = ko
ccflags-y += -I$(M)/mlan
ccflags-y += -DLINUX
ccflags-y += -Idrivers/net/wireless/rockchip_wlan/mvl88w8977/mlan/
ccflags-y += -Idrivers/net/wireless/rockchip_wlan/mvl88w8977/mlinux
ccflags-y += -Idrivers/net/wireless/rockchip_wlan/mvl88w8977/mlan/esa
ccflags-y += -Idrivers/net/wireless/rockchip_wlan/mvl88w8977/mlan/esa/common
ifeq ($(CONFIG_EMBEDDED_SUPP_AUTH), y)
ccflags-y += -I$(M)/mlan/esa
ccflags-y += -I$(M)/mlan/esa/common
endif
LD += -S
BINDIR = ../bin_sd8977
#############################################################################
# Compiler Flags
#############################################################################
ccflags-y += -I$(KERNELDIR)/include
ccflags-y += -I$(PWD)/mlan/esa
ccflags-y += -I$(PWD)/mlan/esa/common
ccflags-y += -DFPNUM='"68"'
ifeq ($(CONFIG_DEBUG),1)
ccflags-y += -DDEBUG_LEVEL1
endif
ifeq ($(CONFIG_DEBUG),2)
ccflags-y += -DDEBUG_LEVEL1
ccflags-y += -DDEBUG_LEVEL2
DBG= -dbg
endif
ifeq ($(CONFIG_PROC_DEBUG),y)
ccflags-y += -DPROC_DEBUG
export CONFIG_PROC_DEBUG
endif
ifeq ($(CONFIG_64BIT), y)
ccflags-y += -DMLAN_64BIT
endif
ifeq ($(CONFIG_STA_SUPPORT),y)
ccflags-y += -DSTA_SUPPORT
ifeq ($(CONFIG_REASSOCIATION),y)
ccflags-y += -DREASSOCIATION
endif
else
CONFIG_WIFI_DIRECT_SUPPORT=n
CONFIG_WIFI_DISPLAY_SUPPORT=n
CONFIG_STA_WEXT=n
CONFIG_STA_CFG80211=n
endif
ifeq ($(CONFIG_UAP_SUPPORT),y)
ccflags-y += -DUAP_SUPPORT
else
CONFIG_WIFI_DIRECT_SUPPORT=n
CONFIG_WIFI_DISPLAY_SUPPORT=n
CONFIG_UAP_WEXT=n
CONFIG_UAP_CFG80211=n
endif
ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y)
ccflags-y += -DWIFI_DIRECT_SUPPORT
endif
ifeq ($(CONFIG_WIFI_DISPLAY_SUPPORT),y)
ccflags-y += -DWIFI_DISPLAY_SUPPORT
endif
ifeq ($(CONFIG_MFG_CMD_SUPPORT),y)
ccflags-y += -DMFG_CMD_SUPPORT
endif
ifeq ($(CONFIG_BIG_ENDIAN),y)
ccflags-y += -DBIG_ENDIAN_SUPPORT
endif
ifeq ($(CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT),y)
ccflags-y += -DUSERSPACE_32BIT_OVER_KERNEL_64BIT
endif
ifeq ($(CONFIG_SDIO_MULTI_PORT_TX_AGGR),y)
ccflags-y += -DSDIO_MULTI_PORT_TX_AGGR
endif
ifeq ($(CONFIG_SDIO_MULTI_PORT_RX_AGGR),y)
ccflags-y += -DSDIO_MULTI_PORT_RX_AGGR
endif
ifeq ($(CONFIG_SDIO_SUSPEND_RESUME),y)
ccflags-y += -DSDIO_SUSPEND_RESUME
endif
ifeq ($(CONFIG_MULTI_CHAN_SUPPORT),y)
ccflags-y += -DMULTI_CHAN_SUPPORT
endif
ifeq ($(CONFIG_DFS_TESTING_SUPPORT),y)
ccflags-y += -DDFS_TESTING_SUPPORT
endif
ifeq ($(CONFIG_ANDROID_KERNEL), y)
ccflags-y += -DANDROID_KERNEL
endif
ifeq ($(CONFIG_OPENWRT_SUPPORT), y)
ccflags-y += -DOPENWRT
endif
ifeq ($(CONFIG_T50), y)
ccflags-y += -DT50
ccflags-y += -DT40
ccflags-y += -DT3T
endif
# add -Wno-packed-bitfield-compat when GCC version greater than 4.4
GCC_VERSION := $(shell echo `gcc -dumpversion | cut -f1-2 -d.` \>= 4.4 | sed -e 's/\./*100+/g' | bc )
ifeq ($(GCC_VERSION),1)
ccflags-y += -Wno-packed-bitfield-compat
endif
#############################################################################
# Make Targets
#############################################################################
ifneq ($(KERNELRELEASE),)
ifeq ($(CONFIG_WIRELESS_EXT),y)
ifeq ($(CONFIG_WEXT_PRIV),y)
# Enable WEXT for STA
CONFIG_STA_WEXT=y
# Enable WEXT for uAP
CONFIG_UAP_WEXT=y
else
# Disable WEXT for STA
CONFIG_STA_WEXT=n
# Disable WEXT for uAP
CONFIG_UAP_WEXT=n
endif
endif
# Enable CFG80211 for STA
ifeq ($(CONFIG_CFG80211),y)
CONFIG_STA_CFG80211=y
else
ifeq ($(CONFIG_CFG80211),m)
CONFIG_STA_CFG80211=y
else
CONFIG_STA_CFG80211=n
endif
endif
# OpenWrt
ifeq ($(CONFIG_OPENWRT_SUPPORT), y)
ifeq ($(CPTCFG_CFG80211),y)
CONFIG_STA_CFG80211=y
else
ifeq ($(CPTCFG_CFG80211),m)
CONFIG_STA_CFG80211=y
else
CONFIG_STA_CFG80211=n
endif
endif
endif
# Enable CFG80211 for uAP
ifeq ($(CONFIG_CFG80211),y)
CONFIG_UAP_CFG80211=y
else
ifeq ($(CONFIG_CFG80211),m)
CONFIG_UAP_CFG80211=y
else
CONFIG_UAP_CFG80211=n
endif
endif
# OpenWrt
ifeq ($(CONFIG_OPENWRT_SUPPORT), y)
ifeq ($(CPTCFG_CFG80211),y)
CONFIG_UAP_CFG80211=y
else
ifeq ($(CPTCFG_CFG80211),m)
CONFIG_UAP_CFG80211=y
else
CONFIG_UAP_CFG80211=n
endif
endif
endif
ifneq ($(CONFIG_STA_SUPPORT),y)
CONFIG_WIFI_DIRECT_SUPPORT=n
CONFIG_WIFI_DISPLAY_SUPPORT=n
CONFIG_STA_WEXT=n
CONFIG_STA_CFG80211=n
endif
ifneq ($(CONFIG_UAP_SUPPORT),y)
CONFIG_WIFI_DIRECT_SUPPORT=n
CONFIG_WIFI_DISPLAY_SUPPORT=n
CONFIG_UAP_WEXT=n
CONFIG_UAP_CFG80211=n
endif
ifeq ($(CONFIG_STA_SUPPORT),y)
ifeq ($(CONFIG_STA_WEXT),y)
ccflags-y += -DSTA_WEXT
endif
ifeq ($(CONFIG_STA_CFG80211),y)
ccflags-y += -DSTA_CFG80211
endif
endif
ifeq ($(CONFIG_UAP_SUPPORT),y)
ifeq ($(CONFIG_UAP_WEXT),y)
ccflags-y += -DUAP_WEXT
endif
ifeq ($(CONFIG_UAP_CFG80211),y)
ccflags-y += -DUAP_CFG80211
endif
endif
print:
ifeq ($(CONFIG_STA_SUPPORT),y)
ifeq ($(CONFIG_STA_WEXT),n)
ifeq ($(CONFIG_STA_CFG80211),n)
@echo "Can not build STA without WEXT or CFG80211"
exit 2
endif
endif
endif
ifeq ($(CONFIG_UAP_SUPPORT),y)
ifeq ($(CONFIG_UAP_WEXT),n)
ifeq ($(CONFIG_UAP_CFG80211),n)
@echo "Can not build UAP without WEXT or CFG80211"
exit 2
endif
endif
endif
ifeq ($(CONFIG_DRV_EMBEDDED_AUTHENTICATOR), y)
ccflags-y += -DDRV_EMBEDDED_AUTHENTICATOR
endif
ifeq ($(CONFIG_DRV_EMBEDDED_SUPPLICANT), y)
ccflags-y += -DDRV_EMBEDDED_SUPPLICANT
endif
MOALOBJS = mlinux/moal_main.o \
mlinux/moal_ioctl.o \
mlinux/moal_shim.o \
mlinux/moal_eth_ioctl.o
MLANOBJS = mlan/mlan_shim.o mlan/mlan_init.o \
mlan/mlan_txrx.o \
mlan/mlan_cmdevt.o mlan/mlan_misc.o \
mlan/mlan_cfp.o \
mlan/mlan_module.o
MLANOBJS += mlan/mlan_wmm.o
MLANOBJS += mlan/mlan_sdio.o
MLANOBJS += mlan/mlan_11n_aggr.o
MLANOBJS += mlan/mlan_11n_rxreorder.o
MLANOBJS += mlan/mlan_11n.o
MLANOBJS += mlan/mlan_11d.o
MLANOBJS += mlan/mlan_11h.o
ifeq ($(CONFIG_STA_SUPPORT),y)
MLANOBJS += mlan/mlan_meas.o
MLANOBJS += mlan/mlan_scan.o \
mlan/mlan_sta_ioctl.o \
mlan/mlan_sta_rx.o \
mlan/mlan_sta_tx.o \
mlan/mlan_sta_event.o \
mlan/mlan_sta_cmd.o \
mlan/mlan_sta_cmdresp.o \
mlan/mlan_join.o
ifeq ($(CONFIG_STA_WEXT),y)
MOALOBJS += mlinux/moal_priv.o \
mlinux/moal_wext.o
endif
endif
ifeq ($(CONFIG_UAP_SUPPORT),y)
MLANOBJS += mlan/mlan_uap_ioctl.o
MLANOBJS += mlan/mlan_uap_cmdevent.o
MLANOBJS += mlan/mlan_uap_txrx.o
MOALOBJS += mlinux/moal_uap.o
ifeq ($(CONFIG_UAP_WEXT),y)
MOALOBJS += mlinux/moal_uap_priv.o
MOALOBJS += mlinux/moal_uap_wext.o
endif
endif
ifeq ($(CONFIG_STA_CFG80211),y)
MOALOBJS += mlinux/moal_cfg80211.o
MOALOBJS += mlinux/moal_cfgvendor.o
MOALOBJS += mlinux/moal_sta_cfg80211.o
endif
ifeq ($(CONFIG_UAP_CFG80211),y)
MOALOBJS += mlinux/moal_cfg80211.o
MOALOBJS += mlinux/moal_cfgvendor.o
MOALOBJS += mlinux/moal_uap_cfg80211.o
endif
ifdef CONFIG_PROC_FS
MOALOBJS += mlinux/moal_proc.o
ifeq ($(CONFIG_PROC_DEBUG),y)
MOALOBJS += mlinux/moal_debug.o
endif
endif
ifeq ($(CONFIG_EMBEDDED_SUPP_AUTH), y)
MLANOBJS += mlan/esa/common/rc4.o \
mlan/esa/common/aes_cmac_rom.o \
mlan/esa/common/hmac_sha1.o \
mlan/esa/common/md5.o \
mlan/esa/common/mrvl_sha256_crypto.o \
mlan/esa/common/hmac_md5.o \
mlan/esa/common/crypt_new_rom.o \
mlan/esa/common/rijndael.o \
mlan/esa/common/sha1.o \
mlan/esa/common/sha256.o \
mlan/esa/common/pass_phrase.o \
mlan/esa/common/pmkCache.o \
mlan/esa/common/pmkCache_rom.o \
mlan/esa/common/parser.o \
mlan/esa/common/parser_rom.o \
mlan/esa/keyMgmtApStaCommon.o \
mlan/esa/hostsa_init.o \
mlan/esa/authenticator_api.o
endif
ifeq ($(CONFIG_DRV_EMBEDDED_SUPPLICANT),y)
MLANOBJS += mlan/esa/keyMgmtSta.o \
mlan/esa/keyMgmtSta_rom.o \
mlan/esa/supplicant.o
endif
ifeq ($(CONFIG_DRV_EMBEDDED_AUTHENTICATOR),y)
MLANOBJS += mlan/esa/AssocAp_srv_rom.o \
mlan/esa/keyMgmtAp_rom.o \
mlan/esa/keyMgmtAp.o
endif
ifeq ($(CONFIG_MULTI_INTERFACE),y)
obj-m := mlan_sdio.o
mlan_sdio-objs := $(MLANOBJS)
else
obj-m := mlan.o
mlan-objs := $(MLANOBJS)
endif
MOALOBJS += mlinux/moal_sdio_mmc.o
obj-m += sd8xxx.o
sd8xxx-objs := $(MOALOBJS)
# Otherwise we were called directly from the command line; invoke the kernel build system.
else
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
###############################################################
export CC LD ccflags-y KERNELDIR
echo:
build: echo default
@if [ ! -d $(BINDIR) ]; then \
mkdir $(BINDIR); \
fi
ifeq ($(CONFIG_MULTI_INTERFACE),y)
cp -f mlan_sdio.$(MODEXT) $(BINDIR)/mlan_sdio$(DBG).$(MODEXT)
else
cp -f mlan.$(MODEXT) $(BINDIR)/mlan$(DBG).$(MODEXT)
endif
cp -f sd8xxx.$(MODEXT) $(BINDIR)/sd8977$(DBG).$(MODEXT)
cp -rpf script/sdio_mmc/* $(BINDIR)/
ifeq ($(CONFIG_STA_SUPPORT),y)
cp -f README $(BINDIR)
cp -f README_MLAN $(BINDIR)
ifeq ($(CONFIG_OPENWRT_SUPPORT),y)
cp -f README_OPENWRT $(BINDIR)
endif
endif
ifeq ($(CONFIG_UAP_SUPPORT),y)
cp -f README_UAP $(BINDIR)
endif
ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y)
cp -f README_WIFIDIRECT $(BINDIR)
cp -rpf script/wifidirect $(BINDIR)
ifeq ($(CONFIG_WIFI_DISPLAY_SUPPORT),y)
cp -rpf script/wifidisplay $(BINDIR)
endif
endif
clean:
-find . -name "*.o" -exec rm {} \;
-find . -name "*.ko" -exec rm {} \;
-find . -name ".*.cmd" -exec rm {} \;
-find . -name "*.mod.c" -exec rm {} \;
-find . -name "Module.symvers" -exec rm {} \;
-find . -name "Module.markers" -exec rm {} \;
-find . -name "modules.order" -exec rm {} \;
-find . -name ".*.dwo" -exec rm {} \;
-find . -name "*dwo" -exec rm {} \;
-rm -rf .tmp_versions
install: default
cp -f mlan.$(MODEXT) $(INSTALLDIR)/mlan$(DBG).$(MODEXT)
cp -f ../io/sdio/$(PLATFORM)/sdio.$(MODEXT) $(INSTALLDIR)
cp -f sd8xxx.$(MODEXT) $(INSTALLDIR)/sd8977$(DBG).$(MODEXT)
echo "sd8977 Driver Installed"
distclean:
-find . -name "*.o" -exec rm {} \;
-find . -name "*.orig" -exec rm {} \;
-find . -name "*.swp" -exec rm {} \;
-find . -name "*.*~" -exec rm {} \;
-find . -name "*~" -exec rm {} \;
-find . -name "*.d" -exec rm {} \;
-find . -name "*.a" -exec rm {} \;
-find . -name "tags" -exec rm {} \;
-find . -name ".*" -exec rm -rf 2> /dev/null \;
-find . -name "*.ko" -exec rm {} \;
-find . -name ".*.cmd" -exec rm {} \;
-find . -name "*.mod.c" -exec rm {} \;
-find . -name ".*.dwo" -exec rm {} \;
-find . -name "*dwo" -exec rm {} \;
-rm -rf .tmp_versions
# End of file

View File

@@ -0,0 +1,356 @@
/** @file AssocAp_src_rom.c
*
* @brief This file defines the function for checking security type and ie
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "hostsa_ext_def.h"
#include "IEEE_types.h"
#include "authenticator.h"
#include "AssocAp_srv_rom.h"
#include "parser.h"
#include "keyMgmtAp.h"
BOOLEAN
AssocSrvAp_checkCipherSupport(Cipher_t cipher, Cipher_t allowedCiphers)
{
BOOLEAN match = FALSE;
if (cipher.ccmp && (allowedCiphers.ccmp)) {
match = TRUE;
} else if (cipher.tkip && (allowedCiphers.tkip)) {
match = TRUE;
} else if (cipher.wep40 && (allowedCiphers.wep40)) {
match = TRUE;
} else if (cipher.wep104 && (allowedCiphers.wep104)) {
match = TRUE;
}
return match;
}
UINT16
AssocSrvAp_checkAkm(phostsa_private priv, AkmSuite_t *pAkm, UINT16 allowedAkms)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT16 matchedAkms;
matchedAkms = 0;
if ((memcmp(util_fns, pAkm->akmOui, wpa_oui, sizeof(wpa_oui)) != 0) &&
((memcmp(util_fns, pAkm->akmOui, kde_oui, sizeof(kde_oui)) != 0))) {
return matchedAkms;
}
switch (pAkm->akmType) {
case AKM_1X:
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_EAP);
break;
case AKM_PSK:
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_PSK);
break;
case AKM_SHA256_PSK:
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_PSK_SHA256);
break;
default:
break;
}
return matchedAkms;
}
WL_STATUS
assocSrvAp_validate4WayHandshakeIe(phostsa_private priv,
SecurityMode_t secType,
Cipher_t pwCipher,
Cipher_t grpCipher,
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
UINT8 akmType,
UINT16 rsnCap, Cipher_t config_mcstCipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
if (memcmp
(util_fns, (void *)&secType, (void *)&pKeyMgmtInfo->staSecType,
sizeof(secType)) != 0) {
return FAIL;
}
if (memcmp(util_fns, (void *)&grpCipher,
(void *)&config_mcstCipher, sizeof(grpCipher)) != 0) {
return FAIL;
}
if (memcmp
(util_fns, (void *)&pwCipher, (void *)&pKeyMgmtInfo->staUcstCipher,
sizeof(pwCipher)) != 0) {
return FAIL;
}
if (akmType != pKeyMgmtInfo->staAkmType) {
return FAIL;
}
return SUCCESS;
}
void
AssocSrvAp_InitKeyMgmtInfo(phostsa_private priv,
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
SecurityMode_t *secType, Cipher_t *pwCipher,
UINT16 staRsnCap, UINT8 akmType)
{
hostsa_util_fns *util_fns = &priv->util_fns;
pKeyMgmtInfo->keyMgmtState = HSK_NOT_STARTED;
memcpy(util_fns, (void *)&pKeyMgmtInfo->staSecType, (void *)secType,
sizeof(SecurityMode_t));
memcpy(util_fns, (void *)&pKeyMgmtInfo->staUcstCipher, (void *)pwCipher,
sizeof(Cipher_t));
pKeyMgmtInfo->staAkmType = akmType;
if (secType->wpa2) {
pKeyMgmtInfo->staRsnCap = staRsnCap;
}
}
void
AssocSrvAp_InitStaKeyInfo(cm_Connection *connPtr,
SecurityMode_t *secType,
Cipher_t *pwCipher, UINT16 staRsnCap, UINT8 akmType)
{
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
phostsa_private priv = (phostsa_private)connPtr->priv;
hostsa_util_fns *util_fns = &priv->util_fns;
KeyMgmtStopHskTimer(connPtr);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
memset(util_fns, (void *)pKeyMgmtInfo, 0x00,
sizeof(apKeyMgmtInfoSta_t));
AssocSrvAp_InitKeyMgmtInfo(priv, &pKeyMgmtInfo->rom, secType, pwCipher,
staRsnCap, akmType);
pKeyMgmtInfo->EAPOLProtoVersion = EAPOL_PROTOCOL_V1;
}
WL_STATUS
assocSrvAp_checkRsnWpa(cm_Connection *connPtr,
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
Cipher_t apWpaCipher,
Cipher_t apWpa2Cipher,
Cipher_t apMcstCipher,
UINT16 apAuthKey,
SecurityMode_t *pSecType,
IEEEtypes_RSNElement_t *pRsn,
IEEEtypes_WPAElement_t *pWpa,
BOOLEAN validate4WayHandshakeIE)
{
phostsa_private priv = (phostsa_private)connPtr->priv;
hostsa_util_fns *util_fns = &priv->util_fns;
WL_STATUS result = SUCCESS;
Cipher_t apCipher;
Cipher_t pwCipher;
Cipher_t grpCipher;
SecurityMode_t wpaType;
AkmSuite_t akm[AKM_SUITE_MAX];
UINT8 minimumRsnLen;
/* staRsnCap field is only used to compare RsnCap received in AssocRequest
with rsnCap received in 4 way handshake PWKMsg2.
we use 0xFFFF signature. If rsnCap is not present in pRsn,
signature 0xFFFF would be saved in pKeyMgmtInfo->staRsnCap.
*/
union {
UINT16 shortInt;
IEEEtypes_RSNCapability_t cfg;
} staRsnCap;
memset(util_fns, &wpaType, 0x00, sizeof(wpaType));
memset(util_fns, &apCipher, 0x00, sizeof(apCipher));
memset(util_fns, &pwCipher, 0x00, sizeof(pwCipher));
memset(util_fns, &grpCipher, 0x00, sizeof(grpCipher));
staRsnCap.shortInt = 0xFFFF;
if (pRsn && (pSecType->wpa2 == 1)) {
/*
In pRsn , All elements after Ver field are optional per the spec.
we reject Assoc Request, if GrpKeyCipher, pwsKey and AuthKey
is not present.
we can rely on minimum length check as we are rejecting Assoc Request
having pwsKeyCnt > 1 and AuthKeyCnt > 1
*/
minimumRsnLen = (unsigned long)&pRsn->RsnCap -
(unsigned long)&pRsn->Ver;
if (pRsn->Len < minimumRsnLen) {
PRINTM(MERROR, "pRsn->Len %x < minimumRsnLen %x\n",
pRsn->Len, minimumRsnLen);
return FAIL;
}
if (pRsn->PwsKeyCnt == 1 && pRsn->AuthKeyCnt == 1) {
apCipher = apWpa2Cipher;
supplicantParseRsnIe(priv, pRsn,
&wpaType,
&grpCipher,
&pwCipher,
akm,
NELEMENTS(akm),
&staRsnCap.cfg, NULL);
} else {
PRINTM(MERROR,
"pRsn->PwsKeyCnt %x pRsn->AuthKeyCnt %x\n",
pRsn->PwsKeyCnt, pRsn->AuthKeyCnt);
result = FAIL;
}
} else if (pWpa && (pSecType->wpa == 1)) {
if (pWpa->PwsKeyCnt == 1 && pWpa->AuthKeyCnt == 1) {
apCipher = apWpaCipher;
supplicantParseWpaIe(priv, pWpa,
&wpaType,
&grpCipher,
&pwCipher, akm, NELEMENTS(akm));
} else {
PRINTM(MERROR,
"pWpa->PwsKeyCnt %x pWpa->AuthKeyCnt %x\n",
pWpa->PwsKeyCnt, pWpa->AuthKeyCnt);
result = FAIL;
}
} else {
PRINTM(MERROR, "No wpa or rsn\n");
result = FAIL;
}
if ((pwCipher.ccmp == 0) && (pwCipher.tkip == 0)) {
PRINTM(MERROR,
"(pwCipher.ccmp(%x) == 0) && (pwCipher.tkip(%x) == 0)\n",
pwCipher.ccmp, pwCipher.tkip);
result = FAIL;
}
if ((grpCipher.ccmp == 0) && (grpCipher.tkip == 0)) {
PRINTM(MERROR,
"((grpCipher.ccmp(%x) == 0) && (grpCipher.tkip(%x) == 0))\n",
grpCipher.ccmp, grpCipher.tkip);
result = FAIL;
}
DBG_HEXDUMP(MCMD_D, " akm", (t_u8 *)&akm[0], sizeof(AkmSuite_t));
if (SUCCESS == result) {
#ifdef DOT11W
if (staRsnCap.shortInt != 0xFFFF) {
/* Save the peer STA PMF capability, which will later used to enable PMF */
connPtr->staData.peerPMFCapable = staRsnCap.cfg.MFPC;
}
#endif
if (validate4WayHandshakeIE == MFALSE) {
if ((AssocSrvAp_checkCipherSupport(pwCipher, apCipher)
== TRUE) &&
(AssocSrvAp_checkCipherSupport
(grpCipher, apMcstCipher)
== TRUE) &&
(AssocSrvAp_checkAkm(priv, akm, apAuthKey) != 0)) {
AssocSrvAp_InitStaKeyInfo(connPtr, &wpaType,
&pwCipher,
staRsnCap.shortInt,
akm[0].akmType);
} else {
result = FAIL;
}
} else {
result = assocSrvAp_validate4WayHandshakeIe(priv,
wpaType,
pwCipher,
grpCipher,
pKeyMgmtInfo,
akm[0].
akmType,
staRsnCap.
shortInt,
apMcstCipher);
}
}
return result;
}
SINT32
assocSrvAp_CheckSecurity(cm_Connection *connPtr,
IEEEtypes_WPSElement_t *pWps,
IEEEtypes_RSNElement_t *pRsn,
IEEEtypes_WPAElement_t *pWpa,
IEEEtypes_WAPIElement_t *pWapi,
IEEEtypes_StatusCode_t *pResult)
{
phostsa_private priv = (phostsa_private)connPtr->priv;
apInfo_t *pApInfo = &priv->apinfo;
BssConfig_t *pBssConfig = NULL;
SINT32 retval = MLME_FAILURE;
*pResult = IEEEtypes_STATUS_INVALID_RSN_CAPABILITIES;
pBssConfig = &pApInfo->bssConfig;
PRINTM(MMSG, "assocSrvAp_CheckSecurity Sectyep wpa %x wpa2 %x\n",
pBssConfig->SecType.wpa, pBssConfig->SecType.wpa2);
if ((pBssConfig->SecType.wpa == 1) || (pBssConfig->SecType.wpa2 == 1)) {
apKeyMgmtInfoSta_t *pKeyMgmtInfo =
&connPtr->staData.keyMgmtInfo;
Cipher_t wpaUcastCipher = pBssConfig->RsnConfig.wpaUcstCipher;
Cipher_t wpa2UcastCipher = pBssConfig->RsnConfig.wpa2UcstCipher;
DBG_HEXDUMP(MCMD_D, " wpa2UcstCipher",
(t_u8 *)&wpa2UcastCipher, sizeof(Cipher_t));
DBG_HEXDUMP(MCMD_D, " wpaUcastCipher",
(t_u8 *)&wpaUcastCipher, sizeof(Cipher_t));
connPtr->staData.RSNEnabled = 0;
if (assocSrvAp_checkRsnWpa(connPtr, &pKeyMgmtInfo->rom,
wpaUcastCipher,
wpa2UcastCipher,
pBssConfig->RsnConfig.mcstCipher,
pBssConfig->RsnConfig.AuthKey,
&pBssConfig->SecType, pRsn, pWpa,
MFALSE) == SUCCESS) {
retval = MLME_SUCCESS;
connPtr->staData.RSNEnabled = 1;
}
} else if (pBssConfig->SecType.wepStatic == 1) {
if (!pRsn || !pWpa) {
retval = MLME_SUCCESS;
}
} else if (pBssConfig->SecType.wapi) {
/* if (wapi_ie_check(pBssConfig, pWapi, pResult))
{
*pResult = 0;
retval = MLME_SUCCESS;
} */
}
return retval;
}

View File

@@ -0,0 +1,51 @@
/** @file AssocAp_src_rom.h
*
* @brief This file contains define check rsn/wpa ie
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef ASSOCAP_SRV_ROM_H_
#define ASSOCAP_SRV_ROM_H_
#include "wltypes.h"
#include "IEEE_types.h"
#include "keyMgmtStaTypes.h"
#include "keyMgmtApTypes_rom.h"
#include "authenticator.h"
WL_STATUS assocSrvAp_checkRsnWpa(cm_Connection *connPtr,
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
Cipher_t apWpaCipher,
Cipher_t apWpa2Cipher,
Cipher_t apMcstCipher,
UINT16 apAuthKey,
SecurityMode_t *pSecType,
IEEEtypes_RSNElement_t *pRsn,
IEEEtypes_WPAElement_t *pWpa,
BOOLEAN validate4WayHandshakeIE);
SINT32 assocSrvAp_CheckSecurity(cm_Connection *connPtr,
IEEEtypes_WPSElement_t *pWps,
IEEEtypes_RSNElement_t *pRsn,
IEEEtypes_WPAElement_t *pWpa,
IEEEtypes_WAPIElement_t *pWapi,
IEEEtypes_StatusCode_t *pResult);
#endif

View File

@@ -0,0 +1,126 @@
/** @file KeyApiStaDefs.h
*
* @brief This file Contains data structures and defines related to key material.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEY_API_STA_DEFS_H
#define _KEY_API_STA_DEFS_H
/******************************************************************/
/*!
* \ingroup wpa_supplicant
* \file keyApiStaDefs.h
* \brief Contains data structures and defines related to key material
*
*******************************************************************/
/* Key Material for TKIP type key */
#define CRYPTO_TKIP_KEY_LEN_MAX 16
#define CRYPTO_KEY_LEN_MAX 16
#define MIC_KEY_LEN_MAX 8
/* Key Material for AES type key */
#define CRYPTO_AES_KEY_LEN_MAX 16
#define WAPI_KEY_LEN 16
#define WAPI_MIC_LEN 16
#define WAPI_PN_LEN 16
#define CRYPTO_AES_CMAC_KEY_LEN 16
#define CRYPTO_AES_CMAC_IPN_LEN 6
#define CRYPTO_WEP_KEY_LEN_MAX 13
/*
WIN7 softAP (uAP) :
BIT14 and BIT15 of keyInfo is used to pass keyID for broadcast frame
*/
#define KEYDATA_KEY_ID_MASK (BIT14 | BIT15)
#define KEYDATA_KEY_ID_OFFSET 14
#define KEY_INFO_MULTICAST 0x1
#define KEY_INFO_UNICAST 0x2
#define KEY_INFO_ENABLED 0x4
#define KEY_INFO_DEFAULT 0x8
#define KEY_INFO_TX 0x10
#define KEY_INFO_RX 0x20
#define KEY_INFO_MULTICAST_IGTK 0x400
typedef MLAN_PACK_START struct {
UINT8 key[CRYPTO_TKIP_KEY_LEN_MAX];
UINT8 txMicKey[MIC_KEY_LEN_MAX];
UINT8 rxMicKey[MIC_KEY_LEN_MAX];
} MLAN_PACK_END key_Type_TKIP_t;
/* This struct is used in ROM and existing fields should not be changed.
* New fields can be added at the end.
*/
typedef MLAN_PACK_START struct {
UINT8 keyIndex;
UINT8 isDefaultTx;
UINT8 key[CRYPTO_WEP_KEY_LEN_MAX];
} MLAN_PACK_END key_Type_WEP_t;
typedef MLAN_PACK_START struct {
UINT8 key[CRYPTO_AES_KEY_LEN_MAX];
} MLAN_PACK_END key_Type_AES_t;
typedef MLAN_PACK_START struct {
UINT8 keyIndex;
UINT8 isDefKey;
UINT8 key[WAPI_KEY_LEN];
UINT8 mickey[WAPI_MIC_LEN];
UINT8 rxPN[WAPI_PN_LEN];
} MLAN_PACK_END key_Type_WAPI_t;
typedef MLAN_PACK_START struct {
UINT8 ipn[CRYPTO_AES_CMAC_IPN_LEN];
UINT8 reserved[2];
UINT8 key[CRYPTO_AES_CMAC_KEY_LEN];
} MLAN_PACK_END key_Type_AES_CMAC_t;
typedef MLAN_PACK_START struct {
UINT16 keyType;
UINT16 keyInfo;
UINT16 keyLen;
MLAN_PACK_START union {
key_Type_TKIP_t TKIP;
key_Type_AES_t AES;
key_Type_WEP_t WEP;
//#if defined(WAPI_HW_SUPPORT) || defined(WAPI_FW_SUPPORT)
// key_Type_WAPI_t WAPI;
//#endif
key_Type_AES_CMAC_t iGTK;
} MLAN_PACK_END keyEncypt;
} MLAN_PACK_END key_MgtMaterial_t;
/* deprecated but still around for backwards compatibility */
#define KEY_INFO_TKIP_MULTICAST 0x1
#define KEY_INFO_TKIP_UNICAST 0x2
#define KEY_INFO_TKIP_ENABLED 0x4
#define KEY_INFO_AES_MULTICAST 0x1
#define KEY_INFO_AES_UNICAST 0x2
#define KEY_INFO_AES_ENABLED 0x4
#endif

View File

@@ -0,0 +1,367 @@
/** @file authenticator.h
*
* @brief This file contains the data structure for authenticator and supplicant.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _AUTHENTICATOR_H
#define _AUTHENTICATOR_H
#include "wltypes.h"
#include "IEEE_types.h"
#include "wl_mib_rom.h"
#include "KeyApiStaDefs.h"
#include "keyApiStaTypes.h"
#include "keyCommonDef.h"
#include "keyMgmtApTypes.h"
#include "pmkCache_rom.h"
#include "hostsa_def.h"
extern const uint8 wpa_oui02[4]; /* WPA TKIP */
extern const uint8 wpa_oui04[4]; /* WPA AES */
extern const uint8 wpa_oui01[4]; /* WPA WEP-40 */
extern const uint8 wpa_oui05[4]; /* WPA WEP-104 */
extern const uint8 wpa_oui_none[4]; /* WPA NONE */
extern const uint8 wpa2_oui02[4]; /* WPA2 TKIP */
extern const uint8 wpa2_oui04[4]; /* WPA2 AES */
extern const uint8 wpa2_oui01[4]; /* WPA2 WEP-40 */
extern const uint8 wpa2_oui05[4]; /* WPA2 WEP-104 */
extern const uint8 wpa_oui[3];
extern const uint8 kde_oui[3];
typedef enum {
NO_MIC_FAILURE,
FIRST_MIC_FAIL_IN_60_SEC,
SECOND_MIC_FAIL_IN_60_SEC
} MIC_Fail_State_e;
typedef struct {
MIC_Fail_State_e status;
BOOLEAN MICCounterMeasureEnabled;
UINT32 disableStaAsso;
} MIC_Error_t;
typedef struct {
UINT8 TKIPICVErrors;
UINT8 TKIPLocalMICFailures;
UINT8 TKIPCounterMeasuresInvoked;
} customMIB_RSNStats_t;
typedef struct {
UINT8 kck[16]; /* PTK_KCK = L(PTK, 0, 128); */
UINT8 kek[16]; /* PTK_KEK = L(PTK, 128, 128); */
UINT8 tk[16]; /* PTK_TK = L(PTK, 256, 128); */
} CcmPtk_t;
typedef struct {
UINT8 kck[16]; /* PTK_KCK = L(PTK, 0, 128); */
UINT8 kek[16]; /* PTK_KEK = L(PTK, 128, 128); */
UINT8 tk[16]; /* PTK_TK = L(PTK, 256, 128); */
UINT8 rxMicKey[8];
UINT8 txMicKey[8];
} TkipPtk_t;
typedef struct {
MIC_Error_t apMicError;
t_void *apMicTimer;
UINT32 ageOutCnt;
UINT32 stateInfo;
//key mgmt data
apKeyMgmtInfoSta_t keyMgmtInfo;
t_u8 RSNEnabled;
UINT16 deauthReason;
UINT8 txPauseState;
//RateChangeInfo[] is used by MAC HW to decide the start TX rate.
//It should be placed in SQ. If staData_t is placed in ITCM/DTCM then put
//staRateTable in SQ and use a pointer here
//staRateTable RateChangeInfo;
UINT16 stickyTimCount;
BOOLEAN stickyTimEnabled;
#ifdef DOT11W
/* Peer STA PMF capability */
BOOLEAN peerPMFCapable;
#endif
} staData_t;
/**connectioninfo*/
typedef struct _cm_Connection {
/**Hand shake timer*/
t_void *HskTimer;
/** Timer set flag */
t_u8 timer_is_set;
/** authenticator Private pointer */
t_void *priv;
t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
/**sta data for authenticator*/
staData_t staData;
/**handshake data*/
eapolHskData_t hskData;
} cm_Connection;
typedef struct {
IEEEtypes_CapInfo_t CapInfo;
UINT32 AssocStationsCnt;
BOOLEAN updatePassPhrase;
KeyData_t grpKeyData;
UINT8 GNonce[32];
/* Following two variables contain that multiple of BI which is just
** greater than user configured ageout time in normal and PS mode. These
** variables get updated at bss_start, and then are used whenever FW
** resets STA age.
*/
UINT32 staAgeOutBcnCnt;
UINT32 psStaAgeOutBcnCnt;
// Store group rekey time as a multiple of beacon interval.
UINT32 grpRekeyCntConfigured;
UINT32 grpRekeyCntRemaining;
} BssData_t;
typedef struct {
UINT16 keyExchange:1;
UINT16 authenticate:1;
UINT16 reserved:14;
} Operation_t;
typedef struct {
Cipher_t mcstCipher;
UINT8 mcstCipherCount;
Cipher_t wpaUcstCipher;
UINT8 wpaUcstCipherCount;
Cipher_t wpa2UcstCipher;
UINT8 wpa2UcstCipherCount;
UINT16 AuthKey;
UINT16 AuthKeyCount;
Operation_t Akmp;
UINT32 GrpReKeyTime;
UINT8 PSKPassPhrase[PSK_PASS_PHRASE_LEN_MAX];
UINT8 PSKPassPhraseLen;
UINT8 PSKValue[PMK_LEN_MAX];
UINT8 MaxPwsHskRetries;
UINT8 MaxGrpHskRetries;
UINT32 PwsHskTimeOut;
UINT32 GrpHskTimeOut;
UINT8 RSNReplayProtEn; /* RSN Replay Attack Protection flag */
} apRsnConfig_t;
typedef struct {
UINT8 ieSet;
UINT8 version;
/* UINT8 akmCnt ; */
UINT8 akmTypes;
/* UINT8 uCastCnt ; */
UINT8 uCastTypes;
UINT8 mCastTypes;
UINT8 capInfo;
} wapi_ie_cfg_t;
typedef struct {
/* The This section only used for initialization of the connPtr */
IEEEtypes_SsId_t SsId;
IEEEtypes_Len_t SsIdLen;
// odd-sized ele clubbed together to keep even alignment
IEEEtypes_DtimPeriod_t DtimPeriod;
IEEEtypes_BcnInterval_t BcnPeriod;
IEEEtypes_MacAddr_t BssId;
UINT16 RtsThresh;
UINT16 FragThresh;
UINT8 ShortRetryLim;
UINT8 LongRetryLim;
// Used in MBSS mode for software beacon suppression
UINT8 MbssBcnIntFac;
UINT8 MbssCurBcnIntCnt;
UINT16 Reserved;
} CommonMlmeData_t;
typedef struct {
IEEEtypes_SsId_t SsId;
IEEEtypes_Len_t SsIdLen;
UINT8 wpa_ie[MAX_IE_SIZE];
UINT16 wpa_ielen;
UINT8 rsn_ie[MAX_IE_SIZE];
UINT16 rsn_ielen;
UINT32 StaAgeOutTime;
UINT32 PsStaAgeOutTime;
/* If the BssAddr field is not aligned on word boundary the hal
functions which update mac registers are unsafe for non-word
aligned pointers. Avoid direct use of the pointer to BssId
field in the hal functions */
/* this field is no longer used and we use mibOpdata_p->StaMacAddr
in its place now */
IEEEtypes_MacAddr_t EepromMacAddr_defunct;
IEEEtypes_DataRate_t OpRateSet[IEEEtypes_MAX_DATA_RATES_G];
// odd-sized ele clubbed together to keep even alignment
UINT8 AuthType;
UINT8 TxPowerLevel;
IEEEtypes_DataRate_t TxDataRate;
IEEEtypes_DataRate_t TxMCBCDataRate;
UINT8 MaxStaSupported;
SecurityMode_t SecType;
UINT8 Padding1[1]; //****** Use this for adding new members *******
BOOLEAN apWmmEn;
IEEEtypes_WMM_ParamElement_t apWmmParamSet;
BOOLEAN ap11nEn;
cipher_key_buf_t *pWepKeyBuf;
cipher_key_buf_t *pGtkKeyBuf;
UINT8 ScanChanCount;
UINT8 AclStaCnt;
UINT8 Padding3[1]; //****** Use this for adding new members *******
apRsnConfig_t RsnConfig;
BOOLEAN apWmmPsEn;
channelInfo_t ScanChanList[IEEEtypes_MAX_CHANNELS]; /* Channels to scan */
CommonMlmeData_t comData;
IEEEtypes_OBSS_ScanParam_t ObssScanParam;
cipher_key_buf_t *piGtkKeyBuf;
UINT32 mgmtFrameSubtypeFwdEn;
UINT8 Ht2040CoexEn; // Enable/Disable 2040 Coex feature in uAP
UINT8 Padding4[1]; //****** Use this for adding new members *******
wapi_ie_cfg_t wapiCfg;
IEEEtypes_ExtCapability_t ExtCap;
UINT8 Padding6[1]; //****** Use this for adding new members *******
} BssConfig_t;
typedef struct {
BssConfig_t bssConfig;
BssData_t bssData;
} apInfo_t;
#ifdef DRV_EMBEDDED_SUPPLICANT
typedef struct {
/* This structure is ROM'd */
UINT8 RSNEnabled:1; /* WPA, WPA2 */
UINT8 pmkidValid:1; /* PMKID valid */
UINT8 rsnCapValid:1;
UINT8 grpMgmtCipherValid:1;
UINT8 rsvd:4; /* rsvd */
SecurityMode_t wpaType;
Cipher_t mcstCipher;
Cipher_t ucstCipher;
AkmSuite_t AKM;
UINT8 PMKID[16];
IEEEtypes_RSNCapability_t rsnCap;
Cipher_t grpMgmtCipher;
} RSNConfig_t;
typedef struct {
UINT8 ANonce[NONCE_SIZE];
UINT8 SNonce[NONCE_SIZE];
UINT8 EAPOL_MIC_Key[EAPOL_MIC_KEY_SIZE];
UINT8 EAPOL_Encr_Key[EAPOL_ENCR_KEY_SIZE];
UINT32 apCounterLo; /* last valid replay counter from authenticator */
UINT32 apCounterHi;
UINT32 apCounterZeroDone; /* have we processed replay == 0? */
UINT32 staCounterLo; /* counter used in request EAPOL frames */
UINT32 staCounterHi;
BOOLEAN RSNDataTrafficEnabled; /* Enabled after 4way handshake */
BOOLEAN RSNSecured; /* Enabled after group key is established */
BOOLEAN pwkHandshakeComplete;
cipher_key_t *pRxDecryptKey;
KeyData_t PWKey;
KeyData_t GRKey;
KeyData_t newPWKey;
MIC_Error_t sta_MIC_Error;
t_void *rsnTimer;
t_void *micTimer;
t_void *deauthDelayTimer; /* hacked in to delay the deauth */
//phostsa_private psapriv;
KeyData_t IGtk;
} keyMgmtInfoSta_t;
typedef struct supplicantData {
BOOLEAN inUse;
BOOLEAN suppInitialized;
IEEEtypes_SsIdElement_t hashSsId;
IEEEtypes_MacAddr_t localBssid;
IEEEtypes_MacAddr_t localStaAddr;
customMIB_RSNStats_t customMIB_RSNStats;
RSNConfig_t customMIB_RSNConfig;
keyMgmtInfoSta_t keyMgmtInfoSta;
SecurityParams_t currParams;
UINT8 wpa_rsn_ie[MAX_IE_SIZE];
} supplicantData_t;
#endif
/** supplicant/authenticator private structure */
typedef struct _hostsa_private {
/** pmlan_private */
t_void *pmlan_private;
/** pmlan_adapter */
t_void *pmlan_adapter;
/** Utility functions table */
hostsa_util_fns util_fns;
/** MLAN APIs table */
hostsa_mlan_fns mlan_fns;
/**apinf_t*/
apInfo_t apinfo;
/**group rekey timer*/
t_void *GrpRekeytimer;
/**Group rekey timer set flag*/
t_u8 GrpRekeyTimerIsSet;
/**local mac address*/
t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
#ifdef DRV_EMBEDDED_SUPPLICANT
/**supplicant data*/
supplicantData_t *suppData;
#endif
/* GTK installed status */
t_u8 gtk_installed;
} hostsa_private, *phostsa_private;
#endif

View File

@@ -0,0 +1,896 @@
/** @file Authenticator_api.c
*
* @brief This file defines the main APIs for authenticator.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
//Authenticator related function definitions
#include "wltypes.h"
#include "IEEE_types.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "wl_macros.h"
#include "wlpd.h"
#include "pass_phrase.h"
#include "sha1.h"
#include "crypt_new.h"
#include "parser.h"
#include "keyCommonDef.h"
#include "keyMgmtStaTypes.h"
#include "AssocAp_srv_rom.h"
#include "pmkCache.h"
#include "keyMgmtApTypes.h"
#include "keyMgmtAp.h"
#include "rc4.h"
#include "keyMgmtAp.h"
/*********************
Local Variables
*********************/
/*********************
Global Variables
*********************/
/*********************
Local Functions
*********************/
/*********************
Global Functions
*********************/
#ifdef DRV_EMBEDDED_SUPPLICANT
extern void allocSupplicantData(void *phostsa_priv);
extern void freeSupplicantData(void *phostsa_priv);
extern mlan_status initSupplicantTimer(void *priv);
extern void keyMgmtSta_RomInit(void);
extern void freeSupplicantTimer(void *priv);
#endif
/*********************
Utility Handler
*********************/
#ifdef DRV_EMBEDDED_AUTHENTICATOR
static UINT32
util_CountBits(UINT32 val)
{
UINT32 count = 0;
for (count = 0; val; count++) {
val &= (val - 1);
}
return count;
}
static void
initMicErrorParams(UINT32 wpa, MIC_Error_t *pApMicError)
{
if (wpa) {
pApMicError->MICCounterMeasureEnabled = 1;
pApMicError->disableStaAsso = 0;
pApMicError->status = NO_MIC_FAILURE;
}
}
/**
* @brief whether authenticator is enabled or not
*
* @param priv A void pointer to phostsa private struct
*
* @return
*/
t_u8
IsAuthenticatorEnabled(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
apInfo_t *pApInfo = NULL;
apRsnConfig_t *pRsnConfig = NULL;
t_u8 ret = 0;
ENTER();
if (!psapriv) {
LEAVE();
return ret;
}
pApInfo = &psapriv->apinfo;
if (pApInfo == NULL) {
LEAVE();
return ret;
}
pRsnConfig = &pApInfo->bssConfig.RsnConfig;
// If Passphrase lengh is nonozero then
// authenticator in the driver is to be used,
// otherwise authenticator in the host is not to be used.
if (pRsnConfig->PSKPassPhraseLen != 0) {
ret = 1;
}
LEAVE();
return ret;
}
/**
* @brief BSS configure initialized
*
* @param priv A void pointer to phostsa private struct
*
* @return
*/
void
AuthenitcatorInitBssConfig(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = MNULL;
apInfo_t *pApInfo = MNULL;
BssConfig_t *pBssConfig = MNULL;
apRsnConfig_t *pRsnConfig = MNULL;
ENTER();
if (!psapriv) {
LEAVE();
return;
}
util_fns = &psapriv->util_fns;
pApInfo = &psapriv->apinfo;
pBssConfig = &pApInfo->bssConfig;
pRsnConfig = &pBssConfig->RsnConfig;
memset(util_fns, pBssConfig, 0x00, sizeof(BssConfig_t));
/**default ap ssid*/
pBssConfig->SsIdLen = wlan_strlen(AP_DEFAULT_SSID);
memset(util_fns, pBssConfig->SsId, 0x00, IEEEtypes_SSID_SIZE);
memcpy(util_fns, pBssConfig->SsId, AP_DEFAULT_SSID,
IEEEtypes_SSID_SIZE);
/**default retry times ans timeout*/
pRsnConfig->PwsHskTimeOut = PWS_HSK_TIMEOUT;
pRsnConfig->MaxPwsHskRetries = PWS_HSK_RETRIES;
pRsnConfig->GrpHskTimeOut = GRP_HSK_TIMEOUT;
pRsnConfig->MaxGrpHskRetries = GRP_HSK_RETRIES;
/**Group key rekey time*/
pRsnConfig->GrpReKeyTime = GRP_REKEY_TIME;
LEAVE();
}
/**
* @brief get bss config
*
* @param priv A void pointer to phostsa private struct
* @param pbss_config a pointer to mlan_uap_bss_param
* @param SetConfigToMlan 1 set releated config to mlan , 0 get related config from mlan
*
* @return
*/
void
AuthenticatorGetBssConfig(hostsa_private *psapriv, t_u8 *pbss_config,
t_u8 SetConfigToMlan)
{
hostsa_util_fns *util_fns = &psapriv->util_fns;
apInfo_t *pApInfo = &psapriv->apinfo;
mlan_uap_bss_param *bss_config = (mlan_uap_bss_param *)pbss_config;
BssConfig_t *pBssConfig = MNULL;
apRsnConfig_t *pRsnConfig = MNULL;
t_u8 zero_mac[] = { 0, 0, 0, 0, 0, 0 };
ENTER();
pBssConfig = &pApInfo->bssConfig;
pRsnConfig = &pBssConfig->RsnConfig;
/**set bss config to mlan*/
if (SetConfigToMlan) {
if ((pRsnConfig->PwsHskTimeOut != 0) &&
(pRsnConfig->PwsHskTimeOut < (MAX_VALID_DWORD))) {
bss_config->pairwise_update_timeout =
pRsnConfig->PwsHskTimeOut;
}
if ((pRsnConfig->MaxPwsHskRetries != 0) &&
(pRsnConfig->MaxPwsHskRetries < (MAX_VALID_DWORD)))
bss_config->pwk_retries = pRsnConfig->MaxPwsHskRetries;
if ((pRsnConfig->GrpHskTimeOut != 0) &&
(pRsnConfig->GrpHskTimeOut < (MAX_VALID_DWORD)))
bss_config->groupwise_update_timeout =
pRsnConfig->GrpHskTimeOut;
if ((pRsnConfig->MaxGrpHskRetries != 0) &&
(pRsnConfig->MaxGrpHskRetries < (MAX_VALID_DWORD)))
bss_config->gwk_retries = pRsnConfig->MaxGrpHskRetries;
if (pRsnConfig->PSKPassPhraseLen != 0) {
bss_config->wpa_cfg.length =
pRsnConfig->PSKPassPhraseLen;
memcpy(util_fns, bss_config->wpa_cfg.passphrase,
pRsnConfig->PSKPassPhrase,
pRsnConfig->PSKPassPhraseLen);
}
if ((pRsnConfig->GrpReKeyTime != 0) &&
(pRsnConfig->GrpReKeyTime < MAX_GRP_TIMER))
bss_config->wpa_cfg.gk_rekey_time =
pRsnConfig->GrpReKeyTime;
LEAVE();
return;
}
if (((pBssConfig->SsIdLen != bss_config->ssid.ssid_len) ||
(memcmp(util_fns, pBssConfig->SsId,
bss_config->ssid.ssid, bss_config->ssid.ssid_len) != 0)) &&
bss_config->ssid.ssid_len) {
pApInfo->bssData.updatePassPhrase = 1;
memcpy(util_fns, pBssConfig->SsId, bss_config->ssid.ssid,
bss_config->ssid.ssid_len);
pBssConfig->SsIdLen = bss_config->ssid.ssid_len;
}
if (memcmp
(util_fns, zero_mac, &bss_config->mac_addr, MLAN_MAC_ADDR_LENGTH)) {
memset(util_fns, psapriv->curr_addr, 0x00,
MLAN_MAC_ADDR_LENGTH);
memcpy(util_fns, psapriv->curr_addr, &bss_config->mac_addr,
MLAN_MAC_ADDR_LENGTH);
}
if ((bss_config->max_sta_count != 0) &&
(bss_config->max_sta_count <= MAX_STA_COUNT))
pBssConfig->MaxStaSupported = bss_config->max_sta_count;
if ((bss_config->pairwise_update_timeout != 0) &&
(bss_config->pairwise_update_timeout < (MAX_VALID_DWORD))) {
pRsnConfig->PwsHskTimeOut = bss_config->pairwise_update_timeout;
}
if ((bss_config->pwk_retries != 0) &&
(bss_config->pwk_retries < (MAX_VALID_DWORD)))
pRsnConfig->MaxPwsHskRetries = bss_config->pwk_retries;
if ((bss_config->groupwise_update_timeout != 0) &&
(bss_config->groupwise_update_timeout < (MAX_VALID_DWORD)))
pRsnConfig->GrpHskTimeOut =
bss_config->groupwise_update_timeout;
if ((bss_config->gwk_retries != 0) &&
(bss_config->gwk_retries < (MAX_VALID_DWORD)))
pRsnConfig->MaxGrpHskRetries = bss_config->gwk_retries;
if ((bss_config->auth_mode <= MLAN_AUTH_MODE_SHARED) ||
(bss_config->auth_mode == MLAN_AUTH_MODE_AUTO))
pBssConfig->AuthType = bss_config->auth_mode;
memcpy(util_fns, &pBssConfig->SecType, &bss_config->protocol,
sizeof(pBssConfig->SecType));
if ((bss_config->protocol & PROTOCOL_WPA) ||
(bss_config->protocol & PROTOCOL_WPA2) ||
(bss_config->protocol & PROTOCOL_EAP)) {
pRsnConfig->AuthKey = bss_config->key_mgmt;
pRsnConfig->AuthKeyCount = util_CountBits(pRsnConfig->AuthKey);
memcpy(util_fns, (char *)&pRsnConfig->Akmp,
(char *)&bss_config->key_mgmt_operation,
sizeof(bss_config->key_mgmt_operation));
if ((bss_config->wpa_cfg.
pairwise_cipher_wpa & VALID_CIPHER_BITMAP) &&
(bss_config->wpa_cfg.pairwise_cipher_wpa != 0xff)) {
memset(util_fns, (t_u8 *)&pRsnConfig->wpaUcstCipher,
0x00, sizeof(Cipher_t));
memcpy(util_fns, (t_u8 *)&pRsnConfig->wpaUcstCipher,
(t_u8 *)&bss_config->wpa_cfg.pairwise_cipher_wpa,
sizeof(Cipher_t));
pRsnConfig->wpaUcstCipherCount =
util_CountBits(bss_config->wpa_cfg.
pairwise_cipher_wpa);
}
if ((bss_config->wpa_cfg.
pairwise_cipher_wpa2 & VALID_CIPHER_BITMAP) &&
(bss_config->wpa_cfg.pairwise_cipher_wpa2 != 0xff)) {
memset(util_fns, (t_u8 *)&pRsnConfig->wpa2UcstCipher,
0x00, sizeof(Cipher_t));
memcpy(util_fns, (t_u8 *)&pRsnConfig->wpa2UcstCipher,
(t_u8 *)&bss_config->wpa_cfg.
pairwise_cipher_wpa2, sizeof(Cipher_t));
pRsnConfig->wpa2UcstCipherCount =
util_CountBits(bss_config->wpa_cfg.
pairwise_cipher_wpa2);
}
DBG_HEXDUMP(MCMD_D, " wpa2UcstCipher",
(t_u8 *)&pRsnConfig->wpa2UcstCipher,
sizeof(Cipher_t));
DBG_HEXDUMP(MCMD_D, " wpaUcastCipher",
(t_u8 *)&pRsnConfig->wpaUcstCipher,
sizeof(Cipher_t));
if (bss_config->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) {
memset(util_fns, (t_u8 *)&pRsnConfig->mcstCipher, 0x00,
sizeof(Cipher_t));
memcpy(util_fns, (t_u8 *)&pRsnConfig->mcstCipher,
(t_u8 *)&bss_config->wpa_cfg.group_cipher,
sizeof(Cipher_t));
pRsnConfig->mcstCipherCount =
util_CountBits(bss_config->wpa_cfg.
group_cipher);
}
if (bss_config->wpa_cfg.rsn_protection <= MTRUE)
pRsnConfig->RSNReplayProtEn =
bss_config->wpa_cfg.
rsn_protection ? MTRUE : MFALSE;
}
if (((pRsnConfig->PSKPassPhraseLen != bss_config->wpa_cfg.length) ||
(memcmp(util_fns, pRsnConfig->PSKPassPhrase,
bss_config->wpa_cfg.passphrase,
bss_config->wpa_cfg.length) != 0)) &&
bss_config->wpa_cfg.length) {
pApInfo->bssData.updatePassPhrase = 1;
pRsnConfig->PSKPassPhraseLen = bss_config->wpa_cfg.length;
memset(util_fns, pRsnConfig->PSKPassPhrase,
0x00, PSK_PASS_PHRASE_LEN_MAX);
memcpy(util_fns, pRsnConfig->PSKPassPhrase,
bss_config->wpa_cfg.passphrase,
bss_config->wpa_cfg.length);
}
if ((bss_config->wpa_cfg.gk_rekey_time != 0) &&
(bss_config->wpa_cfg.gk_rekey_time < MAX_GRP_TIMER))
pRsnConfig->GrpReKeyTime = bss_config->wpa_cfg.gk_rekey_time;
LEAVE();
}
/**
* @brief get bss config for authenticator and append wpa/rsn ie to FW
*
* @param priv A void pointer to phostsa private struct
* @param pbss_config a pointer to mlan_uap_bss_param
* @param appendIE 1 append rsn/wpa ie to fw, 0 not append
* @param clearIE 1 clear rsn/wpa ie to fw, 0 not clear
* @param SetConfigToMlan 1 set releated config to mlan , 0 get related config from mlan
*
*
* @return
*/
t_u8
AuthenticatorBssConfig(void *priv, t_u8 *pbss_config, t_u8 appendIE,
t_u8 clearIE, t_u8 SetConfigToMlan)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = MNULL;
hostsa_mlan_fns *pm_fns = MNULL;
apInfo_t *pApInfo = MNULL;
BssConfig_t *pBssConfig = MNULL;
apRsnConfig_t *pRsnConfig = MNULL;
t_u16 ielen = 0;
t_u8 ret = 0;
ENTER();
if (!psapriv) {
LEAVE();
return ret;
}
util_fns = &psapriv->util_fns;
pm_fns = &psapriv->mlan_fns;
pApInfo = &psapriv->apinfo;
pBssConfig = &pApInfo->bssConfig;
pRsnConfig = &pBssConfig->RsnConfig;
if (pbss_config)
AuthenticatorGetBssConfig(psapriv, pbss_config,
SetConfigToMlan);
if (appendIE && pRsnConfig->PSKPassPhraseLen &&
(pBssConfig->SecType.wpa || pBssConfig->SecType.wpa2 ||
pBssConfig->SecType.wpaNone)) {
PRINTM(MMSG, "authenticator set mgmt IE\n");
if (pBssConfig->wpa_ielen) {
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->wpa_ie,
pBssConfig->wpa_ielen, 1);
pBssConfig->wpa_ielen = 0;
memset(util_fns, pBssConfig->wpa_ie, 0x00, MAX_IE_SIZE);
}
/**construct wpa or RSN ie*/
if (pBssConfig->SecType.wpa) {
memset(util_fns, pBssConfig->wpa_ie, 0x00, MAX_IE_SIZE);
ielen = keyMgmtAp_FormatWPARSN_IE(psapriv,
(IEEEtypes_InfoElementHdr_t
*)pBssConfig->wpa_ie,
0,
&pBssConfig->
RsnConfig.
wpaUcstCipher,
pBssConfig->RsnConfig.
wpaUcstCipherCount,
&pBssConfig->
RsnConfig.mcstCipher,
pBssConfig->RsnConfig.
AuthKey,
pBssConfig->RsnConfig.
AuthKeyCount);
pBssConfig->wpa_ielen = ielen;
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->wpa_ie, ielen,
0);
}
if (pBssConfig->rsn_ielen) {
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->rsn_ie,
pBssConfig->rsn_ielen, 1);
pBssConfig->rsn_ielen = 0;
memset(util_fns, pBssConfig->rsn_ie, 0x00, MAX_IE_SIZE);
}
if (pBssConfig->SecType.wpa2) {
memset(util_fns, pBssConfig->rsn_ie, 0x00, MAX_IE_SIZE);
ielen = keyMgmtAp_FormatWPARSN_IE(psapriv,
(IEEEtypes_InfoElementHdr_t
*)pBssConfig->rsn_ie,
1,
&pBssConfig->
RsnConfig.
wpa2UcstCipher,
pBssConfig->RsnConfig.
wpa2UcstCipherCount,
&pBssConfig->
RsnConfig.mcstCipher,
pBssConfig->RsnConfig.
AuthKey,
pBssConfig->RsnConfig.
AuthKeyCount);
pBssConfig->rsn_ielen = ielen;
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->rsn_ie, ielen,
0);
}
}
if (clearIE) {
PRINTM(MMSG, "authenticator clear mgmt IE\n");
if (pBssConfig->wpa_ielen) {
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->wpa_ie,
pBssConfig->wpa_ielen, 1);
pBssConfig->wpa_ielen = 0;
memset(util_fns, pBssConfig->wpa_ie, 0x00, MAX_IE_SIZE);
}
if (pBssConfig->rsn_ielen) {
pm_fns->Hostsa_set_mgmt_ie(psapriv->pmlan_private,
pBssConfig->rsn_ie,
pBssConfig->rsn_ielen, 1);
pBssConfig->rsn_ielen = 0;
memset(util_fns, pBssConfig->rsn_ie, 0x00, MAX_IE_SIZE);
}
}
LEAVE();
return ret;
}
/**
* @brief initialize key
*
* @param priv A void pointer to phostsa private struct
*
* @return
*/
void
AuthenticatorKeyMgmtInit(void *priv, t_u8 *addr)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
apInfo_t *pApInfo = &psapriv->apinfo;
BssConfig_t *pBssConfig = MNULL;
ENTER();
pBssConfig = &pApInfo->bssConfig;
/**mac address */
memcpy(util_fns, psapriv->curr_addr, addr, MLAN_MAC_ADDR_LENGTH);
/**Reset Group Key*/
memset(util_fns, &pBssConfig->pGtkKeyBuf, 0x00,
sizeof(pBssConfig->pGtkKeyBuf));
/**key init */
KeyMgmtInit(priv);
/**Group key update time,*/
if (pBssConfig->RsnConfig.GrpReKeyTime) {
pApInfo->bssData.grpRekeyCntConfigured = pApInfo->bssConfig.RsnConfig.GrpReKeyTime / 60;
/**every 60s grpRekeyCntRemaining -- */
pApInfo->bssData.grpRekeyCntRemaining
= pApInfo->bssData.grpRekeyCntConfigured;
}
keyApi_ApUpdateKeyMaterial(priv, MNULL, MTRUE);
/**start Group rekey timer*/
if (pBssConfig->RsnConfig.GrpReKeyTime && !psapriv->GrpRekeyTimerIsSet) {
util_fns->moal_start_timer(util_fns->pmoal_handle,
psapriv->GrpRekeytimer,
MFALSE, MRVDRV_TIMER_60S);
psapriv->GrpRekeyTimerIsSet = MTRUE;
}
LEAVE();
}
/**
* @brief clear key
*
* @param priv A void pointer to phostsa private struct
*
* @return
*/
void
AuthenticatorkeyClear(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *putil_fns = &psapriv->util_fns;
apInfo_t *pApInfo = &psapriv->apinfo;
BssConfig_t *pBssConfig = &pApInfo->bssConfig;
if (psapriv->GrpRekeyTimerIsSet) {
psapriv->GrpRekeyTimerIsSet = MFALSE;
putil_fns->moal_stop_timer(putil_fns->pmoal_handle,
psapriv->GrpRekeytimer);
/**Reset Group Key*/
memset(putil_fns, &pBssConfig->pGtkKeyBuf, 0x00,
sizeof(pBssConfig->pGtkKeyBuf));
}
}
/**
* @brief process received eapol packet
*
* @param psapriv A void pointer to phostsa private struct
* @param pbuf a pointer to packet buf
* @param len buffer len
* @
* @return
*/
t_u8
AuthenticatorProcessEapolPacket(t_void *psapriv, t_u8 *pbuf, t_u32 len)
{
phostsa_private priv = (phostsa_private)psapriv;
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_t *rx_eapol_ptr;
Status_e status = FAIL;
cm_Connection *connPtr = MNULL;
cm_Connection *pconnPtr = MNULL;
t_u8 *sta_addr = pbuf + MLAN_MAC_ADDR_LENGTH;
t_u8 ret = 0;
t_u32 eapol_pkt_len, least_len;
ENTER();
rx_eapol_ptr = (EAPOL_KeyMsg_t *)(pbuf + ETHII_HEADER_LEN);
if (rx_eapol_ptr->hdr_8021x.pckt_type !=
IEEE_8021X_PACKET_TYPE_EAPOL_KEY) {
ret = 1;
return ret;
}
eapol_pkt_len = len - ETHII_HEADER_LEN;
least_len = sizeof(EAPOL_KeyMsg_t) - sizeof(rx_eapol_ptr->key_data);
if (eapol_pkt_len < least_len) {
PRINTM(MERROR,
"Invalid EAPOL Key Packet, received len: %u, least len: %u\n",
eapol_pkt_len, least_len);
ret = 1;
return ret;
}
pm_fns->Hostsa_get_station_entry(priv->pmlan_private, sta_addr,
(t_void *)&pconnPtr);
connPtr = (cm_Connection *)pconnPtr;
if (connPtr) {
// rx_eapol_ptr = (EAPOL_KeyMsg_t *)(pbuf + ETHII_HEADER_LEN);
if (rx_eapol_ptr->key_info.Error) {
ApMicCounterMeasureInvoke((t_void *)connPtr);
return ret;
}
if (!isValidReplayCount(priv, &connPtr->staData.keyMgmtInfo,
(UINT8 *)&rx_eapol_ptr->replay_cnt[0]))
{
return ret;
}
if (connPtr->staData.keyMgmtInfo.rom.keyMgmtState ==
WAITING_4_MSG2) {
status = ProcessPWKMsg2(priv, connPtr, pbuf, len);
} else if (connPtr->staData.keyMgmtInfo.rom.keyMgmtState ==
WAITING_4_MSG4) {
status = ProcessPWKMsg4(priv, connPtr, pbuf, len);
} else if ((connPtr->staData.keyMgmtInfo.rom.keyMgmtState
== WAITING_4_GRPMSG2)
|| (connPtr->staData.keyMgmtInfo.rom.keyMgmtState
== WAITING_4_GRP_REKEY_MSG2)) {
status = ProcessGrpMsg2(priv, connPtr, pbuf, len);
}
}
LEAVE();
return ret;
}
/**
* @brief send eapol packet
*
* @param psapriv A void pointer to phostsa private struct
* @param pconnPtr a pointer to connection
* @
* @return
*/
t_void
AuthenticatorSendEapolPacket(t_void *priv, t_void *pconnPtr)
{
phostsa_private psapriv = (phostsa_private)priv;
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
apInfo_t *pApInfo = &psapriv->apinfo;
ENTER();
/**check whether wpa/rsn is used*/
if (!connPtr->staData.RSNEnabled)
return;
/**init Mic error parameters*/
initMicErrorParams(pApInfo->bssConfig.SecType.wpa,
&connPtr->staData.apMicError);
connPtr->staData.keyMgmtInfo.rom.keyMgmtState = MSG1_PENDING;
//If it is in **_pending state
if (((connPtr->staData.keyMgmtInfo.rom.keyMgmtState) & 0x1) != 0) {
GenerateApEapolMsg(psapriv, connPtr,
connPtr->staData.keyMgmtInfo.rom.
keyMgmtState);
}
LEAVE();
}
/**
* @brief get station security infor from (re)assocaite request
*
* @param priv A void pointer to phostsa private struct
* @param pconnPtr a pointer to connection
* @param pIe a pointer to associate request
* @param ieLen len of ie
*
* @return
*/
void
authenticator_get_sta_security_info(void *priv,
t_void *pconnPtr, t_u8 *pIe, t_u8 ieLen)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
IEPointers_t iePointers;
IEEEtypes_StatusCode_t retcode;
ENTER();
ieLen = GetIEPointers((t_void *)priv, pIe, ieLen, &iePointers);
assocSrvAp_CheckSecurity(connPtr, iePointers.pWps,
iePointers.pRsn, iePointers.pWpa,
iePointers.pWapi, &retcode);
/* clean key */
memset(util_fns, (t_u8 *)&connPtr->hskData, 0x00,
sizeof(eapolHskData_t));
LEAVE();
}
/**
* @brief initialize client
*
* @param priv A void pointer to phostsa private struct
* @param pconnPtr a pointer to pointer to connection
* @param mac a pointer to mac address
*
* @return
*/
void
authenticator_init_client(void *priv, void **ppconnPtr, t_u8 *mac)
{
phostsa_private psapriv = (hostsa_private *)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
cm_Connection *connPtr = MNULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
ret = malloc(util_fns, sizeof(cm_Connection), (t_u8 **)&connPtr);
if ((ret != MLAN_STATUS_SUCCESS) || (!connPtr)) {
PRINTM(MERROR, "%s: could not allocate hostsa_private.\n",
__FUNCTION__);
ret = MLAN_STATUS_FAILURE;
goto done;
}
memset(util_fns, connPtr, 0x00, sizeof(cm_Connection));
connPtr->priv = priv;
memcpy(util_fns, connPtr->mac_addr, mac, MLAN_MAC_ADDR_LENGTH);
util_fns->moal_init_timer(util_fns->pmoal_handle, &connPtr->HskTimer,
KeyMgmtHskTimeout, connPtr);
util_fns->moal_init_timer(util_fns->pmoal_handle,
&connPtr->staData.apMicTimer,
ApMicErrTimerExpCb, connPtr);
done:
if (ret == MLAN_STATUS_SUCCESS)
*ppconnPtr = (void *)connPtr;
else
*ppconnPtr = MNULL;
LEAVE();
}
/**
* @brief free client
*
* @param priv A void pointer to phostsa private struct
* @param pconnPtr a pointer to connection
*
* @return
*/
void
authenticator_free_client(void *priv, void *ppconnPtr)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
cm_Connection *connPtr = (cm_Connection *)ppconnPtr;
ENTER();
if (connPtr) {
util_fns->moal_stop_timer(util_fns->pmoal_handle,
connPtr->HskTimer);
util_fns->moal_stop_timer(util_fns->pmoal_handle,
connPtr->staData.apMicTimer);
util_fns->moal_free_timer(util_fns->pmoal_handle,
connPtr->HskTimer);
util_fns->moal_free_timer(util_fns->pmoal_handle,
connPtr->staData.apMicTimer);
free(util_fns, (t_u8 *)connPtr);
}
LEAVE();
}
#endif
/**
* @brief Init hostsa data
*
* @param pphostsa_priv A pointer to pointer to a hostsa private data structure
* @param psa_util_fns A pointer to hostsa utility functions table
* @param psa_mlan_fns A pointer to MLAN APIs table
* @param addr a pointer to address
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status
supplicant_authenticator_init(t_void **pphostsa_priv, t_void *psa_util_fns,
t_void *psa_mlan_fns, t_u8 *addr)
{
hostsa_util_fns *putil_fns = (hostsa_util_fns *)psa_util_fns;
hostsa_mlan_fns *pmlan_fns = (hostsa_mlan_fns *)psa_mlan_fns;
mlan_status ret;
hostsa_private *priv = MNULL;
ENTER();
ret = malloc(putil_fns, sizeof(hostsa_private), (t_u8 **)&priv);
if ((ret != MLAN_STATUS_SUCCESS) || (!priv)) {
PRINTM(MERROR, "%s: could not allocate hostsa_private.\n",
__FUNCTION__);
ret = MLAN_STATUS_FAILURE;
goto done;
}
memset(putil_fns, priv, 0x00, sizeof(hostsa_private));
memset(putil_fns, &priv->apinfo, 0x00, sizeof(apInfo_t));
memcpy(putil_fns, &priv->util_fns, putil_fns, sizeof(hostsa_util_fns));
memcpy(putil_fns, &priv->mlan_fns, pmlan_fns, sizeof(hostsa_mlan_fns));
priv->pmlan_adapter = pmlan_fns->pmlan_adapter;
priv->pmlan_private = pmlan_fns->pmlan_private;
memcpy(putil_fns, priv->curr_addr, addr, MLAN_MAC_ADDR_LENGTH);
#ifdef DRV_EMBEDDED_AUTHENTICATOR
putil_fns->moal_init_timer(putil_fns->pmoal_handle,
&priv->GrpRekeytimer,
KeyMgmtGrpRekeyCountUpdate, priv);
/**Bss configure initialize*/
AuthenitcatorInitBssConfig(priv);
#endif
#ifdef DRV_EMBEDDED_SUPPLICANT
priv->suppData = MNULL;
allocSupplicantData(priv);
ret = initSupplicantTimer(priv);
if (ret != MLAN_STATUS_SUCCESS) {
goto done;
}
pmkCacheInit(priv);
pmkCacheRomInit();
keyMgmtSta_RomInit();
#endif
done:
if (ret == MLAN_STATUS_SUCCESS)
*pphostsa_priv = (t_void *)priv;
else
*pphostsa_priv = MNULL;
LEAVE();
return ret;
}
/**
* @brief Cleanup hostsa data
*
* @param phostsa_priv A pointer to a hostsa private data structure
*
* @return MLAN_STATUS_SUCCESS
*/
mlan_status
supplicant_authenticator_free(t_void *phostsa_priv)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
phostsa_private priv = (hostsa_private *)phostsa_priv;
hostsa_util_fns *putil_fns = &priv->util_fns;
ENTER();
if (!phostsa_priv)
goto done;
#ifdef DRV_EMBEDDED_SUPPLICANT
freeSupplicantData(priv);
freeSupplicantTimer(priv);
#endif
#ifdef DRV_EMBEDDED_AUTHENTICATOR
putil_fns->moal_stop_timer(putil_fns->pmoal_handle,
priv->GrpRekeytimer);
putil_fns->moal_free_timer(putil_fns->pmoal_handle,
priv->GrpRekeytimer);
#endif
free(putil_fns, (t_u8 *)priv);
done:
LEAVE();
return ret;
}

View File

@@ -0,0 +1,70 @@
/** @file Authenticator_api.h
*
* @brief This file delare the main APIs for authenticator.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _AUTHENTICATORAPI_H
#define _AUTHENTICATORAPI_H
/******************************************************
Change log:
03/01/2014: Initial version
******************************************************/
#ifdef DRV_EMBEDDED_AUTHENTICATOR
extern t_u8 IsAuthenticatorEnabled(void *priv);
extern void AuthenitcatorInitBssConfig(void *priv);
extern void AuthenticatorKeyMgmtInit(void *priv, t_u8 *addr);
extern void AuthenticatorkeyClear(void *priv);
extern void authenticator_init_client(void *priv, void **ppconnPtr, t_u8 *mac);
extern void authenticator_free_client(void *priv, void *ppconnPtr);
extern void authenticator_get_sta_security_info(void *priv,
t_void *pconnPtr, t_u8 *pIe,
t_u8 ieLen);
extern t_void AuthenticatorSendEapolPacket(t_void *priv, t_void *pconnPtr);
extern t_u8 AuthenticatorProcessEapolPacket(void *priv, t_u8 *pbuf, t_u32 len);
extern t_u8 AuthenticatorBssConfig(void *priv, t_u8 *pbss_config, t_u8 appendIE,
t_u8 clearIE, t_u8 SetConfigToMlan);
#endif
mlan_status supplicant_authenticator_init(t_void **pphostsa_priv,
t_void *psa_util_fns,
t_void *psa_mlan_fns, t_u8 *addr);
mlan_status supplicant_authenticator_free(t_void *phostsa_priv);
#ifdef DRV_EMBEDDED_SUPPLICANT
extern void supplicantClrEncryptKey(void *priv);
extern void *processRsnWpaInfo(void *priv, void *prsnwpa_ie);
extern void pmkCacheDeletePMK(void *priv, t_u8 *pBssid);
extern void supplicantInitSession(void *priv,
t_u8 *pSsid,
t_u16 len, t_u8 *pBssid, t_u8 *pStaAddr);
extern void supplicantStopSessionTimer(void *priv);
extern t_u8 supplicantIsEnabled(void *priv);
extern void supplicantQueryPassphraseAndEnable(void *priv, t_u8 *pbuf);
extern void supplicantDisable(void *priv);
extern t_u8 ProcessEAPoLPkt(void *priv, mlan_buffer *pmbuf);
extern t_u8 EAPoLKeyPkt_Validation(mlan_buffer *pmbuf);
extern void SupplicantClearPMK(void *priv, void *pPassphrase);
extern t_u16 SupplicantSetPassphrase(void *priv, void *pPassphraseBuf);
extern void SupplicantQueryPassphrase(void *priv, void *pPassphraseBuf);
extern t_u8 supplicantFormatRsnWpaTlv(void *priv, void *rsn_wpa_ie,
void *rsn_ie_tlv);
#endif
#endif /**_AUTHENTICATORAPI_H*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/** @file aes_cmac.h
*
* @brief This file contains defines for aes_cmac
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _AES_CMAC_H_
#define _AES_CMAC_H_
#include "wltypes.h"
#include "aes_cmac_rom.h"
/* ROM Pointers Init */
extern void aes_cmacRomInit(void);
#endif

View File

@@ -0,0 +1,183 @@
/** @file aes_cmac_rom.c
*
* @brief This file defines aes cmac related function
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wl_macros.h"
#include "wltypes.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "crypt_new_rom.h"
#include "aes_cmac_rom.h"
//#pragma diag_default 144
//#pragma arm section rwdata
// End - patch table entries
/* For CMAC Calculation */
static UINT8 const_Rb[16] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87
};
void
mrvl_aes_128(UINT8 *key, UINT8 *input, UINT8 *output)
{
// BOOLEAN weuEnabled;
#if 0
if (IS_AEU_CLK_ENBLD()) {
weuEnabled = TRUE;
} else {
weuEnabled = FALSE;
}
#endif
/* keyLen = 128 bit / 8 bits/byte / 8 for MRVL API encoding == 2 */
MRVL_AesEncrypt(key, (128 / 8) / 8, input, output);
}
/* Basic Functions */
void
xor_128(UINT8 *a, UINT8 *b, UINT8 *out)
{
int i;
for (i = 0; i < 16; i++) {
out[i] = a[i] ^ b[i];
}
}
/* AES-CMAC Generation Function */
void
leftshift_onebit(UINT8 *input, UINT8 *output)
{
int i;
UINT8 overflow = 0;
for (i = 15; i >= 0; i--) {
output[i] = input[i] << 1;
output[i] |= overflow;
overflow = (input[i] & 0x80) ? 1 : 0;
}
}
void
generate_subkey(phostsa_private priv, UINT8 *key, UINT8 *K1, UINT8 *K2)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 L[16];
UINT8 Z[16];
UINT8 tmp[16];
memset(util_fns, Z, 0x00, sizeof(Z));
mrvl_aes_128(key, Z, L);
if ((L[0] & 0x80) == 0) {
/* If MSB(L) = 0, then K1 = L << 1 */
leftshift_onebit(L, K1);
} else {
/* Else K1 = ( L << 1 ) (+) Rb */
leftshift_onebit(L, tmp);
xor_128(tmp, const_Rb, K1);
}
if ((K1[0] & 0x80) == 0) {
leftshift_onebit(K1, K2);
} else {
leftshift_onebit(K1, tmp);
xor_128(tmp, const_Rb, K2);
}
}
void
padding(UINT8 *lastb, UINT8 *pad, int length)
{
int j;
/* original last block */
for (j = 0; j < 16; j++) {
if (j < length) {
pad[j] = lastb[j];
} else if (j == length) {
pad[j] = 0x80;
} else {
pad[j] = 0x00;
}
}
}
void
mrvl_aes_cmac(phostsa_private priv, UINT8 *key, UINT8 *input, int length,
UINT8 *mac)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 X[16];
UINT8 Y[16];
UINT8 M_last[16];
UINT8 padded[16];
UINT8 K1[16];
UINT8 K2[16];
int n, i, flag;
generate_subkey(priv, key, K1, K2);
n = (length + 15) / 16; /* n is number of rounds */
if (n == 0) {
n = 1;
flag = 0;
} else {
if ((length % 16) == 0) {
/* last block is a complete block */
flag = 1;
} else {
/* last block is not complete block */
flag = 0;
}
}
if (flag) {
/* last block is complete block */
xor_128(&input[16 * (n - 1)], K1, M_last);
} else {
padding(&input[16 * (n - 1)], padded, length % 16);
xor_128(padded, K2, M_last);
}
memset(util_fns, X, 0x00, sizeof(X));
for (i = 0; i < n - 1; i++) {
xor_128(X, &input[16 * i], Y); /* Y := Mi (+) X */
mrvl_aes_128(key, Y, X); /* X := AES-128(KEY, Y); */
}
xor_128(X, M_last, Y);
mrvl_aes_128(key, Y, X);
for (i = 0; i < 16; i++) {
mac[i] = X[i];
}
}

View File

@@ -0,0 +1,46 @@
/** @file aes_cmac_rom.h
*
* @brief This file contains the define for aes_cmac_rom
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _AES_CMAC_ROM_H_
#define _AES_CMAC_ROM_H_
#include "wltypes.h"
extern BOOLEAN (*mrvl_aes_cmac_hook) (UINT8 *key, UINT8 *input, int length,
UINT8 *mac);
extern void mrvl_aes_cmac(phostsa_private priv, UINT8 *key, UINT8 *input,
int length, UINT8 *mac);
extern BOOLEAN (*mrvl_aes_128_hook) (UINT8 *key, UINT8 *input, UINT8 *output);
extern void mrvl_aes_128(UINT8 *key, UINT8 *input, UINT8 *output);
/* RAM Linkages */
extern void (*rom_hal_EnableWEU) (void);
extern void (*rom_hal_DisableWEU) (void);
extern void xor_128(UINT8 *a, UINT8 *b, UINT8 *out);
extern void leftshift_onebit(UINT8 *input, UINT8 *output);
extern void padding(UINT8 *lastb, UINT8 *pad, int length);
#endif

View File

@@ -0,0 +1,77 @@
/** @file crypt_new.h
*
* @brief This file contains define for rc4 decrypt/encrypt
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
/*
* AES API header file
*
*/
#ifndef _CRYPT_NEW_H_
#define _CRYPT_NEW_H_
#include "crypt_new_rom.h"
/* forward decl */
typedef void (*MRVL_ENDECRYPT_FUNC_p) (MRVL_ENDECRYPT_t *enDeCrypt, int *pErr);
#if 0
#if (HW_IP_AEU_VERSION < 100000)
#ifdef WAPI_HW_SUPPORT
extern void MRVL_WapiEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_WapiDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
#define MRVL_WAPI_ENCRYPT MRVL_WapiEncrypt
#define MRVL_WAPI_DECRYPT MRVL_WapiDecrypt
#endif
#ifdef DIAG_AES_CCM
#define MRVL_AES_CCM_ENCRYPT MRVL_AesCCMEncrypt
#define MRVL_AES_CCM_DECRYPT MRVL_AesCCMDecrypt
#endif
#endif /*(HW_IP_AEU_VERSION < 100000) */
#endif
#define MRVL_AES_PRIMITIVE_ENCRYPT MRVL_AesPrimitiveEncrypt
#define MRVL_AES_PRIMITIVE_DECRYPT MRVL_AesPrimitiveDecrypt
#define MRVL_AES_WRAP_ENCRYPT MRVL_AesWrapEncrypt
#define MRVL_AES_WRAP_DECRYPT MRVL_AesWrapDecrypt
#ifdef RC4
#define MRVL_RC4_ENCRYPT MRVL_Rc4Cryption
#define MRVL_RC4_DECRYPT MRVL_Rc4Cryption
#endif /* RC4 */
typedef struct {
MRVL_ENDECRYPT_e action;
MRVL_ENDECRYPT_FUNC_p pActionFunc;
} MRVL_ENDECRYPT_SETUP_t;
extern MRVL_ENDECRYPT_SETUP_t mrvlEnDecryptSetup[2][6];
extern void cryptNewRomInit(void);
#endif /* _CRYPT_NEW_H_ */

View File

@@ -0,0 +1,890 @@
/** @file crypt_new_rom.c
*
* @brief This file defines AES based functions.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
/*
* AES based functions
*
* - AES Key Wrap algorithm (128-bit KEK) (RFC-3394)
* - AES primitive algorithm
* - AES CCM algorithm
*
* Date: 11/01/2005
*/
#include "wltypes.h"
#include "crypt_new_rom.h"
#include "rc4_rom.h"
#include "rijndael.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
static const UINT8 MRVL_DEFAULT_IV[8] = { 0xA6, 0xA6, 0xA6, 0xA6,
0xA6, 0xA6, 0xA6, 0xA6
};
UINT8 aesResult[32];
/* MRVL_AES_MEMCMP
* : similiar to memcmp in std c lib
* @dst : dst ptr to be compared to
* @src : src ptr to be compared from
* @len : size of the comparison
*
* ASSUMPTION : dst/src has to be valid data ptrs
*/
int
MRVL_AES_MEMCMP(UINT8 *dst, UINT8 *src, int len)
{
int cnt = len;
while (len--) {
if (*dst++ == *src++) {
cnt--;
}
}
if (0 == cnt) {
return 0; /* dst == src */
}
return -1; /* dst != src */
}
/* MRVL_AES_MEMSET
* : similiar to memset in std c lib
* @dst : dst starting pointer
* @val : val to be set
* @size : size of dst buffer to be set
*
* ASSUMPTION : dst buffer must always have larger than the value of size
*/
void
MRVL_AES_MEMSET(UINT8 *dst, UINT8 val, int size)
{
while (size--) {
*dst++ = val;
}
}
/* MRVL_AES_MEMCPY
* : similar to memcpy in std c lib
* @dst : dst buffer starting ptr
* @src : src buffer starting ptr
* @size : size of copy
*
* ASSUMPTION :
* 1: dst buffer must be larger than src + size of copy
* 2: dst buffer isn't overlapping src buffer
*/
void
MRVL_AES_MEMCPY(UINT8 *dst, UINT8 *src, int size)
{
if (dst < src) {
while (size) {
*dst++ = *src++;
size--;
}
} else {
while (size) {
*(dst + size - 1) = *(src + size - 1);
size--;
}
}
}
int
MRVL_AesInterCheck(UINT8 *inter, UINT8 *d)
{
if (0 == MRVL_AES_MEMCMP(inter, d, 16)) {
return 0;
}
return -1;
}
#ifdef WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH
extern const u8 Te4[256];
extern const u32 rcon[];
extern const u32 Td0[256];
extern const u32 Td1[256];
extern const u32 Td2[256];
extern const u32 Td3[256];
#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
static int
rijndaelKeySetupEnc_2(u32 rk[ /*4*(Nr + 1) */ ], const u8 cipherKey[],
int keyBits)
{
int i = 0;
u32 temp;
rk[0] = GETU32(cipherKey);
rk[1] = GETU32(cipherKey + 4);
rk[2] = GETU32(cipherKey + 8);
rk[3] = GETU32(cipherKey + 12);
if (keyBits == 128) {
for (;;) {
temp = rk[3];
rk[4] = rk[0] ^
(Te4[(temp >> 16) & 0xff] << 24) ^
(Te4[(temp >> 8) & 0xff] << 16) ^
(Te4[(temp) & 0xff] << 8) ^
(Te4[(temp >> 24)]) ^ rcon[i];
rk[5] = rk[1] ^ rk[4];
rk[6] = rk[2] ^ rk[5];
rk[7] = rk[3] ^ rk[6];
if (++i == 10) {
return 10;
}
rk += 4;
}
}
/** Handle 24 bytes key length */
rk[4] = GETU32(cipherKey + 16);
rk[5] = GETU32(cipherKey + 20);
if (keyBits == 192) {
for (;;) {
temp = rk[5];
rk[6] = rk[0] ^
(Te4[(temp >> 16) & 0xff] << 24) ^
(Te4[(temp >> 8) & 0xff] << 16) ^
(Te4[(temp) & 0xff] << 8) ^
(Te4[(temp >> 24)]) ^ rcon[i];
rk[7] = rk[1] ^ rk[6];
rk[8] = rk[2] ^ rk[7];
rk[9] = rk[3] ^ rk[8];
if (++i == 8) {
return 12;
}
rk[10] = rk[4] ^ rk[9];
rk[11] = rk[5] ^ rk[10];
rk += 6;
}
}
/** Handle 32 bytes key length */
rk[6] = GETU32(cipherKey + 24);
rk[7] = GETU32(cipherKey + 28);
if (keyBits == 256) {
for (;;) {
temp = rk[7];
rk[8] = rk[0] ^
(Te4[(temp >> 16) & 0xff] << 24) ^
(Te4[(temp >> 8) & 0xff] << 16) ^
(Te4[(temp) & 0xff] << 8) ^
(Te4[(temp >> 24)]) ^ rcon[i];
rk[9] = rk[1] ^ rk[8];
rk[10] = rk[2] ^ rk[9];
rk[11] = rk[3] ^ rk[10];
if (++i == 7) {
return 14;
}
temp = rk[11];
rk[12] = rk[4] ^
(Te4[(temp >> 24)] << 24) ^
(Te4[(temp >> 16) & 0xff] << 16) ^
(Te4[(temp >> 8) & 0xff] << 8) ^
(Te4[(temp) & 0xff]);
rk[13] = rk[5] ^ rk[12];
rk[14] = rk[6] ^ rk[13];
rk[15] = rk[7] ^ rk[14];
rk += 8;
}
}
return 0;
}
static int
rijndaelKeySetupDec_2(u32 rk[ /*4*(Nr + 1) */ ], const u8 cipherKey[],
int keyBits, int have_encrypt)
{
int Nr, i, j;
u32 temp;
if (have_encrypt) {
Nr = have_encrypt;
} else {
/* expand the cipher key: */
Nr = rijndaelKeySetupEnc_2(rk, cipherKey, keyBits);
}
/* invert the order of the round keys: */
for (i = 0, j = 4 * Nr; i < j; i += 4, j -= 4) {
temp = rk[i];
rk[i] = rk[j];
rk[j] = temp;
temp = rk[i + 1];
rk[i + 1] = rk[j + 1];
rk[j + 1] = temp;
temp = rk[i + 2];
rk[i + 2] = rk[j + 2];
rk[j + 2] = temp;
temp = rk[i + 3];
rk[i + 3] = rk[j + 3];
rk[j + 3] = temp;
}
/* apply the inverse MixColumn transform to all round keys but the first and the last: */
for (i = 1; i < Nr; i++) {
rk += 4;
rk[0] = Td0[Te4[(rk[0] >> 24)]] ^
Td1[Te4[(rk[0] >> 16) & 0xff]] ^
Td2[Te4[(rk[0] >> 8) & 0xff]] ^
Td3[Te4[(rk[0]) & 0xff]];
rk[1] = Td0[Te4[(rk[1] >> 24)]] ^
Td1[Te4[(rk[1] >> 16) & 0xff]] ^
Td2[Te4[(rk[1] >> 8) & 0xff]] ^
Td3[Te4[(rk[1]) & 0xff]];
rk[2] = Td0[Te4[(rk[2] >> 24)]] ^
Td1[Te4[(rk[2] >> 16) & 0xff]] ^
Td2[Te4[(rk[2] >> 8) & 0xff]] ^
Td3[Te4[(rk[2]) & 0xff]];
rk[3] = Td0[Te4[(rk[3] >> 24)]] ^
Td1[Te4[(rk[3] >> 16) & 0xff]] ^
Td2[Te4[(rk[3] >> 8) & 0xff]] ^
Td3[Te4[(rk[3]) & 0xff]];
}
return Nr;
}
static void
rijndael_set_key_2(rijndael_ctx *ctx, u8 *key, int bits, int encrypt)
{
ctx->Nr = rijndaelKeySetupEnc_2(ctx->key, key, bits);
if (encrypt) {
ctx->decrypt = 0;
} else {
ctx->decrypt = 1;
rijndaelKeySetupDec_2(ctx->key, key, bits, ctx->Nr);
/**bt_test :: TBD */
}
}
#endif /** WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH */
/*
* AesEncrypt : aes primitive encryption
*
* @kek : key encryption key
* @kekLen : kek len
* @data : data pointer
*
* ASSUMPTION : both src and dst buffer has to be 16 bytes or 128-bit
*/
int
MRVL_AesEncrypt(UINT8 *kek, UINT8 kekLen, UINT8 *data, UINT8 *ret)
{
//BufferDesc_t * pDesc = NULL;
UINT8 buf[400] = { 0 };
rijndael_ctx *ctx;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
int ptr_val;
if (MRVL_AesEncrypt_hook(kek, kekLen, data, ret, &ptr_val)) {
return ptr_val;
}
#endif
#if 0
/* Wait forever ensures a buffer */
pDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
400, BML_WAIT_FOREVER);
#endif
//ctx = (rijndael_ctx *)BML_DATA_PTR(pDesc);
ctx = (rijndael_ctx *)buf;
#ifdef WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH
rijndael_set_key_2(ctx, (UINT8 *)kek, kekLen * 64, 1);
#else
rijndael_set_key(ctx, (UINT8 *)kek, kekLen * 64, 1);
#endif /** WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH */
rijndael_encrypt(ctx, data, ret);
// bml_FreeBuffer((UINT32)pDesc);
return 0;
}
/****************************************************************
* AES_WRAP : AES_WRAP is specified by RFC 3394 section 2.2.1
*
* Inputs : plaintest, n 64-bit values {P1, P2, ..., Pn}, and
* Key, K (the KEK)
* Outputs : ciphertext, (n+1) 64-bit values {C0, ..., Cn}
*
* NOTE: this function is ported over from WPA_SUPPLICANT
****************************************************************
*
* @kek : key encryption key
* @kekLen : kek len, in unit of 64-bit, has to be 2, 3, or 4
* @n : length of the wrapped key in 64-bit
* unit; e.g.: 2 = 128-bit = 16 bytes
* @plain : plaintext key to be wrapped, has to be n * (64-bit)
* or n * 8 bytes
* @cipher : wrapped key, (n + 1) * 64-bit or (n+1) * 8 bytes
*/
/* debugging */
int
MRVL_AesWrap(UINT8 *kek, UINT8 kekLen, UINT32 n,
UINT8 *plain, UINT8 *keyIv, UINT8 *cipher)
{
UINT8 a[8];
UINT8 b[16];
int i = 0;
int j = 0;
UINT8 *r = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
int ptr_val;
if (MRVL_AesWrap_hook(kek, kekLen, n, plain, keyIv, cipher, &ptr_val)) {
return ptr_val;
}
#endif
/* 0: before everything, check n value
*/
if (1 > n) {
return -1;
}
r = cipher + 8;
/* 1: initialize variables */
MRVL_AES_MEMSET(b, 0x0, 16);
if (keyIv) {
MRVL_AES_MEMCPY(a, keyIv, 8);
} else {
MRVL_AES_MEMCPY(a, (UINT8 *)MRVL_DEFAULT_IV, 8);
}
MRVL_AES_MEMCPY(r, plain, (8 * n));
/* 2: calculate intermediate values
* For j = 0 to 5
* For i=1 to n
* B = AES(K, A | R[i])
* A = MSB(64, B) ^ t where t = (n*j)+i
* R[i] = LSB(64, B)
*/
for (j = 0; j <= 5; j++) {
r = cipher + 8;
for (i = 1; i <= n; i++) {
MRVL_AES_MEMCPY(b, a, 8);
MRVL_AES_MEMCPY(b + 8, r, 8);
MRVL_AesEncrypt(kek, kekLen, b, b);
MRVL_AES_MEMCPY(a, b, 8);
a[7] ^= n * j + i;
MRVL_AES_MEMCPY(r, b + 8, 8);
r += 8;
}
}
MRVL_AES_MEMCPY(cipher, a, 8);
/* 3: output the results
* these are already in @cipher
*/
return 0;
}
/****************************************************************
* AES_UNWRAP : AES_UNWRAP is specified by RFC 3394 section 2.2.2
*
* Inputs : ciphertext, (n+1) 64-bit values {C0, ..., Cn}, and
* Key, K (the KEK)
*
* Outputs : plaintest, n 64-bit values {P1, P2, ..., Pn} + first 8 bytes
* for KEYIV
*
*
****************************************************************
*
* @kek : key encryption key
* @kekLen : kek len, in unit of 64-bit, has to be 2, 3, or 4
* @n : length of the wrapped key in 64-bit
* unit; e.g.: 2 = 128-bit = 16 bytes
* @cipher : wrapped data, (n + 1) * 64-bit or (n+1) * 8 bytes
* @plain : plaintext being unwrapped, has to be n * (64-bit)
* or n * 8 bytes + extra 8 bytes for KEYIV
*/
int
MRVL_AesUnWrap(UINT8 *kek, UINT8 kekLen, UINT32 n,
UINT8 *cipher, UINT8 *keyIv, UINT8 *plain)
{
UINT8 b[16];
int i = 0;
int j = 0;
UINT8 a[8];
UINT8 *r = NULL;
//BufferDesc_t * pDesc = NULL;
UINT8 buf[400] = { 0 };
rijndael_ctx *ctx;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
int ptr_val;
if (MRVL_AesUnWrap_hook(kek, kekLen, n, cipher, keyIv, plain, &ptr_val)) {
return ptr_val;
}
#endif
/* 0: before everything, check n value
*/
if (1 > n) {
return -1;
}
/* 1: initialize variables */
MRVL_AES_MEMSET(a, 0x0, 8);
MRVL_AES_MEMSET(b, 0x0, 16);
MRVL_AES_MEMCPY(a, cipher, 8);
r = plain;
MRVL_AES_MEMCPY(r, cipher + 8, 8 * n);
#if 0
/* Wait forever ensures a buffer */
pDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
400, BML_WAIT_FOREVER);
#endif
//ctx = (rijndael_ctx *)BML_DATA_PTR(pDesc);
ctx = (rijndael_ctx *)buf;
#ifdef WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH
rijndael_set_key_2(ctx, (UINT8 *)kek, kekLen * 64, 0);
#else
rijndael_set_key(ctx, (UINT8 *)kek, kekLen * 64, 0);
#endif /** WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH */
/* 2: compute intermediate values
* For j = 5 to 0
* For i = n to 1
* B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i
* A = MSB(64, B)
* R[i] = LSB(64, B)
*/
for (j = 5; j >= 0; j--) {
r = plain + (n - 1) * 8;
for (i = n; i >= 1; i--) {
MRVL_AES_MEMCPY(b, a, 8);
b[7] ^= n * j + i;
MRVL_AES_MEMCPY(b + 8, r, 8);
rijndael_decrypt(ctx, b, b);
MRVL_AES_MEMCPY(a, b, 8);
MRVL_AES_MEMCPY(r, b + 8, 8);
r -= 8;
}
}
// bml_FreeBuffer((UINT32)pDesc);
/* 3: copy decrypted KeyIV to keyIv array */
if (keyIv) {
if (MRVL_AES_MEMCMP(keyIv, a, 8)) {
return -1;
}
} else {
if (MRVL_AES_MEMCMP((UINT8 *)MRVL_DEFAULT_IV, a, 8)) {
return -1;
}
}
return 0;
}
#if 0
/*****
* AES CRYPTION HELPER FUNCTIONS
*
*/
int
MRVL_AesValidateHostRequest(UINT32 *pBitMap, UINT8 *pCmdPtr,
UINT8 *pCryptData, SINT8 *AESwrapEnc)
{
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEParamSet_t *pLocalIEParam = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
int ptr_val;
if (MRVL_AesValidateHostRequest_hook(pBitMap,
pCmdPtr,
pCryptData,
AESwrapEnc, &ptr_val)) {
return ptr_val;
}
#endif
if (NULL == pBitMap || NULL == pCmdPtr) {
return -1;
}
pLocal = (host_MRVL_AES_CRYPT_t *) pCmdPtr;
pLocalIEParam = (MrvlIEParamSet_t *)&(pLocal->aesTlv);
if ((0 != pLocal->action) && (0x1 != pLocal->action)) {
*pBitMap |= MRVL_AES_NOT_EN_AND_DECRYPT;
}
if (0 == pLocal->action) {
((MRVL_ENDECRYPT_t *)pCryptData)->enDeAction = CRYPT_DECRYPT;
} else if (1 == pLocal->action) {
((MRVL_ENDECRYPT_t *)pCryptData)->enDeAction = CRYPT_ENCRYPT;
}
switch (pLocal->algorithm) {
case MRVL_CRYPTO_TEST_RC4:
if ((1 > (pLocal->keyIVLen + pLocal->keyLen)) ||
(256 < (pLocal->keyIVLen + pLocal->keyLen))) {
*pBitMap |= MRVL_AES_KEY_IV_INVALID_RC4;
}
break;
case MRVL_CRYPTO_TEST_AES_ECB:
if ((16 != pLocal->keyLen) &&
(24 != pLocal->keyLen) && (32 != pLocal->keyLen)) {
*pBitMap |= MRVL_AES_KEY_SIZE_INVALID;
}
if ((16 != pLocalIEParam->Length)) {
*pBitMap |= MRVL_AES_DATA_SIZE_INVALID;
}
break;
case MRVL_CRYPTO_TEST_AES_WRAP:
if (8 != pLocal->keyIVLen) {
*pBitMap |= MRVL_AES_KEY_IV_INVALID_AES_WRAP;
}
if ((16 != pLocal->keyLen) &&
(24 != pLocal->keyLen) && (32 != pLocal->keyLen)) {
*pBitMap |= MRVL_AES_KEY_SIZE_INVALID;
}
if ((1016 < pLocalIEParam->Length) ||
(8 > pLocalIEParam->Length)) {
*pBitMap |= MRVL_AES_DATA_SIZE_INVALID;
}
if (1 == pLocal->action) { /* Encryption */
*AESwrapEnc = 8;
} else if (0 == pLocal->action) { /* Decryption */
*AESwrapEnc = -8;
}
break;
#ifdef DIAG_AES_CCM
case MRVL_CRYPTO_TEST_AEC_CCM:
{
host_MRVL_AES_CCM_CRYPT_t *pLocalCCM
= (host_MRVL_AES_CCM_CRYPT_t *) pCmdPtr;
pLocalIEParam =
(MrvlIEParamSet_t *)&(pLocalCCM->aesTlv);
/* key length should be 16 */
if ((16 != pLocalCCM->keyLen) &&
(24 != pLocalCCM->keyLen) &&
(32 != pLocalCCM->keyLen)) {
*pBitMap |= MRVL_AES_KEY_SIZE_INVALID;
}
/* nonce length 7 ~ 13 bytes */
if ((pLocalCCM->nonceLen < 7) ||
(pLocalCCM->nonceLen > 13)) {
*pBitMap |= MRVL_AES_NONCE_INVALID;
}
/* AAD length 0 ~ 30 bytes */
if (pLocalCCM->aadLen > 30) {
*pBitMap |= MRVL_AES_AAD_INVALID;
}
/* payload length 0 ~ 32 bytes */
if (40 < pLocalIEParam->Length) {
*pBitMap |= MRVL_AES_DATA_SIZE_INVALID;
}
}
break;
#endif
#ifdef WAPI_HW_SUPPORT
case MRVL_CRYPTO_TEST_WAPI:
{
host_MRVL_WAPI_CRYPT_t *pLocalWAPI
= (host_MRVL_WAPI_CRYPT_t *) pCmdPtr;
/* key length should be 16 */
if (pLocalWAPI->keyLen != 32) {
*pBitMap |= MRVL_AES_KEY_SIZE_INVALID;
}
/* nonce length 16 bytes */
if (pLocalWAPI->nonceLen != 16) {
*pBitMap |= MRVL_AES_NONCE_INVALID;
}
/* AAD length 32 or 48 bytes */
if ((pLocalWAPI->aadLen != 32) &&
(pLocalWAPI->aadLen != 48)) {
*pBitMap |= MRVL_AES_AAD_INVALID;
}
}
break;
#endif
default:
*pBitMap |= MRVL_AES_ALGORITHM_INVALID;
break;
}
/* put the buffer ptr to cryptdata */
((MRVL_ENDECRYPT_t *)pCryptData)->pData = pCmdPtr;
return 0;
}
/**************
* WRAPPER to do AES primitive encryption
*/
void
MRVL_AesPrimitiveEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr)
{
UINT8 *kek = NULL;
UINT8 *data = NULL;
UINT8 kekLen = 0;
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEAesCrypt_t *pLocalIEParam = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (MRVL_AesPrimitiveEncrypt_hook(crypt, pErr)) {
return;
}
#endif
if ((NULL == pErr) || (NULL == crypt)) {
*pErr = -1;
return;
}
*pErr = 0;
if ((CRYPT_ENCRYPT != crypt->enDeAction)) {
*pErr = -1;
return;
}
pLocal = (host_MRVL_AES_CRYPT_t *) (crypt->pData);
pLocalIEParam = (MrvlIEAesCrypt_t *)&(pLocal->aesTlv);
kek = (UINT8 *)(pLocal->key);
kekLen = pLocal->keyLen;
data = (UINT8 *)(pLocalIEParam->payload);
if (-1 == MRVL_AesEncrypt(kek, kekLen / 8, data, data)) {
*pErr = -1;
return;
}
}
void
MRVL_AesPrimitiveDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr)
{
UINT8 *kek = NULL;
UINT8 *data = NULL;
UINT8 kekLen = 0;
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEAesCrypt_t *pLocalIEParam = NULL;
BufferDesc_t *pDesc;
rijndael_ctx *ctx;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (MRVL_AesPrimitiveDecrypt_hook(crypt, pErr)) {
return;
}
#endif
if ((NULL == pErr) || (NULL == crypt)) {
*pErr = -1;
return;
}
if ((CRYPT_DECRYPT != crypt->enDeAction)) {
*pErr = -1;
return;
}
pLocal = (host_MRVL_AES_CRYPT_t *) (crypt->pData);
pLocalIEParam = (MrvlIEAesCrypt_t *)&(pLocal->aesTlv);
kek = (UINT8 *)(pLocal->key);
kekLen = pLocal->keyLen;
data = (UINT8 *)(pLocalIEParam->payload);
#if 0
/* Wait forever ensures a buffer */
pDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
400, BML_WAIT_FOREVER);
#endif
ctx = (rijndael_ctx *)BML_DATA_PTR(pDesc);
#ifdef WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH
rijndael_set_key_2(ctx, (UINT8 *)kek, kekLen * 8, 0);
#else
rijndael_set_key(ctx, (UINT8 *)kek, kekLen * 8, 0);
#endif /** WAR_ROM_BUG64609_SUPPORT_24_32_BYTES_KEY_LENGTH */
rijndael_decrypt(ctx, data, data);
bml_FreeBuffer((UINT32)pDesc);
*pErr = 0;
}
void
MRVL_AesWrapEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr)
{
UINT8 *kek = NULL;
UINT8 *data = NULL;
UINT8 *keyIV = NULL;
UINT8 kekLen = 0;
UINT32 dataLen = 0;
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEAesCrypt_t *pLocalIEParam = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (MRVL_AesWrapEncrypt_hook(crypt, pErr)) {
return;
}
#endif
if ((NULL == pErr) || (NULL == crypt)) {
*pErr = -1;
return;
}
*pErr = 0;
if ((CRYPT_ENCRYPT != crypt->enDeAction)) {
*pErr = -1;
return;
}
pLocal = (host_MRVL_AES_CRYPT_t *) (crypt->pData);
pLocalIEParam = (MrvlIEAesCrypt_t *)&(pLocal->aesTlv);
kek = (UINT8 *)(pLocal->key);
keyIV = (UINT8 *)(pLocal->keyIV);
kekLen = pLocal->keyLen;
data = (UINT8 *)(pLocalIEParam->payload);
dataLen = pLocalIEParam->hdr.Length;
/* need to add one more 8-bytes for return length */
pLocalIEParam->hdr.Length = dataLen + 8;
if (-1 ==
MRVL_AesWrap(kek, kekLen / 8, dataLen / 8, data, keyIV,
aesResult)) {
*pErr = -2;
return;
}
MRVL_AES_MEMCPY(data, aesResult, pLocalIEParam->hdr.Length);
}
void
MRVL_AesWrapDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr)
{
UINT8 *kek = NULL;
UINT8 *keyIV = NULL;
UINT8 *data = NULL;
UINT8 kekLen = 0;
UINT32 dataLen = 0;
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEAesCrypt_t *pLocalIEParam = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (MRVL_AesWrapDecrypt_hook(crypt, pErr)) {
return;
}
#endif
if ((NULL == pErr) || (NULL == crypt)) {
*pErr = -1;
return;
}
*pErr = 0;
if ((CRYPT_DECRYPT != crypt->enDeAction)) {
*pErr = -1;
return;
}
pLocal = (host_MRVL_AES_CRYPT_t *) (crypt->pData);
pLocalIEParam = (MrvlIEAesCrypt_t *)&(pLocal->aesTlv);
kek = (UINT8 *)(pLocal->key);
keyIV = (UINT8 *)(pLocal->keyIV);
kekLen = pLocal->keyLen;
data = (UINT8 *)(pLocalIEParam->payload);
dataLen = pLocalIEParam->hdr.Length;
if (-1 == MRVL_AesUnWrap(kek, kekLen / 8, dataLen / 8 - 1,
data, keyIV, aesResult)) {
*pErr = -2;
return;
}
dataLen -= 8;
pLocalIEParam->hdr.Length = dataLen;
MRVL_AES_MEMCPY(data, aesResult, dataLen);
}
#endif
#ifdef RC4
void
MRVL_Rc4Cryption(void *priv, MRVL_ENDECRYPT_t *crypt, int *pErr)
{
host_MRVL_AES_CRYPT_t *pLocal = NULL;
MrvlIEAesCrypt_t *pLocalIEParam = NULL;
UINT8 *key = NULL;
UINT8 *keyIV = NULL;
UINT8 *data = NULL;
UINT32 dataLen = 0;
if ((NULL == pErr) || (NULL == crypt)) {
*pErr = -1;
return;
}
*pErr = 0;
/* since RC4 encrypt/decrypt are the same */
if ((CRYPT_DECRYPT != crypt->enDeAction) &&
(CRYPT_ENCRYPT != crypt->enDeAction)) {
*pErr = -2;
return;
}
pLocal = (host_MRVL_AES_CRYPT_t *) (crypt->pData);
pLocalIEParam = (MrvlIEAesCrypt_t *)&(pLocal->aesTlv);
key = (UINT8 *)(pLocal->key);
data = (UINT8 *)(pLocalIEParam->payload);
keyIV = (UINT8 *)(pLocal->keyIV);
dataLen = pLocalIEParam->hdr.Length;
RC4_Encrypt(priv, key, keyIV, pLocal->keyIVLen, data, dataLen, 0);
return;
}
#endif /* RC4 */

View File

@@ -0,0 +1,167 @@
/** @file crypt_new_rom.c
*
* @brief This file contains the api for AES based functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _CRYPT_NEW_ROM_H_
#define _CRYPT_NEW_ROM_H_
#define MRVL_AES_CMD_REQUEST_TYPE_INVALID (1)
#define MRVL_AES_ALGORITHM_INVALID (1<<1)
#define MRVL_AES_KEY_SIZE_INVALID (1<<2)
#define MRVL_AES_KEY_IV_SIZE_INVALID (1<<3)
#define MRVL_AES_ENCRYPT_DATA_OVER_127 (1<<4)
#define MRVL_AES_ENCRYPT_DATA_LESS_2 (1<<5)
#define MRVL_AES_NOT_EN_AND_DECRYPT (1<<6)
#define MRVL_AES_KEY_IV_INVALID_AES (1<<7)
#define MRVL_AES_KEY_IV_INVALID_AES_WRAP (1<<8)
#define MRVL_AES_KEY_IV_INVALID_RC4 (1<<9)
#define MRVL_AES_DATA_SIZE_INVALID (1<<10)
#define MRVL_AES_NONCE_INVALID (1<<11)
#define MRVL_AES_AAD_INVALID (1<<12)
#define host_AES_ENCRYPT 0x1
#define host_AES_DECRYPT 0x0
#define MRVL_CRYPTO_TEST_RC4 1
#define MRVL_CRYPTO_TEST_AES_ECB 2
#define MRVL_CRYPTO_TEST_AES_WRAP 3
#define MRVL_CRYPTO_TEST_AEC_CCM 4
#define MRVL_CRYPTO_TEST_WAPI 5
/* basic data structs to support AES feature */
/* enum for encrypt/decrypt */
typedef enum {
CRYPT_DECRYPT = 0,
CRYPT_ENCRYPT = 1,
CRYPT_UNKNOWN
} MRVL_ENDECRYPT_e;
/* data strcut to hold action type and data to be processed */
typedef struct {
UINT8 enDeAction; /* encrypt or decrypt */
UINT8 *pData;
} MRVL_ENDECRYPT_t;
#ifdef WAPI_HW_SUPPORT
extern void MRVL_WapiEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_WapiDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
#endif
extern BOOLEAN (*MRVL_AesPrimitiveEncrypt_hook) (MRVL_ENDECRYPT_t *crypt,
int *pErr);
extern void MRVL_AesPrimitiveEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern BOOLEAN (*MRVL_AesPrimitiveDecrypt_hook) (MRVL_ENDECRYPT_t *crypt,
int *pErr);
extern void MRVL_AesPrimitiveDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern BOOLEAN (*MRVL_AesWrapEncrypt_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_AesWrapEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern BOOLEAN (*MRVL_AesWrapDecrypt_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_AesWrapDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
#ifdef DIAG_AES_CCM
extern BOOLEAN (*MRVL_AesCCMPollingMode_hook) (MRVL_ENDECRYPT_t *crypt,
int *pErr, int decEnable);
extern void MRVL_AesCCMPollingMode(MRVL_ENDECRYPT_t *crypt, int *pErr,
int decEnable);
#endif
extern BOOLEAN (*MRVL_AesEncrypt_hook) (UINT8 *kek, UINT8 kekLen, UINT8 *data,
UINT8 *ret, int *ptr_val);
extern int MRVL_AesEncrypt(UINT8 *kek, UINT8 kekLen, UINT8 *data, UINT8 *ret);
extern BOOLEAN (*MRVL_AesValidateHostRequest_hook) (UINT32 *pBitMap,
UINT8 *pCmdPtr,
UINT8 *pCryptData,
SINT8 *pAESWrapEnc,
int *ptr_val);
extern int MRVL_AesValidateHostRequest(UINT32 *pBitMap, UINT8 *pCmdPtr,
UINT8 *pCryptData, SINT8 *pAESWrapEnc);
#ifdef RC4
extern BOOLEAN (*MRVL_Rc4Cryption_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_Rc4Cryption(void *priv, MRVL_ENDECRYPT_t *crypt, int *pErr);
#endif
extern BOOLEAN (*MRVL_AesWrap_hook) (UINT8 *kek, UINT8 kekLen, UINT32 n,
UINT8 *plain, UINT8 *keyIv, UINT8 *cipher,
int *ptr_val);
extern int MRVL_AesWrap(UINT8 *kek, UINT8 kekLen, UINT32 n, UINT8 *plain,
UINT8 *keyIv, UINT8 *cipher);
extern BOOLEAN (*MRVL_AesUnWrap_hook) (UINT8 *kek, UINT8 kekLen, UINT32 n,
UINT8 *cipher, UINT8 *keyIv,
UINT8 *plain, int *ptr_val);
extern int MRVL_AesUnWrap(UINT8 *kek, UINT8 kekLen, UINT32 n, UINT8 *cipher,
UINT8 *keyIv, UINT8 *plain);
extern BOOLEAN (*MRVL_AesSetKey_hook) (const UINT8 *kek, UINT8 kekLen,
int *ptr_val);
extern int MRVL_AesSetKey(const UINT8 *kek, UINT8 kekLen);
/* AES related defines */
#define MRVL_AES_KEY_UPDATE_DONE 5
#define MRVL_AES_DONE 6
#define MRVL_AES_ENGINE_BITS_POS 12
#define MRVL_AES_KEYUPDATE_LOC 0x00000900
#define MRVL_AES_ENABLE_ENCR_LOC 0x00000500
#define MRVL_AES_ENABLE_DECR_LOC 0x00000700
/* convert 4 individual bytes into a 4 byte unsigned int */
#define MRVL_AES_GET_UINT32(x) ((x[3]<<24)|(x[2]<<16)|(x[1]<<8)|x[0])
/* convert 4 byte unsigned int back to a 4 individual bytes */
#define MRVL_AES_CONVERT_UINT32_UINT8(x,u) \
*u = (UINT8)((((UINT32)x)&0x000000ff)); \
*(u + 1)= (UINT8)((((UINT32)x)&0x0000ff00)>>8); \
*(u + 2)= (UINT8)((((UINT32)x)&0x00ff0000)>>16); \
*(u + 3)= (UINT8)((((UINT32)x)&0xff000000)>>24) \
/* HW register read macros */
#define MRVL_AES_READ32(x) (WL_REGS32(x))
#define MRVL_AES_READ16(x) (WL_REGS16(x))
#define MRVL_AES_READ8(x) (WL_REGS8(x) )
/* HW register write macros */
#define MRVL_AES_WRITE32(reg,val) (WL_WRITE_REGS32(reg,val))
#define MRVL_AES_WRITE16(reg,val) (WL_WRITE_REGS16(reg,val))
#define MRVL_AES_WRITE8(reg,val) (WL_WRITE_REGS8(reg,val))
extern UINT32 (*ramHook_CryptNew_EnterCritical) (void);
extern void (*ramHook_CryptNew_ExitCritical) (UINT32 intSave);
extern int MRVL_AES_MEMCMP(UINT8 *dst, UINT8 *src, int len);
extern void MRVL_AES_MEMSET(UINT8 *dst, UINT8 val, int size);
extern void MRVL_AES_MEMCPY(UINT8 *dst, UINT8 *src, int size);
extern int MRVL_AesInterCheck(UINT8 *inter, UINT8 *d);
#ifdef DIAG_AES_CCM
extern void MRVL_AesCCMEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
extern void MRVL_AesCCMDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
#endif
#endif /* _CRYPT_NEW_ROM_H_ */

View File

@@ -0,0 +1,106 @@
/** @file hmac_md5.c
*
* @brief This file defines algorithm for hmac md5
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "md5.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
void
Mrvl_hmac_md5(void *priv, UINT8 *text_data, int text_len, UINT8 *key,
int key_len, void *digest)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
//BufferDesc_t * pDesc = NULL;
UINT8 buf[400] = { 0 };
Mrvl_MD5_CTX *context;
unsigned char *k_pad; /* padding - key XORd with i/opad */
int i;
#if 0
/* Wait forever ensures a buffer */
pDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
400, BML_WAIT_FOREVER);
#endif
/* WLAN buffers are aligned, so k_pad start at a UINT32 boundary */
//k_pad = (unsigned char *)BML_DATA_PTR(pDesc);
k_pad = (unsigned char *)buf;
context = (Mrvl_MD5_CTX *)(k_pad + 64);
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
Mrvl_MD5_CTX tctx;
wpa_MD5Init(&tctx);
wpa_MD5Update((void *)priv, &tctx, key, key_len);
wpa_MD5Final((void *)priv, context->buffer, &tctx);
key = context->buffer;
key_len = 16;
}
/* the HMAC_MD5 transform looks like: */
/* */
/* MD5(K XOR opad, MD5(K XOR ipad, text)) */
/* */
/* where K is an n byte key */
/* ipad is the byte 0x36 repeated 64 times */
/* opad is the byte 0x5c repeated 64 times */
/* and text is the data being protected */
/* start out by storing key in pads */
memset(util_fns, k_pad, 0, 64);
memcpy(util_fns, k_pad, key, key_len);
/* XOR key with ipad and opad values */
for (i = 0; i < 16; i++) {
((UINT32 *)k_pad)[i] ^= 0x36363636;
}
/* perform inner MD5 */
wpa_MD5Init(context); /* init context for 1st pass */
wpa_MD5Update((void *)priv, context, k_pad, 64); /* start with inner pad */
wpa_MD5Update((void *)priv, context, text_data, text_len); /* then text of datagram */
wpa_MD5Final((void *)priv, digest, context); /* finish up 1st pass */
/* start out by storing key in pads */
memset(util_fns, k_pad, 0, 64);
memcpy(util_fns, k_pad, key, key_len);
for (i = 0; i < 16; i++) {
((UINT32 *)k_pad)[i] ^= 0x5c5c5c5c;
}
/* perform outer MD5 */
wpa_MD5Init(context); /* init context for 2nd pass */
wpa_MD5Update((void *)priv, context, k_pad, 64);
/* start with outer pad */
wpa_MD5Update((void *)priv, context, digest, 16);
/* then results of 1st hash */
wpa_MD5Final((void *)priv, digest, context); /* finish up 2nd pass */
// bml_FreeBuffer((UINT32)pDesc);
}

View File

@@ -0,0 +1,163 @@
/** @file hmac_sha1.c
*
* @brief This file defines algorithm for hmac sha1
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "wl_macros.h"
#include "sha1.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
void
Mrvl_hmac_sha1(void *priv, unsigned char **ppText,
int *pTextLen,
int textNum,
unsigned char *key,
int key_len, unsigned char *output, int outputLen)
{
/*
Note- Some of the variables are made static in this function
becuase currently this function executes in the idle task.
The idle task dosent have enough stack space to accomodate
these varables. In the future if this function in executed in
a different task or if we increase the stack size of the idle
task then we can put these variables on the stack
*/
//BufferDesc_t * pDesc = NULL;
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT8 buf[400] = { 0 };
Mrvl_SHA1_CTX *context;
unsigned char *k_pad; /* padding - key XORd with i/opad */
unsigned char *digest;
int i;
k_pad = (unsigned char *)buf;
digest = k_pad + 64;
context = (Mrvl_SHA1_CTX *)(k_pad + 64 + 20);
/* if key is longer than 64 bytes reset it to key=SHA1(key) */
if (key_len > 64) {
Mrvl_SHA1Init(context);
Mrvl_SHA1Update(context, key, key_len);
Mrvl_SHA1Final((void *)priv, context, key);
key_len = 20;
}
/*
* the HMAC_SHA1 transform looks like:
*
* SHA1(K XOR opad, SHA1(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* perform inner SHA1 */
/* start out by storing key in pads */
memset(util_fns, k_pad, 0, 64);
memcpy(util_fns, k_pad, key, key_len);
/* XOR key with ipad and opad values */
for (i = 0; i < 8; i++) {
((UINT64 *)k_pad)[i] ^= 0x3636363636363636ULL;
}
Mrvl_SHA1Init(context); /* init context for 1st pass */
Mrvl_SHA1Update(context, k_pad, 64); /* start with inner pad */
for (i = 0; i < textNum; i++) {
/* then text of datagram */
Mrvl_SHA1Update(context, ppText[i], pTextLen[i]);
}
Mrvl_SHA1Final((void *)priv, context, digest); /* finish up 1st pass */
/* perform outer SHA1 */
/* start out by storing key in pads */
memset(util_fns, k_pad, 0, 64);
memcpy(util_fns, k_pad, key, key_len);
/* XOR key with ipad and opad values */
for (i = 0; i < 8; i++) {
((UINT64 *)k_pad)[i] ^= 0x5c5c5c5c5c5c5c5cULL;
}
Mrvl_SHA1Init(context); /* init context for 2nd pass */
Mrvl_SHA1Update(context, k_pad, 64); /* start with outer pad */
Mrvl_SHA1Update(context, digest, 20); /* then results of 1st hash */
Mrvl_SHA1Final((void *)priv, context, digest); /* finish up 2nd pass */
memcpy(util_fns, output, digest, outputLen);
// bml_FreeBuffer((UINT32)pDesc);
}
/*
* PRF -- Length of output is in octets rather than bits
* since length is always a multiple of 8 output array is
* organized so first N octets starting from 0 contains PRF output
*
* supported inputs are 16, 32, 48, 64
* output array must be 80 octets to allow for sha1 overflow
*/
void
Mrvl_PRF(void *priv, unsigned char *key, int key_len,
unsigned char *prefix, int prefix_len,
unsigned char *data, int data_len, unsigned char *output, int len)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
int i;
int currentindex = 0;
int total_len;
UINT8 prf_input[120]; /* concatenated input */
unsigned char *pText = prf_input;
SINT8 remain = len;
memset(util_fns, prf_input, 0x00, sizeof(prf_input));
if (prefix) {
memcpy(util_fns, prf_input, prefix, prefix_len);
prf_input[prefix_len] = 0; /* single octet 0 */
memcpy(util_fns, &prf_input[prefix_len + 1], data, data_len);
total_len = prefix_len + 1 + data_len;
} else {
memcpy(util_fns, prf_input, data, data_len);
total_len = data_len;
}
prf_input[total_len] = 0; /* single octet count, starts at 0 */
total_len++;
for (i = 0; i < (len + 19) / 20; i++) {
Mrvl_hmac_sha1(priv, (UINT8 **)&pText,
&total_len,
1,
key,
key_len, &output[currentindex], MIN(20, remain));
currentindex += MIN(20, remain); /* next concatenation location */
remain -= 20;
prf_input[total_len - 1]++; /* increment octet count */
}
}

View File

@@ -0,0 +1,277 @@
/** @file md5.c
*
* @brief This file defines the function for md5
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "md5.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
/* Constants for wpa_MD5Transform routine.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
#define Mrvl_MD5_memcpy(utils, output, input, len) memcpy(utils, output, input, len)
#define Mrvl_MD5_memset(utils, output, value, len) memset(utils, output, value, len)
#define Encode(utils, output, input, len) memcpy(utils, output, input, len)
static void wpa_MD5Transform(void *priv, UINT32 *state, unsigned int *block);
static const unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b);}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void
wpa_MD5Init(Mrvl_MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void
wpa_MD5Update(void *priv, Mrvl_MD5_CTX *context, UINT8 *input, UINT32 inputLen)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT32)inputLen << 3))
< ((UINT32)inputLen << 3)) {
context->count[1]++;
}
context->count[1] += ((UINT32)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
Mrvl_MD5_memcpy(util_fns, &context->buffer[index], input,
partLen);
wpa_MD5Transform((void *)priv, context->state,
(UINT32 *)context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64) {
Mrvl_MD5_memcpy(util_fns, context->scratch, (input + i),
64);
wpa_MD5Transform((void *)priv, context->state,
context->scratch);
}
index = 0;
} else {
i = 0;
}
/* Buffer remaining input */
Mrvl_MD5_memcpy(util_fns, &context->buffer[index], &input[i],
inputLen - i);
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void
wpa_MD5Final(void *priv, unsigned char digest[16], Mrvl_MD5_CTX *context)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode(util_fns, bits, context->count, 8);
/* Pad out to 56 mod 64. */
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
wpa_MD5Update(priv, context, (UINT8 *)PADDING, padLen);
/* Append length (before padding) */
wpa_MD5Update(priv, context, bits, 8);
/* Store state in digest */
Encode(util_fns, digest, context->state, 16);
/* Zeroize sensitive information. */
Mrvl_MD5_memset(util_fns, context, 0, sizeof(*context));
}
/* MD5 basic transformation. Transforms state based on block.
*/
static void
wpa_MD5Transform(void *priv, UINT32 *state, unsigned int *block)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT32 a = state[0], b = state[1], c = state[2], d = state[3], *x;
/* Decode (x, block, 64); */
x = block;
/* Round 1 */
FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
Mrvl_MD5_memset(util_fns, x, 0, sizeof(x));
}

View File

@@ -0,0 +1,45 @@
/** @file md5.h
*
* @brief This file contains define for md5.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _MD5_H_
#define _MD5_H_
typedef struct {
unsigned int state[4]; /* state (ABCD) */
unsigned int count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned int scratch[16]; /* This is used to reduce the memory
** requirements of the transform
** function
*/
unsigned char buffer[64]; /* input buffer */
} Mrvl_MD5_CTX;
void wpa_MD5Init(Mrvl_MD5_CTX *context);
void wpa_MD5Update(void *priv, Mrvl_MD5_CTX *context, UINT8 *input,
UINT32 inputLen);
void wpa_MD5Final(void *priv, unsigned char digest[16], Mrvl_MD5_CTX *context);
void Mrvl_hmac_md5(void *priv, UINT8 *text, int text_len, UINT8 *key,
int key_len, void *digest);
#endif

View File

@@ -0,0 +1,118 @@
/** @file Mrvl_sha256_crypto.c
*
* @brief This file defines sha256 crypto
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include <linux/string.h>
#include "wltypes.h"
#include "wl_macros.h"
#include "sha_256.h"
#include "mrvl_sha256_crypto.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
/* Helper function to allocate scratch memory and call sha256_vector() */
void
mrvl_sha256_crypto_vector(void *priv, size_t num_elem,
UINT8 *addr[], size_t * len, UINT8 *mac)
{
//BufferDesc_t* pBufDesc = NULL;
UINT8 buf[SHA256_MIN_SCRATCH_BUF] = { 0 };
sha256_vector((void *)priv, num_elem, addr, len, mac, (UINT8 *)buf);
// bml_FreeBuffer((UINT32)pBufDesc);
}
void
mrvl_sha256_crypto_kdf(void *priv, UINT8 *pKey,
UINT8 key_len,
char *label,
UINT8 label_len,
UINT8 *pContext,
UINT16 context_len, UINT8 *pOutput, UINT16 output_len)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT8 *vectors[4 + 1];
size_t vectLen[NELEMENTS(vectors)];
UINT8 *pResult;
UINT8 *pLoopResult;
UINT8 iterations;
UINT16 i;
//BufferDesc_t* pBufDesc = NULL;
UINT8 buf[HMAC_SHA256_MIN_SCRATCH_BUF] = { 0 };
pResult = pContext + context_len;
/*
** Working memory layout:
** | KDF-Len output --- >
** |
** [KDF Input][HMAC output#1][HMAC output#2][...]
**
*/
/* Number of SHA256 digests needed to meet the bit length output_len */
iterations = (output_len + 255) / 256;
pLoopResult = pResult;
for (i = 1; i <= iterations; i++) {
/* Skip vectors[0]; Used internally in hmac_sha256_vector function */
vectors[1] = (UINT8 *)&i;
vectLen[1] = sizeof(i);
vectors[2] = (UINT8 *)label;
vectLen[2] = label_len;
vectors[3] = pContext;
vectLen[3] = context_len;
vectors[4] = (UINT8 *)&output_len;
vectLen[4] = sizeof(output_len);
/*
**
** KDF input = (K, i || label || Context || Length)
**
*/
hmac_sha256_vector(priv, pKey, key_len,
NELEMENTS(vectors), vectors, vectLen,
pLoopResult, (UINT8 *)buf);
/* Move the hmac output pointer so another digest can be appended
** if more loop iterations are needed to get the output_len key
** bit total
*/
pLoopResult += SHA256_MAC_LEN;
}
// bml_FreeBuffer((UINT32)pBufDesc);
memcpy(util_fns, pOutput, pResult, output_len / 8);
}

View File

@@ -0,0 +1,40 @@
/** @file Mrvl_sha256_crypto.h
*
* @brief This file contains the define for sha256
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _MRVL_SHA256_CRYPTO_H
#define _MRVL_SHA256_CRYPTO_H
extern void mrvl_sha256_crypto_vector(void *priv, size_t num_elem,
UINT8 *addr[], size_t * len, UINT8 *mac);
extern void mrvl_sha256_crypto_kdf(void *priv, UINT8 *pKey,
UINT8 key_len,
char *label,
UINT8 label_len,
UINT8 *pContext,
UINT16 context_len,
UINT8 *pOutput, UINT16 output_len);
#endif

View File

@@ -0,0 +1,76 @@
/** @file packetType.h
*
* @brief This file defines Packet Type enumeration used for PacketType fields in RX and TX
* packet descriptors
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _PACKETTYPE_H_
#define _PACKETTYPE_H_
/**
*** @brief Enumeration of different Packets Types.
**/
typedef enum {
PKT_TYPE_802DOT3_DEFAULT = 0, /*!< For RX packets it represents
** IEEE 802.3 SNAP frame . For
** TX Packets. This Field is for
** backwards compatibility only and
** should not be used going
** forward.
*/
PKT_TYPE_802DOT3_LLC = 1, //!< IEEE 802.3 frame with LLC header
PKT_TYPE_ETHERNET_V2 = 2, //!< Ethernet version 2 frame
PKT_TYPE_802DOT3_SNAP = 3, //!< IEEE 802.3 SNAP frame
PKT_TYPE_802DOT3 = 4, //!< IEEE 802.3 frame
PKT_TYPE_802DOT11 = 5, //!< IEEE 802.11 frame
PKT_TYPE_ETCP_SOCKET_DATA = 7, //!< eTCP Socket Data
PKT_TYPE_RAW_DATA = 8, //!< Non socket data when using eTCP
PKT_TYPE_MRVL_MESH = 9, //!< Marvell Mesh frame
/* Marvell Internal firmware packet types
** Range from 0x0E to 0xEE
** These internal Packet types should grow from
** 0xEE down. This will leave room incase the packet
** types between the driver & firmware need to be expanded
*/
PKT_TYPE_MRVL_EAPOL_MSG = 0xDF,
PKT_TYPE_MRVL_BT_AMP = 0xE0,
PKT_TYPE_FWD_MGT = 0xE2,
PKT_TYPE_MGT = 0xE5,
PKT_TYPE_MRVL_AMSDU = 0xE6,
PKT_TYPE_MRVL_BAR = 0xE7,
PKT_TYPE_MRVL_LOOPBACK = 0xE8,
PKT_TYPE_MRVL_DATA_MORE = 0xE9,
PKT_TYPE_MRVL_DATA_LAST = 0xEA,
PKT_TYPE_MRVL_DATA_NULL = 0xEB,
PKT_TYPE_MRVL_UNKNOWN = 0xEC,
PKT_TYPE_MRVL_SEND_TO_DATASWITCH = 0xED,
PKT_TYPE_MRVL_SEND_TO_HOST = 0xEE,
PKT_TYPE_DEBUG = 0xEF,
// Customer range for Packet Types
// Range 0xF0 to 0xFF
} PacketType;
#endif

View File

@@ -0,0 +1,285 @@
/** @file parser.c
*
* @brief This file defines function for 802.11 Management Frames Parsing
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
/*****************************************************************************
*
* File: parser.c
*
*
*
* Author(s): Rajesh Bhagwat
* Date: 2005-02-04
* Description: 802.11 Management Frames Parsing
*
******************************************************************************/
#include "wltypes.h"
#include "wl_mib.h"
#include "IEEE_types.h"
#include "parser.h"
#include "parser_rom.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
VendorSpecificIEType_e
IsEpigramHTElement(void *priv, uint8 *pBuffer)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
VendorSpecificIEType_e retVal = VendSpecIE_Other;
const uint8 szMatchingCapElement[] = { 0x00, 0x90, 0x4c, 0x33 };
const uint8 szMatchingInfoElement[] = { 0x00, 0x90, 0x4c, 0x34 };
if (!memcmp(util_fns, pBuffer,
szMatchingInfoElement, sizeof(szMatchingInfoElement))) {
retVal = VendSpecIE_HT_Info;
} else if (!memcmp(util_fns, pBuffer,
szMatchingCapElement,
sizeof(szMatchingCapElement))) {
retVal = VendSpecIE_HT_Cap;
}
return retVal;
}
VendorSpecificIEType_e
IsWPSElement(void *priv, UINT8 *pBuffer)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
VendorSpecificIEType_e retVal = VendSpecIE_Other;
const UINT8 szMatchingInfoElement[] = { 0x00, 0x50, 0xf2, 0x04 };
if (!memcmp(util_fns, pBuffer,
szMatchingInfoElement, sizeof(szMatchingInfoElement))) {
retVal = VendSpecIE_WPS;
}
return retVal;
}
VendorSpecificIEType_e
IsSsIdLElement(void *priv, UINT8 *pBuffer)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
VendorSpecificIEType_e retVal = VendSpecIE_Other;
const UINT8 szMatchingInfoElement[] = { 0x00, 0x50, 0xf2, 0x05, 0x00 };
if (!memcmp(util_fns, pBuffer,
szMatchingInfoElement, sizeof(szMatchingInfoElement))) {
retVal = VendSpecIE_SsIdL;
}
return retVal;
}
int
ieBufValidate(UINT8 *pIe, int bufLen)
{
while (bufLen) {
UINT8 ieLen = *(pIe + 1);
if (bufLen < (ieLen + 2)) {
return MLME_FAILURE;
}
bufLen -= ieLen + 2;
pIe += ieLen + 2;
}
return MLME_SUCCESS;
}
int
GetIEPointers(void *priv, UINT8 *pIe, int bufLen, IEPointers_t *pIePointers)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
memset(util_fns, pIePointers, 0x00, sizeof(IEPointers_t));
while (bufLen) {
if (bufLen < (*(pIe + 1) + 2)) {
break;
}
/* Handle IEs not processed by ROM functions. */
switch (*pIe) {
case ELEM_ID_RSN:
pIePointers->pRsn = (IEEEtypes_RSNElement_t *)pIe;
break;
case ELEM_ID_WAPI:
pIePointers->pWapi = (IEEEtypes_WAPIElement_t *)pIe;
break;
/* Add element not handled by ROM_parser_getIEPtr or
** override element processing in ROM_parser_getIEPtr
** here.
*/
case ELEM_ID_VENDOR_SPECIFIC:
default:
if (ROM_parser_getIEPtr(priv, pIe, pIePointers) ==
FALSE) {
if ((*pIe) == ELEM_ID_VENDOR_SPECIFIC) {
if (IsWPSElement(priv, (pIe + 2))) {
pIePointers->pWps =
(IEEEtypes_WPSElement_t
*)pIe;
}
}
// Add your code to process vendor specific elements not
// processed by above ROM_paser_getAssocIEPtr function.
}
break;
}
bufLen -= *(pIe + 1) + 2;
pIe += *(pIe + 1) + 2;
}
return bufLen;
}
BOOLEAN
parser_getAssocIEs(void *priv, UINT8 *pIe,
int bufLen, AssocIePointers_t *pIePointers)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
BOOLEAN ieParseSuccessful = TRUE;
memset(util_fns, pIePointers, 0x00, sizeof(AssocIePointers_t));
while (bufLen) {
UINT8 ieType = *pIe;
UINT8 ieLen = *(pIe + 1);
if (bufLen < (ieLen + 2)) {
ieParseSuccessful = FALSE;
break;
}
switch (ieType) {
// add code for elements not handled in ROM function.
case ELEM_ID_AP_CHANNEL_REPORT:
pIePointers->pApChanRpt =
(IEEEtypes_ApChanRptElement_t *)pIe;
break;
#ifdef TDLS
case ELEM_ID_SUPPORTED_REGCLASS:
pIePointers->pSuppRegClass =
(IEEEtypes_SupportedRegClasses_t *)pIe;
break;
#endif
/* The following 5 elements, HT CAP, HT INFO, 20/40 Coex,
OBSS SCAN PARAM, and EXTENDED CAP, are ignored
here if 11n is not compiled. When 11n is compiled these
5 elements would be handled in ROM_parser_getAssocIEPtr
routine.
*/
case ELEM_ID_HT_CAPABILITY:
case ELEM_ID_HT_INFORMATION:
case ELEM_ID_2040_BSS_COEXISTENCE:
case ELEM_ID_OBSS_SCAN_PARAM:
case ELEM_ID_EXT_CAPABILITIES:
/* Do not process these elements in ROM routine
ROM_parser_getAssocIEPtr
Note: a break here.
*/
break;
/* Add element not handled by ROM_parser_getAssocIEPtr or
override element processing in ROM_parser_getAssocIEPtr
here.
\
*/
case ELEM_ID_VENDOR_SPECIFIC:
default:
if (ROM_parser_getAssocIEPtr(priv, pIe, pIePointers) ==
FALSE) {
// Add your code to process vendor specific elements not
// processed by above ROM_paser_getAssocIEPtr function.
if (!pIePointers->pHtCap ||
!pIePointers->pHtInfo) {
switch (IsEpigramHTElement
(priv, (pIe + 2))) {
case VendSpecIE_HT_Cap:
if (!pIePointers->pHtCap) {
*(pIe + 4) =
ELEM_ID_HT_CAPABILITY;
*(pIe + 5) =
sizeof
(IEEEtypes_HT_Capability_t);
pIePointers->pHtCap =
(IEEEtypes_HT_Capability_t
*)(pIe + 4);
}
break;
case VendSpecIE_HT_Info:
if (!pIePointers->pHtInfo) {
*(pIe + 4) =
ELEM_ID_HT_INFORMATION;
*(pIe + 5) =
sizeof
(IEEEtypes_HT_Information_t);
pIePointers->pHtInfo =
(IEEEtypes_HT_Information_t
*)(pIe + 4);
}
break;
case VendSpecIE_Other:
default:
break;
}
}
}
break;
}
bufLen -= ieLen + 2;
pIe += ieLen + 2;
}
return ieParseSuccessful;
}
UINT8
parser_countNumInfoElements(UINT8 *pIe, int bufLen)
{
UINT8 ieCount = 0;
while (bufLen) {
if (bufLen < (*(pIe + 1) + 2)) {
break;
}
ieCount++;
bufLen -= *(pIe + 1) + 2;
pIe += *(pIe + 1) + 2;
}
return ieCount;
}

View File

@@ -0,0 +1,74 @@
/** @file parser.h
*
* @brief This file contains definitions of 802.11 Management Frames
* and Information Element Parsing
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _PARSER_H_
#define _PARSER_H_
#include "IEEE_types.h"
#include "parser_rom.h"
typedef struct {
IEEEtypes_HT_Capability_t *pHtCap;
IEEEtypes_HT_Information_t *pHtInfo;
IEEEtypes_20N40_BSS_Coexist_t *p2040Coexist;
IEEEtypes_OBSS_ScanParam_t *pHtScanParam;
IEEEtypes_ExtCapability_t *pHtExtCap;
} dot11nIEPointers_t;
#ifdef DOT11AC
typedef struct {
IEEEtypes_VHT_Capability_t *pVhtCap;
IEEEtypes_VHT_Operation_t *pVhtOper;
} dot11acIEPointers_t;
#endif
#ifdef TDLS
typedef struct {
IEEEtypes_MobilityDomainElement_t *pMdie;
IEEEtypes_FastBssTransElement_t *pFtie;
IEEEtypes_RSNElement_t *pRsn;
IEEEtypes_TimeoutIntervalElement_t *pTie[2];
IEEEtypes_RICDataElement_t *pFirstRdie;
} Dot11rIePointers_t;
#endif
extern VendorSpecificIEType_e IsWMMElement(void *priv, UINT8 *pBuffer);
extern VendorSpecificIEType_e IsWPAElement(void *priv, UINT8 *pBuffer);
extern int ieBufValidate(UINT8 *pIe, int bufLen);
extern int GetIEPointers(void *priv, UINT8 *pIe,
int bufLen, IEPointers_t *pIePointers);
extern BOOLEAN parser_getAssocIEs(void *priv, UINT8 *pIe,
int bufLen, AssocIePointers_t *pIePointers);
extern
IEEEtypes_InfoElementHdr_t *parser_getSpecificIE(IEEEtypes_ElementId_e elemId,
UINT8 *pIe, int bufLen);
extern UINT8 parser_countNumInfoElements(UINT8 *pIe, int bufLen);
#endif // _PARSER_H_

View File

@@ -0,0 +1,243 @@
/** @file parser_rom.c
*
* @brief This file define the function for 802.11 Management Frames Parsing
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "parser_rom.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#define WMM_IE_MIN_LEN 7
VendorSpecificIEType_e
IsWMMElement(void *priv, uint8 *pBuffer)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
VendorSpecificIEType_e retVal = VendSpecIE_Other;
const uint8 szMatchingInfoElement[] = { 0x00, 0x50, 0xf2,
0x02, 0x00, 0x01
};
const uint8 szMatchingParamElement[] = { 0x00, 0x50, 0xf2,
0x02, 0x01, 0x01
};
const uint8 szMatchingTspecElement[] = { 0x00, 0x50, 0xf2,
0x02, 0x02, 0x01
};
if (!memcmp(util_fns, pBuffer,
szMatchingInfoElement, sizeof(szMatchingInfoElement))) {
retVal = VendSpecIE_WMM_Info;
} else if (!memcmp(util_fns, pBuffer,
szMatchingParamElement,
sizeof(szMatchingParamElement))) {
retVal = VendSpecIE_WMM_Param;
} else if (!memcmp(util_fns, pBuffer,
szMatchingTspecElement,
sizeof(szMatchingTspecElement))) {
retVal = VendSpecIE_TSPEC;
}
return retVal;
}
VendorSpecificIEType_e
IsWPAElement(void *priv, uint8 *pBuffer)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
VendorSpecificIEType_e retVal = VendSpecIE_Other;
const uint8 szMatchingInfoElement[] = { 0x00, 0x50, 0xf2,
0x01, 0x01, 0x00
};
if (!memcmp(util_fns, pBuffer,
szMatchingInfoElement, sizeof(szMatchingInfoElement))) {
retVal = VendSpecIE_WPA;
}
return retVal;
}
BOOLEAN
ROM_parser_getIEPtr(void *priv, uint8 *pIe, IEPointers_t *pIePointers)
{
BOOLEAN status = TRUE;
switch (*pIe) {
case ELEM_ID_SSID:
pIePointers->pSsid = (IEEEtypes_SsIdElement_t *)pIe;
break;
case ELEM_ID_DS_PARAM_SET:
pIePointers->pDsParam = (IEEEtypes_DsParamElement_t *)pIe;
break;
case ELEM_ID_TIM:
pIePointers->pTim = (IEEEtypes_TimElement_t *)pIe;
break;
case ELEM_ID_SUPPORTED_RATES:
pIePointers->pSupportedRates =
(IEEEtypes_SuppRatesElement_t *)pIe;
break;
case ELEM_ID_EXT_SUPPORTED_RATES:
pIePointers->pExtSupportedRates
= (IEEEtypes_ExtSuppRatesElement_t *)pIe;
break;
case ELEM_ID_ERP_INFO:
pIePointers->pErpInfo = (IEEEtypes_ERPInfoElement_t *)pIe;
break;
case ELEM_ID_IBSS_PARAM_SET:
pIePointers->pIbssParam = (IEEEtypes_IbssParamElement_t *)pIe;
break;
case ELEM_ID_COUNTRY:
pIePointers->pCountry = (IEEEtypes_CountryInfoElement_t *)pIe;
break;
case ELEM_ID_RSN:
pIePointers->pRsn = (IEEEtypes_RSNElement_t *)pIe;
break;
case ELEM_ID_VENDOR_SPECIFIC:
if (IsWPAElement(priv, (pIe + 2))) {
pIePointers->pWpa = (IEEEtypes_WPAElement_t *)pIe;
} else {
switch (IsWMMElement(priv, (pIe + 2))) {
case VendSpecIE_Other:
case VendSpecIE_TSPEC:
default:
status = FALSE;
break;
case VendSpecIE_WMM_Info:
pIePointers->pWmmInfo =
(IEEEtypes_WMM_InfoElement_t *)pIe;
break;
case VendSpecIE_WMM_Param:
pIePointers->pWmmParam
= (IEEEtypes_WMM_ParamElement_t *)pIe;
break;
}
}
break;
default:
status = FALSE;
break;
}
return status;
}
BOOLEAN
ROM_parser_getAssocIEPtr(void *priv, uint8 *pIe, AssocIePointers_t *pIePointers)
{
BOOLEAN status = TRUE;
switch (*pIe) {
case ELEM_ID_SSID:
pIePointers->pSsid = (IEEEtypes_SsIdElement_t *)pIe;
break;
case ELEM_ID_COUNTRY:
pIePointers->pCountry = (IEEEtypes_CountryInfoElement_t *)pIe;
break;
case ELEM_ID_DS_PARAM_SET:
pIePointers->pDsParam = (IEEEtypes_DsParamElement_t *)pIe;
break;
case ELEM_ID_SUPPORTED_RATES:
pIePointers->pSupportedRates =
(IEEEtypes_SuppRatesElement_t *)pIe;
break;
case ELEM_ID_EXT_SUPPORTED_RATES:
pIePointers->pExtSupportedRates
= (IEEEtypes_ExtSuppRatesElement_t *)pIe;
break;
case ELEM_ID_RSN:
pIePointers->pRsn = (IEEEtypes_RSNElement_t *)pIe;
break;
case ELEM_ID_VENDOR_SPECIFIC:
if (IsWPAElement(priv, (pIe + 2))) {
pIePointers->pWpa = (IEEEtypes_WPAElement_t *)pIe;
} else {
switch (IsWMMElement(priv, (pIe + 2))) {
case VendSpecIE_Other:
case VendSpecIE_TSPEC:
default:
status = FALSE;
break;
case VendSpecIE_WMM_Info:
pIePointers->pWmmInfo
= (IEEEtypes_WMM_InfoElement_t *)pIe;
break;
case VendSpecIE_WMM_Param:
pIePointers->pWmmParam
= (IEEEtypes_WMM_ParamElement_t *)pIe;
break;
}
}
break;
default:
status = FALSE;
break;
}
return status;
}
IEEEtypes_InfoElementHdr_t *
parser_getSpecificIE(IEEEtypes_ElementId_e elemId, UINT8 *pIe, int bufLen)
{
if (!pIe) {
return NULL;
}
while (bufLen) {
if (bufLen < (*(pIe + 1) + 2)) {
break;
}
if (*pIe == elemId) {
return (IEEEtypes_InfoElementHdr_t *)pIe;
}
bufLen -= *(pIe + 1) + 2;
pIe += *(pIe + 1) + 2;
}
return NULL;
}

View File

@@ -0,0 +1,135 @@
/** @file parser_rom.h
*
* @brief This file contains the data structrue for iepointer and declare the parse function
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef PARSER_ROM_H__
#define PARSER_ROM_H__
#include "IEEE_types.h"
typedef enum {
VendSpecIE_Other = 0,
VendSpecIE_WMM_Info,
VendSpecIE_WMM_Param,
VendSpecIE_WPA,
VendSpecIE_WPS,
VendSpecIE_TSPEC,
VendSpecIE_SsIdL,
VendSpecIE_WFD,
VendSpecIE_HT_Cap,
VendSpecIE_HT_Info,
} VendorSpecificIEType_e;
typedef struct {
/* IMPORTANT: please read before you modify this struct:
Some of the members of this struct are used in ROM code.
Therefore, please do not change any existing field, including
its name and type. If you want to add a new element into
this struct add it at the end.
*/
IEEEtypes_SsIdElement_t *pSsid;
IEEEtypes_TimElement_t *pTim;
IEEEtypes_WPAElement_t *pWpa;
IEEEtypes_WMM_InfoElement_t *pWmmInfo;
IEEEtypes_WMM_ParamElement_t *pWmmParam;
IEEEtypes_DsParamElement_t *pDsParam;
IEEEtypes_SuppRatesElement_t *pSupportedRates;
IEEEtypes_ExtSuppRatesElement_t *pExtSupportedRates;
IEEEtypes_ERPInfoElement_t *pErpInfo;
IEEEtypes_IbssParamElement_t *pIbssParam;
IEEEtypes_CountryInfoElement_t *pCountry;
IEEEtypes_MobilityDomainElement_t *pMdie;
IEEEtypes_RSNElement_t *pRsn;
IEEEtypes_HT_Capability_t *pHtCap;
IEEEtypes_HT_Information_t *pHtInfo;
IEEEtypes_20N40_BSS_Coexist_t *p2040Coexist;
IEEEtypes_OBSS_ScanParam_t *pHtScanParam;
IEEEtypes_ExtCapability_t *pExtCap;
IEEEtypes_WPSElement_t *pWps;
IEEEtypes_WAPIElement_t *pWapi;
} IEPointers_t;
typedef struct {
/* IMPORTANT: please read before you modify this struct:
Some of the members of this struct are used in ROM code.
Therefore, please do not change any existing field, including
its name and type. If you want to add a new element into
this struct add it at the end.
*/
IEEEtypes_SsIdElement_t *pSsid;
IEEEtypes_TimElement_t *pTim;
IEEEtypes_DsParamElement_t *pDsParam;
IEEEtypes_CountryInfoElement_t *pCountry;
UINT8 numSsIdLs;
IEEEtypes_SsIdLElement_t *pSsIdL; /* Only the first SSIDL found,
** need iterator to get next since
** multiple may be in beacon
*/
} ScanIePointers_t;
typedef struct {
/* IMPORTANT: please read before you modify this struct:
Some of the members of this struct are used in ROM code.
Therefore, please do not change any existing field, including
its name and type. If you want to add a new element into
this struct add it at the end.
*/
IEEEtypes_SsIdElement_t *pSsid;
IEEEtypes_DsParamElement_t *pDsParam;
IEEEtypes_CountryInfoElement_t *pCountry;
IEEEtypes_ApChanRptElement_t *pApChanRpt;
IEEEtypes_PowerConstraintElement_t *pPwrCon;
IEEEtypes_SuppRatesElement_t *pSupportedRates;
IEEEtypes_ExtSuppRatesElement_t *pExtSupportedRates;
IEEEtypes_WPAElement_t *pWpa;
IEEEtypes_WMM_InfoElement_t *pWmmInfo;
IEEEtypes_WMM_ParamElement_t *pWmmParam;
IEEEtypes_MobilityDomainElement_t *pMdie;
IEEEtypes_RSNElement_t *pRsn;
IEEEtypes_HT_Information_t *pHtInfo;
IEEEtypes_HT_Capability_t *pHtCap;
IEEEtypes_20N40_BSS_Coexist_t *p2040Coexist;
IEEEtypes_OBSS_ScanParam_t *pHtScanParam;
IEEEtypes_ExtCapability_t *pExtCap;
} AssocIePointers_t;
extern BOOLEAN ROM_parser_getIEPtr(void *priv, uint8 *pIe,
IEPointers_t *pIePointers);
extern BOOLEAN ROM_parser_getAssocIEPtr(void *priv, uint8 *pIe,
AssocIePointers_t *pIePointers);
#endif // _PARSER_ROM_H_

View File

@@ -0,0 +1,115 @@
/** @file pass_phrase.c
*
* @brief This file defines passphase hash
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wl_macros.h"
#include "pass_phrase.h"
//#include "keyMgmtSta.h"
#include "sha1.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
static INLINE t_u32
pass_strlen(const char *str)
{
t_u32 i;
for (i = 0; str[i] != 0; i++) {
}
return i;
}
/*
* F(P, S, c, i) = U1 xor U2 xor ... Uc
* U1 = PRF(P, S || Int(i))
* U2 = PRF(P, U1)
* Uc = PRF(P, Uc-1)
*/
void
Mrvl_F(void *priv, char *password, unsigned char *ssid, int ssidlength,
int iterations, int count, unsigned char *output)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
static unsigned char digest[36], digest1[A_SHA_DIGEST_LEN];
int i, j;
int len = pass_strlen(password);
int tmpLen = ssidlength + 4;
unsigned char *pTemp = digest;
/* U1 = PRF(P, S || int(i)) */
memcpy(util_fns, digest, ssid, ssidlength);
digest[ssidlength] = (unsigned char)((count >> 24) & 0xff);
digest[ssidlength + 1] = (unsigned char)((count >> 16) & 0xff);
digest[ssidlength + 2] = (unsigned char)((count >> 8) & 0xff);
digest[ssidlength + 3] = (unsigned char)(count & 0xff);
Mrvl_hmac_sha1((void *)priv, &pTemp,
&tmpLen,
1,
(unsigned char *)password,
len, digest1, A_SHA_DIGEST_LEN);
/* output = U1 */
memcpy(util_fns, output, digest1, A_SHA_DIGEST_LEN);
pTemp = digest1;
for (i = 1; i < iterations; i++) {
tmpLen = A_SHA_DIGEST_LEN;
/* Un = PRF(P, Un-1) */
Mrvl_hmac_sha1((void *)priv, &pTemp,
&tmpLen,
1,
(unsigned char *)password,
len, digest, A_SHA_DIGEST_LEN);
memcpy(util_fns, digest1, digest, A_SHA_DIGEST_LEN);
/* output = output xor Un */
for (j = 0; j < A_SHA_DIGEST_LEN; j++) {
output[j] ^= digest[j];
}
}
}
/*
* password - ascii string up to 63 characters in length
* ssid - octet string up to 32 octets
* ssidlength - length of ssid in octets
* output must be 32 octets in length and outputs 256 bits of key
*/
int
Mrvl_PasswordHash(void *priv, char *password, unsigned char *ssid,
int ssidlength, unsigned char *output)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
if ((pass_strlen(password) > 63) || (ssidlength > 32)) {
return 0;
}
Mrvl_F((void *)priv, password, ssid, ssidlength, 4096, 2, output);
memcpy(util_fns, output + A_SHA_DIGEST_LEN, output, 12);
Mrvl_F((void *)priv, password, ssid, ssidlength, 4096, 1, output);
return 1;
}

View File

@@ -0,0 +1,31 @@
/** @file pass_phrase.h
*
* @brief This file contains define for passphase hash
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef PASS_PHRASE_H__
#define PASS_PHRASE_H__
extern int Mrvl_PasswordHash(void *priv, char *password, unsigned char *ssid,
int ssidlength, unsigned char *output);
#endif

View File

@@ -0,0 +1,303 @@
/** @file pmkcache.c
*
* @brief This file defines pmk cache functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wl_macros.h"
#include "pass_phrase.h"
#include "pmkCache.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "tlv.h"
#include "keyMgmtApStaCommon.h"
#define MAX_PMK_CACHE_ENTRIES 10
pmkElement_t pmkCache[MAX_PMK_CACHE_ENTRIES];
char PSKPassPhrase[PSK_PASS_PHRASE_LEN_MAX];
/*
** Replacement rank is used to determine which cache entry to replace
** once the cache is full. The rank order is determined by usage. The
** least recently used cache element is the first to be replaced.
**
** replacementRankMax is an indication of the number of cache entries used.
** It is used to determine the rank of the current cache entry used.
**
** Rank order goes from 1 to MAX_PMK_CACHE_ENTRIES. If the cache is full,
** the element with rank 1 is first to be replaced.
**
** Replacement rank of zero indicates that the entry is invalid.
*/
UINT8 *
pmkCacheFindPSK(void *priv, UINT8 *pSsid, UINT8 ssidLen)
{
UINT8 *pPMK = NULL;
pmkElement_t *pPMKElement;
if (!pPMK) {
/* extract the PSK from the cache entry */
pPMKElement =
pmkCacheFindPSKElement((void *)priv, pSsid, ssidLen);
if (pPMKElement) {
pPMK = pPMKElement->PMK;
} else if ('\0' != PSKPassPhrase[0]) {
/* Generate a new PSK entry with the
** provided passphrase.
*/
pmkCacheAddPSK((void *)priv, pSsid, ssidLen, NULL,
PSKPassPhrase);
pPMKElement =
pmkCacheFindPSKElement((void *)priv, pSsid,
ssidLen);
pmkCacheGeneratePSK((void *)priv, pSsid, ssidLen,
PSKPassPhrase, pPMKElement->PMK);
pPMK = pPMKElement->PMK;
}
}
return pPMK;
}
UINT8 *
pmkCacheFindPassphrase(void *priv, UINT8 *pSsid, UINT8 ssidLen)
{
UINT8 *pPassphrase = NULL;
pmkElement_t *pPMKElement;
if (!pPassphrase) {
/* extract the PSK from the cache entry */
pPMKElement =
pmkCacheFindPSKElement((void *)priv, pSsid, ssidLen);
if (pPMKElement) {
pPassphrase = pPMKElement->passphrase;
}
}
return pPassphrase;
}
void
pmkCacheSetPassphrase(void *priv, char *pPassphrase)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
if (pPassphrase != NULL) {
memcpy(util_fns, PSKPassPhrase,
pPassphrase, sizeof(PSKPassPhrase));
}
}
void
pmkCacheGetPassphrase(void *priv, char *pPassphrase)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
if (pPassphrase != NULL) {
memcpy(util_fns, pPassphrase,
PSKPassPhrase, sizeof(PSKPassPhrase));
}
}
void
pmkCacheInit(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
memset(util_fns, pmkCache, 0x00, sizeof(pmkCache));
memset(util_fns, PSKPassPhrase, 0x00, sizeof(PSKPassPhrase));
replacementRankMax = 0;
}
void
pmkCacheFlush(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
memset(util_fns, pmkCache, 0x00, sizeof(pmkCache));
replacementRankMax = 0;
}
//#pragma arm section code = ".init"
void
pmkCacheRomInit(void)
{
ramHook_MAX_PMK_CACHE_ENTRIES = MAX_PMK_CACHE_ENTRIES;
ramHook_pmkCache = &pmkCache[0];
ramHook_PSKPassPhrase = &PSKPassPhrase[0];
// ramHook_hal_SetCpuMaxSpeed = hal_SetCpuOpToSecuritySpeed;
// ramHook_hal_RestoreCpuSpeed = cm_SetPerformanceParams;
}
//#pragma arm section code
#ifdef DRV_EMBEDDED_SUPPLICANT
t_u16
SupplicantSetPassphrase(void *priv, void *pPassphraseBuf)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = NULL;
mlan_ds_passphrase *psk = (mlan_ds_passphrase *)pPassphraseBuf;
IEEEtypes_MacAddr_t *pBssid = NULL;
UINT8 *pPMK = NULL;
UINT8 Passphrase[PSK_PASS_PHRASE_LEN_MAX], *pPassphrase = NULL;
UINT8 *pSsid = NULL;
UINT8 ssidLen = 0;
UINT16 retVal = 0;
t_u8 zero_mac[] = { 0, 0, 0, 0, 0, 0 };
if (!psapriv)
return retVal;
util_fns = &psapriv->util_fns;
if (memcmp(util_fns, (t_u8 *)&psk->bssid, zero_mac, sizeof(zero_mac)))
pBssid = (IEEEtypes_MacAddr_t *)&psk->bssid;
ssidLen = psk->ssid.ssid_len;
if (ssidLen > 0)
pSsid = psk->ssid.ssid;
if (psk->psk_type == MLAN_PSK_PASSPHRASE) {
pPassphrase = psk->psk.passphrase.passphrase;
memset(util_fns, Passphrase, 0x00, sizeof(Passphrase));
memcpy(util_fns, Passphrase, pPassphrase,
MIN(MLAN_MAX_PASSPHRASE_LENGTH,
psk->psk.passphrase.passphrase_len));
}
if (psk->psk_type == MLAN_PSK_PMK)
pPMK = psk->psk.pmk.pmk;
/* Always enable the supplicant on a set */
// supplicantEnable(priv);
if (pBssid && pPMK) {
pmkCacheAddPMK(priv, pBssid, pPMK);
} else if (pSsid) {
if (pPMK) {
pmkCacheAddPSK(priv, pSsid, ssidLen, pPMK, NULL);
} else if (pPassphrase) {
pmkCacheAddPSK(priv, pSsid, ssidLen, NULL, Passphrase);
pPMK = pmkCacheFindPSK(priv, pSsid, ssidLen);
pmkCacheGeneratePSK(priv, pSsid, ssidLen,
(char *)Passphrase, pPMK);
} else {
/* Just an SSID so we can't set anything in the cache */
retVal = 1;
}
} else if (pPassphrase) {
memcpy(util_fns, PSKPassPhrase, Passphrase, sizeof(Passphrase));
} else {
/* Not enough data to set anything in the cache */
retVal = 1;
}
return retVal;
}
BOOLEAN
SupplicantClearPMK_internal(void *priv, void *pPassphraseBuf)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
mlan_ds_passphrase *psk = (mlan_ds_passphrase *)pPassphraseBuf;
IEEEtypes_MacAddr_t *pBssid = NULL;
UINT8 *pPassphrase = NULL;
UINT8 *pSsid = NULL;
UINT8 ssidLen = 0;
t_u8 zero_mac[] = { 0, 0, 0, 0, 0, 0 };
if (memcmp(util_fns, (t_u8 *)&psk->bssid, zero_mac, sizeof(zero_mac)))
pBssid = (IEEEtypes_MacAddr_t *)&psk->bssid;
ssidLen = psk->ssid.ssid_len;
if (ssidLen > 0)
pSsid = psk->ssid.ssid;
if (psk->psk_type == MLAN_PSK_PASSPHRASE)
pPassphrase = psk->psk.passphrase.passphrase;
if (pBssid) {
pmkCacheDeletePMK(priv, (UINT8 *)pBssid);
} else if (pSsid) {
pmkCacheDeletePSK(priv, pSsid, ssidLen);
} else if (pPassphrase) {
/* Clear the global passphrase by setting it to blank */
memset(util_fns, ramHook_PSKPassPhrase, 0x00,
PSK_PASS_PHRASE_LEN_MAX);
} else {
return FALSE;
}
return TRUE;
}
void
SupplicantClearPMK(void *priv, void *pPassphrase)
{
if (!priv)
return;
if (!SupplicantClearPMK_internal(priv, pPassphrase)) {
/* Always disable the supplicant on a flush */
supplicantDisable(priv);
pmkCacheFlush(priv);
}
}
void
SupplicantQueryPassphrase(void *priv, void *pPassphraseBuf)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = NULL;
mlan_ds_passphrase *psk = (mlan_ds_passphrase *)pPassphraseBuf;
UINT8 *pPassphrase = NULL;
UINT8 *pSsid = NULL;
UINT8 ssidLen = 0;
if (!psapriv)
return;
util_fns = &psapriv->util_fns;
ssidLen = psk->ssid.ssid_len;
pSsid = psk->ssid.ssid;
if (ssidLen) {
pPassphrase = pmkCacheFindPassphrase(priv, pSsid, ssidLen);
if (pPassphrase) {
psk->psk_type = MLAN_PSK_PASSPHRASE;
memcpy(util_fns, psk->psk.passphrase.passphrase,
pPassphrase, PSK_PASS_PHRASE_LEN_MAX);
psk->psk.passphrase.passphrase_len =
wlan_strlen(pPassphrase);
}
}
}
#endif

View File

@@ -0,0 +1,58 @@
/** @file pmkcache.h
*
* @brief This file contains define for pmk cache
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef PMK_CACHE_H__
#define PMK_CACHE_H__
#include "wltypes.h"
#include "IEEE_types.h"
#include "pmkCache_rom.h"
/*!
** \brief If a matching SSID entry is present in the PMK Cache, returns a
** pointer to the PSK. If no entry is found in the cache, a
** new PSK entry will be generated if a PassPhrase is set.
** \param pSsid pointer to string containing desired SSID.
** \param ssidLen length of the SSID string *pSsid.
** \exception Does not handle the case when multiple matching SSID entries are
** found. Returns the first match.
** \return pointer to PSK with matching SSID entry from PMK cache,
** NULL if no matching entry found.
*/
extern UINT8 *pmkCacheFindPSK(void *priv, UINT8 *pSsid, UINT8 ssidLen);
/*!
** \brief Flushes all entries in PMK cache
*/
extern void pmkCacheFlush(void *priv);
extern void pmkCacheGetPassphrase(void *priv, char *pPassphrase);
extern void pmkCacheSetPassphrase(void *priv, char *pPassphrase);
extern void pmkCacheInit(void *priv);
extern void pmkCacheRomInit(void);
extern void supplicantDisable(void *priv);
#endif

View File

@@ -0,0 +1,381 @@
/** @file pmkcache_rom.c
*
* @brief This file defines function for pmk cache
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wl_macros.h"
#include "wltypes.h"
#include "pass_phrase.h"
#include "pmkCache_rom.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#define BSSID_FLAG 0xff
SINT8 replacementRankMax;
SINT32 ramHook_MAX_PMK_CACHE_ENTRIES;
pmkElement_t *ramHook_pmkCache;
char *ramHook_PSKPassPhrase;
//void (*ramHook_hal_SetCpuMaxSpeed)(void);
//void (*ramHook_hal_RestoreCpuSpeed)(void);
/*!
** \brief creates a new PMK cache entry with given SSID.
** \param pSsid pointer to desired SSID.
** \param ssidLen length of the desired SSID string.
** \return pointer to newly created PMK cache entry,
** NULL if PMK cache is full.
*/
pmkElement_t *
pmkCacheNewElement(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT8 index;
pmkElement_t *pPMK = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheNewElement_hook(&pPMK)) {
return pPMK;
}
#endif
for (index = 0; index < ramHook_MAX_PMK_CACHE_ENTRIES; index++) {
/* If the cache is full the least recently used entry
** will be replaced. Decrement all the replacement ranks
** to have a free cache entry.
*/
if (ramHook_MAX_PMK_CACHE_ENTRIES == replacementRankMax) {
(ramHook_pmkCache[index].replacementRank)--;
}
/* Either the entry is free or it can be replaced */
if (NULL == pPMK &&
0 == ramHook_pmkCache[index].replacementRank) {
/* empty entry found */
pPMK = &ramHook_pmkCache[index];
/* clear the entry in case this is a replacement */
memset(util_fns, pPMK, 0x00, sizeof(pmkElement_t));
if (ramHook_MAX_PMK_CACHE_ENTRIES > replacementRankMax) {
/* Cache isn't full so increment the max possible rank */
replacementRankMax++;
}
/* Set the rank so it is the last to be replaced */
ramHook_pmkCache[index].replacementRank =
replacementRankMax;
}
}
return pPMK;
}
void
pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement)
{
UINT8 index;
/* Update the replacementRank field if the PMK is found */
if (pPMKElement && pPMKElement->replacementRank != replacementRankMax) {
/*
** The cache entry with a larger rank value needs to
** to be adjusted. The cache entry given will have the
** largest rank value
*/
for (index = 0; index < ramHook_MAX_PMK_CACHE_ENTRIES; index++) {
if (ramHook_pmkCache[index].replacementRank
> pPMKElement->replacementRank) {
(ramHook_pmkCache[index].replacementRank)--;
}
}
pPMKElement->replacementRank = replacementRankMax;
}
}
/*!
** \brief Finds a PMK entry matching given BSSID
** \param pBssid pointer to the desired BSSID
** \return pointer to key data field of the matching PMK cache entry.
** NULL, if no matching PMK entry is found
*/
pmkElement_t *
pmkCacheFindPMKElement(void *priv, IEEEtypes_MacAddr_t *pBssid)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT8 index = 0;
pmkElement_t *pPMKElement = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheFindPMKElement_hook(pBssid, &pPMKElement)) {
return pPMKElement;
}
#endif
for (index = 0; index < ramHook_MAX_PMK_CACHE_ENTRIES; index++) {
/* See if the entry is valid.
** See if the entry is a PMK
** See if the BSSID matches
*/
if (ramHook_pmkCache[index].replacementRank > 0
&& ramHook_pmkCache[index].length == BSSID_FLAG
&& (0 == memcmp(util_fns, ramHook_pmkCache[index].key.Bssid,
pBssid,
sizeof(ramHook_pmkCache[index].key.Bssid))))
{
pPMKElement = (ramHook_pmkCache + index);
}
}
/* Update the rank if an entry is found. Null is an accepted
** input for the function
*/
pmkCacheUpdateReplacementRank(pPMKElement);
return pPMKElement;
}
/*!
** \brief If a matching SSID entry is present in the PMK Cache, returns a
** pointer to its key field.
** \param pSsid pointer to string containing desired SSID.
** \param ssidLen length of the SSID string *pSsid.
** \exception Does not handle the case when multiple matching SSID entries are
** found. Returns the first match.
** \return pointer to pmkElement with matching SSID entry from PMK cache,
** NULL if no matching entry found.
*/
pmkElement_t *
pmkCacheFindPSKElement(void *priv, UINT8 *pSsid, UINT8 ssidLen)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT8 index = 0;
pmkElement_t *pPMKElement = NULL;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheFindPSKElement_hook(pSsid, ssidLen, &pPMKElement)) {
return pPMKElement;
}
#endif
for (index = 0; index < ramHook_MAX_PMK_CACHE_ENTRIES; index++) {
/* See if the entry is valid.
** See if the entry is a PSK
** See if the SSID matches
*/
if (ramHook_pmkCache[index].replacementRank
&& ramHook_pmkCache[index].length == ssidLen
&& (0 == memcmp(util_fns, ramHook_pmkCache[index].key.Ssid,
pSsid, ssidLen))) {
pPMKElement = (ramHook_pmkCache + index);
}
}
/* Update the rank if an entry is found. Null is an accepted
** input for the function
*/
pmkCacheUpdateReplacementRank(pPMKElement);
return pPMKElement;
}
UINT8 *
pmkCacheFindPMK(void *priv, IEEEtypes_MacAddr_t *pBssid)
{
UINT8 *pPMK = NULL;
pmkElement_t *pPMKElement = pmkCacheFindPMKElement(priv, pBssid);
/* extract the PMK from the cache entry */
if (pPMKElement) {
pPMK = pPMKElement->PMK;
}
return pPMK;
}
void
pmkCacheAddPMK(void *priv, IEEEtypes_MacAddr_t *pBssid, UINT8 *pPMK)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
pmkElement_t *pPMKElement;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheAddPMK_hook(pBssid, pPMK)) {
return;
}
#endif
pPMKElement = pmkCacheFindPMKElement(priv, pBssid);
if (!pPMKElement) {
/* Entry not found. Create a new entry and fill it in */
pPMKElement = pmkCacheNewElement(priv);
/* Update the key union with the BSSID */
memcpy(util_fns, pPMKElement->key.Bssid,
pBssid, sizeof(pPMKElement->key.Bssid));
/* Set the length to a value that is invalid for
** an SSID. The invalid value will flag the entry as a PMK
*/
pPMKElement->length = BSSID_FLAG;
}
if (pPMK) {
memcpy(util_fns, pPMKElement->PMK, pPMK, MAX_PMK_SIZE);
}
}
void
pmkCacheAddPSK(void *priv, UINT8 *pSsid, UINT8 ssidLen, UINT8 *pPSK,
UINT8 *pPassphrase)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
pmkElement_t *pPMKElement;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheAddPSK_hook(pSsid, ssidLen, pPSK)) {
return;
}
#endif
pPMKElement = pmkCacheFindPSKElement(priv, pSsid, ssidLen);
if (NULL == pPMKElement) {
/* Entry not found. Create a new entry and fill it in */
pPMKElement = pmkCacheNewElement(priv);
/* Update the key portion with the SSID */
memcpy(util_fns, pPMKElement->key.Ssid, pSsid, ssidLen);
pPMKElement->length = ssidLen;
}
if (pPSK) {
memcpy(util_fns, pPMKElement->PMK, pPSK, MAX_PMK_SIZE);
}
if (pPassphrase)
memcpy(util_fns, pPMKElement->passphrase, pPassphrase,
PSK_PASS_PHRASE_LEN_MAX);
}
void
pmkCacheDeletePMK(void *priv, t_u8 *pBssid)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
pmkElement_t *pPMKElement =
pmkCacheFindPMKElement(priv, (IEEEtypes_MacAddr_t *)pBssid);
if (pPMKElement) {
/* Invalidate the enrty by setting the memory for the
** cache entry to zero.
** This will ensure that the replacementRank is zero
*/
memset(util_fns, pPMKElement, 0x00, sizeof(pmkElement_t));
replacementRankMax--;
}
}
void
pmkCacheDeletePSK(void *priv, UINT8 *pSsid, UINT8 ssidLen)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
pmkElement_t *pPMKElement =
pmkCacheFindPSKElement(priv, pSsid, ssidLen);
if (pPMKElement) {
/* Invalidate the enrty by setting the memory for the
** cache entry to zero.
** This will ensure that the replacementRank is zero
*/
memset(util_fns, pPMKElement, 0x00, sizeof(pmkElement_t));
replacementRankMax--;
}
}
UINT8
pmkCacheGetHexNibble(UINT8 nibble)
{
if (nibble >= 'a') {
return (nibble - 'a' + 10);
}
if (nibble >= 'A') {
return (nibble - 'A' + 10);
}
return (nibble - '0');
}
void
pmkCacheGeneratePSK(void *priv, UINT8 *pSsid,
UINT8 ssidLen, char *pPassphrase, UINT8 *pPSK)
{
int i;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (pmkCacheGeneratePSK_hook(pSsid, ssidLen, pPassphrase, pPSK)) {
return;
}
#endif
if (pPSK && pPassphrase) {
for (i = 0; i < PSK_PASS_PHRASE_LEN_MAX; i++) {
if (pPassphrase[i] == 0) {
break;
}
}
if (i > 7 && i < PSK_PASS_PHRASE_LEN_MAX) {
/* bump the CPU speed for the PSK generation */
//ramHook_hal_SetCpuMaxSpeed();
Mrvl_PasswordHash((void *)priv, pPassphrase,
(UINT8 *)pSsid, ssidLen, pPSK);
//ramHook_hal_RestoreCpuSpeed();
} else if (i == PSK_PASS_PHRASE_LEN_MAX) {
/* Convert ASCII to binary */
for (i = 0; i < PSK_PASS_PHRASE_LEN_MAX; i += 2) {
pPSK[i / 2] =
((pmkCacheGetHexNibble(pPassphrase[i])
<< 4)
|
pmkCacheGetHexNibble(pPassphrase
[i + 1]));
}
}
}
}

View File

@@ -0,0 +1,125 @@
/** @file pmkcache_rom.h
*
* @brief This file contains the defien for pmk cache
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef PMK_CACHE_ROM_H__
#define PMK_CACHE_ROM_H__
#include "wltypes.h"
#include "IEEE_types.h"
#include "hostsa_ext_def.h"
#define PSK_PASS_PHRASE_LEN_MAX 64
#define PMK_LEN_MAX 32
#define MAX_PMK_SIZE 32
typedef struct {
union {
IEEEtypes_MacAddr_t Bssid;
char Ssid[32];
} key;
UINT8 PMK[MAX_PMK_SIZE]; /* PMK / PSK */
UINT8 length;
UINT8 passphrase[PSK_PASS_PHRASE_LEN_MAX];
SINT8 replacementRank;
} pmkElement_t;
/*!
** \brief Finds a PMK matching a given BSSID
** \param pBssid pointer to the desired BSSID
** \return pointer to the matching PMK.
** NULL, if no matching PMK entry is found
*/
extern UINT8 *pmkCacheFindPMK(void *priv, IEEEtypes_MacAddr_t *pBssid);
#if 0
extern BOOLEAN (*pmkCacheFindPSKElement_hook) (UINT8 *pSsid,
UINT8 ssidLen,
pmkElement_t **ptr_val);
#endif
extern pmkElement_t *pmkCacheFindPSKElement(void *priv, UINT8 *pSsid,
UINT8 ssidLen);
/*!
** \brief adds a new PMK entry to PMK cache.
** \param pBssid pointer to Bssid for which to add the PMK
** \param pPMK pointer to PMK data
*/
//extern BOOLEAN (*pmkCacheAddPMK_hook)(IEEEtypes_MacAddr_t * pBssid,
// UINT8 *pPMK);
extern void pmkCacheAddPMK(void *priv, IEEEtypes_MacAddr_t *pBssid,
UINT8 *pPMK);
/*!
** \brief Adds a new PSK to PMK cache.
** \param pSsid pointer to desired SSID for which to add the PSK entry.
** \param ssidLen length of the SSID string.
** \param pPSK pointer to PSK to store.
*/
#if 0
extern BOOLEAN (*pmkCacheAddPSK_hook) (UINT8 *pSsid,
UINT8 ssidLen, UINT8 *pPSK);
#endif
extern void pmkCacheAddPSK(void *priv, UINT8 *pSsid,
UINT8 ssidLen, UINT8 *pPSK, UINT8 *pPassphrase);
/*!
** \brief Delete a particular PMK entry from PMK cache.
** \param pBssid pointer to BSSID that needs to be deleted
*/
extern void pmkCacheDeletePMK(void *priv, t_u8 *pBssid);
/*!
** \brief delete a particular PSK entry from PMK cache
** \param Ssid pointer to SSID that needs to be deleted
** \param ssidLen length of the string pointed to by Ssid
*/
extern void pmkCacheDeletePSK(void *priv, UINT8 *ssid, UINT8 ssidLen);
#if 0
extern BOOLEAN (*pmkCacheGeneratePSK_hook) (UINT8 *pSsid,
UINT8 ssidLen,
char *pPassphrase, UINT8 *pPSK);
#endif
extern void pmkCacheGeneratePSK(void *priv, UINT8 *pSsid,
UINT8 ssidLen, char *pPassphrase, UINT8 *pPSK);
//extern BOOLEAN (*pmkCacheNewElement_hook)(pmkElement_t ** ptr_val);
extern pmkElement_t *pmkCacheNewElement(void *priv);
//extern BOOLEAN (*pmkCacheFindPMKElement_hook)(IEEEtypes_MacAddr_t * pBssid,
// pmkElement_t ** ptr_val);
extern pmkElement_t *pmkCacheFindPMKElement(void *priv,
IEEEtypes_MacAddr_t *pBssid);
extern void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement);
extern SINT8 replacementRankMax;
/* ROM linkages */
extern SINT32 ramHook_MAX_PMK_CACHE_ENTRIES;
extern pmkElement_t *ramHook_pmkCache;
extern char *ramHook_PSKPassPhrase;
//extern void (*ramHook_hal_SetCpuMaxSpeed)(void);
//extern void (*ramHook_hal_RestoreCpuSpeed)(void);
#endif

View File

@@ -0,0 +1,127 @@
/** @file rc4.c
*
* @brief This file defines rc4 encrypt algorithm
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "rc4_rom.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
typedef struct rc4_key {
unsigned char state[256];
unsigned char x;
unsigned char y;
} rc4_key;
static rc4_key rc4key;
static void swap_byte(unsigned char *a, unsigned char *b);
void
prepare_key(unsigned char *key_data_ptr, int key_data_len, rc4_key *key)
{
unsigned char index1;
unsigned char index2;
unsigned char *state;
short counter;
state = &key->state[0];
for (counter = 0; counter < 256; counter++) {
state[counter] = counter;
}
key->x = 0;
key->y = 0;
index1 = 0;
index2 = 0;
for (counter = 0; counter < 256; counter++) {
index2 = (key_data_ptr[index1] + state[counter] + index2) % 256;
swap_byte(&state[counter], &state[index2]);
index1 = (index1 + 1) % key_data_len;
}
}
void
rc4(unsigned char *buffer_ptr, int buffer_len, int skip, rc4_key *key)
{
unsigned char x;
unsigned char y;
unsigned char *state;
unsigned char xorIndex;
short counter;
x = key->x;
y = key->y;
state = &key->state[0];
for (counter = 0; counter < skip; counter++) {
x = (x + 1) % 256;
y = (state[x] + y) % 256;
swap_byte(&state[x], &state[y]);
}
for (counter = 0; counter < buffer_len; counter++) {
x = (x + 1) % 256;
y = (state[x] + y) % 256;
swap_byte(&state[x], &state[y]);
xorIndex = (state[x] + state[y]) % 256;
buffer_ptr[counter] ^= state[xorIndex];
}
key->x = x;
key->y = y;
}
static void
swap_byte(unsigned char *a, unsigned char *b)
{
unsigned char swapByte;
swapByte = *a;
*a = *b;
*b = swapByte;
}
void
RC4_Encrypt(void *priv, unsigned char *Encr_Key,
unsigned char *IV,
unsigned short iv_length,
unsigned char *Data,
unsigned short data_length, unsigned short skipBytes)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
unsigned char key[32];
if (iv_length + 16 > sizeof(key)) {
return;
}
memcpy(util_fns, key, IV, iv_length);
memcpy(util_fns, key + iv_length, Encr_Key, 16);
prepare_key(key, iv_length + 16, &rc4key);
rc4(Data, data_length, skipBytes, &rc4key);
}

View File

@@ -0,0 +1,30 @@
/** @file rc4.h
*
* @brief This file include rc4_rom.h
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _RC4_H
#define _RC4_H
#include "rc4_rom.h"
#endif

View File

@@ -0,0 +1,33 @@
/** @file rc4._rom.h
*
* @brief This file contains the define for rc4
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _RC4_ROM_H
#define _RC4_ROM_H
extern void RC4_Encrypt(void *pmpriv, unsigned char *Encr_Key,
unsigned char *IV,
unsigned short iv_length,
unsigned char *Data,
unsigned short data_length, unsigned short skipBytes);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
/** @file rijndael.h
*
* @brief This file contains the function optimised ANSI C code for the Rijndael cipher (now AES)
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef __RIJNDAEL_H
#define __RIJNDAEL_H
#include "wltypes.h"
#define MAXKC (256/32)
#define MAXKB (256/8)
#define MAXNR 14
/*
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
*/
/* The structure for key information */
typedef struct {
int decrypt;
int Nr; /* key-length-dependent number of rounds */
UINT key[4 * (MAXNR + 1)]; /* encrypt or decrypt key schedule */
} rijndael_ctx;
void rijndael_set_key(rijndael_ctx *, UINT8 *, int, int);
void rijndael_decrypt(rijndael_ctx *, UINT8 *, UINT8 *);
void rijndael_encrypt(rijndael_ctx *, UINT8 *, UINT8 *);
#endif /* __RIJNDAEL_H */

View File

@@ -0,0 +1,401 @@
/** @file sha1.c
*
* @brief This file defines the sha1 functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "sha1.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
/*
* Define the SHA1 circular left shift macro
*/
#define Mrvl_SHA1CircularShift(bits,word) \
(((word) << (bits)) | ((word) >> (32-(bits))))
/* Local Function Prototyptes */
static void Mrvl_SHA1PadMessage(Mrvl_SHA1_CTX *);
static void Mrvl_SHA1ProcessMessageBlock(Mrvl_SHA1_CTX *);
/*
* SHA1Init
*
* Description:
* This function will initialize the SHA1_CTX in preparation
* for computing a new SHA1 message digest.
*
* Parameters:
* context: [in/out]
* The context to reset.
*
* Returns:
* sha Error Code.
*
*/
/*int SHA1Init(SHA1_CTX *context) */
int
Mrvl_SHA1Init(Mrvl_SHA1_CTX *context)
{
if (!context) {
return shaNull;
}
context->Length_Low = 0;
context->Length_High = 0;
context->Message_Block_Index = 0;
context->Intermediate_Hash[0] = 0x67452301;
context->Intermediate_Hash[1] = 0xEFCDAB89;
context->Intermediate_Hash[2] = 0x98BADCFE;
context->Intermediate_Hash[3] = 0x10325476;
context->Intermediate_Hash[4] = 0xC3D2E1F0;
context->Computed = 0;
context->Corrupted = 0;
return shaSuccess;
}
/*
* SHA1Final
*
* Description:
* This function will return the 160-bit message digest into the
* Message_Digest array provided by the caller.
* NOTE: The first octet of hash is stored in the 0th element,
* the last octet of hash in the 19th element.
*
* Parameters:
* context: [in/out]
* The context to use to calculate the SHA-1 hash.
* Message_Digest: [out]
* Where the digest is returned.
*
* Returns:
* sha Error Code.
*
*/
int
Mrvl_SHA1Final(void *priv, Mrvl_SHA1_CTX *context,
UINT8 Message_Digest[A_SHA_DIGEST_LEN])
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
int i;
if (!context || !Message_Digest) {
return shaNull;
}
if (context->Corrupted) {
return context->Corrupted;
}
if (!context->Computed) {
Mrvl_SHA1PadMessage(context);
for (i = 0; i < 64; ++i) {
/* message may be sensitive, clear it out */
context->Message_Block[i] = 0;
}
context->Length_Low = 0; /* and clear length */
context->Length_High = 0;
context->Computed = 1;
}
for (i = 0; i < A_SHA_DIGEST_LEN; ++i) {
Message_Digest[i] = context->Intermediate_Hash[i >> 2]
>> 8 * (3 - (i & 0x03));
}
memset(util_fns, context, 0x00, sizeof(Mrvl_SHA1_CTX));
return shaSuccess;
}
/*
* SHA1Update
*
* Description:
* This function accepts an array of octets as the next portion
* of the message.
*
* Parameters:
* context: [in/out]
* The SHA context to update
* message_array: [in]
* An array of characters representing the next portion of
* the message.
* length: [in]
* The length of the message in message_array
*
* Returns:
* sha Error Code.
*
*/
int
Mrvl_SHA1Update(Mrvl_SHA1_CTX *context,
const UINT8 *message_array, unsigned length)
{
if (!length) {
return shaSuccess;
}
if (!context || !message_array) {
return shaNull;
}
if (context->Computed) {
context->Corrupted = shaStateError;
return shaStateError;
}
if (context->Corrupted) {
return context->Corrupted;
}
while (length-- && !context->Corrupted) {
context->Message_Block[context->Message_Block_Index++] =
(*message_array & 0xFF);
context->Length_Low += 8;
if (context->Length_Low == 0) {
context->Length_High++;
if (context->Length_High == 0) {
/* Message is too long */
context->Corrupted = 1;
}
}
if (context->Message_Block_Index == 64) {
Mrvl_SHA1ProcessMessageBlock(context);
}
message_array++;
}
return shaSuccess;
}
/*
* SHA1ProcessMessageBlock
*
* Description:
* This function will process the next 512 bits of the message
* stored in the Message_Block array.
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
Eastlake & Jones Informational [Page 14]
RFC 3174 US Secure Hash Algorithm 1 (SHA1) September 2001
* Many of the variable names in this code, especially the
* single character names, were used because those were the
* names used in the publication.
*
*
*/
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#define blk(i) (W[i&15] = rol(W[(i+13)&15]^W[(i+8)&15]^W[(i+2)&15]^W[i&15],1))
#define blk0(i) ((i & 0x30)? blk(i) : W[i])
/*
NOte- Some of the variables are made static in this file because
this function runs in the idle task. The idle task dosent have
enough stack space to accomodate these variables. In the future
if this function is run in a different task with large stack space
or if the stack space of the idle task is increased then we can
remove the static defination from these variables.
*/
void
Mrvl_SHA1ProcessMessageBlock(Mrvl_SHA1_CTX *context)
{
static const UINT32 K[] = { /* Constants defined in SHA-1 */
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6
};
int t; /* Loop counter */
UINT32 temp; /* Temporary word value */
UINT32 *W;
UINT32 A, B, C, D, E; /* Word buffers */
/* WLAN buffers are aligned, so the context starts at a UINT32 boundary */
W = context->Scratch;
for (t = 0; t < 16; t++) {
W[t] = context->Message_Block[t * 4] << 24;
W[t] |= context->Message_Block[t * 4 + 1] << 16;
W[t] |= context->Message_Block[t * 4 + 2] << 8;
W[t] |= context->Message_Block[t * 4 + 3];
}
A = context->Intermediate_Hash[0];
B = context->Intermediate_Hash[1];
C = context->Intermediate_Hash[2];
D = context->Intermediate_Hash[3];
E = context->Intermediate_Hash[4];
for (t = 0; t < 20; t++) {
temp = Mrvl_SHA1CircularShift(5, A) +
((B & C) | ((~B) & D)) + E + blk0(t) + K[0];
E = D;
D = C;
C = Mrvl_SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 20; t < 40; t++) {
temp = Mrvl_SHA1CircularShift(5,
A) + (B ^ C ^ D) + E + blk(t) +
K[1];
E = D;
D = C;
C = Mrvl_SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 40; t < 60; t++) {
temp = Mrvl_SHA1CircularShift(5, A) +
((B & C) | (B & D) | (C & D)) + E + blk(t) + K[2];
E = D;
D = C;
C = Mrvl_SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 60; t < 80; t++) {
temp = Mrvl_SHA1CircularShift(5,
A) + (B ^ C ^ D) + E + blk(t) +
K[3];
E = D;
D = C;
C = Mrvl_SHA1CircularShift(30, B);
B = A;
A = temp;
}
context->Intermediate_Hash[0] += A;
context->Intermediate_Hash[1] += B;
context->Intermediate_Hash[2] += C;
context->Intermediate_Hash[3] += D;
context->Intermediate_Hash[4] += E;
context->Message_Block_Index = 0;
}
/*
* SHA1PadMessage
*
Eastlake & Jones Informational [Page 16]
RFC 3174 US Secure Hash Algorithm 1 (SHA1) September 2001
* Description:
* According to the standard, the message must be padded to an even
* 512 bits. The first padding bit must be a '1'. The last 64
* bits represent the length of the original message. All bits in
* between should be 0. This function will pad the message
* according to those rules by filling the Message_Block array
* accordingly. It will also call the ProcessMessageBlock function
* provided appropriately. When it returns, it can be assumed that
* the message digest has been computed.
*
* Parameters:
* context: [in/out]
* The context to pad
* ProcessMessageBlock: [in]
* The appropriate SHA*ProcessMessageBlock function
* Returns:
* Nothing.
*
*/
void
Mrvl_SHA1PadMessage(Mrvl_SHA1_CTX *context)
{
/*
* Check to see if the current message block is too small to hold
* the initial padding bits and length. If so, we will pad the
* block, process it, and then continue padding into a second
* block.
*/
if (context->Message_Block_Index > 55) {
context->Message_Block[context->Message_Block_Index++] = 0x80;
while (context->Message_Block_Index < 64) {
context->Message_Block[context->Message_Block_Index++] =
0;
}
Mrvl_SHA1ProcessMessageBlock(context);
while (context->Message_Block_Index < 56) {
context->Message_Block[context->Message_Block_Index++] =
0;
}
} else {
context->Message_Block[context->Message_Block_Index++] = 0x80;
while (context->Message_Block_Index < 56) {
context->Message_Block[context->Message_Block_Index++] =
0;
}
}
/*
* Store the message length as the last 8 octets
*/
context->Message_Block[56] = context->Length_High >> 24;
context->Message_Block[57] = context->Length_High >> 16;
context->Message_Block[58] = context->Length_High >> 8;
context->Message_Block[59] = context->Length_High;
context->Message_Block[60] = context->Length_Low >> 24;
context->Message_Block[61] = context->Length_Low >> 16;
context->Message_Block[62] = context->Length_Low >> 8;
context->Message_Block[63] = context->Length_Low;
Mrvl_SHA1ProcessMessageBlock(context);
}

View File

@@ -0,0 +1,82 @@
/** @file sha1.h
*
* @brief This file contains the sha1 functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _SHA1_H_
#define _SHA1_H_
#include "wltypes.h"
enum {
shaSuccess = 0,
shaNull, /* Null pointer parameter */
shaInputTooLong, /* input data too long */
shaStateError /* called Input after Result */
};
#define A_SHA_DIGEST_LEN 20
/*
* This structure will hold context information for the SHA-1
* hashing operation
*/
typedef struct {
UINT32 Intermediate_Hash[A_SHA_DIGEST_LEN / 4]; /* Message Digest */
UINT32 Length_Low; /* Message length in bits */
UINT32 Length_High; /* Message length in bits */
UINT32 Scratch[16]; /* This is used to reduce the memory
** requirements of the transform
**function
*/
UINT8 Message_Block[64]; /* 512-bit message blocks */
/* Index into message block array */
SINT16 Message_Block_Index;
UINT8 Computed; /* Is the digest computed? */
UINT8 Corrupted; /* Is the message digest corrupted? */
} Mrvl_SHA1_CTX;
/*
* Function Prototypes
*/
extern int Mrvl_SHA1Init(Mrvl_SHA1_CTX *);
extern int Mrvl_SHA1Update(Mrvl_SHA1_CTX *, const UINT8 *, unsigned int);
extern int Mrvl_SHA1Final(void *priv, Mrvl_SHA1_CTX *,
UINT8 Message_Digest[A_SHA_DIGEST_LEN]);
extern void Mrvl_PRF(void *priv, unsigned char *key,
int key_len,
unsigned char *prefix,
int prefix_len,
unsigned char *data,
int data_len, unsigned char *output, int len);
extern void Mrvl_hmac_sha1(void *priv, unsigned char **ppText,
int *pTextLen,
int textNum,
unsigned char *key,
int key_len, unsigned char *output, int outputLen);
#endif

View File

@@ -0,0 +1,459 @@
/** @file sha_256.c
*
* @brief This file defines the SHA256 hash implementation and interface functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
/*
* SHA-256 hash implementation and interface functions
*
* Copyright ?2003-2006, Jouni Malinen <jkmaline@cc.hut.fi>
*
* Copyright ?2006-2007, Marvell International Ltd. and its affiliates
* All rights reserved.
*
* 1. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 2. Neither the name of Jouni Malinen, Marvell nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sha_256.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#define WPA_GET_BE32(a) ((((UINT32) (a)[0]) << 24) | \
(((UINT32) (a)[1]) << 16) | \
(((UINT32) (a)[2]) << 8) | \
((UINT32) (a)[3]))
#define WPA_PUT_BE32(a, val) \
do { \
(a)[0] = (UINT8) (((UINT32) (val)) >> 24); \
(a)[1] = (UINT8) (((UINT32) (val)) >> 16); \
(a)[2] = (UINT8) (((UINT32) (val)) >> 8); \
(a)[3] = (UINT8) (((UINT32) (val)) & 0xff); \
} while (0)
#define WPA_PUT_BE64(a, val) \
do { \
(a)[0] = (UINT8) (((UINT64) (val)) >> 56); \
(a)[1] = (UINT8) (((UINT64) (val)) >> 48); \
(a)[2] = (UINT8) (((UINT64) (val)) >> 40); \
(a)[3] = (UINT8) (((UINT64) (val)) >> 32); \
(a)[4] = (UINT8) (((UINT64) (val)) >> 24); \
(a)[5] = (UINT8) (((UINT64) (val)) >> 16); \
(a)[6] = (UINT8) (((UINT64) (val)) >> 8); \
(a)[7] = (UINT8) (((UINT64) (val)) & 0xff); \
} while (0)
/**
* @brief hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104)
* @param priv pointer to previous element
* @param key: Key for HMAC operations
* @param key_len: Length of the key in bytes
* @param num_elem: Number of elements in the data vector; including [0] spare
* @param addr: Pointers to the data areas, [0] element must be left as spare
* @param len: Lengths of the data blocks, [0] element must be left as spare
* @param mac: Buffer for the hash (32 bytes)
* @param pScratchMem: Scratch Memory; At least a 492 byte buffer.
*/
void
hmac_sha256_vector(void *priv, UINT8 *key,
size_t key_len,
size_t num_elem,
UINT8 *addr[], size_t * len, UINT8 *mac, UINT8 *pScratchMem)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
size_t i;
UINT8 *pKpad; /* was UINT8 k_pad[64], padding - key XORd with ipad/opad */
UINT8 *pTk; /* was UINT8 tk[32] */
UINT8 *pTmpBuf;
UINT32 *ptrU32;
pKpad = pScratchMem; /* kpad = 64 bytes */
pTk = pKpad + 64; /* tk = 32 bytes */
pTmpBuf = pTk + 32; /* offset into the scratch buf = +96 bytes */
/* if key is longer than 64 bytes reset it to key = SHA256(key) */
if (key_len > 64) {
/* pTmpBuf = At least 396 bytes */
sha256_vector(priv, 1, &key, &key_len, pTk, pTmpBuf);
key = pTk;
key_len = 32;
}
/* the HMAC_SHA256 transform looks like:
*
* SHA256(K XOR opad, SHA256(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in ipad */
memset(util_fns, pKpad, 0x00, 64);
memcpy(util_fns, pKpad, key, key_len);
/* XOR key with ipad values */
ptrU32 = (UINT32 *)pKpad;
for (i = 16; i > 0; i--) {
*ptrU32++ ^= 0x36363636;
}
/* perform inner SHA256 */
addr[0] = pKpad;
len[0] = 64;
/* pTmpBuf = At least 396 bytes */
sha256_vector((void *)priv, num_elem, addr, len, mac, pTmpBuf);
memset(util_fns, pKpad, 0x00, 64);
memcpy(util_fns, pKpad, key, key_len);
/* XOR key with opad values */
ptrU32 = (UINT32 *)pKpad;
for (i = 16; i > 0; i--) {
*ptrU32++ ^= 0x5C5C5C5C;
}
/* perform outer SHA256 */
addr[0] = pKpad;
len[0] = 64;
addr[1] = mac;
len[1] = SHA256_MAC_LEN;
/* pTmpBuf = At least 396 bytes */
sha256_vector((void *)priv, 2, addr, len, mac, pTmpBuf);
}
static int sha256_process(void *priv, struct sha256_state *md,
const UINT8 *in,
unsigned int inlen, UINT8 *pScratchMem);
static int sha256_done(void *priv, struct sha256_state *md,
UINT8 *out, UINT8 *pScratchMem);
/**
* @brief sha256_vector - SHA256 hash for data vector
* @param priv pointer to previous element
* @param num_elem Number of elements in the data vector
* @param addr Pointers to the data areas
* @param len Lengths of the data blocks
* @param mac Buffer for the hash
* @param pScratchMem Scratch memory; At least (108 + 288) = 396 bytes */
void
sha256_vector(void *priv, size_t num_elem,
UINT8 *addr[], size_t * len, UINT8 *mac, UINT8 *pScratchMem)
{
UINT8 *pTmpBuf;
size_t i;
struct sha256_state *pCtx;
/*
** sizeof(struct sha256_state)
**
** UINT64 length = 8
** UINT32 state[8], curlen; = (9 * 4) = 36
** UINT8 buf[64]; = 64
** -----
** 108
*/
pCtx = (struct sha256_state *)pScratchMem;
pTmpBuf = pScratchMem + sizeof(struct sha256_state);
sha256_init(pCtx);
for (i = 0; i < num_elem; i++) {
/* pTmpBuf = At least 288 bytes of memory */
sha256_process((void *)priv, pCtx, addr[i], len[i], pTmpBuf);
}
sha256_done((void *)priv, pCtx, mac, pTmpBuf);
}
/* ===== start - public domain SHA256 implementation ===== */
/* This is based on SHA256 implementation in LibTomCrypt that was released into
* public domain by Tom St Denis. */
/* the K array */
static const unsigned int K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
};
/* Various logical functions */
#define RORc(x, y) \
(((((unsigned int)(x) & 0xFFFFFFFFUL) >> (unsigned int)((y) & 31)) | \
((unsigned int)(x) << (unsigned int)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) RORc((x), (n))
#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
/**
* sha256_compress - Compress 512-bits.
* @param md: Pointer to the element holding hash state.
* @param msgBuf: Pointer to the buffer containing the data to be hashed.
* @param pScratchMem: Scratch memory; At least 288 bytes of free memory *
*
*/
int
sha256_compress(void *priv, struct sha256_state *md,
UINT8 *msgBuf, UINT8 *pScratchMem)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT32 *pW; /* was UINT32 W[64] */
UINT32 *pS; /* was UINT32 S[8] */
UINT32 t0;
UINT32 t1;
UINT32 t;
UINT32 i;
UINT32 *ptrU32;
/* pW = (64 * 4) = 256
** pS = (8 * 4) = 32
** -----
** 288
*/
ptrU32 = pW = (UINT32 *)pScratchMem;
pS = pW + 64;
/* copy state into S */
memcpy(util_fns, (UINT8 *)pS, (UINT8 *)md->state, 32);
/* copy the a message block of 512-bits into pW[0..15] */
for (i = 16; i > 0; i--) {
int a0, a1;
a0 = *msgBuf++;
a1 = *msgBuf++;
a0 <<= 8;
a0 |= a1;
a1 = *msgBuf++;
a0 <<= 8;
a0 |= a1;
a1 = *msgBuf++;
a0 <<= 8;
*ptrU32++ = a0 | a1;
}
/* fill pW[16..63] */
for (i = 48; i > 0; i--) {
*ptrU32 =
(Gamma1(ptrU32[-2]) + ptrU32[-7] + Gamma0(ptrU32[-15]) +
ptrU32[-16]);
ptrU32++;
}
/* Compress */
#define RND(a,b,c,d,e,f,g,h,i) \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + pW[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1;
for (i = 0; i < 64; ++i) {
RND(pS[0], pS[1], pS[2], pS[3], pS[4], pS[5], pS[6], pS[7], i);
t = pS[7];
pS[7] = pS[6];
pS[6] = pS[5];
pS[5] = pS[4];
pS[4] = pS[3];
pS[3] = pS[2];
pS[2] = pS[1];
pS[1] = pS[0];
pS[0] = t;
}
/* feedback */
for (i = 0; i < 8; i++) {
md->state[i] = md->state[i] + pS[i];
}
return 0;
}
/* Initialize the hash state */
void
sha256_init(struct sha256_state *md)
{
md->curlen = 0;
md->length = 0;
md->state[0] = 0x6A09E667UL;
md->state[1] = 0xBB67AE85UL;
md->state[2] = 0x3C6EF372UL;
md->state[3] = 0xA54FF53AUL;
md->state[4] = 0x510E527FUL;
md->state[5] = 0x9B05688CUL;
md->state[6] = 0x1F83D9ABUL;
md->state[7] = 0x5BE0CD19UL;
}
/**
Process a block of memory though the hash
@param md The hash state
@param in The data to hash
@param inlen The length of the data (octets)
@param pScratchMem Temporary Memory Buf; At least 288 bytes.
@return CRYPT_OK if successful
*/
static int
sha256_process(void *priv, struct sha256_state *md,
const unsigned char *in, unsigned int inlen, UINT8 *pScratchMem)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
unsigned int n;
#define block_size 64
if (md->curlen > sizeof(md->buf)) {
return -1;
}
while (inlen > 0) {
if (md->curlen == 0 && inlen >= block_size) {
/* pScratchMem = At least 288 bytes of memory */
if (sha256_compress
((void *)priv, md, (UINT8 *)in, pScratchMem) < 0) {
return -1;
}
md->length += block_size * 8;
in += block_size;
inlen -= block_size;
} else {
n = MIN(inlen, (block_size - md->curlen));
memcpy(util_fns, md->buf + md->curlen, in, n);
md->curlen += n;
in += n;
inlen -= n;
if (md->curlen == block_size) {
/* pScratchMem = At least 288 bytes of memory */
if (sha256_compress
((void *)priv, md, md->buf,
pScratchMem) < 0) {
return -1;
}
md->length += 8 * block_size;
md->curlen = 0;
}
}
}
return 0;
}
/**
Terminate the hash to get the digest
@param md The hash state
@param out [out] The destination of the hash (32 bytes)
@param pScratchMem [in] Scratch memory; At least 288 bytes
@return CRYPT_OK if successful
*/
static int
sha256_done(void *priv, struct sha256_state *md, UINT8 *out, UINT8 *pScratchMem)
{
int i;
UINT32 *ptrU32;
UINT32 tmpU32;
if (md->curlen >= sizeof(md->buf)) {
return -1;
}
/* increase the length of the message */
md->length += md->curlen * 8;
/* append the '1' bit */
md->buf[md->curlen++] = (unsigned char)0x80;
/* if the length is currently above 56 bytes we append zeros
* then compress. Then we can fall back to padding zeros and length
* encoding like normal.
*/
if (md->curlen > 56) {
while (md->curlen < 64) {
md->buf[md->curlen++] = (unsigned char)0;
}
/* pScratchMem = At least 288 bytes of memory */
sha256_compress((void *)priv, md, md->buf, pScratchMem);
md->curlen = 0;
}
/* pad upto 56 bytes of zeroes */
while (md->curlen < 56) {
md->buf[md->curlen++] = (unsigned char)0;
}
/* store length */
ptrU32 = (UINT32 *)&md->length;
for (i = 0; i < 2; i++) {
tmpU32 = *ptrU32++;
WPA_PUT_BE32(md->buf + 60 - 4 * i, tmpU32);
}
/* pScratchMem = At least 288 bytes of memory */
sha256_compress((void *)priv, md, md->buf, pScratchMem);
ptrU32 = md->state;
/* copy output */
for (i = 8; i > 0; i--) {
tmpU32 = *ptrU32++;
WPA_PUT_BE32(out, tmpU32);
out += sizeof(UINT32);
}
return 0;
}
/* ===== end - public domain SHA256 implementation ===== */

View File

@@ -0,0 +1,80 @@
/** @file sha_256.h
*
* @brief This file contains the SHA256 hash implementation and interface functions
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef SHA256_H
#define SHA256_H
#include "wltypes.h"
#define SHA256_MAC_LEN 32
#define HMAC_SHA256_MIN_SCRATCH_BUF (500)
#define SHA256_MIN_SCRATCH_BUF (400)
struct sha256_state {
UINT64 length;
UINT32 state[8], curlen;
UINT8 buf[64];
};
void sha256_init(struct sha256_state *md);
/**
* @brief sha256_compress - Compress 512-bits.
* @param priv pointer to previous element
* @param md: Pointer to the element holding hash state.
* @param msgBuf: Pointer to the buffer containing the data to be hashed.
* @param pScratchMem: Scratch memory; At least 288 bytes of free memory *
*
*/
int sha256_compress(void *priv, struct sha256_state *md,
UINT8 *msgBuf, UINT8 *pScratchMem);
/**
* sha256_vector - SHA256 hash for data vector
* @param num_elem: Number of elements in the data vector
* @param addr: Pointers to the data areas
* @param len: Lengths of the data blocks
* @param mac: Buffer for the hash
* @param pScratchMem: Scratch memory; Buffer of SHA256_MIN_SCRATCH_BUF size
*/
void sha256_vector(void *priv, size_t num_elem,
UINT8 *addr[], size_t * len, UINT8 *mac, UINT8 *pScratchMem);
/**
* hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104)
* @param key: Key for HMAC operations
* @param key_len: Length of the key in bytes
* @param num_elem: Number of elements in the data vector; including [0]
* @param addr: Pointers to the data areas, [0] element must be left as spare
* @param len: Lengths of the data blocks, [0] element must be left as spare
* @param mac: Buffer for the hash (32 bytes)
* @param pScratchMem: Scratch Memory; Buffer of HMAC_SHA256_MIN_SCRATCH_BUF size
*/
void hmac_sha256_vector(void *priv, UINT8 *key,
size_t key_len,
size_t num_elem,
UINT8 *addr[],
size_t * len, UINT8 *mac, UINT8 *pScratchMem);
#endif /* SHA256_H */

View File

@@ -0,0 +1,875 @@
/** @file tlv.h
*
* @brief Definitions of the Marvell TLV and parsing functions.
*
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/*****************************************************************************
*
* File: tlv.h
*
*
*
* Author(s): Kapil Chhabra
* Date: 2005-01-27
* Description: Definitions of the Marvell TLV and parsing functions.
*
*****************************************************************************/
#ifndef TLV_H__
#define TLV_H__
#include "IEEE_types.h"
#define PROPRIETARY_TLV_BASE_ID 0x0100
/* Terminating TLV Type */
#define MRVL_TERMINATE_TLV_ID 0xffff
/* Defines for MRVL TLV IDs*/
/* IEEE TLVs*/
#define MRVL_SSID_TLV_ID 0x0000
#define MRVL_RATES_TLV_ID 0x0001
#define MRVL_PHYPARAMFHSET_TLV_ID 0x0002
#define MRVL_PHYPARAMDSSET_TLV_ID 0x0003
#define MRVL_CFPARAMSET_TLV_ID 0x0004
#define MRVL_IBSSPARAMSET_TLV_ID 0x0006
#define MRVL_COUNTRY_TLV_ID 0x0007
#define MRVL_PWR_CONSTRAINT_TLV_ID 0x0020
#define MRVL_PWR_CAPABILITY_TLV_ID 0x0021
#define MRVL_SUPPORTEDCHANNELS_TLV_ID 0x0024
#define MRVL_QUIET_TLV_ID 0x0028
#define MRVL_IBSSDFS_TLV_ID 0x0029
#define MRVL_HT_CAPABILITY_TLV_ID 0x002d
#define MRVL_QOSCAPABILITY_TLV_ID 0x002e
#define MRVL_RSN_TLV_ID 0x0030
#define MRVL_SUPPORTED_REGCLASS_TLV_ID 0x003b
#define MRVL_HT_INFORMATION_TLV_ID 0x003d
#define MRVL_SECONDARY_CHAN_OFFSET 0x003e
#define MRVL_2040_BSS_COEX_TLV_ID 0x0048
#define MRVL_OVERLAP_BSS_SCAN_TLV_ID 0x004a
#define MRVL_EXTENDED_CAP_TLV_ID 0x007f
#define MRVL_VHT_CAPABILITIES_TLV_ID 0x00bf
#define MRVL_VHT_OPERATION_TLV_ID 0x00c0
#define MRVL_AID_TLV_ID 0x00c5
#define MRVL_VHT_OPMODENTF_TLV_ID 0x00c7
#define MRVL_VENDORSPECIFIC_TLV_ID 0x00dd
/* Some of these TLV ids are used in ROM and should not be updated.
** You can confirm if it is not being used in rom then it can be updated.
*/
/* Proprietary TLVs */
#define MRVL_KEYPARAMSET_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x00)
#define MRVL_CHANNELLIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x01)
#define MRVL_NUMPROBES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x02)
#define MRVL_OMNI_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x03)
#define MRVL_RSSITHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x04)
#define MRVL_SNRTHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x05)
#define MRVL_BCNLOWRSSITHRESHOLD_TLV_ID MRVL_RSSITHRESHOLD_TLV_ID
#define MRVL_BCNLOWSNRTHRESHOLD_TLV_ID MRVL_SNRTHRESHOLD_TLV_ID
#define MRVL_FAILURECOUNT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x06)
#define MRVL_BEACONMISSED_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x07)
#define MRVL_LEDGPIO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x08)
#define MRVL_LEDBEHAVIOR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x09)
#define MRVL_PASSTHROUGH_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0a)
#define MRVL_REASSOCAP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0b)
#define MRVL_POWER_TBL_2_4GHZ_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0c)
#define MRVL_POWER_TBL_5GHZ_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0d)
/* sending Brocast SSID */
#define MRVL_BCASTPROBE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0e)
/* number of SSIDs for which directed probes need to be generated */
#define MRVL_NUMSSIDPROBE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x0f)
#define MRVL_WMMQSTATUS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x10)
#define MRVL_CRYPTO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x11)
#define MRVL_WILDCARD_SSID_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x12)
#define MRVL_TSFTIMESTAMP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x13)
#define MRVL_POWER_ADAPT_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x14)
#define MRVL_HOSTSLEEP_FILTER_TYPE1_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x15)
#define MRVL_BCNHIGHRSSITHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x16)
#define MRVL_BCNHIGHSNRTHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x17)
#define MRVL_AUTOTX_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x18)
#define MRVL_WSC_SELECTED_REGISTRAR_TLV (PROPRIETARY_TLV_BASE_ID + 0x19)
#define MRVL_WSC_ENROLLEE_TMO_TLV (PROPRIETARY_TLV_BASE_ID + 0x1a)
#define MRVL_WSC_ENROLLEE_PROBE_REQ_TLV (PROPRIETARY_TLV_BASE_ID + 0x1b)
#define MRVL_WSC_REGISTRAR_BEACON_TLV (PROPRIETARY_TLV_BASE_ID + 0x1c)
#define MRVL_WSC_REGISTRAR_PROBE_RESP_TLV (PROPRIETARY_TLV_BASE_ID + 0x1d)
#define MRVL_STARTBGSCANLATER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x1e)
#define MRVL_AUTHTYPE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x1f)
#define MRVL_STA_MAC_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x20)
#define MRVL_CUSTOM_ADHOC_PROBE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x21)
#define MRVL_CUSTOM_ADHOC_PYXIS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x22)
#define MRVL_CUSTOM_BSSID_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x23)
#define MRVL_CUSTOM_LINK_INDICATION_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x24)
#define MRVL_MESHIE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x25)
#define MRVL_DATA_LOWRSSITHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x26)
#define MRVL_DATA_LOWSNRTHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x27)
#define MRVL_DATA_HIGHRSSITHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x28)
#define MRVL_DATA_HIGHSNRTHRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x29)
#define MRVL_CHANNELBANDLIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2a)
#define MRVL_AP_MAC_ADDRESS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2b)
#define MRVL_BEACON_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2c)
#define MRVL_DTIM_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2d)
#define MRVL_BASIC_RATES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2e)
#define MRVL_TX_POWER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2f)
#define MRVL_BCAST_SSID_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x30)
#define MRVL_PREAMBLE_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x31)
#define MRVL_ANTENNA_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x32)
#define MRVL_RTS_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x33)
#define MRVL_RADIO_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x34)
#define MRVL_TX_DATA_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x35)
#define MRVL_PKT_FWD_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x36)
#define MRVL_STA_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x37)
#define MRVL_STA_MAC_ADDR_FILTER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x38)
#define MRVL_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x39)
#define MRVL_SECURITY_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3a)
#define MRVL_WEP_KEY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3b)
#define MRVL_WPA_PASSPHRASE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3c)
#define MRVL_SCAN_TIMING_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3d)
#define MRVL_NEIGHBOR_ENTRY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3e)
#define MRVL_NEIGHBOR_SCAN_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3f)
#define MRVL_ENCRYPTION_PROTOCOL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x40)
#define MRVL_AKMP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x41)
#define MRVL_CIPHER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x42)
#define MRVL_OFFLOAD_ENABLE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x43)
#define MRVL_SUPPLICANT_PMK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x44)
#define MRVL_SUPPLICANT_PASSPHRASE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x45)
#define MRVL_FRAG_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x46)
#define MRVL_GRP_REKEY_TIME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x47)
#define MRVL_ICV_ERROR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x48)
#define MRVL_PRE_BEACONMISSED_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x49)
#define MRVL_OLD_HT_CAPABILITY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4a)
#define MRVL_OLD_HT_INFORMATION_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4b)
#define MRVL_OLD_SECONDARY_CHAN_OFFSET_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4c)
#define MRVL_OLD_2040_BSS_COEX_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4d)
#define MRVL_OLD_OVERLAP_BSS_SCAN_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4e)
#define MRVL_OLD_EXTENDED_CAP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x4f)
#define MRVL_HT_OPERATIONAL_MCSSET_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x50)
#define MRVL_RATEDROPPATTERN_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x51)
#define MRVL_RATEDROPCONTROL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x52)
#define MRVL_RATESCOPE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x53)
#define MRVL_TYPES_POWER_GROUP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x54)
#define MRVL_MAX_STA_CNT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x55)
#define MRVL_BSS_SCAN_RSP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x56)
#define MRVL_BSS_SCAN_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x57)
#define MRVL_CHANRPT_BCN_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x58)
#define MRVL_CHANRPT_CHAN_LOAD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x59)
#define MRVL_CHANRPT_NOISE_HIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5a)
#define MRVL_CHANRPT_11H_BASIC_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5b)
#define MRVL_CHANRPT_FRAME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5c)
#define MRVL_RETRY_LIMIT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5d)
#define MRVL_WAPI_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5e)
#define MRVL_ASSOC_REASON_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5f)
#define MRVL_ROBUST_COEX_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x60)
#define MRVL_ROBUST_COEX_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x61)
#define MRVL_MCBC_DATA_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x62)
#define MRVL_MEASUREMENT_TIMING_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x63)
#define MRVL_RSN_REPLAY_PROT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x64)
#define MRVL_WAPI_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x67)
#define MRVL_MGMT_FRAME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x68)
#define MRVL_MGMT_IE_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x69)
#define MRVL_AP_SLEEP_PARAM_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6a)
#define MRVL_AP_INACT_SLEEP_PARAM_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6b)
#define MRVL_AP_BT_COEX_COMMON_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6c)
#define MRVL_AP_BT_COEX_SCO_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6d)
#define MRVL_AP_BT_COEX_ACL_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6e)
#define MRVL_AP_BT_COEX_STATS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6f)
#define MRVL_MGMT_PASSTHRU_MASK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x70)
#define MRVL_AUTO_DEEP_SLEEP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x71)
#define MRVL_ENHANCED_STA_POWER_SAVE_MODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x72)
#define MRVL_HOSTWAKE_STADB_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x73)
#define MRVL_HOSTWAKE_OUI_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x74)
#define MRVL_EAPOL_PWK_HSK_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x75)
#define MRVL_EAPOL_PWK_HSK_RETRIES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x76)
#define MRVL_EAPOL_GWK_HSK_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x77)
#define MRVL_EAPOL_GWK_HSK_RETRIES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x78)
#define MRVL_OPCHAN_CONTROL_DESC_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x79)
#define MRVL_OPCHAN_CHANGRP_CTRL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7a)
#define MRVL_PS_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7b)
#define MRVL_WFD_DISC_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7c)
#define MRVL_WFD_SCAN_ENABLE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7d)
#define MRVL_WFD_SCAN_PEER_DEVICE_ID_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7e)
#define MRVL_WFD_REQ_DEVICE_TYPE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7f)
#define MRVL_WFD_DEVICE_STATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x80)
#define MRVL_WFD_INTENT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x81)
#define MRVL_WFD_CAPABILITY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x82)
#define MRVL_WFD_NOA_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x83)
#define MRVL_WFD_OPP_PS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x84)
#define MRVL_WFD_INVITATION_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x85)
#define MRVL_WFD_LISTEN_CHANNEL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x86)
#define MRVL_WFD_OPERATING_CHANNEL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x87)
#define MRVL_WFD_PERSISTENT_GROUP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x88)
#define MRVL_CHANNEL_TRPC_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x89)
#define MRVL_IEEE_ACTION_FRAME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8c)
#define MRVL_WIFI_DIRECT_PRESENCE_REQ_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8d)
#define MRVL_WIFI_DIRECT_EXTENDED_LISTEN_TIME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8e)
#define MRVL_WIFI_DIRECT_PROVISIONING_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8f)
#define MRVL_WIFI_DIRECT_WPS_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x90)
#define MRVL_WIFI_DIRECT_ACTION_FRAME_SEND_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb3)
#define MRVL_CIPHER_PWK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x91)
#define MRVL_CIPHER_GWK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x92)
#define MRVL_AP_BSS_STATUS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x93)
#define MRVL_TX_DATA_PAUSE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x94)
#define MRVL_STICKY_TIM_CONFIG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x96)
#define MRVL_STICKY_TIM_STA_MAC_ADDR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x97)
#define MRVL_2040_BSS_COEX_CONTROL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x98)
#define MRVL_KEYPARAMSET_V2_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x9c)
#define MRVL_RXBA_SYNC_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x99)
#define MRVL_PKT_COALESCE_RULE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x9a)
#define MRVL_NETWORK_LIST_CFG_TLV (PROPRIETARY_TLV_BASE_ID + 0X9b)
#define MRVL_MEF_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x9d)
#define MRVL_WFD_SCAN_CFG_TLV (PROPRIETARY_TLV_BASE_ID + 158)
#define MRVL_WFD_SENDTIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 159)
#define MRVL_WFD_GROUPID_TLV_ID (PROPRIETARY_TLV_BASE_ID + 160)
#define MRVL_WFD_DEVICE_ID_TLV_ID (PROPRIETARY_TLV_BASE_ID + 161)
#define MRVL_WFD_INTENDEDINTF_ADDR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 162)
#define MRVL_WFD_STATUS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 163)
#define MRVL_WFD_DEVICE_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 164)
#define MRVL_WFD_CFG_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 165)
#define MRVL_WFD_INVITATION_TLV_ID (PROPRIETARY_TLV_BASE_ID + 166)
#define MRVL_WFD_GROUP_BSSID_TLV_ID (PROPRIETARY_TLV_BASE_ID + 167)
#define MRVL_WFD_WPA_PSK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 168)
#define MRVL_MAX_MGMT_IE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 170)
#define MRVL_REGION_DOMAIN_CODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 171)
#define MRVL_AOIP_IBSS_MODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 172)
#define MRVL_AOIP_MANAGE_PEERS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 173)
#define MRVL_AOIP_STA_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 174)
#define MRVL_AOIP_REMOTE_ADDR_MODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 175)
#define MRVL_BGSCAN_REPEAT_CNT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb0)
#define MRVL_TLV_USB_AGGR_PARAM (PROPRIETARY_TLV_BASE_ID + 177)
#define MRVL_PS_PARAMS_IN_HS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb5)
#define MRVL_HS_WAKE_HOLDOFF_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb6)
#define MRVL_MULTI_CHAN_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb7)
#define MRVL_MULTI_CHAN_GROUP_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb8)
#define MRVL_RESTRICT_CLIENT_MODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xc1)
#define MRVL_WFD_SERVICE_HASH_TLV_ID (PROPRIETARY_TLV_BASE_ID + 195)
#define MRVL_WFD_SERVICES_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 196)
#define MRVL_API_VER_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 199)
#define MRVL_FLOOR_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xb9)
#define MRVL_SCAN_CHAN_GAP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xC5)
#define MRVL_CHAN_STATS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xC6)
/* This struct is used in ROM and should not be changed at all */
typedef MLAN_PACK_START struct {
UINT16 Type;
UINT16 Length;
} MLAN_PACK_END MrvlIEParamSet_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 Value[1];
} MLAN_PACK_END MrvlIEGeneric_t;
/* MultiChannel TLV*/
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 Status; // 1 = Active, 0 = Inactive
UINT8 TlvBuffer[1];
} MLAN_PACK_END MrvlIEMultiChanInfo_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 ChanGroupId;
UINT8 ChanBufWt;
ChanBandInfo_t ChanBandInfo;
UINT32 ChanTime;
UINT32 Reserved;
UINT8 HidPortNum;
UINT8 NumIntf;
UINT8 BssTypeNumList[1];
} MLAN_PACK_END MrvlIEMultiChanGroupInfo_t;
/* Key Material TLV */
typedef MLAN_PACK_START struct MrvlIEKeyParamSet_t {
MrvlIEParamSet_t hdr;
UINT16 keyMgtId;
} MLAN_PACK_END MrvlIEKeyParamSet_t;
#ifdef KEY_MATERIAL_V2
typedef MLAN_PACK_START struct wep_key_t {
UINT16 len;
UINT8 key[1];
} MLAN_PACK_END wep_key_t;
typedef MLAN_PACK_START struct wpax_key_t {
UINT8 pn[8];
UINT16 len;
UINT8 key[1];
} MLAN_PACK_END wpax_key_t;
typedef MLAN_PACK_START struct wapi_key_t {
UINT8 pn[16];
UINT16 len;
UINT8 key[16];
UINT8 micKey[16];
} MLAN_PACK_END wapi_key_t;
typedef MLAN_PACK_START struct MrvlIEKeyParamSet_v2_t {
MrvlIEParamSet_t hdr;
IEEEtypes_MacAddr_t macAddr;
UINT8 keyIdx;
UINT8 keyType;
UINT16 keyInfo;
MLAN_PACK_START union {
wep_key_t wep;
wpax_key_t wpax;
wapi_key_t wapi;
} MLAN_PACK_END keySet;
} MLAN_PACK_END MrvlIEKeyParamSet_v2_t;
#endif
/* Marvell Power Constraint TLV */
typedef MLAN_PACK_START struct MrvlIEPowerConstraint_t {
MrvlIEParamSet_t IEParam;
UINT8 channel;
UINT8 dBm;
} MLAN_PACK_END MrvlIEPowerConstraint_t;
/* Marvell WSC Selected Registar TLV */
typedef MLAN_PACK_START struct MrvlIEWSCSelectedRegistrar_t {
MrvlIEParamSet_t IEParam;
UINT16 devPwdID;
} MLAN_PACK_END MrvlIEWSCSelectedRegistrar_t;
/* Marvell WSC Enrollee TMO TLV */
typedef MLAN_PACK_START struct MrvlIEWSCEnrolleeTmo_t {
MrvlIEParamSet_t IEParam;
UINT16 tmo;
} MLAN_PACK_END MrvlIEWSCEnrolleeTmo_t;
/****************
* AES CRYPTION FEATURE
*
* DEFINE STARTS --------------
*/
typedef MLAN_PACK_START struct MrvlIEAesCrypt_t {
MrvlIEParamSet_t hdr;
UINT8 payload[40];
} MLAN_PACK_END MrvlIEAesCrypt_t;
/* DEFINE ENDS ----------------
*/
/* Marvell Power Capability TLV */
typedef MLAN_PACK_START struct MrvlIEPowerCapability_t {
MrvlIEParamSet_t IEParam;
UINT8 minPwr;
UINT8 maxPwr;
} MLAN_PACK_END MrvlIEPowerCapability_t;
/* Marvell TLV for OMNI Serial Number and Hw Revision Information. */
typedef MLAN_PACK_START struct MrvlIE_OMNI_t {
MrvlIEParamSet_t IEParam;
UINT8 SerialNumber[16];
UINT8 HWRev;
UINT8 Reserved[3];
} MLAN_PACK_END MrvlIE_OMNI_t;
/* Marvell LED Behavior TLV */
typedef MLAN_PACK_START struct MrvlIELedBehavior_t {
MrvlIEParamSet_t IEParam;
UINT8 FirmwareState;
UINT8 LedNumber;
UINT8 LedState;
UINT8 LedArgs;
} MLAN_PACK_END MrvlIELedBehavior_t;
/* Marvell LED GPIO Mapping TLV */
typedef MLAN_PACK_START struct MrvlIELedGpio_t {
MrvlIEParamSet_t IEParam;
UINT8 LEDNumber;
UINT8 GPIONumber;
} MLAN_PACK_END MrvlIELedGpio_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
/*
** Set a place holder for the TSF values. Sized to max BSS for message
** allocation. The TLV will return a variable number of TSF values.
*/
UINT64 TSFValue[IEEEtypes_MAX_BSS_DESCRIPTS];
} MLAN_PACK_END MrvlIETsfArray_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 maxLen;
IEEEtypes_SsId_t ssid;
} MLAN_PACK_END MrvlIEWildcardSsid_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 snrThreshold;
UINT8 reportFrequency;
} MLAN_PACK_END MrvlIELowSnrThreshold_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 rssiThreshold;
UINT8 reportFrequency;
} MLAN_PACK_END MrvlIELowRssiThreshold_t;
/* Marvell AutoTx TLV */
#define MAX_KEEPALIVE_PKT_LEN (0x60)
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 Interval; /* in seconds */
UINT8 Priority;
UINT8 Reserved;
UINT16 EtherFrmLen;
UINT8 DestAddr[6];
UINT8 SrcAddr[6];
UINT8 EtherFrmBody[MAX_KEEPALIVE_PKT_LEN]; //Last 4 bytes are 32bit FCS
} MLAN_PACK_END MrvlIEAutoTx_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
IEEEtypes_DFS_Map_t map;
} MLAN_PACK_END MrvlIEChanRpt11hBasic_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 scanReqId;
} MLAN_PACK_END MrvlIEChanRptBeacon_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 ccaBusyFraction;
} MLAN_PACK_END MrvlIEChanRptChanLoad_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
SINT16 anpi;
UINT8 rpiDensities[11];
} MLAN_PACK_END MrvlIEChanRptNoiseHist_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
IEEEtypes_MacAddr_t sourceAddr;
IEEEtypes_MacAddr_t bssid;
SINT16 rssi;
UINT16 frameCnt;
} MLAN_PACK_END MrvlIEChanRptFrame_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
SINT16 rssi;
SINT16 anpi;
UINT8 ccaBusyFraction;
#ifdef SCAN_REPORT_THROUGH_EVENT
BandConfig_t band;
UINT8 channel;
UINT8 reserved;
UINT64 tsf;
#endif
} MLAN_PACK_END MrvlIEBssScanStats_t;
typedef MLAN_PACK_START struct {
/** Header */
MrvlIEParamSet_t IEParam;
UINT32 mode;
UINT32 maxOff;
UINT32 maxOn;
} MLAN_PACK_END MrvlIETypes_MeasurementTiming_t;
typedef MLAN_PACK_START struct {
/** Header */
MrvlIEParamSet_t IEParam;
UINT32 mode;
UINT32 dwell;
UINT32 maxOff;
UINT32 minLink;
UINT32 rspTimeout;
} MLAN_PACK_END MrvlIETypes_ConfigScanTiming_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 KeyIndex;
UINT8 IsDefaultIndex;
UINT8 Value[1];
} MLAN_PACK_END MrvlIETypes_WepKey_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 PMK[32];
} MLAN_PACK_END MrvlIETypes_PMK_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 ssid[1];
} MLAN_PACK_END MrvlIETypes_Ssid_Param_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 Passphrase[64];
} MLAN_PACK_END MrvlIETypes_Passphrase_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 BSSID[6];
} MLAN_PACK_END MrvlIETypes_BSSID_t;
typedef MLAN_PACK_START struct {
UINT16 Type;
UINT16 Length;
IEEEtypes_MacAddr_t Bssid;
UINT16 Rsvd;
SINT16 Rssi; //Signal strength
UINT16 Age;
UINT32 QualifiedNeighborBitmap;
UINT32 BlackListDuration;
} MLAN_PACK_END MrvlIETypes_NeighbourEntry_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 SearchMode;
UINT16 State;
UINT32 ScanPeriod;
} MLAN_PACK_END MrvlIETypes_NeighbourScanPeriod_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 Rssi;
UINT8 Frequency;
} MLAN_PACK_END MrvlIETypes_BeaconHighRssiThreshold_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 Rssi;
UINT8 Frequency;
} MLAN_PACK_END MrvlIETypes_BeaconLowRssiThreshold_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 Value;
UINT8 Frequency;
} MLAN_PACK_END MrvlIETypes_RoamingAgent_Threshold_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 AssocReason;
} MLAN_PACK_END MrvlIETypes_AssocReason_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
IEEEtypes_MacAddr_t macAddr;
UINT8 txPauseState;
UINT8 totalQueued;
} MLAN_PACK_END MrvlIETypes_TxDataPause_t;
typedef MLAN_PACK_START struct {
UINT16 startFreq;
UINT8 chanWidth;
UINT8 chanNum;
} MLAN_PACK_END MrvlIEChannelDesc_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
MrvlIEChannelDesc_t chanDesc;
UINT16 controlFlags;
UINT16 reserved;
UINT8 activePower;
UINT8 mdMinPower;
UINT8 mdMaxPower;
UINT8 mdPower;
} MLAN_PACK_END MrvlIETypes_OpChanControlDesc_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT32 chanGroupBitmap;
ChanScanMode_t scanMode;
UINT8 numChan;
MrvlIEChannelDesc_t chanDesc[50];
} MLAN_PACK_END MrvlIETypes_ChanGroupControl_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
ChanBandInfo_t ChanBandInfo[IEEEtypes_MAX_BSS_DESCRIPTS];
} MLAN_PACK_END MrvlIEChanBandList_t;
#if 0
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
IEEEtypes_MacAddr_t srcAddr;
IEEEtypes_MacAddr_t dstAddr;
IEEEtypes_ActionFrame_t actionFrame;
} MLAN_PACK_END MrvlIEActionFrame_t;
#endif
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
HtEntry_t htEntry[IEEEtypes_MAX_BSS_DESCRIPTS];
} MLAN_PACK_END MrvlIEHtList_t;
/* This struct is used in ROM code and all the fields of
** this should be kept intact
*/
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 bmpRateOfHRDSSS;
UINT16 bmpRateOfOFDM;
UINT32 bmpRateOfHT_DW0;
UINT32 bmpRateOfHT_DW1;
UINT32 bmpRateOfHT_DW2;
UINT32 bmpRateOfHT_DW3;
#ifdef DOT11AC
UINT16 bmpRateOfVHT[8]; //per SS
#endif
} MLAN_PACK_END MrvlIE_TxRateScope_t;
typedef MLAN_PACK_START struct {
UINT8 mod_class;
UINT8 rate;
UINT8 attemptLimit;
UINT8 reserved;
} MLAN_PACK_END MrvlIE_RateInfoEntry_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
MrvlIE_RateInfoEntry_t rate_info[8];
} MLAN_PACK_END MrvlIE_RateDropTable_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT32 mode;
// for 1x1 11n, 9 HT rate, 8 OFDM rate, 4 DSSS rate
MrvlIE_RateDropTable_t rateDropTbls[9 + 8 + 4];
} MLAN_PACK_END MrvlIE_RateDropPattern_t;
#ifdef USB_FRAME_AGGR
#define USB_TX_AGGR_ENABLE ( 1 << 1 )
#define USB_RX_AGGR_ENABLE ( 1 << 0 )
#define USB_RX_AGGR_MODE_MASK ( 1 << 0 )
#define USB_RX_AGGR_MODE_SIZE (1)
#define USB_RX_AGGR_MODE_NUM (0)
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 enable;
UINT16 rx_mode;
UINT16 rx_align;
UINT16 rx_max;
UINT16 rx_timeout;
UINT16 tx_mode;
UINT16 tx_align;
} MLAN_PACK_END MrvlIE_USBAggrTLV_t;
extern MrvlIE_USBAggrTLV_t g_Aggr_Conf;
#endif
typedef MLAN_PACK_START struct {
UINT8 mod_class;
UINT8 firstRateCode;
UINT8 lastRateCode;
SINT8 power_step;
SINT8 min_power;
SINT8 max_power;
UINT8 ht_bandwidth;
UINT8 reserved[1];
} MLAN_PACK_END MrvlIE_PowerGroupEntry_t;
#define MRVL_MAX_PWR_GROUP 15
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
MrvlIE_PowerGroupEntry_t PowerGroup[MRVL_MAX_PWR_GROUP];
} MLAN_PACK_END MrvlIE_PowerGroup_t;
#ifdef AP_STA_PS
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 NullPktInterval;
UINT16 numDtims;
UINT16 BCNMissTimeOut;
UINT16 LocalListenInterval;
UINT16 AdhocAwakePeriod;
UINT16 PS_mode;
UINT16 DelayToPS;
} MrvlIETypes_StaSleepParams_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 idleTime;
} MrvlIETypes_AutoDeepSleepParams_t;
#endif
#ifdef MESH
typedef MLAN_PACK_START struct _MrvlMeshIE_Tlv_t {
MrvlIEParamSet_t hdr;
IEEEtypes_VendorSpecific_MeshIE_t meshIE;
} MLAN_PACK_END MrvlMeshIE_Tlv_t;
#endif
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 RBCMode;
UINT8 Reserved[3];
} MLAN_PACK_END MrvlIERobustCoex_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 Mode;
UINT16 Reserved;
UINT32 BTTime;
UINT32 Period;
} MLAN_PACK_END MrvlIERobustCoexPeriod_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT8 staMacAddr[IEEEtypes_ADDRESS_SIZE];
IEEEtypes_IE_Param_t IeBuf;
} MLAN_PACK_END MrvlIEHostWakeStaDBCfg;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 ouiCmpLen;
UINT8 ouiBuf[6];
} MLAN_PACK_END MrvlIEHostWakeOuiCfg;
#ifdef MICRO_AP_MODE
/* This struct is used in ROM and should not be changed at all */
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t hdr;
IEEEtypes_MacAddr_t macAddr;
UINT8 pwrMode;
SINT8 rssi;
} MLAN_PACK_END MrvlIEStaInfo_t;
#endif
typedef struct {
MrvlIEParamSet_t Hdr;
uint16 protocol;
uint8 cipher;
uint8 reserved;
} MrvlIETypes_PwkCipher_t;
typedef struct {
MrvlIEParamSet_t Hdr;
uint8 cipher;
uint8 reserved;
} MrvlIETypes_GwkCipher_t;
typedef MLAN_PACK_START struct {
uint8 modGroup;
uint8 txPower;
} MLAN_PACK_END MrvlIE_ChanTrpcEntry_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t Hdr;
MrvlIEChannelDesc_t chanDesc;
MrvlIE_ChanTrpcEntry_t data[1];
} MLAN_PACK_END MrvlIETypes_ChanTrpcCfg_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
IEEEtypes_MacAddr_t mac[IEEEtypes_MAX_BSS_DESCRIPTS];
} MLAN_PACK_END MrvlIETypes_MacAddr_t;
#ifdef AP_BTCOEX
typedef enum _tagScoCoexBtTraffic {
ONLY_SCO,
ACL_BEFORE_SCO,
ACL_AFTER_SCO,
BT_TRAFFIC_RESERVED,
BT_TRAFFIC_MAX
} ScoCoexBtTraffic_e;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT32 configBitmap; /* Bit 0 : overrideCts2SelfProtection
** Bit 1-31 : Reserved
*/
UINT32 apStaBtCoexEnabled;
UINT32 reserved[3]; /* For future use. */
} MLAN_PACK_END MrvlIETypes_ApBTCoexCommonConfig_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 protectionFrmQTime[BT_TRAFFIC_MAX]; /* Index 0 for ONLY_SCO
** 1 for ACL_BEFORE_SCO
** 2 for ACL_AFTER_SCO
** 3 is Reserved
*/
UINT16 protectionFrmRate;
UINT16 aclFrequency;
UINT32 reserved[4]; /* For future use. */
} MLAN_PACK_END MrvlIETypes_ApBTCoexScoConfig_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT16 enabled;
UINT16 btTime;
UINT16 wlanTime;
UINT16 protectionFrmRate;
UINT32 reserved[4]; /* For future use. */
} MLAN_PACK_END MrvlIETypes_ApBTCoexAclConfig_t;
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t IEParam;
UINT32 nullNotSent;
UINT32 numOfNullQueued;
UINT32 nullNotQueued;
UINT32 numOfCfEndQueued;
UINT32 cfEndNotQueued;
UINT32 nullAllocationFail;
UINT32 cfEndAllocationFail;
UINT32 reserved[8]; /* For future use. */
} MLAN_PACK_END MrvlIETypes_ApBTCoexStats_t;
#endif //AP_BTCOEX
typedef MLAN_PACK_START struct {
MrvlIEParamSet_t Hdr;
IEEEtypes_MacAddr_t macAddr;
UINT8 tid;
UINT8 reserved;
UINT16 startSeqNum;
UINT16 bitMapLen;
UINT8 bitMap[1];
} MLAN_PACK_END MrvlIETypes_RxBaSync_t;
#ifdef SCAN_CHAN_STATISTICS
typedef MLAN_PACK_START struct MrvlIEChannelStats {
MrvlIEParamSet_t IEParam;
UINT8 chanStat[1];
} MLAN_PACK_END MrvlIEChannelStats_t;
#endif
/* API Version Info Entry for MRVL_API_VER_INFO_TLV_ID */
typedef MLAN_PACK_START struct MrvlIE_ApiVersionEntry_t {
UINT16 apiId;
UINT8 major;
UINT8 minor;
} MLAN_PACK_END MrvlIE_ApiVersionEntry_t;
/** API Version Ids */
#define KEY_API_VER_ID 0x1
#endif //_TLV_H_

View File

@@ -0,0 +1,136 @@
/** @file wl_macros.h
*
* @brief Common macros are defined here. Must include "wltypes.h" before this file
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#if !defined(WL_MACROS_H__)
#define WL_MACROS_H__
#define MACRO_START do {
#define MACRO_END } while (0)
#define WL_REGS8(x) (*(volatile unsigned char *)(x))
#define WL_REGS16(x) (*(volatile unsigned short *)(x))
#define WL_REGS32(x) (*(volatile unsigned int *)(x))
#define WL_READ_REGS8(reg,val) ((val) = WL_REGS8(reg))
#define WL_READ_REGS16(reg,val) ((val) = WL_REGS16(reg))
#define WL_READ_REGS32(reg,val) ((val) = WL_REGS32(reg))
#define WL_READ_BYTE(reg,val) ((val) = WL_REGS8(reg))
#define WL_READ_HWORD(reg,val) ((val) = WL_REGS16(reg)) /*half word; */
/*16bits */
#define WL_READ_WORD(reg,val) ((val) = WL_REGS32(reg)) /*32 bits */
#define WL_WRITE_REGS8(reg,val) (WL_REGS8(reg) = (val))
#define WL_WRITE_REGS16(reg,val) (WL_REGS16(reg) = (val))
#define WL_WRITE_REGS32(reg,val) (WL_REGS32(reg) = (val))
#define WL_WRITE_BYTE(reg,val) (WL_REGS8(reg) = (val))
#define WL_WRITE_HWORD(reg,val) (WL_REGS16(reg) = (val)) /*half word; */
/*16bits */
#define WL_WRITE_WORD(reg,val) (WL_REGS32(reg) = (val)) /*32 bits */
#define WL_REGS8_SETBITS(reg, val) (WL_REGS8(reg) |= (UINT8)(val))
#define WL_REGS16_SETBITS(reg, val) (WL_REGS16(reg) |= (UINT16)(val))
#define WL_REGS32_SETBITS(reg, val) (WL_REGS32(reg) |= (val))
#define WL_REGS8_CLRBITS(reg, val) (WL_REGS8(reg) = \
(UINT8)(WL_REGS8(reg)&~(val)))
#define WL_REGS16_CLRBITS(reg, val) (WL_REGS16(reg) = \
(UINT16)(WL_REGS16(reg)&~(val)))
#define WL_REGS32_CLRBITS(reg, val) (WL_REGS32(reg) = \
(WL_REGS32(reg)&~(val)))
#define WL_WRITE_CHUNK(dst, src, length) (memcpy((void*) (dst), \
(void*) (src), (length)))
/*!
* Bitmask macros
*/
#define WL_BITMASK(nbits) ((0x1 << nbits) - 1)
/*!
* Macro to put the WLAN SoC into sleep mode
*/
#define WL_GO_TO_SLEEP asm volatile ("MCR p15, 0, r3, c7, c0, 4;")
/*!
* BE vs. LE macros
*/
#ifdef BE /* Big Endian */
#define SHORT_SWAP(X) (X)
#define WORD_SWAP(X) (X)
#define LONG_SWAP(X) ((l64)(X))
#else /* Little Endian */
#define SHORT_SWAP(X) ((X <<8 ) | (X >> 8)) //!< swap bytes in a 16 bit short
#define WORD_SWAP(X) (((X)&0xff)<<24)+ \
(((X)&0xff00)<<8)+ \
(((X)&0xff0000)>>8)+ \
(((X)&0xff000000)>>24) //!< swap bytes in a 32 bit word
#define LONG_SWAP(X) ( (l64) (((X)&0xffULL)<<56)+ \
(((X)&0xff00ULL)<<40)+ \
(((X)&0xff0000ULL)<<24)+ \
(((X)&0xff000000ULL)<<8)+ \
(((X)&0xff00000000ULL)>>8)+ \
(((X)&0xff0000000000ULL)>>24)+ \
(((X)&0xff000000000000ULL)>>40)+ \
(((X)&0xff00000000000000ULL)>>56)) //!< swap bytes in a 64 bit long
#endif
/*!
* Alignment macros
*/
#define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN4BYTE(x) (x=ALIGN4(x))
#define ROUNDUP4US(x) (ALIGN4(x))
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef NELEMENTS
#define NELEMENTS(x) (sizeof(x)/sizeof(x[0]))
#endif
#define HWORD_LOW_BYTE(x) ((x) & 0xFF)
#define HWORD_HIGH_BYTE(x) (((x) >> 8) & 0xFF)
#define htons(x) (UINT16)SHORT_SWAP(x)
#define htonl(x) (UINT32)WORD_SWAP(x)
#define ntohs(x) (UINT16)SHORT_SWAP(x)
#define ntohl(x) (UINT32)WORD_SWAP(x)
#define CEIL_aByb(a, b) ((a + b - 1) / b)
#endif /* _WL_MACROS_H_ */

View File

@@ -0,0 +1,586 @@
/** @file wl_mib.h
*
* @brief This file contains the MIB structure definitions based on IEEE 802.11 specification.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#if !defined(WL_MIB_H__)
#define WL_MIB_H__
#include "wl_mib_rom.h"
/*============================================================================= */
/* Management Information Base STRUCTURES (IEEE 802.11) */
/*============================================================================= */
/*-----------------------------*/
/* Station Configuration Table */
/*-----------------------------*/
typedef struct MIB_StaCfg_s
{
UINT8 CfPeriod; /* 0 to 255 */
UINT16 CfpMax; /* 0 to 65535 */
UINT8 PwrMgtMode; /* PwrMgmtMode_e values */
UINT8 OpRateSet[16]; /* 16 byte array is sufficient for
14 rate */
#ifdef DOT11H
Boolean dot11SpectrumManagementRequired;
#endif
Boolean dot11WWSenabled;
} MIB_STA_CFG;
/*------------------------*/
/* WEP Key Mappings Table */
/*------------------------*/
/* This struct is used in ROM and it should not be changed at all */
typedef struct MIB_WepKeyMappings_s {
UINT32 WepKeyMappingIdx;
IEEEtypes_MacAddr_t WepKeyMappingAddr;
UINT8 WepKeyMappingWepOn; /* SNMP_Boolean_e values */
UINT8 WepKeyMappingVal[WEP_KEY_USER_INPUT]; /* 5 byte string */
UINT8 WepKeyMappingStatus; /* SNMP_Rowstatus_e values */
} MIB_WEP_KEY_MAPPINGS;
/*---------------*/
/* Privacy Table */
/*---------------*/
typedef struct MIB_PrivacyTable_s {
UINT8 PrivInvoked; /* SNMP_Boolean_e values */
UINT8 WepDefaultKeyId; /* 0 to 3 */
UINT32 WepKeyMappingLen; /* 10 to 4294967295 */
UINT8 ExcludeUnencrypt; /* SNMP_Boolean_e values */
UINT32 WepIcvErrCnt;
UINT32 WepExcludedCnt;
UINT8 RSNEnabled; /* SNMP_Boolean_e values */
} MIB_PRIVACY_TABLE;
/*============================================================================= */
/* MAC ATTRIBUTES */
/*============================================================================= */
/*---------------------*/
/* MAC Operation Table */
/*---------------------*/
typedef struct MIB_OpData_s
{
IEEEtypes_MacAddr_t StaMacAddr;
UINT16 RtsThresh; /* 0 to 2347 */
UINT8 ShortRetryLim; /* 1 to 255 */
UINT8 LongRetryLim; /* 1 to 255 */
UINT16 FragThresh; /* 256 to 2346 */
UINT32 MaxTxMsduLife; /* 1 to 4294967295 */
UINT32 MaxRxLife; /* 1 to 4294967295 */
#ifdef IN_USE
UINT8 ManufId[128]; /* 128 byte string */
UINT8 ProdId[128]; /* 128 byte string */
#endif
} MIB_OP_DATA;
/*----------------*/
/* Counters Table */
/*----------------*/
typedef struct MIB_Counters_s {
UINT32 RxFrmCnt;
UINT32 MulticastTxFrmCnt;
UINT32 FailedCnt;
UINT32 RetryCnt;
UINT32 MultRetryCnt;
UINT32 FrmDupCnt;
UINT32 RtsSuccessCnt;
UINT32 RtsFailCnt;
UINT32 AckFailCnt;
UINT32 RxFragCnt;
UINT32 MulticastRxFrmCnt;
UINT32 FcsErrCnt;
UINT32 TxFrmCnt;
UINT32 WepUndecryptCnt;
} MIB_COUNTERS;
/*-----------------------*/
/* Group Addresses Table */
/*-----------------------*/
typedef struct MIB_GroupAddr_s {
UINT32 GroupAddrIdx;
IEEEtypes_MacAddr_t Addr;
UINT8 GroupAddrStatus; /* SNMP_Rowstatus_e values */
} MIB_GROUP_ADDR;
/*----------------------------*/
/* Resource Information Table */
/*----------------------------*/
typedef struct MIB_RsrcInfo_s {
UINT8 ManufOui[3]; /* 3 byte string */
UINT8 ManufName[128]; /* 128 byte string */
UINT8 ManufProdName[128]; /* 128 byte string */
UINT8 ManufProdVer[128]; /* 128 byte string */
} MIB_RESOURCE_INFO;
/*============================================================================= */
/* PHY ATTRIBUTES */
/*============================================================================= */
/*---------------------*/
/* PHY Operation Table */
/*---------------------*/
typedef struct MIB_PhyOpTable_s {
UINT8 PhyType; /* SNMP_PhyType_e values */
UINT32 CurrRegDomain;
UINT8 TempType; /* SNMP_TempType_e values */
} MIB_PHY_OP_TABLE;
/*-------------------*/
/* PHY Antenna Table */
/*-------------------*/
typedef struct MIB_PhyAntTable_s {
UINT8 CurrTxAnt; /* 1 to 255 */
UINT8 DivSupport; /* SNMP_DivSupp_e values */
UINT8 CurrRxAnt; /* 1 to 255 */
} MIB_PHY_ANT_TABLE;
typedef struct MIB_PhyAntSelect_s {
UINT8 SelectRxAnt; /* 0 to 1 */
UINT8 SelectTxAnt; /* 0 to 1 */
UINT8 DiversityRxAnt; /* Boolean */
UINT8 DiversityTxAnt; /* Boolean */
} MIB_PHY_ANT_SELECT;
/*--------------------------*/
/* PHY Transmit Power Table */
/*--------------------------*/
typedef struct MIB_PhyTxPwrTable_s {
UINT8 NumSuppPwrLevels; /* 1 to 8 */
UINT16 TxPwrLevel1; /* 0 to 10000 */
UINT16 TxPwrLevel2; /* 0 to 10000 */
UINT16 TxPwrLevel3; /* 0 to 10000 */
UINT16 TxPwrLevel4; /* 0 to 10000 */
UINT16 TxPwrLevel5; /* 0 to 10000 */
UINT16 TxPwrLevel6; /* 0 to 10000 */
UINT16 TxPwrLevel7; /* 0 to 10000 */
UINT16 TxPwrLevel8; /* 0 to 10000 */
UINT8 CurrTxPwrLevel; /* 1 to 8 */
} MIB_PHY_TX_POWER_TABLE;
/*---------------------------------------------*/
/* PHY Frequency Hopping Spread Spectrum Table */
/*---------------------------------------------*/
typedef struct MIB_PhyFHSSTable_s {
UINT8 HopTime; /* 224? */
UINT8 CurrChanNum; /* 0 to 99 */
UINT16 MaxDwellTime; /* 0 to 65535 */
UINT16 CurrDwellTime; /* 0 to 65535 */
UINT16 CurrSet; /* 0 to 255 */
UINT16 CurrPattern; /* 0 to 255 */
UINT16 CurrIdx; /* 0 to 255 */
} MIB_PHY_FHSS_TABLE;
/*-------------------------------------------*/
/* PHY Direct Sequence Spread Spectrum Table */
/*-------------------------------------------*/
typedef enum MIB_CCAMode_s {
ENERGY_DETECT_ONLY = 1,
CARRIER_SENSE_ONLY = 2,
CARRIER_SENSE_AND_ENERGY_DETECT = 4
} MIB_CCA_MODE;
typedef struct MIB_PhyDSSSTable_s {
UINT8 CurrChan; /* 0 to 14 */
UINT8 CcaModeSupp; /* 1 to 7 */
UINT16 CurrCcaMode; /* MIB_CCA_MODE values only */
UINT32 EdThresh;
} MIB_PHY_DSSS_TABLE;
/*--------------*/
/* PHY IR Table */
/*--------------*/
typedef struct MIB_PhyIRTable_s {
UINT32 CcaWatchDogTmrMax;
UINT32 CcaWatchDogCntMax;
UINT32 CcaWatchDogTmrMin;
UINT32 CcaWatchDogCntMin;
} MIB_PHY_IR_TABLE;
/*----------------------------------------*/
/* PHY Regulatory Domains Supported Table */
/*----------------------------------------*/
typedef struct MIB_PhyRegDomainsSupp_s {
UINT32 RegDomainsSuppIdx;
UINT8 RegDomainsSuppVal; /*SNMP_RegDomainsSuppVal_e values */
} MIB_PHY_REG_DOMAINS_SUPPPORTED;
/*-------------------------*/
/* PHY Antennas List Table */
/*-------------------------*/
typedef struct MIB_PhyAntList_s {
UINT8 AntListIdx;
UINT8 SuppTxAnt; /*SNMP_Boolean_e values */
UINT8 SuppRxAnt; /*SNMP_Boolean_e values */
UINT8 RxDiv; /*SNMP_Boolean_e values */
} MIB_PHY_ANT_LIST;
/*----------------------------------------*/
/* PHY Supported Receive Data Rates Table */
/*----------------------------------------*/
typedef struct MIB_PhySuppDataRatesRx_s {
UINT8 SuppDataRatesRxIdx; /*1 to 8 */
UINT8 SuppDataRatesRxVal; /*2 to 127 */
} MIB_PHY_SUPP_DATA_RATES_RX;
typedef struct MIB_DHCP_s {
UINT32 IPAddr;
UINT32 SubnetMask;
UINT32 GwyAddr;
#ifdef GATEWAY
UINT32 PrimaryDNS;
UINT32 SecondaryDNS;
#endif
} MIB_DHCP;
#if defined(GATEWAY)
typedef struct MIB_IP_LAN_s {
UINT32 IPAddr;
UINT32 SubnetMask;
} MIB_IP_LAN;
#endif
/* Added for WB31 */
typedef struct _MIB_WB {
UINT8 devName[16]; // Must be a string:
// 15 Max characters
UINT8 cloneMacAddr[6]; // cloned MAC Address
UINT8 opMode; // 0 for infrastructure,
// 1 for ad-hoc
UINT8 macCloneEnable; // boolean
} MIB_WB;
/* Added for WB31 end */
/*---------------------*/
/* RSN Config Table */
/*---------------------*/
typedef struct MIB_RSNConfig_s {
UINT32 Index;
UINT32 Version;
UINT32 PairwiseKeysSupported;
UINT8 MulticastCipher[4];
UINT8 GroupRekeyMethod;
UINT32 GroupRekeyTime;
UINT32 GroupRekeyPackets;
UINT8 GroupRekeyStrict;
UINT8 PSKValue[40];
UINT8 PSKPassPhrase[64];
UINT8 TSNEnabled;
UINT32 GroupMasterRekeyTime;
UINT32 GroupUpdateTimeOut;
UINT32 GroupUpdateCount;
UINT32 PairwiseUpdateTimeOut;
UINT32 PairwiseUpdateCount;
} MIB_RSNCONFIG;
/*---------------------*/
/* RSN Unicast Cipher Suites Config Table */
/*---------------------*/
typedef struct MIB_RSNConfigUnicastCiphers_s {
UINT32 Index;
UINT8 UnicastCipher[4];
UINT8 Enabled;
} MIB_RSNCONFIG_UNICAST_CIPHERS;
/*---------------------*/
/* RSN Authentication Suites Config Table */
/*---------------------*/
typedef struct MIB_RSNConfigAuthSuites_s {
UINT32 Index;
UINT8 AuthSuites[4];
UINT8 Enabled;
} MIB_RSNCONFIG_AUTH_SUITES;
typedef struct Mrvl_MIB_RSN_GrpKey_s {
UINT8 GrpMasterKey[32];
UINT8 EncryptKey[16];
UINT32 TxMICKey[2];
UINT32 RxMICKey[2];
UINT32 g_IV32;
UINT16 g_IV16;
UINT16 g_Phase1Key[5];
UINT8 g_KeyIndex;
} MRVL_MIB_RSN_GRP_KEY;
#ifdef MIB_STATS
typedef struct Mrvl_MIB_StatsDetails {
/* WARNING: Do not change the order of variables in this structure */
UINT32 TKIPLocalMICFailures; /* OID: 0x0b -> 0 */
UINT32 CCMPDecryptErrors; /* OID: 0x0c -> 1 */
UINT32 WEPUndecryptableCount; /* OID: 0x0d -> 2 */
UINT32 WEPICVErrorCount; /* OID: 0x0e -> 3 */
UINT32 DecryptFailureCount; /* OID: 0x0f -> 4 */
UINT32 failed; /* OID: 0x12 -> 5 */
UINT32 retry; /* OID: 0x13 -> 6 */
UINT32 multiretry; /* OID: 0x14 -> 7 */
UINT32 framedup; /* OID: 0x15 -> 8 */
UINT32 rtssuccess; /* OID: 0x16 -> 9 */
UINT32 rtsfailure; /* OID: 0x17 -> 10 */
UINT32 ackfailure; /* OID: 0x18 -> 11 */
UINT32 rxfrag; /* OID: 0x19 -> 12 */
UINT32 mcastrxframe; /* OID: 0x1a -> 13 */
UINT32 fcserror; /* OID: 0x1b -> 14 */
UINT32 txframe; /* OID: 0x1c -> 15 */
UINT32 rsntkipcminvoked; /* OID: 0x1d -> 16 */
UINT32 rsn4wayhandshakefailure; /* OID: 0x1e -> 17 */
UINT32 mcasttxframe; /* OID: 0x1f -> 18 */
UINT32 TKIPICVErrors; /* Not in the OID list */
UINT32 TKIPReplays; /* Not in the OID list */
UINT32 CCMPReplays; /* Not in the OID list */
UINT32 CMACICVErrors; /* Not in the OID list */
UINT32 CMACReplays; /* Not in the OID list */
UINT32 WEPFragError; /* Not in the OID list */
UINT32 DecryptSuccessCount; /* Not in the OID list */
UINT32 wepicverrCnt[4]; /* Not in the OID list */
/* EAPoL Tx Stats */
UINT16 eapolSentTotalCnt;
UINT16 eapolSentFrmFwCnt;
UINT16 eapolSentSuccessCnt;
UINT16 eapolSentFailCnt;
/* EAPoL Rx Stats */
UINT16 eapolRxTotalCnt;
UINT16 eapolRxForESUPPCnt;
/* Key Stats */
UINT16 PTKRecvdTotalCnt;
UINT16 PTKSentFrmESUPPCnt;
UINT16 GTKRecvdTotalCnt;
UINT16 GTKSentFrmESUPPCnt;
} MRVL_MIB_STATSDETAILS;
#define NUM_OF_STATS_OIDS (19)
#define INC_MIB_STAT(x, a) if (x && x->pMibStats) { x->pMibStats->data.mib.a++; }
#define INC_MIB_STAT2(x, a, b) if (x && x->pMibStats) { x->pMibStats->data.mib.a++; x->pMibStats->data.mib.b++;}
#define INC_MIB_STAT3(x, a, b, c) if (x && x->pMibStats) { x->pMibStats->data.mib.a++; x->pMibStats->data.mib.b++; x->pMibStats->data.mib.c++;}
#define CLR_MIB_STAT(x, a) if (x && x->pMibStats) { x->pMibStats->data.mib.a = 0; }
typedef struct Mrvl_MIB_Stats {
union {
MRVL_MIB_STATSDETAILS mib;
UINT32 mib_stats[NUM_OF_STATS_OIDS];
} data;
} MRVL_MIB_STATS;
#endif
typedef struct MIB_BURST_MODE {
UINT8 mib_burstmode;
UINT32 mib_burstrate;
} MIB_BURST_MODE;
#ifdef BRIDGE_STP
typedef struct mib_dot1dPortEntry_s {
UINT8 mib_dot1dStpPortPriority; /* (0..255) */
UINT8 mib_dot1dStpPortEnable; /*1: enable; 2: disable */
UINT16 mib_dot1dStpPortPathCost; /* (1..65535) */
} mib_dot1dPortEntry_t;
typedef struct mib_dot1dStp_s {
UINT8 mib_dot1dStpPortPriority; /* (0..255) */
UINT8 mib_dot1dStpPortEnable; /*1: enable; 2: disable */
UINT16 mib_dot1dStpPortPathCost; /* (1..65535) */
UINT32 mib_dot1dTpAgingTime; /* (10..1000000) */
UINT16 mib_dot1dStpPriority;
UINT16 mib_dot1dStpBridgeMaxAge;
UINT16 mib_dot1dStpBridgeHelloTime;
UINT16 mib_dot1dStpBridgeForwardDelay;
} mib_dot1dStp_t;
typedef struct mib_priv_dot1dStp_s {
UINT8 mib_priv_dot1dStpEnable; /* 1 or 0 */
} mib_priv_dot1dStp_t;
#endif
typedef struct MIB_802DOT11_s {
/*-----------------------------------------*/
/* Station Management Attributes */
/*-----------------------------------------*/
MIB_STA_CFG StationConfig; /* station configuration table */
MIB_WEP_DEFAULT_KEYS WepDefaultKeys[4]; /* wep default keys table */
MIB_WEP_KEY_MAPPINGS WepKeyMappings; /* wep key mappings table */
MIB_PRIVACY_TABLE Privacy; /* privacy table */
/* SMT Notification Objects */
#ifdef AP_SW
MIB_DISASSOC_NOT NoteDisassoc; /* disassociate notification */
MIB_DEAUTH_NOT NoteDeauth; /* deauthentication notification */
MIB_AUTH_FAIL_NOT NoteAuthFail; /* authentication fail notification */
#endif
/*-----------------------------------------*/
/* MAC Attributes */
/*-----------------------------------------*/
MIB_OP_DATA OperationTable;
#ifdef WMM_IMPLEMENTED
MIB_EDCA_CONFIG EdcaConfigTable[WMM_MAX_TIDS];
#endif
#ifdef AP_SW
MIB_COUNTERS CountersTable;
MIB_GROUP_ADDR GroupAddrTable;
/*-----------------------------------------*/
/* Resource Type */
/*-----------------------------------------*/
MIB_RESOURCE_INFO ResourceInfo;
/*-----------------------------------------*/
/* PHY Attributes */
/*-----------------------------------------*/
MIB_PHY_OP_TABLE PhyOpTable;
MIB_PHY_TX_POWER_TABLE PhyPowerTable;
MIB_PHY_FHSS_TABLE PhyFHSSTable;
MIB_PHY_IR_TABLE PhyIRTable;
MIB_PHY_REG_DOMAINS_SUPPPORTED PhyRegDomainsSupp;
MIB_PHY_ANT_LIST AntennasListTable;
#endif
MIB_PHY_ANT_TABLE PhyAntTable;
MIB_PHY_DSSS_TABLE PhyDSSSTable;
MIB_PHY_SUPP_DATA_RATES_TX SuppDataRatesTx[IEEEtypes_MAX_DATA_RATES_G];
MIB_PHY_SUPP_DATA_RATES_RX SuppDataRatesRx;
#if defined(AP_SW)
MIB_RSNCONFIG RSNConfig;
#endif
//MIB_RSNCONFIG_UNICAST_CIPHERS UnicastCiphers;
//MIB_RSNCONFIG_AUTH_SUITES RSNConfigAuthSuites;
#ifdef AP_WPA2
MIB_RSNCONFIGWPA2 RSNConfigWPA2;
MIB_RSNCONFIGWPA2_UNICAST_CIPHERS WPA2UnicastCiphers;
MIB_RSNCONFIGWPA2_UNICAST_CIPHERS WPA2UnicastCiphers2;
MIB_RSNCONFIGWPA2_AUTH_SUITES WPA2AuthSuites;
#endif
#ifdef BURST_MODE
MIB_BURST_MODE BurstMode;
#endif
MIB_PHY_ANT_SELECT PhyAntSelect;
#ifdef WEP_RSN_STATS_MIB
MIB_RSNSTATS RSNStats;
#endif
} MIB_802DOT11;
extern BOOLEAN mib_InitSta(MIB_802DOT11 *mib);
extern BOOLEAN mib_InitAp(MIB_802DOT11 *mib);
#endif /* _WL_MIB_H_ */

View File

@@ -0,0 +1,60 @@
/** @file wl_mib_rom.h
*
* @brieThis file contains the MIB structure definitions
* based on IEEE 802.11 specification.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#if !defined(WL_MIB_ROM_H__)
#define WL_MIB_ROM_H__
#include "IEEE_types.h"
#define MIB_EDCA_MSDU_LIFETIME_DEFAULT 512
#define WEP_KEY_USER_INPUT 13 /** Also defined in keyApiStaTypes.h */
/*-----------------------------------------*/
/* PHY Supported Transmit Data Rates Table */
/*-----------------------------------------*/
typedef struct MIB_PhySuppDataRatesTx_s {
UINT8 SuppDataRatesTxIdx; /*1 to IEEEtypes_MAX_DATA_RATES_G */
UINT8 SuppDataRatesTxVal; /*2 to 127 */
} MIB_PHY_SUPP_DATA_RATES_TX;
/*------------------------*/
/* WEP Default Keys Table */
/*------------------------*/
/* This struct is used in ROM and it should not be changed at all */
typedef struct MIB_WepDefaultKeys_s {
UINT8 WepDefaultKeyIdx; /* 1 to 4 */
UINT8 WepDefaultKeyType; /* */
UINT8 WepDefaultKeyValue[WEP_KEY_USER_INPUT]; /* 5 byte string */
} MIB_WEP_DEFAULT_KEYS;
typedef struct {
/* Maximum lifetime of an MSDU from when it enters the MAC, 802.11e */
UINT16 MSDULifetime; /* 0 to 500, 500 default */
} MIB_EDCA_CONFIG;
#endif /* _WL_MIB_ROM_H_ */

View File

@@ -0,0 +1,161 @@
/** @file wlpd.h
*
* @brief RX and TX packet descriptor
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef WLPD_H__
#define WLPD_H__
/** include files **/
#include "packetType.h"
#include "wltypes.h"
/** @defgroup PacketTypes Tx Rx Data Packet Types
* Functions exported by wlpd.h
* @{
*/
/*****************************************************************************/
typedef MLAN_PACK_START struct {
UINT8 tdlsPkt:1;
UINT8 rsvd:7;
} MLAN_PACK_END rxFlags_t;
/**
*** @brief Enumeration of action to be take for returned Rx Packets.
**/
/**
*** @brief Receive Packet Descriptor
**/
typedef MLAN_PACK_START struct RxPD_t {
/* TODO: Port EMBEDDED_TCPIP and VISTA_802_11_DRIVER_INTERFACE
members to W8786 */
UINT8 RxBSSType;
UINT8 RxBSSNum;
UINT16 RxPacketLength; //!< Rx Packet Length
SINT16 RxPacketOffset; //!< Offset to the Rx Data
UINT16 RxPacketType;
UINT16 SeqNum;
UINT8 userPriority;
UINT8 RxRate; // LG 0-3 (11b), 5-12(11g), HT :MCS# (11n)
SINT8 SNR;
SINT8 RxSQ2; // defined to RxNF
UINT8 RxHTInfo; // [Bit o] RxRate format : Legacy = 0 , HT =1
//[Bit 1] HT Bandwidth :BW20 =0 , BW40 = 1
//[Bit 2] HT Guard Interval : LGI = 0, SGI = 1
#if defined(VISTA_802_11_DRIVER_INTERFACE) || defined(SNIFFER_MODE_ENABLE)
UINT8 PacketType;
UINT8 NumFragments;
UINT8 EncryptionStatus;
#else
UINT8 Reserved2[3];
#endif
rxFlags_t flags;
UINT8 Reserved3;
} MLAN_PACK_END RxPD_t;
#define PACKET_TYPE_802_3 0
#define PACKET_TYPE_802_11 1
#define PACKET_TYPE_802_11_QOS 2
#define PACKET_TYPE_802_11_MRVL_MESH 3
#define PACKET_TYPE_TDLS 4
#define MESH_FWD_PACKET_MASK (1 << 0)
#define MESH_OLPC_PKT_MASK (1 << 1)
#define PACKET_DECRYPTED 0
#define PACKET_NOT_DECRYPTED 1
#if defined(VISTA_802_11_DRIVER_INTERFACE)
#define PACKET_NO_DECRYPT_NEEDED 2
#define MAGIC_PACKET_MARKER_BITMASK (1<<3)
#define COALESCED_PACKET_MARKER_BITMASK (1<<2)
#endif
#define RxNF RxSQ2
// Since Small Debug print and Myung's Debug Facility both use
// PKT_TYPE_DEBUG rx pkt, the following debug header is required to distinguish
// Small Debug from Myung's.
//
typedef MLAN_PACK_START struct {
UINT8 dbg_type;
UINT8 reserve[3];
} MLAN_PACK_END to_host_dbg_hdr_t;
#define DBG_TYPE_SMALL 2
/* The following fields have been added for Null frame handling
in Power Save Mode.
*/
typedef MLAN_PACK_START struct {
UINT8 nullPkt:1;
UINT8 overRideFwPM:1;
UINT8 pmVal:1;
UINT8 lastTxPkt:1;
UINT8 tdlsPkt:1;
UINT8 rsvd:3;
} MLAN_PACK_END wcb_flags_t;
/**
*** @brief Transmit Packet Descriptor
**/
typedef MLAN_PACK_START struct {
/* TODO: Port EMBEDDED_TCPIP and VISTA_802_11_DRIVER_INTERFACE
members to W8786 */
UINT8 TxBSSType;
UINT8 TxBSSNum;
UINT16 TxPacketLength; //!< Tx Packet Length
UINT16 TxPacketOffset; //!< Offset to Tx Data
UINT16 TxPacketType; //!< Tx Packet Type
UINT32 TxControl; //b3-0: RateID; b4:HostRateCtrl;
//b11-8: RetryLimit; b12:HostRetryCtrl;
//b14-13: Ack Policy, 10 ACK_IMMD
// 11 NO_ACK 0x ACK_PER_FRM
UINT8 userPriority;
wcb_flags_t flags; // These BitFields are for Null Frame Handling and
// other Power Save requirements.
UINT8 PktDelay_2ms; /* Driver queue delay used in stats and MSDU
** lifetime expiry calcs; value is represented
** by 2ms units (ms bit shifted by 1)
*/
#ifdef VISTA_802_11_DRIVER_INTERFACE
/* Include Packet type for NWF */
UINT8 PacketType;
UINT8 EncrOpt;
#else
UINT8 Reserved[2];
#endif
UINT8 TxTokenId;
} MLAN_PACK_END wcb_t;
// Encryption Option is an 8 bit field
#define ENCR_OPT_NORMAL 0x00 // Normal packet. Follows Enc rules in FW
#define ENCR_OPT_FORCE_PTEXT 0x01 // Force plain text. No encryption.
#define ENCR_OPT_FW_KEY_MAP 0x02 // Encrypt using key mapping table in FW
#define ENCR_OPT_PTEXT_80211_PKT 0x03 // No encryption for 802.11 pkt
/*@}*/
#endif /* _WLPD_H_ */

View File

@@ -0,0 +1,574 @@
/** @file wltypes.h
*
* @brief Basic types common to all the modules must be defined in this file.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#if !defined(WLTYPES_H__)
#define WLTYPES_H__
/*
* Copyright 2003, Marvell Semiconductor, Inc.
* This code contains confidential information of Marvell Semiconductor, Inc.
* No rights are granted herein under any patent, mask work right or copyright
* of Marvell or any third party.
* Marvell reserves the right at its sole discretion to request that this code
* be immediately returned to Marvell. This code is provided "as is".
* Marvell makes no warranties, express, implied or otherwise, regarding its
* accuracy, completeness or performance.
*/
/*!
* \file wltypes.h
* \brief Basic types common to all the modules must be defined in this file.
*
*/
/** @defgroup DataTypes Data Types used in SDK
* Functions exported by wltypes.h
* @{
*/
/*! Create type names for native C types for portability reasons */
typedef unsigned long long UINT64; //!< 64 bit unsigned
typedef signed long long SINT64; //!< 64 bit signed
typedef unsigned int UINT32; //!< 32 bit unsigned
typedef signed int SINT32; //!< 32 bit signed
typedef unsigned short UINT16; //!< 16 bit unsigned
typedef signed short SINT16; //!< 16 bit signed
typedef unsigned char UINT8; //!< 8 bit unsigned
typedef signed char SINT8; //!< 8 bit signed
typedef unsigned long long uint64; //!< 64 bit unsigned
typedef signed long long sint64; //!< 64 bit signed
typedef unsigned int uint32; //!< 32 bit unsigned
typedef signed int sint32; //!< 32 bit signed
typedef unsigned short uint16; //!< 16 bit unsigned
typedef signed short sint16; //!< 16 bit signed
typedef unsigned char uint8; //!< 8 bit unsigned
typedef signed char sint8; //!< 8 bit signed
typedef signed char int8; //!< 8 bit signed
typedef int BOOLEAN; //!< boolean
typedef int Boolean; //!< boolean
typedef signed int BIT_FIELD; //!< bit field
typedef unsigned int UINT; //!< unsigned integer
//From dwc_os.h
#define size_t uint32
extern SINT8 SINT8_minus_SINT8(SINT8 x, SINT8 y);
extern SINT8 SINT8_plus_SINT8(SINT8 x, SINT8 y);
#ifdef __GNUC__
/** Structure packing begins */
#define MLAN_PACK_START
/** Structure packeing end */
#define MLAN_PACK_END __attribute__((packed))
#else /* !__GNUC__ */
#ifdef PRAGMA_PACK
/** Structure packing begins */
#define MLAN_PACK_START
/** Structure packeing end */
#define MLAN_PACK_END
#else /* !PRAGMA_PACK */
/** Structure packing begins */
#define MLAN_PACK_START __packed
/** Structure packing end */
#define MLAN_PACK_END
#endif /* PRAGMA_PACK */
#endif /* __GNUC__ */
#ifndef INLINE
#ifdef __GNUC__
/** inline directive */
#define INLINE inline
#else
/** inline directive */
#define INLINE __inline
#endif
#endif
typedef struct _REFCLK_VAL8_REG7F {
UINT8 refClk;
UINT8 val;
} REFCLK_VAL8_REG7F;
#define REG8_TERMINATOR (0xFF)
typedef struct _ADDR8_VAL8_REG {
UINT8 reg;
UINT8 val;
} ADDR8_VAL8_REG;
#define REG16_TERMINATOR (0xFFFF)
typedef struct _ADDR16_VAL8_REG {
UINT16 reg;
UINT8 val;
} ADDR16_VAL8_REG;
#define REG32_TERMINATOR (0xFFFFFFFF)
typedef struct _ADDR32_VAL32_REG {
UINT32 reg;
UINT32 val;
} ADDR32_VAL32_REG;
#if defined(BBP_9BIT_ADDR)
#define BBP_TERMINATOR REG16_TERMINATOR
#else
#define BBP_TERMINATOR REG8_TERMINATOR
#endif
/*! Generic status code */
#define WL_STATUS_OK 0 //!< ok
#define WL_STATUS_ERR -1 //!< error
#define WL_STATUS_BAD_PARAM -2 //!< bad parameter
/* Some BT files require access to wltypes.h file which result in duplicate definition of FALSE & TRUE
* undef TRUE and FALSE to avoid these warnings */
#undef FALSE
#undef TRUE
#undef INLINE
/*! BOOLEAN values */
#define FALSE 0 //!< False
#define TRUE 1 //!< True
/**
*** @brief Enumeration of Status type
**/
typedef enum {
SUCCESS, //!< 0
FAIL //!< 1
} Status_e;
typedef Status_e WL_STATUS;
/*! Value for NULL pointer */
#undef NULL
#define NULL ((void *)0) //!< null
#if 0
#ifndef LINT
#define MLAN_PACK_START __packed //!< packed structure
#define MLAN_PACK_END //!< end of packed structure
#define ALIGNED_START(x) __align(x) //!< allignment macro
#define ALIGNED_END(x) //!< allignment end
#else
#define MLAN_PACK_START
#define MLAN_PACK_END
#define ALIGNED_START(x)
#define ALIGNED_END(x)
#endif
#endif
#define INLINE
#define BIT0 (0x00000001 << 0)
#define BIT1 (0x00000001 << 1)
#define BIT2 (0x00000001 << 2)
#define BIT3 (0x00000001 << 3)
#define BIT4 (0x00000001 << 4)
#define BIT5 (0x00000001 << 5)
#define BIT6 (0x00000001 << 6)
#define BIT7 (0x00000001 << 7)
#define BIT8 (0x00000001 << 8)
#define BIT9 (0x00000001 << 9)
#define BIT10 (0x00000001 << 10)
#define BIT11 (0x00000001 << 11)
#define BIT12 (0x00000001 << 12)
#define BIT13 (0x00000001 << 13)
#define BIT14 (0x00000001 << 14)
#define BIT15 (0x00000001 << 15)
#define BIT16 (0x00000001 << 16)
#define BIT17 (0x00000001 << 17)
#define BIT18 (0x00000001 << 18)
#define BIT19 (0x00000001 << 19)
#define BIT20 (0x00000001 << 20)
#define BIT21 (0x00000001 << 21)
#define BIT22 (0x00000001 << 22)
#define BIT23 (0x00000001 << 23)
#define BIT24 (0x00000001 << 24)
#define BIT25 (0x00000001 << 25)
#define BIT26 (0x00000001 << 26)
#define BIT27 (0x00000001 << 27)
#define BIT28 (0x00000001 << 28)
#define BIT29 (0x00000001 << 29)
#define BIT30 (0x00000001 << 30)
#define BIT31 (0x00000001UL << 31)
// VOLT_RESOLUTION_50mV
#define VOLT_0_5 10 // 10x50mV = 5x100mV
#define VOLT_0_6 12 // 12x50mV = 6x100mV
#define VOLT_0_7 14 // 14x50mV = 7x100mV
#define VOLT_0_7_5 15 // 15x50mV = 7.5x100mV
#define VOLT_0_8 16 // 16x50mV = 8x100mV
#define VOLT_0_8_5 17 // 17x50mV = 8.5x100mV
#define VOLT_0_9 18 // 18x50mV = 9x100mV
#define VOLT_1_0 20 // 20x50mV = 10x100mV
#define VOLT_1_0_5 21 // 21x50mV
#define VOLT_1_1 22 // 22x50mV = 11x100mV
#define VOLT_1_1_5 23 // 23x50mV
#define VOLT_1_2 24 // 24x50mV = 12x100mV
#define VOLT_1_2_5 25 // 25x50mV
#define VOLT_1_3 26 // 26x50mV = 13x100mV
#define VOLT_1_4 28 // 28x50mV = 14x100mV
#define VOLT_1_5 30 // 30x50mV = 15x100mV
#define VOLT_1_5_5 31 // 31x50mV = 15.5x100mV
#define VOLT_1_6 32 // 32x50mV = 16x100mV
#define VOLT_1_6_5 33 // 33x50mV = 16.5x100mV
#define VOLT_1_7 34 // 34x50mV = 17x100mV
#define VOLT_1_7_5 35 // 35x50mV = 17.5x100mV
#define VOLT_1_8 36 // 36x50mV = 18x100mV
#define VOLT_1_8_5 37 // 37x50mV = 18.5x100mV
#define VOLT_1_9 38 // 38x50mV = 19x100mV
#define VOLT_1_9_5 39 // 39x50mV = 19.5x100mV
#define VOLT_2_0 40 // 40x50mV = 20x100mV
#define VOLT_2_1 42 // 42x50mV = 21x100mV
#define VOLT_2_2 44 // 44x50mV = 22x100mV
#define VOLT_2_3 46 // 46x50mV = 23x100mV
#define VOLT_2_4 48 // 48x50mV = 24x100mV
#define VOLT_2_5 50 // 50x50mV = 25x100mV
#define VOLT_2_6 52 // 52x50mV = 26x100mV
#define VOLT_2_7 54 // 54x50mV = 27x100mV
#define VOLT_2_8 56 // 56x50mV = 28x100mV
#define VOLT_2_9 58 // 58x50mV = 29x100mV
#define VOLT_3_0 60 // 60x50mV = 30x100mV
#define VOLT_3_1 62 // 62x50mV = 31x100mV
#define VOLT_3_2 64 // 64x50mV = 32x100mV
#define VOLT_3_3 66 // 66x50mV = 33x100mV
#define VOLT_3_4 68 // 68x50mV = 34x100mV
#define VOLT_3_5 70 // 70x50mV = 35x100mV
#define VOLT_3_6 72 // 72x50mV = 36x100mV
typedef enum {
OFF = 0,
ON = 1,
UNKOWN = 0xFF
} ON_OFF_UNKOWN_e;
typedef unsigned char MRVL_RATEID;
#if defined(DOT11AC) && defined(STREAM_2x2)
typedef unsigned long long MRVL_RATEID_BITMAP_UNIT;
typedef struct {
unsigned long long bitmap[2];
} MRVL_RATEID_BITMAP;
#define MRVL_RATEID_BIT(rateId) (1ULL << (rateId))
#else
#if defined(STREAM_2x2) || defined(DOT11AC)
typedef unsigned long long MRVL_RATEID_BITMAP_UNIT;
typedef unsigned long long MRVL_RATEID_BITMAP;
#define MRVL_RATEID_BIT(rateId) (1ULL << (rateId))
#else
typedef unsigned int MRVL_RATEID_BITMAP_UNIT;
typedef unsigned int MRVL_RATEID_BITMAP;
#define MRVL_RATEID_BIT(rateId) (1UL << (rateId))
#endif
#endif
#define NUM_RATE_BITMAP_UNIT (sizeof(MRVL_RATEID_BITMAP_UNIT)*8)
enum {
RATEID_DBPSK1Mbps, //(0)
RATEID_DQPSK2Mbps, //(1)
RATEID_CCK5_5Mbps, //(2)
RATEID_CCK11Mbps, //(3)
RATEID_CCK22Mbps, //(4)
RATEID_OFDM6Mbps, //(5)
RATEID_OFDM9Mbps, //(6)
RATEID_OFDM12Mbps, //(7)
RATEID_OFDM18Mbps, //(8)
RATEID_OFDM24Mbps, //(9)
RATEID_OFDM36Mbps, //(10)
RATEID_OFDM48Mbps, //(11)
RATEID_OFDM54Mbps, //(12)
RATEID_OFDM72Mbps, //(13)
RATEID_MCS0_6d5Mbps, //(14) //RATEID_OFDM72Mbps + 1
RATEID_MCS1_13Mbps, //(15)
RATEID_MCS2_19d5Mbps, //(16)
RATEID_MCS3_26Mbps, //(17)
RATEID_MCS4_39Mbps, //(18)
RATEID_MCS5_52Mbps, //(19)
RATEID_MCS6_58d5Mbps, //(20)
RATEID_MCS7_65Mbps, //(21)
#ifdef STREAM_2x2
RATEID_MCS8_13Mbps, //(22)
RATEID_MCS9_26Mbps, //(23)
RATEID_MCS10_39Mbps, //(24)
RATEID_MCS11_52Mbps, //(25)
RATEID_MCS12_78Mbps, //(26)
RATEID_MCS13_104Mbps, //(27)
RATEID_MCS14_117Mbps, //(28)
RATEID_MCS15_130Mbps, //(29)
#endif
RATEID_MCS32BW40_6Mbps, //(30), (22)
RATEID_MCS0BW40_13d5Mbps, //(31), (23)
RATEID_MCS1BW40_27Mbps, //(32), (24)
RATEID_MCS2BW40_40d5Mbps, //(33), (25)
RATEID_MCS3BW40_54Mbps, //(34), (26)
RATEID_MCS4BW40_81Mbps, //(35), (27)
RATEID_MCS5BW40_108Mbps, //(36), (28)
RATEID_MCS6BW40_121d5Mbps, //(37), (29)
RATEID_MCS7BW40_135Mbps, //(38), (30)
#ifdef STREAM_2x2
RATEID_MCS8BW40_27Mbps, //(39)
RATEID_MCS9BW40_54Mbps, //(40)
RATEID_MCS10BW40_81Mbps, //(41)
RATEID_MCS11BW40_108Mbps, //(42)
RATEID_MCS12BW40_162Mbps, //(43)
RATEID_MCS13BW40_216Mbps, //(44)
RATEID_MCS14BW40_243Mbps, //(45)
RATEID_MCS15BW40_270Mbps, //(46)
#endif
#if defined(DOT11AC)
RATEID_VHT_MCS0_1SS_BW20, //(47), (31) //6.5 Mbps
RATEID_VHT_MCS1_1SS_BW20, //(48), (32) //13 Mbps
RATEID_VHT_MCS2_1SS_BW20, //(49), (33) //19.5 Mbps
RATEID_VHT_MCS3_1SS_BW20, //(50), (34) //26 Mbps
RATEID_VHT_MCS4_1SS_BW20, //(51), (35) //39 Mbps
RATEID_VHT_MCS5_1SS_BW20, //(52), (36) //52 Mbps
RATEID_VHT_MCS6_1SS_BW20, //(53), (37) //58.5 Mbps
RATEID_VHT_MCS7_1SS_BW20, //(54), (38) //65 Mbps
RATEID_VHT_MCS8_1SS_BW20, //(55), (39) //78 Mbps
RATEID_VHT_MCS9_1SS_BW20, //(56), (40) //86.7 Mbps(INVALID)
#ifdef STREAM_2x2
RATEID_VHT_MCS0_2SS_BW20, //(57) //13 Mbps
RATEID_VHT_MCS1_2SS_BW20, //(58) //26 Mbps
RATEID_VHT_MCS2_2SS_BW20, //(59) //39 Mbps
RATEID_VHT_MCS3_2SS_BW20, //(60) //52 Mbps
RATEID_VHT_MCS4_2SS_BW20, //(61) //78 Mbps
RATEID_VHT_MCS5_2SS_BW20, //(62) //104 Mbps
RATEID_VHT_MCS6_2SS_BW20, //(63) //117 Mbps
RATEID_VHT_MCS7_2SS_BW20, //(64) //130 Mbps
RATEID_VHT_MCS8_2SS_BW20, //(65) //156 Mbps
RATEID_VHT_MCS9_2SS_BW20, //(66) //173.3 Mbps(INVALID)
#endif
RATEID_VHT_MCS0_1SS_BW40, //(67), (41) //13.5 Mbps
RATEID_VHT_MCS1_1SS_BW40, //(68), (42) //27 Mbps
RATEID_VHT_MCS2_1SS_BW40, //(69), (43) //40.5 Mbps
RATEID_VHT_MCS3_1SS_BW40, //(70), (44) //54 Mbps
RATEID_VHT_MCS4_1SS_BW40, //(71), (45) //81 Mbps
RATEID_VHT_MCS5_1SS_BW40, //(72), (46) //108 Mbps
RATEID_VHT_MCS6_1SS_BW40, //(73), (47) //121.5 Mbps
RATEID_VHT_MCS7_1SS_BW40, //(74), (48) //135 Mbps
RATEID_VHT_MCS8_1SS_BW40, //(75), (49) //162 Mbps
RATEID_VHT_MCS9_1SS_BW40, //(76), (50) //180 Mbps
#ifdef STREAM_2x2
RATEID_VHT_MCS0_2SS_BW40, //(77) //27 Mbps
RATEID_VHT_MCS1_2SS_BW40, //(78) //54 Mbps
RATEID_VHT_MCS2_2SS_BW40, //(79) //81 Mbps
RATEID_VHT_MCS3_2SS_BW40, //(80) //108 Mbps
RATEID_VHT_MCS4_2SS_BW40, //(81) //162 Mbps
RATEID_VHT_MCS5_2SS_BW40, //(82) //216 Mbps
RATEID_VHT_MCS6_2SS_BW40, //(83) //243 Mbps
RATEID_VHT_MCS7_2SS_BW40, //(84) //270 Mbps
RATEID_VHT_MCS8_2SS_BW40, //(85) //324 Mbps
RATEID_VHT_MCS9_2SS_BW40, //(86) //360 Mbps
#endif
RATEID_VHT_MCS0_1SS_BW80, //(87), (51) //29.3 Mbps
RATEID_VHT_MCS1_1SS_BW80, //(88), (52) //58.5 Mbps
RATEID_VHT_MCS2_1SS_BW80, //(89), (53) //87.8 Mbps
RATEID_VHT_MCS3_1SS_BW80, //(90), (54) //117 Mbps
RATEID_VHT_MCS4_1SS_BW80, //(91), (55) //175.5 Mbps
RATEID_VHT_MCS5_1SS_BW80, //(92), (56) //234 Mbps
RATEID_VHT_MCS6_1SS_BW80, //(93), (57) //263.3 Mbps
RATEID_VHT_MCS7_1SS_BW80, //(94), (58) //292.5 Mbps
RATEID_VHT_MCS8_1SS_BW80, //(95), (59) //351 Mbps
RATEID_VHT_MCS9_1SS_BW80, //(96), (60) //390 Mbps
#ifdef STREAM_2x2
RATEID_VHT_MCS0_2SS_BW80, //(97) //58.5 Mbps
RATEID_VHT_MCS1_2SS_BW80, //(98) //117 Mbps
RATEID_VHT_MCS2_2SS_BW80, //(99) //175 Mbps
RATEID_VHT_MCS3_2SS_BW80, //(100) //234 Mbps
RATEID_VHT_MCS4_2SS_BW80, //(101) //351 Mbps
RATEID_VHT_MCS5_2SS_BW80, //(102) //468 Mbps
RATEID_VHT_MCS6_2SS_BW80, //(103) //526.5 Mbps
RATEID_VHT_MCS7_2SS_BW80, //(104) //585 Mbps
RATEID_VHT_MCS8_2SS_BW80, //(105) //702 Mbps
RATEID_VHT_MCS9_2SS_BW80, //(106) //780 Mbps
#endif
#endif //DOT11AC
RATEID_AUTO = 0xFE,
RATEID_UNKNOWN = 0xFF
};
//MAX RATE DEFINITION
#define RATEID_DSSSMAX RATEID_DQPSK2Mbps
#define RATEID_CCKMAX RATEID_CCK11Mbps
#define RATEID_OFDMMAX RATEID_OFDM54Mbps
#define RATEID_OFDMMIN RATEID_OFDM6Mbps
#define RATEID_HTBW20MIN RATEID_MCS0_6d5Mbps
#ifdef STREAM_2x2
#define RATEID_HTBW20MAX RATEID_MCS15_130Mbps
#else
#define RATEID_HTBW20MAX RATEID_MCS7_65Mbps
#endif
#define RATEID_HTBW40MIN RATEID_MCS32BW40_6Mbps
#ifdef STREAM_2x2
#define RATEID_HTBW40MAX RATEID_MCS15BW40_270Mbps
#else
#define RATEID_HTBW40MAX RATEID_MCS7BW40_135Mbps
#endif
#define RATEID_HTMIN RATEID_HTBW20MIN
#define RATEID_HTMAX RATEID_HTBW40MAX
#if defined(DOT11AC)
#define RATEID_VHTBW20MIN RATEID_VHT_MCS0_1SS_BW20
#define RATEID_VHTBW40MIN RATEID_VHT_MCS0_1SS_BW40
#define RATEID_VHTBW80MIN RATEID_VHT_MCS0_1SS_BW80
#define RATEID_VHTMIN RATEID_VHT_MCS0_1SS_BW20
#ifdef STREAM_2x2
#define RATEID_VHTBW20MAX RATEID_VHT_MCS9_2SS_BW20
#define RATEID_VHTBW40MAX RATEID_VHT_MCS9_2SS_BW40
#define RATEID_VHTMAX RATEID_VHT_MCS9_2SS_BW80
#else
#define RATEID_VHTBW20MAX RATEID_VHT_MCS9_1SS_BW20
#define RATEID_VHTBW40MAX RATEID_VHT_MCS9_1SS_BW40
#define RATEID_VHTMAX RATEID_VHT_MCS9_1SS_BW80
#endif
#define RATEID_VHTBW80MAX RATEID_VHTMAX
/* 160 is not supported yet; define them correctly when supported */
#define RATEID_VHTBW160MIN 0xFF
#define RATEID_VHTBW160MAX 0xFF
#endif //DOT11AC
#define MLME_SUCCESS 0
#define MLME_INPROCESS 1
#define MLME_FAILURE -1
#define RATEID_9_6_MASK (((1<<(1+RATEID_OFDM9Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_12_6_MASK (((1<<(1+RATEID_OFDM12Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_18_6_MASK (((1<<(1+RATEID_OFDM18Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_24_6_MASK (((1<<(1+RATEID_OFDM24Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_36_6_MASK (((1<<(1+RATEID_OFDM36Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_48_6_MASK (((1<<(1+RATEID_OFDM48Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_54_6_MASK (((1<<(1+RATEID_OFDM54Mbps-RATEID_OFDM6Mbps))-1) \
<< RATEID_OFDM6Mbps)
#define RATEID_CCK_MASK ( (1 << RATEID_DBPSK1Mbps) \
| (1 << RATEID_DQPSK2Mbps) \
| (1 << RATEID_CCK5_5Mbps) \
| (1 << RATEID_CCK11Mbps) )
#define HT_RATE_MASK_MCS0_7 ( (1ULL << RATEID_MCS0_6d5Mbps) \
| (1ULL << RATEID_MCS1_13Mbps) \
| (1ULL << RATEID_MCS2_19d5Mbps) \
| (1ULL << RATEID_MCS3_26Mbps) \
| (1ULL << RATEID_MCS4_39Mbps) \
| (1ULL << RATEID_MCS5_52Mbps) \
| (1ULL << RATEID_MCS6_58d5Mbps) \
| (1ULL << RATEID_MCS7_65Mbps) )
#ifdef STREAM_2x2
#define HT_RATE_MASK_MCS8_15 ( (1ULL << RATEID_MCS8_13Mbps) \
| (1ULL << RATEID_MCS9_26Mbps) \
| (1ULL << RATEID_MCS10_39Mbps) \
| (1ULL << RATEID_MCS11_52Mbps) \
| (1ULL << RATEID_MCS12_78Mbps) \
| (1ULL << RATEID_MCS13_104Mbps) \
| (1ULL << RATEID_MCS14_117Mbps) \
| (1ULL << RATEID_MCS15_130Mbps) )
#else //1x1
#define HT_RATE_MASK_MCS8_15 (0)
#endif
#define HT_RATE_MASK_MCS0_7_32_40MHZ ( (1ULL << RATEID_MCS32BW40_6Mbps) \
| (1ULL << RATEID_MCS0BW40_13d5Mbps) \
| (1ULL << RATEID_MCS1BW40_27Mbps) \
| (1ULL << RATEID_MCS2BW40_40d5Mbps) \
| (1ULL << RATEID_MCS3BW40_54Mbps) \
| (1ULL << RATEID_MCS4BW40_81Mbps) \
| (1ULL << RATEID_MCS5BW40_108Mbps) \
| (1ULL << RATEID_MCS6BW40_121d5Mbps) \
| (1ULL << RATEID_MCS7BW40_135Mbps) )
#ifdef STREAM_2x2
#define HT_RATE_MASK_MCS8_15_40MHZ ( (1ULL << RATEID_MCS8BW40_27Mbps) \
| (1ULL << RATEID_MCS9BW40_54Mbps) \
| (1ULL << RATEID_MCS10BW40_81Mbps) \
| (1ULL << RATEID_MCS11BW40_108Mbps) \
| (1ULL << RATEID_MCS12BW40_162Mbps) \
| (1ULL << RATEID_MCS13BW40_216Mbps) \
| (1ULL << RATEID_MCS14BW40_243Mbps) \
| (1ULL << RATEID_MCS15BW40_270Mbps) )
#else //1x1
#define HT_RATE_MASK_MCS8_15_40MHZ (0)
#endif
#define RATEID_MCS_MASK ( HT_RATE_MASK_MCS0_7 \
| HT_RATE_MASK_MCS8_15 \
| HT_RATE_MASK_MCS0_7_32_40MHZ \
| HT_RATE_MASK_MCS8_15_40MHZ )
#define RATEID_MCSBW40_MASK ( HT_RATE_MASK_MCS0_7_32_40MHZ \
| HT_RATE_MASK_MCS8_15_40MHZ )
#define RATEID_MCS1x1_MASK ( HT_RATE_MASK_MCS0_7 \
| HT_RATE_MASK_MCS0_7_32_40MHZ)
#define RATEID_MCS2x2_MASK ( HT_RATE_MASK_MCS8_15 \
| HT_RATE_MASK_MCS8_15_40MHZ )
#define IS_DSSS_FRAME(rateid) (rateid < RATEID_OFDM6Mbps)
#define IS_OFDM_FRAME(rateid) (rateid >= RATEID_OFDM6Mbps)
typedef unsigned char MRVL_TRPCID;
typedef signed long PWR_in_dBm;
#if 0
#define ASSERT_RATEID(rateid) {while(rateid > RATEID_MAX);}
#define ASSERT_NonZero(x) {while(x == 0);}
#else
#define ASSERT_RATEID(rateid)
#define ASSERT_NonZero(x)
#endif
#endif /* _WLTYPES_H_ */

View File

@@ -0,0 +1,137 @@
/** @file hostsa_def.h
*
* @brief This file contains data structrue for authenticator/supplicant.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _HOSTSA_DEF_H
#define _HOSTSA_DEF_H
/* subset of mlan_callbacks data structure */
/** hostsa_util_fns data structure */
typedef struct _hostsa_util_fns {
/** pmoal_handle */
t_void *pmoal_handle;
/** moal_malloc */
mlan_status (*moal_malloc) (IN t_void *pmoal_handle,
IN t_u32 size,
IN t_u32 flag, OUT t_u8 **ppbuf);
/** moal_mfree */
mlan_status (*moal_mfree) (IN t_void *pmoal_handle, IN t_u8 *pbuf);
/** moal_memset */
t_void *(*moal_memset) (IN t_void *pmoal_handle,
IN t_void *pmem, IN t_u8 byte, IN t_u32 num);
/** moal_memcpy */
t_void *(*moal_memcpy) (IN t_void *pmoal_handle,
IN t_void *pdest,
IN const t_void *psrc, IN t_u32 num);
/** moal_memmove */
t_void *(*moal_memmove) (IN t_void *pmoal_handle,
IN t_void *pdest,
IN const t_void *psrc, IN t_u32 num);
/** moal_memcmp */
t_s32 (*moal_memcmp) (IN t_void *pmoal_handle,
IN const t_void *pmem1,
IN const t_void *pmem2, IN t_u32 num);
/** moal_udelay */
t_void (*moal_udelay) (IN t_void *pmoal_handle, IN t_u32 udelay);
/** moal_get_system_time */
mlan_status (*moal_get_system_time) (IN t_void *pmoal_handle,
OUT t_u32 *psec, OUT t_u32 *pusec);
/** moal_init_timer*/
mlan_status (*moal_init_timer) (IN t_void *pmoal_handle,
OUT t_void **pptimer,
IN t_void (*callback) (t_void
*pcontext),
IN t_void *pcontext);
/** moal_free_timer */
mlan_status (*moal_free_timer) (IN t_void *pmoal_handle,
IN t_void *ptimer);
/** moal_start_timer*/
mlan_status (*moal_start_timer) (IN t_void *pmoal_handle,
IN t_void *ptimer,
IN t_u8 periodic, IN t_u32 msec);
/** moal_stop_timer*/
mlan_status (*moal_stop_timer) (IN t_void *pmoal_handle,
IN t_void *ptimer);
/** moal_init_lock */
mlan_status (*moal_init_lock) (IN t_void *pmoal_handle,
OUT t_void **pplock);
/** moal_free_lock */
mlan_status (*moal_free_lock) (IN t_void *pmoal_handle,
IN t_void *plock);
/** moal_spin_lock */
mlan_status (*moal_spin_lock) (IN t_void *pmoal_handle,
IN t_void *plock);
/** moal_spin_unlock */
mlan_status (*moal_spin_unlock) (IN t_void *pmoal_handle,
IN t_void *plock);
/** moal_print */
t_void (*moal_print) (IN t_void *pmoal_handle,
IN t_u32 level, IN char *pformat, IN ...
);
/** moal_print_netintf */
t_void (*moal_print_netintf) (IN t_void *pmoal_handle,
IN t_u32 bss_index, IN t_u32 level);
} hostsa_util_fns, *phostsa_util_fns;
/* Required functions from mlan */
/** hostsa_mlan_fns data structure */
typedef struct _hostsa_mlan_fns {
/** pmlan_private */
t_void *pmlan_private;
/** pmlan_adapter */
t_void *pmlan_adapter;
/** BSS index */
t_u8 bss_index;
/** BSS type */
t_u8 bss_type;
pmlan_buffer (*hostsa_alloc_mlan_buffer) (t_void *pmlan_adapter,
t_u32 data_len,
t_u32 head_room,
t_u32 malloc_flag);
void (*hostsa_tx_packet) (t_void *pmlan_private,
pmlan_buffer pmbuf, t_u16 frameLen);
void (*hostsa_set_encrypt_key) (t_void *pmlan_private,
mlan_ds_encrypt_key *encrypt_key);
void (*hostsa_clr_encrypt_key) (t_void *pmlan_private);
void (*hostsa_SendDeauth) (t_void *pmlan_private,
t_u8 *addr, t_u16 reason);
void (*Hostsa_DisAssocAllSta) (void *pmlan_private, t_u16 reason);
void (*hostsa_free_mlan_buffer) (t_void *pmlan_adapter,
mlan_buffer *pmbuf);
void (*Hostsa_get_station_entry) (t_void *pmlan_private,
t_u8 *mac, t_void **ppconPtr);
void (*Hostsa_set_mgmt_ie) (t_void *pmlan_private,
t_u8 *pbuf, t_u16 len, t_u8 clearIE);
void (*Hostsa_find_connection) (t_void *pmlan_private,
t_void **ppconPtr, t_void **ppsta_node);
void (*Hostsa_find_next_connection) (t_void *pmlan_private,
t_void **ppconPtr,
t_void **ppsta_node);
t_void (*Hostsa_StaControlledPortOpen) (t_void *pmlan_private);
void (*hostsa_StaSendDeauth) (t_void *pmlan_private,
t_u8 *addr, t_u16 reason);
t_u8 (*Hostsa_get_bss_role) (t_void *pmlan_private);
t_u8 (*Hostsa_get_intf_hr_len) (t_void *pmlan_private);
t_void (*Hostsa_sendEventRsnConnect) (t_void *pmlan_private,
t_u8 *addr);
} hostsa_mlan_fns, *phostsa_mlan_fns;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,649 @@
/** @file hostsa_init.c
*
* @brief This file defines the initialize /free APIs for authenticator and supplicant.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "mlan.h"
#ifdef STA_SUPPORT
#include "mlan_join.h"
#endif
#include "mlan_ioctl.h"
#include "mlan_util.h"
#include "mlan_fw.h"
#include "mlan_main.h"
#include "mlan_init.h"
#include "mlan_wmm.h"
#include "hostsa_def.h"
#include "authenticator_api.h"
/*********************
Local Variables
*********************/
/*********************
Global Variables
*********************/
/*********************
Local Functions
*********************/
/*********************
Global Functions
*********************/
/*********************
Utility Handler
*********************/
/**
* @brief alloc mlan buffer
*
* @param pmlan_adapter A void pointer
* @param data_len request buffer len
* @param head_room head room len
* @param malloc_flag flag for mlan buffer
* @return pointer to mlan buffer
*/
pmlan_buffer
hostsa_alloc_mlan_buffer(t_void *pmlan_adapter,
t_u32 data_len, t_u32 head_room, t_u32 malloc_flag)
{
mlan_adapter *pmadapter = (mlan_adapter *)pmlan_adapter;
pmlan_buffer newbuf = MNULL;
newbuf = wlan_alloc_mlan_buffer(pmadapter, data_len, head_room,
malloc_flag);
return newbuf;
}
/**
* @brief free mlan buffer
*
* @param pmlan_adapter A void pointer
* @param pmbuf a pointer to mlan buffer
*
* @return
*/
void
hostsa_free_mlan_buffer(t_void *pmlan_adapter, mlan_buffer *pmbuf)
{
mlan_adapter *pmadapter = (mlan_adapter *)pmlan_adapter;
ENTER();
wlan_free_mlan_buffer(pmadapter, pmbuf);
LEAVE();
}
/**
* @brief send packet
*
* @param pmlan_private A void pointer
* @param pmbuf a pointer to mlan buffer
* @param frameLen paket len
*
* @return
*/
void
hostsa_tx_packet(t_void *pmlan_private, pmlan_buffer pmbuf, t_u16 frameLen)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = pmpriv->adapter;
ENTER();
pmbuf->bss_index = pmpriv->bss_index;
pmbuf->data_len = frameLen;
wlan_add_buf_bypass_txqueue(pmadapter, pmbuf);
wlan_recv_event(pmpriv, MLAN_EVENT_ID_DRV_DEFER_HANDLING, MNULL);
LEAVE();
}
/**
* @brief set key to fw
*
* @param pmlan_private A void pointer
* @param encrypt_key key structure
*
* @return
*/
void
wlan_set_encrypt_key(t_void *pmlan_private, mlan_ds_encrypt_key *encrypt_key)
{
mlan_private *priv = (mlan_private *)pmlan_private;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
if (!encrypt_key->key_len) {
PRINTM(MCMND, "Skip set key with key_len = 0\n");
LEAVE();
return;
}
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_802_11_KEY_MATERIAL,
HostCmd_ACT_GEN_SET,
KEY_INFO_ENABLED, MNULL, encrypt_key);
if (ret == MLAN_STATUS_SUCCESS)
wlan_recv_event(priv, MLAN_EVENT_ID_DRV_DEFER_HANDLING, MNULL);
LEAVE();
}
/**
* @brief clear key to fw
*
* @param pmlan_private A void pointer
*
* @return
*/
void
wlan_clr_encrypt_key(t_void *pmlan_private)
{
mlan_private *priv = (mlan_private *)pmlan_private;
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_encrypt_key encrypt_key;
ENTER();
memset(priv->adapter, &encrypt_key, 0, sizeof(mlan_ds_encrypt_key));
encrypt_key.key_disable = MTRUE;
encrypt_key.key_flags = KEY_FLAG_REMOVE_KEY;
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_802_11_KEY_MATERIAL,
HostCmd_ACT_GEN_SET,
KEY_INFO_ENABLED, MNULL, &encrypt_key);
if (ret == MLAN_STATUS_SUCCESS)
wlan_recv_event(priv, MLAN_EVENT_ID_DRV_DEFER_HANDLING, MNULL);
LEAVE();
}
/**
* @brief send deauth frame
*
* @param pmlan_private A void pointer
* @param addr destination mac address
* @param reason deauth reason
*
* @return
*/
void
hostsa_SendDeauth(t_void *pmlan_private, t_u8 *addr, t_u16 reason)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = pmpriv->adapter;
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_deauth_param deauth;
ENTER();
memcpy(pmadapter, deauth.mac_addr, addr, MLAN_MAC_ADDR_LENGTH);
deauth.reason_code = reason;
ret = wlan_prepare_cmd(pmpriv,
HOST_CMD_APCMD_STA_DEAUTH,
HostCmd_ACT_GEN_SET,
0, MNULL, (t_void *)&deauth);
if (ret == MLAN_STATUS_SUCCESS)
wlan_recv_event(pmpriv, MLAN_EVENT_ID_DRV_DEFER_HANDLING,
MNULL);
LEAVE();
}
/**
* @brief deauth all connected stations
*
* @param pmlan_private A void pointer
* @param reason deauth reason
*
* @return
*/
void
ApDisAssocAllSta(void *pmlan_private, t_u16 reason)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = pmpriv->adapter;
sta_node *sta_ptr;
ENTER();
sta_ptr = (sta_node *)util_peek_list(pmadapter->pmoal_handle,
&pmpriv->sta_list,
pmadapter->callbacks.
moal_spin_lock,
pmadapter->callbacks.
moal_spin_unlock);
if (!sta_ptr) {
LEAVE();
return;
}
while (sta_ptr != (sta_node *)&pmpriv->sta_list) {
hostsa_SendDeauth((t_void *)pmpriv, sta_ptr->mac_addr, reason);
sta_ptr = sta_ptr->pnext;
}
LEAVE();
}
/**
* @brief get station entry
*
* @param pmlan_private A void pointer
* @param mac pointer to station mac address
* @param ppconPtr pointer to pointer to connection
*
* @return
*/
void
Hostsa_get_station_entry(t_void *pmlan_private, t_u8 *mac, t_void **ppconPtr)
{
mlan_private *priv = (mlan_private *)pmlan_private;
sta_node *sta_ptr = MNULL;
ENTER();
sta_ptr = wlan_get_station_entry(priv, mac);
if (sta_ptr)
*ppconPtr = sta_ptr->cm_connectioninfo;
else
*ppconPtr = MNULL;
LEAVE();
}
/**
* @brief find a connection
*
* @param pmlan_private A void pointer
* @param ppconPtr a pointer to pointer to connection
* @param ppsta_node a pointer to pointer to sta node
*
* @return
*/
void
Hostsa_find_connection(t_void *pmlan_private, t_void **ppconPtr,
t_void **ppsta_node)
{
mlan_private *priv = (mlan_private *)pmlan_private;
sta_node *sta_ptr = MNULL;
ENTER();
sta_ptr = (sta_node *)util_peek_list(priv->adapter->pmoal_handle,
&priv->sta_list,
priv->adapter->callbacks.
moal_spin_lock,
priv->adapter->callbacks.
moal_spin_unlock);
if (!sta_ptr) {
LEAVE();
return;
}
*ppsta_node = (t_void *)sta_ptr;
*ppconPtr = sta_ptr->cm_connectioninfo;
LEAVE();
}
/**
* @brief find next connection
*
* @param pmlan_private A void pointer
* @param ppconPtr a pointer to pointer to connection
* @param ppsta_node a pointer to pointer to sta node
*
* @return
*/
void
Hostsa_find_next_connection(t_void *pmlan_private, t_void **ppconPtr,
t_void **ppsta_node)
{
mlan_private *priv = (mlan_private *)pmlan_private;
sta_node *sta_ptr = (sta_node *)*ppsta_node;
ENTER();
if (sta_ptr != (sta_node *)&priv->sta_list)
sta_ptr = sta_ptr->pnext;
*ppsta_node = MNULL;
*ppconPtr = MNULL;
if ((sta_ptr != MNULL) && (sta_ptr != (sta_node *)&priv->sta_list)) {
*ppsta_node = (t_void *)sta_ptr;
*ppconPtr = sta_ptr->cm_connectioninfo;
}
LEAVE();
}
/**
* @brief set management ie for beacon or probe response
*
* @param pmlan_private A void pointer
* @param pbuf ie buf
* @param len ie len
* @param clearIE clear ie
*
* @return
*/
void
Hostsa_set_mgmt_ie(t_void *pmlan_private, t_u8 *pbuf, t_u16 len, t_u8 clearIE)
{
mlan_private *priv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = priv->adapter;
mlan_ioctl_req *pioctl_req = MNULL;
mlan_ds_misc_cfg *pds_misc_cfg = MNULL;
custom_ie *pmgmt_ie = MNULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
if (pmadapter == MNULL) {
LEAVE();
return;
}
/* allocate buffer for mlan_ioctl_req and mlan_ds_misc_cfg */
/* FYI - will be freed as part of cmd_response handler */
ret = pmadapter->callbacks.moal_malloc(pmadapter->pmoal_handle,
sizeof(mlan_ioctl_req) +
sizeof(mlan_ds_misc_cfg),
MLAN_MEM_DEF,
(t_u8 **)&pioctl_req);
if ((ret != MLAN_STATUS_SUCCESS) || !pioctl_req) {
PRINTM(MERROR, "%s(): Could not allocate ioctl req\n",
__func__);
LEAVE();
return;
}
pds_misc_cfg = (mlan_ds_misc_cfg *)((t_u8 *)pioctl_req +
sizeof(mlan_ioctl_req));
/* prepare mlan_ioctl_req */
memset(pmadapter, pioctl_req, 0x00, sizeof(mlan_ioctl_req));
pioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
pioctl_req->action = MLAN_ACT_SET;
pioctl_req->bss_index = priv->bss_index;
pioctl_req->pbuf = (t_u8 *)pds_misc_cfg;
pioctl_req->buf_len = sizeof(mlan_ds_misc_cfg);
/* prepare mlan_ds_misc_cfg */
memset(pmadapter, pds_misc_cfg, 0x00, sizeof(mlan_ds_misc_cfg));
pds_misc_cfg->sub_command = MLAN_OID_MISC_CUSTOM_IE;
pds_misc_cfg->param.cust_ie.type = TLV_TYPE_MGMT_IE;
pds_misc_cfg->param.cust_ie.len = (sizeof(custom_ie) - MAX_IE_SIZE);
/* configure custom_ie api settings */
pmgmt_ie = (custom_ie *)&pds_misc_cfg->param.cust_ie.ie_data_list[0];
pmgmt_ie->ie_index = 0xffff; /* Auto index */
pmgmt_ie->ie_length = len;
pmgmt_ie->mgmt_subtype_mask = MBIT(8) | MBIT(5); /* add IE for BEACON | PROBE_RSP */
if (clearIE)
pmgmt_ie->mgmt_subtype_mask = 0;
memcpy(pmadapter, pmgmt_ie->ie_buffer, pbuf, len);
pds_misc_cfg->param.cust_ie.len += pmgmt_ie->ie_length;
DBG_HEXDUMP(MCMD_D, "authenticator: RSN or WPA IE",
(t_u8 *)pmgmt_ie, pds_misc_cfg->param.cust_ie.len);
ret = wlan_misc_ioctl_custom_ie_list(pmadapter, pioctl_req, MFALSE);
if (ret != MLAN_STATUS_SUCCESS && ret != MLAN_STATUS_PENDING) {
PRINTM(MERROR,
"%s(): Could not set IE for priv=%p [priv_bss_idx=%d]!\n",
__func__, priv, priv->bss_index);
/* TODO: how to handle this error case?? ignore & continue? */
}
/* free ioctl buffer memory before we leave */
pmadapter->callbacks.moal_mfree(pmadapter->pmoal_handle,
(t_u8 *)pioctl_req);
}
t_void
StaControlledPortOpen(t_void *pmlan_private)
{
mlan_private *priv = (mlan_private *)pmlan_private;
PRINTM(MERROR, "StaControlledPortOpen\n");
if (priv->port_ctrl_mode == MTRUE) {
PRINTM(MINFO, "PORT_REL: port_status = OPEN\n");
priv->port_open = MTRUE;
}
priv->adapter->scan_block = MFALSE;
wlan_recv_event(priv, MLAN_EVENT_ID_FW_PORT_RELEASE, MNULL);
}
void
hostsa_StaSendDeauth(t_void *pmlan_private, t_u8 *addr, t_u16 reason)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = pmpriv->adapter;
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_deauth_param deauth;
ENTER();
memcpy(pmadapter, deauth.mac_addr, addr, MLAN_MAC_ADDR_LENGTH);
deauth.reason_code = reason;
ret = wlan_prepare_cmd(pmpriv,
HostCmd_CMD_802_11_DEAUTHENTICATE,
HostCmd_ACT_GEN_SET,
0, MNULL, (t_void *)&deauth);
if (ret == MLAN_STATUS_SUCCESS)
wlan_recv_event(pmpriv, MLAN_EVENT_ID_DRV_DEFER_HANDLING,
MNULL);
LEAVE();
}
t_u8
Hostsa_get_bss_role(t_void *pmlan_private)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
return GET_BSS_ROLE(pmpriv);
}
t_u8
Hostsa_get_intf_hr_len(t_void *pmlan_private)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
return pmpriv->intf_hr_len;
}
/**
* @brief send event to moal to notice that 4 way handshake complete
*
* @param pmlan_private A void pointer
* @param addr pointer to station mac address
*
* @return
*/
t_void
Hostsa_sendEventRsnConnect(t_void *pmlan_private, t_u8 *addr)
{
mlan_private *pmpriv = (mlan_private *)pmlan_private;
mlan_adapter *pmadapter = pmpriv->adapter;
t_u8 *event_buf = MNULL, *pos = MNULL;
t_u32 event_cause = 0;
mlan_event *pevent = MNULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
ret = pmadapter->callbacks.moal_malloc(pmadapter->pmoal_handle,
MAX_EVENT_SIZE, MLAN_MEM_DEF,
&event_buf);
if ((ret != MLAN_STATUS_SUCCESS) || !event_buf) {
PRINTM(MERROR, "Could not allocate buffer for event buf\n");
goto done;
}
pevent = (pmlan_event)event_buf;
memset(pmadapter, event_buf, 0, MAX_EVENT_SIZE);
pevent->event_id = MLAN_EVENT_ID_DRV_PASSTHRU;
pevent->bss_index = pmpriv->bss_index;
event_cause = wlan_cpu_to_le32(0x51); /*MICRO_AP_EV_ID_RSN_CONNECT */
memcpy(pmadapter, (t_u8 *)pevent->event_buf,
(t_u8 *)&event_cause, sizeof(event_cause));
pos = pevent->event_buf + sizeof(event_cause) + 2; /*reserved 2 byte */
memcpy(pmadapter, (t_u8 *)pos, addr, MLAN_MAC_ADDR_LENGTH);
pevent->event_len = MLAN_MAC_ADDR_LENGTH + sizeof(event_cause) + 2;
wlan_recv_event(pmpriv, MLAN_EVENT_ID_DRV_PASSTHRU, event_buf);
done:
if (event_buf)
pmadapter->callbacks.moal_mfree(pmadapter->pmoal_handle,
event_buf);
LEAVE();
}
/**
* @brief This function initializes callbacks that hostsa interface uses.
*
* @param pmpriv A pointer to mlan_private structure
* @param putil_fns A pointer to hostsa_util_fns structure
* @param pmlan_fns A pointer to hostsa_mlan_fns structure
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
static t_void
hostsa_mlan_callbacks(IN pmlan_private pmpriv,
IN hostsa_util_fns *putil_fns,
IN hostsa_mlan_fns *pmlan_fns)
{
pmlan_adapter pmadapter = pmpriv->adapter;
pmlan_callbacks pcb = &pmadapter->callbacks;
putil_fns->pmoal_handle = pmadapter->pmoal_handle;
putil_fns->moal_malloc = pcb->moal_malloc;
putil_fns->moal_mfree = pcb->moal_mfree;
putil_fns->moal_memset = pcb->moal_memset;
putil_fns->moal_memcpy = pcb->moal_memcpy;
putil_fns->moal_memmove = pcb->moal_memmove;
putil_fns->moal_memcmp = pcb->moal_memcmp;
putil_fns->moal_udelay = pcb->moal_udelay;
putil_fns->moal_get_system_time = pcb->moal_get_system_time;
putil_fns->moal_init_timer = pcb->moal_init_timer;
putil_fns->moal_free_timer = pcb->moal_free_timer;
putil_fns->moal_start_timer = pcb->moal_start_timer;
putil_fns->moal_stop_timer = pcb->moal_stop_timer;
putil_fns->moal_init_lock = pcb->moal_init_lock;
putil_fns->moal_free_lock = pcb->moal_free_lock;
putil_fns->moal_spin_lock = pcb->moal_spin_lock;
putil_fns->moal_spin_unlock = pcb->moal_spin_unlock;
putil_fns->moal_print = pcb->moal_print;
putil_fns->moal_print_netintf = pcb->moal_print_netintf;
pmlan_fns->pmlan_private = pmpriv;
pmlan_fns->pmlan_adapter = pmpriv->adapter;
pmlan_fns->bss_index = pmpriv->bss_index;
pmlan_fns->bss_type = pmpriv->bss_type;
#if 0
pmlan_fns->mlan_add_buf_txqueue = mlan_add_buf_txqueue;
pmlan_fns->mlan_select_wmm_queue = mlan_select_wmm_queue;
pmlan_fns->mlan_write_data_complete = mlan_write_data_complete;
#endif
pmlan_fns->hostsa_alloc_mlan_buffer = hostsa_alloc_mlan_buffer;
pmlan_fns->hostsa_tx_packet = hostsa_tx_packet;
pmlan_fns->hostsa_set_encrypt_key = wlan_set_encrypt_key;
pmlan_fns->hostsa_clr_encrypt_key = wlan_clr_encrypt_key;
pmlan_fns->hostsa_SendDeauth = hostsa_SendDeauth;
pmlan_fns->Hostsa_DisAssocAllSta = ApDisAssocAllSta;
pmlan_fns->hostsa_free_mlan_buffer = hostsa_free_mlan_buffer;
pmlan_fns->Hostsa_get_station_entry = Hostsa_get_station_entry;
pmlan_fns->Hostsa_set_mgmt_ie = Hostsa_set_mgmt_ie;
pmlan_fns->Hostsa_find_connection = Hostsa_find_connection;
pmlan_fns->Hostsa_find_next_connection = Hostsa_find_next_connection;
pmlan_fns->Hostsa_StaControlledPortOpen = StaControlledPortOpen;
pmlan_fns->hostsa_StaSendDeauth = hostsa_StaSendDeauth;
pmlan_fns->Hostsa_get_bss_role = Hostsa_get_bss_role;
pmlan_fns->Hostsa_get_intf_hr_len = Hostsa_get_intf_hr_len;
pmlan_fns->Hostsa_sendEventRsnConnect = Hostsa_sendEventRsnConnect;
};
/**
* @brief Init hostsa data
*
* @param pmpriv A pointer to mlan_private structure
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status
hostsa_init(pmlan_private pmpriv)
{
hostsa_util_fns util_fns;
hostsa_mlan_fns mlan_fns;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
hostsa_mlan_callbacks(pmpriv, &util_fns, &mlan_fns);
ret = supplicant_authenticator_init(&pmpriv->psapriv, &util_fns,
&mlan_fns, pmpriv->curr_addr);
LEAVE();
return ret;
}
/**
* @brief Cleanup hostsa data
*
* @param pmpriv A pointer to mlan_private structure
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status
hostsa_cleanup(pmlan_private pmpriv)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
supplicant_authenticator_free(pmpriv->psapriv);
LEAVE();
return ret;
}

View File

@@ -0,0 +1,42 @@
/** @file hostsa_init.h
*
* @brief This file contains definitions the APIs.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _HOSTSA_INIT_H_
#define _HOSTSA_INIT_H_
#ifndef MACSTR
/** MAC address security format */
#define MACSTR "%02x:XX:XX:XX:%02x:%02x"
#endif
#ifndef MAC2STR
/** MAC address security print arguments */
#define MAC2STR(a) (a)[0], (a)[4], (a)[5]
#endif
extern mlan_status hostsa_init(pmlan_private pmpriv);
extern mlan_status hostsa_cleanup(pmlan_private pmpriv);
#endif /* _MPL_MAIN_H_ */

View File

@@ -0,0 +1,165 @@
/** @file KeyApiStaTypes.h
*
* @brief This file defines some of the macros and types
* Please do not change those macros and types.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef KEY_API_STA_TYPES_H__
#define KEY_API_STA_TYPES_H__
#include "KeyApiStaDefs.h"
#include "wl_mib.h"
#include "keyCommonDef.h"
/******************************** Pool ID 11 ********************************/
#define POOL_ID11_BLOCK_POOL_CNT 1
#define POOL_ID11_BUF0_SZ CIPHER_KEYS_BUF_SIZE
#define POOL_ID11_BUF0_CNT CIPHER_KEYS_BUF_NUM
#define POOL_ID11_BUF0_REAL_SZ (POOL_ID11_BUF0_SZ)
#define POOL_ID11_BUF0_TOT_SZ (POOL_ID11_BUF0_REAL_SZ * POOL_ID11_BUF0_CNT)
#define POOL_ID11_SZ (POOL_ID11_BUF0_TOT_SZ)
#define POOL_ID11_OVERHEAD ((POOL_ID11_BUF0_CNT) * sizeof(uint32))
#define KEY_STATE_ENABLE 0x01
#define KEY_STATE_FORCE_EAPOL_UNENCRYPTED 0x02
#define KEY_ACTION_ADD 0x01
#define KEY_ACTION_DELETE 0x02
#define KEY_ACTION_FLUSHALL 0xFF
#define KEY_DIRECTION_UNSPEC (0x0)
#define KEY_DIRECTION_RX (0x1)
#define KEY_DIRECTION_TX (0x2)
#define KEY_DIRECTION_RXTX (KEY_DIRECTION_RX \
| KEY_DIRECTION_TX)
#define KEY_INFO_PWK (0x1)
#define KEY_INFO_GWK (0x2)
#define KEY_INFO_IGWK (0x40)
#define KEY_INFO_KEY_MAPPING_KEY (0x4)
#define KEY_INFO_WEP_SUBTYPE (0x8)
#define KEY_INFO_GLOBAL (0x10)
/*
we use BIT6 and BIT7 of
keyInfo field of cipher_key_hdr_t to pass keyID.
*/
#define CIPHERKEY_KEY_ID_MASK (BIT6 | BIT7)
#define CIPHERKEY_KEY_ID_OFFSET 6
#define KEY_INFO_DEFAULT_KEY (~KEY_INFO_KEY_MAPPING_KEY)
#define VERSION_0 0
#define VERSION_2 2
#define IS_KEY_INFO_WEP_SUBTYPE_104BIT(x) \
( (x) ? \
((x)->hdr.keyInfo & KEY_INFO_WEP_SUBTYPE) : 0 )
#define IS_KEY_INFO_WEP_SUBTYPE_40BIT(x) \
( (x) ? \
(!((x)->hdr.keyInfo & KEY_INFO_WEP_SUBTYPE)) : 0 )
#define SET_KEY_INFO_WEP_SUBTYPE_104BIT(x) \
( (x) ? ((x)->hdr.keyInfo |= KEY_INFO_WEP_SUBTYPE) : 0 )
#define SET_KEY_INFO_WEP_SUBTYPE_40BIT(x) \
( (x) ? ((x)->hdr.keyInfo &= ~KEY_INFO_WEP_SUBTYPE) : 0 )
#define SET_KEY_INFO_PWKGWK(x) \
( (x) ? \
((x)->hdr.keyInfo |= KEY_INFO_PWK|KEY_INFO_GWK) : 0)
#define SET_KEY_INFO_PWK(x) \
( (x) ? ((x)->hdr.keyInfo |= KEY_INFO_PWK, \
((x)->hdr.keyInfo &= ~KEY_INFO_GWK)) : 0 )
#define SET_KEY_INFO_GWK(x) \
( (x) ? ((x)->hdr.keyInfo |= KEY_INFO_GWK, \
((x)->hdr.keyInfo &= ~KEY_INFO_PWK)): 0 )
#define SET_KEY_INFO_GLOBAL(x) \
( (x) ? ((x)->hdr.keyInfo |= KEY_INFO_GLOBAL) : 0 )
#define IS_KEY_INFO_GLOBAL(x) \
( (x) ? ((x)->hdr.keyInfo & KEY_INFO_GLOBAL) : 0 )
#define SET_KEY_STATE_ENABLED(x, state) (((state) == TRUE) ? \
((x)->hdr.keyState |= KEY_STATE_ENABLE) \
: ((x)->hdr.keyState &= ~KEY_STATE_ENABLE) )
#define IS_KEY_STATE_ENABLED(x) \
( (x) ? ((x)->hdr.keyState & KEY_STATE_ENABLE) : 0 )
#define IS_KEY_STATE_FORCE_EAPOL_UNENCRYPTED(x) \
( (x) ? \
((x)->hdr.keyState & KEY_STATE_FORCE_EAPOL_UNENCRYPTED) : 0)
#define SET_KEY_STATE_FORCE_EAPOL_UNENCRYPTED(x,state) \
(((state) == TRUE) ? \
((x)->hdr.keyState |= KEY_STATE_FORCE_EAPOL_UNENCRYPTED) \
: ((x)->hdr.keyState &= ~KEY_STATE_FORCE_EAPOL_UNENCRYPTED) )
typedef MLAN_PACK_START struct {
IEEEtypes_MacAddr_t macAddr;
UINT8 keyDirection;
UINT8 keyType;
UINT16 keyLen;
UINT8 keyAction;
UINT8 keyInfo;
} MLAN_PACK_END nwf_key_mgthdr_t;
/* host command for GET/SET Key Material */
typedef MLAN_PACK_START struct {
UINT16 Action;
nwf_key_mgthdr_t key_material;
} MLAN_PACK_END host_802_11_NWF_Key_Material_t;
/* host command for set wep parameters in Vista uses different struct
from the one we use in FW */
typedef MLAN_PACK_START struct host_802_11_wep_key {
UINT8 WepDefaultKeyIdx; /* 1 to 4 */
UINT8 WepDefaultKeyValue[WEP_KEY_USER_INPUT]; /* 5 byte string */
} MLAN_PACK_END host_802_11_wep_key_t;
typedef struct host_802_11_wep_key_data_t {
host_802_11_wep_key_t WepDefaultKeys[MAX_WEP_KEYS];
UINT8 default_key_idx;
UINT8 Reserved1[3];
} host_802_11_wep_key_data_t;
typedef UINT32 buffer_t;
typedef struct cipher_key_buf {
struct cipher_key_buf_t *prev;
struct cipher_key_buf_t *next;
cipher_key_t cipher_key;
} cipher_key_buf_t;
#define CIPHER_KEYS_BUF_SIZE (sizeof(cipher_key_buf_t))
#define CIPHER_KEYS_BUF_NUM (CM_MAX_CONNECTIONS)
#endif /* KEY_API_STA_H__ end */

View File

@@ -0,0 +1,231 @@
/** @file keyCommonDef.h
*
* @brief This file contains normal data type for key management
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEYMGMT_COMMON_H_
#define _KEYMGMT_COMMON_H_
#include "wltypes.h"
#include "IEEE_types.h"
#include "wl_mib_rom.h"
#include "KeyApiStaDefs.h"
#define NONCE_SIZE 32
#define EAPOL_MIC_KEY_SIZE 16
#define EAPOL_MIC_SIZE 16
#define EAPOL_ENCR_KEY_SIZE 16
#define MAC_ADDR_SIZE 6
#define TK_SIZE 16
#define HDR_8021x_LEN 4
#define KEYMGMTTIMEOUTVAL 10
#define TDLS_MIC_KEY_SIZE 16
#define EAPOL_PROTOCOL_V1 1
#define EAPOL_PROTOCOL_V2 2
#define UAP_HOSTCMD_KEYMGMT_EAP BIT0
#define UAP_HOSTCMD_KEYMGMT_PSK BIT1
#define UAP_HOSTCMD_KEYMGMT_NONE BIT2
#define UAP_HOSTCMD_KEYMGMT_PSK_SHA256 BIT8
#define UAP_HOSTCMD_CIPHER_WEP40 0x01
#define UAP_HOSTCMD_CIPHER_WEP104 0x02
#define UAP_HOSTCMD_CIPHER_TKIP 0x04
#define UAP_HOSTCMD_CIPHER_CCMP 0x08
#define UAP_HOSTCMD_CIPHER_MASK 0x0F
typedef struct {
UINT8 Key[TK_SIZE];
UINT8 RxMICKey[8];
UINT8 TxMICKey[8];
UINT32 TxIV32;
UINT16 TxIV16;
UINT16 KeyIndex;
} KeyData_t;
#define MAX_WEP_KEYS 4
/* This structure is used in rom and existing fields should not be changed */
/* This structure is already aligned and hence packing is not needed */
typedef struct cipher_key_hdr_t {
IEEEtypes_MacAddr_t macAddr;
UINT8 keyDirection;
UINT8 keyType:4;
UINT8 version:4;
UINT16 keyLen;
UINT8 keyState;
UINT8 keyInfo;
} cipher_key_hdr_t;
/* This structure is used in rom and existing fields should not be changed */
typedef struct tkip_aes_key_data_t {
// key material information (TKIP/AES/WEP)
UINT8 key[CRYPTO_KEY_LEN_MAX];
UINT8 txMICKey[MIC_KEY_LEN_MAX];
UINT8 rxMICKey[MIC_KEY_LEN_MAX];
UINT32 hiReplayCounter32; //!< initialized by host
UINT16 loReplayCounter16; //!< initialized by host
UINT32 txIV32; //!< controlled by FW
UINT16 txIV16; //!< controlled by FW
UINT32 TKIPMicLeftValue;
UINT32 TKIPMicRightValue;
/* HW new design for 8682 only to support interleaving
* FW need to save these value and
* restore for next fragment
*/
UINT32 TKIPMicData0Value;
UINT32 TKIPMicData1Value;
UINT32 TKIPMicData2Value;
UINT8 keyIdx;
UINT8 reserved[3];
} tkip_aes_key_data_t;
/* This structure is used in rom and existing fields should not be changed */
typedef struct wep_key_data_t {
MIB_WEP_DEFAULT_KEYS WepDefaultKeys[MAX_WEP_KEYS];
UINT8 default_key_idx;
UINT8 keyCfg;
UINT8 Reserved;
} wep_key_data_t;
/* This structure is used in rom and existing fields should not be changed */
typedef struct {
UINT8 key_idx;
UINT8 mickey[WAPI_MIC_LEN];
UINT8 rawkey[WAPI_KEY_LEN];
} wapi_key_detail_t;
/* cipher_key_t -> tkip_aes is much bigger than wapi_key_data_t and
* since wapi_key_data_t is not used by ROM it is ok to change this size. */
typedef struct {
wapi_key_detail_t key;
UINT8 pn_inc;
UINT8 TxPN[WAPI_PN_LEN];
UINT8 RxPN[WAPI_PN_LEN];
UINT8 *pLastKey; //keep the orig cipher_key_t pointer
} wapi_key_data_t;
typedef struct {
UINT8 ANonce[NONCE_SIZE];
KeyData_t pwsKeyData;
} eapolHskData_t;
/* This structure is used in rom and existing fields should not be changed */
typedef struct cipher_key_t {
cipher_key_hdr_t hdr;
union ckd {
tkip_aes_key_data_t tkip_aes;
wep_key_data_t wep;
wapi_key_data_t wapi;
eapolHskData_t hskData;
} ckd;
} cipher_key_t;
typedef MLAN_PACK_START struct {
UINT8 protocol_ver;
IEEEtypes_8021x_PacketType_e pckt_type;
UINT16 pckt_body_len;
} MLAN_PACK_END Hdr_8021x_t;
typedef MLAN_PACK_START struct {
/* don't change this order. It is set to match the
** endianness of the message
*/
/* Byte 1 */
UINT16 KeyMIC:1; /* Bit 8 */
UINT16 Secure:1; /* Bit 9 */
UINT16 Error:1; /* Bit 10 */
UINT16 Request:1; /* Bit 11 */
UINT16 EncryptedKeyData:1; /* Bit 12 */
UINT16 Reserved:3; /* Bits 13-15 */
/* Byte 0 */
UINT16 KeyDescriptorVersion:3; /* Bits 0-2 */
UINT16 KeyType:1; /* Bit 3 */
UINT16 KeyIndex:2; /* Bits 4-5 */
UINT16 Install:1; /* Bit 6 */
UINT16 KeyAck:1; /* Bit 7 */
} MLAN_PACK_END key_info_t;
#define KEY_DESCRIPTOR_HMAC_MD5_RC4 (1U << 0)
#define KEY_DESCRIPTOR_HMAC_SHA1_AES (1U << 1)
#define EAPOL_KeyMsg_Len (100)
/* WPA2 GTK IE */
typedef MLAN_PACK_START struct {
UINT8 KeyID:2;
UINT8 Tx:1;
UINT8 rsvd:5;
UINT8 rsvd1;
UINT8 GTK[1];
} MLAN_PACK_END GTK_KDE_t;
/* WPA2 Key Data */
typedef MLAN_PACK_START struct {
UINT8 type;
UINT8 length;
UINT8 OUI[3];
UINT8 dataType;
UINT8 data[1];
} MLAN_PACK_END KDE_t;
typedef MLAN_PACK_START struct {
uint8 llc[3];
uint8 snap_oui[3];
uint16 snap_type;
} MLAN_PACK_END llc_snap_t;
typedef MLAN_PACK_START struct {
Hdr_8021x_t hdr_8021x;
UINT8 desc_type;
key_info_t key_info;
UINT16 key_length;
UINT32 replay_cnt[2];
UINT8 key_nonce[NONCE_SIZE]; /*32 bytes */
UINT8 EAPOL_key_IV[16];
UINT8 key_RSC[8];
UINT8 key_ID[8];
UINT8 key_MIC[EAPOL_MIC_KEY_SIZE];
UINT16 key_material_len;
UINT8 key_data[1];
} MLAN_PACK_END EAPOL_KeyMsg_t;
typedef MLAN_PACK_START struct {
Hdr_8021x_t hdr_8021x;
IEEEtypes_8021x_CodeType_e code;
UINT8 identifier;
UINT16 length;
UINT8 data[1];
} MLAN_PACK_END EAP_PacketMsg_t;
typedef MLAN_PACK_START struct {
ether_hdr_t ethHdr;
EAPOL_KeyMsg_t keyMsg;
} MLAN_PACK_END EAPOL_KeyMsg_Tx_t;
#endif

View File

@@ -0,0 +1,967 @@
/** @file keyMgntAP.c
*
* @brief This file defined the eapol paket process and key management for authenticator
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
//Authenticator related function definitions
#include "wltypes.h"
#include "IEEE_types.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "wl_macros.h"
#include "wlpd.h"
#include "pass_phrase.h"
#include "sha1.h"
#include "crypt_new.h"
#include "parser.h"
#include "keyCommonDef.h"
#include "keyMgmtStaTypes.h"
#include "AssocAp_srv_rom.h"
#include "pmkCache.h"
#include "keyMgmtApTypes.h"
#include "keyMgmtAp.h"
#include "rc4.h"
#include "authenticator_api.h"
//////////////////////
// STATIC FUNCTIONS
//////////////////////
//#ifdef AUTHENTICATOR
////////////////////////
// FORWARD DECLARATIONS
////////////////////////
Status_e GeneratePWKMsg3(hostsa_private *priv, cm_Connection *connPtr);
Status_e GenerateGrpMsg1(hostsa_private *priv, cm_Connection *connPtr);
Status_e GenerateApEapolMsg(hostsa_private *priv,
t_void *pconnPtr, keyMgmtState_e msgState);
static void
handleFailedHSK(t_void *priv, t_void *pconnPtr, IEEEtypes_ReasonCode_t reason)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_mlan_fns *pm_fns = &psapriv->mlan_fns;
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
KeyMgmtStopHskTimer(connPtr);
pm_fns->hostsa_SendDeauth(pm_fns->pmlan_private, connPtr->mac_addr,
(t_u16)reason);
}
static void
incrementReplayCounter(apKeyMgmtInfoSta_t *pKeyMgmtInfo)
{
if (++pKeyMgmtInfo->counterLo == 0) {
pKeyMgmtInfo->counterHi++;
}
}
int
isValidReplayCount(t_void *priv, apKeyMgmtInfoSta_t *pKeyMgmtInfo,
UINT8 *pRxReplayCount)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
UINT32 rxCounterHi;
UINT32 rxCounterLo;
memcpy(util_fns, &rxCounterHi, pRxReplayCount, 4);
memcpy(util_fns, &rxCounterLo, pRxReplayCount + 4, 4);
if ((pKeyMgmtInfo->counterHi == WORD_SWAP(rxCounterHi)) &&
(pKeyMgmtInfo->counterLo == WORD_SWAP(rxCounterLo))) {
return 1;
}
return 0;
}
void
KeyMgmtSendGrpKeyMsgToAllSta(hostsa_private *priv)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
cm_Connection *connPtr = MNULL;
t_void *sta_node = MNULL;
ENTER();
pm_fns->Hostsa_find_connection(priv->pmlan_private, (t_void *)&connPtr,
&sta_node);
while (connPtr != MNULL) {
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
if (pKeyMgmtInfo->rom.keyMgmtState == HSK_END) {
GenerateApEapolMsg(priv, connPtr,
GRP_REKEY_MSG1_PENDING);
} else if ((pKeyMgmtInfo->rom.keyMgmtState == WAITING_4_GRPMSG2)
|| (pKeyMgmtInfo->rom.staSecType.wpa2 &&
(pKeyMgmtInfo->rom.keyMgmtState ==
WAITING_4_MSG4)) ||
(pKeyMgmtInfo->rom.keyMgmtState ==
WAITING_4_GRP_REKEY_MSG2)) {
// TODO:How to handle group rekey if either Groupwise handshake
// Group rekey is already in progress for this STA?
}
pm_fns->Hostsa_find_next_connection(priv->pmlan_private,
(t_void *)&connPtr,
&sta_node);
}
LEAVE();
}
UINT32
keyApi_ApUpdateKeyMaterial(void *priv, cm_Connection *connPtr,
BOOLEAN updateGrpKey)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
hostsa_mlan_fns *pm_fns = &psapriv->mlan_fns;
BssConfig_t *pBssConfig = MNULL;
KeyData_t *pKeyData = MNULL;
//cipher_key_buf_t *pCipherKeyBuf;
Cipher_t *pCipher = MNULL;
//KeyData_t pwsKeyData;
mlan_ds_encrypt_key encrypt_key;
t_u8 bcast_addr[MAC_ADDR_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
apInfo_t *pApInfo = &psapriv->apinfo;
pBssConfig = &pApInfo->bssConfig;
if (pBssConfig->SecType.wpa || pBssConfig->SecType.wpa2) {
memset(util_fns, &encrypt_key, 0, sizeof(mlan_ds_encrypt_key));
//connPtr->cmFlags.RSNEnabled = TRUE;
if (updateGrpKey == TRUE) {
pKeyData = &pApInfo->bssData.grpKeyData;
pCipher = &pBssConfig->RsnConfig.mcstCipher;
} else if (connPtr) {
/* pCipherKeyBuf = connPtr->pwTxRxCipherKeyBuf;
memcpy((void*)&pwsKeyData,
(void*)&pCipherKeyBuf->cipher_key.ckd.hskData.pwsKeyData,
sizeof(KeyData_t)); */
pKeyData = &connPtr->hskData.pwsKeyData;
pCipher =
&connPtr->staData.keyMgmtInfo.rom.staUcstCipher;
}
if (updateGrpKey == TRUE) {
memcpy(util_fns, encrypt_key.mac_addr, bcast_addr,
MAC_ADDR_SIZE);
encrypt_key.key_flags |= KEY_FLAG_GROUP_KEY;
} else if (connPtr) {
memcpy(util_fns, encrypt_key.mac_addr,
connPtr->mac_addr, MAC_ADDR_SIZE);
encrypt_key.key_flags |= KEY_FLAG_SET_TX_KEY;
}
if (!pKeyData || !pCipher) {
PRINTM(MERROR, "Invalid KeyData or Cipher pointer!\n");
return 1;
}
if (pCipher->ccmp) {
/**AES*/
encrypt_key.key_len = TK_SIZE;
memcpy(util_fns, encrypt_key.key_material,
pKeyData->Key, TK_SIZE);
} else if (pCipher->tkip) {
/**TKIP*/
encrypt_key.key_len =
TK_SIZE + MIC_KEY_SIZE + MIC_KEY_SIZE;
memcpy(util_fns, encrypt_key.key_material,
pKeyData->Key, TK_SIZE);
memcpy(util_fns, &encrypt_key.key_material[TK_SIZE],
pKeyData->TxMICKey, MIC_KEY_SIZE);
memcpy(util_fns,
&encrypt_key.key_material[TK_SIZE +
MIC_KEY_SIZE],
pKeyData->RxMICKey, MIC_KEY_SIZE);
}
/**set pn 0*/
memset(util_fns, encrypt_key.pn, 0, PN_SIZE);
/**key flag*/
encrypt_key.key_flags |= KEY_FLAG_RX_SEQ_VALID;
/**key index*/
encrypt_key.key_index = pKeyData->KeyIndex;
/**set command to fw update key*/
pm_fns->hostsa_set_encrypt_key(psapriv->pmlan_private,
&encrypt_key);
}
return 0;
}
void
GenerateGTK(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
apInfo_t *pApInfo = &psapriv->apinfo;
BssData_t *pBssData = MNULL;
pBssData = &pApInfo->bssData;
GenerateGTK_internal(psapriv, &pBssData->grpKeyData,
pBssData->GNonce, psapriv->curr_addr);
}
void
ReInitGTK(t_void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
apInfo_t *pApInfo = &psapriv->apinfo;
BssData_t *pBssData;
pBssData = &pApInfo->bssData;
/*
Disabled for interop
Not all clients like this
pBssData->grpKeyData.KeyIndex = (pBssData->grpKeyData.KeyIndex & 3) + 1;
*/
ROM_InitGTK(psapriv, &pBssData->grpKeyData,
pBssData->GNonce, psapriv->curr_addr);
keyApi_ApUpdateKeyMaterial(priv, MNULL, MTRUE);
}
void
KeyMgmtGrpRekeyCountUpdate(t_void *context)
{
phostsa_private psapriv = (phostsa_private)context;
apInfo_t *pApInfo = &psapriv->apinfo;
hostsa_util_fns *putil_fns = &psapriv->util_fns;
ENTER();
if (psapriv->GrpRekeyTimerIsSet &&
pApInfo->bssData.grpRekeyCntRemaining) {
//Periodic group rekey is configured.
pApInfo->bssData.grpRekeyCntRemaining--;
if (!pApInfo->bssData.grpRekeyCntRemaining) {
//Group rekey timeout hit.
pApInfo->bssData.grpRekeyCntRemaining
= pApInfo->bssData.grpRekeyCntConfigured;
ReInitGTK((t_void *)psapriv);
KeyMgmtSendGrpKeyMsgToAllSta(psapriv);
}
/**start Group rekey timer*/
putil_fns->moal_start_timer(putil_fns->pmoal_handle,
psapriv->GrpRekeytimer,
MFALSE, MRVDRV_TIMER_60S);
}
LEAVE();
}
void
KeyMgmtInit(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
apInfo_t *pApInfo = &psapriv->apinfo;
UINT8 *pPassPhrase;
UINT8 *pPskValue;
UINT8 passPhraseLen;
pPassPhrase = pApInfo->bssConfig.RsnConfig.PSKPassPhrase;
pPskValue = pApInfo->bssConfig.RsnConfig.PSKValue;
passPhraseLen = pApInfo->bssConfig.RsnConfig.PSKPassPhraseLen;
ROM_InitGTK(psapriv, &pApInfo->bssData.grpKeyData,
pApInfo->bssData.GNonce, psapriv->curr_addr);
if (pApInfo->bssData.updatePassPhrase == MTRUE) {
pmkCacheGeneratePSK(priv, pApInfo->bssConfig.SsId,
pApInfo->bssConfig.SsIdLen,
(char *)pPassPhrase, pPskValue);
pApInfo->bssData.updatePassPhrase = MFALSE;
}
}
void
KeyMgmtHskTimeout(t_void *context)
{
cm_Connection *connPtr = (cm_Connection *)context;
phostsa_private priv = (phostsa_private)connPtr->priv;
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
apRsnConfig_t *pRsnConfig;
IEEEtypes_ReasonCode_t reason;
BOOLEAN maxRetriesDone = MFALSE;
apInfo_t *pApInfo = &priv->apinfo;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
pRsnConfig = &pApInfo->bssConfig.RsnConfig;
connPtr->timer_is_set = 0;
/* Assume when this function gets called pKeyMgmtInfo->keyMgmtState
** will not be in HSK_NOT_STARTED or HSK_END
*/
if (pKeyMgmtInfo->rom.keyMgmtState <= WAITING_4_MSG4) {
if (pKeyMgmtInfo->numHskTries >= pRsnConfig->MaxPwsHskRetries) {
maxRetriesDone = MTRUE;
reason = IEEEtypes_REASON_4WAY_HANDSHK_TIMEOUT;
}
} else {
if (pKeyMgmtInfo->numHskTries >= pRsnConfig->MaxGrpHskRetries) {
maxRetriesDone = MTRUE;
reason = IEEEtypes_REASON_GRP_KEY_UPD_TIMEOUT;
}
}
if (maxRetriesDone) {
// Some STAs do not respond to PWK Msg1 if the EAPOL Proto Version is 1
// in 802.1X header, hence switch to v2 after all attempts with v1 fail
// for PWK Msg1. Set the HskTimeoutCtn to 1 to get the same "retries"
// as with v1.
if (((WAITING_4_MSG2 == pKeyMgmtInfo->rom.keyMgmtState)
|| (MSG1_PENDING == pKeyMgmtInfo->rom.keyMgmtState))
&& (EAPOL_PROTOCOL_V1 == pKeyMgmtInfo->EAPOLProtoVersion)) {
pKeyMgmtInfo->numHskTries = 1;
pKeyMgmtInfo->EAPOLProtoVersion = EAPOL_PROTOCOL_V2;
GenerateApEapolMsg(priv, connPtr,
pKeyMgmtInfo->rom.keyMgmtState);
} else {
pm_fns->hostsa_SendDeauth(priv->pmlan_private,
connPtr->mac_addr,
(t_u16)reason);
pKeyMgmtInfo->rom.keyMgmtState = HSK_END;
}
} else {
GenerateApEapolMsg(priv, connPtr,
pKeyMgmtInfo->rom.keyMgmtState);
}
return;
}
void
KeyMgmtStartHskTimer(void *context)
{
cm_Connection *connPtr = (cm_Connection *)context;
phostsa_private psapriv = (phostsa_private)(connPtr->priv);
hostsa_util_fns *util_fns = &psapriv->util_fns;
apInfo_t *pApInfo = MNULL;
UINT32 timeoutInms;
apRsnConfig_t *pRsnConfig;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
pApInfo = &psapriv->apinfo;
pRsnConfig = &pApInfo->bssConfig.RsnConfig;
if ((connPtr->staData.keyMgmtInfo.rom.keyMgmtState >= MSG1_PENDING)
&& (connPtr->staData.keyMgmtInfo.rom.keyMgmtState <=
WAITING_4_MSG4)) {
timeoutInms = pRsnConfig->PwsHskTimeOut;
} else if ((connPtr->staData.keyMgmtInfo.rom.keyMgmtState >=
GRPMSG1_PENDING)
&& (connPtr->staData.keyMgmtInfo.rom.keyMgmtState <=
WAITING_4_GRP_REKEY_MSG2)) {
timeoutInms = pRsnConfig->GrpHskTimeOut;
} else {
//EAPOL HSK is not in progress. No need to start HSK timer
return;
}
// Retry happen, increase timeout to at least 1 sec
if (connPtr->staData.keyMgmtInfo.numHskTries > 0) {
timeoutInms = MAX(AP_RETRY_EAPOL_HSK_TIMEOUT, timeoutInms);
}
/* if STA is in PS1 then we are using max(STA_PS_EAPOL_HSK_TIMEOUT,
* HSKtimeout)for timeout instead of configured timeout value
*/
/* if(PWR_MODE_PWR_SAVE == connPtr->staData.pwrSaveInfo.mode)
{
timeoutInms = MAX(STA_PS_EAPOL_HSK_TIMEOUT, timeoutInms);
}
*/
util_fns->moal_start_timer(util_fns->pmoal_handle,
connPtr->HskTimer, MFALSE, timeoutInms);
connPtr->timer_is_set = 1;
}
void
KeyMgmtStopHskTimer(t_void *pconnPtr)
{
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
phostsa_private priv = (phostsa_private)connPtr->priv;
hostsa_util_fns *util_fns = &priv->util_fns;
util_fns->moal_stop_timer(util_fns->pmoal_handle, connPtr->HskTimer);
connPtr->timer_is_set = 0;
}
void
PrepDefaultEapolMsg(phostsa_private priv, cm_Connection *connPtr,
EAPOL_KeyMsg_Tx_t **pTxEapolPtr, pmlan_buffer pmbuf)
{
hostsa_util_fns *util_fns = &priv->util_fns;
apInfo_t *pApInfo = &priv->apinfo;
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
UINT8 intf_hr_len =
pm_fns->Hostsa_get_intf_hr_len(pm_fns->pmlan_private);
#define UAP_EAPOL_PRIORITY 7 /* Voice */
ENTER();
pmbuf->priority = UAP_EAPOL_PRIORITY;
pmbuf->buf_type = MLAN_BUF_TYPE_DATA;
pmbuf->data_offset = (sizeof(UapTxPD) + intf_hr_len + DMA_ALIGNMENT);
tx_eapol_ptr =
(EAPOL_KeyMsg_Tx_t *)((UINT8 *)pmbuf->pbuf +
pmbuf->data_offset);
memset(util_fns, (UINT8 *)tx_eapol_ptr, 0x00,
sizeof(EAPOL_KeyMsg_Tx_t));
formEAPOLEthHdr(priv, tx_eapol_ptr, connPtr->mac_addr, priv->curr_addr);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
SetEAPOLKeyDescTypeVersion(tx_eapol_ptr,
pKeyMgmtInfo->rom.staSecType.wpa2,
MFALSE,
(pKeyMgmtInfo->rom.staUcstCipher.ccmp ||
pApInfo->bssConfig.RsnConfig.mcstCipher.
ccmp));
*pTxEapolPtr = tx_eapol_ptr;
LEAVE();
}
Status_e
GeneratePWKMsg1(hostsa_private *priv, cm_Connection *connPtr)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr;
UINT16 frameLen = 0, packet_len = 0;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
UINT32 replay_cnt[2];
eapolHskData_t *pHskData;
pmlan_buffer pmbuf = MNULL;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
pmbuf = pm_fns->hostsa_alloc_mlan_buffer(priv->pmlan_adapter,
MLAN_TX_DATA_BUF_SIZE_2K, 0,
MOAL_MALLOC_BUFFER);
if (pmbuf == NULL) {
PRINTM(MERROR, "allocate buffer fail for eapol \n");
return FAIL;
}
PrepDefaultEapolMsg(priv, connPtr, &tx_eapol_ptr, pmbuf);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
pHskData = &connPtr->hskData;
incrementReplayCounter(pKeyMgmtInfo);
replay_cnt[0] = pKeyMgmtInfo->counterHi;
replay_cnt[1] = pKeyMgmtInfo->counterLo;
supplicantGenerateRand(priv, pHskData->ANonce, NONCE_SIZE);
PopulateKeyMsg(priv, tx_eapol_ptr,
&pKeyMgmtInfo->rom.staUcstCipher,
PAIRWISE_KEY_MSG, replay_cnt, pHskData->ANonce);
frameLen = EAPOL_KeyMsg_Len - sizeof(Hdr_8021x_t)
- sizeof(tx_eapol_ptr->keyMsg.key_data)
+ tx_eapol_ptr->keyMsg.key_material_len; //key_mtr_len is 0 here
packet_len = frameLen + sizeof(Hdr_8021x_t) + sizeof(ether_hdr_t);
tx_eapol_ptr->keyMsg.hdr_8021x.protocol_ver
= pKeyMgmtInfo->EAPOLProtoVersion;
tx_eapol_ptr->keyMsg.hdr_8021x.pckt_type
= IEEE_8021X_PACKET_TYPE_EAPOL_KEY;
tx_eapol_ptr->keyMsg.hdr_8021x.pckt_body_len = htons(frameLen);
UpdateEAPOLWcbLenAndTransmit(priv, pmbuf, packet_len);
return SUCCESS;
}
// returns 0 on success, or error code
Status_e
ProcessPWKMsg2(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len)
{
EAPOL_KeyMsg_t *rx_eapol_ptr;
UINT8 *PMK;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
BssConfig_t *pBssConfig = NULL;
IEPointers_t iePointers;
UINT32 ieLen;
UINT8 *pIe = NULL;
apInfo_t *pApInfo = &priv->apinfo;
Cipher_t wpaUcastCipher;
Cipher_t wpa2UcastCipher;
eapolHskData_t *pHskData = &connPtr->hskData;
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
rx_eapol_ptr = (EAPOL_KeyMsg_t *)(pbuf + ETHII_HEADER_LEN);
pBssConfig = &pApInfo->bssConfig;
// compare the RSN IE from assoc req to current
pIe = (UINT8 *)rx_eapol_ptr->key_data;
ieLen = pIe[1] + sizeof(IEEEtypes_InfoElementHdr_t);
GetIEPointers((void *)priv, pIe, ieLen, &iePointers);
wpaUcastCipher = pBssConfig->RsnConfig.wpaUcstCipher;
wpa2UcastCipher = pBssConfig->RsnConfig.wpa2UcstCipher;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
if (assocSrvAp_checkRsnWpa(connPtr, &pKeyMgmtInfo->rom,
wpaUcastCipher,
wpa2UcastCipher,
pBssConfig->RsnConfig.mcstCipher,
pBssConfig->RsnConfig.AuthKey,
&pKeyMgmtInfo->rom.staSecType,
iePointers.pRsn,
iePointers.pWpa, TRUE) == FAIL) {
handleFailedHSK(priv, connPtr, IEEEtypes_REASON_IE_4WAY_DIFF);
return FAIL;
}
PMK = pApInfo->bssConfig.RsnConfig.PSKValue;
KeyMgmtAp_DerivePTK(priv, PMK,
connPtr->mac_addr,
priv->curr_addr,
pHskData->ANonce,
rx_eapol_ptr->key_nonce,
pKeyMgmtInfo->EAPOL_MIC_Key,
pKeyMgmtInfo->EAPOL_Encr_Key,
&pHskData->pwsKeyData, MFALSE);
if (!IsEAPOL_MICValid(priv, rx_eapol_ptr, pKeyMgmtInfo->EAPOL_MIC_Key)) {
return FAIL;
}
KeyMgmtStopHskTimer(connPtr);
connPtr->staData.keyMgmtInfo.numHskTries = 0;
return GenerateApEapolMsg(priv, connPtr, MSG3_PENDING);
}
Status_e
GeneratePWKMsg3(hostsa_private *priv, cm_Connection *connPtr)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr;
UINT16 frameLen = 0, packet_len = 0;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
apInfo_t *pApInfo = &priv->apinfo;
BssConfig_t *pBssConfig = MNULL;
UINT32 replay_cnt[2];
eapolHskData_t *pHskData;
pmlan_buffer pmbuf = MNULL;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
pmbuf = pm_fns->hostsa_alloc_mlan_buffer(priv->pmlan_adapter,
MLAN_TX_DATA_BUF_SIZE_2K, 0,
MOAL_MALLOC_BUFFER);
if (pmbuf == NULL) {
PRINTM(MERROR, "allocate buffer fail for eapol \n");
return FAIL;
}
PrepDefaultEapolMsg(priv, connPtr, &tx_eapol_ptr, pmbuf);
pBssConfig = &pApInfo->bssConfig;
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
pHskData = &connPtr->hskData;
incrementReplayCounter(pKeyMgmtInfo);
replay_cnt[0] = pKeyMgmtInfo->counterHi;
replay_cnt[1] = pKeyMgmtInfo->counterLo;
PopulateKeyMsg(priv, tx_eapol_ptr,
&pKeyMgmtInfo->rom.staUcstCipher,
((PAIRWISE_KEY_MSG | SECURE_HANDSHAKE_FLAG) |
((pKeyMgmtInfo->rom.staSecType.
wpa2) ? WPA2_HANDSHAKE : 0)), replay_cnt,
pHskData->ANonce);
/*if (pKeyMgmtInfo->staSecType.wpa2)
{
// Netgear WAG511 and USB55 cards don't like this field set to
// anything other than zero. Hence hard code this value to zero
// in all outbound EAPOL frames...
// The client is now vulnerable to replay attacks from the point
// it receives EAP-message3 till reception of first management
// frame from uAP.
tx_eapol_ptr->keyMsg.key_RSC[0] =
pApInfo->bssConfig.grpKeyData.TxIV16 & 0x00FF;
tx_eapol_ptr->keyMsg.key_RSC[1] =
(pApInfo->bssConfig.grpKeyData.TxIV16 >> 8) & 0x00FF;
memcpy((void*)(tx_eapol_ptr->keyMsg.key_RSC + 2),
&pApInfo->bssData.grpKeyData.TxIV32, 4);
} */
/*
pBcnFrame = (dot11MgtFrame_t *)BML_DATA_PTR(connPtr->pBcnBufferDesc);
if (pKeyMgmtInfo->rom.staSecType.wpa)
{
pWpaIE = syncSrv_ParseAttrib(pBcnFrame,
ELEM_ID_VENDOR_SPECIFIC,
IEEE_MSG_BEACON,
(UINT8 *)wpa_oui01,
sizeof(wpa_oui01));
}
else if (pKeyMgmtInfo->rom.staSecType.wpa2)
{
pWpa2IE = syncSrv_ParseAttrib(pBcnFrame,
ELEM_ID_RSN,
IEEE_MSG_BEACON,
NULL,
0);
}*/
if (!KeyData_UpdateKeyMaterial(priv, tx_eapol_ptr,
&pKeyMgmtInfo->rom.staSecType,
pBssConfig->wpa_ie,
pBssConfig->rsn_ie)) {
/* We have WPA/WPA2 enabled but no corresponding IE */
pm_fns->hostsa_free_mlan_buffer(pm_fns->pmlan_adapter, pmbuf);
return FAIL;
}
if (pKeyMgmtInfo->rom.staSecType.wpa2) { // WPA2
prepareKDE(priv, tx_eapol_ptr,
&pApInfo->bssData.grpKeyData,
&pApInfo->bssConfig.RsnConfig.mcstCipher);
if (!Encrypt_keyData((t_void *)priv, tx_eapol_ptr,
pKeyMgmtInfo->EAPOL_Encr_Key,
&pKeyMgmtInfo->rom.staUcstCipher))
{
pm_fns->hostsa_free_mlan_buffer(pm_fns->pmlan_adapter,
pmbuf);
return FAIL;
}
}
frameLen = KeyMgmtSta_PopulateEAPOLLengthMic(priv,
tx_eapol_ptr,
pKeyMgmtInfo->
EAPOL_MIC_Key,
pKeyMgmtInfo->
EAPOLProtoVersion,
tx_eapol_ptr->keyMsg.
key_info.
KeyDescriptorVersion);
packet_len = frameLen + sizeof(Hdr_8021x_t) + sizeof(ether_hdr_t);
UpdateEAPOLWcbLenAndTransmit(priv, pmbuf, packet_len);
return SUCCESS;
}
Status_e
ProcessPWKMsg4(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_t *rx_eapol_ptr;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
eapolHskData_t *pHskData = &connPtr->hskData;
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
rx_eapol_ptr = (EAPOL_KeyMsg_t *)(pbuf + ETHII_HEADER_LEN);
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
if (!IsEAPOL_MICValid(priv, rx_eapol_ptr, pKeyMgmtInfo->EAPOL_MIC_Key)) {
return FAIL;
}
pHskData->pwsKeyData.TxIV16 = 0x0001;
pHskData->pwsKeyData.TxIV32 = 0;
if (keyApi_ApUpdateKeyMaterial(priv, connPtr, FALSE)) {
handleFailedHSK(priv, connPtr, IEEEtypes_REASON_UNSPEC);
return FAIL;
}
KeyMgmtStopHskTimer(connPtr);
connPtr->staData.keyMgmtInfo.numHskTries = 0;
if (pKeyMgmtInfo->rom.staSecType.wpa2) {
pm_fns->Hostsa_sendEventRsnConnect(priv->pmlan_private,
connPtr->mac_addr);
pKeyMgmtInfo->rom.keyMgmtState = HSK_END;
} else {
return GenerateApEapolMsg(priv, connPtr, GRPMSG1_PENDING);
}
return SUCCESS;
}
Status_e
GenerateGrpMsg1(hostsa_private *priv, cm_Connection *connPtr)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr;
UINT16 frameLen = 0, packet_len = 0;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
apInfo_t *pApInfo = &priv->apinfo;
UINT32 replay_cnt[2];
pmlan_buffer pmbuf = MNULL;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
pmbuf = pm_fns->hostsa_alloc_mlan_buffer(priv->pmlan_adapter,
MLAN_TX_DATA_BUF_SIZE_2K, 0,
MOAL_MALLOC_BUFFER);
if (pmbuf == NULL) {
PRINTM(MERROR, "allocate buffer fail for eapol \n");
return FAIL;
}
PrepDefaultEapolMsg(priv, connPtr, &tx_eapol_ptr, pmbuf);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
incrementReplayCounter(pKeyMgmtInfo);
replay_cnt[0] = pKeyMgmtInfo->counterHi;
replay_cnt[1] = pKeyMgmtInfo->counterLo;
PopulateKeyMsg(priv, tx_eapol_ptr,
&pApInfo->bssConfig.RsnConfig.mcstCipher,
(SECURE_HANDSHAKE_FLAG |
((pKeyMgmtInfo->rom.staSecType.
wpa2) ? WPA2_HANDSHAKE : 0)), replay_cnt,
pApInfo->bssData.GNonce);
KeyData_AddKey(priv,
tx_eapol_ptr,
&pKeyMgmtInfo->rom.staSecType,
&pApInfo->bssData.grpKeyData,
&pApInfo->bssConfig.RsnConfig.mcstCipher);
if (!Encrypt_keyData(priv, tx_eapol_ptr,
pKeyMgmtInfo->EAPOL_Encr_Key,
&pKeyMgmtInfo->rom.staUcstCipher))
{
// nothing here.
}
frameLen = KeyMgmtSta_PopulateEAPOLLengthMic(priv,
tx_eapol_ptr,
pKeyMgmtInfo->
EAPOL_MIC_Key,
pKeyMgmtInfo->
EAPOLProtoVersion,
tx_eapol_ptr->keyMsg.
key_info.
KeyDescriptorVersion);
packet_len = frameLen + sizeof(Hdr_8021x_t) + sizeof(ether_hdr_t);
UpdateEAPOLWcbLenAndTransmit(priv, pmbuf, packet_len);
return SUCCESS;
}
Status_e
ProcessGrpMsg2(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
EAPOL_KeyMsg_t *rx_eapol_ptr;
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
PRINTM(MMSG, "ENTER: %s\n", __FUNCTION__);
rx_eapol_ptr = (EAPOL_KeyMsg_t *)(pbuf + ETHII_HEADER_LEN);
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
if (!IsEAPOL_MICValid(priv, rx_eapol_ptr, pKeyMgmtInfo->EAPOL_MIC_Key)) {
handleFailedHSK(priv, connPtr, IEEEtypes_REASON_IE_4WAY_DIFF);
return FAIL;
}
KeyMgmtStopHskTimer(connPtr);
connPtr->staData.keyMgmtInfo.numHskTries = 0;
if (WAITING_4_GRPMSG2 == pKeyMgmtInfo->rom.keyMgmtState) {
/* sendEventRsnConnect(connPtr, pKeyMgmtInfo); */
pm_fns->Hostsa_sendEventRsnConnect(priv->pmlan_private,
connPtr->mac_addr);
}
pKeyMgmtInfo->rom.keyMgmtState = HSK_END;
return SUCCESS;
}
Status_e
GenerateApEapolMsg(hostsa_private *priv,
t_void *pconnPtr, keyMgmtState_e msgState)
{
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
Status_e status;
// OSASysContext prevContext;
if (connPtr->timer_is_set) {
KeyMgmtStopHskTimer((t_void *)connPtr);
}
/* If msgState is any waiting_** state,
** it will decrease to corresponding **_pending state.
*/
/* Note: it will reduce the if checks
*/
if ((msgState & 0x1) == 0) {
msgState--;
}
connPtr->staData.keyMgmtInfo.rom.keyMgmtState = msgState;
if (msgState == MSG1_PENDING) {
status = GeneratePWKMsg1(priv, connPtr);
} else if (msgState == MSG3_PENDING) {
status = GeneratePWKMsg3(priv, connPtr);
} else if ((msgState == GRPMSG1_PENDING)
|| (msgState == GRP_REKEY_MSG1_PENDING)) {
status = GenerateGrpMsg1(priv, connPtr);
} else {
//This should not happen
return FAIL;
}
if (SUCCESS == status) {
connPtr->staData.keyMgmtInfo.rom.keyMgmtState++;
}
if (SUCCESS == status) {
connPtr->staData.keyMgmtInfo.numHskTries++;
/* we are starting the timer irrespective of whether the msg generation is
sucessful or not. This is because, if the msg generation fails because
of buffer unavailabilty then we can re-try the msg after the timeout
period. */
if (!connPtr->timer_is_set)
KeyMgmtStartHskTimer(connPtr);
}
return status;
}
//#endif // AUTHENTICATOR
void
ApMicErrTimerExpCb(t_void *context)
{
cm_Connection *connPtr = (cm_Connection *)context;
phostsa_private priv;
// UINT32 int_save;
apInfo_t *pApInfo;
if (connPtr == NULL) {
//no AP connection. Do nothing, just return
return;
}
priv = (phostsa_private)connPtr->priv;
if (!priv)
return;
pApInfo = &priv->apinfo;
switch (connPtr->staData.apMicError.status) {
case FIRST_MIC_FAIL_IN_60_SEC:
connPtr->staData.apMicError.status = NO_MIC_FAILURE;
break;
case SECOND_MIC_FAIL_IN_60_SEC:
if ((pApInfo->bssConfig.RsnConfig.mcstCipher.tkip) &&
IsAuthenticatorEnabled(priv)) {
// re-enable the group re-key timer
pApInfo->bssData.grpRekeyCntRemaining
= pApInfo->bssData.grpRekeyCntConfigured;
}
connPtr->staData.apMicError.status = NO_MIC_FAILURE;
connPtr->staData.apMicError.disableStaAsso = 0;
break;
default:
break;
}
}
void
ApMicCounterMeasureInvoke(t_void *pconnPtr)
{
cm_Connection *connPtr = (cm_Connection *)pconnPtr;
phostsa_private priv = (phostsa_private)connPtr->priv;
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
hostsa_util_fns *util_fns = &priv->util_fns;
apInfo_t *pApInfo = &priv->apinfo;
if (connPtr->staData.apMicError.MICCounterMeasureEnabled) {
switch (connPtr->staData.apMicError.status) {
case NO_MIC_FAILURE:
util_fns->moal_start_timer(util_fns->pmoal_handle,
connPtr->staData.apMicTimer,
MFALSE, MRVDRV_TIMER_60S);
connPtr->staData.apMicError.status =
FIRST_MIC_FAIL_IN_60_SEC;
break;
case FIRST_MIC_FAIL_IN_60_SEC:
connPtr->staData.apMicError.disableStaAsso = 1;
connPtr->staData.apMicError.status =
SECOND_MIC_FAIL_IN_60_SEC;
//start timer for 60 seconds
util_fns->moal_stop_timer(util_fns->pmoal_handle,
connPtr->staData.apMicTimer);
util_fns->moal_start_timer(util_fns->pmoal_handle,
connPtr->staData.apMicTimer,
MFALSE, MRVDRV_TIMER_60S);
/* smeAPStateMgr_sendSmeMsg(connPtr, MlmeApBcastDisassoc); */
pm_fns->Hostsa_DisAssocAllSta(priv->pmlan_private,
IEEEtypes_REASON_MIC_FAILURE);
// if current GTK is tkip
if ((pApInfo->bssConfig.RsnConfig.mcstCipher.tkip) &&
IsAuthenticatorEnabled(priv)) {
//Disable periodic group rekey and re-init GTK.
priv->GrpRekeyTimerIsSet = MFALSE;
pApInfo->bssData.grpRekeyCntRemaining = 0;
ReInitGTK(priv);
}
break;
default:
break;
}
}
return;
}

View File

@@ -0,0 +1,64 @@
/** @file keyMgntAP.h
*
* @brief This file contains the eapol paket process and key management for authenticator
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEYMGMTAP_H_
#define _KEYMGMTAP_H_
//Authenticator related data structures, function prototypes
#include "wltypes.h"
#include "keyMgmtAp_rom.h"
#define STA_PS_EAPOL_HSK_TIMEOUT 3000 //ms
#define AP_RETRY_EAPOL_HSK_TIMEOUT 1000 //ms
extern void KeyMgmtInit(void *priv);
extern void ReInitGTK(void *priv);
int isValidReplayCount(t_void *priv, apKeyMgmtInfoSta_t *pKeyMgmtInfo,
UINT8 *pRxReplayCount);
extern void KeyMgmtGrpRekeyCountUpdate(t_void *context);
extern void KeyMgmtStartHskTimer(void *context);
extern void KeyMgmtStopHskTimer(void *context);
extern void KeyMgmtHskTimeout(t_void *context);
extern UINT32 keyApi_ApUpdateKeyMaterial(void *priv, cm_Connection *connPtr,
BOOLEAN updateGrpKey);
extern Status_e ProcessPWKMsg2(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len);
extern Status_e ProcessPWKMsg4(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len);
extern Status_e ProcessGrpMsg2(hostsa_private *priv,
cm_Connection *connPtr, t_u8 *pbuf, t_u32 len);
extern Status_e GenerateApEapolMsg(hostsa_private *priv,
t_void *pconnPtr, keyMgmtState_e msgState);
extern void ApMicErrTimerExpCb(t_void *context);
extern void ApMicCounterMeasureInvoke(t_void *pconnPtr);
extern t_u16 keyMgmtAp_FormatWPARSN_IE(void *priv,
IEEEtypes_InfoElementHdr_t *pIe,
UINT8 isRsn,
Cipher_t *pCipher,
UINT8 cipherCount,
Cipher_t *pMcastCipher,
UINT16 authKey, UINT16 authKeyCount);
#endif //_KEYMGMTAP_H_

View File

@@ -0,0 +1,679 @@
/** @file keyMgmtApStaCommon.c
*
* @brief This file defines common api for authenticator and supplicant.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
//Authenticator related function definitions
#include "wltypes.h"
#include "IEEE_types.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "keyMgmtAp_rom.h"
#include "crypt_new_rom.h"
#include "keyCommonDef.h"
#include "pmkCache_rom.h"
#include "crypt_new_rom.h"
#include "rc4_rom.h"
#include "aes_cmac_rom.h"
#include "sha1.h"
#include "md5.h"
#include "mrvl_sha256_crypto.h"
const UINT8 wpa_oui_none[4] = { 0x00, 0x50, 0xf2, 0x00 };
const UINT8 wpa_oui01[4] = { 0x00, 0x50, 0xf2, 0x01 };
const UINT8 wpa_oui02[4] = { 0x00, 0x50, 0xf2, 0x02 };
const UINT8 wpa_oui03[4] = { 0x00, 0x50, 0xf2, 0x03 };
const UINT8 wpa_oui04[4] = { 0x00, 0x50, 0xf2, 0x04 };
const UINT8 wpa_oui05[4] = { 0x00, 0x50, 0xf2, 0x05 };
const UINT8 wpa_oui06[4] = { 0x00, 0x50, 0xf2, 0x06 };
const UINT8 wpa2_oui01[4] = { 0x00, 0x0f, 0xac, 0x01 };
const UINT8 wpa2_oui02[4] = { 0x00, 0x0f, 0xac, 0x02 };
const UINT8 wpa2_oui03[4] = { 0x00, 0x0f, 0xac, 0x03 };
const UINT8 wpa2_oui04[4] = { 0x00, 0x0f, 0xac, 0x04 };
const UINT8 wpa2_oui05[4] = { 0x00, 0x0f, 0xac, 0x05 };
const UINT8 wpa2_oui06[4] = { 0x00, 0x0f, 0xac, 0x06 };
const UINT8 wpa_oui[3] = { 0x00, 0x50, 0xf2 };
const UINT8 kde_oui[3] = { 0x00, 0x0f, 0xac };
/**
* @brief strlen
*
* @param str A pointer to string
*
* @return Length of string
*/
t_u32
wlan_strlen(const char *str)
{
t_u32 i;
for (i = 0; str[i] != 0; i++) {
}
return i;
}
static t_u32
srand_new(void *priv)
{
phostsa_private psapriv = (phostsa_private)priv;
hostsa_util_fns *util_fns = &psapriv->util_fns;
t_u32 sec, usec;
ENTER();
get_system_time(util_fns, &sec, &usec);
sec = (sec & 0xFFFF) + (sec >> 16);
usec = (usec & 0xFFFF) + (usec >> 16);
LEAVE();
return (usec << 16) | sec;
}
static unsigned int
rand_new(unsigned int seed, UINT32 randvaule)
{
unsigned int next = seed;
unsigned int result;
next *= (3515245 * randvaule + randvaule * next);
next += 12345 + randvaule * 7;
result = (unsigned int)(next / 65536) % 2048;
next *= (39018768 * randvaule + randvaule * next);
next += 56789 + randvaule * 4;
result <<= 10;
result ^= (unsigned int)(next / 65536) % 1024;
next *= (89042053 * randvaule + randvaule * next);
next += 43728 + randvaule * 9;
result <<= 10;
result ^= (unsigned int)(next / 65536) % 1024;
return result;
}
void
supplicantGenerateRand(hostsa_private *priv, UINT8 *dataOut, UINT32 length)
{
UINT32 i;
//UINT32 valueHi, valueLo;
/* Read mac 0 timer.
** Doesn't matter which one we read. We just need a good seed.
*/
//msi_wl_GetMCUCoreTimerTxTSF(&valueHi, &valueLo);
//srand(valueLo);
for (i = 0; i < length; i++) {
//dataOut[i] = rand();
dataOut[i] = rand_new(srand_new(priv), i + 1);
}
}
void
SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,
BOOLEAN isWPA2, BOOLEAN isKDF, BOOLEAN nonTKIP)
{
if (isWPA2) {
/* WPA2 */
pTxEapol->keyMsg.desc_type = 2;
} else {
/* WPA */
pTxEapol->keyMsg.desc_type = 254;
}
if (isKDF) {
/* 802.11r and 802.11w use SHA256-KDF and a different KeyDescVer */
pTxEapol->keyMsg.key_info.KeyDescriptorVersion = 3;
} else if (nonTKIP) {
/* CCMP */
pTxEapol->keyMsg.key_info.KeyDescriptorVersion = 2;
} else {
/* TKIP OR WEP */
pTxEapol->keyMsg.key_info.KeyDescriptorVersion = 1;
}
}
void
ComputeEAPOL_MIC(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
UINT16 data_length,
UINT8 *MIC_Key, UINT8 MIC_Key_length, UINT8 micKeyDescVersion)
{
int len = data_length;
UINT8 *pMicData;
pMicData = (UINT8 *)pKeyMsg;
/* Allow the caller to override the algorithm used to get by some Cisco
** CCX bugs where the wrong MIC algorithm is used
*/
if (micKeyDescVersion == 0) {
/* Algorithm not specified, use proper one from key_info */
micKeyDescVersion = pKeyMsg->key_info.KeyDescriptorVersion;
}
switch (micKeyDescVersion) {
case 3:
/* AES-128-CMAC */
mrvl_aes_cmac(priv, MIC_Key, pMicData, len,
(UINT8 *)pKeyMsg->key_MIC);
break;
case 2:
/* CCMP */
Mrvl_hmac_sha1((t_void *)priv, &pMicData,
&len,
1,
MIC_Key,
(int)MIC_Key_length,
(UINT8 *)pKeyMsg->key_MIC, EAPOL_MIC_SIZE);
break;
default:
case 1:
/* TKIP or WEP */
Mrvl_hmac_md5((t_void *)priv, pMicData,
data_length,
MIC_Key,
(int)MIC_Key_length, (UINT8 *)pKeyMsg->key_MIC);
break;
}
}
/* Returns TRUE if EAPOL MIC check passes, FALSE otherwise. */
BOOLEAN
IsEAPOL_MICValid(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg, UINT8 *pMICKey)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 msgMIC[EAPOL_MIC_SIZE];
/* pull the MIC */
memcpy(util_fns, (UINT8 *)msgMIC, (UINT8 *)pKeyMsg->key_MIC,
EAPOL_MIC_SIZE);
/* zero the MIC key field before calculating the data */
memset(util_fns, (UINT8 *)pKeyMsg->key_MIC, 0x00, EAPOL_MIC_SIZE);
ComputeEAPOL_MIC(priv, pKeyMsg, (ntohs(pKeyMsg->hdr_8021x.pckt_body_len)
+ sizeof(pKeyMsg->hdr_8021x)),
pMICKey, EAPOL_MIC_KEY_SIZE, 0);
if (memcmp(util_fns, (UINT8 *)pKeyMsg->key_MIC, msgMIC, EAPOL_MIC_SIZE)) {
#ifdef KEYMSG_DEBUG
hostEventPrintf(assocAgent_getConnPtr(),
"EAPOL MIC Failure: cmac(%d), sha1(%d), md5(%d)",
(pKeyMsg->key_info.KeyDescriptorVersion == 3),
(pKeyMsg->key_info.KeyDescriptorVersion == 2),
(pKeyMsg->key_info.KeyDescriptorVersion == 1));
#endif
/* MIC Failure */
return FALSE;
}
return TRUE;
}
void
supplicantConstructContext(phostsa_private priv, UINT8 *pAddr1,
UINT8 *pAddr2,
UINT8 *pNonce1, UINT8 *pNonce2, UINT8 *pContext)
{
hostsa_util_fns *util_fns = &priv->util_fns;
if (memcmp(util_fns, pAddr1, pAddr2, 6) < 0) {
memcpy(util_fns, pContext, pAddr1, sizeof(IEEEtypes_MacAddr_t));
memcpy(util_fns, (pContext + 6), pAddr2,
sizeof(IEEEtypes_MacAddr_t));
} else {
memcpy(util_fns, pContext, pAddr2, sizeof(IEEEtypes_MacAddr_t));
memcpy(util_fns, (pContext + 6), pAddr1,
sizeof(IEEEtypes_MacAddr_t));
}
if (memcmp(util_fns, pNonce1, pNonce2, NONCE_SIZE) < 0) {
memcpy(util_fns, pContext + 6 + 6, pNonce1, NONCE_SIZE);
memcpy(util_fns, pContext + 6 + 6 + NONCE_SIZE, pNonce2,
NONCE_SIZE);
} else {
memcpy(util_fns, pContext + 6 + 6, pNonce2, NONCE_SIZE);
memcpy(util_fns, pContext + 6 + 6 + NONCE_SIZE, pNonce1,
NONCE_SIZE);
}
}
UINT16
KeyMgmtSta_PopulateEAPOLLengthMic(phostsa_private priv,
EAPOL_KeyMsg_Tx_t *pTxEapol,
UINT8 *pEAPOLMICKey,
UINT8 eapolProtocolVersion,
UINT8 forceKeyDescVersion)
{
UINT16 frameLen;
#if 0 //!defined(REMOVE_PATCH_HOOKS)
if (KeyMgmtSta_PopulateEAPOLLengthMic_hook(pTxEapol,
pEAPOLMICKey,
eapolProtocolVersion,
forceKeyDescVersion,
&frameLen)) {
return frameLen;
}
#endif
if (!pTxEapol) {
return 0;
}
frameLen = sizeof(pTxEapol->keyMsg);
frameLen -= sizeof(pTxEapol->keyMsg.hdr_8021x);
frameLen -= sizeof(pTxEapol->keyMsg.key_data);
frameLen += pTxEapol->keyMsg.key_material_len;
pTxEapol->keyMsg.hdr_8021x.protocol_ver = eapolProtocolVersion;
pTxEapol->keyMsg.hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY;
pTxEapol->keyMsg.hdr_8021x.pckt_body_len = htons(frameLen);
pTxEapol->keyMsg.key_material_len
= htons(pTxEapol->keyMsg.key_material_len);
ComputeEAPOL_MIC(priv, &pTxEapol->keyMsg,
frameLen + sizeof(pTxEapol->keyMsg.hdr_8021x),
pEAPOLMICKey, EAPOL_MIC_KEY_SIZE, forceKeyDescVersion);
return frameLen;
}
/*
** This function generates the Pairwise transient key
*/
void
KeyMgmt_DerivePTK(phostsa_private priv, UINT8 *pAddr1,
UINT8 *pAddr2,
UINT8 *pNonce1,
UINT8 *pNonce2, UINT8 *pPTK, UINT8 *pPMK, BOOLEAN use_kdf)
{
UINT8 *pContext;
char *prefix;
/* pPTK is expected to be an encryption pool buffer (at least 500 bytes).
**
** Use the first portion for the ptk output. Use memory in the end of
** the buffer for the context construction (76 bytes).
**
** The sha256 routine assumes available memory after the context for its
** own sha256 output. Space after the context (76 bytes) is required
** for 2 digests (2 * 32). pContext must have at least 76 + 64 bytes
** available.
*/
pContext = pPTK + 200;
supplicantConstructContext(priv, pAddr1, pAddr2, pNonce1, pNonce2,
pContext);
prefix = "Pairwise key expansion";
if (use_kdf) {
mrvl_sha256_crypto_kdf((t_void *)priv, pPMK, PMK_LEN_MAX, prefix, 22, /* strlen(prefix) */
pContext, 76, /* sizeof constructed context */
pPTK, 384);
} else {
Mrvl_PRF((void *)priv, pPMK, PMK_LEN_MAX, (UINT8 *)prefix, 22, /* strlen(prefix) */
pContext, 76, /* sizeof constructed context */
pPTK, 64);
}
}
void
KeyMgmtSta_DeriveKeys(hostsa_private *priv, UINT8 *pPMK,
UINT8 *da,
UINT8 *sa,
UINT8 *ANonce,
UINT8 *SNonce,
UINT8 *EAPOL_MIC_Key,
UINT8 *EAPOL_Encr_Key,
KeyData_t *newPWKey, BOOLEAN use_kdf)
{
hostsa_util_fns *util_fns = &priv->util_fns;
// phostsa_private psapriv = (phostsa_private) priv;
// hostsa_util_fns *util_fns = &psapriv->util_fns;
//BufferDesc_t* pBufDesc = NULL;
UINT8 buf[500] = { 0 };
TkipPtk_t *pPtk;
#if 0
#if !defined(REMOVE_PATCH_HOOKS)
if (KeyMgmtSta_DeriveKeys_hook(pPMK,
da,
sa,
ANonce,
SNonce,
EAPOL_MIC_Key,
EAPOL_Encr_Key, newPWKey, use_kdf)) {
return;
}
#endif
#endif
if (!pPMK || !EAPOL_MIC_Key || !newPWKey) {
return;
}
#if 0
/* Wait forever ensures a buffer */
pBufDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
500, BML_WAIT_FOREVER);
pPtk = (TkipPtk_t *)BML_DATA_PTR(pBufDesc);
#endif
pPtk = (TkipPtk_t *)buf;
KeyMgmt_DerivePTK(priv, sa, da, ANonce, SNonce, (UINT8 *)pPtk, pPMK,
use_kdf);
memcpy(util_fns, EAPOL_MIC_Key, pPtk->kck, sizeof(pPtk->kck));
memcpy(util_fns, EAPOL_Encr_Key, pPtk->kek, sizeof(pPtk->kek));
memcpy(util_fns, newPWKey->Key, pPtk->tk, sizeof(pPtk->tk));
memcpy(util_fns, newPWKey->RxMICKey,
pPtk->rxMicKey, sizeof(pPtk->rxMicKey));
memcpy(util_fns, newPWKey->TxMICKey,
pPtk->txMicKey, sizeof(pPtk->txMicKey));
// bml_FreeBuffer((UINT32)pBufDesc);
}
void
UpdateEAPOLWcbLenAndTransmit(hostsa_private *priv, pmlan_buffer pmbuf,
UINT16 frameLen)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
pm_fns->hostsa_tx_packet(priv->pmlan_private, pmbuf, frameLen);
}
void
formEAPOLEthHdr(phostsa_private priv, EAPOL_KeyMsg_Tx_t *pTxEapol,
t_u8 *da, t_u8 *sa)
{
hostsa_util_fns *util_fns = &priv->util_fns;
memcpy(util_fns, (void *)pTxEapol->ethHdr.da, da,
IEEEtypes_ADDRESS_SIZE);
memcpy(util_fns, (void *)pTxEapol->ethHdr.sa, sa,
IEEEtypes_ADDRESS_SIZE);
pTxEapol->ethHdr.type = 0x8E88;
}
void
supplicantParseWpaIe(phostsa_private priv, IEEEtypes_WPAElement_t *pIe,
SecurityMode_t *pWpaType,
Cipher_t *pMcstCipher,
Cipher_t *pUcstCipher,
AkmSuite_t *pAkmList, UINT8 akmOutMax)
{
hostsa_util_fns *util_fns = &priv->util_fns;
IEEEtypes_WPAElement_t *pTemp = pIe;
int count;
int akmCount = akmOutMax;
AkmSuite_t *pAkm = pAkmList;
memset(util_fns, pMcstCipher, 0x00, sizeof(Cipher_t));
memset(util_fns, pUcstCipher, 0x00, sizeof(Cipher_t));
memset(util_fns, pAkmList, 0x00, akmOutMax * sizeof(AkmSuite_t));
memset(util_fns, pWpaType, 0x00, sizeof(SecurityMode_t));
pWpaType->wpa = 1;
/* record the AP's multicast cipher */
if (!memcmp
(util_fns, (char *)pTemp->GrpKeyCipher, wpa_oui02,
sizeof(wpa_oui02))) {
/* WPA TKIP */
pMcstCipher->tkip = 1;
} else if (!memcmp
(util_fns, (char *)pTemp->GrpKeyCipher, wpa_oui04,
sizeof(wpa_oui04))) {
/* WPA AES */
pMcstCipher->ccmp = 1;
} else if (!memcmp
(util_fns, (char *)pTemp->GrpKeyCipher, wpa_oui01,
sizeof(wpa_oui01))) {
/* WPA WEP 40 */
pMcstCipher->wep40 = 1;
} else if (!memcmp
(util_fns, (char *)pTemp->GrpKeyCipher, wpa_oui05,
sizeof(wpa_oui05))) {
/* WPA WEP 104 */
pMcstCipher->wep104 = 1;
}
count = wlan_le16_to_cpu(pTemp->PwsKeyCnt);
while (count) {
/* record the AP's unicast cipher */
if (!memcmp(util_fns, (char *)pTemp->PwsKeyCipherList,
wpa_oui02, sizeof(wpa_oui02))) {
/* WPA TKIP */
pUcstCipher->tkip = 1;
} else if (!memcmp(util_fns, (char *)pTemp->PwsKeyCipherList,
wpa_oui04, sizeof(wpa_oui04))) {
/* WPA AES */
pUcstCipher->ccmp = 1;
}
count--;
if (count) {
pTemp = (IEEEtypes_WPAElement_t *)((UINT8 *)pTemp +
sizeof(pTemp->
PwsKeyCipherList));
}
}
count = wlan_le16_to_cpu(pTemp->AuthKeyCnt);
while (count) {
if (akmCount) {
/* Store the AKM */
memcpy(util_fns, pAkm,
(char *)pTemp->AuthKeyList,
sizeof(pTemp->AuthKeyList));
pAkm++;
akmCount--;
}
count--;
if (count) {
pTemp = (IEEEtypes_WPAElement_t *)((UINT8 *)pTemp
+
sizeof(pTemp->
AuthKeyList));
}
}
if (!memcmp(util_fns, pAkmList, wpa_oui_none, sizeof(wpa_oui_none))) {
pWpaType->wpaNone = 1;
}
}
void
supplicantParseMcstCipher(phostsa_private priv, Cipher_t *pMcstCipherOut,
UINT8 *pGrpKeyCipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
memset(util_fns, pMcstCipherOut, 0x00, sizeof(Cipher_t));
/* record the AP's multicast cipher */
if (!memcmp(util_fns, pGrpKeyCipher, wpa2_oui02, sizeof(wpa2_oui02))) {
/* WPA2 TKIP */
pMcstCipherOut->tkip = 1;
} else if (!memcmp
(util_fns, pGrpKeyCipher, wpa2_oui04, sizeof(wpa2_oui04))) {
/* WPA2 AES */
pMcstCipherOut->ccmp = 1;
} else if (!memcmp
(util_fns, pGrpKeyCipher, wpa2_oui01, sizeof(wpa2_oui01))) {
/* WPA2 WEP 40 */
pMcstCipherOut->wep40 = 1;
} else if (!memcmp
(util_fns, pGrpKeyCipher, wpa2_oui05, sizeof(wpa2_oui05))) {
/* WPA2 WEP 104 */
pMcstCipherOut->wep104 = 1;
}
}
void
supplicantParseUcstCipher(phostsa_private priv, Cipher_t *pUcstCipherOut,
UINT8 pwsKeyCnt, UINT8 *pPwsKeyCipherList)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 count;
memset(util_fns, pUcstCipherOut, 0x00, sizeof(Cipher_t));
/* Cycle through the PwsKeyCipherList and record each unicast cipher */
for (count = 0; count < pwsKeyCnt; count++) {
/* record the AP's unicast cipher */
if (!memcmp(util_fns, pPwsKeyCipherList + (count * 4),
wpa2_oui02, sizeof(wpa2_oui02))) {
/* WPA2 TKIP */
pUcstCipherOut->tkip = 1;
} else if (!memcmp(util_fns, pPwsKeyCipherList + (count * 4),
wpa2_oui04, sizeof(wpa2_oui04))) {
/* WPA2 AES */
pUcstCipherOut->ccmp = 1;
}
}
}
void
supplicantParseRsnIe(phostsa_private priv, IEEEtypes_RSNElement_t *pRsnIe,
SecurityMode_t *pWpaTypeOut,
Cipher_t *pMcstCipherOut,
Cipher_t *pUcstCipherOut,
AkmSuite_t *pAkmListOut,
UINT8 akmOutMax,
IEEEtypes_RSNCapability_t *pRsnCapOut,
Cipher_t *pGrpMgmtCipherOut)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 *pIeData;
UINT8 *pIeEnd;
UINT8 *pGrpKeyCipher;
UINT16 pwsKeyCnt;
UINT8 *pPwsKeyCipherList;
UINT16 authKeyCnt;
UINT8 *pAuthKeyList;
IEEEtypes_RSNCapability_t *pRsnCap;
UINT16 *pPMKIDCnt;
UINT16 PMKIDCnt;
UINT8 *pGrpMgmtCipher;
#if 0
#if !defined(REMOVE_PATCH_HOOKS)
if (supplicantParseRsnIe_hook(pRsnIe,
pWpaTypeOut,
pMcstCipherOut,
pUcstCipherOut,
pAkmListOut,
akmOutMax,
pRsnCapOut, pGrpMgmtCipherOut)) {
return;
}
#endif
#endif
memset(util_fns, pWpaTypeOut, 0x00, sizeof(SecurityMode_t));
pWpaTypeOut->wpa2 = 1;
/* Set the start and end of the IE data */
pIeData = (UINT8 *)&pRsnIe->Ver;
pIeEnd = pIeData + pRsnIe->Len;
/* Skip past the version field */
pIeData += sizeof(pRsnIe->Ver);
/* Parse the group key cipher list */
pGrpKeyCipher = pIeData;
pIeData += sizeof(pRsnIe->GrpKeyCipher);
supplicantParseMcstCipher(priv, pMcstCipherOut, pGrpKeyCipher);
/* Parse the pairwise key cipher list */
pwsKeyCnt = wlan_le16_to_cpu(*(UINT16 *)pIeData);
pIeData += sizeof(pRsnIe->PwsKeyCnt);
pPwsKeyCipherList = pIeData;
pIeData += pwsKeyCnt * sizeof(pRsnIe->PwsKeyCipherList);
supplicantParseUcstCipher(priv, pUcstCipherOut, pwsKeyCnt,
pPwsKeyCipherList);
/* Parse and return the AKM list */
authKeyCnt = wlan_le16_to_cpu(*(UINT16 *)pIeData);
pIeData += sizeof(pRsnIe->AuthKeyCnt);
pAuthKeyList = pIeData;
pIeData += authKeyCnt * sizeof(pRsnIe->AuthKeyList);
memset(util_fns, pAkmListOut, 0x00, akmOutMax * sizeof(AkmSuite_t));
memcpy(util_fns, pAkmListOut,
pAuthKeyList,
MIN(authKeyCnt, akmOutMax) * sizeof(pRsnIe->AuthKeyList));
DBG_HEXDUMP(MCMD_D, " pAuthKeyList",
(t_u8 *)pAuthKeyList, MIN(authKeyCnt,
akmOutMax) *
sizeof(pRsnIe->AuthKeyList));
DBG_HEXDUMP(MCMD_D, " pAuthKeyList", (t_u8 *)pAkmListOut,
MIN(authKeyCnt, akmOutMax) * sizeof(pRsnIe->AuthKeyList));
/* Check if the RSN Capability is included */
if (pIeData < pIeEnd) {
pRsnCap = (IEEEtypes_RSNCapability_t *)pIeData;
pIeData += sizeof(pRsnIe->RsnCap);
if (pRsnCapOut) {
memcpy(util_fns, pRsnCapOut, pRsnCap,
sizeof(IEEEtypes_RSNCapability_t));
}
}
/* Check if the PMKID count is included */
if (pIeData < pIeEnd) {
pPMKIDCnt = (UINT16 *)pIeData;
PMKIDCnt = wlan_le16_to_cpu(*pPMKIDCnt);
pIeData += sizeof(pRsnIe->PMKIDCnt);
/* Check if the PMKID List is included */
if (pIeData < pIeEnd) {
/* pPMKIDList = pIeData; <-- Currently not used in parsing */
pIeData += PMKIDCnt * sizeof(pRsnIe->PMKIDList);
}
}
/* Check if the Group Mgmt Cipher is included */
if (pIeData < pIeEnd) {
pGrpMgmtCipher = pIeData;
if (pGrpMgmtCipherOut) {
memcpy(util_fns, pGrpMgmtCipherOut,
pGrpMgmtCipher, sizeof(pRsnIe->GrpMgmtCipher));
}
}
}

View File

@@ -0,0 +1,83 @@
/** @file keyMgmtApStaCommon.h
*
* @brief This file contains common api for authenticator and supplicant.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef KEYMGMTAPSTACOMMON_H__
#define KEYMGMTAPSTACOMMON_H__
//Authenticator related data structures, function prototypes
#include "wltypes.h"
#include "IEEE_types.h"
#include "sha1.h"
#include "keyMgmtStaTypes.h"
#include "wl_macros.h"
#include "keyMgmtApTypes.h"
#include "rc4_rom.h"
#include "keyCommonDef.h"
#include "authenticator.h"
extern t_u32 wlan_strlen(const char *str);
extern void supplicantGenerateRand(hostsa_private *priv, UINT8 *dataOut,
UINT32 length);
extern void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,
BOOLEAN isWPA2, BOOLEAN isKDF,
BOOLEAN nonTKIP);
extern void ComputeEAPOL_MIC(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
UINT16 data_length, UINT8 *MIC_Key,
UINT8 MIC_Key_length, UINT8 micKeyDescVersion);
extern BOOLEAN IsEAPOL_MICValid(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
UINT8 *pMICKey);
extern void supplicantConstructContext(phostsa_private priv, UINT8 *pAddr1,
UINT8 *pAddr2, UINT8 *pNonce1,
UINT8 *pNonce2, UINT8 *pContext);
extern UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(phostsa_private priv,
EAPOL_KeyMsg_Tx_t *pTxEapol,
UINT8 *pEAPOLMICKey,
UINT8 eapolProtocolVersion,
UINT8 forceKeyDescVersion);
extern void KeyMgmt_DerivePTK(phostsa_private priv, UINT8 *pAddr1,
UINT8 *pAddr2, UINT8 *pNonce1, UINT8 *pNonce2,
UINT8 *pPTK, UINT8 *pPMK, BOOLEAN use_kdf);
extern void KeyMgmtSta_DeriveKeys(hostsa_private *priv, UINT8 *pPMK, UINT8 *da,
UINT8 *sa, UINT8 *ANonce, UINT8 *SNonce,
UINT8 *EAPOL_MIC_Key, UINT8 *EAPOL_Encr_Key,
KeyData_t *newPWKey, BOOLEAN use_kdf);
extern void UpdateEAPOLWcbLenAndTransmit(hostsa_private *priv,
pmlan_buffer pmbuf, UINT16 frameLen);
extern void formEAPOLEthHdr(phostsa_private priv, EAPOL_KeyMsg_Tx_t *pTxEapol,
t_u8 *da, t_u8 *sa);
extern void supplicantParseWpaIe(phostsa_private priv,
IEEEtypes_WPAElement_t *pIe,
SecurityMode_t *pWpaType,
Cipher_t *pMcstCipher, Cipher_t *pUcstCipher,
AkmSuite_t *pAkmList, UINT8 akmOutMax);
extern void supplicantParseRsnIe(phostsa_private priv,
IEEEtypes_RSNElement_t *pRsnIe,
SecurityMode_t *pWpaTypeOut,
Cipher_t *pMcstCipherOut,
Cipher_t *pUcstCipherOut,
AkmSuite_t *pAkmListOut, UINT8 akmOutMax,
IEEEtypes_RSNCapability_t *pRsnCapOut,
Cipher_t *pGrpMgmtCipherOut);
#endif //KEYMGMTAPSTACOMMON_H__

View File

@@ -0,0 +1,68 @@
/** @file KeyMgmtApTypes.h
*
* @brief This file contains the key management type for ap
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEYMGMTAPTYPES_H_
#define _KEYMGMTAPTYPES_H_
#include "wltypes.h"
#include "IEEE_types.h"
#include "keyMgmtStaTypes.h"
#include "keyMgmtApTypes_rom.h"
#include "keyCommonDef.h"
typedef enum {
STA_ASSO_EVT,
MSGRECVD_EVT,
KEYMGMTTIMEOUT_EVT,
GRPKEYTIMEOUT_EVT,
UPDATEKEYS_EVT
} keyMgmt_HskEvent_e;
/* Fields till keyMgmtState are being accessed in rom code and
* should be kept intact. Fields after keyMgmtState can be changed
* safely.
*/
typedef struct {
apKeyMgmtInfoStaRom_t rom;
UINT8 numHskTries;
UINT32 counterLo;
UINT32 counterHi;
UINT8 EAPOL_MIC_Key[EAPOL_MIC_KEY_SIZE];
UINT8 EAPOL_Encr_Key[EAPOL_ENCR_KEY_SIZE];
UINT8 EAPOLProtoVersion;
UINT8 rsvd[3];
} apKeyMgmtInfoSta_t;
/* Convert an Ascii character to a hex nibble
e.g. Input is 'b' : Output will be 0xb
Input is 'E' : Output will be 0xE
Input is '8' : Output will be 0x8
Assumption is that input is a-f or A-F or 0-9
*/
#define ASCII2HEX(Asc) (((Asc) >= 'a') ? (Asc - 'a' + 0xA)\
: ( (Asc) >= 'A' ? ( (Asc) - 'A' + 0xA ) : ((Asc) - '0') ))
#define ETH_P_EAPOL 0x8E88
#endif //_KEYMGMTAPTYPES_H_

View File

@@ -0,0 +1,63 @@
/** @file KeyMgmtApTypes_rom.h
*
* @brief This file contains the key management type for ap
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEYMGMTAPTYPES_ROM_H_
#define _KEYMGMTAPTYPES_ROM_H_
#include "wltypes.h"
#include "keyMgmtStaTypes.h"
#define KDE_IE_SIZE (2) // type+length of KDE_t
#define KDE_SIZE (KDE_IE_SIZE + 4 ) // OUI+datatype of KDE_t
#define GTK_IE_SIZE (2)
#define KEYDATA_SIZE (4 + GTK_IE_SIZE + TK_SIZE) //OUI+datatype+ GTK_IE+ GTK
typedef enum {
HSK_NOT_STARTED,
MSG1_PENDING,
WAITING_4_MSG2,
MSG3_PENDING,
WAITING_4_MSG4,
GRPMSG1_PENDING,
WAITING_4_GRPMSG2,
GRP_REKEY_MSG1_PENDING,
WAITING_4_GRP_REKEY_MSG2,
/* the relative positions of the different enum elements
** should not be changed since FW code checks for even/odd
** values at certain places.
*/
HSK_DUMMY_STATE,
HSK_END
} keyMgmtState_e;
/* This sturcture is being accessed in rom code and should be kept intact. */
typedef struct {
UINT16 staRsnCap;
SecurityMode_t staSecType;
Cipher_t staUcstCipher;
UINT8 staAkmType;
keyMgmtState_e keyMgmtState;
} apKeyMgmtInfoStaRom_t;
#endif

View File

@@ -0,0 +1,574 @@
/** @file keyMgmtAp_rom.c
*
* @brief This file defines api for key managment
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
//Authenticator related function definitions
#include "wltypes.h"
#include "IEEE_types.h"
#include "hostsa_ext_def.h"
#include "authenticator.h"
#include "keyMgmtAp_rom.h"
#include "crypt_new_rom.h"
#include "keyCommonDef.h"
#include "pmkCache_rom.h"
#include "crypt_new_rom.h"
#include "rc4_rom.h"
#include "aes_cmac_rom.h"
#include "sha1.h"
#include "md5.h"
#include "mrvl_sha256_crypto.h"
UINT32
util_FindLowestBitSet(UINT32 val)
{
UINT32 bitmap = 1;
while (bitmap && (!(bitmap & val))) {
bitmap <<= 1;
}
return bitmap;
}
UINT8
convertMrvlAuthToIEEEAuth(UINT32 mrvlauth)
{
UINT8 auth;
switch (mrvlauth) {
case UAP_HOSTCMD_KEYMGMT_EAP:
auth = IEEEtypes_RSN_AUTH_KEY_SUITE_8021X;
break;
case UAP_HOSTCMD_KEYMGMT_PSK:
auth = IEEEtypes_RSN_AUTH_KEY_SUITE_PSK;
break;
case UAP_HOSTCMD_KEYMGMT_NONE:
default:
auth = IEEEtypes_RSN_AUTH_KEY_SUITE_RSVD;
break;
}
return auth;
}
UINT32
convertIEEEAuthToMrvlAuth(UINT8 auth)
{
UINT32 MrvlAuth = 0;
switch (auth) {
case IEEEtypes_RSN_AUTH_KEY_SUITE_8021X:
MrvlAuth |= UAP_HOSTCMD_KEYMGMT_EAP;
break;
case IEEEtypes_RSN_AUTH_KEY_SUITE_PSK:
MrvlAuth |= UAP_HOSTCMD_KEYMGMT_PSK;
break;
case IEEEtypes_RSN_AUTH_KEY_SUITE_RSVD:
default:
MrvlAuth = 0;
break;
}
return MrvlAuth;
}
UINT8
convertMrvlCipherToIEEECipher(UINT8 mrvlcipher)
{
UINT8 Cipher;
switch (mrvlcipher) {
case UAP_HOSTCMD_CIPHER_WEP40:
Cipher = IEEEtypes_RSN_CIPHER_SUITE_WEP40;
break;
case UAP_HOSTCMD_CIPHER_WEP104:
Cipher = IEEEtypes_RSN_CIPHER_SUITE_WEP104;
break;
case UAP_HOSTCMD_CIPHER_TKIP:
Cipher = IEEEtypes_RSN_CIPHER_SUITE_TKIP;
break;
case UAP_HOSTCMD_CIPHER_CCMP:
Cipher = IEEEtypes_RSN_CIPHER_SUITE_CCMP;
break;
default:
Cipher = IEEEtypes_RSN_CIPHER_SUITE_NONE;
break;
}
return Cipher;
}
UINT32
convertIEEECipherToMrvlCipher(UINT8 cipher)
{
UINT32 MrvlCipher = 0;
switch (cipher) {
case IEEEtypes_RSN_CIPHER_SUITE_WEP40:
MrvlCipher |= UAP_HOSTCMD_CIPHER_WEP40;
break;
case IEEEtypes_RSN_CIPHER_SUITE_TKIP:
MrvlCipher |= UAP_HOSTCMD_CIPHER_TKIP;
break;
case IEEEtypes_RSN_CIPHER_SUITE_CCMP:
MrvlCipher |= UAP_HOSTCMD_CIPHER_CCMP;
break;
case IEEEtypes_RSN_CIPHER_SUITE_WEP104:
MrvlCipher |= UAP_HOSTCMD_CIPHER_WEP104;
break;
case IEEEtypes_RSN_CIPHER_SUITE_NONE:
case IEEEtypes_RSN_CIPHER_SUITE_WRAP:
default:
MrvlCipher = 0;
break;
}
return MrvlCipher;
}
void
GenerateGTK_internal(hostsa_private *priv, KeyData_t *grpKeyData,
UINT8 *nonce, UINT8 *StaMacAddr)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 inp_data[NONCE_SIZE + sizeof(IEEEtypes_MacAddr_t)];
UINT8 prefix[] = "Group key expansion";
UINT8 GTK[32]; //group transient key
UINT8 grpMasterKey[32];
if (!grpKeyData || !nonce) {
return;
}
memcpy(util_fns, inp_data, StaMacAddr, sizeof(IEEEtypes_MacAddr_t));
supplicantGenerateRand(priv, nonce, NONCE_SIZE);
memcpy(util_fns, inp_data + sizeof(IEEEtypes_MacAddr_t), nonce,
NONCE_SIZE);
supplicantGenerateRand(priv, grpMasterKey, sizeof(grpMasterKey));
Mrvl_PRF((void *)priv, grpMasterKey,
sizeof(grpMasterKey),
prefix,
wlan_strlen((char *)prefix),
inp_data, sizeof(inp_data), GTK, sizeof(GTK));
memcpy(util_fns, grpKeyData->Key, GTK, TK_SIZE);
memcpy(util_fns, grpKeyData->TxMICKey, GTK + TK_SIZE, MIC_KEY_SIZE);
memcpy(util_fns, grpKeyData->RxMICKey, GTK + TK_SIZE + MIC_KEY_SIZE,
MIC_KEY_SIZE);
}
/*
Populates EAPOL frame based on Cipher, given Nonce, replay counters,
and type, which encodes whether this is secure, part of WPA2 or WPA
handshake.
This is currently used for EAPOL sent from AP, msg1, msg3 and group
key msg.
*/
void
PopulateKeyMsg(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,
Cipher_t *Cipher,
UINT16 Type, UINT32 replay_cnt[2], UINT8 *Nonce)
{
hostsa_util_fns *util_fns = &priv->util_fns;
key_info_t *pKeyInfo;
if (!tx_eapol_ptr || !Cipher) {
return;
}
pKeyInfo = &tx_eapol_ptr->keyMsg.key_info;
if (Cipher->tkip) {
//TKIP unicast
tx_eapol_ptr->keyMsg.key_length =
SHORT_SWAP((TK_SIZE + TK_SIZE));
} else if (Cipher->ccmp) {
//CCMP unicast
tx_eapol_ptr->keyMsg.key_length = SHORT_SWAP(TK_SIZE);
}
pKeyInfo->KeyAck = 1;
if (Type & PAIRWISE_KEY_MSG) {
pKeyInfo->KeyType = 1;
if (Type & SECURE_HANDSHAKE_FLAG) {
pKeyInfo->KeyMIC = 1;
pKeyInfo->Install = 1;
pKeyInfo->EncryptedKeyData = pKeyInfo->Secure =
(Type & WPA2_HANDSHAKE) ? 1 : 0;
}
} else {
pKeyInfo->Secure = 1;
pKeyInfo->KeyMIC = 1;
pKeyInfo->EncryptedKeyData = (Type & WPA2_HANDSHAKE) ? 1 : 0;
}
tx_eapol_ptr->keyMsg.replay_cnt[0] = WORD_SWAP(replay_cnt[0]);
tx_eapol_ptr->keyMsg.replay_cnt[1] = WORD_SWAP(replay_cnt[1]);
memcpy(util_fns, (void *)tx_eapol_ptr->keyMsg.key_nonce, Nonce,
NONCE_SIZE);
DBG_HEXDUMP(MCMD_D, " nonce ",
(t_u8 *)tx_eapol_ptr->keyMsg.key_nonce, NONCE_SIZE);
}
/*
Function to prepare KDE in EAPOL frame .
Used by the AP to encapsulate GTK
*/
void
prepareKDE(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,
KeyData_t *grKey, Cipher_t *cipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
KDE_t *pKeyDataWPA2;
GTK_KDE_t *pGTK_IE;
UINT8 RsnIE_len = 0, PadLen = 0;
UINT8 *buf_p;
if (!tx_eapol_ptr || !grKey || !cipher) {
return;
}
RsnIE_len = tx_eapol_ptr->keyMsg.key_material_len;
buf_p = (UINT8 *)(tx_eapol_ptr->keyMsg.key_data + RsnIE_len);
pKeyDataWPA2 = (KDE_t *)buf_p;
pKeyDataWPA2->type = 0xdd;
pKeyDataWPA2->length = KEYDATA_SIZE;
pKeyDataWPA2->OUI[0] = kde_oui[0];
pKeyDataWPA2->OUI[1] = kde_oui[1];
pKeyDataWPA2->OUI[2] = kde_oui[2];
pKeyDataWPA2->dataType = 1;
buf_p = buf_p + KDE_SIZE;
pGTK_IE = (GTK_KDE_t *)buf_p;
pGTK_IE->KeyID = 1;
buf_p = buf_p + GTK_IE_SIZE;
// copy over GTK
memcpy(util_fns, (void *)buf_p, (void *)grKey->Key, TK_SIZE);
buf_p = buf_p + TK_SIZE;
if (cipher->tkip) {
pKeyDataWPA2->length += (MIC_KEY_SIZE + MIC_KEY_SIZE);
memcpy(util_fns, (void *)buf_p, (void *)grKey->TxMICKey,
MIC_KEY_SIZE);
buf_p = buf_p + MIC_KEY_SIZE;
memcpy(util_fns, (void *)buf_p, (void *)grKey->RxMICKey,
MIC_KEY_SIZE);
buf_p = buf_p + MIC_KEY_SIZE;
}
tx_eapol_ptr->keyMsg.key_material_len += (pKeyDataWPA2->length
+ KDE_IE_SIZE);
PadLen = ((8 - ((tx_eapol_ptr->keyMsg.key_material_len) % 8)) % 8);
if (PadLen) {
*(buf_p) = 0xdd;
memset(util_fns, (void *)(buf_p + 1), 0, PadLen - 1);
tx_eapol_ptr->keyMsg.key_material_len += PadLen;
}
}
BOOLEAN
Encrypt_keyData(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,
UINT8 *EAPOL_Encr_Key, Cipher_t *cipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 key[16];
UINT8 cipherText[400] = { 0 };
if (!tx_eapol_ptr || !EAPOL_Encr_Key || !cipher) {
return FALSE;
}
if (cipher->ccmp) {
// Pairwise is CCMP
memcpy(util_fns, (void *)key, EAPOL_Encr_Key, 16);
// use AES-only mode from AEU HW to perform AES wrap
MRVL_AesWrap(key, 2, tx_eapol_ptr->keyMsg.key_material_len / 8,
tx_eapol_ptr->keyMsg.key_data, NULL, cipherText);
tx_eapol_ptr->keyMsg.key_material_len += 8;
memcpy(util_fns, (void *)tx_eapol_ptr->keyMsg.key_data,
cipherText, tx_eapol_ptr->keyMsg.key_material_len);
} else if (cipher->tkip) {
// Pairwise is TKIP
supplicantGenerateRand(priv,
(UINT8 *)tx_eapol_ptr->keyMsg.
EAPOL_key_IV, 16);
RC4_Encrypt((t_void *)priv, (unsigned char *)EAPOL_Encr_Key,
(unsigned char *)&tx_eapol_ptr->keyMsg.EAPOL_key_IV,
16, (unsigned char *)&tx_eapol_ptr->keyMsg.key_data,
(unsigned short)tx_eapol_ptr->keyMsg.
key_material_len, 256);
} else {
return FALSE;
}
return TRUE;
}
void
KeyMgmtAp_DerivePTK(hostsa_private *priv,
UINT8 *pPMK,
t_u8 *da,
t_u8 *sa,
UINT8 *ANonce,
UINT8 *SNonce,
UINT8 *EAPOL_MIC_Key,
UINT8 *EAPOL_Encr_Key, KeyData_t *newPWKey, BOOLEAN use_kdf)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 tmp[MIC_KEY_SIZE];
// call STA PTK generation funciton first
KeyMgmtSta_DeriveKeys(priv, pPMK,
da,
sa,
ANonce,
SNonce,
EAPOL_MIC_Key, EAPOL_Encr_Key, newPWKey, use_kdf);
// We need to swap Rx/Tx Keys for AP
memcpy(util_fns, tmp, newPWKey->RxMICKey, MIC_KEY_SIZE);
memcpy(util_fns, newPWKey->RxMICKey, newPWKey->TxMICKey, MIC_KEY_SIZE);
memcpy(util_fns, newPWKey->TxMICKey, tmp, MIC_KEY_SIZE);
}
BOOLEAN
KeyData_CopyWPAWP2(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL, void *pIe)
{
hostsa_util_fns *util_fns = &priv->util_fns;
IEEEtypes_InfoElementHdr_t *pElement =
(IEEEtypes_InfoElementHdr_t *)pIe;
if (!pIe) {
return FALSE;
}
pTxEAPOL->keyMsg.key_material_len =
pElement->Len + sizeof(IEEEtypes_InfoElementHdr_t);
memcpy(util_fns, (void *)pTxEAPOL->keyMsg.key_data,
pIe, pTxEAPOL->keyMsg.key_material_len);
return TRUE;
}
BOOLEAN
KeyData_UpdateKeyMaterial(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL,
SecurityMode_t *pSecType, void *pWPA, void *pWPA2)
{
if (pSecType->wpa || pSecType->wpaNone) {
if (KeyData_CopyWPAWP2(priv, pTxEAPOL, pWPA) == FALSE) {
return FALSE;
}
} else if (pSecType->wpa2) {
if (KeyData_CopyWPAWP2(priv, pTxEAPOL, pWPA2) == FALSE) {
return FALSE;
}
}
return TRUE;
}
void
KeyData_AddGTK(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL,
KeyData_t *grKey, Cipher_t *cipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
UINT8 *buf_p;
buf_p = (UINT8 *)pTxEAPOL->keyMsg.key_data;
memcpy(util_fns, (void *)buf_p, (void *)grKey, TK_SIZE);
buf_p = buf_p + TK_SIZE;
pTxEAPOL->keyMsg.key_material_len += TK_SIZE;
if (cipher->tkip) {
memcpy(util_fns, (void *)buf_p, (void *)grKey->TxMICKey,
MIC_KEY_SIZE);
buf_p = buf_p + MIC_KEY_SIZE;
memcpy(util_fns, (void *)buf_p, (void *)grKey->RxMICKey,
MIC_KEY_SIZE);
pTxEAPOL->keyMsg.key_material_len += (MIC_KEY_SIZE +
MIC_KEY_SIZE);
}
}
/* Returns FALSE if security type is other than WPA* */
BOOLEAN
KeyData_AddKey(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL,
SecurityMode_t *pSecType, KeyData_t *grKey, Cipher_t *cipher)
{
hostsa_util_fns *util_fns = &priv->util_fns;
BOOLEAN status = FALSE;
pTxEAPOL->keyMsg.key_info.KeyIndex = grKey->KeyIndex;
pTxEAPOL->keyMsg.key_RSC[0] = grKey->TxIV16 & 0x00FF;
pTxEAPOL->keyMsg.key_RSC[1] = (grKey->TxIV16 >> 8) & 0x00FF;
memcpy(util_fns, (void *)(pTxEAPOL->keyMsg.key_RSC + 2),
&grKey->TxIV32, 4);
if (pSecType->wpa || pSecType->wpaNone) {
KeyData_AddGTK(priv, pTxEAPOL, grKey, cipher);
status = TRUE;
} else if (pSecType->wpa2) {
prepareKDE(priv, pTxEAPOL, grKey, cipher);
status = TRUE;
}
return status;
}
void
ROM_InitGTK(hostsa_private *priv, KeyData_t *grpKeyData, UINT8 *nonce,
UINT8 *StaMacAddr)
{
grpKeyData->KeyIndex = 1;
grpKeyData->TxIV16 = 1;
grpKeyData->TxIV32 = 0;
GenerateGTK_internal(priv, grpKeyData, nonce, StaMacAddr);
}
t_u16
keyMgmtAp_FormatWPARSN_IE_internal(phostsa_private priv,
IEEEtypes_InfoElementHdr_t *pIe,
UINT8 isRsn,
Cipher_t *pCipher,
UINT8 cipherCnt,
Cipher_t *pMcastCipher,
UINT16 authKey, UINT16 authKeyCnt)
{
phostsa_util_fns util_fns = &priv->util_fns;
int i;
UINT8 *pBuf = NULL;
IEEEtypes_RSNElement_t *pRsn = (IEEEtypes_RSNElement_t *)pIe;
IEEEtypes_WPAElement_t *pWpa = (IEEEtypes_WPAElement_t *)pIe;
UINT16 bitPos = 0;
UINT16 authKeyBitmap = authKey;
UINT8 ucastBitmap = *((UINT8 *)pCipher);
UINT8 mcastBitmap = *((UINT8 *)pMcastCipher);
UINT8 oui[3];
UINT16 ieLength = 0;
pIe->ElementId = (isRsn == 1) ? ELEM_ID_RSN : ELEM_ID_VENDOR_SPECIFIC;
if (isRsn) {
memcpy(util_fns, (void *)&oui, (void *)&kde_oui, sizeof(oui));
pBuf = (UINT8 *)&pRsn->Ver;
} else {
memcpy(util_fns, (void *)&oui, (void *)&wpa_oui01, sizeof(oui));
memcpy(util_fns, (void *)&pWpa->OuiType, (void *)&wpa_oui01,
sizeof(wpa_oui01));
pBuf = (UINT8 *)&pWpa->Ver;
}
pBuf[0] = 0x1;
pBuf[1] = 0x0;
pBuf += 2;
//filling group cipher
memcpy(util_fns, (void *)pBuf, (void *)&oui, sizeof(oui));
if (mcastBitmap) {
bitPos = util_FindLowestBitSet(mcastBitmap);
}
pBuf[3] = convertMrvlCipherToIEEECipher(bitPos);
pBuf += 4;
pBuf[0] = (cipherCnt >> 0) & 0xFF;
pBuf[1] = (cipherCnt >> 16) & 0xFF;
pBuf += 2;
for (i = 0; i < cipherCnt; i++) {
pBuf[0] = oui[0];
pBuf[1] = oui[1];
pBuf[2] = oui[2];
bitPos = util_FindLowestBitSet(ucastBitmap);
pBuf[3] = convertMrvlCipherToIEEECipher(bitPos);
ucastBitmap &= ~bitPos;
pBuf += 4;
}
pBuf[0] = (authKeyCnt >> 0) & 0xFF;
pBuf[1] = (authKeyCnt >> 16) & 0xFF;
pBuf += 2;
for (i = 0; i < authKeyCnt; i++) {
pBuf[0] = oui[0];
pBuf[1] = oui[1];
pBuf[2] = oui[2];
bitPos = util_FindLowestBitSet(authKeyBitmap);
pBuf[3] = convertMrvlAuthToIEEEAuth(bitPos);
authKeyBitmap &= ~bitPos;
pBuf += 4;
}
if (isRsn) {
pBuf[0] = 0x0;
pBuf[1] = 0x0;
pBuf += 2;
}
ieLength = (unsigned long)pBuf - (unsigned long)pIe;
pIe->Len = ieLength - sizeof(IEEEtypes_InfoElementHdr_t);
DBG_HEXDUMP(MCMD_D, "RSN or WPA IE", (t_u8 *)pIe, ieLength);
return ieLength;
}
/* Ideally one day this function should re-use client code */
t_u16
keyMgmtAp_FormatWPARSN_IE(hostsa_private *priv,
IEEEtypes_InfoElementHdr_t *pIe,
UINT8 isRsn,
Cipher_t *pCipher,
UINT8 cipherCount,
Cipher_t *pMcastCipher,
UINT16 authKey, UINT16 authKeyCount)
{
UINT16 ieLength;
ieLength = keyMgmtAp_FormatWPARSN_IE_internal(priv, pIe,
isRsn,
pCipher,
cipherCount,
pMcastCipher,
authKey, authKeyCount);
return ieLength;
}

View File

@@ -0,0 +1,84 @@
/** @file keyMgmtAp_rom.h
*
* @brief This file contains define for key management
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef KEYMGMTAP_ROM_H__
#define KEYMGMTAP_ROM_H__
//Authenticator related data structures, function prototypes
#include "wltypes.h"
#include "IEEE_types.h"
#include "sha1.h"
#include "keyMgmtStaTypes.h"
#include "wl_macros.h"
#include "keyMgmtApTypes.h"
#include "rc4_rom.h"
#include "keyCommonDef.h"
#include "authenticator.h"
#include "keyMgmtApStaCommon.h"
/* This flags if the Secure flag in EAPOL key frame must be set */
#define SECURE_HANDSHAKE_FLAG 0x0080
/* Whether the EAPOL frame is for pairwise or group Key */
#define PAIRWISE_KEY_MSG 0x0800
/* Flags when WPA2 is enabled, not used for WPA */
#define WPA2_HANDSHAKE 0x8000
extern void GenerateGTK_internal(hostsa_private *priv, KeyData_t *grpKeyData,
UINT8 *nonce, UINT8 *StaMacAddr);
extern void PopulateKeyMsg(hostsa_private *priv,
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr, Cipher_t *Cipher,
UINT16 Type, UINT32 replay_cnt[2], UINT8 *Nonce);
extern void prepareKDE(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,
KeyData_t *grKey, Cipher_t *cipher);
extern BOOLEAN Encrypt_keyData(hostsa_private *priv,
EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,
UINT8 *EAPOL_Encr_Key, Cipher_t *cipher);
extern void ROM_InitGTK(hostsa_private *priv, KeyData_t *grpKeyData,
UINT8 *nonce, UINT8 *StaMacAddr);
extern void KeyData_AddGTK(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL,
KeyData_t *grKey, Cipher_t *cipher);
extern BOOLEAN KeyData_AddKey(hostsa_private *priv, EAPOL_KeyMsg_Tx_t *pTxEAPOL,
SecurityMode_t *pSecType,
KeyData_t *grKey, Cipher_t *cipher);
extern BOOLEAN KeyData_CopyWPAWP2(hostsa_private *priv,
EAPOL_KeyMsg_Tx_t *pTxEAPOL, void *pIe);
extern BOOLEAN KeyData_UpdateKeyMaterial(hostsa_private *priv,
EAPOL_KeyMsg_Tx_t *pTxEAPOL,
SecurityMode_t *pSecType, void *pWPA,
void *pWPA2);
extern void KeyMgmtAp_DerivePTK(hostsa_private *priv, UINT8 *pPMK, t_u8 *da,
t_u8 *sa, UINT8 *ANonce, UINT8 *SNonce,
UINT8 *EAPOL_MIC_Key, UINT8 *EAPOL_Encr_Key,
KeyData_t *newPWKey, BOOLEAN use_kdf);
#endif //_KEYMGMTAP_ROM_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
/** @file keyMgmtSta.h
*
* @brief This file contains the defines for key management.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEY_MGMT_STA_H_
#define _KEY_MGMT_STA_H_
#include "keyCommonDef.h"
#include "KeyApiStaDefs.h"
#include "IEEE_types.h"
#include "keyMgmtStaTypes.h"
#include "keyMgmtSta_rom.h"
#ifdef BTAMP
#include "btamp_config.h"
#define BTAMP_SUPPLICATNT_SESSIONS AMPHCI_MAX_PHYSICAL_LINK_SUPPORTED
#else
#define BTAMP_SUPPLICATNT_SESSIONS 0
#endif
//longl test
#define MAX_SUPPLICANT_SESSIONS (10)
void keyMgmtControlledPortOpen(phostsa_private priv);
extern BOOLEAN supplicantAkmIsWpaWpa2(phostsa_private priv, AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmIsWpaWpa2Psk(phostsa_private priv,
AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmUsesKdf(phostsa_private priv, AkmSuite_t *pAkm);
extern BOOLEAN supplicantGetPmkid(phostsa_private priv,
IEEEtypes_MacAddr_t *pBssid,
IEEEtypes_MacAddr_t *pSta, AkmSuite_t *pAkm,
UINT8 *pPMKID);
extern void keyMgmtSetIGtk(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtInfoSta,
IGtkKde_t *pIGtkKde, UINT8 iGtkKdeLen);
extern UINT8 *keyMgmtGetIGtk(phostsa_private priv);
extern void keyMgmtSta_RomInit(void);
#if 0
extern BufferDesc_t *GetTxEAPOLBuffer(struct cm_ConnectionInfo *connPtr,
EAPOL_KeyMsg_Tx_t **ppTxEapol,
BufferDesc_t * pBufDesc);
#endif
extern void allocSupplicantData(void *priv);
extern void freeSupplicantData(void *priv);
extern void supplicantInit(void *priv, supplicantData_t *suppData);
extern BOOLEAN keyMgmtProcessMsgExt(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtInfoSta,
EAPOL_KeyMsg_t *pKeyMsg);
extern void ProcessKeyMgmtDataSta(phostsa_private priv, mlan_buffer *pmbuf,
IEEEtypes_MacAddr_t *sa,
IEEEtypes_MacAddr_t *da);
#endif

View File

@@ -0,0 +1,109 @@
/** @file keyMgmtstaType.h
*
* @brief This file defines data types structrue for key managment.
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEYMGMTSTATYPES_H_
#define _KEYMGMTSTATYPES_H_
#define WPA_AES_KEY_LEN 16
#define WPA_TKIP_KEY_LEN 32
#define WPA_WEP104_KEY_LEN 13
#define WPA_WEP40_KEY_LEN 5
#define KEY_TYPE_WEP 0
#define KEY_TYPE_TKIP 1
#define KEY_TYPE_AES 2
#define KEY_TYPE_WAPI 3
#define KEY_TYPE_AES_CMAC 4
/* This struct definition is used in ROM and should be kept intact */
typedef struct {
UINT8 wep40:1;
UINT8 wep104:1;
UINT8 tkip:1;
UINT8 ccmp:1;
UINT8 rsvd:4;
} Cipher_t;
/* This struct definition is used in ROM and should be kept intact */
typedef MLAN_PACK_START struct {
UINT16 noRsn:1;
UINT16 wepStatic:1;
UINT16 wepDynamic:1;
UINT16 wpa:1;
UINT16 wpaNone:1;
UINT16 wpa2:1;
UINT16 cckm:1;
UINT16 wapi:1;
UINT16 rsvd:8;
} MLAN_PACK_END SecurityMode_t;
typedef MLAN_PACK_START enum {
AKM_NONE = 0,
AKM_1X = 1,
AKM_PSK = 2,
AKM_FT_1X = 3,
AKM_FT_PSK = 4,
AKM_SHA256_1X = 5,
AKM_SHA256_PSK = 6,
AKM_TDLS = 7,
AKM_CCKM = 99, /* Make CCKM a unique AKM enumeration */
AKM_WPA_MAX = 2, /* Only AKM types 1 and 2 are expected for WPA */
AKM_RSN_MAX = 6, /* AKM types 1 to 6 are valid for RSN */
AKM_SUITE_MAX = 5 /* Used to size max parsing of AKMs from a BCN */
} MLAN_PACK_END AkmType_e;
typedef AkmType_e AkmTypePacked_e;
typedef struct {
UINT8 akmOui[3];
AkmTypePacked_e akmType;
} AkmSuite_t;
typedef struct {
SecurityMode_t wpaType;
Cipher_t mcstCipher;
Cipher_t ucstCipher;
} SecurityParams_t;
typedef enum {
host_PSK_SUPP_MIC_FAIL_TIMEOUT = 0x0001,
host_PSK_SUPP_FOURWAY_HANDSHAKE_FAIL = 0x0002
} host_psk_suppMsg_e;
typedef struct {
UINT8 keyId[2];
UINT8 IPN[6];
UINT8 IGtk[32];
} IGtkKde_t;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,243 @@
/** @file keyMgntsta_rom.h
*
* @brief This file contains key management function for sta
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#ifndef _KEY_MGMT_STA_ROM_H_
#define _KEY_MGMT_STA_ROM_H_
#include "keyCommonDef.h"
#include "KeyApiStaDefs.h"
#include "IEEE_types.h"
#include "keyApiStaTypes.h"
//#include "keyMgmtStaHostTypes.h"
#include "authenticator.h"
#include "keyMgmtApStaCommon.h"
/* Timer ID passed back to the caller when starting a timer. */
typedef UINT32 MicroTimerId_t;
/* Callback function registered when starting a timer */
typedef void (*MicroTimerCallback_t) (MicroTimerId_t, UINT32);
#define PMKID_LEN 16
extern void updateApReplayCounter(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtStaInfo,
UINT8 *pRxReplayCount);
extern KDE_t *parseKeyKDE(phostsa_private priv,
IEEEtypes_InfoElementHdr_t *pIe);
extern void supplicantGenerateSha1Pmkid(phostsa_private priv, UINT8 *pPMK,
IEEEtypes_MacAddr_t *pBssid,
IEEEtypes_MacAddr_t *pSta,
UINT8 *pPMKID);
extern void FillKeyMaterialStruct_internal(phostsa_private priv,
key_MgtMaterial_t *p_keyMgtData,
UINT16 key_len, UINT8 isPairwise,
KeyData_t *pKey);
extern BOOLEAN (*supplicantSetAssocRsn_internal_hook) (RSNConfig_t *pRsnConfig,
SecurityParams_t
*pSecurityParams,
SecurityMode_t wpaType,
Cipher_t *pMcstCipher,
Cipher_t *pUcstCipher,
AkmSuite_t *pAkm,
IEEEtypes_RSNCapability_t
*pRsnCap,
Cipher_t
*pGrpMgmtCipher);
extern void supplicantSetAssocRsn_internal(phostsa_private priv,
RSNConfig_t *pRsnConfig,
SecurityParams_t *pSecurityParams,
SecurityMode_t wpaType,
Cipher_t *pMcstCipher,
Cipher_t *pUcstCipher,
AkmSuite_t *pAkm,
IEEEtypes_RSNCapability_t *pRsnCap,
Cipher_t *pGrpMgmtCipher);
#if 0
extern BOOLEAN (*keyMgmtFormatWpaRsnIe_internal_hook) (RSNConfig_t *pRsnConfig,
UINT8 *pos,
IEEEtypes_MacAddr_t
*pBssid,
IEEEtypes_MacAddr_t
*pStaAddr, UINT8 *pPmkid,
BOOLEAN addPmkid,
UINT16 *ptr_val);
#endif
extern UINT16 keyMgmtFormatWpaRsnIe_internal(phostsa_private priv,
RSNConfig_t *pRsnConfig,
UINT8 *pos,
IEEEtypes_MacAddr_t *pBssid,
IEEEtypes_MacAddr_t *pStaAddr,
UINT8 *pPmkid, BOOLEAN addPmkid);
#if 0
extern BOOLEAN (*install_wpa_none_keys_internal_hook) (key_MgtMaterial_t
*p_keyMgtData,
UINT8 *pPMK, UINT8 type,
UINT8 unicast);
#endif
extern void install_wpa_none_keys_internal(phostsa_private priv,
key_MgtMaterial_t *p_keyMgtData,
UINT8 *pPMK, UINT8 type,
UINT8 unicast);
#if 0
extern BOOLEAN (*keyMgmtGetKeySize_internal_hook) (RSNConfig_t *pRsnConfig,
UINT8 isPairwise,
UINT16 *ptr_val);
#endif
extern UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,
UINT8 isPairwise);
extern BOOLEAN supplicantAkmIsWpaWpa2(phostsa_private priv, AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmIsWpaWpa2Psk(phostsa_private priv,
AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmUsesKdf(phostsa_private priv, AkmSuite_t *pAkm);
#if 0
extern
BOOLEAN (*parseKeyKDE_DataType_hook) (UINT8 *pData,
SINT32 dataLen,
IEEEtypes_KDEDataType_e KDEDataType,
UINT32 *ptr_val);
#endif
extern KDE_t *parseKeyKDE_DataType(phostsa_private priv, UINT8 *pData,
SINT32 dataLen,
IEEEtypes_KDEDataType_e KDEDataType);
#if 0
extern BOOLEAN (*parseKeyDataGTK_hook) (UINT8 *pKey,
UINT16 len,
KeyData_t *pGRKey, UINT32 *ptr_val);
#endif
extern KDE_t *parseKeyDataGTK(phostsa_private priv, UINT8 *pKey, UINT16 len,
KeyData_t *pGRKey);
extern BOOLEAN IsEAPOL_MICValid(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
UINT8 *pMICKey);
#if 0
extern BOOLEAN (*KeyMgmtSta_ApplyKEK_hook) (EAPOL_KeyMsg_t *pKeyMsg,
KeyData_t *pGRKey,
UINT8 *EAPOL_Encr_Key);
#endif
extern void KeyMgmtSta_ApplyKEK(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
KeyData_t *pGRKey, UINT8 *EAPOL_Encr_Key);
#if 0
extern
BOOLEAN (*KeyMgmtSta_IsRxEAPOLValid_hook) (keyMgmtInfoSta_t *pKeyMgmtInfoSta,
EAPOL_KeyMsg_t *pKeyMsg,
BOOLEAN *ptr_val);
#endif
extern BOOLEAN KeyMgmtSta_IsRxEAPOLValid(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtInfoSta,
EAPOL_KeyMsg_t *pKeyMsg);
extern void KeyMgmtSta_PrepareEAPOLFrame(phostsa_private priv,
EAPOL_KeyMsg_Tx_t *pTxEapol,
EAPOL_KeyMsg_t *pRxEapol, t_u8 *da,
t_u8 *sa, UINT8 *pSNonce);
extern UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(phostsa_private priv,
EAPOL_KeyMsg_Tx_t *pTxEapol,
UINT8 *pEAPOLMICKey,
UINT8 eapolProtocolVersion,
UINT8 forceKeyDescVersion);
extern
void KeyMgmtSta_PrepareEAPOLMicErrFrame(phostsa_private priv,
EAPOL_KeyMsg_Tx_t *pTxEapol,
BOOLEAN isUnicast,
IEEEtypes_MacAddr_t *da,
IEEEtypes_MacAddr_t *sa,
keyMgmtInfoSta_t *pKeyMgmtInfoSta);
extern BOOLEAN supplicantAkmWpa2Ft(phostsa_private priv, AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmUsesSha256Pmkid(phostsa_private priv,
AkmSuite_t *pAkm);
extern void supplicantGenerateSha256Pmkid(phostsa_private priv, UINT8 *pPMK,
IEEEtypes_MacAddr_t *pBssid,
IEEEtypes_MacAddr_t *pSta,
UINT8 *pPMKID);
extern BOOLEAN supplicantGetPmkid(phostsa_private priv,
IEEEtypes_MacAddr_t *pBssid,
IEEEtypes_MacAddr_t *pStaAddr,
AkmSuite_t *pAkm, UINT8 *pPMKID);
extern void KeyMgmt_DerivePTK(phostsa_private priv, UINT8 *pAddr1,
UINT8 *pAddr2,
UINT8 *pNonce1,
UINT8 *pNonce2,
UINT8 *pPTK, UINT8 *pPMK, BOOLEAN use_kdf);
extern void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,
BOOLEAN isWPA2,
BOOLEAN isKDF, BOOLEAN nonTKIP);
extern void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo);
extern void keyMgmtSta_StartSession_internal(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtInfoSta,
//MicroTimerCallback_t callback,
UINT32 expiry, UINT8 flags);
extern void KeyMgmtSta_handleMICDeauthTimer(keyMgmtInfoSta_t *pKeyMgmtInfoSta,
MicroTimerCallback_t callback,
UINT32 expiry, UINT8 flags);
extern void KeyMgmtSta_handleMICErr(MIC_Fail_State_e state,
keyMgmtInfoSta_t *pKeyMgmtInfoSta,
MicroTimerCallback_t callback, UINT8 flags);
extern void DeauthDelayTimerExp_Sta(t_void *context);
extern void keyMgmtStaRsnSecuredTimeoutHandler(t_void *context);
extern void keyMgmtSendDeauth2Peer(phostsa_private priv, UINT16 reason);
extern void supplicantGenerateRand(hostsa_private *priv, UINT8 *dataOut,
UINT32 length);
extern EAPOL_KeyMsg_t *GetKeyMsgNonceFromEAPOL(phostsa_private priv,
mlan_buffer *pmbuf,
keyMgmtInfoSta_t
*pKeyMgmtInfoSta);
extern EAPOL_KeyMsg_t *ProcessRxEAPOL_PwkMsg3(phostsa_private priv,
mlan_buffer *pmbuf,
keyMgmtInfoSta_t
*pKeyMgmtInfoSta);
extern EAPOL_KeyMsg_t *ProcessRxEAPOL_GrpMsg1(phostsa_private priv,
mlan_buffer *pmbuf,
keyMgmtInfoSta_t
*pKeyMgmtInfoSta);
extern void KeyMgmtSta_InitSession(phostsa_private priv,
keyMgmtInfoSta_t *pKeyMgmtInfoSta);
extern void supplicantParseMcstCipher(phostsa_private priv,
Cipher_t *pMcstCipherOut,
UINT8 *pGrpKeyCipher);
extern void supplicantParseUcstCipher(phostsa_private priv,
Cipher_t *pUcstCipherOut, UINT8 pwsKeyCnt,
UINT8 *pPwsKeyCipherList);
#endif

View File

@@ -0,0 +1,151 @@
/** @file supplicant.c
*
* @brief This file defines the API for supplicant
*
* Copyright (C) 2014-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
03/07/2014: Initial version
******************************************************/
#include "wltypes.h"
#include "keyMgmtSta.h"
#include "keyCommonDef.h"
#include "keyMgmtSta.h"
#include "pmkCache.h"
t_u8
EAPoLKeyPkt_Validation(mlan_buffer *pmbuf)
{
t_u32 recvd_pkt_len, eapol_pkt_len;
EAPOL_KeyMsg_t *pKeyMsg = NULL;
pKeyMsg =
(EAPOL_KeyMsg_t *)(pmbuf->pbuf + pmbuf->data_offset +
sizeof(ether_hdr_t));
/* Received eapol pkt length: DataLen - 802.3 header */
recvd_pkt_len = pmbuf->data_len - sizeof(ether_hdr_t);
/* 8021.X header + EAPOL key pkt header */
eapol_pkt_len = sizeof(EAPOL_KeyMsg_t) - sizeof(pKeyMsg->key_data);
if (recvd_pkt_len < eapol_pkt_len) {
PRINTM(MERROR,
"Invalid EAPOL Key Msg, received length: %u, least length: %u\n",
recvd_pkt_len, eapol_pkt_len);
return 1;
}
/* Todo: other validation check */
return 0;
}
static __inline void
ProcessEAPoLKeyPkt(phostsa_private priv, mlan_buffer *pmbuf,
IEEEtypes_MacAddr_t *sa, IEEEtypes_MacAddr_t *da)
{
hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
t_u8 bss_role = pm_fns->Hostsa_get_bss_role(pm_fns->pmlan_private);
PRINTM(MMSG, "ProcessEAPoLKeyPk bss_type=%x bss_role=%x\n",
pm_fns->bss_type, bss_role);
#ifdef MIB_STATS
INC_MIB_STAT(connPtr, eapolRxForESUPPCnt);
#endif
if (EAPoLKeyPkt_Validation(pmbuf) != 0)
return;
switch (bss_role) {
#ifdef BTAMP
case CONNECTION_TYPE_BTAMP:
ProcessKeyMgmtDataAmp(bufDesc);
break;
#endif
case MLAN_BSS_ROLE_STA:
/*key data */
ProcessKeyMgmtDataSta(priv, pmbuf, sa, da);
break;
default:
#ifdef AUTHENTICATOR
if (WIFI_DIRECT_MODE_GO == connPtr->DeviceMode) {
ProcessKeyMgmtDataAp(bufDesc);
}
#endif
break;
}
}
t_u8
ProcessEAPoLPkt(void *priv, mlan_buffer *pmbuf)
{
phostsa_private psapriv = (phostsa_private)priv;
ether_hdr_t *pEthHdr =
(ether_hdr_t *)(pmbuf->pbuf + pmbuf->data_offset);
EAP_PacketMsg_t *pEapPkt = NULL;
UINT8 fPacketProcessed = 0;
pEapPkt = (EAP_PacketMsg_t *)((t_u8 *)pEthHdr + sizeof(ether_hdr_t));
switch (pEapPkt->hdr_8021x.pckt_type) {
case IEEE_8021X_PACKET_TYPE_EAPOL_KEY:
ProcessEAPoLKeyPkt(psapriv, pmbuf,
(IEEEtypes_MacAddr_t *)pEthHdr->sa,
(IEEEtypes_MacAddr_t *)pEthHdr->da);
fPacketProcessed = 1;
break;
#if 0
case IEEE_8021X_PACKET_TYPE_EAP_PACKET:
{
if (WIFI_DIRECT_MODE_CLIENT == connPtr->DeviceMode
|| WIFI_DIRECT_MODE_DEVICE == connPtr->DeviceMode) {
if (pEapPkt->code ==
IEEE_8021X_CODE_TYPE_REQUEST) {
assocAgent_eapRequestRx(sa);
}
}
}
break;
#endif
default:
break;
}
// CLEAN_FLUSH_CACHED_SQMEM((UINT32)(pEapPkt), bufDesc->DataLen);
return fPacketProcessed;
}
Status_e
supplicantRestoreDefaults(void *priv)
{
pmkCacheInit(priv);
return SUCCESS;
}
/* This can also be removed*/
//#pragma arm section code = ".init"
void
supplicantFuncInit(void *priv)
{
supplicantRestoreDefaults(priv);
}
//#pragma arm section code
//#endif /* PSK_SUPPLICANT */

View File

@@ -0,0 +1,35 @@
/** @file mlan.h
*
* @brief This file declares all APIs that will be called from MOAL module.
* It also defines the data structures used for APIs between MLAN and MOAL.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
10/13/2008: initial version
11/07/2008: split mlan.h into mlan_decl.h & mlan_ioctl.h
******************************************************/
#ifndef _MLAN_H_
#define _MLAN_H_
#include "mlan_decl.h"
#include "mlan_ioctl.h"
#include "mlan_ieee.h"
#endif /* !_MLAN_H_ */

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,189 @@
/** @file mlan_11h.h
*
* @brief This header file contains data structures and
* function declarations of 802.11h
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/*************************************************************
Change Log:
03/26/2009: initial creation
*************************************************************/
#ifndef _MLAN_11H_
#define _MLAN_11H_
/** 11H OID bitmasks */
#define ENABLE_11H_MASK MBIT(0)
#define MASTER_RADAR_DET_MASK MBIT(1)
#define SLAVE_RADAR_DET_MASK MBIT(2)
/** DFS Master Radar Detect global enable */
#define DFS_MASTER_RADAR_DETECT_EN (MTRUE)
/** DFS Slave Radar Detect global enable */
#define DFS_SLAVE_RADAR_DETECT_EN (MFALSE)
#define CHANNEL_OFFSET_MASK 0x30
#define CHANNEL_BANDWIDTH_MASK 0x0C
/**
* 11H APIs
*/
/* Is master radar detection enabled in firmware? */
extern t_bool wlan_11h_is_master_radar_det_active(mlan_private *priv);
/** Configure master radar detection.
* Need call wlan_11h_check_update_radar_det_state() after.
*/
extern mlan_status wlan_11h_config_master_radar_det(mlan_private *priv,
t_bool enable);
/** Configure slave radar detection.
* Need call wlan_11h_check_update_radar_det_state() after.
*/
extern mlan_status wlan_11h_config_slave_radar_det(mlan_private *priv,
t_bool enable);
/** Checks all interfaces and updates radar detect flags if necessary */
extern mlan_status wlan_11h_check_update_radar_det_state(mlan_private *pmpriv);
/** Return 1 if 11h is active in the firmware, 0 if it is inactive */
extern t_bool wlan_11h_is_active(mlan_private *priv);
/** Enable the tx interface and record the new transmit state */
extern void wlan_11h_tx_enable(mlan_private *priv);
/** Disable the tx interface and record the new transmit state */
extern void wlan_11h_tx_disable(mlan_private *priv);
/** Activate 11h extensions in the firmware */
extern mlan_status wlan_11h_activate(mlan_private *priv, t_void *pioctl_buf,
t_bool flag);
/** Initialize the 11h device structure */
extern void wlan_11h_init(mlan_adapter *pmadapter);
/** Cleanup for the 11h device structure */
extern void wlan_11h_cleanup(mlan_adapter *pmadapter);
/** Initialize the 11h interface structure */
extern void wlan_11h_priv_init(mlan_private *pmpriv);
/** Get an initial random channel to start an adhoc network on */
extern t_u8 wlan_11h_get_adhoc_start_channel(mlan_private *priv);
/** Get channel that has been closed via Channel Switch Announcement */
extern t_u8 wlan_11h_get_csa_closed_channel(mlan_private *priv);
/** Check if radar detection is required on the specified channel */
extern t_bool wlan_11h_radar_detect_required(mlan_private *priv, t_u8 channel);
/** Perform a standard availibility check on the specified channel */
extern t_s32 wlan_11h_issue_radar_detect(mlan_private *priv,
pmlan_ioctl_req pioctl_req,
t_u8 channel, Band_Config_t bandcfg);
/** Check previously issued radar report for a channel */
extern mlan_status wlan_11h_check_chan_report(mlan_private *priv, t_u8 chan);
/** Add any 11h TLVs necessary to complete an adhoc start command */
extern t_s32 wlan_11h_process_start(mlan_private *priv,
t_u8 **ppbuffer,
IEEEtypes_CapInfo_t *pcap_info,
t_u32 channel,
wlan_11h_bss_info_t *p11h_bss_info);
/** Add any 11h TLVs necessary to complete a join command (adhoc or infra) */
extern t_s32 wlan_11h_process_join(mlan_private *priv,
t_u8 **ppbuffer,
IEEEtypes_CapInfo_t *pcap_info,
t_u8 band,
t_u32 channel,
wlan_11h_bss_info_t *p11h_bss_info);
/** Complete the firmware command preparation for an 11h command function */
extern mlan_status wlan_11h_cmd_process(mlan_private *priv,
HostCmd_DS_COMMAND *pcmd_ptr,
const t_void *pinfo_buf);
/** Process the response of an 11h firmware command */
extern mlan_status wlan_11h_cmdresp_process(mlan_private *priv,
const HostCmd_DS_COMMAND *resp);
/** Receive IEs from scan processing and record any needed info for 11h */
extern mlan_status wlan_11h_process_bss_elem(mlan_adapter *pmadapter,
wlan_11h_bss_info_t *p11h_bss_info,
const t_u8 *pelement);
/** Handler for EVENT_CHANNEL_SWITCH_ANN */
extern mlan_status wlan_11h_handle_event_chanswann(mlan_private *priv);
/** Handler for EVENT_CHANNEL_REPORT_RDY */
extern mlan_status wlan_11h_handle_event_chanrpt_ready(mlan_private *priv,
mlan_event *pevent);
#ifdef DFS_TESTING_SUPPORT
/** Handler for DFS_TESTING IOCTL */
extern mlan_status wlan_11h_ioctl_dfs_testing(pmlan_adapter pmadapter,
pmlan_ioctl_req pioctl_req);
extern mlan_status wlan_11h_ioctl_get_channel_nop_info(pmlan_adapter pmadapter,
pmlan_ioctl_req
pioctl_req);
#endif
extern mlan_status
wlan_11h_ioctl_dfs_cancel_chan_report(mlan_private *priv,
pmlan_ioctl_req pioctl_req);
extern
mlan_status wlan_11h_ioctl_chan_switch_count(pmlan_adapter pmadapter,
pmlan_ioctl_req pioctl_req);
/** Check if channel is under a NOP duration (should not be used) */
extern t_bool wlan_11h_is_channel_under_nop(mlan_adapter *pmadapter,
t_u8 channel);
/** Check if RADAR_DETECTED handling is blocking data tx */
extern t_bool wlan_11h_radar_detected_tx_blocked(mlan_adapter *pmadapter);
/** Callback for RADAR_DETECTED (for UAP cmdresp) */
extern mlan_status wlan_11h_radar_detected_callback(t_void *priv);
/** BW_change event Handler for dfs_repeater */
void wlan_dfs_rep_bw_change(mlan_adapter *pmadapter);
/** disconnect event Handler for dfs_repeater */
void wlan_dfs_rep_disconnect(mlan_adapter *pmadapter);
/** Handler for RADAR_DETECTED */
extern mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
mlan_private *priv);
/** DFS Event pre-processing */
extern mlan_status wlan_11h_dfs_event_preprocessing(mlan_adapter *pmadapter);
/** DFS switch to non-DFS channel */
extern mlan_status wlan_11h_switch_non_dfs_chan(mlan_private *priv, t_u8 *chan);
extern void wlan_11h_update_bandcfg(IN Band_Config_t *uap_band_cfg,
IN t_u8 new_channel);
/** function checks if interface is active. **/
extern t_bool wlan_is_intf_active(mlan_private *pmpriv);
#endif /*_MLAN_11H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,392 @@
/** @file mlan_11n.h
*
* @brief Interface for the 802.11n mlan_11n module implemented in mlan_11n.c
*
* Driver interface functions and type declarations for the 11n module
* implemented in mlan_11n.c.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/********************************************************
Change log:
12/01/2008: initial version
********************************************************/
#ifndef _MLAN_11N_H_
#define _MLAN_11N_H_
#include "mlan_11n_aggr.h"
#include "mlan_11n_rxreorder.h"
#include "mlan_wmm.h"
/** Print the 802.11n device capability */
void wlan_show_dot11ndevcap(pmlan_adapter pmadapter, t_u32 cap);
/** Print the 802.11n device MCS */
void wlan_show_devmcssupport(pmlan_adapter pmadapter, t_u8 support);
/** Handle the command response of a delete block ack request */
mlan_status wlan_ret_11n_delba(mlan_private *priv, HostCmd_DS_COMMAND *resp);
/** Handle the command response of an add block ack request */
mlan_status wlan_ret_11n_addba_req(mlan_private *priv,
HostCmd_DS_COMMAND *resp);
/** Handle the command response of 11ncfg command */
mlan_status wlan_ret_11n_cfg(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *resp,
IN mlan_ioctl_req *pioctl_buf);
/** Prepare 11ncfg command */
mlan_status wlan_cmd_11n_cfg(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action,
IN t_void *pdata_buf);
/** Prepare reject addba requst command */
mlan_status wlan_cmd_reject_addba_req(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *cmd,
IN t_u16 cmd_action,
IN t_void *pdata_buf);
/** Handle the command response of rejecting addba request */
mlan_status wlan_ret_reject_addba_req(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *resp,
IN mlan_ioctl_req *pioctl_buf);
/** Prepare TX BF configuration command */
mlan_status wlan_cmd_tx_bf_cfg(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *cmd,
IN t_u16 cmd_action, IN t_void *pdata_buf);
/** Handle the command response TX BF configuration */
mlan_status wlan_ret_tx_bf_cfg(IN pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *resp,
IN mlan_ioctl_req *pioctl_buf);
#ifdef STA_SUPPORT
t_u8 wlan_11n_bandconfig_allowed(mlan_private *pmpriv, t_u8 bss_band);
/** Append the 802_11N tlv */
int wlan_cmd_append_11n_tlv(IN mlan_private *pmpriv,
IN BSSDescriptor_t *pbss_desc, OUT t_u8 **ppbuffer);
/** wlan fill HT cap tlv */
void wlan_fill_ht_cap_tlv(mlan_private *priv, MrvlIETypes_HTCap_t *pht_cap,
t_u8 band, t_u8 fill);
/** wlan fill HT cap IE */
void wlan_fill_ht_cap_ie(mlan_private *priv, IEEEtypes_HTCap_t *pht_cap,
t_u8 bands);
#endif /* STA_SUPPORT */
/** Miscellaneous configuration handler */
mlan_status wlan_11n_cfg_ioctl(IN pmlan_adapter pmadapter,
IN pmlan_ioctl_req pioctl_req);
/** Delete Tx BA stream table entry */
void wlan_11n_delete_txbastream_tbl_entry(mlan_private *priv,
TxBAStreamTbl *ptx_tbl);
/** Delete all Tx BA stream table entries */
void wlan_11n_deleteall_txbastream_tbl(mlan_private *priv);
/** Get Tx BA stream table */
TxBAStreamTbl *wlan_11n_get_txbastream_tbl(mlan_private *priv, int tid,
t_u8 *ra, int lock);
/** Create Tx BA stream table */
void wlan_11n_create_txbastream_tbl(mlan_private *priv, t_u8 *ra, int tid,
baStatus_e ba_status);
/** Send ADD BA request */
int wlan_send_addba(mlan_private *priv, int tid, t_u8 *peer_mac);
/** Send DEL BA request */
int wlan_send_delba(mlan_private *priv, pmlan_ioctl_req pioctl_req, int tid,
t_u8 *peer_mac, int initiator);
/** This function handles the command response of delete a block ack request*/
void wlan_11n_delete_bastream(mlan_private *priv, t_u8 *del_ba);
/** get rx reorder table */
int wlan_get_rxreorder_tbl(mlan_private *priv, rx_reorder_tbl *buf);
/** get tx ba stream table */
int wlan_get_txbastream_tbl(mlan_private *priv, tx_ba_stream_tbl *buf);
/** send delba */
void wlan_11n_delba(mlan_private *priv, int tid);
/** update amdpdu tx win size */
void wlan_update_ampdu_txwinsize(pmlan_adapter pmadapter);
/** Minimum number of AMSDU */
#define MIN_NUM_AMSDU 2
/** AMSDU Aggr control cmd resp */
mlan_status wlan_ret_amsdu_aggr_ctrl(pmlan_private pmpriv,
HostCmd_DS_COMMAND *resp,
mlan_ioctl_req *pioctl_buf);
void wlan_set_tx_pause_flag(mlan_private *priv, t_u8 flag);
/** reconfigure tx buf size */
mlan_status wlan_cmd_recfg_tx_buf(mlan_private *priv,
HostCmd_DS_COMMAND *cmd,
int cmd_action, void *pdata_buf);
/** AMSDU aggr control cmd */
mlan_status wlan_cmd_amsdu_aggr_ctrl(mlan_private *priv,
HostCmd_DS_COMMAND *cmd,
int cmd_action, void *pdata_buf);
t_u8 wlan_validate_chan_offset(IN mlan_private *pmpriv,
IN t_u8 band, IN t_u32 chan, IN t_u8 chan_bw);
/** get channel offset */
t_u8 wlan_get_second_channel_offset(int chan);
void wlan_update_11n_cap(mlan_private *pmpriv);
/** clean up txbastream_tbl */
void wlan_11n_cleanup_txbastream_tbl(mlan_private *priv, t_u8 *ra);
/**
* @brief This function checks whether a station has 11N enabled or not
*
* @param priv A pointer to mlan_private
* @param mac station mac address
* @return MTRUE or MFALSE
*/
static INLINE t_u8
is_station_11n_enabled(mlan_private *priv, t_u8 *mac)
{
sta_node *sta_ptr = MNULL;
sta_ptr = wlan_get_station_entry(priv, mac);
if (sta_ptr)
return (sta_ptr->is_11n_enabled) ? MTRUE : MFALSE;
return MFALSE;
}
/**
* @brief This function get station max amsdu size
*
* @param priv A pointer to mlan_private
* @param mac station mac address
* @return max amsdu size statio supported
*/
static INLINE t_u16
get_station_max_amsdu_size(mlan_private *priv, t_u8 *mac)
{
sta_node *sta_ptr = MNULL;
sta_ptr = wlan_get_station_entry(priv, mac);
if (sta_ptr)
return sta_ptr->max_amsdu;
return 0;
}
/**
* @brief This function checks whether a station allows AMPDU or not
*
* @param priv A pointer to mlan_private
* @param ptr A pointer to RA list table
* @param tid TID value for ptr
* @return MTRUE or MFALSE
*/
static INLINE t_u8
is_station_ampdu_allowed(mlan_private *priv, raListTbl *ptr, int tid)
{
sta_node *sta_ptr = MNULL;
sta_ptr = wlan_get_station_entry(priv, ptr->ra);
if (sta_ptr) {
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
if (priv->sec_info.wapi_enabled &&
!sta_ptr->wapi_key_on)
return MFALSE;
}
return (sta_ptr->ampdu_sta[tid] != BA_STREAM_NOT_ALLOWED)
? MTRUE : MFALSE;
}
return MFALSE;
}
/**
* @brief This function disable station ampdu for specific tid
*
* @param priv A pointer to mlan_private
* @param tid tid index
* @param ra station mac address
* @return N/A
*/
static INLINE void
disable_station_ampdu(mlan_private *priv, t_u8 tid, t_u8 *ra)
{
sta_node *sta_ptr = MNULL;
sta_ptr = wlan_get_station_entry(priv, ra);
if (sta_ptr)
sta_ptr->ampdu_sta[tid] = BA_STREAM_NOT_ALLOWED;
return;
}
/**
* @brief This function reset station ampdu for specific id to user setting.
*
* @param priv A pointer to mlan_private
* @param tid tid index
* @param ra station mac address
* @return N/A
*/
static INLINE void
reset_station_ampdu(mlan_private *priv, t_u8 tid, t_u8 *ra)
{
sta_node *sta_ptr = MNULL;
sta_ptr = wlan_get_station_entry(priv, ra);
if (sta_ptr)
sta_ptr->ampdu_sta[tid] = priv->aggr_prio_tbl[tid].ampdu_user;
return;
}
/**
* @brief This function checks whether AMPDU is allowed or not
*
* @param priv A pointer to mlan_private
* @param ptr A pointer to RA list table
* @param tid TID value for ptr
*
* @return MTRUE or MFALSE
*/
static INLINE t_u8
wlan_is_ampdu_allowed(mlan_private *priv, raListTbl *ptr, int tid)
{
#ifdef UAP_SUPPORT
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP)
return is_station_ampdu_allowed(priv, ptr, tid);
#endif /* UAP_SUPPORT */
if (priv->sec_info.wapi_enabled && !priv->sec_info.wapi_key_on)
return MFALSE;
if (ptr->is_tdls_link)
return is_station_ampdu_allowed(priv, ptr, tid);
if (priv->adapter->tdls_status != TDLS_NOT_SETUP && !priv->txaggrctrl)
return MFALSE;
if (priv->bss_mode == MLAN_BSS_MODE_IBSS)
return is_station_ampdu_allowed(priv, ptr, tid);
return (priv->aggr_prio_tbl[tid].ampdu_ap != BA_STREAM_NOT_ALLOWED)
? MTRUE : MFALSE;
}
/**
* @brief This function checks whether AMSDU is allowed or not
*
* @param priv A pointer to mlan_private
* @param ptr A pointer to RA list table
* @param tid TID value for ptr
*
* @return MTRUE or MFALSE
*/
static INLINE t_u8
wlan_is_amsdu_allowed(mlan_private *priv, raListTbl *ptr, int tid)
{
#ifdef UAP_SUPPORT
sta_node *sta_ptr = MNULL;
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
sta_ptr = wlan_get_station_entry(priv, ptr->ra);
if (sta_ptr) {
if (priv->sec_info.wapi_enabled &&
!sta_ptr->wapi_key_on)
return MFALSE;
}
}
#endif /* UAP_SUPPORT */
#define TXRATE_BITMAP_INDEX_MCS0_7 2
return ((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED)
&&((priv->is_data_rate_auto)
|| !((priv->bitmap_rates[TXRATE_BITMAP_INDEX_MCS0_7]) &
0x03))) ? MTRUE : MFALSE;
}
/**
* @brief This function checks whether a BA stream is available or not
*
* @param priv A pointer to mlan_private
*
* @return MTRUE or MFALSE
*/
static INLINE t_u8
wlan_is_bastream_avail(mlan_private *priv)
{
mlan_private *pmpriv = MNULL;
t_u8 i = 0;
t_u32 bastream_num = 0;
t_u32 bastream_max = 0;
for (i = 0; i < priv->adapter->priv_num; i++) {
pmpriv = priv->adapter->priv[i];
if (pmpriv)
bastream_num +=
wlan_wmm_list_len(priv->adapter,
(pmlan_list_head)&pmpriv->
tx_ba_stream_tbl_ptr);
}
bastream_max = ISSUPP_GETTXBASTREAM(priv->adapter->hw_dot_11n_dev_cap);
if (bastream_max == 0)
bastream_max = MLAN_MAX_TX_BASTREAM_DEFAULT;
return (bastream_num < bastream_max) ? MTRUE : MFALSE;
}
/**
* @brief This function finds the stream to delete
*
* @param priv A pointer to mlan_private
* @param ptr A pointer to RA list table
* @param ptr_tid TID value of ptr
* @param ptid A pointer to TID of stream to delete, if return MTRUE
* @param ra RA of stream to delete, if return MTRUE
*
* @return MTRUE or MFALSE
*/
static INLINE t_u8
wlan_find_stream_to_delete(mlan_private *priv,
raListTbl *ptr, int ptr_tid, int *ptid, t_u8 *ra)
{
int tid;
t_u8 ret = MFALSE;
TxBAStreamTbl *ptx_tbl;
ENTER();
ptx_tbl = (TxBAStreamTbl *)util_peek_list(priv->adapter->pmoal_handle,
&priv->tx_ba_stream_tbl_ptr,
MNULL, MNULL);
if (!ptx_tbl) {
LEAVE();
return ret;
}
tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
while (ptx_tbl != (TxBAStreamTbl *)&priv->tx_ba_stream_tbl_ptr) {
if (tid > priv->aggr_prio_tbl[ptx_tbl->tid].ampdu_user) {
tid = priv->aggr_prio_tbl[ptx_tbl->tid].ampdu_user;
*ptid = ptx_tbl->tid;
memcpy(priv->adapter, ra, ptx_tbl->ra,
MLAN_MAC_ADDR_LENGTH);
ret = MTRUE;
}
ptx_tbl = ptx_tbl->pnext;
}
LEAVE();
return ret;
}
/**
* @brief This function checks whether 11n is supported
*
* @param priv A pointer to mlan_private
* @param ra Address of the receiver STA
*
* @return MTRUE or MFALSE
*/
static int INLINE
wlan_is_11n_enabled(mlan_private *priv, t_u8 *ra)
{
int ret = MFALSE;
ENTER();
#ifdef UAP_SUPPORT
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
if ((!(ra[0] & 0x01)) && (priv->is_11n_enabled))
ret = is_station_11n_enabled(priv, ra);
}
#endif /* UAP_SUPPORT */
#ifdef STA_SUPPORT
if (priv->bss_mode == MLAN_BSS_MODE_IBSS) {
if ((!(ra[0] & 0x01)) && (priv->adapter->adhoc_11n_enabled))
ret = is_station_11n_enabled(priv, ra);
}
#endif
LEAVE();
return ret;
}
#endif /* !_MLAN_11N_H_ */

View File

@@ -0,0 +1,592 @@
/** @file mlan_11n_aggr.c
*
* @brief This file contains functions for 11n Aggregation.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/********************************************************
Change log:
11/10/2008: initial version
********************************************************/
#include "mlan.h"
#include "mlan_join.h"
#include "mlan_util.h"
#include "mlan_fw.h"
#include "mlan_main.h"
#include "mlan_wmm.h"
#include "mlan_11n.h"
#include "mlan_11n_aggr.h"
#include "mlan_sdio.h"
/********************************************************
Local Variables
********************************************************/
/********************************************************
Global Variables
********************************************************/
/********************************************************
Local Functions
********************************************************/
/**
* @brief Aggregate individual packets into one AMSDU packet
*
* @param pmadapter A pointer to mlan_adapter structure
* @param amsdu_buf A pointer to packet buffer
* @param data A pointer to aggregated data packet being formed
* @param pkt_len Length of current packet to aggregate
* @param pad Pad
*
* @return Final packet size
*/
static int
wlan_11n_form_amsdu_pkt(pmlan_adapter pmadapter, t_u8 *amsdu_buf, t_u8 *data,
int pkt_len, int *pad)
{
int dt_offset, amsdu_buf_offset;
Rfc1042Hdr_t snap = {
0xaa, /* LLC DSAP */
0xaa, /* LLC SSAP */
0x03, /* LLC CTRL */
{0x00, 0x00, 0x00}, /* SNAP OUI */
0x0000 /* SNAP type */
/*
* This field will be overwritten
* later with ethertype
*/
};
ENTER();
memcpy(pmadapter, amsdu_buf, data, (MLAN_MAC_ADDR_LENGTH) * 2);
dt_offset = amsdu_buf_offset = (MLAN_MAC_ADDR_LENGTH) * 2;
snap.snap_type = *(t_u16 *)(data + dt_offset);
dt_offset += sizeof(t_u16);
*(t_u16 *)(amsdu_buf + amsdu_buf_offset) = mlan_htons(pkt_len +
LLC_SNAP_LEN -
((2 *
MLAN_MAC_ADDR_LENGTH)
+
sizeof(t_u16)));
amsdu_buf_offset += sizeof(t_u16);
memcpy(pmadapter, amsdu_buf + amsdu_buf_offset, &snap, LLC_SNAP_LEN);
amsdu_buf_offset += LLC_SNAP_LEN;
memcpy(pmadapter, amsdu_buf + amsdu_buf_offset, data + dt_offset,
pkt_len - dt_offset);
*pad = (((pkt_len + LLC_SNAP_LEN) & 3)) ? (4 -
(((pkt_len +
LLC_SNAP_LEN)) & 3)) : 0;
LEAVE();
return pkt_len + LLC_SNAP_LEN + *pad;
}
/**
* @brief Add TxPD to AMSDU header
*
* @param priv A pointer to mlan_private structure
* @param mbuf Pointer to buffer where the TxPD will be formed
*
* @return N/A
*/
static void
wlan_11n_form_amsdu_txpd(mlan_private *priv, mlan_buffer *mbuf)
{
TxPD *ptx_pd;
mlan_adapter *pmadapter = priv->adapter;
ENTER();
ptx_pd = (TxPD *)mbuf->pbuf;
memset(pmadapter, ptx_pd, 0, sizeof(TxPD));
/*
* Original priority has been overwritten
*/
ptx_pd->priority = (t_u8)mbuf->priority;
ptx_pd->pkt_delay_2ms =
wlan_wmm_compute_driver_packet_delay(priv, mbuf);
ptx_pd->bss_num = GET_BSS_NUM(priv);
ptx_pd->bss_type = priv->bss_type;
/* Always zero as the data is followed by TxPD */
ptx_pd->tx_pkt_offset = sizeof(TxPD);
ptx_pd->tx_pkt_type = PKT_TYPE_AMSDU;
if (mbuf->flags & MLAN_BUF_FLAG_TDLS)
ptx_pd->flags = MRVDRV_TxPD_FLAGS_TDLS_PACKET;
if (ptx_pd->tx_control == 0)
/* TxCtrl set by user or default */
ptx_pd->tx_control = priv->pkt_tx_ctrl;
endian_convert_TxPD(ptx_pd);
LEAVE();
}
/**
* @brief Update the TxPktLength field in TxPD after the complete AMSDU
* packet is formed
*
* @param priv A pointer to mlan_private structure
* @param mbuf TxPD buffer
*
* @return N/A
*/
static INLINE void
wlan_11n_update_pktlen_amsdu_txpd(mlan_private *priv, pmlan_buffer mbuf)
{
TxPD *ptx_pd;
ENTER();
ptx_pd = (TxPD *)mbuf->pbuf;
ptx_pd->tx_pkt_length =
(t_u16)wlan_cpu_to_le16(mbuf->data_len - sizeof(TxPD));
#ifdef STA_SUPPORT
if ((GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
(priv->adapter->pps_uapsd_mode)) {
if (MTRUE == wlan_check_last_packet_indication(priv)) {
priv->adapter->tx_lock_flag = MTRUE;
ptx_pd->flags |= MRVDRV_TxPD_POWER_MGMT_LAST_PACKET;
}
}
#endif /* STA_SUPPORT */
LEAVE();
}
/**
* @brief Get number of aggregated packets
*
* @param data A pointer to packet data
* @param total_pkt_len Total packet length
*
* @return Number of packets
*/
static int
wlan_11n_get_num_aggrpkts(t_u8 *data, int total_pkt_len)
{
int pkt_count = 0, pkt_len, pad;
t_u8 hdr_len = sizeof(Eth803Hdr_t);
ENTER();
while (total_pkt_len >= hdr_len) {
/* Length will be in network format, change it to host */
pkt_len = mlan_ntohs((*(t_u16 *)(data + (2 *
MLAN_MAC_ADDR_LENGTH))));
if (pkt_len > total_pkt_len) {
PRINTM(MERROR, "Error in packet length.\n");
break;
}
pad = (((pkt_len + sizeof(Eth803Hdr_t)) & 3)) ?
(4 - ((pkt_len + sizeof(Eth803Hdr_t)) & 3)) : 0;
data += pkt_len + pad + sizeof(Eth803Hdr_t);
total_pkt_len -= pkt_len + pad + sizeof(Eth803Hdr_t);
++pkt_count;
}
LEAVE();
return pkt_count;
}
/********************************************************
Global Functions
********************************************************/
/**
* @brief Deaggregate the received AMSDU packet
*
* @param priv A pointer to mlan_private structure
* @param pmbuf A pointer to aggregated data packet
*
* @return MLAN_STATUS_SUCCESS --success, otherwise fail
*/
mlan_status
wlan_11n_deaggregate_pkt(mlan_private *priv, pmlan_buffer pmbuf)
{
t_u16 pkt_len;
int total_pkt_len;
t_u8 *data;
mlan_adapter *pmadapter = priv->adapter;
t_u32 max_rx_data_size = MLAN_RX_DATA_BUF_SIZE;
int pad;
mlan_status ret = MLAN_STATUS_FAILURE;
RxPacketHdr_t *prx_pkt;
mlan_buffer *daggr_mbuf = MNULL;
t_u8 rfc1042_eth_hdr[MLAN_MAC_ADDR_LENGTH] = { 0xaa, 0xaa, 0x03,
0x00, 0x00, 0x00
};
t_u8 hdr_len = sizeof(Eth803Hdr_t);
t_u8 eapol_type[2] = { 0x88, 0x8e };
t_u8 tdls_action_type[2] = { 0x89, 0x0d };
ENTER();
data = (t_u8 *)(pmbuf->pbuf + pmbuf->data_offset);
total_pkt_len = pmbuf->data_len;
/* Sanity test */
if (total_pkt_len > max_rx_data_size) {
PRINTM(MERROR, "Total packet length greater than tx buffer"
" size %d\n", total_pkt_len);
goto done;
}
pmbuf->use_count = wlan_11n_get_num_aggrpkts(data, total_pkt_len);
while (total_pkt_len >= hdr_len) {
prx_pkt = (RxPacketHdr_t *)data;
/* Length will be in network format, change it to host */
pkt_len = mlan_ntohs((*(t_u16 *)(data + (2 *
MLAN_MAC_ADDR_LENGTH))));
if (pkt_len > total_pkt_len) {
PRINTM(MERROR,
"Error in packet length: total_pkt_len = %d, pkt_len = %d\n",
total_pkt_len, pkt_len);
ret = MLAN_STATUS_FAILURE;
break;
}
pad = (((pkt_len + sizeof(Eth803Hdr_t)) & 3)) ?
(4 - ((pkt_len + sizeof(Eth803Hdr_t)) & 3)) : 0;
total_pkt_len -= pkt_len + pad + sizeof(Eth803Hdr_t);
if (memcmp(pmadapter, &prx_pkt->rfc1042_hdr,
rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)) == 0) {
memmove(pmadapter, data + LLC_SNAP_LEN, data, (2 *
MLAN_MAC_ADDR_LENGTH));
data += LLC_SNAP_LEN;
pkt_len += sizeof(Eth803Hdr_t) - LLC_SNAP_LEN;
} else {
*(t_u16 *)(data + (2 * MLAN_MAC_ADDR_LENGTH))
= (t_u16)0;
pkt_len += sizeof(Eth803Hdr_t);
}
daggr_mbuf =
wlan_alloc_mlan_buffer(pmadapter,
pkt_len + MLAN_NET_IP_ALIGN, 0,
MOAL_ALLOC_MLAN_BUFFER);
daggr_mbuf->data_offset += MLAN_NET_IP_ALIGN;
if (daggr_mbuf == MNULL) {
PRINTM(MERROR, "Error allocating daggr mlan_buffer\n");
ret = MLAN_STATUS_FAILURE;
break;
}
daggr_mbuf->bss_index = pmbuf->bss_index;
daggr_mbuf->buf_type = pmbuf->buf_type;
daggr_mbuf->data_len = pkt_len;
daggr_mbuf->in_ts_sec = pmbuf->in_ts_sec;
daggr_mbuf->in_ts_usec = pmbuf->in_ts_usec;
daggr_mbuf->pparent = pmbuf;
daggr_mbuf->priority = pmbuf->priority;
memcpy(pmadapter, daggr_mbuf->pbuf + daggr_mbuf->data_offset,
data, pkt_len);
#ifdef UAP_SUPPORT
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
ret = wlan_uap_recv_packet(priv, daggr_mbuf);
} else {
#endif /* UAP_SUPPORT */
/** send EAPOL from AMSDU pkt to firmware */
if (priv->sec_info.ewpa_enabled &&
(!memcmp
(pmadapter,
daggr_mbuf->pbuf + daggr_mbuf->data_offset +
MLAN_ETHER_PKT_TYPE_OFFSET, eapol_type,
sizeof(eapol_type)))) {
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_802_11_EAPOL_PKT,
0, 0, MNULL, daggr_mbuf);
if (ret == MLAN_STATUS_SUCCESS)
wlan_recv_event(priv,
MLAN_EVENT_ID_DRV_DEFER_HANDLING,
MNULL);
wlan_free_mlan_buffer(pmadapter, daggr_mbuf);
data += pkt_len + pad;
continue;
}
/**process tdls packet*/
if (!memcmp
(pmadapter,
daggr_mbuf->pbuf + daggr_mbuf->data_offset +
MLAN_ETHER_PKT_TYPE_OFFSET, tdls_action_type,
sizeof(tdls_action_type))) {
PRINTM(MEVENT,
"Recevie AMSDU TDLS action frame\n");
wlan_process_tdls_action_frame(priv,
daggr_mbuf->
pbuf +
daggr_mbuf->
data_offset,
daggr_mbuf->
data_len);
}
ret = pmadapter->callbacks.moal_recv_packet(pmadapter->
pmoal_handle,
daggr_mbuf);
#ifdef UAP_SUPPORT
}
#endif /* UAP_SUPPORT */
switch (ret) {
case MLAN_STATUS_PENDING:
break;
case MLAN_STATUS_FAILURE:
PRINTM(MERROR, "Deaggr, send to moal failed\n");
daggr_mbuf->status_code = MLAN_ERROR_PKT_INVALID;
case MLAN_STATUS_SUCCESS:
wlan_recv_packet_complete(pmadapter, daggr_mbuf, ret);
break;
default:
break;
}
data += pkt_len + pad;
}
done:
priv->msdu_in_rx_amsdu_cnt += pmbuf->use_count;
priv->amsdu_rx_cnt++;
/** we should free the aggr buffer after deaggr */
wlan_free_mlan_buffer(pmadapter, pmbuf);
LEAVE();
return ret;
}
/**
* @brief Aggregate multiple packets into one single AMSDU packet
*
* @param priv A pointer to mlan_private structure
* @param pra_list Pointer to the RA List table containing the pointers
* to packets.
* @param headroom Any interface specific headroom that may be need. TxPD
* will be formed leaving this headroom.
* @param ptrindex Pointer index
*
* @return Final packet size or MLAN_STATUS_FAILURE
*/
int
wlan_11n_aggregate_pkt(mlan_private *priv, raListTbl *pra_list,
int headroom, int ptrindex)
{
int pkt_size = 0;
pmlan_adapter pmadapter = priv->adapter;
mlan_buffer *pmbuf_aggr, *pmbuf_src;
t_u8 *data;
int pad = 0;
mlan_status ret = MLAN_STATUS_SUCCESS;
#ifdef DEBUG_LEVEL1
t_u32 sec = 0, usec = 0;
#endif
mlan_tx_param tx_param;
#ifdef STA_SUPPORT
TxPD *ptx_pd = MNULL;
#endif
t_u32 max_amsdu_size = MIN(pra_list->max_amsdu, pmadapter->tx_buf_size);
ENTER();
PRINTM(MDAT_D, "Handling Aggr packet\n");
pmbuf_src =
(pmlan_buffer)util_peek_list(pmadapter->pmoal_handle,
&pra_list->buf_head, MNULL, MNULL);
if (pmbuf_src) {
pmbuf_aggr = wlan_alloc_mlan_buffer(pmadapter,
pmadapter->tx_buf_size, 0,
MOAL_MALLOC_BUFFER);
if (!pmbuf_aggr) {
PRINTM(MERROR, "Error allocating mlan_buffer\n");
pmadapter->callbacks.moal_spin_unlock(pmadapter->
pmoal_handle,
priv->wmm.
ra_list_spinlock);
LEAVE();
return MLAN_STATUS_FAILURE;
}
data = pmbuf_aggr->pbuf + headroom;
pmbuf_aggr->bss_index = pmbuf_src->bss_index;
pmbuf_aggr->buf_type = pmbuf_src->buf_type;
pmbuf_aggr->priority = pmbuf_src->priority;
pmbuf_aggr->pbuf = data;
pmbuf_aggr->data_offset = 0;
pmbuf_aggr->in_ts_sec = pmbuf_src->in_ts_sec;
pmbuf_aggr->in_ts_usec = pmbuf_src->in_ts_usec;
if (pmbuf_src->flags & MLAN_BUF_FLAG_TDLS)
pmbuf_aggr->flags |= MLAN_BUF_FLAG_TDLS;
if (pmbuf_src->flags & MLAN_BUF_FLAG_TCP_ACK)
pmbuf_aggr->flags |= MLAN_BUF_FLAG_TCP_ACK;
/* Form AMSDU */
wlan_11n_form_amsdu_txpd(priv, pmbuf_aggr);
pkt_size = sizeof(TxPD);
#ifdef STA_SUPPORT
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA)
ptx_pd = (TxPD *)pmbuf_aggr->pbuf;
#endif
priv->msdu_in_tx_amsdu_cnt++;
} else {
pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
priv->wmm.
ra_list_spinlock);
goto exit;
}
while (pmbuf_src && ((pkt_size + (pmbuf_src->data_len + LLC_SNAP_LEN)
+ headroom) <= max_amsdu_size)) {
pmbuf_src = (pmlan_buffer)
util_dequeue_list(pmadapter->pmoal_handle,
&pra_list->buf_head, MNULL, MNULL);
pra_list->total_pkts--;
/* decrement for every PDU taken from the list */
priv->wmm.pkts_queued[ptrindex]--;
util_scalar_decrement(pmadapter->pmoal_handle,
&priv->wmm.tx_pkts_queued, MNULL, MNULL);
pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
priv->wmm.
ra_list_spinlock);
pkt_size += wlan_11n_form_amsdu_pkt(pmadapter,
(data + pkt_size),
pmbuf_src->pbuf +
pmbuf_src->data_offset,
pmbuf_src->data_len, &pad);
DBG_HEXDUMP(MDAT_D, "pmbuf_src", pmbuf_src,
sizeof(mlan_buffer));
wlan_write_data_complete(pmadapter, pmbuf_src,
MLAN_STATUS_SUCCESS);
pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
priv->wmm.ra_list_spinlock);
if (!wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
pmadapter->callbacks.moal_spin_unlock(pmadapter->
pmoal_handle,
priv->wmm.
ra_list_spinlock);
LEAVE();
return MLAN_STATUS_FAILURE;
}
pmbuf_src =
(pmlan_buffer)util_peek_list(pmadapter->pmoal_handle,
&pra_list->buf_head, MNULL,
MNULL);
priv->msdu_in_tx_amsdu_cnt++;
}
pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
priv->wmm.ra_list_spinlock);
/* Last AMSDU packet does not need padding */
pkt_size -= pad;
pmbuf_aggr->data_len = pkt_size;
wlan_11n_update_pktlen_amsdu_txpd(priv, pmbuf_aggr);
pmbuf_aggr->data_len += headroom;
pmbuf_aggr->pbuf = data - headroom;
tx_param.next_pkt_len = ((pmbuf_src) ?
pmbuf_src->data_len + sizeof(TxPD) : 0);
ret = wlan_sdio_host_to_card(pmadapter, MLAN_TYPE_DATA,
pmbuf_aggr, &tx_param);
switch (ret) {
case MLAN_STATUS_RESOURCE:
pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
priv->wmm.ra_list_spinlock);
if (!wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
pmadapter->callbacks.moal_spin_unlock(pmadapter->
pmoal_handle,
priv->wmm.
ra_list_spinlock);
pmbuf_aggr->status_code = MLAN_ERROR_PKT_INVALID;
wlan_write_data_complete(pmadapter, pmbuf_aggr,
MLAN_STATUS_FAILURE);
LEAVE();
return MLAN_STATUS_FAILURE;
}
#ifdef STA_SUPPORT
/* reset tx_lock_flag */
if ((GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
pmadapter->pps_uapsd_mode &&
(pmadapter->tx_lock_flag == MTRUE)) {
pmadapter->tx_lock_flag = MFALSE;
ptx_pd->flags = 0;
}
#endif
util_enqueue_list_head(pmadapter->pmoal_handle,
&pra_list->buf_head,
(pmlan_linked_list)pmbuf_aggr, MNULL,
MNULL);
pra_list->total_pkts++;
/* add back only one: aggregated packet is requeued as one */
priv->wmm.pkts_queued[ptrindex]++;
util_scalar_increment(pmadapter->pmoal_handle,
&priv->wmm.tx_pkts_queued, MNULL, MNULL);
pmbuf_aggr->flags |= MLAN_BUF_FLAG_REQUEUED_PKT;
pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
priv->wmm.
ra_list_spinlock);
PRINTM(MINFO, "MLAN_STATUS_RESOURCE is returned\n");
pmbuf_aggr->status_code = MLAN_ERROR_PKT_INVALID;
break;
case MLAN_STATUS_FAILURE:
pmadapter->data_sent = MFALSE;
PRINTM(MERROR, "Error: host_to_card failed: 0x%X\n", ret);
pmbuf_aggr->status_code = MLAN_ERROR_DATA_TX_FAIL;
pmadapter->dbg.num_tx_host_to_card_failure++;
wlan_write_data_complete(pmadapter, pmbuf_aggr, ret);
goto exit;
case MLAN_STATUS_PENDING:
break;
case MLAN_STATUS_SUCCESS:
wlan_write_data_complete(pmadapter, pmbuf_aggr, ret);
break;
default:
break;
}
if (ret != MLAN_STATUS_RESOURCE) {
pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
priv->wmm.ra_list_spinlock);
if (wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
priv->wmm.packets_out[ptrindex]++;
priv->wmm.tid_tbl_ptr[ptrindex].ra_list_curr = pra_list;
}
pmadapter->bssprio_tbl[priv->bss_priority].bssprio_cur =
pmadapter->bssprio_tbl[priv->bss_priority].bssprio_cur->
pnext;
pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
priv->wmm.
ra_list_spinlock);
}
PRINTM_GET_SYS_TIME(MDATA, &sec, &usec);
PRINTM_NETINTF(MDATA, priv);
PRINTM(MDATA, "%lu.%06lu : Data => FW\n", sec, usec);
priv->amsdu_tx_cnt++;
exit:
LEAVE();
return pkt_size + headroom;
}

View File

@@ -0,0 +1,37 @@
/** @file mlan_11n_aggr.h
*
* @brief This file contains related macros, enum, and struct
* of 11n aggregation functionalities
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/********************************************************
Change log:
11/10/2008: initial version
********************************************************/
#ifndef _MLAN_11N_AGGR_H_
#define _MLAN_11N_AGGR_H_
/** Aggregate 11N packets */
mlan_status wlan_11n_deaggregate_pkt(pmlan_private priv, pmlan_buffer pmbuf);
/** Deaggregate 11N packets */
int wlan_11n_aggregate_pkt(mlan_private *priv, raListTbl *ptr,
int headroom, int ptrindex);
#endif /* !_MLAN_11N_AGGR_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
/** @file mlan_11n_rxreorder.h
*
* @brief This file contains related macros, enum, and struct
* of 11n RxReordering functionalities
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/********************************************************
Change log:
11/10/2008: initial version
********************************************************/
#ifndef _MLAN_11N_RXREORDER_H_
#define _MLAN_11N_RXREORDER_H_
/** Max value a TID can take = 2^12 = 4096 */
#define MAX_TID_VALUE (2 << 11)
/** 2^11 = 2048 */
#define TWOPOW11 (2 << 10)
/** Tid Mask used for extracting TID from BlockAckParamSet */
#define BLOCKACKPARAM_TID_MASK 0x3C
/** Tid position in BlockAckParamSet */
#define BLOCKACKPARAM_TID_POS 2
/** WinSize Mask used for extracting WinSize from BlockAckParamSet */
#define BLOCKACKPARAM_WINSIZE_MASK 0xffc0
/** WinSize Mask used for extracting WinSize from BlockAckParamSet */
#define BLOCKACKPARAM_AMSDU_SUPP_MASK 0x1
/** WinSize position in BlockAckParamSet */
#define BLOCKACKPARAM_WINSIZE_POS 6
/** Position of TID in DelBA Param set */
#define DELBA_TID_POS 12
/** Position of INITIATOR in DelBA Param set */
#define DELBA_INITIATOR_POS 11
/** Reason code: Requested from peer STA as it does not want to
* use the mechanism */
#define REASON_CODE_STA_DONT_WANT 37
/** Reason code: Requested from peer STA due to timeout*/
#define REASON_CODE_STA_TIMEOUT 39
/** Type: send delba command */
#define TYPE_DELBA_SENT 1
/** Type: recieve delba command */
#define TYPE_DELBA_RECEIVE 2
/** Set Initiator Bit */
#define DELBA_INITIATOR(paramset) (paramset = (paramset | (1 << 11)))
/** Reset Initiator Bit for recipient */
#define DELBA_RECIPIENT(paramset) (paramset = (paramset & ~(1 << 11)))
/** Immediate block ack */
#define IMMEDIATE_BLOCK_ACK 0x2
/** The request has been declined */
#define ADDBA_RSP_STATUS_DECLINED 37
/** ADDBA response status : Reject */
#define ADDBA_RSP_STATUS_REJECT 1
/** ADDBA response status : Accept */
#define ADDBA_RSP_STATUS_ACCEPT 0
/** DEFAULT SEQ NUM */
#define DEFAULT_SEQ_NUM 0xffff
/** Indicate packet has been dropped in FW */
#define RX_PKT_DROPPED_IN_FW 0xffffffff
mlan_status mlan_11n_rxreorder_pkt(void *priv, t_u16 seqNum, t_u16 tid,
t_u8 *ta, t_u8 pkttype, void *payload);
void mlan_11n_delete_bastream_tbl(mlan_private *priv, int tid,
t_u8 *PeerMACAddr, t_u8 type, int initiator,
t_u16 reason_code);
void wlan_11n_ba_stream_timeout(mlan_private *priv,
HostCmd_DS_11N_BATIMEOUT *event);
mlan_status wlan_ret_11n_addba_resp(mlan_private *priv,
HostCmd_DS_COMMAND *resp);
mlan_status wlan_cmd_11n_delba(mlan_private *priv, HostCmd_DS_COMMAND *cmd,
void *pdata_buf);
mlan_status wlan_cmd_11n_addba_rspgen(mlan_private *priv,
HostCmd_DS_COMMAND *cmd, void *pdata_buf);
mlan_status wlan_cmd_11n_addba_req(mlan_private *priv, HostCmd_DS_COMMAND *cmd,
void *pdata_buf);
void wlan_11n_cleanup_reorder_tbl(mlan_private *priv);
RxReorderTbl *wlan_11n_get_rxreorder_tbl(mlan_private *priv, int tid, t_u8 *ta);
void wlan_11n_rxba_sync_event(mlan_private *priv, t_u8 *event_buf, t_u16 len);
void wlan_update_rxreorder_tbl(pmlan_adapter pmadapter, t_u8 flag);
void wlan_flush_rxreorder_tbl(pmlan_adapter pmadapter);
void wlan_coex_ampdu_rxwinsize(pmlan_adapter pmadapter);
/** clean up reorder_tbl */
void wlan_cleanup_reorder_tbl(mlan_private *priv, t_u8 *ta);
#endif /* _MLAN_11N_RXREORDER_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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,90 @@
/** @file mlan_init.h
*
* @brief This file defines the FW initialization data
* structures.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
10/13/2008: initial version
******************************************************/
#ifndef _MLAN_INIT_H_
#define _MLAN_INIT_H_
/** Tx buffer size for firmware download*/
#define FW_DNLD_TX_BUF_SIZE 620
/** Rx buffer size for firmware download*/
#define FW_DNLD_RX_BUF_SIZE 2048
/** Max firmware retry */
#define MAX_FW_RETRY 3
/** Firmware has last block */
#define FW_HAS_LAST_BLOCK 0x00000004
/** CMD id for CMD7 */
#define FW_CMD_7 0x00000007
/** Firmware data transmit size */
#define FW_DATA_XMIT_SIZE (sizeof(FWHeader) + DataLength + sizeof(t_u32))
/** FWHeader */
typedef MLAN_PACK_START struct _FWHeader {
/** FW download command */
t_u32 dnld_cmd;
/** FW base address */
t_u32 base_addr;
/** FW data length */
t_u32 data_length;
/** FW CRC */
t_u32 crc;
} MLAN_PACK_END FWHeader;
/** FWData */
typedef MLAN_PACK_START struct _FWData {
/** FW data header */
FWHeader fw_header;
/** FW data sequence number */
t_u32 seq_num;
/** FW data buffer */
t_u8 data[1];
} MLAN_PACK_END FWData;
/** FWSyncHeader */
typedef MLAN_PACK_START struct _FWSyncHeader {
/** FW sync header command */
t_u32 cmd;
/** FW sync header sequence number */
t_u32 seq_num;
} MLAN_PACK_END FWSyncHeader;
#ifdef BIG_ENDIAN_SUPPORT
/** Convert sequence number and command fields
* of fwheader to correct endian format
*/
#define endian_convert_syncfwheader(x) { \
(x)->cmd = wlan_le32_to_cpu((x)->cmd); \
(x)->seq_num = wlan_le32_to_cpu((x)->seq_num); \
}
#else
/** Convert sequence number and command fields
* of fwheader to correct endian format
*/
#define endian_convert_syncfwheader(x)
#endif /* BIG_ENDIAN_SUPPORT */
#endif /* _MLAN_INIT_H_ */

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,40 @@
/** @file mlan_join.h
*
* @brief This file defines the interface for the WLAN infrastructure
* and adhoc join routines.
*
* Driver interface functions and type declarations for the join module
* implemented in mlan_join.c. Process all start/join requests for
* both adhoc and infrastructure networks
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
10/13/2008: initial version
******************************************************/
#ifndef _MLAN_JOIN_H_
#define _MLAN_JOIN_H_
/** Size of buffer allocated to store the association response from firmware */
#define MRVDRV_ASSOC_RSP_BUF_SIZE 500
/** Size of buffer allocated to store IEs passed to firmware in the assoc req */
#define MRVDRV_GENIE_BUF_SIZE 256
#endif /* _MLAN_JOIN_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,463 @@
/**
* @file mlan_meas.c
*
* @brief Implementation of measurement interface code with the app/firmware
*
* Driver implementation for sending and retrieving measurement requests
* and responses.
*
* Current use is limited to 802.11h.
*
* Requires use of the following preprocessor define:
* - ENABLE_MEAS
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/*************************************************************
Change Log:
03/24/2009: initial version
************************************************************/
#include "mlan.h"
#include "mlan_join.h"
#include "mlan_util.h"
#include "mlan_fw.h"
#include "mlan_main.h"
#include "mlan_ioctl.h"
#include "mlan_meas.h"
/** Default measurement duration when not provided by the application */
#define WLAN_MEAS_DEFAULT_MEAS_DURATION 1000U /* TUs */
#ifdef DEBUG_LEVEL2
/** String descriptions of the different measurement enums. Debug display */
static const char *meas_type_str[WLAN_MEAS_NUM_TYPES] = {
"basic",
};
/********************************************************
Local Functions
********************************************************/
/**
* @brief Retrieve the measurement string representation of a meas_type enum
* Used for debug display only
*
* @param meas_type Measurement type enumeration input for string lookup
*
* @return Constant string representing measurement type
*/
static const char *
wlan_meas_get_meas_type_str(MeasType_t meas_type)
{
if (meas_type <= WLAN_MEAS_11H_MAX_TYPE)
return meas_type_str[meas_type];
return "Invld";
}
#endif
/**
* @brief Debug print display of the input measurement request
*
* @param pmeas_req Pointer to the measurement request to display
*
* @return N/A
*/
static
void
wlan_meas_dump_meas_req(const HostCmd_DS_MEASUREMENT_REQUEST *pmeas_req)
{
ENTER();
PRINTM(MINFO, "Meas: Req: ------------------------------\n");
PRINTM(MINFO, "Meas: Req: mac_addr: " MACSTR "\n",
MAC2STR(pmeas_req->mac_addr));
PRINTM(MINFO, "Meas: Req: dlgTkn: %d\n", pmeas_req->dialog_token);
PRINTM(MINFO, "Meas: Req: mode: dm[%c] rpt[%c] req[%c]\n",
pmeas_req->req_mode.duration_mandatory ? 'X' : ' ',
pmeas_req->req_mode.report ? 'X' : ' ',
pmeas_req->req_mode.request ? 'X' : ' ');
PRINTM(MINFO, "Meas: Req: : en[%c] par[%c]\n",
pmeas_req->req_mode.enable ? 'X' : ' ',
pmeas_req->req_mode.parallel ? 'X' : ' ');
#ifdef DEBUG_LEVEL2
PRINTM(MINFO, "Meas: Req: measTyp: %s\n",
wlan_meas_get_meas_type_str(pmeas_req->meas_type));
#endif
switch (pmeas_req->meas_type) {
case WLAN_MEAS_BASIC:
/* Lazy cheat, fields of bas, cca, rpi union match on the request */
PRINTM(MINFO, "Meas: Req: chan: %u\n",
pmeas_req->req.basic.channel);
PRINTM(MINFO, "Meas: Req: strt: %llu\n",
wlan_le64_to_cpu(pmeas_req->req.basic.start_time));
PRINTM(MINFO, "Meas: Req: dur: %u\n",
wlan_le16_to_cpu(pmeas_req->req.basic.duration));
break;
default:
PRINTM(MINFO, "Meas: Req: <unhandled>\n");
break;
}
PRINTM(MINFO, "Meas: Req: ------------------------------\n");
LEAVE();
}
/**
* @brief Debug print display of the input measurement report
*
* @param pmeas_rpt Pointer to measurement report to display
*
* @return N/A
*/
static
void
wlan_meas_dump_meas_rpt(const HostCmd_DS_MEASUREMENT_REPORT *pmeas_rpt)
{
MeasType_t type;
ENTER();
PRINTM(MINFO, "Meas: Rpt: ------------------------------\n");
PRINTM(MINFO, "Meas: Rpt: mac_addr: " MACSTR "\n",
MAC2STR(pmeas_rpt->mac_addr));
PRINTM(MINFO, "Meas: Rpt: dlgTkn: %d\n", pmeas_rpt->dialog_token);
PRINTM(MINFO, "Meas: Rpt: rptMode: (%x): Rfs[%c] ICp[%c] Lt[%c]\n",
*(t_u8 *)&pmeas_rpt->rpt_mode,
pmeas_rpt->rpt_mode.refused ? 'X' : ' ',
pmeas_rpt->rpt_mode.incapable ? 'X' : ' ',
pmeas_rpt->rpt_mode.late ? 'X' : ' ');
#ifdef DEBUG_LEVEL2
PRINTM(MINFO, "Meas: Rpt: measTyp: %s\n",
wlan_meas_get_meas_type_str(pmeas_rpt->meas_type));
#endif
type = wlan_le32_to_cpu(pmeas_rpt->meas_type);
switch (type) {
case WLAN_MEAS_BASIC:
PRINTM(MINFO, "Meas: Rpt: chan: %u\n",
pmeas_rpt->rpt.basic.channel);
PRINTM(MINFO, "Meas: Rpt: strt: %llu\n",
wlan_le64_to_cpu(pmeas_rpt->rpt.basic.start_time));
PRINTM(MINFO, "Meas: Rpt: dur: %u\n",
wlan_le16_to_cpu(pmeas_rpt->rpt.basic.duration));
PRINTM(MINFO, "Meas: Rpt: bas: (%x): unmsd[%c], radar[%c]\n",
*(t_u8 *)&(pmeas_rpt->rpt.basic.map),
pmeas_rpt->rpt.basic.map.unmeasured ? 'X' : ' ',
pmeas_rpt->rpt.basic.map.radar ? 'X' : ' ');
PRINTM(MINFO, "Meas: Rpt: bas: unidSig[%c] ofdm[%c] bss[%c]\n",
pmeas_rpt->rpt.basic.map.unidentified_sig ? 'X' : ' ',
pmeas_rpt->rpt.basic.map.ofdm_preamble ? 'X' : ' ',
pmeas_rpt->rpt.basic.map.bss ? 'X' : ' ');
break;
default:
PRINTM(MINFO, "Meas: Rpt: <unhandled>\n");
break;
}
PRINTM(MINFO, "Meas: Rpt: ------------------------------\n");
LEAVE();
}
/**
* @brief Retrieve a measurement report from the firmware
*
* Callback from command processing when a measurement report is received
* from the firmware. Perform the following when a report is received:
*
* -# Debug displays the report if compiled with the appropriate flags
* -# If we are pending on a specific measurement report token, and it
* matches the received report's token, store the report and wake up
* any pending threads
*
* @param pmpriv Private driver information structure
* @param resp HostCmd_DS_COMMAND struct returned from the firmware command
* passing a HostCmd_DS_MEASUREMENT_REPORT structure.
*
* @return MLAN_STATUS_SUCCESS
*/
static int
wlan_meas_cmdresp_get_report(mlan_private *pmpriv,
const HostCmd_DS_COMMAND *resp)
{
mlan_adapter *pmadapter = pmpriv->adapter;
const HostCmd_DS_MEASUREMENT_REPORT *pmeas_rpt = &resp->params.meas_rpt;
ENTER();
PRINTM(MINFO, "Meas: Rpt: %#x-%u, Seq=%u, Ret=%u\n",
resp->command, resp->size, resp->seq_num, resp->result);
/* Debug displays the measurement report */
wlan_meas_dump_meas_rpt(pmeas_rpt);
/*
* Check if we are pending on a measurement report and it matches
* the dialog token of the received report:
*/
if (pmadapter->state_meas.meas_rpt_pend_on
&& pmadapter->state_meas.meas_rpt_pend_on ==
pmeas_rpt->dialog_token) {
PRINTM(MINFO, "Meas: Rpt: RCV'd Pend on meas #%d\n",
pmadapter->state_meas.meas_rpt_pend_on);
/* Clear the pending report indicator */
pmadapter->state_meas.meas_rpt_pend_on = 0;
/* Copy the received report into the measurement state for retrieval */
memcpy(pmadapter, &pmadapter->state_meas.meas_rpt_returned,
pmeas_rpt,
sizeof(pmadapter->state_meas.meas_rpt_returned));
/*
* Wake up any threads pending on the wait queue
*/
wlan_recv_event(pmpriv, MLAN_EVENT_ID_DRV_MEAS_REPORT, MNULL);
}
LEAVE();
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Prepare CMD_MEASURMENT_REPORT firmware command
*
* @param pmpriv Private driver information structure
* @param pcmd_ptr Output parameter: Pointer to the command being prepared
* for the firmware
* @param pinfo_buf HostCmd_DS_MEASUREMENT_REQUEST passed as void data block
*
* @return MLAN_STATUS_SUCCESS
*/
static int
wlan_meas_cmd_request(mlan_private *pmpriv,
HostCmd_DS_COMMAND *pcmd_ptr, const void *pinfo_buf)
{
const HostCmd_DS_MEASUREMENT_REQUEST *pmeas_req =
(HostCmd_DS_MEASUREMENT_REQUEST *)pinfo_buf;
ENTER();
pcmd_ptr->command = HostCmd_CMD_MEASUREMENT_REQUEST;
pcmd_ptr->size = sizeof(HostCmd_DS_MEASUREMENT_REQUEST) + S_DS_GEN;
memcpy(pmpriv->adapter, &pcmd_ptr->params.meas_req, pmeas_req,
sizeof(pcmd_ptr->params.meas_req));
PRINTM(MINFO, "Meas: Req: %#x-%u, Seq=%u, Ret=%u\n",
pcmd_ptr->command, pcmd_ptr->size, pcmd_ptr->seq_num,
pcmd_ptr->result);
wlan_meas_dump_meas_req(pmeas_req);
LEAVE();
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Retrieve a measurement report from the firmware
*
* The firmware will send a EVENT_MEAS_REPORT_RDY event when it
* completes or receives a measurement report. The event response
* handler will then start a HostCmd_CMD_MEASUREMENT_REPORT firmware command
* which gets completed for transmission to the firmware in this routine.
*
* @param pmpriv Private driver information structure
* @param pcmd_ptr Output parameter: Pointer to the command being prepared
* for the firmware
*
* @return MLAN_STATUS_SUCCESS
*/
static int
wlan_meas_cmd_get_report(mlan_private *pmpriv, HostCmd_DS_COMMAND *pcmd_ptr)
{
ENTER();
pcmd_ptr->command = HostCmd_CMD_MEASUREMENT_REPORT;
pcmd_ptr->size = sizeof(HostCmd_DS_MEASUREMENT_REPORT) + S_DS_GEN;
memset(pmpriv->adapter, &pcmd_ptr->params.meas_rpt, 0x00,
sizeof(pcmd_ptr->params.meas_rpt));
/*
* Set the meas_rpt.mac_addr to our mac address to get a meas report,
* setting the mac to another STA address instructs the firmware
* to transmit this measurement report frame instead
*/
memcpy(pmpriv->adapter, pcmd_ptr->params.meas_rpt.mac_addr,
pmpriv->curr_addr, sizeof(pcmd_ptr->params.meas_rpt.mac_addr));
LEAVE();
return MLAN_STATUS_SUCCESS;
}
/********************************************************
Global functions
********************************************************/
/**
* @brief Send the input measurement request to the firmware.
*
* If the dialog token in the measurement request is set to 0, the function
* will use an local static auto-incremented token in the measurement
* request. This ensures the dialog token is always set.
*
* If wait_for_resp_timeout is set, the function will block its return on
* a timeout or returned measurement report that matches the requests
* dialog token.
*
* @param pmpriv Private driver information structure
* @param pmeas_req Pointer to the measurement request to send
* @param wait_for_resp_timeout Timeout value of the measurement request
* in ms.
* @param pioctl_req Pointer to IOCTL request buffer
* @param pmeas_rpt Output parameter: Pointer for the resulting
* measurement report
*
* @return
* - 0 for success
* - -ETIMEDOUT if the measurement report does not return before
* the timeout expires
* - Error return from wlan_prepare_cmd routine otherwise
*/
int
wlan_meas_util_send_req(mlan_private *pmpriv,
HostCmd_DS_MEASUREMENT_REQUEST *pmeas_req,
t_u32 wait_for_resp_timeout, pmlan_ioctl_req pioctl_req,
HostCmd_DS_MEASUREMENT_REPORT *pmeas_rpt)
{
static t_u8 auto_dialog_tok;
wlan_meas_state_t *pmeas_state = &pmpriv->adapter->state_meas;
int ret;
ENTER();
/* If dialogTok was set to 0 or not provided, autoset */
pmeas_req->dialog_token = (pmeas_req->dialog_token ?
pmeas_req->dialog_token : ++auto_dialog_tok);
/* Check for rollover of the dialog token. Avoid using 0 as a token */
pmeas_req->dialog_token = (pmeas_req->dialog_token ?
pmeas_req->dialog_token : 1);
/*
* If the request is to pend waiting for the result, set the dialog token
* of this measurement request in the state structure. The measurement
* report handling routines can then check the incoming measurement
* reports for a match with this dialog token.
*/
if (wait_for_resp_timeout) {
pmeas_state->meas_rpt_pend_on = pmeas_req->dialog_token;
PRINTM(MINFO, "Meas: Req: START Pend on meas #%d\n",
pmeas_req->dialog_token);
}
/* Send the measurement request to the firmware */
ret = wlan_prepare_cmd(pmpriv, HostCmd_CMD_MEASUREMENT_REQUEST,
HostCmd_ACT_GEN_SET,
0, (t_void *)pioctl_req, (void *)pmeas_req);
LEAVE();
return ret;
}
/**
* @brief Prepare the HostCmd_DS_Command structure for a measurement command.
*
* Use the Command field to determine if the command being set up is for
* 11h and call one of the local command handlers accordingly for:
*
* - HostCmd_CMD_MEASUREMENT_REQUEST
* - HostCmd_CMD_MEASUREMENT_REPORT
*
* @param pmpriv Private driver information structure
* @param pcmd_ptr Output parameter: Pointer to the command being prepared
* for the firmware
* @param pinfo_buf Void buffer passthrough with data necessary for a
* specific command type
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*
*/
int
wlan_meas_cmd_process(mlan_private *pmpriv,
HostCmd_DS_COMMAND *pcmd_ptr, const void *pinfo_buf)
{
int ret = MLAN_STATUS_SUCCESS;
ENTER();
switch (pcmd_ptr->command) {
case HostCmd_CMD_MEASUREMENT_REQUEST:
ret = wlan_meas_cmd_request(pmpriv, pcmd_ptr, pinfo_buf);
break;
case HostCmd_CMD_MEASUREMENT_REPORT:
ret = wlan_meas_cmd_get_report(pmpriv, pcmd_ptr);
break;
default:
ret = MLAN_STATUS_FAILURE;
}
pcmd_ptr->command = wlan_cpu_to_le16(pcmd_ptr->command);
pcmd_ptr->size = wlan_cpu_to_le16(pcmd_ptr->size);
LEAVE();
return ret;
}
/**
* @brief Handle the command response from the firmware for a measurement
* command
*
* Use the Command field to determine if the command response being
* is for meas. Call the local command response handler accordingly for:
*
* - HostCmd_CMD_802_MEASUREMENT_REQUEST
* - HostCmd_CMD_802_MEASUREMENT_REPORT
*
* @param pmpriv Private driver information structure
* @param resp HostCmd_DS_COMMAND struct returned from the firmware command
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
int
wlan_meas_cmdresp_process(mlan_private *pmpriv, const HostCmd_DS_COMMAND *resp)
{
int ret = MLAN_STATUS_SUCCESS;
ENTER();
switch (resp->command) {
case HostCmd_CMD_MEASUREMENT_REQUEST:
PRINTM(MINFO, "Meas: Req Resp: Sz=%u, Seq=%u, Ret=%u\n",
resp->size, resp->seq_num, resp->result);
break;
case HostCmd_CMD_MEASUREMENT_REPORT:
ret = wlan_meas_cmdresp_get_report(pmpriv, resp);
break;
default:
ret = MLAN_STATUS_FAILURE;
}
LEAVE();
return ret;
}

View File

@@ -0,0 +1,55 @@
/**
* @file mlan_meas.h
*
* @brief Interface for the measurement module implemented in mlan_meas.c
*
* Driver interface functions and type declarations for the measurement module
* implemented in mlan_meas.c
*
* @sa mlan_meas.c
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/*************************************************************
Change Log:
03/25/2009: initial version
************************************************************/
#ifndef _MLAN_MEAS_H_
#define _MLAN_MEAS_H_
#include "mlan_fw.h"
/* Send a given measurement request to the firmware, report back the result */
extern int
wlan_meas_util_send_req(mlan_private *pmpriv,
HostCmd_DS_MEASUREMENT_REQUEST *pmeas_req,
t_u32 wait_for_resp_timeout, pmlan_ioctl_req pioctl_req,
HostCmd_DS_MEASUREMENT_REPORT *pmeas_rpt);
/* Setup a measurement command before it is sent to the firmware */
extern int wlan_meas_cmd_process(mlan_private *pmpriv,
HostCmd_DS_COMMAND *pcmd_ptr,
const t_void *pinfo_buf);
/* Handle a given measurement command response from the firmware */
extern int wlan_meas_cmdresp_process(mlan_private *pmpriv,
const HostCmd_DS_COMMAND *resp);
#endif /* _MLAN_MEAS_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
/** @file mlan_module.c
*
* @brief This file declares the exported symbols from MLAN.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
/******************************************************
Change log:
12/08/2008: initial version
******************************************************/
#ifdef LINUX
#include <linux/module.h>
#include "mlan_decl.h"
#include "mlan_ioctl.h"
EXPORT_SYMBOL(mlan_register);
EXPORT_SYMBOL(mlan_unregister);
EXPORT_SYMBOL(mlan_init_fw);
EXPORT_SYMBOL(mlan_set_init_param);
EXPORT_SYMBOL(mlan_dnld_fw);
EXPORT_SYMBOL(mlan_shutdown_fw);
EXPORT_SYMBOL(mlan_send_packet);
EXPORT_SYMBOL(mlan_ioctl);
EXPORT_SYMBOL(mlan_main_process);
EXPORT_SYMBOL(mlan_rx_process);
EXPORT_SYMBOL(mlan_select_wmm_queue);
EXPORT_SYMBOL(mlan_interrupt);
#if defined(SYSKT)
EXPORT_SYMBOL(mlan_hs_callback);
#endif /* SYSKT_MULTI || SYSKT */
EXPORT_SYMBOL(mlan_pm_wakeup_card);
EXPORT_SYMBOL(mlan_is_main_process_running);
MODULE_DESCRIPTION("M-WLAN MLAN Driver");
MODULE_AUTHOR("Marvell International Ltd.");
MODULE_VERSION(MLAN_RELEASE_VERSION);
MODULE_LICENSE("GPL");
#endif /* LINUX */

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,436 @@
/** @file mlan_sdio.h
*
* @brief This file contains definitions for SDIO interface.
* driver.
*
* Copyright (C) 2008-2017, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/****************************************************
Change log:
****************************************************/
#ifndef _MLAN_SDIO_H
#define _MLAN_SDIO_H
/** Block mode */
#ifndef BLOCK_MODE
#define BLOCK_MODE 1
#endif
/** Fixed address mode */
#ifndef FIXED_ADDRESS
#define FIXED_ADDRESS 0
#endif
/* Host Control Registers */
/** Host Control Registers : Host to Card Event */
#define HOST_TO_CARD_EVENT_REG 0x00
/** Host Control Registers : Host terminates Command 53 */
#define HOST_TERM_CMD53 (0x1U << 2)
/** Host Control Registers : Host without Command 53 finish host */
#define HOST_WO_CMD53_FINISH_HOST (0x1U << 2)
/** Host Control Registers : Host power up */
#define HOST_POWER_UP (0x1U << 1)
/** Host Control Registers : Host power down */
#define HOST_POWER_DOWN (0x1U << 0)
/** Host Control Registers : Host interrupt RSR */
#define HOST_INT_RSR_REG 0x04
/** Host Control Registers : Upload host interrupt RSR */
#define UP_LD_HOST_INT_RSR (0x1U)
#define HOST_INT_RSR_MASK 0xFF
/** Host Control Registers : Host interrupt mask */
#define HOST_INT_MASK_REG 0x08
/** Host Control Registers : Upload host interrupt mask */
#define UP_LD_HOST_INT_MASK (0x1U)
/** Host Control Registers : Download host interrupt mask */
#define DN_LD_HOST_INT_MASK (0x2U)
/** Host Control Registers : Cmd port upload interrupt mask */
#define CMD_PORT_UPLD_INT_MASK (0x1U << 6)
/** Host Control Registers : Cmd port download interrupt mask */
#define CMD_PORT_DNLD_INT_MASK (0x1U << 7)
/** Enable Host interrupt mask */
#define HIM_ENABLE (UP_LD_HOST_INT_MASK | \
DN_LD_HOST_INT_MASK | \
CMD_PORT_UPLD_INT_MASK | \
CMD_PORT_DNLD_INT_MASK)
/** Disable Host interrupt mask */
#define HIM_DISABLE 0xff
/** Host Control Registers : Host interrupt status */
#define HOST_INT_STATUS_REG 0x0C
/** Host Control Registers : Upload command port host interrupt status */
#define UP_LD_CMD_PORT_HOST_INT_STATUS (0x40U)
/** Host Control Registers : Download command port host interrupt status */
#define DN_LD_CMD_PORT_HOST_INT_STATUS (0x80U)
/** Host Control Registers : Upload host interrupt status */
#define UP_LD_HOST_INT_STATUS (0x1U)
/** Host Control Registers : Download host interrupt status */
#define DN_LD_HOST_INT_STATUS (0x2U)
/** Port for registers */
#define REG_PORT 0
/** Port for memory */
#define MEM_PORT 0x10000
/** LSB of read bitmap */
#define RD_BITMAP_L 0x10
/** MSB of read bitmap */
#define RD_BITMAP_U 0x11
/** LSB of read bitmap second word */
#define RD_BITMAP_1L 0x12
/** MSB of read bitmap second word */
#define RD_BITMAP_1U 0x13
/** LSB of write bitmap */
#define WR_BITMAP_L 0x14
/** MSB of write bitmap */
#define WR_BITMAP_U 0x15
/** LSB of write bitmap second word */
#define WR_BITMAP_1L 0x16
/** MSB of write bitmap second word */
#define WR_BITMAP_1U 0x17
/** LSB of read length for port 0 */
#define RD_LEN_P0_L 0x18
/** MSB of read length for port 0 */
#define RD_LEN_P0_U 0x19
/* Card Control Registers : Command port read length 0 */
#define CMD_RD_LEN_0 0xC0
/* Card Control Registers : Command port read length 1 */
#define CMD_RD_LEN_1 0xC1
/* Card Control Registers : Command port read length 2 (reserved) */
#define CMD_RD_LEN_2 0xC2
/* Card Control Registers : Command port read length 3 */
#define CMD_RD_LEN_3 0xC3
/* Card Control Registers : Command port configuration 0 */
#define CMD_CONFIG_0 0xC4
#define CMD_PORT_RD_LEN_EN (0x1U << 2)
/* Card Control Registers : Command port configuration 1 */
#define CMD_CONFIG_1 0xC5
/* Card Control Registers : cmd port auto enable */
#define CMD_PORT_AUTO_EN (0x1U << 0)
/* Card Control Registers : Command port configuration 2 (reserved) */
#define CMD_CONFIG_2 0xC6
/* Card Control Registers : Command port configuration 3 (reserved) */
#define CMD_CONFIG_3 0xC7
/* Command port */
#define CMD_PORT_SLCT 0x8000
/** Data port mask */
#define DATA_PORT_MASK 0xffffffff
/** Misc. Config Register : Auto Re-enable interrupts */
#define AUTO_RE_ENABLE_INT MBIT(4)
/** Host Control Registers : Host transfer status */
#define HOST_RESTART_REG 0x58
/** Host Control Registers : Download CRC error */
#define DN_LD_CRC_ERR (0x1U << 2)
/** Host Control Registers : Upload restart */
#define UP_LD_RESTART (0x1U << 1)
/** Host Control Registers : Download restart */
#define DN_LD_RESTART (0x1U << 0)
/* Card Control Registers */
/** Card Control Registers : Card to host event */
#define CARD_TO_HOST_EVENT_REG 0x5C
/** Card Control Registers : Command port upload ready */
#define UP_LD_CP_RDY (0x1U << 6)
/** Card Control Registers : Command port download ready */
#define DN_LD_CP_RDY (0x1U << 7)
/** Card Control Registers : Card I/O ready */
#define CARD_IO_READY (0x1U << 3)
/** Card Control Registers : CIS card ready */
#define CIS_CARD_RDY (0x1U << 2)
/** Card Control Registers : Upload card ready */
#define UP_LD_CARD_RDY (0x1U << 1)
/** Card Control Registers : Download card ready */
#define DN_LD_CARD_RDY (0x1U << 0)
/** Card Control Registers : Host interrupt mask register */
#define HOST_INTERRUPT_MASK_REG 0x60
/** Card Control Registers : Host power interrupt mask */
#define HOST_POWER_INT_MASK (0x1U << 3)
/** Card Control Registers : Abort card interrupt mask */
#define ABORT_CARD_INT_MASK (0x1U << 2)
/** Card Control Registers : Upload card interrupt mask */
#define UP_LD_CARD_INT_MASK (0x1U << 1)
/** Card Control Registers : Download card interrupt mask */
#define DN_LD_CARD_INT_MASK (0x1U << 0)
/** Card Control Registers : Card interrupt status register */
#define CARD_INTERRUPT_STATUS_REG 0x64
/** Card Control Registers : Power up interrupt */
#define POWER_UP_INT (0x1U << 4)
/** Card Control Registers : Power down interrupt */
#define POWER_DOWN_INT (0x1U << 3)
/** Card Control Registers : Card interrupt RSR register */
#define CARD_INTERRUPT_RSR_REG 0x68
/** Card Control Registers : Power up RSR */
#define POWER_UP_RSR (0x1U << 4)
/** Card Control Registers : Power down RSR */
#define POWER_DOWN_RSR (0x1U << 3)
/** Card Control Registers : SQ Read base address 0 register */
#define READ_BASE_0_REG 0xf8
/** Card Control Registers : SQ Read base address 1 register */
#define READ_BASE_1_REG 0xf9
/** Enable GPIO-1 as a duplicated signal of interrupt as appear of SDIO_DAT1*/
#define ENABLE_GPIO_1_INT_MODE 0x88
/** Scratch reg 3 2 : Configure GPIO-1 INT*/
#define SCRATCH_REG_32 0xEE
/** Card Control Registers : Card revision register */
#define CARD_REVISION_REG 0xC8
/** Firmware status 0 register (SCRATCH0_0) */
#define CARD_FW_STATUS0_REG 0xe8
/** Firmware status 1 register (SCRATCH0_1) */
#define CARD_FW_STATUS1_REG 0xe9
/** Rx length register (SCRATCH0_2) */
#define CARD_RX_LEN_REG 0xea
/** Rx unit register (SCRATCH0_3) */
#define CARD_RX_UNIT_REG 0xeb
/** Card Control Registers : Card OCR 0 register */
#define CARD_OCR_0_REG 0xD4
/** Card Control Registers : Card OCR 1 register */
#define CARD_OCR_1_REG 0xD5
/** Card Control Registers : Card OCR 3 register */
#define CARD_OCR_3_REG 0xD6
/** Card Control Registers : Card config register */
#define CARD_CONFIG_REG 0xD7
/** Card Control Registers : Miscellaneous Configuration Register */
#define CARD_MISC_CFG_REG 0xD8
/** Card Control Registers : sdio new mode register 1 */
#define CARD_CONFIG_2_1_REG 0xD9
/** Card Control Registers : cmd53 new mode */
#define CMD53_NEW_MODE (0x1U << 0)
/** Card Control Registers : cmd53 tx len format 1 (0x10) */
#define CMD53_TX_LEN_FORMAT_1 (0x1U << 4)
/** Card Control Registers : cmd53 tx len format 2 (0x20)*/
#define CMD53_TX_LEN_FORMAT_2 (0x1U << 5)
/** Card Control Registers : cmd53 rx len format 1 (0x40) */
#define CMD53_RX_LEN_FORMAT_1 (0x1U << 6)
/** Card Control Registers : cmd53 rx len format 2 (0x80)*/
#define CMD53_RX_LEN_FORMAT_2 (0x1U << 7)
/** Card Control Registers : sdio new mode register 2 */
#define CARD_CONFIG_2_2_REG 0xDA
/** Card Control Registers : test data out (0x01) */
#define TEST_DATA_OUT_1 (0x1U << 0)
/** Card Control Registers : test data out (0x02) */
#define TEST_DATA_OUT_2 (0x1U << 1)
/** Card Control Registers : test data out (0x04) */
#define TEST_DATA_OUT_3 (0x1U << 2)
/** Card Control Registers : test data out (0x08) */
#define TEST_DATA_OUT_4 (0x1U << 3)
/** Card Control Registers : test cmd out (0x10) */
#define TEST_CMD_OUT (0x1U << 4)
/** Card Control Registers : sdio new mode register 3 */
#define CARD_CONFIG_2_3_REG 0xDB
/** Card Control Registers : test data enable (0x01) */
#define TEST_DATA_EN_1 (0x1U << 0)
/** Card Control Registers : test data enable (0x02) */
#define TEST_DATA_EN_2 (0x1U << 1)
/** Card Control Registers : test data enable (0x04) */
#define TEST_DATA_EN_3 (0x1U << 2)
/** Card Control Registers : test data enable (0x08) */
#define TEST_DATA_EN_4 (0x1U << 3)
/** Card Control Registers : test cmd enable (0x10) */
#define TEST_CMD_EN (0x1U << 4)
/** Card Control Registers : test mode (0x20) */
#define TEST_MODE (0x1U << 5)
/** Card Control Registers : Debug 0 register */
#define DEBUG_0_REG 0xDC
/** Card Control Registers : SD test BUS 0 */
#define SD_TESTBUS0 (0x1U)
/** Card Control Registers : Debug 1 register */
#define DEBUG_1_REG 0xDD
/** Card Control Registers : SD test BUS 1 */
#define SD_TESTBUS1 (0x1U)
/** Card Control Registers : Debug 2 register */
#define DEBUG_2_REG 0xDE
/** Card Control Registers : SD test BUS 2 */
#define SD_TESTBUS2 (0x1U)
/** Card Control Registers : Debug 3 register */
#define DEBUG_3_REG 0xDF
/** Card Control Registers : SD test BUS 3 */
#define SD_TESTBUS3 (0x1U)
/** Host Control Registers : I/O port 0 */
#define IO_PORT_0_REG 0xE4
/** Host Control Registers : I/O port 1 */
#define IO_PORT_1_REG 0xE5
/** Host Control Registers : I/O port 2 */
#define IO_PORT_2_REG 0xE6
#define FW_RESET_REG 0x0EE
#define FW_RESET_VAL 0x99
/** Event header Len*/
#define MLAN_EVENT_HEADER_LEN 8
/** SDIO byte mode size */
#define MAX_BYTE_MODE_SIZE 512
#if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
/** The base address for packet with multiple ports aggregation */
#define SDIO_MPA_ADDR_BASE 0x1000
#endif
#ifdef SDIO_MULTI_PORT_TX_AGGR
/** SDIO Tx aggregation in progress ? */
#define MP_TX_AGGR_IN_PROGRESS(a) (a->mpa_tx.pkt_cnt > 0)
/** SDIO Tx aggregation buffer room for next packet ? */
#define MP_TX_AGGR_BUF_HAS_ROOM(a, mbuf, len) \
(((a->mpa_tx.buf_len) + len) <= (a->mpa_tx.buf_size))
/** Copy current packet (SDIO Tx aggregation buffer) to SDIO buffer */
#define MP_TX_AGGR_BUF_PUT(a, mbuf, port) do { \
pmadapter->callbacks.moal_memmove(a->pmoal_handle, \
&a->mpa_tx.buf[a->mpa_tx.buf_len], \
mbuf->pbuf+mbuf->data_offset, mbuf->data_len);\
a->mpa_tx.buf_len += mbuf->data_len; \
a->mpa_tx.mp_wr_info[a->mpa_tx.pkt_cnt] = \
*(t_u16 *)(mbuf->pbuf+mbuf->data_offset); \
if (!a->mpa_tx.pkt_cnt) { \
a->mpa_tx.start_port = port; \
} \
a->mpa_tx.ports |= (1 << port); \
a->mpa_tx.pkt_cnt++; \
} while (0)
#define MP_TX_AGGR_BUF_PUT_SG(a, mbuf, port) do { \
a->mpa_tx.buf_len += mbuf->data_len; \
a->mpa_tx.mp_wr_info[a->mpa_tx.pkt_cnt] = \
*(t_u16 *)(mbuf->pbuf+mbuf->data_offset); \
a->mpa_tx.mbuf_arr[a->mpa_tx.pkt_cnt] = mbuf; \
if (!a->mpa_tx.pkt_cnt) { \
a->mpa_tx.start_port = port; \
} \
a->mpa_tx.ports |= (1 << port); \
a->mpa_tx.pkt_cnt++; \
} while (0)
/** SDIO Tx aggregation limit ? */
#define MP_TX_AGGR_PKT_LIMIT_REACHED(a) ((a->mpa_tx.pkt_cnt) \
== (a->mpa_tx.pkt_aggr_limit))
/** SDIO Tx aggregation port limit ? */
#define MP_TX_AGGR_PORT_LIMIT_REACHED(a) (MFALSE)
/** Reset SDIO Tx aggregation buffer parameters */
#define MP_TX_AGGR_BUF_RESET(a) do { \
memset(a, a->mpa_tx.mp_wr_info, 0, sizeof(a->mpa_tx.mp_wr_info)); \
a->mpa_tx.pkt_cnt = 0; \
a->mpa_tx.buf_len = 0; \
a->mpa_tx.ports = 0; \
a->mpa_tx.start_port = 0; \
} while (0)
#endif /* SDIO_MULTI_PORT_TX_AGGR */
#ifdef SDIO_MULTI_PORT_RX_AGGR
/** SDIO Rx aggregation limit ? */
#define MP_RX_AGGR_PKT_LIMIT_REACHED(a) (a->mpa_rx.pkt_cnt \
== a->mpa_rx.pkt_aggr_limit)
/** SDIO Rx aggregation port limit ? */
/** this is for test only, because port 0 is reserved for control port */
/* #define MP_RX_AGGR_PORT_LIMIT_REACHED(a) (a->curr_rd_port == 1) */
/* receive packets aggregated up to a half of mp_end_port */
/* note: hw rx wraps round only after port (MAX_PORT-1) */
#define MP_RX_AGGR_PORT_LIMIT_REACHED(a) \
(((a->curr_rd_port < a->mpa_rx.start_port) && \
(((MAX_PORT - a->mpa_rx.start_port) + a->curr_rd_port) \
>= (a->mp_end_port >> 1))) || \
((a->curr_rd_port - a->mpa_rx.start_port) >= \
(a->mp_end_port >> 1)))
/** SDIO Rx aggregation in progress ? */
#define MP_RX_AGGR_IN_PROGRESS(a) (a->mpa_rx.pkt_cnt > 0)
/** SDIO Rx aggregation buffer room for next packet ? */
#define MP_RX_AGGR_BUF_HAS_ROOM(a, rx_len) \
((a->mpa_rx.buf_len + rx_len) <= a->mpa_rx.buf_size)
/** Prepare to copy current packet from card to SDIO Rx aggregation buffer */
#define MP_RX_AGGR_SETUP(a, mbuf, port, rx_len) do { \
a->mpa_rx.buf_len += rx_len; \
if (!a->mpa_rx.pkt_cnt) { \
a->mpa_rx.start_port = port; \
} \
a->mpa_rx.ports |= (1 << port); \
a->mpa_rx.mbuf_arr[a->mpa_rx.pkt_cnt] = mbuf; \
a->mpa_rx.len_arr[a->mpa_rx.pkt_cnt] = rx_len; \
a->mpa_rx.pkt_cnt++; \
} while (0)
/** Reset SDIO Rx aggregation buffer parameters */
#define MP_RX_AGGR_BUF_RESET(a) do { \
a->mpa_rx.pkt_cnt = 0; \
a->mpa_rx.buf_len = 0; \
a->mpa_rx.ports = 0; \
a->mpa_rx.start_port = 0; \
} while (0)
#endif /* SDIO_MULTI_PORT_RX_AGGR */
/** Enable host interrupt */
mlan_status wlan_enable_host_int(pmlan_adapter pmadapter);
/** Probe and initialization function */
mlan_status wlan_sdio_probe(pmlan_adapter pmadapter);
/** multi interface download check */
mlan_status wlan_check_winner_status(mlan_adapter *pmadapter, t_u32 *val);
#ifdef SDIO_MULTI_PORT_TX_AGGR
mlan_status wlan_send_mp_aggr_buf(mlan_adapter *pmadapter);
#endif
#if defined(SDIO_MULTI_PORT_RX_AGGR)
mlan_status wlan_re_alloc_sdio_rx_mpa_buffer(IN mlan_adapter *pmadapter);
#endif
void wlan_decode_spa_buffer(mlan_adapter *pmadapter, t_u8 *buf, t_u32 len);
t_void wlan_sdio_deaggr_rx_pkt(IN pmlan_adapter pmadapter, mlan_buffer *pmbuf);
/** Firmware status check */
mlan_status wlan_check_fw_status(mlan_adapter *pmadapter, t_u32 pollnum);
/** Read interrupt status */
mlan_status wlan_interrupt(pmlan_adapter pmadapter);
/** Process Interrupt Status */
mlan_status wlan_process_int_status(mlan_adapter *pmadapter);
/** Transfer data to card */
mlan_status wlan_sdio_host_to_card(mlan_adapter *pmadapter, t_u8 type,
mlan_buffer *mbuf, mlan_tx_param *tx_param);
mlan_status wlan_set_sdio_gpio_int(IN pmlan_private priv);
mlan_status wlan_cmd_sdio_gpio_int(pmlan_private pmpriv,
IN HostCmd_DS_COMMAND *cmd,
IN t_u16 cmd_action, IN t_void *pdata_buf);
mlan_status wlan_reset_fw(pmlan_adapter pmadapter);
#endif /* _MLAN_SDIO_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More