linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iw: Sync nl80211.h with wireless-testing
@ 2010-07-27  9:49 Bruno Randolf
  2010-07-27  9:49 ` [PATCH 2/2] iw: Add antenna configuration commands Bruno Randolf
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Randolf @ 2010-07-27  9:49 UTC (permalink / raw)
  To: johannes, linville; +Cc: linux-wireless

Adding antenna attributes.

Signed-off-by: Bruno Randolf <br1@einfach.org>
---
 nl80211.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/nl80211.h b/nl80211.h
index 2c87016..b9de53c 100644
--- a/nl80211.h
+++ b/nl80211.h
@@ -731,6 +731,20 @@ enum nl80211_commands {
  *      This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
  *      for non-automatic settings.
  *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ *	Each bit represents one antenna, starting with antenna 1 at the first
+ *	bit. If the bitmap is zero (0), the TX antenna follows RX diversity.
+ *	If multiple antennas are selected all selected antennas have to be used
+ *	for transmitting (801.11n multiple TX chains).
+ *	Drivers may reject configurations they cannot support.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ *	Each bit represents one antenna, starting with antenna 1 at the first
+ *	bit. If multiple antennas are selected in the bitmap, 802.11n devices
+ *	should use multiple RX chains on these antennas, while non-802.11n
+ *	drivers should use antenna diversity between these antennas.
+ *	Drivers may reject configurations they cannot support.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -891,6 +905,9 @@ enum nl80211_attrs {
 	NL80211_ATTR_WIPHY_TX_POWER_SETTING,
 	NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
 
+	NL80211_ATTR_WIPHY_ANTENNA_TX,
+	NL80211_ATTR_WIPHY_ANTENNA_RX,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,


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

* [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-27  9:49 [PATCH 1/2] iw: Sync nl80211.h with wireless-testing Bruno Randolf
@ 2010-07-27  9:49 ` Bruno Randolf
  2010-07-27 10:04   ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Randolf @ 2010-07-27  9:49 UTC (permalink / raw)
  To: johannes, linville; +Cc: linux-wireless

Add command to set the antenna configuration (iw phyX set antenna ...) and
include antenna setting in wiphy information (iw phyX info).

Signed-off-by: Bruno Randolf <br1@einfach.org>
---
 info.c |    7 +++++++
 phy.c  |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/info.c b/info.c
index 512e777..dc987c7 100644
--- a/info.c
+++ b/info.c
@@ -167,6 +167,13 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 		printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
 	}
 
+	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
+	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
+		printf("\tAntenna: TX %d RX %d\n",
+		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
+		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
+	}
+
 	if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
 		goto commands;
 
diff --git a/phy.c b/phy.c
index 1f54ba3..75c80d2 100644
--- a/phy.c
+++ b/phy.c
@@ -306,3 +306,49 @@ COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
 COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
 	NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_txpower,
 	"Specify transmit power level and setting type.");
+
+static int handle_antenna(struct nl80211_state *state,
+			  struct nl_cb *cb,
+			  struct nl_msg *msg,
+			  int argc, char **argv)
+{
+	char *end;
+	uint8_t tx_ant = 0, rx_ant = 0;
+
+	if (argc == 1) {
+		if (strcmp(*argv, "diversity") == 0) {
+			tx_ant = 0;
+			rx_ant = 0xf;
+		} else {
+			tx_ant = rx_ant = strtoul(argv[0], &end, 10);
+		}
+	}
+	else if (argc == 4) {
+		while (argc) {
+			if (strcmp(*argv, "tx") == 0 ||
+			    strcmp(*argv, "rx") == 0) {
+				if (strcmp(*argv, "tx") == 0)
+					tx_ant = strtoul(argv[1], &end, 10);
+				else
+					rx_ant = strtoul(argv[1], &end, 10);
+			}
+			argv = argv + 2;
+			argc = argc - 2;
+		}
+	}
+
+	if (*end)
+		return 1;
+
+	NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant);
+	NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant);
+
+	return 0;
+
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, antenna, "<bitmap> | diversity | tx <bitmap> rx <bitmap>",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna,
+	"Set a bitmap of allowed antennas to use for TX and RX.\n"
+	"The driver may reject antenna configurations it cannot support.");


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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-27  9:49 ` [PATCH 2/2] iw: Add antenna configuration commands Bruno Randolf
@ 2010-07-27 10:04   ` Johannes Berg
  2010-07-28  2:07     ` Bruno Randolf
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2010-07-27 10:04 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: linville, linux-wireless

On Tue, 2010-07-27 at 18:49 +0900, Bruno Randolf wrote:

> +	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> +	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> +		printf("\tAntenna: TX %d RX %d\n",
> +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
> +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));

That's like the worst possible way to show the info.

johannes


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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-27 10:04   ` Johannes Berg
@ 2010-07-28  2:07     ` Bruno Randolf
  2010-07-28  6:50       ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Randolf @ 2010-07-28  2:07 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linville, linux-wireless

On Tue July 27 2010 19:04:21 Johannes Berg wrote:
> On Tue, 2010-07-27 at 18:49 +0900, Bruno Randolf wrote:
> > +	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> > +	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> > +		printf("\tAntenna: TX %d RX %d\n",
> > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
> > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
> 
> That's like the worst possible way to show the info.

which way would you prefer?

bruno

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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-28  2:07     ` Bruno Randolf
@ 2010-07-28  6:50       ` Johannes Berg
  2010-07-28  8:29         ` Bruno Randolf
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2010-07-28  6:50 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: linville, linux-wireless

