2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* File: mac.c
|
|
|
|
*
|
|
|
|
* Purpose: MAC routines
|
|
|
|
*
|
|
|
|
* Author: Tevin Chen
|
|
|
|
*
|
|
|
|
* Date: May 21, 1996
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tmacro.h"
|
|
|
|
#include "tether.h"
|
|
|
|
#include "desc.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "80211hdr.h"
|
|
|
|
#include "control.h"
|
2009-08-12 21:54:08 +00:00
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
//static int msglevel =MSG_LEVEL_DEBUG;
|
|
|
|
static int msglevel =MSG_LEVEL_INFO;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Write MAC Multicast Address Mask
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-02-12 19:18:26 +00:00
|
|
|
* mc_filter (mac filter)
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-23 17:00:00 +00:00
|
|
|
void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-02-12 19:18:26 +00:00
|
|
|
__le64 le_mc = cpu_to_le64(mc_filter);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:00 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0,
|
2014-02-12 19:18:26 +00:00
|
|
|
MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Shut Down MAC
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2014-05-23 17:00:01 +00:00
|
|
|
void MACbShutdown(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:01 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:02 +00:00
|
|
|
void MACvSetBBType(struct vnt_private *priv, u8 type)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:02 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:02 +00:00
|
|
|
data[0] = type;
|
|
|
|
data[1] = EnCFG_BBType_MASK;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:02 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0,
|
|
|
|
MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Disable the Key Entry by MISCFIFO
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* dwIoBase - Base Address for MAC
|
|
|
|
*
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-23 17:00:04 +00:00
|
|
|
void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:04 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0,
|
|
|
|
sizeof(entry_idx), &entry_idx);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Set the Key by MISCFIFO
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* dwIoBase - Base Address for MAC
|
|
|
|
*
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2012-12-10 22:01:23 +00:00
|
|
|
void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx,
|
|
|
|
u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2012-12-10 22:01:23 +00:00
|
|
|
u8 *pbyKey;
|
|
|
|
u16 wOffset;
|
|
|
|
u32 dwData1, dwData2;
|
|
|
|
int ii;
|
|
|
|
u8 pbyData[24];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-17 23:19:37 +00:00
|
|
|
if (pDevice->byLocalID <= MAC_REVISION_A1)
|
|
|
|
if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP)
|
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
wOffset = MISCFIFO_KEYETRY0;
|
|
|
|
wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
|
|
|
|
|
|
|
|
dwData1 = 0;
|
|
|
|
dwData1 |= wKeyCtl;
|
|
|
|
dwData1 <<= 16;
|
|
|
|
dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
|
|
|
|
|
2012-11-11 15:45:52 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %X,"\
|
|
|
|
" KeyCtl:%X\n", wOffset, dwData1, wKeyCtl);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
dwData2 = 0;
|
|
|
|
dwData2 |= *(pbyAddr+3);
|
|
|
|
dwData2 <<= 8;
|
|
|
|
dwData2 |= *(pbyAddr+2);
|
|
|
|
dwData2 <<= 8;
|
|
|
|
dwData2 |= *(pbyAddr+1);
|
|
|
|
dwData2 <<= 8;
|
|
|
|
dwData2 |= *(pbyAddr+0);
|
|
|
|
|
2012-11-11 15:45:52 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n",
|
|
|
|
wOffset, dwData2);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-26 01:32:51 +00:00
|
|
|
pbyKey = (u8 *)pdwKey;
|
|
|
|
|
|
|
|
pbyData[0] = (u8)dwData1;
|
|
|
|
pbyData[1] = (u8)(dwData1>>8);
|
|
|
|
pbyData[2] = (u8)(dwData1>>16);
|
|
|
|
pbyData[3] = (u8)(dwData1>>24);
|
|
|
|
pbyData[4] = (u8)dwData2;
|
|
|
|
pbyData[5] = (u8)(dwData2>>8);
|
|
|
|
pbyData[6] = (u8)(dwData2>>16);
|
|
|
|
pbyData[7] = (u8)(dwData2>>24);
|
2010-05-20 02:50:00 +00:00
|
|
|
for (ii = 8; ii < 24; ii++)
|
|
|
|
pbyData[ii] = *pbyKey++;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
CONTROLnsRequestOut(pDevice,
|
|
|
|
MESSAGE_TYPE_SETKEY,
|
|
|
|
wOffset,
|
2013-02-26 01:32:52 +00:00
|
|
|
(u16)uKeyIdx,
|
2013-06-17 21:19:54 +00:00
|
|
|
ARRAY_SIZE(pbyData),
|
2009-06-13 11:38:31 +00:00
|
|
|
pbyData
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:05 +00:00
|
|
|
void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:05 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:05 +00:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = bits;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:05 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:06 +00:00
|
|
|
void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:06 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:06 +00:00
|
|
|
data[0] = bits;
|
|
|
|
data[1] = bits;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:06 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:07 +00:00
|
|
|
void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:07 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:07 +00:00
|
|
|
data[0] = (u8)(word & 0xff);
|
|
|
|
data[1] = (u8)(word >> 8);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:07 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE,
|
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:09 +00:00
|
|
|
void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:09 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0,
|
|
|
|
MESSAGE_REQUEST_MACREG, ETH_ALEN, addr);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:10 +00:00
|
|
|
void MACvEnableProtectMD(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:10 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:10 +00:00
|
|
|
data[0] = EnCFG_ProtectMd;
|
|
|
|
data[1] = EnCFG_ProtectMd;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:10 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:11 +00:00
|
|
|
void MACvDisableProtectMD(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:11 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:11 +00:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = EnCFG_ProtectMd;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:11 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:12 +00:00
|
|
|
void MACvEnableBarkerPreambleMd(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:12 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:12 +00:00
|
|
|
data[0] = EnCFG_BarkerPream;
|
|
|
|
data[1] = EnCFG_BarkerPream;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:12 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 17:00:13 +00:00
|
|
|
void MACvDisableBarkerPreambleMd(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:13 +00:00
|
|
|
u8 data[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:13 +00:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = EnCFG_BarkerPream;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:13 +00:00
|
|
|
CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK,
|
|
|
|
MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 22:01:23 +00:00
|
|
|
void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2012-12-10 22:01:23 +00:00
|
|
|
u8 pbyData[2];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-12-10 22:01:23 +00:00
|
|
|
pbyData[0] = (u8)(wInterval & 0xff);
|
|
|
|
pbyData[1] = (u8)(wInterval >> 8);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
CONTROLnsRequestOut(pDevice,
|
2010-09-16 18:00:19 +00:00
|
|
|
MESSAGE_TYPE_WRITE,
|
|
|
|
MAC_REG_BI,
|
|
|
|
MESSAGE_REQUEST_MACREG,
|
2013-06-17 21:19:54 +00:00
|
|
|
ARRAY_SIZE(pbyData),
|
2010-09-16 18:00:19 +00:00
|
|
|
pbyData
|
|
|
|
);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|