]> Git Repo - linux.git/blob - drivers/staging/vt6656/mac.c
selinux: Remove security_ops extern
[linux.git] / drivers / staging / vt6656 / mac.c
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
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.
9  *
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.
14  *
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.
18  *
19  *
20  * File: mac.c
21  *
22  * Purpose:  MAC routines
23  *
24  * Author: Tevin Chen
25  *
26  * Date: May 21, 1996
27  *
28  * Functions:
29  *
30  * Revision History:
31  */
32
33 #include "tmacro.h"
34 #include "tether.h"
35 #include "desc.h"
36 #include "mac.h"
37 #include "80211hdr.h"
38 #include "usbpipe.h"
39
40 /*
41  * Description:
42  *      Write MAC Multicast Address Mask
43  *
44  * Parameters:
45  *  In:
46  *      mc_filter (mac filter)
47  *  Out:
48  *      none
49  *
50  * Return Value: none
51  *
52  */
53 void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter)
54 {
55         __le64 le_mc = cpu_to_le64(mc_filter);
56
57         vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0,
58                 MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc);
59 }
60
61 /*
62  * Description:
63  *      Shut Down MAC
64  *
65  * Parameters:
66  *  In:
67  *  Out:
68  *      none
69  *
70  *
71  */
72 void MACbShutdown(struct vnt_private *priv)
73 {
74         vnt_control_out(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL);
75 }
76
77 void MACvSetBBType(struct vnt_private *priv, u8 type)
78 {
79         u8 data[2];
80
81         data[0] = type;
82         data[1] = EnCFG_BBType_MASK;
83
84         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0,
85                 MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
86 }
87
88 /*
89  * Description:
90  *      Disable the Key Entry by MISCFIFO
91  *
92  * Parameters:
93  *  In:
94  *      dwIoBase        - Base Address for MAC
95  *
96  *  Out:
97  *      none
98  *
99  * Return Value: none
100  *
101  */
102 void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx)
103 {
104         vnt_control_out(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0,
105                 sizeof(entry_idx), &entry_idx);
106 }
107
108 /*
109  * Description:
110  *      Set the Key by MISCFIFO
111  *
112  * Parameters:
113  *  In:
114  *      dwIoBase        - Base Address for MAC
115  *
116  *  Out:
117  *      none
118  *
119  * Return Value: none
120  *
121  */
122 void MACvSetKeyEntry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
123         u32 key_idx, u8 *addr, u8 *key)
124 {
125         struct vnt_mac_set_key set_key;
126         u16 offset;
127
128         if (priv->byLocalID <= MAC_REVISION_A1)
129                 if (priv->vnt_mgmt.byCSSPK == KEY_CTL_CCMP)
130                         return;
131
132         offset = MISCFIFO_KEYETRY0;
133         offset += (entry_idx * MISCFIFO_KEYENTRYSIZE);
134
135         set_key.u.write.key_ctl = cpu_to_le16(key_ctl);
136         memcpy(set_key.u.write.addr, addr, ETH_ALEN);
137
138         /* swap over swap[0] and swap[1] to get correct write order */
139         swap(set_key.u.swap[0], set_key.u.swap[1]);
140
141         memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP);
142
143         dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n",
144                                 offset, key_ctl, (u8 *)&set_key);
145
146         vnt_control_out(priv, MESSAGE_TYPE_SETKEY, offset,
147                 (u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key);
148 }
149
150 void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits)
151 {
152         u8 data[2];
153
154         data[0] = 0;
155         data[1] = bits;
156
157         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
158                 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
159 }
160
161 void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits)
162 {
163         u8 data[2];
164
165         data[0] = bits;
166         data[1] = bits;
167
168         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
169                 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
170 }
171
172 void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word)
173 {
174         u8 data[2];
175
176         data[0] = (u8)(word & 0xff);
177         data[1] = (u8)(word >> 8);
178
179         vnt_control_out(priv, MESSAGE_TYPE_WRITE,
180                 reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
181 }
182
183 void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr)
184 {
185         vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0,
186                 MESSAGE_REQUEST_MACREG, ETH_ALEN, addr);
187 }
188
189 void MACvEnableProtectMD(struct vnt_private *priv)
190 {
191         u8 data[2];
192
193         data[0] = EnCFG_ProtectMd;
194         data[1] = EnCFG_ProtectMd;
195
196         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
197                 MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
198 }
199
200 void MACvDisableProtectMD(struct vnt_private *priv)
201 {
202         u8 data[2];
203
204         data[0] = 0;
205         data[1] = EnCFG_ProtectMd;
206
207         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
208                 MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
209 }
210
211 void MACvEnableBarkerPreambleMd(struct vnt_private *priv)
212 {
213         u8 data[2];
214
215         data[0] = EnCFG_BarkerPream;
216         data[1] = EnCFG_BarkerPream;
217
218         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
219                 MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
220 }
221
222 void MACvDisableBarkerPreambleMd(struct vnt_private *priv)
223 {
224         u8 data[2];
225
226         data[0] = 0;
227         data[1] = EnCFG_BarkerPream;
228
229         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
230                 MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
231 }
232
233 void MACvWriteBeaconInterval(struct vnt_private *priv, u16 interval)
234 {
235         u8 data[2];
236
237         data[0] = (u8)(interval & 0xff);
238         data[1] = (u8)(interval >> 8);
239
240         vnt_control_out(priv, MESSAGE_TYPE_WRITE,
241                 MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
242 }
243
244 void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led)
245 {
246         u8 data[2];
247
248         data[0] = led;
249         data[1] = state;
250
251         vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY,
252                         MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
253
254         return;
255 }
This page took 0.047731 seconds and 4 git commands to generate.