From patchwork Wed Dec 22 01:54:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Randolf X-Patchwork-Id: 425621 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBM1sdI6007687 for ; Wed, 22 Dec 2010 01:54:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751880Ab0LVBy1 (ORCPT ); Tue, 21 Dec 2010 20:54:27 -0500 Received: from mail30t.wh2.ocn.ne.jp ([125.206.180.136]:21046 "HELO mail30t.wh2.ocn.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751876Ab0LVBy0 (ORCPT ); Tue, 21 Dec 2010 20:54:26 -0500 Received: from vs3009.wh2.ocn.ne.jp (125.206.180.237) by mail30t.wh2.ocn.ne.jp (RS ver 1.0.95vs) with SMTP id 5-0630032863 for ; Wed, 22 Dec 2010 10:54:24 +0900 (JST) Received: (qmail 27079 invoked from network); 22 Dec 2010 01:54:23 -0000 Received: from unknown (HELO localhost6.localdomain6) (220.110.201.18) by with SMTP; 22 Dec 2010 01:54:23 -0000 Subject: [PATCH v9] iw: Add antenna configuration To: johannes@sipsolutions.net, linville@tuxdriver.com From: Bruno Randolf Cc: linux-wireless@vger.kernel.org Date: Wed, 22 Dec 2010 10:54:39 +0900 Message-ID: <20101222015439.16569.9985.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 X-SF-Loop: 1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 22 Dec 2010 01:54:41 +0000 (UTC) diff --git a/info.c b/info.c index 0783701..de4777f 100644 --- a/info.c +++ b/info.c @@ -168,6 +168,18 @@ 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_AVAIL_TX] && + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) + printf("\tAvailable Antennas: TX %#x RX %#x\n", + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]), + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])); + + if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] && + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) + printf("\tConfigured Antennas: TX %#x RX %#x\n", + 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_SUPPORTED_IFTYPES]) { printf("\tSupported interface modes:\n"); nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode) diff --git a/phy.c b/phy.c index 7c6c7c8..e3bd4e8 100644 --- a/phy.c +++ b/phy.c @@ -307,3 +307,42 @@ COMMAND(set, txpower, " []", COMMAND(set, txpower, " []", 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; + uint32_t tx_ant = 0, rx_ant = 0; + + if (argc == 1 && strcmp(argv[0], "all") == 0) { + tx_ant = 0xffffffff; + rx_ant = 0xffffffff; + } else if (argc == 1) { + tx_ant = rx_ant = strtoul(argv[0], &end, 0); + if (*end) + return 1; + } + else if (argc == 2) { + tx_ant = strtoul(argv[0], &end, 0); + if (*end) + return 1; + rx_ant = strtoul(argv[1], &end, 0); + if (*end) + return 1; + } else + return 1; + + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant); + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant); + + return 0; + + nla_put_failure: + return -ENOBUFS; +} +COMMAND(set, antenna, " | 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.");