blob: 57bf1d7ee80fc76591621f51ffd4fbdf56a656b7 [file] [log] [blame]
Arend van Spriel5b435de2011-10-05 13:19:03 +02001/*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
Joe Perches02f77192012-01-15 00:38:44 -080017#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
Arend van Spriel5b435de2011-10-05 13:19:03 +020019#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/kthread.h>
22#include <linux/slab.h>
23#include <linux/skbuff.h>
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/mmc/sdio_func.h>
27#include <linux/random.h>
28#include <linux/spinlock.h>
29#include <linux/ethtool.h>
30#include <linux/fcntl.h>
31#include <linux/fs.h>
32#include <linux/uaccess.h>
33#include <linux/hardirq.h>
34#include <linux/mutex.h>
35#include <linux/wait.h>
Stephen Rothwellb7a57e72011-10-12 21:35:07 +020036#include <linux/module.h>
Arend van Spriel5b435de2011-10-05 13:19:03 +020037#include <net/cfg80211.h>
38#include <net/rtnetlink.h>
39#include <defs.h>
40#include <brcmu_utils.h>
41#include <brcmu_wifi.h>
42
43#include "dhd.h"
44#include "dhd_bus.h"
45#include "dhd_proto.h"
46#include "dhd_dbg.h"
47#include "wl_cfg80211.h"
Arend van Spriel5b435de2011-10-05 13:19:03 +020048
49MODULE_AUTHOR("Broadcom Corporation");
50MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver.");
51MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards");
52MODULE_LICENSE("Dual BSD/GPL");
53
54
55/* Interface control information */
56struct brcmf_if {
Franky Lind08b6a32011-12-16 18:36:51 -080057 struct brcmf_pub *drvr; /* back pointer to brcmf_pub */
Arend van Spriel5b435de2011-10-05 13:19:03 +020058 /* OS/stack specifics */
59 struct net_device *ndev;
60 struct net_device_stats stats;
61 int idx; /* iface idx in dongle */
Arend van Spriel5b435de2011-10-05 13:19:03 +020062 u8 mac_addr[ETH_ALEN]; /* assigned MAC address */
63};
64
Arend van Spriel5b435de2011-10-05 13:19:03 +020065/* Error bits */
Franky Lin4f96bf12011-11-22 17:21:48 -080066int brcmf_msg_level = BRCMF_ERROR_VAL;
Arend van Spriel5b435de2011-10-05 13:19:03 +020067module_param(brcmf_msg_level, int, 0);
68
Franky Lind08b6a32011-12-16 18:36:51 -080069int brcmf_ifname2idx(struct brcmf_pub *drvr, char *name)
Arend van Spriel5b435de2011-10-05 13:19:03 +020070{
71 int i = BRCMF_MAX_IFS;
72 struct brcmf_if *ifp;
73
74 if (name == NULL || *name == '\0')
75 return 0;
76
77 while (--i > 0) {
Franky Lind08b6a32011-12-16 18:36:51 -080078 ifp = drvr->iflist[i];
Arend van Spriel5b435de2011-10-05 13:19:03 +020079 if (ifp && !strncmp(ifp->ndev->name, name, IFNAMSIZ))
80 break;
81 }
82
83 brcmf_dbg(TRACE, "return idx %d for \"%s\"\n", i, name);
84
85 return i; /* default - the primary interface */
86}
87
88char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx)
89{
Arend van Spriel5b435de2011-10-05 13:19:03 +020090 if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
91 brcmf_dbg(ERROR, "ifidx %d out of range\n", ifidx);
92 return "<if_bad>";
93 }
94
Franky Lind08b6a32011-12-16 18:36:51 -080095 if (drvr->iflist[ifidx] == NULL) {
Arend van Spriel5b435de2011-10-05 13:19:03 +020096 brcmf_dbg(ERROR, "null i/f %d\n", ifidx);
97 return "<if_null>";
98 }
99
Franky Lind08b6a32011-12-16 18:36:51 -0800100 if (drvr->iflist[ifidx]->ndev)
101 return drvr->iflist[ifidx]->ndev->name;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200102
103 return "<if_none>";
104}
105
106static void _brcmf_set_multicast_list(struct work_struct *work)
107{
108 struct net_device *ndev;
109 struct netdev_hw_addr *ha;
Arend van Sprielb5036242011-10-12 20:51:17 +0200110 u32 dcmd_value, cnt;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200111 __le32 cnt_le;
Arend van Sprielb5036242011-10-12 20:51:17 +0200112 __le32 dcmd_le_value;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200113
114 struct brcmf_dcmd dcmd;
115 char *buf, *bufp;
116 uint buflen;
117 int ret;
118
Franky Lind08b6a32011-12-16 18:36:51 -0800119 struct brcmf_pub *drvr = container_of(work, struct brcmf_pub,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200120 multicast_work);
121
Franky Lind08b6a32011-12-16 18:36:51 -0800122 ndev = drvr->iflist[0]->ndev;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200123 cnt = netdev_mc_count(ndev);
124
125 /* Determine initial value of allmulti flag */
Arend van Sprielb5036242011-10-12 20:51:17 +0200126 dcmd_value = (ndev->flags & IFF_ALLMULTI) ? true : false;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200127
128 /* Send down the multicast list first. */
129
130 buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN);
131 bufp = buf = kmalloc(buflen, GFP_ATOMIC);
132 if (!bufp)
133 return;
134
135 strcpy(bufp, "mcast_list");
136 bufp += strlen("mcast_list") + 1;
137
138 cnt_le = cpu_to_le32(cnt);
139 memcpy(bufp, &cnt_le, sizeof(cnt));
140 bufp += sizeof(cnt_le);
141
142 netdev_for_each_mc_addr(ha, ndev) {
143 if (!cnt)
144 break;
145 memcpy(bufp, ha->addr, ETH_ALEN);
146 bufp += ETH_ALEN;
147 cnt--;
148 }
149
150 memset(&dcmd, 0, sizeof(dcmd));
151 dcmd.cmd = BRCMF_C_SET_VAR;
152 dcmd.buf = buf;
153 dcmd.len = buflen;
154 dcmd.set = true;
155
Franky Lind08b6a32011-12-16 18:36:51 -0800156 ret = brcmf_proto_dcmd(drvr, 0, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200157 if (ret < 0) {
158 brcmf_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800159 brcmf_ifname(drvr, 0), cnt);
Arend van Sprielb5036242011-10-12 20:51:17 +0200160 dcmd_value = cnt ? true : dcmd_value;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200161 }
162
163 kfree(buf);
164
165 /* Now send the allmulti setting. This is based on the setting in the
166 * net_device flags, but might be modified above to be turned on if we
167 * were trying to set some addresses and dongle rejected it...
168 */
169
Arend van Sprielb5036242011-10-12 20:51:17 +0200170 buflen = sizeof("allmulti") + sizeof(dcmd_value);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200171 buf = kmalloc(buflen, GFP_ATOMIC);
172 if (!buf)
173 return;
174
Arend van Sprielb5036242011-10-12 20:51:17 +0200175 dcmd_le_value = cpu_to_le32(dcmd_value);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200176
Alwin Beukers53a22772011-10-12 20:51:30 +0200177 if (!brcmf_c_mkiovar
Arend van Sprielb5036242011-10-12 20:51:17 +0200178 ("allmulti", (void *)&dcmd_le_value,
179 sizeof(dcmd_le_value), buf, buflen)) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200180 brcmf_dbg(ERROR, "%s: mkiovar failed for allmulti, datalen %d buflen %u\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800181 brcmf_ifname(drvr, 0),
Arend van Sprielb5036242011-10-12 20:51:17 +0200182 (int)sizeof(dcmd_value), buflen);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200183 kfree(buf);
184 return;
185 }
186
187 memset(&dcmd, 0, sizeof(dcmd));
188 dcmd.cmd = BRCMF_C_SET_VAR;
189 dcmd.buf = buf;
190 dcmd.len = buflen;
191 dcmd.set = true;
192
Franky Lind08b6a32011-12-16 18:36:51 -0800193 ret = brcmf_proto_dcmd(drvr, 0, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200194 if (ret < 0) {
195 brcmf_dbg(ERROR, "%s: set allmulti %d failed\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800196 brcmf_ifname(drvr, 0),
Arend van Sprielb5036242011-10-12 20:51:17 +0200197 le32_to_cpu(dcmd_le_value));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200198 }
199
200 kfree(buf);
201
202 /* Finally, pick up the PROMISC flag as well, like the NIC
203 driver does */
204
Arend van Sprielb5036242011-10-12 20:51:17 +0200205 dcmd_value = (ndev->flags & IFF_PROMISC) ? true : false;
206 dcmd_le_value = cpu_to_le32(dcmd_value);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200207
208 memset(&dcmd, 0, sizeof(dcmd));
209 dcmd.cmd = BRCMF_C_SET_PROMISC;
Arend van Sprielb5036242011-10-12 20:51:17 +0200210 dcmd.buf = &dcmd_le_value;
211 dcmd.len = sizeof(dcmd_le_value);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200212 dcmd.set = true;
213
Franky Lind08b6a32011-12-16 18:36:51 -0800214 ret = brcmf_proto_dcmd(drvr, 0, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200215 if (ret < 0) {
216 brcmf_dbg(ERROR, "%s: set promisc %d failed\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800217 brcmf_ifname(drvr, 0),
Arend van Sprielb5036242011-10-12 20:51:17 +0200218 le32_to_cpu(dcmd_le_value));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200219 }
220}
221
222static void
223_brcmf_set_mac_address(struct work_struct *work)
224{
225 char buf[32];
226 struct brcmf_dcmd dcmd;
227 int ret;
228
Franky Lind08b6a32011-12-16 18:36:51 -0800229 struct brcmf_pub *drvr = container_of(work, struct brcmf_pub,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200230 setmacaddr_work);
231
232 brcmf_dbg(TRACE, "enter\n");
Franky Lind08b6a32011-12-16 18:36:51 -0800233 if (!brcmf_c_mkiovar("cur_etheraddr", (char *)drvr->macvalue,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200234 ETH_ALEN, buf, 32)) {
235 brcmf_dbg(ERROR, "%s: mkiovar failed for cur_etheraddr\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800236 brcmf_ifname(drvr, 0));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200237 return;
238 }
239 memset(&dcmd, 0, sizeof(dcmd));
240 dcmd.cmd = BRCMF_C_SET_VAR;
241 dcmd.buf = buf;
242 dcmd.len = 32;
243 dcmd.set = true;
244
Franky Lind08b6a32011-12-16 18:36:51 -0800245 ret = brcmf_proto_dcmd(drvr, 0, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200246 if (ret < 0)
247 brcmf_dbg(ERROR, "%s: set cur_etheraddr failed\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800248 brcmf_ifname(drvr, 0));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200249 else
Franky Lind08b6a32011-12-16 18:36:51 -0800250 memcpy(drvr->iflist[0]->ndev->dev_addr,
251 drvr->macvalue, ETH_ALEN);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200252
253 return;
254}
255
256static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr)
257{
Franky Line1b83582011-10-21 16:16:33 +0200258 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800259 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200260 struct sockaddr *sa = (struct sockaddr *)addr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200261
Franky Lind08b6a32011-12-16 18:36:51 -0800262 memcpy(&drvr->macvalue, sa->sa_data, ETH_ALEN);
263 schedule_work(&drvr->setmacaddr_work);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200264 return 0;
265}
266
267static void brcmf_netdev_set_multicast_list(struct net_device *ndev)
268{
Franky Line1b83582011-10-21 16:16:33 +0200269 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800270 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200271
Franky Lind08b6a32011-12-16 18:36:51 -0800272 schedule_work(&drvr->multicast_work);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200273}
274
275int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf)
276{
Arend van Spriel5b435de2011-10-05 13:19:03 +0200277 /* Reject if down */
Franky Lin3fb1d8d2011-12-16 18:37:04 -0800278 if (!drvr->bus_if->drvr_up || (drvr->bus_if->state == BRCMF_BUS_DOWN))
Arend van Spriel5b435de2011-10-05 13:19:03 +0200279 return -ENODEV;
280
281 /* Update multicast statistic */
282 if (pktbuf->len >= ETH_ALEN) {
283 u8 *pktdata = (u8 *) (pktbuf->data);
284 struct ethhdr *eh = (struct ethhdr *)pktdata;
285
286 if (is_multicast_ether_addr(eh->h_dest))
287 drvr->tx_multicast++;
288 if (ntohs(eh->h_proto) == ETH_P_PAE)
Franky Lind08b6a32011-12-16 18:36:51 -0800289 atomic_inc(&drvr->pend_8021x_cnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200290 }
291
292 /* If the protocol uses a data header, apply it */
293 brcmf_proto_hdrpush(drvr, ifidx, pktbuf);
294
295 /* Use bus module to send data frame */
Franky Linb9692d12011-12-16 18:37:15 -0800296 return drvr->bus_if->brcmf_bus_txdata(drvr->dev, pktbuf);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200297}
298
299static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev)
300{
301 int ret;
Franky Line1b83582011-10-21 16:16:33 +0200302 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800303 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200304
305 brcmf_dbg(TRACE, "Enter\n");
306
307 /* Reject if down */
Franky Lin3fb1d8d2011-12-16 18:37:04 -0800308 if (!drvr->bus_if->drvr_up ||
Franky Lind08b6a32011-12-16 18:36:51 -0800309 (drvr->bus_if->state == BRCMF_BUS_DOWN)) {
Franky Lin3fb1d8d2011-12-16 18:37:04 -0800310 brcmf_dbg(ERROR, "xmit rejected drvup=%d state=%d\n",
311 drvr->bus_if->drvr_up,
Franky Lind08b6a32011-12-16 18:36:51 -0800312 drvr->bus_if->state);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200313 netif_stop_queue(ndev);
314 return -ENODEV;
315 }
316
Franky Lind08b6a32011-12-16 18:36:51 -0800317 if (!drvr->iflist[ifp->idx]) {
Franky Line1b83582011-10-21 16:16:33 +0200318 brcmf_dbg(ERROR, "bad ifidx %d\n", ifp->idx);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200319 netif_stop_queue(ndev);
320 return -ENODEV;
321 }
322
323 /* Make sure there's enough room for any header */
Franky Lind08b6a32011-12-16 18:36:51 -0800324 if (skb_headroom(skb) < drvr->hdrlen) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200325 struct sk_buff *skb2;
326
327 brcmf_dbg(INFO, "%s: insufficient headroom\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800328 brcmf_ifname(drvr, ifp->idx));
Franky Lin9c1a0432011-12-16 18:37:07 -0800329 drvr->bus_if->tx_realloc++;
Franky Lind08b6a32011-12-16 18:36:51 -0800330 skb2 = skb_realloc_headroom(skb, drvr->hdrlen);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200331 dev_kfree_skb(skb);
332 skb = skb2;
333 if (skb == NULL) {
334 brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800335 brcmf_ifname(drvr, ifp->idx));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200336 ret = -ENOMEM;
337 goto done;
338 }
339 }
340
Franky Lind08b6a32011-12-16 18:36:51 -0800341 ret = brcmf_sendpkt(drvr, ifp->idx, skb);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200342
343done:
344 if (ret)
Franky Lin719f2732011-12-16 18:37:06 -0800345 drvr->bus_if->dstats.tx_dropped++;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200346 else
Franky Lin719f2732011-12-16 18:37:06 -0800347 drvr->bus_if->dstats.tx_packets++;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200348
349 /* Return ok: we always eat the packet */
350 return 0;
351}
352
Franky Lin2b459052011-12-16 18:36:57 -0800353void brcmf_txflowcontrol(struct device *dev, int ifidx, bool state)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200354{
355 struct net_device *ndev;
Franky Lin2b459052011-12-16 18:36:57 -0800356 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
357 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200358
359 brcmf_dbg(TRACE, "Enter\n");
360
Franky Lind08b6a32011-12-16 18:36:51 -0800361 ndev = drvr->iflist[ifidx]->ndev;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200362 if (state == ON)
363 netif_stop_queue(ndev);
364 else
365 netif_wake_queue(ndev);
366}
367
Franky Lind08b6a32011-12-16 18:36:51 -0800368static int brcmf_host_event(struct brcmf_pub *drvr, int *ifidx,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200369 void *pktdata, struct brcmf_event_msg *event,
370 void **data)
371{
372 int bcmerror = 0;
373
Franky Lind08b6a32011-12-16 18:36:51 -0800374 bcmerror = brcmf_c_host_event(drvr, ifidx, pktdata, event, data);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200375 if (bcmerror != 0)
376 return bcmerror;
377
Franky Lind08b6a32011-12-16 18:36:51 -0800378 if (drvr->iflist[*ifidx]->ndev)
379 brcmf_cfg80211_event(drvr->iflist[*ifidx]->ndev,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200380 event, *data);
381
382 return bcmerror;
383}
384
Franky Lin228bb432011-12-16 18:37:00 -0800385void brcmf_rx_frame(struct device *dev, int ifidx,
Arend van Spriel0b45bf72011-11-22 17:21:36 -0800386 struct sk_buff_head *skb_list)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200387{
Arend van Spriel5b435de2011-10-05 13:19:03 +0200388 unsigned char *eth;
389 uint len;
390 void *data;
Arend van Spriel0b45bf72011-11-22 17:21:36 -0800391 struct sk_buff *skb, *pnext;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200392 struct brcmf_if *ifp;
393 struct brcmf_event_msg event;
Franky Lin228bb432011-12-16 18:37:00 -0800394 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
395 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200396
397 brcmf_dbg(TRACE, "Enter\n");
398
Arend van Spriel0b45bf72011-11-22 17:21:36 -0800399 skb_queue_walk_safe(skb_list, skb, pnext) {
400 skb_unlink(skb, skb_list);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200401
402 /* Get the protocol, maintain skb around eth_type_trans()
403 * The main reason for this hack is for the limitation of
404 * Linux 2.4 where 'eth_type_trans' uses the
405 * 'net->hard_header_len'
406 * to perform skb_pull inside vs ETH_HLEN. Since to avoid
407 * coping of the packet coming from the network stack to add
408 * BDC, Hardware header etc, during network interface
409 * registration
410 * we set the 'net->hard_header_len' to ETH_HLEN + extra space
411 * required
412 * for BDC, Hardware header etc. and not just the ETH_HLEN
413 */
414 eth = skb->data;
415 len = skb->len;
416
Franky Lind08b6a32011-12-16 18:36:51 -0800417 ifp = drvr->iflist[ifidx];
Arend van Spriel5b435de2011-10-05 13:19:03 +0200418 if (ifp == NULL)
Franky Lind08b6a32011-12-16 18:36:51 -0800419 ifp = drvr->iflist[0];
Arend van Spriel5b435de2011-10-05 13:19:03 +0200420
Franky Lin0c094c72011-11-22 17:21:46 -0800421 if (!ifp || !ifp->ndev ||
422 ifp->ndev->reg_state != NETREG_REGISTERED) {
423 brcmu_pkt_buf_free_skb(skb);
424 continue;
425 }
426
Arend van Spriel5b435de2011-10-05 13:19:03 +0200427 skb->dev = ifp->ndev;
428 skb->protocol = eth_type_trans(skb, skb->dev);
429
430 if (skb->pkt_type == PACKET_MULTICAST)
Franky Lin719f2732011-12-16 18:37:06 -0800431 bus_if->dstats.multicast++;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200432
433 skb->data = eth;
434 skb->len = len;
435
436 /* Strip header, count, deliver upward */
437 skb_pull(skb, ETH_HLEN);
438
439 /* Process special event packets and then discard them */
440 if (ntohs(skb->protocol) == ETH_P_LINK_CTL)
Franky Lind08b6a32011-12-16 18:36:51 -0800441 brcmf_host_event(drvr, &ifidx,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200442 skb_mac_header(skb),
443 &event, &data);
444
Franky Lind08b6a32011-12-16 18:36:51 -0800445 if (drvr->iflist[ifidx]) {
446 ifp = drvr->iflist[ifidx];
Arend van Spriel5b435de2011-10-05 13:19:03 +0200447 ifp->ndev->last_rx = jiffies;
Franky Lind1a5b6f2011-10-21 16:16:34 +0200448 }
Arend van Spriel5b435de2011-10-05 13:19:03 +0200449
Franky Lin719f2732011-12-16 18:37:06 -0800450 bus_if->dstats.rx_bytes += skb->len;
451 bus_if->dstats.rx_packets++; /* Local count */
Arend van Spriel5b435de2011-10-05 13:19:03 +0200452
453 if (in_interrupt())
454 netif_rx(skb);
455 else
456 /* If the receive is not processed inside an ISR,
457 * the softirqd must be woken explicitly to service
458 * the NET_RX_SOFTIRQ. In 2.6 kernels, this is handled
459 * by netif_rx_ni(), but in earlier kernels, we need
460 * to do it manually.
461 */
462 netif_rx_ni(skb);
463 }
464}
465
Franky Linc9957882011-12-16 18:36:58 -0800466void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200467{
468 uint ifidx;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200469 struct ethhdr *eh;
470 u16 type;
Franky Linc9957882011-12-16 18:36:58 -0800471 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
472 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200473
Franky Lind5625ee2011-12-16 18:37:01 -0800474 brcmf_proto_hdrpull(dev, &ifidx, txp);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200475
476 eh = (struct ethhdr *)(txp->data);
477 type = ntohs(eh->h_proto);
478
479 if (type == ETH_P_PAE)
Franky Lind08b6a32011-12-16 18:36:51 -0800480 atomic_dec(&drvr->pend_8021x_cnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200481
482}
483
484static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev)
485{
Franky Line1b83582011-10-21 16:16:33 +0200486 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lin719f2732011-12-16 18:37:06 -0800487 struct brcmf_bus *bus_if = ifp->drvr->bus_if;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200488
489 brcmf_dbg(TRACE, "Enter\n");
490
Arend van Spriel5b435de2011-10-05 13:19:03 +0200491 /* Copy dongle stats to net device stats */
Franky Lin719f2732011-12-16 18:37:06 -0800492 ifp->stats.rx_packets = bus_if->dstats.rx_packets;
493 ifp->stats.tx_packets = bus_if->dstats.tx_packets;
494 ifp->stats.rx_bytes = bus_if->dstats.rx_bytes;
495 ifp->stats.tx_bytes = bus_if->dstats.tx_bytes;
496 ifp->stats.rx_errors = bus_if->dstats.rx_errors;
497 ifp->stats.tx_errors = bus_if->dstats.tx_errors;
498 ifp->stats.rx_dropped = bus_if->dstats.rx_dropped;
499 ifp->stats.tx_dropped = bus_if->dstats.tx_dropped;
500 ifp->stats.multicast = bus_if->dstats.multicast;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200501
502 return &ifp->stats;
503}
504
505/* Retrieve current toe component enables, which are kept
506 as a bitmap in toe_ol iovar */
Franky Lind08b6a32011-12-16 18:36:51 -0800507static int brcmf_toe_get(struct brcmf_pub *drvr, int ifidx, u32 *toe_ol)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200508{
509 struct brcmf_dcmd dcmd;
Arend van Spriel10629042011-10-12 20:51:18 +0200510 __le32 toe_le;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200511 char buf[32];
512 int ret;
513
514 memset(&dcmd, 0, sizeof(dcmd));
515
516 dcmd.cmd = BRCMF_C_GET_VAR;
517 dcmd.buf = buf;
518 dcmd.len = (uint) sizeof(buf);
519 dcmd.set = false;
520
521 strcpy(buf, "toe_ol");
Franky Lind08b6a32011-12-16 18:36:51 -0800522 ret = brcmf_proto_dcmd(drvr, ifidx, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200523 if (ret < 0) {
524 /* Check for older dongle image that doesn't support toe_ol */
525 if (ret == -EIO) {
526 brcmf_dbg(ERROR, "%s: toe not supported by device\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800527 brcmf_ifname(drvr, ifidx));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200528 return -EOPNOTSUPP;
529 }
530
531 brcmf_dbg(INFO, "%s: could not get toe_ol: ret=%d\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800532 brcmf_ifname(drvr, ifidx), ret);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200533 return ret;
534 }
535
Arend van Spriel10629042011-10-12 20:51:18 +0200536 memcpy(&toe_le, buf, sizeof(u32));
537 *toe_ol = le32_to_cpu(toe_le);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200538 return 0;
539}
540
541/* Set current toe component enables in toe_ol iovar,
542 and set toe global enable iovar */
Franky Lind08b6a32011-12-16 18:36:51 -0800543static int brcmf_toe_set(struct brcmf_pub *drvr, int ifidx, u32 toe_ol)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200544{
545 struct brcmf_dcmd dcmd;
546 char buf[32];
Arend van Spriel10629042011-10-12 20:51:18 +0200547 int ret;
548 __le32 toe_le = cpu_to_le32(toe_ol);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200549
550 memset(&dcmd, 0, sizeof(dcmd));
551
552 dcmd.cmd = BRCMF_C_SET_VAR;
553 dcmd.buf = buf;
554 dcmd.len = (uint) sizeof(buf);
555 dcmd.set = true;
556
557 /* Set toe_ol as requested */
Arend van Spriel5b435de2011-10-05 13:19:03 +0200558 strcpy(buf, "toe_ol");
Arend van Spriel10629042011-10-12 20:51:18 +0200559 memcpy(&buf[sizeof("toe_ol")], &toe_le, sizeof(u32));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200560
Franky Lind08b6a32011-12-16 18:36:51 -0800561 ret = brcmf_proto_dcmd(drvr, ifidx, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200562 if (ret < 0) {
563 brcmf_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800564 brcmf_ifname(drvr, ifidx), ret);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200565 return ret;
566 }
567
568 /* Enable toe globally only if any components are enabled. */
Arend van Spriel10629042011-10-12 20:51:18 +0200569 toe_le = cpu_to_le32(toe_ol != 0);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200570
571 strcpy(buf, "toe");
Arend van Spriel10629042011-10-12 20:51:18 +0200572 memcpy(&buf[sizeof("toe")], &toe_le, sizeof(u32));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200573
Franky Lind08b6a32011-12-16 18:36:51 -0800574 ret = brcmf_proto_dcmd(drvr, ifidx, &dcmd, dcmd.len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200575 if (ret < 0) {
576 brcmf_dbg(ERROR, "%s: could not set toe: ret=%d\n",
Franky Lind08b6a32011-12-16 18:36:51 -0800577 brcmf_ifname(drvr, ifidx), ret);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200578 return ret;
579 }
580
581 return 0;
582}
583
584static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
585 struct ethtool_drvinfo *info)
586{
Franky Line1b83582011-10-21 16:16:33 +0200587 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800588 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200589
590 sprintf(info->driver, KBUILD_MODNAME);
Franky Lind08b6a32011-12-16 18:36:51 -0800591 sprintf(info->version, "%lu", drvr->drv_version);
592 sprintf(info->bus_info, "%s", dev_name(drvr->dev));
Arend van Spriel5b435de2011-10-05 13:19:03 +0200593}
594
Stephen Hemminger3eb1fa72012-01-04 14:52:51 -0800595static const struct ethtool_ops brcmf_ethtool_ops = {
596 .get_drvinfo = brcmf_ethtool_get_drvinfo,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200597};
598
Franky Lind08b6a32011-12-16 18:36:51 -0800599static int brcmf_ethtool(struct brcmf_pub *drvr, void __user *uaddr)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200600{
601 struct ethtool_drvinfo info;
602 char drvname[sizeof(info.driver)];
603 u32 cmd;
604 struct ethtool_value edata;
605 u32 toe_cmpnt, csum_dir;
606 int ret;
607
608 brcmf_dbg(TRACE, "Enter\n");
609
610 /* all ethtool calls start with a cmd word */
611 if (copy_from_user(&cmd, uaddr, sizeof(u32)))
612 return -EFAULT;
613
614 switch (cmd) {
615 case ETHTOOL_GDRVINFO:
616 /* Copy out any request driver name */
617 if (copy_from_user(&info, uaddr, sizeof(info)))
618 return -EFAULT;
619 strncpy(drvname, info.driver, sizeof(info.driver));
620 drvname[sizeof(info.driver) - 1] = '\0';
621
622 /* clear struct for return */
623 memset(&info, 0, sizeof(info));
624 info.cmd = cmd;
625
626 /* if requested, identify ourselves */
627 if (strcmp(drvname, "?dhd") == 0) {
628 sprintf(info.driver, "dhd");
629 strcpy(info.version, BRCMF_VERSION_STR);
630 }
631
632 /* otherwise, require dongle to be up */
Franky Lin3fb1d8d2011-12-16 18:37:04 -0800633 else if (!drvr->bus_if->drvr_up) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200634 brcmf_dbg(ERROR, "dongle is not up\n");
635 return -ENODEV;
636 }
637
638 /* finally, report dongle driver type */
Franky Lind08b6a32011-12-16 18:36:51 -0800639 else if (drvr->iswl)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200640 sprintf(info.driver, "wl");
641 else
642 sprintf(info.driver, "xx");
643
Franky Lind08b6a32011-12-16 18:36:51 -0800644 sprintf(info.version, "%lu", drvr->drv_version);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200645 if (copy_to_user(uaddr, &info, sizeof(info)))
646 return -EFAULT;
647 brcmf_dbg(CTL, "given %*s, returning %s\n",
648 (int)sizeof(drvname), drvname, info.driver);
649 break;
650
651 /* Get toe offload components from dongle */
652 case ETHTOOL_GRXCSUM:
653 case ETHTOOL_GTXCSUM:
Franky Lind08b6a32011-12-16 18:36:51 -0800654 ret = brcmf_toe_get(drvr, 0, &toe_cmpnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200655 if (ret < 0)
656 return ret;
657
658 csum_dir =
659 (cmd == ETHTOOL_GTXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL;
660
661 edata.cmd = cmd;
662 edata.data = (toe_cmpnt & csum_dir) ? 1 : 0;
663
664 if (copy_to_user(uaddr, &edata, sizeof(edata)))
665 return -EFAULT;
666 break;
667
668 /* Set toe offload components in dongle */
669 case ETHTOOL_SRXCSUM:
670 case ETHTOOL_STXCSUM:
671 if (copy_from_user(&edata, uaddr, sizeof(edata)))
672 return -EFAULT;
673
674 /* Read the current settings, update and write back */
Franky Lind08b6a32011-12-16 18:36:51 -0800675 ret = brcmf_toe_get(drvr, 0, &toe_cmpnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200676 if (ret < 0)
677 return ret;
678
679 csum_dir =
680 (cmd == ETHTOOL_STXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL;
681
682 if (edata.data != 0)
683 toe_cmpnt |= csum_dir;
684 else
685 toe_cmpnt &= ~csum_dir;
686
Franky Lind08b6a32011-12-16 18:36:51 -0800687 ret = brcmf_toe_set(drvr, 0, toe_cmpnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200688 if (ret < 0)
689 return ret;
690
691 /* If setting TX checksum mode, tell Linux the new mode */
692 if (cmd == ETHTOOL_STXCSUM) {
693 if (edata.data)
Franky Lind08b6a32011-12-16 18:36:51 -0800694 drvr->iflist[0]->ndev->features |=
Arend van Spriel5b435de2011-10-05 13:19:03 +0200695 NETIF_F_IP_CSUM;
696 else
Franky Lind08b6a32011-12-16 18:36:51 -0800697 drvr->iflist[0]->ndev->features &=
Arend van Spriel5b435de2011-10-05 13:19:03 +0200698 ~NETIF_F_IP_CSUM;
699 }
700
701 break;
702
703 default:
704 return -EOPNOTSUPP;
705 }
706
707 return 0;
708}
709
710static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr,
711 int cmd)
712{
Franky Line1b83582011-10-21 16:16:33 +0200713 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800714 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200715
Franky Line1b83582011-10-21 16:16:33 +0200716 brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifp->idx, cmd);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200717
Franky Lind08b6a32011-12-16 18:36:51 -0800718 if (!drvr->iflist[ifp->idx])
Arend van Spriel5b435de2011-10-05 13:19:03 +0200719 return -1;
720
721 if (cmd == SIOCETHTOOL)
Franky Lind08b6a32011-12-16 18:36:51 -0800722 return brcmf_ethtool(drvr, ifr->ifr_data);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200723
724 return -EOPNOTSUPP;
725}
726
727/* called only from within this driver. Sends a command to the dongle. */
728s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len)
729{
730 struct brcmf_dcmd dcmd;
731 s32 err = 0;
732 int buflen = 0;
733 bool is_set_key_cmd;
Franky Line1b83582011-10-21 16:16:33 +0200734 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800735 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200736
737 memset(&dcmd, 0, sizeof(dcmd));
738 dcmd.cmd = cmd;
739 dcmd.buf = arg;
740 dcmd.len = len;
741
Arend van Spriel5b435de2011-10-05 13:19:03 +0200742 if (dcmd.buf != NULL)
743 buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN);
744
745 /* send to dongle (must be up, and wl) */
Franky Lind08b6a32011-12-16 18:36:51 -0800746 if ((drvr->bus_if->state != BRCMF_BUS_DATA)) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200747 brcmf_dbg(ERROR, "DONGLE_DOWN\n");
748 err = -EIO;
749 goto done;
750 }
751
Franky Lind08b6a32011-12-16 18:36:51 -0800752 if (!drvr->iswl) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200753 err = -EIO;
754 goto done;
755 }
756
757 /*
758 * Intercept BRCMF_C_SET_KEY CMD - serialize M4 send and
759 * set key CMD to prevent M4 encryption.
760 */
761 is_set_key_cmd = ((dcmd.cmd == BRCMF_C_SET_KEY) ||
762 ((dcmd.cmd == BRCMF_C_SET_VAR) &&
763 !(strncmp("wsec_key", dcmd.buf, 9))) ||
764 ((dcmd.cmd == BRCMF_C_SET_VAR) &&
765 !(strncmp("bsscfg:wsec_key", dcmd.buf, 15))));
766 if (is_set_key_cmd)
767 brcmf_netdev_wait_pend8021x(ndev);
768
Franky Lind08b6a32011-12-16 18:36:51 -0800769 err = brcmf_proto_dcmd(drvr, ifp->idx, &dcmd, buflen);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200770
771done:
772 if (err > 0)
773 err = 0;
774
775 return err;
776}
777
778static int brcmf_netdev_stop(struct net_device *ndev)
779{
Franky Line1b83582011-10-21 16:16:33 +0200780 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800781 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200782
783 brcmf_dbg(TRACE, "Enter\n");
784 brcmf_cfg80211_down(drvr->config);
Franky Lin3fb1d8d2011-12-16 18:37:04 -0800785 if (drvr->bus_if->drvr_up == 0)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200786 return 0;
787
788 /* Set state and stop OS transmissions */
John W. Linville57adc1f2012-01-03 15:16:34 -0500789 drvr->bus_if->drvr_up = false;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200790 netif_stop_queue(ndev);
791
792 return 0;
793}
794
795static int brcmf_netdev_open(struct net_device *ndev)
796{
Franky Line1b83582011-10-21 16:16:33 +0200797 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800798 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel1bb1f382012-02-09 21:09:05 +0100799 struct brcmf_bus *bus_if = drvr->bus_if;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200800 u32 toe_ol;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200801 s32 ret = 0;
Franky Lin33380842012-04-11 11:52:47 +0200802 uint up = 0;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200803
Franky Line1b83582011-10-21 16:16:33 +0200804 brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200805
Franky Line1b83582011-10-21 16:16:33 +0200806 if (ifp->idx == 0) { /* do it only for primary eth0 */
Arend van Spriel1bb1f382012-02-09 21:09:05 +0100807 /* If bus is not ready, can't continue */
808 if (bus_if->state != BRCMF_BUS_DATA) {
809 brcmf_dbg(ERROR, "failed bus is not ready\n");
810 return -EAGAIN;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200811 }
Arend van Spriel1bb1f382012-02-09 21:09:05 +0100812
Franky Lind08b6a32011-12-16 18:36:51 -0800813 atomic_set(&drvr->pend_8021x_cnt, 0);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200814
Franky Lind08b6a32011-12-16 18:36:51 -0800815 memcpy(ndev->dev_addr, drvr->mac, ETH_ALEN);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200816
817 /* Get current TOE mode from dongle */
Franky Lind08b6a32011-12-16 18:36:51 -0800818 if (brcmf_toe_get(drvr, ifp->idx, &toe_ol) >= 0
Arend van Spriel5b435de2011-10-05 13:19:03 +0200819 && (toe_ol & TOE_TX_CSUM_OL) != 0)
Franky Lind08b6a32011-12-16 18:36:51 -0800820 drvr->iflist[ifp->idx]->ndev->features |=
Arend van Spriel5b435de2011-10-05 13:19:03 +0200821 NETIF_F_IP_CSUM;
822 else
Franky Lind08b6a32011-12-16 18:36:51 -0800823 drvr->iflist[ifp->idx]->ndev->features &=
Arend van Spriel5b435de2011-10-05 13:19:03 +0200824 ~NETIF_F_IP_CSUM;
825 }
Franky Lin33380842012-04-11 11:52:47 +0200826
827 /* make sure RF is ready for work */
828 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up));
829
Arend van Spriel5b435de2011-10-05 13:19:03 +0200830 /* Allow transmit calls */
831 netif_start_queue(ndev);
John W. Linville57adc1f2012-01-03 15:16:34 -0500832 drvr->bus_if->drvr_up = true;
Franky Lind08b6a32011-12-16 18:36:51 -0800833 if (brcmf_cfg80211_up(drvr->config)) {
Arend van Spriel5b435de2011-10-05 13:19:03 +0200834 brcmf_dbg(ERROR, "failed to bring up cfg80211\n");
835 return -1;
836 }
837
838 return ret;
839}
840
Franky Lindfded552011-10-21 16:16:20 +0200841static const struct net_device_ops brcmf_netdev_ops_pri = {
842 .ndo_open = brcmf_netdev_open,
843 .ndo_stop = brcmf_netdev_stop,
844 .ndo_get_stats = brcmf_netdev_get_stats,
845 .ndo_do_ioctl = brcmf_netdev_ioctl_entry,
846 .ndo_start_xmit = brcmf_netdev_start_xmit,
847 .ndo_set_mac_address = brcmf_netdev_set_mac_address,
848 .ndo_set_rx_mode = brcmf_netdev_set_multicast_list
849};
850
Arend van Spriel3625c142012-04-11 11:52:44 +0200851static int brcmf_net_attach(struct brcmf_if *ifp)
Arend van Spriel75c49902012-04-11 11:52:43 +0200852{
Arend van Spriel3625c142012-04-11 11:52:44 +0200853 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel75c49902012-04-11 11:52:43 +0200854 struct net_device *ndev;
Arend van Spriel3625c142012-04-11 11:52:44 +0200855 u8 temp_addr[ETH_ALEN];
Arend van Spriel75c49902012-04-11 11:52:43 +0200856
Arend van Spriel3625c142012-04-11 11:52:44 +0200857 brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx);
Arend van Spriel75c49902012-04-11 11:52:43 +0200858
Arend van Spriel3625c142012-04-11 11:52:44 +0200859 ndev = drvr->iflist[ifp->idx]->ndev;
Arend van Spriel75c49902012-04-11 11:52:43 +0200860 ndev->netdev_ops = &brcmf_netdev_ops_pri;
861
862 /*
Arend van Spriel3625c142012-04-11 11:52:44 +0200863 * determine mac address to use
Arend van Spriel75c49902012-04-11 11:52:43 +0200864 */
Arend van Spriel3625c142012-04-11 11:52:44 +0200865 if (is_valid_ether_addr(ifp->mac_addr))
866 memcpy(temp_addr, ifp->mac_addr, ETH_ALEN);
867 else
Arend van Spriel75c49902012-04-11 11:52:43 +0200868 memcpy(temp_addr, drvr->mac, ETH_ALEN);
869
Arend van Spriel3625c142012-04-11 11:52:44 +0200870 if (ifp->idx == 1) {
Arend van Spriel75c49902012-04-11 11:52:43 +0200871 brcmf_dbg(TRACE, "ACCESS POINT MAC:\n");
872 /* ACCESSPOINT INTERFACE CASE */
873 temp_addr[0] |= 0X02; /* set bit 2 ,
874 - Locally Administered address */
875
876 }
877 ndev->hard_header_len = ETH_HLEN + drvr->hdrlen;
878 ndev->ethtool_ops = &brcmf_ethtool_ops;
879
880 drvr->rxsz = ndev->mtu + ndev->hard_header_len +
881 drvr->hdrlen;
882
883 memcpy(ndev->dev_addr, temp_addr, ETH_ALEN);
884
885 /* attach to cfg80211 for primary interface */
Arend van Spriel3625c142012-04-11 11:52:44 +0200886 if (!ifp->idx) {
Arend van Spriel75c49902012-04-11 11:52:43 +0200887 drvr->config = brcmf_cfg80211_attach(ndev, drvr->dev, drvr);
888 if (drvr->config == NULL) {
889 brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n");
890 goto fail;
891 }
892 }
893
894 if (register_netdev(ndev) != 0) {
895 brcmf_dbg(ERROR, "couldn't register the net device\n");
896 goto fail;
897 }
898
899 brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", ndev->name);
900
901 return 0;
902
903fail:
904 ndev->netdev_ops = NULL;
905 return -EBADE;
906}
907
Arend van Spriel5b435de2011-10-05 13:19:03 +0200908int
Franky Lin55a63bc2011-12-16 18:36:54 -0800909brcmf_add_if(struct device *dev, int ifidx, char *name, u8 *mac_addr)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200910{
911 struct brcmf_if *ifp;
Franky Line1b83582011-10-21 16:16:33 +0200912 struct net_device *ndev;
Franky Lin55a63bc2011-12-16 18:36:54 -0800913 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
914 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200915
Franky Lin15d45b62011-10-21 16:16:32 +0200916 brcmf_dbg(TRACE, "idx %d\n", ifidx);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200917
Franky Lind08b6a32011-12-16 18:36:51 -0800918 ifp = drvr->iflist[ifidx];
Franky Line1b83582011-10-21 16:16:33 +0200919 /*
920 * Delete the existing interface before overwriting it
921 * in case we missed the BRCMF_E_IF_DEL event.
922 */
923 if (ifp) {
924 brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n",
925 ifp->ndev->name);
926 netif_stop_queue(ifp->ndev);
927 unregister_netdev(ifp->ndev);
928 free_netdev(ifp->ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800929 drvr->iflist[ifidx] = NULL;
Franky Lin15d45b62011-10-21 16:16:32 +0200930 }
Franky Line1b83582011-10-21 16:16:33 +0200931
932 /* Allocate netdev, including space for private structure */
933 ndev = alloc_netdev(sizeof(struct brcmf_if), name, ether_setup);
934 if (!ndev) {
935 brcmf_dbg(ERROR, "OOM - alloc_netdev\n");
936 return -ENOMEM;
937 }
938
939 ifp = netdev_priv(ndev);
940 ifp->ndev = ndev;
Franky Lind08b6a32011-12-16 18:36:51 -0800941 ifp->drvr = drvr;
942 drvr->iflist[ifidx] = ifp;
Franky Lin15d45b62011-10-21 16:16:32 +0200943 ifp->idx = ifidx;
Franky Lin15d45b62011-10-21 16:16:32 +0200944 if (mac_addr != NULL)
945 memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200946
Arend van Spriel3625c142012-04-11 11:52:44 +0200947 if (brcmf_net_attach(ifp)) {
Franky Lin15d45b62011-10-21 16:16:32 +0200948 brcmf_dbg(ERROR, "brcmf_net_attach failed");
949 free_netdev(ifp->ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800950 drvr->iflist[ifidx] = NULL;
Franky Line1b83582011-10-21 16:16:33 +0200951 return -EOPNOTSUPP;
Franky Lin15d45b62011-10-21 16:16:32 +0200952 }
Arend van Spriel5b435de2011-10-05 13:19:03 +0200953
Franky Lin15d45b62011-10-21 16:16:32 +0200954 brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n",
955 current->pid, ifp->ndev->name);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200956
957 return 0;
958}
959
Franky Lind08b6a32011-12-16 18:36:51 -0800960void brcmf_del_if(struct brcmf_pub *drvr, int ifidx)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200961{
962 struct brcmf_if *ifp;
963
964 brcmf_dbg(TRACE, "idx %d\n", ifidx);
965
Franky Lind08b6a32011-12-16 18:36:51 -0800966 ifp = drvr->iflist[ifidx];
Arend van Spriel5b435de2011-10-05 13:19:03 +0200967 if (!ifp) {
968 brcmf_dbg(ERROR, "Null interface\n");
969 return;
970 }
Franky Lindfded552011-10-21 16:16:20 +0200971 if (ifp->ndev) {
972 if (ifidx == 0) {
973 if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
974 rtnl_lock();
975 brcmf_netdev_stop(ifp->ndev);
976 rtnl_unlock();
977 }
978 } else {
979 netif_stop_queue(ifp->ndev);
980 }
981
Arend van Spriel5b435de2011-10-05 13:19:03 +0200982 unregister_netdev(ifp->ndev);
Franky Lind08b6a32011-12-16 18:36:51 -0800983 drvr->iflist[ifidx] = NULL;
Franky Lindfded552011-10-21 16:16:20 +0200984 if (ifidx == 0)
Franky Lind08b6a32011-12-16 18:36:51 -0800985 brcmf_cfg80211_detach(drvr->config);
Franky Lindfded552011-10-21 16:16:20 +0200986 free_netdev(ifp->ndev);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200987 }
988}
989
Franky Lin2447ffb2011-12-16 18:37:10 -0800990int brcmf_attach(uint bus_hdrlen, struct device *dev)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200991{
Franky Lind08b6a32011-12-16 18:36:51 -0800992 struct brcmf_pub *drvr = NULL;
Franky Lin712ac5b2011-12-16 18:37:09 -0800993 int ret = 0;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200994
995 brcmf_dbg(TRACE, "Enter\n");
996
Arend van Spriel5b435de2011-10-05 13:19:03 +0200997 /* Allocate primary brcmf_info */
Franky Lind08b6a32011-12-16 18:36:51 -0800998 drvr = kzalloc(sizeof(struct brcmf_pub), GFP_ATOMIC);
999 if (!drvr)
Franky Lin712ac5b2011-12-16 18:37:09 -08001000 return -ENOMEM;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001001
Franky Lind08b6a32011-12-16 18:36:51 -08001002 mutex_init(&drvr->proto_block);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001003
1004 /* Link to bus module */
Franky Lind08b6a32011-12-16 18:36:51 -08001005 drvr->hdrlen = bus_hdrlen;
1006 drvr->bus_if = dev_get_drvdata(dev);
Franky Lin55a63bc2011-12-16 18:36:54 -08001007 drvr->bus_if->drvr = drvr;
Franky Lind08b6a32011-12-16 18:36:51 -08001008 drvr->dev = dev;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001009
Arend van Sprield319a7c2012-06-09 22:51:43 +02001010 /* create device debugfs folder */
1011 brcmf_debugfs_attach(drvr);
1012
Arend van Spriel5b435de2011-10-05 13:19:03 +02001013 /* Attach and link in the protocol */
Franky Lin712ac5b2011-12-16 18:37:09 -08001014 ret = brcmf_proto_attach(drvr);
1015 if (ret != 0) {
Arend van Spriel5b435de2011-10-05 13:19:03 +02001016 brcmf_dbg(ERROR, "brcmf_prot_attach failed\n");
1017 goto fail;
1018 }
1019
Franky Lind08b6a32011-12-16 18:36:51 -08001020 INIT_WORK(&drvr->setmacaddr_work, _brcmf_set_mac_address);
1021 INIT_WORK(&drvr->multicast_work, _brcmf_set_multicast_list);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001022
Franky Lin135e4c62012-06-26 21:26:34 +02001023 INIT_LIST_HEAD(&drvr->bus_if->dcmd_list);
1024
Franky Lin712ac5b2011-12-16 18:37:09 -08001025 return ret;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001026
1027fail:
Franky Lin712ac5b2011-12-16 18:37:09 -08001028 brcmf_detach(dev);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001029
Franky Lin712ac5b2011-12-16 18:37:09 -08001030 return ret;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001031}
1032
Franky Lined683c92011-12-16 18:36:55 -08001033int brcmf_bus_start(struct device *dev)
Arend van Spriel5b435de2011-10-05 13:19:03 +02001034{
1035 int ret = -1;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001036 /* Room for "event_msgs" + '\0' + bitvec */
1037 char iovbuf[BRCMF_EVENTING_MASK_LEN + 12];
Franky Lined683c92011-12-16 18:36:55 -08001038 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
1039 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001040
1041 brcmf_dbg(TRACE, "\n");
1042
1043 /* Bring up the bus */
Franky Lin99a0b8f2011-12-16 18:37:14 -08001044 ret = bus_if->brcmf_bus_init(dev);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001045 if (ret != 0) {
1046 brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret);
1047 return ret;
1048 }
1049
Alwin Beukers53a22772011-10-12 20:51:30 +02001050 brcmf_c_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN,
Arend van Spriel5b435de2011-10-05 13:19:03 +02001051 iovbuf, sizeof(iovbuf));
1052 brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, iovbuf,
1053 sizeof(iovbuf));
1054 memcpy(drvr->eventmask, iovbuf, BRCMF_EVENTING_MASK_LEN);
1055
1056 setbit(drvr->eventmask, BRCMF_E_SET_SSID);
1057 setbit(drvr->eventmask, BRCMF_E_PRUNE);
1058 setbit(drvr->eventmask, BRCMF_E_AUTH);
1059 setbit(drvr->eventmask, BRCMF_E_REASSOC);
1060 setbit(drvr->eventmask, BRCMF_E_REASSOC_IND);
1061 setbit(drvr->eventmask, BRCMF_E_DEAUTH_IND);
1062 setbit(drvr->eventmask, BRCMF_E_DISASSOC_IND);
1063 setbit(drvr->eventmask, BRCMF_E_DISASSOC);
1064 setbit(drvr->eventmask, BRCMF_E_JOIN);
1065 setbit(drvr->eventmask, BRCMF_E_ASSOC_IND);
1066 setbit(drvr->eventmask, BRCMF_E_PSK_SUP);
1067 setbit(drvr->eventmask, BRCMF_E_LINK);
1068 setbit(drvr->eventmask, BRCMF_E_NDIS_LINK);
1069 setbit(drvr->eventmask, BRCMF_E_MIC_ERROR);
1070 setbit(drvr->eventmask, BRCMF_E_PMKID_CACHE);
1071 setbit(drvr->eventmask, BRCMF_E_TXFAIL);
1072 setbit(drvr->eventmask, BRCMF_E_JOIN_START);
1073 setbit(drvr->eventmask, BRCMF_E_SCAN_COMPLETE);
1074
1075/* enable dongle roaming event */
1076
1077 drvr->pktfilter_count = 1;
1078 /* Setup filter to allow only unicast */
1079 drvr->pktfilter[0] = "100 0 0 0 0x01 0x00";
1080
1081 /* Bus is ready, do any protocol initialization */
Franky Lind08b6a32011-12-16 18:36:51 -08001082 ret = brcmf_proto_init(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001083 if (ret < 0)
1084 return ret;
1085
Arend van Spriel474a64c2012-04-11 11:52:45 +02001086 /* add primary networking interface */
1087 ret = brcmf_add_if(dev, 0, "wlan%d", drvr->mac);
1088 if (ret < 0)
1089 return ret;
1090
Arend van Spriel1bb1f382012-02-09 21:09:05 +01001091 /* signal bus ready */
1092 bus_if->state = BRCMF_BUS_DATA;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001093 return 0;
1094}
1095
Arend van Spriel5b435de2011-10-05 13:19:03 +02001096static void brcmf_bus_detach(struct brcmf_pub *drvr)
1097{
Arend van Spriel5b435de2011-10-05 13:19:03 +02001098 brcmf_dbg(TRACE, "Enter\n");
1099
1100 if (drvr) {
Franky Lind08b6a32011-12-16 18:36:51 -08001101 /* Stop the protocol module */
1102 brcmf_proto_stop(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001103
Franky Lind08b6a32011-12-16 18:36:51 -08001104 /* Stop the bus module */
Franky Lina9ffda82011-12-16 18:37:12 -08001105 drvr->bus_if->brcmf_bus_stop(drvr->dev);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001106 }
1107}
1108
Franky Lin5f947ad2011-12-16 18:36:56 -08001109void brcmf_detach(struct device *dev)
Arend van Spriel5b435de2011-10-05 13:19:03 +02001110{
Franky Lin5f947ad2011-12-16 18:36:56 -08001111 int i;
1112 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
1113 struct brcmf_pub *drvr = bus_if->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001114
1115 brcmf_dbg(TRACE, "Enter\n");
1116
Arend van Spriel5b435de2011-10-05 13:19:03 +02001117
Franky Lin5f947ad2011-12-16 18:36:56 -08001118 /* make sure primary interface removed last */
1119 for (i = BRCMF_MAX_IFS-1; i > -1; i--)
1120 if (drvr->iflist[i])
1121 brcmf_del_if(drvr, i);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001122
Franky Lin5f947ad2011-12-16 18:36:56 -08001123 brcmf_bus_detach(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001124
Franky Lin89fdb462012-02-09 21:09:01 +01001125 if (drvr->prot) {
1126 cancel_work_sync(&drvr->setmacaddr_work);
1127 cancel_work_sync(&drvr->multicast_work);
Franky Lin5f947ad2011-12-16 18:36:56 -08001128 brcmf_proto_detach(drvr);
Franky Lin89fdb462012-02-09 21:09:01 +01001129 }
Arend van Spriel5b435de2011-10-05 13:19:03 +02001130
Arend van Sprield319a7c2012-06-09 22:51:43 +02001131 brcmf_debugfs_detach(drvr);
Franky Lin5f947ad2011-12-16 18:36:56 -08001132 bus_if->drvr = NULL;
1133 kfree(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001134}
1135
Franky Lind08b6a32011-12-16 18:36:51 -08001136static int brcmf_get_pend_8021x_cnt(struct brcmf_pub *drvr)
Arend van Spriel5b435de2011-10-05 13:19:03 +02001137{
Franky Lind08b6a32011-12-16 18:36:51 -08001138 return atomic_read(&drvr->pend_8021x_cnt);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001139}
1140
1141#define MAX_WAIT_FOR_8021X_TX 10
1142
1143int brcmf_netdev_wait_pend8021x(struct net_device *ndev)
1144{
Franky Line1b83582011-10-21 16:16:33 +02001145 struct brcmf_if *ifp = netdev_priv(ndev);
Franky Lind08b6a32011-12-16 18:36:51 -08001146 struct brcmf_pub *drvr = ifp->drvr;
Arend van Spriel5b435de2011-10-05 13:19:03 +02001147 int timeout = 10 * HZ / 1000;
1148 int ntimes = MAX_WAIT_FOR_8021X_TX;
Franky Lind08b6a32011-12-16 18:36:51 -08001149 int pend = brcmf_get_pend_8021x_cnt(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001150
1151 while (ntimes && pend) {
1152 if (pend) {
1153 set_current_state(TASK_INTERRUPTIBLE);
1154 schedule_timeout(timeout);
1155 set_current_state(TASK_RUNNING);
1156 ntimes--;
1157 }
Franky Lind08b6a32011-12-16 18:36:51 -08001158 pend = brcmf_get_pend_8021x_cnt(drvr);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001159 }
1160 return pend;
1161}
1162
Joe Perches8ae74652012-01-15 00:38:38 -08001163#ifdef DEBUG
Arend van Sprielaf534952011-10-12 20:51:14 +02001164int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size)
Arend van Spriel5b435de2011-10-05 13:19:03 +02001165{
1166 int ret = 0;
1167 struct file *fp;
1168 mm_segment_t old_fs;
1169 loff_t pos = 0;
1170
1171 /* change to KERNEL_DS address limit */
1172 old_fs = get_fs();
1173 set_fs(KERNEL_DS);
1174
1175 /* open file to write */
1176 fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640);
1177 if (!fp) {
1178 brcmf_dbg(ERROR, "open file error\n");
1179 ret = -1;
1180 goto exit;
1181 }
1182
1183 /* Write buf to file */
Arend van Sprielaf534952011-10-12 20:51:14 +02001184 fp->f_op->write(fp, (char __user *)buf, size, &pos);
Arend van Spriel5b435de2011-10-05 13:19:03 +02001185
1186exit:
1187 /* free buf before return */
1188 kfree(buf);
1189 /* close file before return */
1190 if (fp)
1191 filp_close(fp, current->files);
1192 /* restore previous address limit */
1193 set_fs(old_fs);
1194
1195 return ret;
1196}
Joe Perches8ae74652012-01-15 00:38:38 -08001197#endif /* DEBUG */
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001198
Arend van Spriele64a4b72012-03-02 22:55:49 +01001199static void brcmf_driver_init(struct work_struct *work)
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001200{
Arend van Sprield319a7c2012-06-09 22:51:43 +02001201 brcmf_debugfs_init();
1202
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001203#ifdef CONFIG_BRCMFMAC_SDIO
Arend van Spriel549040a2012-03-02 22:55:48 +01001204 brcmf_sdio_init();
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001205#endif
Arend van Spriel71bb2442012-02-09 21:09:08 +01001206#ifdef CONFIG_BRCMFMAC_USB
Arend van Spriel549040a2012-03-02 22:55:48 +01001207 brcmf_usb_init();
Arend van Spriel71bb2442012-02-09 21:09:08 +01001208#endif
Arend van Spriele64a4b72012-03-02 22:55:49 +01001209}
1210static DECLARE_WORK(brcmf_driver_work, brcmf_driver_init);
1211
1212static int __init brcmfmac_module_init(void)
1213{
1214 if (!schedule_work(&brcmf_driver_work))
1215 return -EBUSY;
1216
Arend van Spriel549040a2012-03-02 22:55:48 +01001217 return 0;
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001218}
1219
Arend van Spriele64a4b72012-03-02 22:55:49 +01001220static void __exit brcmfmac_module_exit(void)
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001221{
Arend van Spriele64a4b72012-03-02 22:55:49 +01001222 cancel_work_sync(&brcmf_driver_work);
1223
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001224#ifdef CONFIG_BRCMFMAC_SDIO
1225 brcmf_sdio_exit();
1226#endif
Arend van Spriel71bb2442012-02-09 21:09:08 +01001227#ifdef CONFIG_BRCMFMAC_USB
1228 brcmf_usb_exit();
1229#endif
Arend van Sprield319a7c2012-06-09 22:51:43 +02001230 brcmf_debugfs_exit();
Arend van Sprielf3d7cdc2012-02-09 21:09:03 +01001231}
1232
Arend van Spriele64a4b72012-03-02 22:55:49 +01001233module_init(brcmfmac_module_init);
1234module_exit(brcmfmac_module_exit);