Skip to contentSkip to conversation

wireless: expose set-wiphy-name method to other modules.

PATCH Superseded [email protected] 1 participant 3 messages Sep 25, 2014 – Sep 26, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

---
 include/net/cfg80211.h | 6 ++++++
 net/wireless/core.c    | 9 +++++++++
 2 files changed, 15 insertions(+)
include/net/cfg80211.h +6 -0
index 3a13aab..68aabfa 100644
@@ -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
@@ -4869,6 +4874,7 @@ void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
 void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
 
 
+
 /* ethtool helper */
 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
 
net/wireless/core.c +9 -0
index f52a4cd..03e4715 100644
@@ -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
#1 lore raw

PATCH 2/2 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.

---

NOTE: This depends on the earlier patch that added the radio-name
attribute.

 drivers/net/wireless/mac80211_hwsim.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +13 -3
index b755920..2b54413 100644
@@ -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,12 @@ 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.
+		 */
+		cfg80211_dev_rename_wiphy(hw->wiphy, hwname);
+
 	wiphy_debug(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr);
 
 	if (reg_alpha2)
@@ -2508,10 +2514,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 +2539,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 +2771,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
author
#2 lore raw
In reply to [email protected]
Quoted 4 lines · On 09/25/2014 04:59 PM, [email protected] wrote:

From: Ben Greear <[email protected]>

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

This has an added whitespace that should not have been included, and next patch does not take rtnl before doing the rename.

Will test some more and re-send.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com