2 * Copyright (c) 2014 Qualcomm Atheros, Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 void ath10k_sta_update_rx_duration(struct ath10k *ar, struct list_head *head)
22 { struct ieee80211_sta *sta;
23 struct ath10k_fw_stats_peer *peer;
24 struct ath10k_sta *arsta;
27 list_for_each_entry(peer, head, list) {
28 sta = ieee80211_find_sta_by_ifaddr(ar->hw, peer->peer_macaddr,
32 arsta = (struct ath10k_sta *)sta->drv_priv;
33 arsta->rx_duration += (u64)peer->rx_duration;
38 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
39 char __user *user_buf,
40 size_t count, loff_t *ppos)
42 struct ieee80211_sta *sta = file->private_data;
43 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
44 struct ath10k *ar = arsta->arvif->ar;
48 mutex_lock(&ar->conf_mutex);
49 len = scnprintf(buf, sizeof(buf) - len, "aggregation mode: %s\n",
50 (arsta->aggr_mode == ATH10K_DBG_AGGR_MODE_AUTO) ?
52 mutex_unlock(&ar->conf_mutex);
54 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
57 static ssize_t ath10k_dbg_sta_write_aggr_mode(struct file *file,
58 const char __user *user_buf,
59 size_t count, loff_t *ppos)
61 struct ieee80211_sta *sta = file->private_data;
62 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
63 struct ath10k *ar = arsta->arvif->ar;
67 if (kstrtouint_from_user(user_buf, count, 0, &aggr_mode))
70 if (aggr_mode >= ATH10K_DBG_AGGR_MODE_MAX)
73 mutex_lock(&ar->conf_mutex);
74 if ((ar->state != ATH10K_STATE_ON) ||
75 (aggr_mode == arsta->aggr_mode)) {
80 ret = ath10k_wmi_addba_clear_resp(ar, arsta->arvif->vdev_id, sta->addr);
82 ath10k_warn(ar, "failed to clear addba session ret: %d\n", ret);
86 arsta->aggr_mode = aggr_mode;
88 mutex_unlock(&ar->conf_mutex);
92 static const struct file_operations fops_aggr_mode = {
93 .read = ath10k_dbg_sta_read_aggr_mode,
94 .write = ath10k_dbg_sta_write_aggr_mode,
97 .llseek = default_llseek,
100 static ssize_t ath10k_dbg_sta_write_addba(struct file *file,
101 const char __user *user_buf,
102 size_t count, loff_t *ppos)
104 struct ieee80211_sta *sta = file->private_data;
105 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
106 struct ath10k *ar = arsta->arvif->ar;
111 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
113 /* make sure that buf is null terminated */
114 buf[sizeof(buf) - 1] = '\0';
116 ret = sscanf(buf, "%u %u", &tid, &buf_size);
120 /* Valid TID values are 0 through 15 */
121 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
124 mutex_lock(&ar->conf_mutex);
125 if ((ar->state != ATH10K_STATE_ON) ||
126 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
131 ret = ath10k_wmi_addba_send(ar, arsta->arvif->vdev_id, sta->addr,
134 ath10k_warn(ar, "failed to send addba request: vdev_id %u peer %pM tid %u buf_size %u\n",
135 arsta->arvif->vdev_id, sta->addr, tid, buf_size);
140 mutex_unlock(&ar->conf_mutex);
144 static const struct file_operations fops_addba = {
145 .write = ath10k_dbg_sta_write_addba,
147 .owner = THIS_MODULE,
148 .llseek = default_llseek,
151 static ssize_t ath10k_dbg_sta_write_addba_resp(struct file *file,
152 const char __user *user_buf,
153 size_t count, loff_t *ppos)
155 struct ieee80211_sta *sta = file->private_data;
156 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
157 struct ath10k *ar = arsta->arvif->ar;
162 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
164 /* make sure that buf is null terminated */
165 buf[sizeof(buf) - 1] = '\0';
167 ret = sscanf(buf, "%u %u", &tid, &status);
171 /* Valid TID values are 0 through 15 */
172 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
175 mutex_lock(&ar->conf_mutex);
176 if ((ar->state != ATH10K_STATE_ON) ||
177 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
182 ret = ath10k_wmi_addba_set_resp(ar, arsta->arvif->vdev_id, sta->addr,
185 ath10k_warn(ar, "failed to send addba response: vdev_id %u peer %pM tid %u status%u\n",
186 arsta->arvif->vdev_id, sta->addr, tid, status);
190 mutex_unlock(&ar->conf_mutex);
194 static const struct file_operations fops_addba_resp = {
195 .write = ath10k_dbg_sta_write_addba_resp,
197 .owner = THIS_MODULE,
198 .llseek = default_llseek,
201 static ssize_t ath10k_dbg_sta_write_delba(struct file *file,
202 const char __user *user_buf,
203 size_t count, loff_t *ppos)
205 struct ieee80211_sta *sta = file->private_data;
206 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
207 struct ath10k *ar = arsta->arvif->ar;
208 u32 tid, initiator, reason;
212 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
214 /* make sure that buf is null terminated */
215 buf[sizeof(buf) - 1] = '\0';
217 ret = sscanf(buf, "%u %u %u", &tid, &initiator, &reason);
221 /* Valid TID values are 0 through 15 */
222 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
225 mutex_lock(&ar->conf_mutex);
226 if ((ar->state != ATH10K_STATE_ON) ||
227 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
232 ret = ath10k_wmi_delba_send(ar, arsta->arvif->vdev_id, sta->addr,
233 tid, initiator, reason);
235 ath10k_warn(ar, "failed to send delba: vdev_id %u peer %pM tid %u initiator %u reason %u\n",
236 arsta->arvif->vdev_id, sta->addr, tid, initiator,
241 mutex_unlock(&ar->conf_mutex);
245 static const struct file_operations fops_delba = {
246 .write = ath10k_dbg_sta_write_delba,
248 .owner = THIS_MODULE,
249 .llseek = default_llseek,
252 static ssize_t ath10k_dbg_sta_read_rx_duration(struct file *file,
253 char __user *user_buf,
254 size_t count, loff_t *ppos)
256 struct ieee80211_sta *sta = file->private_data;
257 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
261 len = scnprintf(buf, sizeof(buf),
262 "%llu usecs\n", arsta->rx_duration);
264 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
267 static const struct file_operations fops_rx_duration = {
268 .read = ath10k_dbg_sta_read_rx_duration,
270 .owner = THIS_MODULE,
271 .llseek = default_llseek,
274 void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
275 struct ieee80211_sta *sta, struct dentry *dir)
277 debugfs_create_file("aggr_mode", S_IRUGO | S_IWUSR, dir, sta,
279 debugfs_create_file("addba", S_IWUSR, dir, sta, &fops_addba);
280 debugfs_create_file("addba_resp", S_IWUSR, dir, sta, &fops_addba_resp);
281 debugfs_create_file("delba", S_IWUSR, dir, sta, &fops_delba);
282 debugfs_create_file("rx_duration", S_IRUGO, dir, sta,