All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] iw: Allow user to provide freq during mesh join
@ 2014-09-20  6:40 Chun-Yeow Yeoh
  2014-09-20  6:40 ` [PATCH v3 2/2] iw: Allow basic rates to be configured when joining mesh Chun-Yeow Yeoh
  2014-09-22 11:00 ` [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Bob Copeland
  0 siblings, 2 replies; 4+ messages in thread
From: Chun-Yeow Yeoh @ 2014-09-20  6:40 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, devel, Chun-Yeow Yeoh, Ashok Nagarajan

Allow user to configure frequency and channel type during
mesh join command.

Signed-off-by: Ashok Nagarajan <ashok.dragon@gmail.com>
Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

v2: use chandef similar to IBSS (Johannes)
---
 mesh.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 67 insertions(+), 3 deletions(-)

diff --git a/mesh.c b/mesh.c
index ca065bf..69c54cc 100644
--- a/mesh.c
+++ b/mesh.c
@@ -438,8 +438,32 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
 {
 	struct nlattr *container;
 	float rate;
-	int bintval, dtim_period;
+	int bintval, dtim_period, i;
 	char *end;
+	unsigned long freq = 0;
+	static const struct {
+		const char *name;
+		unsigned int width;
+		int freq1_diff;
+		int chantype; /* for older kernel */
+	} *chanmode_selected = NULL, chanmode[] = {
+		{ .name = "HT20",
+		  .width = NL80211_CHAN_WIDTH_20,
+		  .freq1_diff = 0,
+		  .chantype = NL80211_CHAN_HT20 },
+		{ .name = "HT40+",
+		  .width = NL80211_CHAN_WIDTH_40,
+		  .freq1_diff = 10,
+		  .chantype = NL80211_CHAN_HT40PLUS },
+		{ .name = "HT40-",
+		  .width = NL80211_CHAN_WIDTH_40,
+		  .freq1_diff = -10,
+		  .chantype = NL80211_CHAN_HT40MINUS },
+		{ .name = "NOHT",
+		  .width = NL80211_CHAN_WIDTH_20_NOHT,
+		  .freq1_diff = 0,
+		  .chantype = NL80211_CHAN_NO_HT },
+	};
 
 	if (argc < 1)
 		return 1;
@@ -448,6 +472,44 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
 	argc--;
 	argv++;
 
+	/* freq */
+	if (argc > 1 && strcmp(argv[0], "freq") == 0) {
+		argv++;
+		argc--;
+
+		freq = strtoul(argv[0], &end, 10);
+		if (*end != '\0')
+			return 1;
+		NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+
+		argv++;
+		argc--;
+	}
+
+	/* channel type */
+	if (argc) {
+		for (i = 0; i < ARRAY_SIZE(chanmode); i++) {
+			if (strcasecmp(chanmode[i].name, argv[0]) == 0) {
+				chanmode_selected = &chanmode[i];
+				break;
+			}
+		}
+
+		if (chanmode_selected) {
+			NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
+				    chanmode_selected->width);
+			NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
+				    freq + chanmode_selected->freq1_diff);
+			if (chanmode_selected->chantype != -1)
+				NLA_PUT_U32(msg,
+					    NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+					    chanmode_selected->chantype);
+
+			argv++;
+			argc--;
+		}
+	}
+
 	if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
 		argv++;
 		argc--;
@@ -513,11 +575,13 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
  nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(mesh, join, "<mesh ID> [mcast-rate <rate in Mbps>]"
+COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"
+	" [mcast-rate <rate in Mbps>]"
 	" [beacon-interval <time in TUs>] [dtim-period <value>]"
 	" [vendor_sync on|off] [<param>=<value>]*",
 	NL80211_CMD_JOIN_MESH, 0, CIB_NETDEV, join_mesh,
-	"Join a mesh with the given mesh ID with mcast-rate and mesh parameters.");
+	"Join a mesh with the given mesh ID with frequency, mcast-rate, "
+	"and mesh parameters.");
 
 static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
 		      struct nl_msg *msg, int argc, char **argv,
-- 
1.9.2


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