On Wed, 2010-07-28 at 11:07 +0900, Bruno Randolf wrote:
> On Tue July 27 2010 19:04:21 Johannes Berg wrote:
> > On Tue, 2010-07-27 at 18:49 +0900, Bruno Randolf wrote:
> > > +	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> > > +	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> > > +		printf("\tAntenna: TX %d RX %d\n",
> > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
> > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
> > 
> > That's like the worst possible way to show the info.
> 
> which way would you prefer?

It occurred to me later that with the normal numbers we have (1 through
7) it won't matter much ... but still, I'd prefer %#x.

johannes


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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-28  6:50       ` Johannes Berg
@ 2010-07-28  8:29         ` Bruno Randolf
  2010-07-29  3:35           ` Bruno Randolf
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Randolf @ 2010-07-28  8:29 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linville, linux-wireless

On Wed July 28 2010 15:50:48 Johannes Berg wrote:
> On Wed, 2010-07-28 at 11:07 +0900, Bruno Randolf wrote:
> > On Tue July 27 2010 19:04:21 Johannes Berg wrote:
> > > On Tue, 2010-07-27 at 18:49 +0900, Bruno Randolf wrote:
> > > > +	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> > > > +	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> > > > +		printf("\tAntenna: TX %d RX %d\n",
> > > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
> > > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
> > > 
> > > That's like the worst possible way to show the info.
> > 
> > which way would you prefer?
> 
> It occurred to me later that with the normal numbers we have (1 through
> 7) it won't matter much ... but still, I'd prefer %#x.

ok. changed that and the command line parsing to use "strtoul(argv[1], &end, 
0)" so we can use hex, decimal or octal for the setting. i will resend the 
patches once a consensus is reached (or after an unspecified timeout ;)).

bruno

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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-28  8:29         ` Bruno Randolf
@ 2010-07-29  3:35           ` Bruno Randolf
  2010-07-29  7:49             ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Bruno Randolf @ 2010-07-29  3:35 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linville, linux-wireless

On Wed July 28 2010 17:29:38 Bruno Randolf wrote:
> On Wed July 28 2010 15:50:48 Johannes Berg wrote:
> > On Wed, 2010-07-28 at 11:07 +0900, Bruno Randolf wrote:
> > > On Tue July 27 2010 19:04:21 Johannes Berg wrote:
> > > > On Tue, 2010-07-27 at 18:49 +0900, Bruno Randolf wrote:
> > > > > +	if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> > > > > +	    tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> > > > > +		printf("\tAntenna: TX %d RX %d\n",
> > > > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
> > > > > +		       nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
> > > > 
> > > > That's like the worst possible way to show the info.
> > > 
> > > which way would you prefer?
> > 
> > It occurred to me later that with the normal numbers we have (1 through
> > 7) it won't matter much ... but still, I'd prefer %#x.
> 
> ok. changed that...

actually - no. what sense does it make to use a hexadecimal notation and print 
0x for values between 0 and 7?

bruno

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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-29  3:35           ` Bruno Randolf
@ 2010-07-29  7:49             ` Johannes Berg
  2010-07-29  9:14               ` Bruno Randolf
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2010-07-29  7:49 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: linville, linux-wireless

On Thu, 2010-07-29 at 12:35 +0900, Bruno Randolf wrote:

> actually - no. what sense does it make to use a hexadecimal notation and print 
> 0x for values between 0 and 7?

Well ... 11n does define mimo 4x4.

johannes


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

* Re: [PATCH 2/2] iw: Add antenna configuration commands
  2010-07-29  7:49             ` Johannes Berg
@ 2010-07-29  9:14               ` Bruno Randolf
  0 siblings, 0 replies; 9+ messages in thread
From: Bruno Randolf @ 2010-07-29  9:14 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linville, linux-wireless

On Thu July 29 2010 16:49:05 Johannes Berg wrote:
> On Thu, 2010-07-29 at 12:35 +0900, Bruno Randolf wrote:
> > actually - no. what sense does it make to use a hexadecimal notation and
> > print 0x for values between 0 and 7?
> 
> Well ... 11n does define mimo 4x4.

oh, yes, true: 0xf

bruno

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

end of thread, other threads:[~2010-07-29  9:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-27  9:49 [PATCH 1/2] iw: Sync nl80211.h with wireless-testing Bruno Randolf
2010-07-27  9:49 ` [PATCH 2/2] iw: Add antenna configuration commands Bruno Randolf
2010-07-27 10:04   ` Johannes Berg
2010-07-28  2:07     ` Bruno Randolf
2010-07-28  6:50       ` Johannes Berg
2010-07-28  8:29         ` Bruno Randolf
2010-07-29  3:35           ` Bruno Randolf
2010-07-29  7:49             ` Johannes Berg
2010-07-29  9:14               ` Bruno Randolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).