drivers/net/wireless/ath/ath12k/debugfs_sta.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath12k/debugfs_sta.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/ath12k/debugfs_sta.c
Extension
.c
Size
9676 bytes
Lines
324
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations fops_rx_stats = {
	.read = ath12k_dbg_sta_dump_rx_stats,
	.open = simple_open,
	.owner = THIS_MODULE,
	.llseek = default_llseek,
};

static ssize_t ath12k_dbg_sta_reset_rx_stats(struct file *file,
					     const char __user *buf,
					     size_t count, loff_t *ppos)
{
	struct ieee80211_link_sta *link_sta = file->private_data;
	struct ath12k_sta *ahsta = ath12k_sta_to_ahsta(link_sta->sta);
	struct ath12k_hw *ah = ahsta->ahvif->ah;
	u8 link_id = link_sta->link_id;
	struct ath12k_link_sta *arsta;
	struct ath12k_dp *dp;
	bool reset;
	int ret;

	ret = kstrtobool_from_user(buf, count, &reset);
	if (ret)
		return ret;

	if (!reset)
		return -EINVAL;

	wiphy_lock(ah->hw->wiphy);

	if (!(BIT(link_id) & ahsta->links_map)) {
		ret = -ENOENT;
		goto out;
	}

	arsta = wiphy_dereference(ah->hw->wiphy, ahsta->link[link_id]);
	if (!arsta || !arsta->arvif->ar) {
		ret = -ENOENT;
		goto out;
	}

	dp = ath12k_ab_to_dp(arsta->arvif->ar->ab);

	ath12k_dp_link_peer_reset_rx_stats(dp, arsta->addr);

	ret = count;
out:
	wiphy_unlock(ah->hw->wiphy);
	return ret;
}

static const struct file_operations fops_reset_rx_stats = {
	.write = ath12k_dbg_sta_reset_rx_stats,
	.open = simple_open,
	.owner = THIS_MODULE,
	.llseek = default_llseek,
};

void ath12k_debugfs_link_sta_op_add(struct ieee80211_hw *hw,
				    struct ieee80211_vif *vif,
				    struct ieee80211_link_sta *link_sta,
				    struct dentry *dir)
{
	struct ath12k *ar;

	lockdep_assert_wiphy(hw->wiphy);

	ar = ath12k_get_ar_by_vif(hw, vif, link_sta->link_id);
	if (!ar)
		return;

	if (ath12k_debugfs_is_extd_rx_stats_enabled(ar)) {
		debugfs_create_file("rx_stats", 0400, dir, link_sta,
				    &fops_rx_stats);
		debugfs_create_file("reset_rx_stats", 0200, dir, link_sta,
				    &fops_reset_rx_stats);
	}
}
EXPORT_SYMBOL(ath12k_debugfs_link_sta_op_add);

Annotation

Implementation Notes