linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] wireless:  expose set-wiphy-name method to other modules.
@ 2014-09-26 23:24 greearb
  2014-09-26 23:24 ` [PATCH v2 2/4] mac-sim: support creating radios with specific name greearb
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: greearb @ 2014-09-26 23:24 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This will let hw-sim create wiphy objects with a specific
name.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v2:  Fix checkpatch warnings (char * instead of char*)

 include/net/cfg80211.h | 5 +++++
 net/wireless/core.c    | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3a13aab..e1641e6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -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
diff --git a/net/wireless/core.c b/net/wireless/core.c
index f52a4cd..4d7e17c 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -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)
 {
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/4] mac-sim:  support creating radios with specific name.
  2014-09-26 23:24 [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules greearb
@ 2014-09-26 23:24 ` greearb
  2014-09-26 23:24 ` [PATCH v2 3/4] wireless: support creating wiphy w/out creating wlanX greearb
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: greearb @ 2014-09-26 23:24 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

Otherwise, it can be very difficult to know which is which
if you are trying to do detailed testing.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v2:  Add rtnl lock around rename logic.

 drivers/net/wireless/mac80211_hwsim.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index b755920..e78c149 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -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;
 	}
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/4] wireless:  support creating wiphy w/out creating wlanX.
  2014-09-26 23:24 [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules greearb
  2014-09-26 23:24 ` [PATCH v2 2/4] mac-sim: support creating radios with specific name greearb
@ 2014-09-26 23:24 ` greearb
  2014-09-26 23:24 ` [PATCH v2 4/4] hwsim: " greearb
  2014-10-06 14:27 ` [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules Johannes Berg
  3 siblings, 0 replies; 7+ messages in thread
From: greearb @ 2014-09-26 23:24 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

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(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 0ad1f47..5c3dade2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -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,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 0de7c93..8106770 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -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)
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/4] hwsim:  support creating wiphy w/out creating wlanX.
  2014-09-26 23:24 [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules greearb
  2014-09-26 23:24 ` [PATCH v2 2/4] mac-sim: support creating radios with specific name greearb
  2014-09-26 23:24 ` [PATCH v2 3/4] wireless: support creating wiphy w/out creating wlanX greearb
@ 2014-09-26 23:24 ` greearb
  2014-10-06 14:28   ` Johannes Berg
  2014-10-06 14:27 ` [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules Johannes Berg
  3 siblings, 1 reply; 7+ messages in thread
From: greearb @ 2014-09-26 23:24 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

Good for automated testing, where user can create wlan
interfaces with specified names.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

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(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index e78c149..c803dd6 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -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;
 	}
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index 37c040b..6efd9f3 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -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)
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/4] wireless:  expose set-wiphy-name method to other modules.
  2014-09-26 23:24 [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules greearb
                   ` (2 preceding siblings ...)
  2014-09-26 23:24 ` [PATCH v2 4/4] hwsim: " greearb
@ 2014-10-06 14:27 ` Johannes Berg
  2014-10-06 18:26   ` Ben Greear
  3 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-10-06 14:27 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless

On Fri, 2014-09-26 at 16:24 -0700, greearb@candelatech.com wrote:

> +/*
> + * Attempt to rename a device.  Acquire RTNL before calling.
> + */

please add kernel-doc

> +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?
>  
> +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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 4/4] hwsim:  support creating wiphy w/out creating wlanX.
  2014-09-26 23:24 ` [PATCH v2 4/4] hwsim: " greearb
@ 2014-10-06 14:28   ` Johannes Berg
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2014-10-06 14:28 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless

You also really need to work on the subject prefixes...

They should be
1) cfg80211
2) mac80211-hwsim:
3) mac80211:
4) mac80211-hwsim:

johannes



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/4] wireless:  expose set-wiphy-name method to other modules.
  2014-10-06 14:27 ` [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules Johannes Berg
@ 2014-10-06 18:26   ` Ben Greear
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Greear @ 2014-10-06 18:26 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On 10/06/2014 07:27 AM, Johannes Berg wrote:
> On Fri, 2014-09-26 at 16:24 -0700, greearb@candelatech.com wrote:
>
>> +/*
>> + * Attempt to rename a device.  Acquire RTNL before calling.
>> + */
>
> please add kernel-doc
>
>> +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?
>>
>> +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?

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

>
> johannes
>


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-10-06 18:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-26 23:24 [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules greearb
2014-09-26 23:24 ` [PATCH v2 2/4] mac-sim: support creating radios with specific name greearb
2014-09-26 23:24 ` [PATCH v2 3/4] wireless: support creating wiphy w/out creating wlanX greearb
2014-09-26 23:24 ` [PATCH v2 4/4] hwsim: " greearb
2014-10-06 14:28   ` Johannes Berg
2014-10-06 14:27 ` [PATCH v2 1/4] wireless: expose set-wiphy-name method to other modules Johannes Berg
2014-10-06 18:26   ` Ben Greear

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).