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.
18 * Purpose: MAC routines
29 #include <linux/etherdevice.h>
37 * Write MAC Multicast Address Mask
41 * mc_filter (mac filter)
48 void vnt_mac_set_filter(struct vnt_private
*priv
, u64 mc_filter
)
50 __le64 le_mc
= cpu_to_le64(mc_filter
);
52 vnt_control_out(priv
, MESSAGE_TYPE_WRITE
, MAC_REG_MAR0
,
53 MESSAGE_REQUEST_MACREG
, sizeof(le_mc
), (u8
*)&le_mc
);
67 void vnt_mac_shutdown(struct vnt_private
*priv
)
69 vnt_control_out(priv
, MESSAGE_TYPE_MACSHUTDOWN
, 0, 0, 0, NULL
);
72 void vnt_mac_set_bb_type(struct vnt_private
*priv
, u8 type
)
77 data
[1] = EnCFG_BBType_MASK
;
79 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_ENCFG0
,
80 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
85 * Disable the Key Entry by MISCFIFO
89 * dwIoBase - Base Address for MAC
97 void vnt_mac_disable_keyentry(struct vnt_private
*priv
, u8 entry_idx
)
99 vnt_control_out(priv
, MESSAGE_TYPE_CLRKEYENTRY
, 0, 0,
100 sizeof(entry_idx
), &entry_idx
);
105 * Set the Key by MISCFIFO
109 * dwIoBase - Base Address for MAC
117 void vnt_mac_set_keyentry(struct vnt_private
*priv
, u16 key_ctl
, u32 entry_idx
,
118 u32 key_idx
, u8
*addr
, u8
*key
)
120 struct vnt_mac_set_key set_key
;
123 offset
= MISCFIFO_KEYETRY0
;
124 offset
+= entry_idx
* MISCFIFO_KEYENTRYSIZE
;
126 set_key
.u
.write
.key_ctl
= cpu_to_le16(key_ctl
);
127 ether_addr_copy(set_key
.u
.write
.addr
, addr
);
129 /* swap over swap[0] and swap[1] to get correct write order */
130 swap(set_key
.u
.swap
[0], set_key
.u
.swap
[1]);
132 memcpy(set_key
.key
, key
, WLAN_KEY_LEN_CCMP
);
134 dev_dbg(&priv
->usb
->dev
, "offset %d key ctl %d set key %24ph\n",
135 offset
, key_ctl
, (u8
*)&set_key
);
137 vnt_control_out(priv
, MESSAGE_TYPE_SETKEY
, offset
,
138 (u16
)key_idx
, sizeof(struct vnt_mac_set_key
),
142 void vnt_mac_reg_bits_off(struct vnt_private
*priv
, u8 reg_ofs
, u8 bits
)
149 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
,
150 reg_ofs
, MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
),
154 void vnt_mac_reg_bits_on(struct vnt_private
*priv
, u8 reg_ofs
, u8 bits
)
161 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, reg_ofs
,
162 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
165 void vnt_mac_write_word(struct vnt_private
*priv
, u8 reg_ofs
, u16 word
)
169 data
[0] = (u8
)(word
& 0xff);
170 data
[1] = (u8
)(word
>> 8);
172 vnt_control_out(priv
, MESSAGE_TYPE_WRITE
, reg_ofs
,
173 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
176 void vnt_mac_set_bssid_addr(struct vnt_private
*priv
, u8
*addr
)
178 vnt_control_out(priv
, MESSAGE_TYPE_WRITE
, MAC_REG_BSSID0
,
179 MESSAGE_REQUEST_MACREG
, ETH_ALEN
, addr
);
182 void vnt_mac_enable_protect_mode(struct vnt_private
*priv
)
186 data
[0] = EnCFG_ProtectMd
;
187 data
[1] = EnCFG_ProtectMd
;
189 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_ENCFG0
,
190 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
193 void vnt_mac_disable_protect_mode(struct vnt_private
*priv
)
198 data
[1] = EnCFG_ProtectMd
;
200 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_ENCFG0
,
201 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
204 void vnt_mac_enable_barker_preamble_mode(struct vnt_private
*priv
)
208 data
[0] = EnCFG_BarkerPream
;
209 data
[1] = EnCFG_BarkerPream
;
211 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_ENCFG2
,
212 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
215 void vnt_mac_disable_barker_preamble_mode(struct vnt_private
*priv
)
220 data
[1] = EnCFG_BarkerPream
;
222 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_ENCFG2
,
223 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
226 void vnt_mac_set_beacon_interval(struct vnt_private
*priv
, u16 interval
)
230 data
[0] = (u8
)(interval
& 0xff);
231 data
[1] = (u8
)(interval
>> 8);
233 vnt_control_out(priv
, MESSAGE_TYPE_WRITE
, MAC_REG_BI
,
234 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);
237 void vnt_mac_set_led(struct vnt_private
*priv
, u8 state
, u8 led
)
244 vnt_control_out(priv
, MESSAGE_TYPE_WRITE_MASK
, MAC_REG_PAPEDELAY
,
245 MESSAGE_REQUEST_MACREG
, ARRAY_SIZE(data
), data
);