2014-12-18 23:18:17

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 0/3] add debugfs support to ath9k hw TPC

*[PATCH 1/3]: enable TPC by default on AR9003 based chips
*[PATCH 2/3]: enable/disable hw TPC through debugfs
*[PATCH 3/3]: fix typo

Lorenzo Bianconi (3):
ath9k: enable TPC by default
ath9k: add debugfs support for hw TPC
ath9k: fix typo

drivers/net/wireless/ath/ath9k/debug.c | 71 ++++++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath9k/hw.c | 3 ++
drivers/net/wireless/ath/ath9k/xmit.c | 2 +-
3 files changed, 75 insertions(+), 1 deletion(-)

--
2.1.0



2014-12-18 23:18:18

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 2/3] ath9k: add debugfs support for hw TPC

Add tpc entry to ath9k debugfs in order to enable/disable hw TPC

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/ath/ath9k/debug.c | 71 ++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 696e3d5..346290a 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1188,6 +1188,75 @@ static const struct file_operations fops_ackto = {
};
#endif

+static ssize_t read_file_tpc(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ struct ath_hw *ah = sc->sc_ah;
+ unsigned int len = 0, size = 32;
+ ssize_t retval;
+ char *buf;
+
+ buf = kzalloc(size, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ len += scnprintf(buf + len, size - len, "%s\n",
+ ah->tpc_enabled ? "ENABLED" : "DISABLED");
+
+ if (len > size)
+ len = size;
+
+ retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ kfree(buf);
+
+ return retval;
+}
+
+static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ struct ath_hw *ah = sc->sc_ah;
+ unsigned long val;
+ char buf[32];
+ ssize_t len;
+ bool tpc_enabled;
+
+ if (!AR_SREV_9300_20_OR_LATER(ah)) {
+ /* ar9002 does not support TPC for the moment */
+ return -EOPNOTSUPP;
+ }
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, len))
+ return -EFAULT;
+
+ buf[len] = '\0';
+ if (kstrtoul(buf, 0, &val))
+ return -EINVAL;
+
+ if (val < 0 || val > 1)
+ return -EINVAL;
+
+ tpc_enabled = !!val;
+
+ if (tpc_enabled != ah->tpc_enabled) {
+ ah->tpc_enabled = tpc_enabled;
+ ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
+ }
+
+ return count;
+}
+
+static const struct file_operations fops_tpc = {
+ .read = read_file_tpc,
+ .write = write_file_tpc,
+ .open = simple_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+
/* Ethtool support for get-stats */

#define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
@@ -1397,6 +1466,8 @@ int ath9k_init_debug(struct ath_hw *ah)
debugfs_create_file("ack_to", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
sc, &fops_ackto);
#endif
+ debugfs_create_file("tpc", S_IRUSR | S_IWUSR,
+ sc->debug.debugfs_phy, sc, &fops_tpc);

return 0;
}
--
2.1.0


2014-12-18 23:18:18

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 1/3] ath9k: enable TPC by default

Enable hw TPC by default on AR9003 based chips

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/ath/ath9k/hw.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 6d4b273..258c4d2 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -422,6 +422,9 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
ah->power_mode = ATH9K_PM_UNDEFINED;
ah->htc_reset_init = true;

+ /* ar9002 does not support TPC for the moment */
+ ah->tpc_enabled = !!AR_SREV_9300_20_OR_LATER(ah);
+
ah->ani_function = ATH9K_ANI_ALL;
if (!AR_SREV_9300_20_OR_LATER(ah))
ah->ani_function &= ~ATH9K_ANI_MRC_CCK;
--
2.1.0


2014-12-24 17:19:28

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 0/3] add debugfs support to ath9k hw TPC

Lorenzo Bianconi <[email protected]> writes:

> *[PATCH 1/3]: enable TPC by default on AR9003 based chips
> *[PATCH 2/3]: enable/disable hw TPC through debugfs
> *[PATCH 3/3]: fix typo
>
> Lorenzo Bianconi (3):
> ath9k: enable TPC by default
> ath9k: add debugfs support for hw TPC
> ath9k: fix typo

Thanks, all three applied to wireless-drivers-next.git.

--
Kalle Valo

2014-12-18 23:18:19

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 3/3] ath9k: fix typo

Fix typo

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/ath/ath9k/xmit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index e9bd02c..52d63de 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1106,7 +1106,7 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf,
return MAX_RATE_POWER;

if (!AR_SREV_9300_20_OR_LATER(ah)) {
- /* ar9002 is not sipported for the moment */
+ /* ar9002 does not support TPC for the moment */
return MAX_RATE_POWER;
}

--
2.1.0