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);
38 static const struct net_device_ops wil_netdev_ops = {
41 .ndo_start_xmit = wil_start_xmit,
42 .ndo_set_mac_address = eth_mac_addr,
43 .ndo_validate_addr = eth_validate_addr,
46 void *wil_if_alloc(struct device *dev, void __iomem *csr)
48 struct net_device *ndev;
49 struct wireless_dev *wdev;
50 struct wil6210_priv *wil;
51 struct ieee80211_channel *ch;
54 wdev = wil_cfg80211_init(dev);
56 dev_err(dev, "wil_cfg80211_init failed\n");
60 wil = wdev_to_wil(wdev);
64 rc = wil_priv_init(wil);
66 dev_err(dev, "wil_priv_init failed\n");
70 wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */
71 /* default monitor channel */
72 ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels;
73 cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT);
75 ndev = alloc_netdev(0, "wlan%d", ether_setup);
77 dev_err(dev, "alloc_netdev_mqs failed\n");
82 ndev->netdev_ops = &wil_netdev_ops;
83 ndev->ieee80211_ptr = wdev;
84 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
100 void wil_if_free(struct wil6210_priv *wil)
102 struct net_device *ndev = wil_to_ndev(wil);
107 wil_priv_deinit(wil);
111 int wil_if_add(struct wil6210_priv *wil)
113 struct net_device *ndev = wil_to_ndev(wil);
116 rc = register_netdev(ndev);
118 dev_err(&ndev->dev, "Failed to register netdev: %d\n", rc);
127 void wil_if_remove(struct wil6210_priv *wil)
129 struct net_device *ndev = wil_to_ndev(wil);
131 unregister_netdev(ndev);