2009-06-13 05:38:31 -06: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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* File: mac.c
|
|
|
|
*
|
|
|
|
* Purpose: MAC routines
|
|
|
|
*
|
|
|
|
* Author: Tevin Chen
|
|
|
|
*
|
|
|
|
* Date: May 21, 1996
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*/
|
|
|
|
|
2015-02-26 18:06:53 -07:00
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
#include "desc.h"
|
|
|
|
#include "mac.h"
|
2014-05-26 06:59:07 -06:00
|
|
|
#include "usbpipe.h"
|
2009-08-12 15:54:08 -06:00
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Write MAC Multicast Address Mask
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-02-12 12:18:26 -07:00
|
|
|
* mc_filter (mac filter)
|
2009-06-13 05:38:31 -06:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-31 04:50:36 -06:00
|
|
|
void vnt_mac_set_filter(struct vnt_private *priv, u64 mc_filter)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-02-12 12:18:26 -07:00
|
|
|
__le64 le_mc = cpu_to_le64(mc_filter);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0,
|
2014-02-12 12:18:26 -07:00
|
|
|
MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Shut Down MAC
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2014-05-31 04:50:37 -06:00
|
|
|
void vnt_mac_shutdown(struct vnt_private *priv)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:38 -06:00
|
|
|
void vnt_mac_set_bb_type(struct vnt_private *priv, u8 type)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:02 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:02 -06:00
|
|
|
data[0] = type;
|
|
|
|
data[1] = EnCFG_BBType_MASK;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0,
|
2014-05-23 11:00:02 -06:00
|
|
|
MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Disable the Key Entry by MISCFIFO
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* dwIoBase - Base Address for MAC
|
|
|
|
*
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-31 04:50:39 -06:00
|
|
|
void vnt_mac_disable_keyentry(struct vnt_private *priv, u8 entry_idx)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0,
|
2014-05-23 11:00:04 -06:00
|
|
|
sizeof(entry_idx), &entry_idx);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Set the Key by MISCFIFO
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* dwIoBase - Base Address for MAC
|
|
|
|
*
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-31 04:50:40 -06:00
|
|
|
void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
|
2014-05-26 06:58:59 -06:00
|
|
|
u32 key_idx, u8 *addr, u8 *key)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-25 14:36:29 -06:00
|
|
|
struct vnt_mac_set_key set_key;
|
2014-05-26 06:58:59 -06:00
|
|
|
u16 offset;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:58:59 -06:00
|
|
|
offset = MISCFIFO_KEYETRY0;
|
|
|
|
offset += (entry_idx * MISCFIFO_KEYENTRYSIZE);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:58:59 -06:00
|
|
|
set_key.u.write.key_ctl = cpu_to_le16(key_ctl);
|
2015-02-26 18:06:53 -07:00
|
|
|
ether_addr_copy(set_key.u.write.addr, addr);
|
2014-05-25 14:36:29 -06:00
|
|
|
|
|
|
|
/* swap over swap[0] and swap[1] to get correct write order */
|
|
|
|
swap(set_key.u.swap[0], set_key.u.swap[1]);
|
|
|
|
|
2014-05-26 06:58:58 -06:00
|
|
|
memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP);
|
2014-05-25 14:36:29 -06:00
|
|
|
|
2014-05-26 06:59:00 -06:00
|
|
|
dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n",
|
2014-05-26 06:58:59 -06:00
|
|
|
offset, key_ctl, (u8 *)&set_key);
|
2014-05-25 14:36:29 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_SETKEY, offset,
|
2014-05-26 06:58:59 -06:00
|
|
|
(u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:41 -06:00
|
|
|
void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:05 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:05 -06:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = bits;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:05 -06:00
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:42 -06:00
|
|
|
void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:06 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:06 -06:00
|
|
|
data[0] = bits;
|
|
|
|
data[1] = bits;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:06 -06:00
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:43 -06:00
|
|
|
void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:07 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:07 -06:00
|
|
|
data[0] = (u8)(word & 0xff);
|
|
|
|
data[1] = (u8)(word >> 8);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE,
|
2014-05-23 11:00:07 -06:00
|
|
|
reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:44 -06:00
|
|
|
void vnt_mac_set_bssid_addr(struct vnt_private *priv, u8 *addr)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0,
|
2014-05-23 11:00:09 -06:00
|
|
|
MESSAGE_REQUEST_MACREG, ETH_ALEN, addr);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:45 -06:00
|
|
|
void vnt_mac_enable_protect_mode(struct vnt_private *priv)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:10 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:10 -06:00
|
|
|
data[0] = EnCFG_ProtectMd;
|
|
|
|
data[1] = EnCFG_ProtectMd;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:10 -06:00
|
|
|
MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:46 -06:00
|
|
|
void vnt_mac_disable_protect_mode(struct vnt_private *priv)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:11 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:11 -06:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = EnCFG_ProtectMd;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:11 -06:00
|
|
|
MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:47 -06:00
|
|
|
void vnt_mac_enable_barker_preamble_mode(struct vnt_private *priv)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:12 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:12 -06:00
|
|
|
data[0] = EnCFG_BarkerPream;
|
|
|
|
data[1] = EnCFG_BarkerPream;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:12 -06:00
|
|
|
MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:48 -06:00
|
|
|
void vnt_mac_disable_barker_preamble_mode(struct vnt_private *priv)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:13 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:13 -06:00
|
|
|
data[0] = 0;
|
|
|
|
data[1] = EnCFG_BarkerPream;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
|
2014-05-23 11:00:13 -06:00
|
|
|
MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2014-05-31 04:50:49 -06:00
|
|
|
void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2014-05-23 11:00:14 -06:00
|
|
|
u8 data[2];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-23 11:00:14 -06:00
|
|
|
data[0] = (u8)(interval & 0xff);
|
|
|
|
data[1] = (u8)(interval >> 8);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2014-05-26 06:59:01 -06:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE,
|
2014-05-23 11:00:14 -06:00
|
|
|
MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2014-05-26 06:59:04 -06:00
|
|
|
|
|
|
|
void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led)
|
|
|
|
{
|
|
|
|
u8 data[2];
|
|
|
|
|
|
|
|
data[0] = led;
|
|
|
|
data[1] = state;
|
|
|
|
|
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY,
|
|
|
|
MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
|
|
|
|
}
|