summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/wil6210/netdev.c
diff options
context:
space:
mode:
authorLior David <liord@codeaurora.org>2018-02-26 20:12:11 +0200
committerKalle Valo <kvalo@codeaurora.org>2018-02-27 18:50:04 +0200
commit9f38f28624555af82a2909c9716688367d7297b1 (patch)
tree4e7bff528883ea923fbb28dcf821abc283eefc54 /drivers/net/wireless/ath/wil6210/netdev.c
parent9bfd05e35ac3519c26ffa0bfb1ab8933c8f00c74 (diff)
downloadtalos-op-linux-9f38f28624555af82a2909c9716688367d7297b1.tar.gz
talos-op-linux-9f38f28624555af82a2909c9716688367d7297b1.zip
wil6210: add wil6210_vif structure for per-VIF data
For supporting multiple virtual interfaces in the future, introduce a wil6210_vif structure which will hold per-VIF data. Change the module initialization so wil6210_vif will be part of net_device structure, and wireless_dev will be embedded inside the wil6210_vif structure. This will allow us to find the appropriate wil6210_vif structure when we only have access to wireless_dev or net_device. Signed-off-by: Lior David <liord@codeaurora.org> Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/ath/wil6210/netdev.c')
-rw-r--r--drivers/net/wireless/ath/wil6210/netdev.c93
1 files changed, 58 insertions, 35 deletions
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index 7ba4e0af8f57..648f63682f59 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -121,63 +122,85 @@ static void wil_dev_setup(struct net_device *dev)
dev->tx_queue_len = WIL_TX_Q_LEN_DEFAULT;
}
-void *wil_if_alloc(struct device *dev)
+struct wil6210_vif *
+wil_vif_alloc(struct wil6210_priv *wil, const char *name,
+ unsigned char name_assign_type, enum nl80211_iftype iftype,
+ u8 mid)
{
struct net_device *ndev;
struct wireless_dev *wdev;
+ struct wil6210_vif *vif;
+
+ ndev = alloc_netdev(sizeof(*vif), name, name_assign_type,
+ wil_dev_setup);
+ if (!ndev) {
+ dev_err(wil_to_dev(wil), "alloc_netdev failed\n");
+ return ERR_PTR(-ENOMEM);
+ }
+ if (mid == 0)
+ wil->ndev = ndev;
+ vif = ndev_to_vif(ndev);
+ vif->wil = wil;
+ vif->mid = mid;
+
+ wdev = &vif->wdev;
+ wdev->wiphy = wil->wiphy;
+ wdev->iftype = iftype;
+
+ ndev->netdev_ops = &wil_netdev_ops;
+ wil_set_ethtoolops(ndev);
+ ndev->ieee80211_ptr = wdev;
+ ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
+ NETIF_F_SG | NETIF_F_GRO |
+ NETIF_F_TSO | NETIF_F_TSO6 |
+ NETIF_F_RXHASH;
+
+ ndev->features |= ndev->hw_features;
+ SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
+ wdev->netdev = ndev;
+ return vif;
+}
+
+void *wil_if_alloc(struct device *dev)
+{
+ struct wireless_dev *wdev;
struct wil6210_priv *wil;
- struct ieee80211_channel *ch;
+ struct wil6210_vif *vif;
int rc = 0;
- wdev = wil_cfg80211_init(dev);
- if (IS_ERR(wdev)) {
+ wil = wil_cfg80211_init(dev);
+ if (IS_ERR(wil)) {
dev_err(dev, "wil_cfg80211_init failed\n");
- return wdev;
+ return wil;
}
- wil = wdev_to_wil(wdev);
- wil->wdev = wdev;
- wil->radio_wdev = wdev;
-
- wil_dbg_misc(wil, "if_alloc\n");
-
rc = wil_priv_init(wil);
if (rc) {
dev_err(dev, "wil_priv_init failed\n");
- goto out_wdev;
+ goto out_cfg;
}
- wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */
- /* default monitor channel */
- ch = wdev->wiphy->bands[NL80211_BAND_60GHZ]->channels;
- cfg80211_chandef_create(&wil->monitor_chandef, ch, NL80211_CHAN_NO_HT);
+ wil_dbg_misc(wil, "if_alloc\n");
- ndev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, wil_dev_setup);
- if (!ndev) {
- dev_err(dev, "alloc_netdev_mqs failed\n");
+ vif = wil_vif_alloc(wil, "wlan%d", NET_NAME_UNKNOWN,
+ NL80211_IFTYPE_STATION, 0);
+ if (IS_ERR(vif)) {
+ dev_err(dev, "wil_vif_alloc failed\n");
rc = -ENOMEM;
goto out_priv;
}
- ndev->netdev_ops = &wil_netdev_ops;
- wil_set_ethtoolops(ndev);
- ndev->ieee80211_ptr = wdev;
- ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
- NETIF_F_SG | NETIF_F_GRO |
- NETIF_F_TSO | NETIF_F_TSO6 |
- NETIF_F_RXHASH;
-
- ndev->features |= ndev->hw_features;
- SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
- wdev->netdev = ndev;
+ wdev = &vif->wdev;
+ wil->wdev = wdev;
+ wil->radio_wdev = wdev;
return wil;
- out_priv:
+out_priv:
wil_priv_deinit(wil);
- out_wdev:
- wil_wdev_free(wil);
+out_cfg:
+ wil_cfg80211_deinit(wil);
return ERR_PTR(rc);
}
@@ -196,13 +219,13 @@ void wil_if_free(struct wil6210_priv *wil)
wil_to_ndev(wil) = NULL;
free_netdev(ndev);
- wil_wdev_free(wil);
+ wil_cfg80211_deinit(wil);
}
int wil_if_add(struct wil6210_priv *wil)
{
struct wireless_dev *wdev = wil_to_wdev(wil);
- struct wiphy *wiphy = wdev->wiphy;
+ struct wiphy *wiphy = wil->wiphy;
struct net_device *ndev = wil_to_ndev(wil);
int rc;
OpenPOWER on IntegriCloud