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

Commit c80d545d authored by Javier Cardona's avatar Javier Cardona Committed by John W. Linville
Browse files

mac80211: Let userspace enable and configure vendor specific path selection.



Userspace will now be allowed to toggle between the default path
selection algorithm (HWMP, implemented in the kernel), and a vendor
specific alternative.  Also in the same patch, allow userspace to add
information elements to mesh beacons.  This is accordance with the
Extensible Path Selection Framework specified in version 7.0 of the
802.11s draft.

Signed-off-by: default avatarJavier Cardona <javier@cozybit.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 24bdd9f4
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,31 @@ enum ieee80211_key_len {
	WLAN_KEY_LEN_AES_CMAC = 16,
};

/**
 * enum - mesh path selection protocol identifier
 *
 * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
 * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
 * be specified in a vendor specific information element
 */
enum {
	IEEE80211_PATH_PROTOCOL_HWMP = 0,
	IEEE80211_PATH_PROTOCOL_VENDOR = 255,
};

/**
 * enum - mesh path selection metric identifier
 *
 * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
 * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
 * specified in a vendor specific information element
 */
enum {
	IEEE80211_PATH_METRIC_AIRTIME = 0,
	IEEE80211_PATH_METRIC_VENDOR = 255,
};


/*
 * IEEE 802.11-2007 7.3.2.9 Country information element
 *
+43 −4
Original line number Diff line number Diff line
@@ -872,6 +872,9 @@ enum nl80211_commands {
 *	attributes, specifying what a key should be set as default as.
 *	See &enum nl80211_key_default_types.
 *
 * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters.  These cannot be
 * changed once the mesh is active.
 *
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @__NL80211_ATTR_AFTER_LAST: internal use
 */
@@ -1054,6 +1057,8 @@ enum nl80211_attrs {

	NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,

	NL80211_ATTR_MESH_SETUP,

	/* add attributes here, update the policy in nl80211.c */

	__NL80211_ATTR_AFTER_LAST,
@@ -1564,7 +1569,8 @@ enum nl80211_mntr_flags {
/**
 * enum nl80211_meshconf_params - mesh configuration parameters
 *
 * Mesh configuration parameters
 * Mesh configuration parameters. These can be changed while the mesh is
 * active.
 *
 * @__NL80211_MESHCONF_INVALID: internal use
 *
@@ -1587,9 +1593,6 @@ enum nl80211_mntr_flags {
 * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
 * point.
 *
 * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
 * source mesh point for path selection elements.
 *
 * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically
 * open peer links when we detect compatible mesh peers.
 *
@@ -1616,6 +1619,9 @@ enum nl80211_mntr_flags {
 *
 * @NL80211_MESHCONF_ROOTMODE: whether root mode is enabled or not
 *
 * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
 * source mesh point for path selection elements.
 *
 * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
 *
 * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
@@ -1643,6 +1649,39 @@ enum nl80211_meshconf_params {
	NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
};

/**
 * enum nl80211_mesh_setup_params - mesh setup parameters
 *
 * Mesh setup parameters.  These are used to start/join a mesh and cannot be
 * changed while the mesh is active.
 *
 * @__NL80211_MESH_SETUP_INVALID: Internal use
 *
 * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
 * vendor specific path selection algorithm or disable it to use the default
 * HWMP.
 *
 * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
 * vendor specific path metric or disable it to use the default Airtime
 * metric.
 *
 * @NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE: A vendor specific information
 * element that vendors will use to identify the path selection methods and
 * metrics in use.
 *
 * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
 */
enum nl80211_mesh_setup_params {
	__NL80211_MESH_SETUP_INVALID,
	NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
	NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
	NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE,

	/* keep last */
	__NL80211_MESH_SETUP_ATTR_AFTER_LAST,
	NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
};

/**
 * enum nl80211_txq_attr - TX queue parameter attributes
 * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+8 −0
Original line number Diff line number Diff line
@@ -649,12 +649,20 @@ struct mesh_config {
 * struct mesh_setup - 802.11s mesh setup configuration
 * @mesh_id: the mesh ID
 * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
 * @path_sel_proto: which path selection protocol to use
 * @path_metric: which metric to use
 * @vendor_ie: vendor information elements (optional)
 * @vendor_ie_len: length of vendor information elements
 *
 * These parameters are fixed when the mesh is created.
 */
struct mesh_setup {
	const u8 *mesh_id;
	u8 mesh_id_len;
	u8  path_sel_proto;
	u8  path_metric;
	const u8 *vendor_ie;
	u8 vendor_ie_len;
};

/**
+35 −4
Original line number Diff line number Diff line
@@ -1000,6 +1000,36 @@ static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
	return (mask >> (parm-1)) & 0x1;
}

static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
		const struct mesh_setup *setup)
{
	u8 *new_ie;
	const u8 *old_ie;

	/* first allocate the new vendor information element */
	new_ie = NULL;
	old_ie = ifmsh->vendor_ie;

	ifmsh->vendor_ie_len = setup->vendor_ie_len;
	if (setup->vendor_ie_len) {
		new_ie = kmemdup(setup->vendor_ie, setup->vendor_ie_len,
				GFP_KERNEL);
		if (!new_ie)
			return -ENOMEM;
	}

	/* now copy the rest of the setup parameters */
	ifmsh->mesh_id_len = setup->mesh_id_len;
	memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
	ifmsh->mesh_pp_id = setup->path_sel_proto;
	ifmsh->mesh_pm_id = setup->path_metric;
	ifmsh->vendor_ie = new_ie;

	kfree(old_ie);

	return 0;
}

static int ieee80211_update_mesh_config(struct wiphy *wiphy,
					struct net_device *dev, u32 mask,
					const struct mesh_config *nconf)
@@ -1059,11 +1089,12 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	int err;

	memcpy(&sdata->u.mesh.mshcfg, conf, sizeof(struct mesh_config));
	ifmsh->mesh_id_len = setup->mesh_id_len;
	memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);

	memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
	err = copy_mesh_setup(ifmsh, setup);
	if (err)
		return err;
	ieee80211_start_mesh(sdata);

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -484,6 +484,8 @@ struct ieee80211_if_mesh {
	struct mesh_config mshcfg;
	u32 mesh_seqnum;
	bool accepting_plinks;
	const u8 *vendor_ie;
	u8 vendor_ie_len;
};

#ifdef CONFIG_MAC80211_MESH
@@ -585,9 +587,7 @@ struct ieee80211_sub_if_data {
		struct ieee80211_if_vlan vlan;
		struct ieee80211_if_managed mgd;
		struct ieee80211_if_ibss ibss;
#ifdef CONFIG_MAC80211_MESH
		struct ieee80211_if_mesh mesh;
#endif
		u32 mntr_flags;
	} u;

Loading