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 static ssize_t
ath10k_dbg_sta_read_aggr_mode(struct file
*file
,
22 char __user
*user_buf
,
23 size_t count
, loff_t
*ppos
)
25 struct ieee80211_sta
*sta
= file
->private_data
;
26 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
27 struct ath10k
*ar
= arsta
->arvif
->ar
;
31 mutex_lock(&ar
->conf_mutex
);
32 len
= scnprintf(buf
, sizeof(buf
) - len
, "aggregation mode: %s\n",
33 (arsta
->aggr_mode
== ATH10K_DBG_AGGR_MODE_AUTO
) ?
35 mutex_unlock(&ar
->conf_mutex
);
37 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
40 static ssize_t
ath10k_dbg_sta_write_aggr_mode(struct file
*file
,
41 const char __user
*user_buf
,
42 size_t count
, loff_t
*ppos
)
44 struct ieee80211_sta
*sta
= file
->private_data
;
45 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
46 struct ath10k
*ar
= arsta
->arvif
->ar
;
50 if (kstrtouint_from_user(user_buf
, count
, 0, &aggr_mode
))
53 if (aggr_mode
>= ATH10K_DBG_AGGR_MODE_MAX
)
56 mutex_lock(&ar
->conf_mutex
);
57 if ((ar
->state
!= ATH10K_STATE_ON
) ||
58 (aggr_mode
== arsta
->aggr_mode
)) {
63 ret
= ath10k_wmi_addba_clear_resp(ar
, arsta
->arvif
->vdev_id
, sta
->addr
);
65 ath10k_warn(ar
, "failed to clear addba session ret: %d\n", ret
);
69 arsta
->aggr_mode
= aggr_mode
;
71 mutex_unlock(&ar
->conf_mutex
);
75 static const struct file_operations fops_aggr_mode
= {
76 .read
= ath10k_dbg_sta_read_aggr_mode
,
77 .write
= ath10k_dbg_sta_write_aggr_mode
,
80 .llseek
= default_llseek
,
83 static ssize_t
ath10k_dbg_sta_write_addba(struct file
*file
,
84 const char __user
*user_buf
,
85 size_t count
, loff_t
*ppos
)
87 struct ieee80211_sta
*sta
= file
->private_data
;
88 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
89 struct ath10k
*ar
= arsta
->arvif
->ar
;
94 simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
, user_buf
, count
);
96 /* make sure that buf is null terminated */
97 buf
[sizeof(buf
) - 1] = '\0';
99 ret
= sscanf(buf
, "%u %u", &tid
, &buf_size
);
103 /* Valid TID values are 0 through 15 */
104 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
107 mutex_lock(&ar
->conf_mutex
);
108 if ((ar
->state
!= ATH10K_STATE_ON
) ||
109 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
114 ret
= ath10k_wmi_addba_send(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
117 ath10k_warn(ar
, "failed to send addba request: vdev_id %u peer %pM tid %u buf_size %u\n",
118 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, buf_size
);
123 mutex_unlock(&ar
->conf_mutex
);
127 static const struct file_operations fops_addba
= {
128 .write
= ath10k_dbg_sta_write_addba
,
130 .owner
= THIS_MODULE
,
131 .llseek
= default_llseek
,
134 static ssize_t
ath10k_dbg_sta_write_addba_resp(struct file
*file
,
135 const char __user
*user_buf
,
136 size_t count
, loff_t
*ppos
)
138 struct ieee80211_sta
*sta
= file
->private_data
;
139 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
140 struct ath10k
*ar
= arsta
->arvif
->ar
;
145 simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
, user_buf
, count
);
147 /* make sure that buf is null terminated */
148 buf
[sizeof(buf
) - 1] = '\0';
150 ret
= sscanf(buf
, "%u %u", &tid
, &status
);
154 /* Valid TID values are 0 through 15 */
155 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
158 mutex_lock(&ar
->conf_mutex
);
159 if ((ar
->state
!= ATH10K_STATE_ON
) ||
160 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
165 ret
= ath10k_wmi_addba_set_resp(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
168 ath10k_warn(ar
, "failed to send addba response: vdev_id %u peer %pM tid %u status%u\n",
169 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, status
);
173 mutex_unlock(&ar
->conf_mutex
);
177 static const struct file_operations fops_addba_resp
= {
178 .write
= ath10k_dbg_sta_write_addba_resp
,
180 .owner
= THIS_MODULE
,
181 .llseek
= default_llseek
,
184 static ssize_t
ath10k_dbg_sta_write_delba(struct file
*file
,
185 const char __user
*user_buf
,
186 size_t count
, loff_t
*ppos
)
188 struct ieee80211_sta
*sta
= file
->private_data
;
189 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
190 struct ath10k
*ar
= arsta
->arvif
->ar
;
191 u32 tid
, initiator
, reason
;
195 simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
, user_buf
, count
);
197 /* make sure that buf is null terminated */
198 buf
[sizeof(buf
) - 1] = '\0';
200 ret
= sscanf(buf
, "%u %u %u", &tid
, &initiator
, &reason
);
204 /* Valid TID values are 0 through 15 */
205 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
208 mutex_lock(&ar
->conf_mutex
);
209 if ((ar
->state
!= ATH10K_STATE_ON
) ||
210 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
215 ret
= ath10k_wmi_delba_send(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
216 tid
, initiator
, reason
);
218 ath10k_warn(ar
, "failed to send delba: vdev_id %u peer %pM tid %u initiator %u reason %u\n",
219 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, initiator
,
224 mutex_unlock(&ar
->conf_mutex
);
228 static const struct file_operations fops_delba
= {
229 .write
= ath10k_dbg_sta_write_delba
,
231 .owner
= THIS_MODULE
,
232 .llseek
= default_llseek
,
235 void ath10k_sta_add_debugfs(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
236 struct ieee80211_sta
*sta
, struct dentry
*dir
)
238 debugfs_create_file("aggr_mode", S_IRUGO
| S_IWUSR
, dir
, sta
,
240 debugfs_create_file("addba", S_IWUSR
, dir
, sta
, &fops_addba
);
241 debugfs_create_file("addba_resp", S_IWUSR
, dir
, sta
, &fops_addba_resp
);
242 debugfs_create_file("delba", S_IWUSR
, dir
, sta
, &fops_delba
);