Skip to contentSkip to conversation

Add nl80211 commands to get and set o11s mesh networking parameters.

PATCH Superseded [email protected] 3 participants 5 messages Oct 17, 2008 – Oct 20, 2008

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add nl80211 commands to get and set o11s mesh networking parameters.

The two new commands are NL80211_CMD_GET_MESH_PARAMS and NL80211_CMD_SET_MESH_PARAMS. There is a new attribute enum, NL80211_ATTR_MESH_PARAMS, which enumerates the various mesh configuration parameters.

Moved struct mesh_config from mac80211/ieee80211_i.h to net/cfg80211.h. nl80211_get_mesh_params and nl80211_set_mesh_params unpack the netlink messages and ask the driver to get or set the configuration. This is done via two new function stubs, get_mesh_params and set_mesh_params, in struct cfg80211_ops.

---
 include/linux/nl80211.h    |   86 ++++++++++++++++++++
 include/net/cfg80211.h     |   32 +++++++-
 net/mac80211/cfg.c         |   72 +++++++++++++++++
 net/mac80211/ieee80211_i.h |   21 +-----
 net/wireless/nl80211.c     |  187 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 377 insertions(+), 21 deletions(-)
include/linux/nl80211.h +86 -0
index 9bad654..40d7b27 100644
@@ -106,6 +106,12 @@
  * 	to the the specified ISO/IEC 3166-1 alpha2 country code. The core will
  * 	store this as a valid request and then query userspace for it.
  *
