2019-07-24 08:58:20 +00:00
|
|
|
// SPDX-License-Identifier: ISC
|
2017-11-21 09:50:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
|
|
|
*/
|
|
|
|
#include "mt76.h"
|
|
|
|
|
|
|
|
static int
|
|
|
|
mt76_reg_set(void *data, u64 val)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = data;
|
|
|
|
|
2020-06-12 10:08:59 +00:00
|
|
|
__mt76_wr(dev, dev->debugfs_reg, val);
|
2017-11-21 09:50:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mt76_reg_get(void *data, u64 *val)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = data;
|
|
|
|
|
2020-06-12 10:08:59 +00:00
|
|
|
*val = __mt76_rr(dev, dev->debugfs_reg);
|
2017-11-21 09:50:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-14 15:39:05 +00:00
|
|
|
DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set,
|
|
|
|
"0x%08llx\n");
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2021-03-15 21:49:15 +00:00
|
|
|
static int
|
|
|
|
mt76_napi_threaded_set(void *data, u64 val)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = data;
|
|
|
|
|
|
|
|
if (!mt76_is_mmio(dev))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (dev->napi_dev.threaded != val)
|
|
|
|
return dev_set_threaded(&dev->napi_dev, val);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mt76_napi_threaded_get(void *data, u64 *val)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = data;
|
|
|
|
|
|
|
|
*val = dev->napi_dev.threaded;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_DEBUGFS_ATTRIBUTE(fops_napi_threaded, mt76_napi_threaded_get,
|
|
|
|
mt76_napi_threaded_set, "%llu\n");
|
|
|
|
|
2019-09-13 07:05:50 +00:00
|
|
|
int mt76_queues_read(struct seq_file *s, void *data)
|
2017-11-21 09:50:52 +00:00
|
|
|
{
|
|
|
|
struct mt76_dev *dev = dev_get_drvdata(s->private);
|
|
|
|
int i;
|
|
|
|
|
2021-09-25 13:27:02 +00:00
|
|
|
seq_puts(s, " queue | hw-queued | head | tail |\n");
|
2020-11-11 13:47:32 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dev->phy.q_tx); i++) {
|
|
|
|
struct mt76_queue *q = dev->phy.q_tx[i];
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-08-23 19:22:20 +00:00
|
|
|
if (!q)
|
2017-11-21 09:50:52 +00:00
|
|
|
continue;
|
|
|
|
|
2021-09-25 13:27:02 +00:00
|
|
|
seq_printf(s, " %9d | %9d | %9d | %9d |\n",
|
2020-08-23 19:22:20 +00:00
|
|
|
i, q->queued, q->head, q->tail);
|
2017-11-21 09:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-09-13 07:05:50 +00:00
|
|
|
EXPORT_SYMBOL_GPL(mt76_queues_read);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-04-19 20:11:41 +00:00
|
|
|
static int mt76_rx_queues_read(struct seq_file *s, void *data)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = dev_get_drvdata(s->private);
|
2021-11-08 10:03:52 +00:00
|
|
|
int i, queued;
|
2020-04-19 20:11:41 +00:00
|
|
|
|
2021-09-25 13:27:02 +00:00
|
|
|
seq_puts(s, " queue | hw-queued | head | tail |\n");
|
2020-05-24 12:44:52 +00:00
|
|
|
mt76_for_each_q_rx(dev, i) {
|
2020-04-19 20:11:41 +00:00
|
|
|
struct mt76_queue *q = &dev->q_rx[i];
|
|
|
|
|
2021-11-08 10:03:52 +00:00
|
|
|
queued = mt76_is_usb(dev) ? q->ndesc - q->queued : q->queued;
|
2021-09-25 13:27:02 +00:00
|
|
|
seq_printf(s, " %9d | %9d | %9d | %9d |\n",
|
2021-11-08 10:03:52 +00:00
|
|
|
i, queued, q->head, q->tail);
|
2020-04-19 20:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-20 09:11:48 +00:00
|
|
|
void mt76_seq_puts_array(struct seq_file *file, const char *str,
|
|
|
|
s8 *val, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
seq_printf(file, "%10s:", str);
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
seq_printf(file, " %2d", val[i]);
|
|
|
|
seq_puts(file, "\n");
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mt76_seq_puts_array);
|
|
|
|
|
2018-09-22 11:45:31 +00:00
|
|
|
static int mt76_read_rate_txpower(struct seq_file *s, void *data)
|
|
|
|
{
|
|
|
|
struct mt76_dev *dev = dev_get_drvdata(s->private);
|
|
|
|
|
|
|
|
mt76_seq_puts_array(s, "CCK", dev->rate_power.cck,
|
|
|
|
ARRAY_SIZE(dev->rate_power.cck));
|
|
|
|
mt76_seq_puts_array(s, "OFDM", dev->rate_power.ofdm,
|
|
|
|
ARRAY_SIZE(dev->rate_power.ofdm));
|
|
|
|
mt76_seq_puts_array(s, "STBC", dev->rate_power.stbc,
|
|
|
|
ARRAY_SIZE(dev->rate_power.stbc));
|
|
|
|
mt76_seq_puts_array(s, "HT", dev->rate_power.ht,
|
|
|
|
ARRAY_SIZE(dev->rate_power.ht));
|
|
|
|
mt76_seq_puts_array(s, "VHT", dev->rate_power.vht,
|
|
|
|
ARRAY_SIZE(dev->rate_power.vht));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-08 19:11:49 +00:00
|
|
|
struct dentry *
|
2021-10-11 10:38:27 +00:00
|
|
|
mt76_register_debugfs_fops(struct mt76_phy *phy,
|
2021-08-08 19:11:49 +00:00
|
|
|
const struct file_operations *ops)
|
2017-11-21 09:50:52 +00:00
|
|
|
{
|
2021-08-08 19:11:49 +00:00
|
|
|
const struct file_operations *fops = ops ? ops : &fops_regval;
|
2021-10-11 10:38:27 +00:00
|
|
|
struct mt76_dev *dev = phy->dev;
|
2017-11-21 09:50:52 +00:00
|
|
|
struct dentry *dir;
|
|
|
|
|
2021-10-11 10:38:27 +00:00
|
|
|
dir = debugfs_create_dir("mt76", phy->hw->wiphy->debugfsdir);
|
2017-11-21 09:50:52 +00:00
|
|
|
if (!dir)
|
|
|
|
return NULL;
|
|
|
|
|
2018-03-23 22:54:37 +00:00
|
|
|
debugfs_create_u8("led_pin", 0600, dir, &dev->led_pin);
|
|
|
|
debugfs_create_u32("regidx", 0600, dir, &dev->debugfs_reg);
|
2021-08-08 19:11:49 +00:00
|
|
|
debugfs_create_file_unsafe("regval", 0600, dir, dev, fops);
|
2021-03-15 21:49:15 +00:00
|
|
|
debugfs_create_file_unsafe("napi_threaded", 0600, dir, dev,
|
|
|
|
&fops_napi_threaded);
|
2018-03-23 22:54:37 +00:00
|
|
|
debugfs_create_blob("eeprom", 0400, dir, &dev->eeprom);
|
2017-11-21 09:50:52 +00:00
|
|
|
if (dev->otp.data)
|
2018-03-23 22:54:37 +00:00
|
|
|
debugfs_create_blob("otp", 0400, dir, &dev->otp);
|
2018-09-22 11:45:31 +00:00
|
|
|
debugfs_create_devm_seqfile(dev->dev, "rate_txpower", dir,
|
|
|
|
mt76_read_rate_txpower);
|
2020-04-19 20:11:41 +00:00
|
|
|
debugfs_create_devm_seqfile(dev->dev, "rx-queues", dir,
|
|
|
|
mt76_rx_queues_read);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
return dir;
|
|
|
|
}
|
2021-08-08 19:11:49 +00:00
|
|
|
EXPORT_SYMBOL_GPL(mt76_register_debugfs_fops);
|