2 * Copyright (c) 2012 Qualcomm Atheros, Inc.
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
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/module.h>
18 #include <linux/netdevice.h>
19 #include <linux/etherdevice.h>
20 #include <linux/slab.h>
24 static int wil_open(struct net_device *ndev)
26 struct wil6210_priv *wil = ndev_to_wil(ndev);
31 static int wil_stop(struct net_device *ndev)
33 struct wil6210_priv *wil = ndev_to_wil(ndev);
46 static u16 wil_select_queue(struct net_device *ndev, struct sk_buff *skb)
48 static const u16 wil_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
49 struct wil6210_priv *wil = ndev_to_wil(ndev);
52 skb->priority = cfg80211_classify8021d(skb);
54 rc = wil_1d_to_queue[skb->priority];
56 wil_dbg_TXRX(wil, "%s() %d -> %d\n", __func__, (int)skb->priority,
62 static const struct net_device_ops wil_netdev_ops = {
65 .ndo_start_xmit = wil_start_xmit,
66 .ndo_select_queue = wil_select_queue,
67 .ndo_set_mac_address = eth_mac_addr,
68 .ndo_validate_addr = eth_validate_addr,
71 void *wil_if_alloc(struct device *dev, void __iomem *csr)
73 struct net_device *ndev;
74 struct wireless_dev *wdev;
75 struct wil6210_priv *wil;
76 struct ieee80211_channel *ch;
79 wdev = wil_cfg80211_init(dev);
81 dev_err(dev, "wil_cfg80211_init failed\n");
85 wil = wdev_to_wil(wdev);
89 rc = wil_priv_init(wil);
91 dev_err(dev, "wil_priv_init failed\n");
95 wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */
96 /* default monitor channel */
97 ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels;
98 cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT);
100 ndev = alloc_netdev_mqs(0, "wlan%d", ether_setup, WIL6210_TX_QUEUES, 1);
102 dev_err(dev, "alloc_netdev_mqs failed\n");
107 ndev->netdev_ops = &wil_netdev_ops;
108 ndev->ieee80211_ptr = wdev;
109 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
117 wil_priv_deinit(wil);
125 void wil_if_free(struct wil6210_priv *wil)
127 struct net_device *ndev = wil_to_ndev(wil);
132 wil_priv_deinit(wil);
136 int wil_if_add(struct wil6210_priv *wil)
138 struct net_device *ndev = wil_to_ndev(wil);
141 rc = register_netdev(ndev);
143 dev_err(&ndev->dev, "Failed to register netdev: %d\n", rc);
152 void wil_if_remove(struct wil6210_priv *wil)
154 struct net_device *ndev = wil_to_ndev(wil);
156 unregister_netdev(ndev);