+ * @NL80211_CMD_GET_MESH_PARAMS: Get mesh networking properties for the
+ *	interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_PARAMS: Set mesh networking properties for the
+ *      interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -148,6 +154,9 @@ enum nl80211_commands {
 	NL80211_CMD_SET_REG,
 	NL80211_CMD_REQ_SET_REG,
 
+	NL80211_CMD_GET_MESH_PARAMS,
+	NL80211_CMD_SET_MESH_PARAMS,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -296,6 +305,8 @@ enum nl80211_attrs {
 	NL80211_ATTR_REG_ALPHA2,
 	NL80211_ATTR_REG_RULES,
 
+	NL80211_ATTR_MESH_PARAMS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -594,4 +605,79 @@ enum nl80211_mntr_flags {
 	NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
 };
 
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the inital confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically
+ * open peer links when we detect compatible mesh peers.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from the
+ * root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+	__NL80211_MESHCONF_INVALID,
+	NL80211_MESHCONF_RETRY_TIMEOUT,
+	NL80211_MESHCONF_CONFIRM_TIMEOUT,
+	NL80211_MESHCONF_HOLDING_TIMEOUT,
+	NL80211_MESHCONF_MAX_PEER_LINKS,
+	NL80211_MESHCONF_MAX_RETRIES,
+	NL80211_MESHCONF_TTL,
+	NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+	NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+	NL80211_MESHCONF_PATH_REFRESH_TIME,
+	NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+	NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+	NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+	NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+
+	/* keep last */
+	__NL80211_MESHCONF_ATTR_AFTER_LAST,
+	NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
 #endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +31 -1
index 0e85ec3..03e1e88 100644
@@ -347,6 +347,25 @@ struct ieee80211_regdomain {
 	.flags = reg_flags, \
 	}
 
+struct mesh_config {
+	/* Timeouts in ms */
+	/* Mesh plink management parameters */
+	u16 dot11MeshRetryTimeout;
+	u16 dot11MeshConfirmTimeout;
+	u16 dot11MeshHoldingTimeout;
+	u16 dot11MeshMaxPeerLinks;
+	u8  dot11MeshMaxRetries;
+	u8  dot11MeshTTL;
+	bool auto_open_plinks;
+	/* HWMP parameters */
+	u8  dot11MeshHWMPmaxPREQretries;
+	u32 path_refresh_time;
+	u16 min_discovery_timeout;
+	u32 dot11MeshHWMPactivePathTimeout;
+	u16 dot11MeshHWMPpreqMinInterval;
+	u16 dot11MeshHWMPnetDiameterTraversalTime;
+};
+
 /* from net/wireless.h */
 struct wiphy;
 
@@ -397,6 +416,12 @@ struct wiphy;
  *
  * @change_station: Modify a given station.
  *
+ * @get_mesh_params: Put the current mesh parameters into *params
+ *
+ * @set_mesh_params: Set mesh parameters.
+ *	The mask is a bitfield which tells us which parameters to
+ *	set, and which to leave alone.
+ *
  * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
  *
  * @change_bss: Modify parameters for a given BSS.
@@ -452,7 +477,12 @@ struct cfg80211_ops {
 	int	(*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
 			       int idx, u8 *dst, u8 *next_hop,
 			       struct mpath_info *pinfo);
-
+	int	(*get_mesh_params)(struct wiphy *wiphy,
+				struct net_device *dev,
+				struct mesh_config *conf);
+	int	(*set_mesh_params)(struct wiphy *wiphy,
+				struct net_device *dev,
+				const struct mesh_config *nconf, u32 mask);
 	int	(*change_bss)(struct wiphy *wiphy, struct net_device *dev,
 			      struct bss_parameters *params);
 };
net/mac80211/cfg.c +72 -0

84 lines not on this page · raw message

net/mac80211/ieee80211_i.h +1 -20
index 8198447..7a4a3c4 100644
@@ -23,6 +23,7 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <linux/etherdevice.h>
+#include <net/cfg80211.h>
 #include <net/wireless.h>
 #include <net/iw_handler.h>
 #include <net/mac80211.h>
@@ -255,26 +256,6 @@ struct mesh_preq_queue {
 	u8 flags;
 };
 
-struct mesh_config {
-	/* Timeouts in ms */
-	/* Mesh plink management parameters */
-	u16 dot11MeshRetryTimeout;
-	u16 dot11MeshConfirmTimeout;
-	u16 dot11MeshHoldingTimeout;
-	u16 dot11MeshMaxPeerLinks;
-	u8  dot11MeshMaxRetries;
-	u8  dot11MeshTTL;
-	bool auto_open_plinks;
-	/* HWMP parameters */
-	u8  dot11MeshHWMPmaxPREQretries;
-	u32 path_refresh_time;
-	u16 min_discovery_timeout;
-	u32 dot11MeshHWMPactivePathTimeout;
-	u16 dot11MeshHWMPpreqMinInterval;
-	u16 dot11MeshHWMPnetDiameterTraversalTime;
-};
-
-
 /* flags used in struct ieee80211_if_sta.flags */
 #define IEEE80211_STA_SSID_SET		BIT(0)
 #define IEEE80211_STA_BSSID_SET		BIT(1)
net/wireless/nl80211.c +187 -0

205 lines not on this page · raw message

Signature · 1 line
1.5.4.3
maintainer
#1 lore raw
Quoted 95 lines · On Thu, 2008-10-16 at 17:05 -0700, [email protected] wrote:

The two new commands are NL80211_CMD_GET_MESH_PARAMS and NL80211_CMD_SET_MESH_PARAMS. There is a new attribute enum, NL80211_ATTR_MESH_PARAMS, which enumerates the various mesh configuration parameters.

Moved struct mesh_config from mac80211/ieee80211_i.h to net/cfg80211.h. nl80211_get_mesh_params and nl80211_set_mesh_params unpack the netlink messages and ask the driver to get or set the configuration. This is done via two new function stubs, get_mesh_params and set_mesh_params, in struct cfg80211_ops.

---
 include/linux/nl80211.h    |   86 ++++++++++++++++++++
 include/net/cfg80211.h     |   32 +++++++-
 net/mac80211/cfg.c         |   72 +++++++++++++++++
 net/mac80211/ieee80211_i.h |   21 +-----
 net/wireless/nl80211.c     |  187 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 377 insertions(+), 21 deletions(-)
include/linux/nl80211.h +47 -0
index 9bad654..40d7b27 100644
@@ -106,6 +106,12 @@
  * 	to the the specified ISO/IEC 3166-1 alpha2 country code. The core will
  * 	store this as a valid request and then query userspace for it.
  *
+ * @NL80211_CMD_GET_MESH_PARAMS: Get mesh networking properties for the
+ *	interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_PARAMS: Set mesh networking properties for the
+ *      interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -148,6 +154,9 @@ enum nl80211_commands {
 	NL80211_CMD_SET_REG,
 	NL80211_CMD_REQ_SET_REG,
 
+	NL80211_CMD_GET_MESH_PARAMS,
+	NL80211_CMD_SET_MESH_PARAMS,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -296,6 +305,8 @@ enum nl80211_attrs {
 	NL80211_ATTR_REG_ALPHA2,
 	NL80211_ATTR_REG_RULES,
 
+	NL80211_ATTR_MESH_PARAMS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -594,4 +605,79 @@ enum nl80211_mntr_flags {
 	NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
 };
 
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the inital confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically
+ * open peer links when we detect compatible mesh peers.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *

include/linux/nl80211.h enum nl80211_mntr_flags { · line 653

Quoted 10 lines
include/linux/nl80211.h +10 -0
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from the
+ * root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element

Why are some in TU and some in ms? Are there any restrictions between these?

include/linux/nl80211.h enum nl80211_mntr_flags { · line 656

Quoted 2 lines
include/linux/nl80211.h +2 -0
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh

How does userspace know this one?

Quoted 8 lines
include/linux/nl80211.h +8 -0
+static int ieee80211_get_mesh_params(struct wiphy *wiphy,
+				struct net_device *dev,
+				struct mesh_config *conf)
+{
+	struct ieee80211_sub_if_data *sdata;
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+	if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)

include/linux/nl80211.h enum nl80211_mntr_flags { · line 673

Quoted 10 lines
include/linux/nl80211.h +10 -0
+		return -ENOTSUPP;
+	memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
+	return 0;
+}
+
+static inline bool _chg_mesh_attr(enum nl80211_attrs attr, u32 mask)
+{
+	/* This makes sure that there aren't more than 32 mesh config
+	 * parameters (otherwise our bitfield scheme would not work.) */
+	BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);

That BUILD_BUG_ON should be somewhere in cfg80211/nl80211 (core code) rather than mac80211 I think.

The attr parameter looks weird, are you sure it should be that enum and not the mesh config one?

include/linux/nl80211.h enum nl80211_mntr_flags { · line 674

Quoted 1 line
include/linux/nl80211.h +1 -0
+	return (mask >> (attr-1)) & 0x1;

I think

	return mask & (1<<(attr-1));

would be easier to understand.

include/linux/nl80211.h enum nl80211_mntr_flags {

Quoted 13 lines
include/linux/nl80211.h +11 -0
+#define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, attr_num, nla_fn) \
+do {\
+	if (table[attr_num]) {\
+		cfg.param = nla_fn(table[attr_num]); \
+	} \
+} while (0);\
 
 
+	/* Set the mask */
+	mask = 0;
+	for (i = 0; i < NL80211_MESHCONF_ATTR_MAX; ++i)
+		if (tb[i+1])
+			mask |= (1 << i);

I think it'd make more sense to set the mask in the macro too. That'd make it less error-prone when adding attributes (if that will ever happen).

For good measure, you could #undef the macro again at the end of the function. Maybe even declare it within the function, but I don't care much.

But this is all fairly minor stuff, looks good to me, thanks for doing this. Do you have a corresponding patch for iw?

johannes

#2 lore raw
Quoted 7 lines · On Saturday 18 October 2008 16:53:57 Johannes Berg wrote:

net/mac80211/cfg.c static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, · line 972

Quoted 1 line
net/mac80211/cfg.c +1 -0
+	return (mask >> (attr-1)) & 0x1;

I think

	return mask & (1<<(attr-1));

would be easier to understand.

I'm not sure if that would be correct.
The returned type is bool, which is 8bit. mask is 32bit. So if attr is > 8 you end up with truncation, AFAICS.

So it should be

	return !!(mask & (1<<(attr-1)));

to explicitely convert the mask into a boolean with the LSB indicating the state.

But the original contruct isn't that bad, either, IMO :)

Signature · 1 line
Greetings Michael.
maintainer
#3 lore raw
Quoted 10 lines · Michael Buesch
Quoted 7 lines · On Saturday 18 October 2008 16:53:57 Johannes Berg wrote:

net/mac80211/cfg.c static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, · line 972

Quoted 1 line
net/mac80211/cfg.c +1 -0
+	return (mask >> (attr-1)) & 0x1;

I think

	return mask & (1<<(attr-1));

would be easier to understand.

Quoted 7 lines

I'm not sure if that would be correct.
The returned type is bool, which is 8bit. mask is 32bit. So if attr is > 8 you end up with truncation, AFAICS.

So it should be

	return !!(mask & (1<<(attr-1)));

Indeed.

Quoted 4 lines

to explicitely convert the mask into a boolean with the LSB indicating the state.

But the original contruct isn't that bad, either, IMO :)

True :) I just had to think about it for a moment, but that's ok :)

johannes

#4 lore raw
In reply to Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 3 lines · On Thu, 2008-10-16 at 17:05 -0700, [email protected] wrote:

+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element

Why are some in TU and some in ms? Are there any restrictions between these?

All but two of these configuration parameters are specified in the draft 802.11s standard as MIB objects. I pretty much copied the descriptions directly from there.

A time units is 1024 microseconds. Since the different between a time unit and a millisecond is only 24 microseconds, all of the 80211s code that I've looked at simply treats these parameters as milliseconds. That is ok, because these parameters are timeouts and minimum intervals, rather than exact values.

Still, I wanted to use the same language to describe the parameters that the standard does.

Quoted 5 lines
Quoted 3 lines

+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh

How does userspace know this one?

The recommended value is 10 TUs. Increasing the value will increase the minimum timeout for PREQs.

One way to tune this parameter would be to analyze incoming network traffic at a mesh point, measuring the maximum time it takes to receive a PREQ from a mesh point. Then you would set this parameter to half of that value.
I haven't tried this in the lab, though.

Quoted 23 lines
Quoted 9 lines
net/mac80211/cfg.c +8 -0
+static int ieee80211_get_mesh_params(struct wiphy *wiphy,
+                             struct net_device *dev,
+                             struct mesh_config *conf)
+{
+     struct ieee80211_sub_if_data *sdata;
+     sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+     if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)

net/mac80211/cfg.c static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, · line 970

Quoted 10 lines
net/mac80211/cfg.c +10 -0
+             return -ENOTSUPP;
+     memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
+     return 0;
+}
+
+static inline bool _chg_mesh_attr(enum nl80211_attrs attr, u32 mask)
+{
+     /* This makes sure that there aren't more than 32 mesh config
+      * parameters (otherwise our bitfield scheme would not work.) */
+     BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);

That BUILD_BUG_ON should be somewhere in cfg80211/nl80211 (core code) rather than mac80211 I think.

Quoted 2 lines

The attr parameter looks weird, are you sure it should be that enum and not the mesh config one?

Fixed.

Quoted 3 lines

For good measure, you could #undef the macro again at the end of the function. Maybe even declare it within the function, but I don't care much.

Fixed.

Quoted 3 lines

But this is all fairly minor stuff, looks good to me, thanks for doing this. Do you have a corresponding patch for iw?

Yeah... I'll post it in just a bit.

Regards,
Colin McCabe

Quoted 3 lines

johannes