ath9k-devel.lists.ath9k.org archive mirror
 help / color / mirror / Atom feed
* [ath9k-devel] [PATCH v1 -1/3] support for antenna configuration profiles
@ 2011-11-28 14:58 Daniel Golle
  0 siblings, 0 replies; only message in thread
From: Daniel Golle @ 2011-11-28 14:58 UTC (permalink / raw)
  To: ath9k-devel

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 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-28 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-28 14:58 [ath9k-devel] [PATCH v1 -1/3] support for antenna configuration profiles Daniel Golle

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).