* [PATCH v3 2/2] iw: Allow basic rates to be configured when joining mesh
  2014-09-20  6:40 [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Chun-Yeow Yeoh
@ 2014-09-20  6:40 ` Chun-Yeow Yeoh
  2014-09-22 11:00 ` [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Bob Copeland
  1 sibling, 0 replies; 4+ messages in thread
From: Chun-Yeow Yeoh @ 2014-09-20  6:40 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, devel, Chun-Yeow Yeoh, Ashok Nagarajan

This patch adds option to configure basic rates during mesh join.

Signed-off-by: Ashok Nagarajan <ashok.dragon@gmail.com>
Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

v2: minor change for upstream
v3: fix typo error (Colleen)
---
 mesh.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/mesh.c b/mesh.c
index 69c54cc..23cba2e 100644
--- a/mesh.c
+++ b/mesh.c
@@ -438,8 +438,9 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
 {
 	struct nlattr *container;
 	float rate;
-	int bintval, dtim_period, i;
-	char *end;
+	unsigned char rates[NL80211_MAX_SUPP_RATES];
+	int bintval, dtim_period, i, n_rates = 0;
+	char *end, *value = NULL, *sptr = NULL;
 	unsigned long freq = 0;
 	static const struct {
 		const char *name;
@@ -510,6 +511,32 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
 		}
 	}
 
+	/* basic rates */
+	if (argc > 1 && strcmp(argv[0], "basic-rates") == 0) {
+		argv++;
+		argc--;
+
+		value = strtok_r(argv[0], ",", &sptr);
+
+		while (value && n_rates < NL80211_MAX_SUPP_RATES) {
+			rate = strtod(value, &end);
+			rates[n_rates] = rate * 2;
+
+			/* filter out suspicious values  */
+			if (*end != '\0' || !rates[n_rates] ||
+			    rate*2 != rates[n_rates])
+				return 1;
+
+			n_rates++;
+			value = strtok_r(NULL, ",", &sptr);
+		}
+
+		NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, n_rates, rates);
+		argv++;
+		argc--;
+	}
+
+	/* multicast rate */
 	if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
 		argv++;
 		argc--;
@@ -575,13 +602,14 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
  nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"
-	" [mcast-rate <rate in Mbps>]"
+COMMAND(mesh, join, "<mesh ID> [freq in MHz [HT20|HT40+|HT40-|NOHT]"
+	" [basic-rates <rate in Mbps,rate2,...>]], [mcast-rate <rate in Mbps>]"
 	" [beacon-interval <time in TUs>] [dtim-period <value>]"
 	" [vendor_sync on|off] [<param>=<value>]*",
 	NL80211_CMD_JOIN_MESH, 0, CIB_NETDEV, join_mesh,
-	"Join a mesh with the given mesh ID with frequency, mcast-rate, "
-	"and mesh parameters.");
+	"Join a mesh with the given mesh ID with frequency, basic-rates,\n"
+	"mcast-rate and mesh parameters. Basic-rates are applied only if\n"
+	"frequency is provided.");
 
 static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
 		      struct nl_msg *msg, int argc, char **argv,
-- 
1.9.2


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

* Re: [PATCH v3 1/2] iw: Allow user to provide freq during mesh join
  2014-09-20  6:40 [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Chun-Yeow Yeoh
  2014-09-20  6:40 ` [PATCH v3 2/2] iw: Allow basic rates to be configured when joining mesh Chun-Yeow Yeoh
@ 2014-09-22 11:00 ` Bob Copeland
  2014-09-22 12:50   ` Yeoh Chun-Yeow
  1 sibling, 1 reply; 4+ messages in thread
From: Bob Copeland @ 2014-09-22 11:00 UTC (permalink / raw)
  To: Chun-Yeow Yeoh, devel; +Cc: linux-wireless, Ashok Nagarajan, johannes

On Sat, Sep 20, 2014 at 02:40:43PM +0800, Chun-Yeow Yeoh via Devel wrote:
> +	/* freq */
> +	if (argc > 1 && strcmp(argv[0], "freq") == 0) {
> +		argv++;
> +		argc--;

[snip]

> -COMMAND(mesh, join, "<mesh ID> [mcast-rate <rate in Mbps>]"
> +COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"

Should this be something like:

> +COMMAND(mesh, join, "<mesh ID> [freq <freq in MHz> <HT20|HT40+|HT40-|NOHT>]"

...so we know to specify the 'freq' keyword?

-- 
Bob Copeland %% www.bobcopeland.com

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

* Re: [PATCH v3 1/2] iw: Allow user to provide freq during mesh join
  2014-09-22 11:00 ` [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Bob Copeland
@ 2014-09-22 12:50   ` Yeoh Chun-Yeow
  0 siblings, 0 replies; 4+ messages in thread
From: Yeoh Chun-Yeow @ 2014-09-22 12:50 UTC (permalink / raw)
  To: Bob Copeland
  Cc: devel@lists.open80211s.org, linux-wireless@vger.kernel.org,
	Ashok Nagarajan, Johannes Berg

On Mon, Sep 22, 2014 at 7:00 PM, Bob Copeland <me@bobcopeland.com> wrote:
> On Sat, Sep 20, 2014 at 02:40:43PM +0800, Chun-Yeow Yeoh via Devel wrote:
>> +     /* freq */
>> +     if (argc > 1 && strcmp(argv[0], "freq") == 0) {
>> +             argv++;
>> +             argc--;
>
> [snip]
>
>> -COMMAND(mesh, join, "<mesh ID> [mcast-rate <rate in Mbps>]"
>> +COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"
>
> Should this be something like:
>
>> +COMMAND(mesh, join, "<mesh ID> [freq <freq in MHz> <HT20|HT40+|HT40-|NOHT>]"
>
> ...so we know to specify the 'freq' keyword?

Yes, it makes sense. I will resubmit v4 later on.

----
Chun-Yeow

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

end of thread, other threads:[~2014-09-22 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-20  6:40 [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Chun-Yeow Yeoh
2014-09-20  6:40 ` [PATCH v3 2/2] iw: Allow basic rates to be configured when joining mesh Chun-Yeow Yeoh
2014-09-22 11:00 ` [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Bob Copeland
2014-09-22 12:50   ` Yeoh Chun-Yeow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.