2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: MAC routines
33 #include <linux/etherdevice.h>
41 * Write MAC Multicast Address Mask
45 * mc_filter (mac filter)
52 void vnt_mac_set_filter(struct vnt_private *priv, u64 mc_filter)
54 __le64 le_mc = cpu_to_le64(mc_filter);
56 vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0,
57 MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc);
71 void vnt_mac_shutdown(struct vnt_private *priv)
73 vnt_control_out(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL);
76 void vnt_mac_set_bb_type(struct vnt_private *priv, u8 type)
81 data[1] = EnCFG_BBType_MASK;
83 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0,
84 MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
89 * Disable the Key Entry by MISCFIFO
93 * dwIoBase - Base Address for MAC
101 void vnt_mac_disable_keyentry(struct vnt_private *priv, u8 entry_idx)
103 vnt_control_out(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0,
104 sizeof(entry_idx), &entry_idx);
109 * Set the Key by MISCFIFO
113 * dwIoBase - Base Address for MAC
121 void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
122 u32 key_idx, u8 *addr, u8 *key)
124 struct vnt_mac_set_key set_key;
127 offset = MISCFIFO_KEYETRY0;
128 offset += (entry_idx * MISCFIFO_KEYENTRYSIZE);
130 set_key.u.write.key_ctl = cpu_to_le16(key_ctl);
131 ether_addr_copy(set_key.u.write.addr, addr);
133 /* swap over swap[0] and swap[1] to get correct write order */
134 swap(set_key.u.swap[0], set_key.u.swap[1]);
136 memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP);
138 dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n",
139 offset, key_ctl, (u8 *)&set_key);
141 vnt_control_out(priv, MESSAGE_TYPE_SETKEY, offset,
142 (u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key);
145 void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits)
152 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
153 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
156 void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits)
163 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
164 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
167 void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word)
171 data[0] = (u8)(word & 0xff);
172 data[1] = (u8)(word >> 8);
174 vnt_control_out(priv, MESSAGE_TYPE_WRITE,
175 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
178 void vnt_mac_set_bssid_addr(struct vnt_private *priv, u8 *addr)
180 vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0,
181 MESSAGE_REQUEST_MACREG, ETH_ALEN, addr);
184 void vnt_mac_enable_protect_mode(struct vnt_private *priv)
188 data[0] = EnCFG_ProtectMd;
189 data[1] = EnCFG_ProtectMd;
191 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
192 MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
195 void vnt_mac_disable_protect_mode(struct vnt_private *priv)
200 data[1] = EnCFG_ProtectMd;
202 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
203 MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
206 void vnt_mac_enable_barker_preamble_mode(struct vnt_private *priv)
210 data[0] = EnCFG_BarkerPream;
211 data[1] = EnCFG_BarkerPream;
213 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
214 MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
217 void vnt_mac_disable_barker_preamble_mode(struct vnt_private *priv)
222 data[1] = EnCFG_BarkerPream;
224 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
225 MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
228 void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval)
232 data[0] = (u8)(interval & 0xff);
233 data[1] = (u8)(interval >> 8);
235 vnt_control_out(priv, MESSAGE_TYPE_WRITE,
236 MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
239 void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led)
246 vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY,
247 MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);