Commit 96d51056 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

mac80211: defer master netdev allocation to ieee80211_register_hw

When we want to go multiqueue, we will need to know the number of
queues the hardware has for registering the master netdev. This
number is only available in ieee80211_register_hw() rather than
ieee80211_alloc_hw(), so defer allocation of the master device to
ieee80211_register_hw().
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 4688be30
...@@ -1375,9 +1375,7 @@ EXPORT_SYMBOL(ieee80211_tx_status); ...@@ -1375,9 +1375,7 @@ EXPORT_SYMBOL(ieee80211_tx_status);
struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
const struct ieee80211_ops *ops) const struct ieee80211_ops *ops)
{ {
struct net_device *mdev;
struct ieee80211_local *local; struct ieee80211_local *local;
struct ieee80211_sub_if_data *sdata;
int priv_size; int priv_size;
struct wiphy *wiphy; struct wiphy *wiphy;
...@@ -1423,22 +1421,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, ...@@ -1423,22 +1421,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
BUG_ON(!ops->configure_filter); BUG_ON(!ops->configure_filter);
local->ops = ops; local->ops = ops;
/* for now, mdev needs sub_if_data :/ */
mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
"wmaster%d", ether_setup);
if (!mdev) {
wiphy_free(wiphy);
return NULL;
}
sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
mdev->ieee80211_ptr = &sdata->wdev;
sdata->wdev.wiphy = wiphy;
local->hw.queues = 1; /* default */ local->hw.queues = 1; /* default */
local->mdev = mdev;
local->bridge_packets = 1; local->bridge_packets = 1;
local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
...@@ -1450,26 +1434,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, ...@@ -1450,26 +1434,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
INIT_LIST_HEAD(&local->interfaces); INIT_LIST_HEAD(&local->interfaces);
INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
ieee80211_rx_bss_list_init(mdev);
sta_info_init(local); sta_info_init(local);
mdev->hard_start_xmit = ieee80211_master_start_xmit;
mdev->open = ieee80211_master_open;
mdev->stop = ieee80211_master_stop;
mdev->type = ARPHRD_IEEE80211;
mdev->header_ops = &ieee80211_header_ops;
mdev->set_multicast_list = ieee80211_master_set_multicast_list;
sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = mdev;
sdata->local = local;
sdata->u.ap.force_unicast_rateidx = -1;
sdata->u.ap.max_ratectrl_rateidx = -1;
ieee80211_if_sdata_init(sdata);
/* no RCU needed since we're still during init phase */
list_add_tail(&sdata->list, &local->interfaces);
tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
(unsigned long)local); (unsigned long)local);
tasklet_disable(&local->tx_pending_tasklet); tasklet_disable(&local->tx_pending_tasklet);
...@@ -1492,6 +1459,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) ...@@ -1492,6 +1459,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
const char *name; const char *name;
int result; int result;
enum ieee80211_band band; enum ieee80211_band band;
struct net_device *mdev;
struct ieee80211_sub_if_data *sdata;
/* /*
* generic code guarantees at least one band, * generic code guarantees at least one band,
...@@ -1515,6 +1484,37 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) ...@@ -1515,6 +1484,37 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
if (result < 0) if (result < 0)
return result; return result;
/* for now, mdev needs sub_if_data :/ */
mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
"wmaster%d", ether_setup);
if (!mdev)
goto fail_mdev_alloc;
sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
mdev->ieee80211_ptr = &sdata->wdev;
sdata->wdev.wiphy = local->hw.wiphy;
local->mdev = mdev;
ieee80211_rx_bss_list_init(mdev);
mdev->hard_start_xmit = ieee80211_master_start_xmit;
mdev->open = ieee80211_master_open;
mdev->stop = ieee80211_master_stop;
mdev->type = ARPHRD_IEEE80211;
mdev->header_ops = &ieee80211_header_ops;
mdev->set_multicast_list = ieee80211_master_set_multicast_list;
sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = mdev;
sdata->local = local;
sdata->u.ap.force_unicast_rateidx = -1;
sdata->u.ap.max_ratectrl_rateidx = -1;
ieee80211_if_sdata_init(sdata);
/* no RCU needed since we're still during init phase */
list_add_tail(&sdata->list, &local->interfaces);
name = wiphy_dev(local->hw.wiphy)->driver->name; name = wiphy_dev(local->hw.wiphy)->driver->name;
local->hw.workqueue = create_singlethread_workqueue(name); local->hw.workqueue = create_singlethread_workqueue(name);
if (!local->hw.workqueue) { if (!local->hw.workqueue) {
...@@ -1606,6 +1606,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) ...@@ -1606,6 +1606,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
debugfs_hw_del(local); debugfs_hw_del(local);
destroy_workqueue(local->hw.workqueue); destroy_workqueue(local->hw.workqueue);
fail_workqueue: fail_workqueue:
ieee80211_if_free(local->mdev);
local->mdev = NULL;
fail_mdev_alloc:
wiphy_unregister(local->hw.wiphy); wiphy_unregister(local->hw.wiphy);
return result; return result;
} }
...@@ -1666,6 +1669,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) ...@@ -1666,6 +1669,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
wiphy_unregister(local->hw.wiphy); wiphy_unregister(local->hw.wiphy);
ieee80211_wep_free(local); ieee80211_wep_free(local);
ieee80211_led_exit(local); ieee80211_led_exit(local);
ieee80211_if_free(local->mdev);
local->mdev = NULL;
} }
EXPORT_SYMBOL(ieee80211_unregister_hw); EXPORT_SYMBOL(ieee80211_unregister_hw);
...@@ -1673,7 +1678,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw) ...@@ -1673,7 +1678,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
{ {
struct ieee80211_local *local = hw_to_local(hw); struct ieee80211_local *local = hw_to_local(hw);
ieee80211_if_free(local->mdev);
wiphy_free(local->hw.wiphy); wiphy_free(local->hw.wiphy);
} }
EXPORT_SYMBOL(ieee80211_free_hw); EXPORT_SYMBOL(ieee80211_free_hw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment