All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avery Pennarun <apenwarr@gmail.com>
To: Ben Greear <greearb@candelatech.com>,
	Vu Hai NGUYEN <vh.nguyen@actiasodielec.fr>,
	Patrick CARNEIRO RODRIGUEZ <p.carneiro@actiasodielec.fr>,
	"ath10k@lists.infradead.org" <ath10k@lists.infradead.org>
Cc: Avery Pennarun <apenwarr@gmail.com>
Subject: [PATCH v3] ath10k: support get/set antenna configurations.
Date: Tue, 13 May 2014 17:11:12 -0400	[thread overview]
Message-ID: <1400015472-4647-1-git-send-email-apenwarr@gmail.com> (raw)
In-Reply-To: <1399942355-19993-1-git-send-email-apenwarr@gmail.com>

From: Ben Greear <greearb@candelatech.com>

Tested with CT firmware, but should work on standard
firmware as well.

Verified that target's tx/rx chain register is set appropriately,
and that the tx rate goes down as number of chains
decrease, but I did not actually try to verify antenna
ceased to transmit when disabled.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---
 drivers/net/wireless/ath/ath10k/core.h |  6 +++
 drivers/net/wireless/ath/ath10k/mac.c  | 71 ++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.c  |  5 +++
 3 files changed, 82 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 9b86e57..6ab6c73 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -440,6 +440,12 @@ struct ath10k {
 	bool radar_enabled;
 	int num_started_vdevs;
 
+	/* Protected by conf-mutex */
+	u8 supp_tx_chainmask;
+	u8 supp_rx_chainmask;
+	u8 cfg_tx_chainmask;
+	u8 cfg_rx_chainmask;
+
 	struct wmi_pdev_set_wmm_params_arg wmm_params;
 	struct completion install_key_done;
 
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index ecd191b..f0ae331 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -2329,6 +2329,68 @@ void ath10k_halt(struct ath10k *ar)
 	spin_unlock_bh(&ar->data_lock);
 }
 
