2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #include <linux/kernel.h>
18 #include <linux/etherdevice.h>
19 #include <linux/module.h>
20 #include <net/cfg80211.h>
21 #include <net/rtnetlink.h>
22 #include <brcmu_utils.h>
23 #include <brcmu_wifi.h>
27 #include "dhd_proto.h"
29 #include "wl_cfg80211.h"
32 MODULE_AUTHOR("Broadcom Corporation");
33 MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
34 MODULE_SUPPORTED_DEVICE("Broadcom 802.11 WLAN fullmac cards");
35 MODULE_LICENSE("Dual BSD/GPL");
37 #define MAX_WAIT_FOR_8021X_TX 50 /* msecs */
41 module_param(brcmf_msg_level, int, 0);
44 char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx)
46 if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
47 brcmf_err("ifidx %d out of range\n", ifidx);
51 if (drvr->iflist[ifidx] == NULL) {
52 brcmf_err("null i/f %d\n", ifidx);
56 if (drvr->iflist[ifidx]->ndev)
57 return drvr->iflist[ifidx]->ndev->name;
62 static void _brcmf_set_multicast_list(struct work_struct *work)
65 struct net_device *ndev;
66 struct netdev_hw_addr *ha;
73 ifp = container_of(work, struct brcmf_if, multicast_work);
75 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
79 /* Determine initial value of allmulti flag */
80 cmd_value = (ndev->flags & IFF_ALLMULTI) ? true : false;
82 /* Send down the multicast list first. */
83 cnt = netdev_mc_count(ndev);
84 buflen = sizeof(cnt) + (cnt * ETH_ALEN);
85 buf = kmalloc(buflen, GFP_ATOMIC);
90 cnt_le = cpu_to_le32(cnt);
91 memcpy(bufp, &cnt_le, sizeof(cnt_le));
92 bufp += sizeof(cnt_le);
94 netdev_for_each_mc_addr(ha, ndev) {
97 memcpy(bufp, ha->addr, ETH_ALEN);
102 err = brcmf_fil_iovar_data_set(ifp, "mcast_list", buf, buflen);
104 brcmf_err("Setting mcast_list failed, %d\n", err);
105 cmd_value = cnt ? true : cmd_value;
111 * Now send the allmulti setting. This is based on the setting in the
112 * net_device flags, but might be modified above to be turned on if we
113 * were trying to set some addresses and dongle rejected it...
115 err = brcmf_fil_iovar_int_set(ifp, "allmulti", cmd_value);
117 brcmf_err("Setting allmulti failed, %d\n", err);
119 /*Finally, pick up the PROMISC flag */
120 cmd_value = (ndev->flags & IFF_PROMISC) ? true : false;
121 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PROMISC, cmd_value);
123 brcmf_err("Setting BRCMF_C_SET_PROMISC failed, %d\n",
128 _brcmf_set_mac_address(struct work_struct *work)
130 struct brcmf_if *ifp;
133 ifp = container_of(work, struct brcmf_if, setmacaddr_work);
135 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
137 err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", ifp->mac_addr,
140 brcmf_err("Setting cur_etheraddr failed, %d\n", err);
142 brcmf_dbg(TRACE, "MAC address updated to %pM\n",
144 memcpy(ifp->ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
148 static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr)
150 struct brcmf_if *ifp = netdev_priv(ndev);
151 struct sockaddr *sa = (struct sockaddr *)addr;
153 memcpy(&ifp->mac_addr, sa->sa_data, ETH_ALEN);
154 schedule_work(&ifp->setmacaddr_work);
158 static void brcmf_netdev_set_multicast_list(struct net_device *ndev)
160 struct brcmf_if *ifp = netdev_priv(ndev);
162 schedule_work(&ifp->multicast_work);
165 static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
166 struct net_device *ndev)
169 struct brcmf_if *ifp = netdev_priv(ndev);
170 struct brcmf_pub *drvr = ifp->drvr;
173 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
175 /* Can the device send data? */
176 if (drvr->bus_if->state != BRCMF_BUS_DATA) {
177 brcmf_err("xmit rejected state=%d\n", drvr->bus_if->state);
178 netif_stop_queue(ndev);
184 if (!drvr->iflist[ifp->idx]) {
185 brcmf_err("bad ifidx %d\n", ifp->idx);
186 netif_stop_queue(ndev);
192 /* Make sure there's enough room for any header */
193 if (skb_headroom(skb) < drvr->hdrlen) {
194 struct sk_buff *skb2;
196 brcmf_dbg(INFO, "%s: insufficient headroom\n",
197 brcmf_ifname(drvr, ifp->idx));
198 drvr->bus_if->tx_realloc++;
199 skb2 = skb_realloc_headroom(skb, drvr->hdrlen);
203 brcmf_err("%s: skb_realloc_headroom failed\n",
204 brcmf_ifname(drvr, ifp->idx));
210 /* validate length for ether packet */
211 if (skb->len < sizeof(*eh)) {
217 /* handle ethernet header */
218 eh = (struct ethhdr *)(skb->data);
219 if (is_multicast_ether_addr(eh->h_dest))
220 drvr->tx_multicast++;
221 if (ntohs(eh->h_proto) == ETH_P_PAE)
222 atomic_inc(&ifp->pend_8021x_cnt);
224 /* If the protocol uses a data header, apply it */
225 brcmf_proto_hdrpush(drvr, ifp->idx, skb);
227 /* Use bus module to send data frame */
228 ret = brcmf_bus_txdata(drvr->bus_if, skb);
232 ifp->stats.tx_dropped++;
234 ifp->stats.tx_packets++;
235 ifp->stats.tx_bytes += skb->len;
238 /* Return ok: we always eat the packet */
242 void brcmf_txflowblock(struct device *dev, bool state)
244 struct net_device *ndev;
245 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
246 struct brcmf_pub *drvr = bus_if->drvr;
249 brcmf_dbg(TRACE, "Enter\n");
251 for (i = 0; i < BRCMF_MAX_IFS; i++)
252 if (drvr->iflist[i]) {
253 ndev = drvr->iflist[i]->ndev;
255 netif_stop_queue(ndev);
257 netif_wake_queue(ndev);
261 void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list)
265 struct sk_buff *skb, *pnext;
266 struct brcmf_if *ifp;
267 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
268 struct brcmf_pub *drvr = bus_if->drvr;
272 brcmf_dbg(TRACE, "Enter\n");
274 skb_queue_walk_safe(skb_list, skb, pnext) {
275 skb_unlink(skb, skb_list);
277 /* process and remove protocol-specific header */
278 ret = brcmf_proto_hdrpull(drvr, &ifidx, skb);
279 ifp = drvr->iflist[ifidx];
281 if (ret || !ifp || !ifp->ndev) {
282 if ((ret != -ENODATA) && ifp)
283 ifp->stats.rx_errors++;
284 brcmu_pkt_buf_free_skb(skb);
288 /* Get the protocol, maintain skb around eth_type_trans()
289 * The main reason for this hack is for the limitation of
290 * Linux 2.4 where 'eth_type_trans' uses the
291 * 'net->hard_header_len'
292 * to perform skb_pull inside vs ETH_HLEN. Since to avoid
293 * coping of the packet coming from the network stack to add
294 * BDC, Hardware header etc, during network interface
296 * we set the 'net->hard_header_len' to ETH_HLEN + extra space
298 * for BDC, Hardware header etc. and not just the ETH_HLEN
303 skb->dev = ifp->ndev;
304 skb->protocol = eth_type_trans(skb, skb->dev);
306 if (skb->pkt_type == PACKET_MULTICAST)
307 ifp->stats.multicast++;
312 /* Strip header, count, deliver upward */
313 skb_pull(skb, ETH_HLEN);
315 /* Process special event packets and then discard them */
316 brcmf_fweh_process_skb(drvr, skb, &ifidx);
318 if (drvr->iflist[ifidx]) {
319 ifp = drvr->iflist[ifidx];
320 ifp->ndev->last_rx = jiffies;
323 if (!(ifp->ndev->flags & IFF_UP)) {
324 brcmu_pkt_buf_free_skb(skb);
328 ifp->stats.rx_bytes += skb->len;
329 ifp->stats.rx_packets++;
334 /* If the receive is not processed inside an ISR,
335 * the softirqd must be woken explicitly to service
336 * the NET_RX_SOFTIRQ. In 2.6 kernels, this is handled
337 * by netif_rx_ni(), but in earlier kernels, we need
344 void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success)
349 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
350 struct brcmf_pub *drvr = bus_if->drvr;
351 struct brcmf_if *ifp;
353 brcmf_proto_hdrpull(drvr, &ifidx, txp);
355 ifp = drvr->iflist[ifidx];
359 eh = (struct ethhdr *)(txp->data);
360 type = ntohs(eh->h_proto);
362 if (type == ETH_P_PAE) {
363 atomic_dec(&ifp->pend_8021x_cnt);
364 if (waitqueue_active(&ifp->pend_8021x_wait))
365 wake_up(&ifp->pend_8021x_wait);
368 ifp->stats.tx_errors++;
371 static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev)
373 struct brcmf_if *ifp = netdev_priv(ndev);
375 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
381 * Set current toe component enables in toe_ol iovar,
382 * and set toe global enable iovar
384 static int brcmf_toe_set(struct brcmf_if *ifp, u32 toe_ol)
388 err = brcmf_fil_iovar_int_set(ifp, "toe_ol", toe_ol);
390 brcmf_err("Setting toe_ol failed, %d\n", err);
394 err = brcmf_fil_iovar_int_set(ifp, "toe", (toe_ol != 0));
396 brcmf_err("Setting toe failed, %d\n", err);
402 static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
403 struct ethtool_drvinfo *info)
405 struct brcmf_if *ifp = netdev_priv(ndev);
406 struct brcmf_pub *drvr = ifp->drvr;
408 sprintf(info->driver, KBUILD_MODNAME);
409 sprintf(info->version, "%lu", drvr->drv_version);
410 sprintf(info->bus_info, "%s", dev_name(drvr->bus_if->dev));
413 static const struct ethtool_ops brcmf_ethtool_ops = {
414 .get_drvinfo = brcmf_ethtool_get_drvinfo,
417 static int brcmf_ethtool(struct brcmf_if *ifp, void __user *uaddr)
419 struct brcmf_pub *drvr = ifp->drvr;
420 struct ethtool_drvinfo info;
421 char drvname[sizeof(info.driver)];
423 struct ethtool_value edata;
424 u32 toe_cmpnt, csum_dir;
427 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
429 /* all ethtool calls start with a cmd word */
430 if (copy_from_user(&cmd, uaddr, sizeof(u32)))
434 case ETHTOOL_GDRVINFO:
435 /* Copy out any request driver name */
436 if (copy_from_user(&info, uaddr, sizeof(info)))
438 strncpy(drvname, info.driver, sizeof(info.driver));
439 drvname[sizeof(info.driver) - 1] = '\0';
441 /* clear struct for return */
442 memset(&info, 0, sizeof(info));
445 /* if requested, identify ourselves */
446 if (strcmp(drvname, "?dhd") == 0) {
447 sprintf(info.driver, "dhd");
448 strcpy(info.version, BRCMF_VERSION_STR);
450 /* report dongle driver type */
452 sprintf(info.driver, "wl");
454 sprintf(info.version, "%lu", drvr->drv_version);
455 if (copy_to_user(uaddr, &info, sizeof(info)))
457 brcmf_dbg(TRACE, "given %*s, returning %s\n",
458 (int)sizeof(drvname), drvname, info.driver);
461 /* Get toe offload components from dongle */
462 case ETHTOOL_GRXCSUM:
463 case ETHTOOL_GTXCSUM:
464 ret = brcmf_fil_iovar_int_get(ifp, "toe_ol", &toe_cmpnt);
469 (cmd == ETHTOOL_GTXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL;
472 edata.data = (toe_cmpnt & csum_dir) ? 1 : 0;
474 if (copy_to_user(uaddr, &edata, sizeof(edata)))
478 /* Set toe offload components in dongle */
479 case ETHTOOL_SRXCSUM:
480 case ETHTOOL_STXCSUM:
481 if (copy_from_user(&edata, uaddr, sizeof(edata)))
484 /* Read the current settings, update and write back */
485 ret = brcmf_fil_iovar_int_get(ifp, "toe_ol", &toe_cmpnt);
490 (cmd == ETHTOOL_STXCSUM) ? TOE_TX_CSUM_OL : TOE_RX_CSUM_OL;
493 toe_cmpnt |= csum_dir;
495 toe_cmpnt &= ~csum_dir;
497 ret = brcmf_toe_set(ifp, toe_cmpnt);
501 /* If setting TX checksum mode, tell Linux the new mode */
502 if (cmd == ETHTOOL_STXCSUM) {
504 ifp->ndev->features |= NETIF_F_IP_CSUM;
506 ifp->ndev->features &= ~NETIF_F_IP_CSUM;
518 static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr,
521 struct brcmf_if *ifp = netdev_priv(ndev);
522 struct brcmf_pub *drvr = ifp->drvr;
524 brcmf_dbg(TRACE, "Enter, bssidx=%d, cmd=0x%04x\n", ifp->idx, cmd);
526 if (!drvr->iflist[ifp->idx])
529 if (cmd == SIOCETHTOOL)
530 return brcmf_ethtool(ifp, ifr->ifr_data);
535 static int brcmf_netdev_stop(struct net_device *ndev)
537 struct brcmf_if *ifp = netdev_priv(ndev);
539 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
541 brcmf_cfg80211_down(ndev);
543 /* Set state and stop OS transmissions */
544 netif_stop_queue(ndev);
549 static int brcmf_netdev_open(struct net_device *ndev)
551 struct brcmf_if *ifp = netdev_priv(ndev);
552 struct brcmf_pub *drvr = ifp->drvr;
553 struct brcmf_bus *bus_if = drvr->bus_if;
557 brcmf_dbg(TRACE, "Enter, idx=%d\n", ifp->idx);
559 /* If bus is not ready, can't continue */
560 if (bus_if->state != BRCMF_BUS_DATA) {
561 brcmf_err("failed bus is not ready\n");
565 atomic_set(&ifp->pend_8021x_cnt, 0);
567 /* Get current TOE mode from dongle */
568 if (brcmf_fil_iovar_int_get(ifp, "toe_ol", &toe_ol) >= 0
569 && (toe_ol & TOE_TX_CSUM_OL) != 0)
570 ndev->features |= NETIF_F_IP_CSUM;
572 ndev->features &= ~NETIF_F_IP_CSUM;
574 /* Allow transmit calls */
575 netif_start_queue(ndev);
576 if (brcmf_cfg80211_up(ndev)) {
577 brcmf_err("failed to bring up cfg80211\n");
584 static const struct net_device_ops brcmf_netdev_ops_pri = {
585 .ndo_open = brcmf_netdev_open,
586 .ndo_stop = brcmf_netdev_stop,
587 .ndo_get_stats = brcmf_netdev_get_stats,
588 .ndo_do_ioctl = brcmf_netdev_ioctl_entry,
589 .ndo_start_xmit = brcmf_netdev_start_xmit,
590 .ndo_set_mac_address = brcmf_netdev_set_mac_address,
591 .ndo_set_rx_mode = brcmf_netdev_set_multicast_list
594 static const struct net_device_ops brcmf_netdev_ops_virt = {
595 .ndo_open = brcmf_cfg80211_up,
596 .ndo_stop = brcmf_cfg80211_down,
597 .ndo_get_stats = brcmf_netdev_get_stats,
598 .ndo_do_ioctl = brcmf_netdev_ioctl_entry,
599 .ndo_start_xmit = brcmf_netdev_start_xmit,
600 .ndo_set_mac_address = brcmf_netdev_set_mac_address,
601 .ndo_set_rx_mode = brcmf_netdev_set_multicast_list
604 int brcmf_net_attach(struct brcmf_if *ifp)
606 struct brcmf_pub *drvr = ifp->drvr;
607 struct net_device *ndev;
609 brcmf_dbg(TRACE, "Enter, idx=%d mac=%pM\n", ifp->idx,
613 /* set appropriate operations */
615 ndev->netdev_ops = &brcmf_netdev_ops_pri;
617 ndev->netdev_ops = &brcmf_netdev_ops_virt;
619 ndev->hard_header_len = ETH_HLEN + drvr->hdrlen;
620 ndev->ethtool_ops = &brcmf_ethtool_ops;
622 drvr->rxsz = ndev->mtu + ndev->hard_header_len +
625 /* set the mac address */
626 memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
628 if (register_netdev(ndev) != 0) {
629 brcmf_err("couldn't register the net device\n");
633 brcmf_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", ndev->name);
638 ndev->netdev_ops = NULL;
642 struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, int ifidx, s32 bssidx,
643 char *name, u8 *addr_mask)
645 struct brcmf_if *ifp;
646 struct net_device *ndev;
649 brcmf_dbg(TRACE, "Enter, bssidx=%d, ifidx=%d\n", bssidx, ifidx);
651 ifp = drvr->iflist[ifidx];
653 * Delete the existing interface before overwriting it
654 * in case we missed the BRCMF_E_IF_DEL event.
657 brcmf_err("ERROR: netdev:%s already exists\n",
660 netif_stop_queue(ifp->ndev);
661 unregister_netdev(ifp->ndev);
662 free_netdev(ifp->ndev);
663 drvr->iflist[ifidx] = NULL;
665 brcmf_err("ignore IF event\n");
666 return ERR_PTR(-EINVAL);
670 /* Allocate netdev, including space for private structure */
671 ndev = alloc_netdev(sizeof(struct brcmf_if), name, ether_setup);
673 brcmf_err("OOM - alloc_netdev\n");
674 return ERR_PTR(-ENOMEM);
677 ifp = netdev_priv(ndev);
680 drvr->iflist[ifidx] = ifp;
682 ifp->bssidx = bssidx;
684 INIT_WORK(&ifp->setmacaddr_work, _brcmf_set_mac_address);
685 INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list);
687 init_waitqueue_head(&ifp->pend_8021x_wait);
689 if (addr_mask != NULL)
690 for (i = 0; i < ETH_ALEN; i++)
691 ifp->mac_addr[i] = drvr->mac[i] ^ addr_mask[i];
693 brcmf_dbg(TRACE, " ==== pid:%x, if:%s (%pM) created ===\n",
694 current->pid, ifp->ndev->name, ifp->mac_addr);
699 void brcmf_del_if(struct brcmf_pub *drvr, int ifidx)
701 struct brcmf_if *ifp;
703 ifp = drvr->iflist[ifidx];
705 brcmf_err("Null interface, idx=%d\n", ifidx);
708 brcmf_dbg(TRACE, "Enter, idx=%d, bssidx=%d\n", ifidx, ifp->bssidx);
711 if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
713 brcmf_netdev_stop(ifp->ndev);
717 netif_stop_queue(ifp->ndev);
720 cancel_work_sync(&ifp->setmacaddr_work);
721 cancel_work_sync(&ifp->multicast_work);
723 unregister_netdev(ifp->ndev);
724 drvr->iflist[ifidx] = NULL;
726 brcmf_cfg80211_detach(drvr->config);
727 free_netdev(ifp->ndev);
731 int brcmf_attach(uint bus_hdrlen, struct device *dev)
733 struct brcmf_pub *drvr = NULL;
736 brcmf_dbg(TRACE, "Enter\n");
738 /* Allocate primary brcmf_info */
739 drvr = kzalloc(sizeof(struct brcmf_pub), GFP_ATOMIC);
743 mutex_init(&drvr->proto_block);
745 /* Link to bus module */
746 drvr->hdrlen = bus_hdrlen;
747 drvr->bus_if = dev_get_drvdata(dev);
748 drvr->bus_if->drvr = drvr;
750 /* create device debugfs folder */
751 brcmf_debugfs_attach(drvr);
753 /* Attach and link in the protocol */
754 ret = brcmf_proto_attach(drvr);
756 brcmf_err("brcmf_prot_attach failed\n");
760 /* attach firmware event handler */
761 brcmf_fweh_attach(drvr);
763 INIT_LIST_HEAD(&drvr->bus_if->dcmd_list);
773 int brcmf_bus_start(struct device *dev)
776 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
777 struct brcmf_pub *drvr = bus_if->drvr;
778 struct brcmf_if *ifp;
780 brcmf_dbg(TRACE, "\n");
782 /* Bring up the bus */
783 ret = brcmf_bus_init(bus_if);
785 brcmf_err("brcmf_sdbrcm_bus_init failed %d\n", ret);
789 /* add primary networking interface */
790 ifp = brcmf_add_if(drvr, 0, 0, "wlan%d", NULL);
794 /* signal bus ready */
795 bus_if->state = BRCMF_BUS_DATA;
797 /* Bus is ready, do any initialization */
798 ret = brcmf_c_preinit_dcmds(ifp);
802 drvr->config = brcmf_cfg80211_attach(drvr, bus_if->dev);
803 if (drvr->config == NULL) {
808 ret = brcmf_fweh_activate_events(ifp);
812 ret = brcmf_net_attach(ifp);
815 brcmf_err("failed: %d\n", ret);
817 brcmf_cfg80211_detach(drvr->config);
818 free_netdev(drvr->iflist[0]->ndev);
819 drvr->iflist[0] = NULL;
826 static void brcmf_bus_detach(struct brcmf_pub *drvr)
828 brcmf_dbg(TRACE, "Enter\n");
831 /* Stop the protocol module */
832 brcmf_proto_stop(drvr);
834 /* Stop the bus module */
835 brcmf_bus_stop(drvr->bus_if);
839 void brcmf_dev_reset(struct device *dev)
841 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
842 struct brcmf_pub *drvr = bus_if->drvr;
847 brcmf_fil_cmd_int_set(drvr->iflist[0], BRCMF_C_TERMINATED, 1);
850 void brcmf_detach(struct device *dev)
853 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
854 struct brcmf_pub *drvr = bus_if->drvr;
856 brcmf_dbg(TRACE, "Enter\n");
861 /* stop firmware event handling */
862 brcmf_fweh_detach(drvr);
864 /* make sure primary interface removed last */
865 for (i = BRCMF_MAX_IFS-1; i > -1; i--)
867 brcmf_del_if(drvr, i);
869 brcmf_bus_detach(drvr);
872 brcmf_proto_detach(drvr);
874 brcmf_debugfs_detach(drvr);
879 static int brcmf_get_pend_8021x_cnt(struct brcmf_if *ifp)
881 return atomic_read(&ifp->pend_8021x_cnt);
884 int brcmf_netdev_wait_pend8021x(struct net_device *ndev)
886 struct brcmf_if *ifp = netdev_priv(ndev);
889 err = wait_event_timeout(ifp->pend_8021x_wait,
890 !brcmf_get_pend_8021x_cnt(ifp),
891 msecs_to_jiffies(MAX_WAIT_FOR_8021X_TX));
899 * return chip id and rev of the device encoded in u32.
901 u32 brcmf_get_chip_info(struct brcmf_if *ifp)
903 struct brcmf_bus *bus = ifp->drvr->bus_if;
905 return bus->chip << 4 | bus->chiprev;
908 static void brcmf_driver_init(struct work_struct *work)
910 brcmf_debugfs_init();
912 #ifdef CONFIG_BRCMFMAC_SDIO
915 #ifdef CONFIG_BRCMFMAC_USB
919 static DECLARE_WORK(brcmf_driver_work, brcmf_driver_init);
921 static int __init brcmfmac_module_init(void)
923 if (!schedule_work(&brcmf_driver_work))
929 static void __exit brcmfmac_module_exit(void)
931 cancel_work_sync(&brcmf_driver_work);
933 #ifdef CONFIG_BRCMFMAC_SDIO
936 #ifdef CONFIG_BRCMFMAC_USB
939 brcmf_debugfs_exit();
942 module_init(brcmfmac_module_init);
943 module_exit(brcmfmac_module_exit);