wireless: expose set-wiphy-name method to other modules.
PATCH v2 1/4 wireless: expose set-wiphy-name method to other modules.
From: Ben Greear <[email protected]>
This will let hw-sim create wiphy objects with a specific name.
---
v2: Fix checkpatch warnings (char * instead of char*)
include/net/cfg80211.h | 5 +++++ net/wireless/core.c | 9 +++++++++ 2 files changed, 14 insertions(+)
include/net/cfg80211.h +5 -0
@@ -4854,6 +4854,11 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,void cfg80211_stop_iface (struct wiphy *wiphy,struct wireless_dev *wdev,gfp_t gfp); +/* +* Attempt to rename a device. Acquire RTNL before calling. +*/ +int cfg80211_dev_rename_wiphy (struct wiphy *wiphy,char *newname); +/** * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy * @wiphy: the wiphy to shut down
net/wireless/core.c +9 -0
@@ -86,6 +86,15 @@ struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)return &rdev->wiphy; } +int cfg80211_dev_rename_wiphy (struct wiphy *wiphy,char *newname) +{ +struct cfg80211_registered_device *rdev; + + rdev =wiphy_to_rdev (wiphy); +return cfg80211_dev_rename (rdev, newname); +} +EXPORT_SYMBOL_GPL (cfg80211_dev_rename_wiphy); +int cfg80211_dev_rename (struct cfg80211_registered_device *rdev,char *newname) {
Signature · 1 line
1.7.11.7
PATCH v2 2/4 mac-sim: support creating radios with specific name.
From: Ben Greear <[email protected]>
Otherwise, it can be very difficult to know which is which if you are trying to do detailed testing.
---
v2: Add rtnl lock around rename logic.
drivers/net/wireless/mac80211_hwsim.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +16 -3
@@ -2018,7 +2018,7 @@ static struct ieee80211_ops mac80211_hwsim_mchan_ops;static int mac80211_hwsim_create_radio (int channels,const char *reg_alpha2,const struct ieee80211_regdomain *regd,bool reg_strict,bool p2p_device, -bool use_chanctx) +bool use_chanctx,char *hwname) {int err;u8 addr[ETH_ALEN ];
@@ -2230,6 +2230,15 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2, goto failed_hw; } +if (hwname) { +/* If this fails, continue on anyway, treat it as request +* instead of command. +*/ +rtnl_lock (); +cfg80211_dev_rename_wiphy (hw->wiphy, hwname); +rtnl_unlock (); + } +wiphy_debug (hw->wiphy,"hwaddr %pM registered\n" , hw->wiphy->perm_addr);if (reg_alpha2)
@@ -2508,10 +2517,14 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info)bool reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG ];bool p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE ];bool use_chanctx; +char *hwname =NULL ;if (info->attrs[HWSIM_ATTR_CHANNELS ]) chans =nla_get_u32 (info->attrs[HWSIM_ATTR_CHANNELS ]); +if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) + hwname =nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ]); +if (info->attrs[HWSIM_ATTR_USE_CHANCTX ]) use_chanctx = true;else
@@ -2529,7 +2542,7 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info) }return mac80211_hwsim_create_radio (chans, alpha2, regd, reg_strict, - p2p_device, use_chanctx); + p2p_device, use_chanctx, hwname); }static int hwsim_destroy_radio_nl (struct sk_buff *msg,struct genl_info *info)
@@ -2761,7 +2774,7 @@ static int __init init_mac80211_hwsim(void) err =mac80211_hwsim_create_radio (channels, reg_alpha2, regd, reg_strict, support_p2p_device, - channels >1 ); + channels >1 ,NULL );if (err <0 ) goto out_free_radios; }
Signature · 1 line
1.7.11.7
PATCH v2 3/4 wireless: support creating wiphy w/out creating wlanX.
In reply to [email protected]From: Ben Greear <[email protected]>
This will be helpful when using the mac80211_hwsim wiphys and automated testing. Let user create the wlan devs as needed, and named as expected.
---
v2: New to the series, more help with automation.
include/net/mac80211.h | 7 ++++++- net/mac80211/main.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-)
include/net/mac80211.h +6 -1
@@ -1576,6 +1576,10 @@ struct ieee80211_tx_control {* a virtual monitor interface when monitor interfaces are the only * active interfaces. * +* @IEEE80211_HW_NO_AUTO_VDEV: The driver would like for no wlanX to +* be created. It is expected user-space will create vdevs as +* desired (and thus have them named as desired). +* * @IEEE80211_HW_QUEUE_CONTROL: The driver wants to control per-interface * queue mapping in order to use different queues (not just one per AC) * for different virtual interfaces. See the doc section on HW queue
@@ -1622,7 +1626,8 @@ enum ieee80211_hw_flags {IEEE80211_HW_SUPPORTS_DYNAMIC_PS =1 <<12 ,IEEE80211_HW_MFP_CAPABLE =1 <<13 ,IEEE80211_HW_WANT_MONITOR_VIF =1 <<14 , -/* free slots */ +IEEE80211_HW_NO_AUTO_VDEV =1 <<15 , +/* free slot */ IEEE80211_HW_SUPPORTS_UAPSD =1 <<17 ,IEEE80211_HW_REPORTS_TX_ACK_STATUS =1 <<18 , IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
net/mac80211/main.c +2 -1
@@ -1019,7 +1019,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) }/* add one default STA interface if supported */ -if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_STATION )) { +if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_STATION ) && + !(hw->flags &IEEE80211_HW_NO_AUTO_VDEV )) { result =ieee80211_if_add (local,"wlan%d" ,NULL ,NL80211_IFTYPE_STATION ,NULL );if (result)
Signature · 1 line
1.7.11.7
PATCH v2 4/4 hwsim: support creating wiphy w/out creating wlanX.
In reply to [email protected]From: Ben Greear <[email protected]>
Good for automated testing, where user can create wlan interfaces with specified names.
---
v2: New to the series, more help with automation.
drivers/net/wireless/mac80211_hwsim.c | 15 ++++++++++++--- drivers/net/wireless/mac80211_hwsim.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +12 -3
@@ -2018,7 +2018,8 @@ static struct ieee80211_ops mac80211_hwsim_mchan_ops;static int mac80211_hwsim_create_radio (int channels,const char *reg_alpha2,const struct ieee80211_regdomain *regd,bool reg_strict,bool p2p_device, -bool use_chanctx,char *hwname) +bool use_chanctx,char *hwname, +bool no_vdev) {int err;u8 addr[ETH_ALEN ];
@@ -2223,6 +2224,9 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2,schedule_timeout_interruptible (1 ); } +if (no_vdev) + hw->flags |=IEEE80211_HW_NO_AUTO_VDEV ; + err =ieee80211_register_hw (hw);if (err <0 ) { printk(KERN_DEBUG "mac80211_hwsim: ieee80211_register_hw failed (%d)\n",
@@ -2517,11 +2521,15 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info)bool reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG ];bool p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE ];bool use_chanctx; +bool no_vdev = false;char *hwname =NULL ;if (info->attrs[HWSIM_ATTR_CHANNELS ]) chans =nla_get_u32 (info->attrs[HWSIM_ATTR_CHANNELS ]); +if (info->attrs[HWSIM_ATTR_NO_VDEV ]) + no_vdev = true; +if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) hwname =nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ]);
@@ -2542,7 +2550,8 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info) }return mac80211_hwsim_create_radio (chans, alpha2, regd, reg_strict, - p2p_device, use_chanctx, hwname); + p2p_device, use_chanctx, hwname, + no_vdev); }static int hwsim_destroy_radio_nl (struct sk_buff *msg,struct genl_info *info)
@@ -2774,7 +2783,7 @@ static int __init init_mac80211_hwsim(void) err =mac80211_hwsim_create_radio (channels, reg_alpha2, regd, reg_strict, support_p2p_device, - channels >1 ,NULL ); + channels >1 ,NULL , false);if (err <0 ) goto out_free_radios; }
drivers/net/wireless/mac80211_hwsim.h +2 -0
@@ -112,6 +112,7 @@ enum {* command to force use of channel contexts even when only a * single channel is supported * @HWSIM_ATTR_RADIO_NAME: Name of radio, ie phy666 +* @HWSIM_ATTR_NO_VDEV: Do not create vdev (wlanX) when creating radio. * @__HWSIM_ATTR_MAX: enum limit */
@@ -134,6 +135,7 @@ enum {HWSIM_ATTR_SUPPORT_P2P_DEVICE ,HWSIM_ATTR_USE_CHANCTX ,HWSIM_ATTR_RADIO_NAME , +HWSIM_ATTR_NO_VDEV , __HWSIM_ATTR_MAX, };#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
Signature · 1 line
1.7.11.7
Johannes Berg
maintainerRe: [PATCH v2 4/4] hwsim: support creating wiphy w/out creating wlanX.
You also really need to work on the subject prefixes...
They should be
1) cfg80211
2) mac80211-hwsim:
3) mac80211:
4) mac80211-hwsim:
johannes
Johannes Berg
maintainerQuoted 3 lines · On Fri, 2014-09-26 at 16:24 -0700, [email protected] wrote:
+/*
+ * Attempt to rename a device. Acquire RTNL before calling.
+ */
please add kernel-doc
Quoted 1 line
+int
cfg80211_dev_rename_wiphy(struct wiphy *wiphy, char *newname);
Should also be const char *
And should probably be called cfg80211_rename_wiphy() only? What's the dev doing there?
net/wireless/core.c struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx) · line 94
Quoted 7 lines
net/wireless/core.c +6
-0+int cfg80211_dev_rename_wiphy (struct wiphy *wiphy,char *newname) +{ +struct cfg80211_registered_device *rdev; + + rdev =wiphy_to_rdev (wiphy); +return cfg80211_dev_rename (rdev, newname);
You could just inlin ethe wiphy_to_rdev() and get rid of the variable.
Anyhow - if the intent is to do this at creation, why do you do it after the fact? Couldn't you just specify the name when creating it?
johannes
Quoted 24 lines · Johannes Berg
Quoted 3 lines · On Fri, 2014-09-26 at 16:24 -0700, [email protected] wrote:
+/*
+ * Attempt to rename a device. Acquire RTNL before calling.
+ */please add kernel-doc
Quoted 1 line
+int
cfg80211_dev_rename_wiphy(struct wiphy *wiphy, char *newname);Should also be const char *
And should probably be called
cfg80211_rename_wiphy()only? What's the dev doing there?net/wireless/core.c struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx) · line 94
Quoted 7 lines
net/wireless/core.c +6
-0+int cfg80211_dev_rename_wiphy (struct wiphy *wiphy,char *newname) +{ +struct cfg80211_registered_device *rdev; + + rdev =wiphy_to_rdev (wiphy); +return cfg80211_dev_rename (rdev, newname);You could just inlin ethe
wiphy_to_rdev()and get rid of the variable.
Quoted 2 lines
Anyhow - if the intent is to do this at creation, why do you do it after the fact? Couldn't you just specify the name when creating it?
That would be fine with me..I thought it might be more invasive and thus less welcome. I'll see what it takes to implement it like that when I get a chance. On the road this week, so might be a bit...
Thanks,
Ben
Quoted 3 lines
johannes
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com