+static int ath10k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
+{
+	struct ath10k *ar = hw->priv;
+
+	mutex_lock(&ar->conf_mutex);
+
+	if (ar->cfg_tx_chainmask) {
+		*tx_ant = ar->cfg_tx_chainmask;
+		*rx_ant = ar->cfg_rx_chainmask;
+	} else {
+		*tx_ant = ar->supp_tx_chainmask;
+		*rx_ant = ar->supp_rx_chainmask;
+	}
+
+	mutex_unlock(&ar->conf_mutex);
+
+	return 0;
+}
+
+static int __ath10k_set_antenna(struct ath10k *ar, u32 tx_ant, u32 rx_ant)
+{
+	int ret;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	ar->cfg_tx_chainmask = tx_ant;
+	ar->cfg_rx_chainmask = rx_ant;
+
+	if ((ar->state != ATH10K_STATE_ON) &&
+	    (ar->state != ATH10K_STATE_RESTARTED))
+		return 0;
+
+	ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->tx_chain_mask,
+					tx_ant);
+	if (ret) {
+		ath10k_warn("failed to set tx-chainmask: %d, req 0x%x\n",
+			    ret, tx_ant);
+		return ret;
+	}
+
+	ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->rx_chain_mask,
+					rx_ant);
+	if (ret) {
+		ath10k_warn("failed to set rx-chainmask: %d, req 0x%x\n",
+			    ret, rx_ant);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int ath10k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
+{
+	struct ath10k *ar = hw->priv;
+	int ret;
+
+	mutex_lock(&ar->conf_mutex);
+	ret = __ath10k_set_antenna(ar, tx_ant, rx_ant);
+	mutex_unlock(&ar->conf_mutex);
+	return ret;
+}
+
 static int ath10k_start(struct ieee80211_hw *hw)
 {
 	struct ath10k *ar = hw->priv;
@@ -2370,6 +2432,10 @@ static int ath10k_start(struct ieee80211_hw *hw)
 	if (ret)
 		ath10k_warn("failed to enable dynamic BW: %d\n", ret);
 
+	if (ar->cfg_tx_chainmask)
+		__ath10k_set_antenna(ar, ar->cfg_tx_chainmask,
+				     ar->cfg_rx_chainmask);
+
 	/*
 	 * By default FW set ARP frames ac to voice (6). In that case ARP
 	 * exchange is not working properly for UAPSD enabled AP. ARP requests
@@ -4252,6 +4318,8 @@ static const struct ieee80211_ops ath10k_ops = {
 	.set_frag_threshold		= ath10k_set_frag_threshold,
 	.flush				= ath10k_flush,
 	.tx_last_beacon			= ath10k_tx_last_beacon,
+	.set_antenna			= ath10k_set_antenna,
+	.get_antenna			= ath10k_get_antenna,
 	.restart_complete		= ath10k_restart_complete,
 	.get_survey			= ath10k_get_survey,
 	.set_bitrate_mask		= ath10k_set_bitrate_mask,
@@ -4601,6 +4669,9 @@ int ath10k_mac_register(struct ath10k *ar)
 		BIT(NL80211_IFTYPE_ADHOC) |
 		BIT(NL80211_IFTYPE_AP);
 
+	ar->hw->wiphy->available_antennas_rx = ar->supp_rx_chainmask;
+	ar->hw->wiphy->available_antennas_tx = ar->supp_tx_chainmask;
+
 	if (!test_bit(ATH10K_FW_FEATURE_NO_P2P, ar->fw_features))
 		ar->hw->wiphy->interface_modes |=
 			BIT(NL80211_IFTYPE_P2P_CLIENT) |
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 0a2d04c..d22874a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -2558,6 +2558,8 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
 	config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
 	config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
 	config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
+	ar->supp_tx_chainmask = TARGET_TX_CHAIN_MASK;
+	ar->supp_rx_chainmask = TARGET_RX_CHAIN_MASK;
 	config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
 	config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
 	config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
@@ -2652,6 +2654,9 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
 	config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
 	config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
 	config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
+	/* TODO:  Have to deal with 2x2 chips if/when the come out. */
+	ar->supp_tx_chainmask = TARGET_10X_TX_CHAIN_MASK;
+	ar->supp_rx_chainmask = TARGET_10X_RX_CHAIN_MASK;
 	config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
 	config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
 	config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
-- 
1.9.1.423.g4596e3a


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

  parent reply	other threads:[~2014-05-13 21:11 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 16:18 [PATCH v2 2/2] ath10k: support get/set antenna configurations greearb
2014-05-08 16:18 ` greearb
2014-05-12 15:43 ` RE : " Vu Hai NGUYEN
2014-05-12 16:17   ` Ben Greear
2014-05-13  0:49     ` Avery Pennarun
2014-05-13  3:36       ` Ben Greear
2014-05-13 13:08         ` ath10k: set channel by command "iw" not from hostapd and DFS support of firmware-2.bin_10.1.467.2-1 Vu Hai NGUYEN
2014-05-14  9:32           ` Matti Laakso
2014-05-14 11:56             ` RE : " Vu Hai NGUYEN
2014-05-15  8:02               ` Matti Laakso
2014-05-15 10:41                 ` RE : " Vu Hai NGUYEN
2014-05-15 11:11                   ` Janusz Dziedzic
2014-05-15 13:36                     ` RE : " Vu Hai NGUYEN
2014-05-15 16:08                       ` Vu Hai NGUYEN
2014-05-16  6:52                         ` Janusz Dziedzic
2014-05-16  7:01                           ` RE : " Vu Hai NGUYEN
2014-05-16  7:35                             ` Janusz Dziedzic
2014-05-16  7:46                               ` Bartosz Markowski
2014-05-16  8:03                                 ` RE : " Vu Hai NGUYEN
2014-05-16  8:13                                   ` Bartosz Markowski
2014-05-16  9:41                                     ` RE : " Vu Hai NGUYEN
2014-05-16 11:39                                       ` Janusz Dziedzic
2014-05-16 11:50                                         ` Janusz Dziedzic
2014-05-16 13:17                                           ` RE : RE " Vu Hai NGUYEN
2014-05-16 17:40                                             ` Janusz Dziedzic
2014-05-19  9:39                                               ` Vu Hai NGUYEN
2014-05-19 10:42                                                 ` Janusz Dziedzic
2014-05-16 13:00                               ` RE : RE : RE : RE : " Kalle Valo
2014-05-16 14:03                                 ` Janusz Dziedzic
2014-05-16 14:12                                   ` Kalle Valo
2014-05-16  7:41                             ` Matti Laakso
2014-05-15  7:07           ` ath10k: firmware crash in station mode Vu Hai NGUYEN
2014-05-15  7:53             ` Janusz Dziedzic
2014-05-15 10:57             ` Michal Kazior
2014-05-15 13:27               ` RE : " Vu Hai NGUYEN
2014-05-19  6:59                 ` Michal Kazior
2014-05-19  9:47                   ` RE : " Vu Hai NGUYEN
2014-05-19 12:51                     ` Michal Kazior
2014-05-20  6:44                       ` ath10k: firmware crash in station mode & problem DFS Vu Hai NGUYEN
2014-05-20  8:15                         ` RE : " Vu Hai NGUYEN
2014-05-20 17:59                           ` Janusz Dziedzic
2014-05-21  9:43                             ` RE : " Vu Hai NGUYEN
2014-05-21 14:03                               ` Janusz Dziedzic
2014-05-22  7:54                                 ` RE : " Vu Hai NGUYEN
2014-05-22  8:06                                   ` Vu Hai NGUYEN
2014-05-22 12:18                                     ` Janusz Dziedzic
2014-05-22 12:25                                       ` Janusz Dziedzic
2014-05-22 14:40                                         ` RE : " Vu Hai NGUYEN
2014-05-22 14:45                                           ` Vu Hai NGUYEN
2014-05-22 16:44                                           ` RE : " Kalle Valo
     [not found]                                             ` <EE97821C81277E459BEA5C6384C6F241012F109978E8@srvexch01.SODIELEC.local>
     [not found]                                               ` <EE97821C81277E459BEA5C6384C6F241012F109978E9@srvexch01.SODIELEC.local>
2014-05-23  7:40                                                 ` Kalle Valo
2014-05-23  7:52                                                 ` RE : " Vu Hai NGUYEN
2014-05-26  8:34                                                   ` Janusz Dziedzic
2014-05-26 13:45                                                     ` Vu Hai NGUYEN
     [not found]                                                       ` <CAFED-j=i5uhjqaJYL+dm_ui48EFeHG3isHYSSSo=+3gk-Wa5YQ@mail.gmail.com>
2014-05-27  6:50                                                         ` Janusz Dziedzic
2014-05-27  9:21                                                           ` Vu Hai NGUYEN
2014-05-27 16:36                                                           ` Vu Hai NGUYEN
2014-05-28 15:25                                                             ` Vu Hai NGUYEN
2014-05-28 15:49                                                               ` Ben Greear
2014-05-30  9:10                                                                 ` Vu Hai NGUYEN
2014-05-30 14:49                                                                   ` Ben Greear
2014-06-02 16:16                                                                     ` Vu Hai NGUYEN
2014-06-02 16:48                                                                       ` Ben Greear
2014-06-03  6:51                                                                         ` Vu Hai NGUYEN
2014-06-04  4:14                                                                           ` Ben Greear
2014-06-04  9:20                                                                             ` Vu Hai NGUYEN
2014-06-04 16:20                                                                               ` Ben Greear
2014-06-04 21:40                                                                               ` Ben Greear
2014-06-05  8:41                                                                                 ` RE : " Vu Hai NGUYEN
2014-06-05 15:43                                                                                   ` Ben Greear
2014-06-05 17:33                                                                                   ` Ben Greear
2014-06-06  9:05                                                                                     ` RE : " Vu Hai NGUYEN
2014-06-06 15:50                                                                                       ` Ben Greear
2014-06-10  7:15                                                                                         ` Vu Hai NGUYEN
2014-06-10 15:51                                                                                           ` Ben Greear
2014-06-11  7:19                                                                                             ` Vu Hai NGUYEN
2014-06-11 17:05                                                                                               ` Ben Greear
2014-06-12  8:48                                                                                                 ` RE : " Vu Hai NGUYEN
2014-06-12 17:54                                                                                                   ` Ben Greear
2014-06-12 20:22                                                                                                   ` Ben Greear
2014-06-13  8:50                                                                                                     ` Vu Hai NGUYEN
2014-06-13 14:34                                                                                                       ` Ben Greear
2014-06-13 17:04                                                                                                       ` Ben Greear
2014-06-16  7:16                                                                                                         ` Vu Hai NGUYEN
2014-06-16 14:47                                                                                                           ` Ben Greear
2014-06-17  7:25                                                                                                             ` Vu Hai NGUYEN
2014-06-23  9:03                                                                                                               ` Warning message in bridge mode Vu Hai NGUYEN
2014-06-23 21:33                                                                                                                 ` Ben Greear
2014-06-23 21:47                                                                                                                   ` Bruno Antunes
2014-06-24  7:39                                                                                                                     ` RE : " Vu Hai NGUYEN
2014-06-24 15:10                                                                                                                       ` Ben Greear
2014-06-26 14:17                                                                                                                         ` Vu Hai NGUYEN
2014-06-26 14:34                                                                                                                           ` Ben Greear
2014-06-27 15:52                                                                                                                             ` Vu Hai NGUYEN
2014-06-27 15:59                                                                                                                               ` Ben Greear
2014-06-30  8:14                                                                                                                                 ` Vu Hai NGUYEN
2014-06-07  0:28                                                                                       ` RE : RE : RE : RE : RE : ath10k: firmware crash in station mode & problem DFS Ben Greear
2014-05-28 17:19                                                               ` Janusz Dziedzic
2014-05-28 18:40                                                                 ` Janusz Dziedzic
2014-05-30 11:55                                                                   ` Vu Hai NGUYEN
2014-06-02  7:03                                                                     ` Janusz Dziedzic
2014-05-23  7:18                                           ` Michal Kazior
2014-05-23  9:15                       ` RE : RE : ath10k: firmware crash in station mode Yeoh Chun-Yeow
2014-05-23 11:35                         ` RE : " Vu Hai NGUYEN
2014-05-23 14:27                           ` Yeoh Chun-Yeow
2014-05-23 14:55                 ` TR " Vu Hai NGUYEN
2014-05-23 15:36                   ` Yeoh Chun-Yeow
2014-05-23 16:03                     ` Ben Greear
2014-05-24  6:29                       ` Tim Harvey
2014-05-24 16:14                         ` Ben Greear
2014-05-27 19:13                           ` Ben Greear
2014-05-25  7:26                         ` Kalle Valo
2014-05-24  5:49                     ` Tim Harvey
2014-05-24 16:46                       ` Yeoh Chun-Yeow
2014-05-13  0:52     ` [PATCH] ath10k: support get/set antenna configurations Avery Pennarun
2014-05-13 18:10       ` Kalle Valo
2014-05-13 18:15         ` Ben Greear
2014-05-13 21:03           ` Avery Pennarun
2014-05-14 12:28             ` Kalle Valo
2014-05-15  4:04               ` Yeoh Chun-Yeow
2014-05-15  5:47                 ` Avery Pennarun
2014-05-15  6:51                   ` Yeoh Chun-Yeow
2014-05-15  7:11                 ` Kalle Valo
2014-05-13 21:11       ` Avery Pennarun [this message]
2014-05-14  6:20         ` [PATCH v3] " Yeoh Chun-Yeow
2014-05-14  6:21           ` Avery Pennarun
2014-05-14  6:25             ` Yeoh Chun-Yeow
2014-05-14  7:18               ` Avery Pennarun
2014-05-14  7:22                 ` Yeoh Chun-Yeow
2014-05-14  7:33                   ` Yeoh Chun-Yeow
2014-05-16 12:30         ` Kalle Valo
2014-05-16 13:00           ` Ben Greear
2014-05-22 16:56         ` Kalle Valo
2014-05-13 17:50     ` RE : [PATCH v2 2/2] " Kalle Valo

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=1400015472-4647-1-git-send-email-apenwarr@gmail.com \
    --to=apenwarr@gmail.com \
    --cc=ath10k@lists.infradead.org \
    --cc=greearb@candelatech.com \
    --cc=p.carneiro@actiasodielec.fr \
    --cc=vh.nguyen@actiasodielec.fr \
    /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 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.