ath9k-devel.lists.ath9k.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Golle <dgolle@allnet.de>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH v1 -1/3] support for antenna configuration profiles
Date: Mon, 28 Nov 2011 15:58:24 +0100	[thread overview]
Message-ID: <20111128145824.GA24947@localhost> (raw)

This is a patch against the iw userspace tool.
Antenna switch configuration profiles are printed out in info.c, marking the
currently selected profile.
An operation to select the profile is added to phy.c.

Signed-off-by: Daniel Golle <dgolle@allnet.de>
---
--- a/info.c
+++ b/info.c
@@ -180,6 +180,58 @@ static int print_phy_handler(struct nl_m
 		       nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
 		       nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
 
+	if (tb_msg[NL80211_ATTR_WIPHY_EXTANT]) {
+		static struct nla_policy extant_policy[NL80211_EXTANT_ATTR_MAX + 1] = {
+			[NL80211_EXTANT_ATTR_STATE] = { .type = NLA_U32 },
+			[NL80211_EXTANT_ATTR_PROFILES] = { .type = NLA_NESTED },
+		};
+		struct nlattr *tb_extant[NL80211_EXTANT_ATTR_MAX + 1];
+		struct nlattr *nl_easp, *tb_easp[NL80211_EASP_ATTR_MAX + 1];
+		int err, rem_easp;
+		int current_profile, num_profiles = 0;
+		int id;
+		int i;
+		static struct nla_policy easp_policy[NL80211_EASP_ATTR_MAX + 1] = {
+			[NL80211_EASP_ATTR_ID] = { .type = NLA_U32 },
+			[NL80211_EASP_ATTR_NAME] = { },
+			[NL80211_EASP_ATTR_DESC] = { },
+		};
+
+		printf("\tDevice supports antenna configuration profiles.\n");
+		err = nla_parse_nested(tb_extant, NL80211_EXTANT_ATTR_MAX, tb_msg[NL80211_ATTR_WIPHY_EXTANT], extant_policy);
+		if (err)
+			goto broken_extant;
+
+		if (tb_extant[NL80211_EXTANT_ATTR_STATE])
+			current_profile = nla_get_u32(tb_extant[NL80211_EXTANT_ATTR_STATE]);
+		else
+			current_profile = -1;
+
+		nla_for_each_nested(nl_easp, tb_extant[NL80211_EXTANT_ATTR_PROFILES], rem_easp) {
+			num_profiles++;
+		}
+
+		nla_for_each_nested(nl_easp, tb_extant[NL80211_EXTANT_ATTR_PROFILES], rem_easp)
+		{
+			err = nla_parse(tb_easp, NL80211_EASP_ATTR_MAX, nla_data(nl_easp), nla_len(nl_easp), easp_policy);
+
+			if (err || !tb_easp[NL80211_EASP_ATTR_ID] || !tb_easp[NL80211_EASP_ATTR_NAME] || !tb_easp[NL80211_EASP_ATTR_DESC]) {
+				printf("cannot parse antenna switch profile, err %x\n", err);
+				goto broken_extant;
+			}
+			id = nla_get_u32(tb_easp[NL80211_EASP_ATTR_ID]);
+			if ( id == current_profile )
+				printf("\t\t (*)");
+			else
+				printf("\t\t ( )");
+			printf(" %u\t%s\t(%s)", id, nla_get_string(tb_easp[NL80211_EASP_ATTR_NAME]),
+				nla_get_string(tb_easp[NL80211_EASP_ATTR_DESC]));
+			printf("\n");
+		}
+broken_extant:
+		;
+	}
+
 	if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) {
 		printf("\tSupported interface modes:\n");
 		nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
@@ -219,6 +271,9 @@ static int print_phy_handler(struct nl_m
 				have_combinations = true;
 			}
 
+
+
+
 			printf("\t\t * ");
 
 			err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
--- a/phy.c
+++ b/phy.c
@@ -333,3 +333,30 @@ COMMAND(set, antenna, "<bitmap> | all |
 	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.");
+
+static int handle_extant(struct nl80211_state *state,
+			  struct nl_cb *cb,
+			  struct nl_msg *msg,
+			  int argc, char **argv)
+{
+	char *end;
+	__u32 extant;
+
+	if (argc == 1) {
+		extant = strtoul(argv[0], &end, 0);
+		if (*end)
+			return 1;
+	} else
+		return 1;
+
+	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_EXTANT_SELECT, extant);
+
+	return 0;
+
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, extant, "<profile>",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_extant,
+	"Select the external antenna switch configuration profile.\n"
+	"The driver accepts only profiles defined for the hardware.");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20111128/3c91ae77/attachment-0001.pgp 

                 reply	other threads:[~2011-11-28 14:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111128145824.GA24947@localhost \
    --to=dgolle@allnet.de \
    --cc=ath9k-devel@lists.ath9k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).