Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8c9bd5b authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

cfg80211: clarify set_channel APIs



Now that we've removed all uses of the set_channel
API except for the monitor channel and in libertas,
clarify this. Split the libertas mesh use into a
new libertas_set_mesh_channel() operation, just to
keep backward compatibility, and rename the normal
set_channel() to set_monitor_channel().

Also describe the desired set_monitor_channel()
semantics more clearly.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7c9c46c1
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -435,23 +435,19 @@ static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len)
 * Set Channel
 */

static int lbs_cfg_set_channel(struct wiphy *wiphy,
	struct net_device *netdev,
static int lbs_cfg_set_monitor_channel(struct wiphy *wiphy,
				       struct ieee80211_channel *channel,
				       enum nl80211_channel_type channel_type)
{
	struct lbs_private *priv = wiphy_priv(wiphy);
	int ret = -ENOTSUPP;

	lbs_deb_enter_args(LBS_DEB_CFG80211, "iface %s freq %d, type %d",
			   netdev_name(netdev), channel->center_freq, channel_type);
	lbs_deb_enter_args(LBS_DEB_CFG80211, "freq %d, type %d",
			   channel->center_freq, channel_type);

	if (channel_type != NL80211_CHAN_NO_HT)
		goto out;

	if (netdev == priv->mesh_dev)
		ret = lbs_mesh_set_channel(priv, channel->hw_value);
	else
	ret = lbs_set_channel(priv, channel->hw_value);

 out:
@@ -459,6 +455,26 @@ static int lbs_cfg_set_channel(struct wiphy *wiphy,
	return ret;
}

static int lbs_cfg_set_mesh_channel(struct wiphy *wiphy,
				    struct net_device *netdev,
				    struct ieee80211_channel *channel)
{
	struct lbs_private *priv = wiphy_priv(wiphy);
	int ret = -ENOTSUPP;

	lbs_deb_enter_args(LBS_DEB_CFG80211, "iface %s freq %d",
			   netdev_name(netdev), channel->center_freq);

	if (netdev != priv->mesh_dev)
		goto out;

	ret = lbs_mesh_set_channel(priv, channel->hw_value);

 out:
	lbs_deb_leave_args(LBS_DEB_CFG80211, "ret %d", ret);
	return ret;
}



/*
@@ -2029,7 +2045,8 @@ static int lbs_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
 */

static struct cfg80211_ops lbs_cfg80211_ops = {
	.set_channel = lbs_cfg_set_channel,
	.set_monitor_channel = lbs_cfg_set_monitor_channel,
	.libertas_set_mesh_channel = lbs_cfg_set_mesh_channel,
	.scan = lbs_cfg_scan,
	.connect = lbs_cfg_connect,
	.disconnect = lbs_cfg_disconnect,
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ struct lbs_private {
	uint16_t mesh_tlv;
	u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
	u8 mesh_ssid_len;
	u8 mesh_channel;
#endif

	/* Debugfs */
+2 −5
Original line number Diff line number Diff line
@@ -131,16 +131,13 @@ static int lbs_mesh_config(struct lbs_private *priv, uint16_t action,

int lbs_mesh_set_channel(struct lbs_private *priv, u8 channel)
{
	priv->mesh_channel = channel;
	return lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, channel);
}

static uint16_t lbs_mesh_get_channel(struct lbs_private *priv)
{
	struct wireless_dev *mesh_wdev = priv->mesh_dev->ieee80211_ptr;
	if (mesh_wdev->channel)
		return mesh_wdev->channel->hw_value;
	else
		return 1;
	return priv->mesh_channel ?: 1;
}

/***************************************************************************
+4 −5
Original line number Diff line number Diff line
@@ -160,8 +160,7 @@ static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev,
	return err;
}

static int orinoco_set_channel(struct wiphy *wiphy,
			struct net_device *netdev,
static int orinoco_set_monitor_channel(struct wiphy *wiphy,
				       struct ieee80211_channel *chan,
				       enum nl80211_channel_type channel_type)
{
@@ -286,7 +285,7 @@ static int orinoco_set_wiphy_params(struct wiphy *wiphy, u32 changed)

const struct cfg80211_ops orinoco_cfg_ops = {
	.change_virtual_intf = orinoco_change_vif,
	.set_channel = orinoco_set_channel,
	.set_monitor_channel = orinoco_set_monitor_channel,
	.scan = orinoco_scan,
	.set_wiphy_params = orinoco_set_wiphy_params,
};
+15 −9
Original line number Diff line number Diff line
@@ -1420,11 +1420,14 @@ struct cfg80211_gtk_rekey_data {
 *
 * @set_txq_params: Set TX queue parameters
 *
 * @set_channel: Set channel for a given wireless interface. Some devices
 *	may support multi-channel operation (by channel hopping) so cfg80211
 *	doesn't verify much. Note, however, that the passed netdev may be
 *	%NULL as well if the user requested changing the channel for the
 *	device itself, or for a monitor interface.
 * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
 *	as it doesn't implement join_mesh and needs to set the channel to
 *	join the mesh instead.
 *
 * @set_monitor_channel: Set the monitor mode channel for the device. If other
 *	interfaces are active this callback should reject the configuration.
 *	If no interfaces are active or the device is down, the channel should
 *	be stored for when a monitor interface becomes active.
 * @get_channel: Get the current operating channel, should return %NULL if
 *	there's no single defined operating channel if for example the
 *	device implements channel hopping for multi-channel virtual interfaces.
@@ -1614,7 +1617,11 @@ struct cfg80211_ops {
	int	(*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
				  struct ieee80211_txq_params *params);

	int	(*set_channel)(struct wiphy *wiphy, struct net_device *dev,
	int	(*libertas_set_mesh_channel)(struct wiphy *wiphy,
					     struct net_device *dev,
					     struct ieee80211_channel *chan);

	int	(*set_monitor_channel)(struct wiphy *wiphy,
				       struct ieee80211_channel *chan,
				       enum nl80211_channel_type channel_type);

@@ -2325,7 +2332,6 @@ struct wireless_dev {
	spinlock_t event_lock;

	struct cfg80211_internal_bss *current_bss; /* associated / joined */
	struct ieee80211_channel *channel;
	struct ieee80211_channel *preset_chan;
	enum nl80211_channel_type preset_chantype;

Loading