30 #define DRV_PKT_DELAY_TO_FW_MAX 512
33 #define WMM_QUEUED_PACKET_LOWER_LIMIT 180
35 #define WMM_QUEUED_PACKET_UPPER_LIMIT 200
38 #define IPTOS_OFFSET 5
42 0x00, 0x50, 0xf2, 0x02,
46 static const u8 wmm_aci_to_qidx_map[] = {
WMM_AC_BE,
52 static u8 tos_to_tid[] = {
69 static u8 tos_to_tid_inv[] = {
79 static u8 ac_to_tid[4][2] = { {1, 2}, {0, 3}, {4, 5}, {6, 7} };
87 const char *ac_str[] = {
"BK",
"BE",
"VI",
"VO" };
89 pr_debug(
"info: WMM AC_%s: ACI=%d, ACM=%d, Aifsn=%d, "
90 "EcwMin=%d, EcwMax=%d, TxopLimit=%d\n",
114 dev_err(adapter->
dev,
"%s: failed to alloc ra_list\n",
118 INIT_LIST_HEAD(&ra_list->
list);
119 skb_queue_head_init(&ra_list->
skb_head);
125 dev_dbg(adapter->
dev,
"info: allocated ra_list %p\n", ra_list);
133 static u8 mwifiex_get_random_ba_threshold(
void)
145 sec = (ba_tstamp.tv_sec & 0xFFFF) + (ba_tstamp.tv_sec >> 16);
146 usec = (ba_tstamp.tv_usec & 0xFFFF) + (ba_tstamp.tv_usec >> 16);
171 ra_list = mwifiex_wmm_allocate_ralist_node(adapter, ra);
172 dev_dbg(adapter->
dev,
"info: created ra_list %p\n", ra_list);
178 if (!mwifiex_queuing_ra_based(priv)) {
182 mwifiex_is_sta_11n_enabled(priv, node);
187 dev_dbg(adapter->
dev,
"data: ralist %p: is_11n_enabled=%d\n",
193 mwifiex_get_random_ba_threshold();
196 &priv->
wmm.tid_tbl_ptr[i].ra_list);
198 if (!priv->
wmm.tid_tbl_ptr[i].ra_list_curr)
199 priv->
wmm.tid_tbl_ptr[
i].ra_list_curr = ra_list;
224 for (i = 0; i < 4; ++
i) {
225 tos_to_tid[7 - (i * 2)] = ac_to_tid[queue_priority[i]][1];
226 tos_to_tid[6 - (i * 2)] = ac_to_tid[queue_priority[i]][0];
230 tos_to_tid_inv[tos_to_tid[i]] = (
u8)
i;
248 mwifiex_wmm_default_queue_priorities(priv);
252 dev_dbg(priv->
adapter->dev,
"info: WMM Parameter IE: version=%d, "
253 "qos_info Parameter Set Count=%d, Reserved=%#x\n",
264 ac_idx = wmm_aci_to_qidx_map[(aci_aifsn &
MWIFIEX_ACI) >> 5];
265 priv->
wmm.queue_priority[ac_idx] = ac_idx;
266 tmp[ac_idx] = avg_back_off;
269 "info: WMM: CWmax=%d CWmin=%d Avg Back-off=%d\n",
271 cw_min, avg_back_off);
272 mwifiex_wmm_ac_debug_print(&wmm_ie->
ac_params[num_ac]);
276 for (i = 0; i < num_ac; i++) {
277 for (j = 1; j < num_ac -
i; j++) {
278 if (tmp[j - 1] > tmp[j]) {
279 swap(tmp[j - 1], tmp[j]);
280 swap(priv->
wmm.queue_priority[j - 1],
281 priv->
wmm.queue_priority[j]);
282 }
else if (tmp[j - 1] == tmp[j]) {
283 if (priv->
wmm.queue_priority[j - 1]
284 < priv->
wmm.queue_priority[j])
285 swap(priv->
wmm.queue_priority[j - 1],
286 priv->
wmm.queue_priority[j]);
291 mwifiex_wmm_queue_priorities_tid(&priv->
wmm);
308 ac_status = &priv->
wmm.ac_status[eval_ac];
324 for (down_ac =
WMM_AC_BK; down_ac < eval_ac; down_ac++) {
325 ac_status = &priv->
wmm.ac_status[down_ac];
345 "BK(0), BE(1), VI(2), VO(3)\n");
350 priv->
wmm.ac_down_graded_vals[ac_val] =
354 priv->
wmm.ac_down_graded_vals[ac_val]
355 = mwifiex_wmm_eval_downgrade_ac(priv,
358 "info: WMM: AC PRIO %d maps to %d\n",
359 ac_val, priv->
wmm.ac_down_graded_vals[ac_val]);
385 return tos_to_ac[tos];
400 ac = mwifiex_wmm_convert_tos_to_ac(priv->
adapter, tid);
401 ac_down = priv->
wmm.ac_down_graded_vals[
ac];
406 new_tid = ac_to_tid[ac_down][tid % 2];
421 for (j = 0; j < adapter->
priv_num; ++
j) {
422 priv = adapter->
priv[
j];
430 priv->
wmm.tid_tbl_ptr[
i].ra_list_curr =
NULL;
446 mwifiex_reset_11n_rx_seq_num(priv);
462 for (i = 0; i < adapter->
priv_num; ++
i) {
463 priv = adapter->
priv[
i];
485 skb_queue_walk_safe(&ra_list->
skb_head, skb, tmp)
502 mwifiex_wmm_del_pkts_in_ralist_node(priv, ra_list);
513 mwifiex_wmm_del_pkts_in_ralist(priv, &priv->wmm.tid_tbl_ptr[i].
523 static void mwifiex_wmm_delete_all_ralist(
struct mwifiex_private *priv)
530 "info: ra_list: freeing buf for tid %d\n", i);
532 &priv->
wmm.tid_tbl_ptr[i].ra_list,
538 INIT_LIST_HEAD(&priv->
wmm.tid_tbl_ptr[i].ra_list);
540 priv->
wmm.tid_tbl_ptr[
i].ra_list_curr =
NULL;
562 mwifiex_wmm_cleanup_queues(priv);
565 if (priv->
adapter->if_ops.cleanup_mpa_buf)
568 mwifiex_wmm_delete_all_ralist(priv);
569 memcpy(tos_to_tid, ac_to_tid,
sizeof(tos_to_tid));
571 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, flags);
605 ra_list = mwifiex_wmm_get_ralist_node(priv, tid, ra_addr);
610 return mwifiex_wmm_get_ralist_node(priv, tid, ra_addr);
625 if (rlist == ra_list)
652 dev_dbg(adapter->
dev,
"data: drop packet in disconnect\n");
661 tid_down = mwifiex_wmm_downgrade_tid(priv, tid);
666 if (!mwifiex_queuing_ra_based(priv) &&
667 !mwifiex_is_skb_mgmt_frame(skb)) {
668 if (!list_empty(&priv->
wmm.tid_tbl_ptr[tid_down].ra_list))
670 &priv->
wmm.tid_tbl_ptr[tid_down].ra_list,
676 if (ra[0] & 0x01 || mwifiex_is_skb_mgmt_frame(skb))
678 ra_list = mwifiex_wmm_get_queue_raptr(priv, tid_down, ra);
682 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, flags);
695 tos_to_tid_inv[tid_down])
697 tos_to_tid_inv[tid_down]);
699 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, flags);
725 dev_dbg(priv->
adapter->dev,
"info: WMM: WMM_GET_STATUS cmdresp received: %d\n",
738 "info: CMD_RESP: WMM_GET_STATUS:"
739 " QSTATUS TLV: %d, %d, %d\n",
744 ac_status = &priv->
wmm.ac_status[tlv_wmm_qstatus->
766 "info: CMD_RESP: WMM_GET_STATUS:"
767 " WMM Parameter Set Count: %d\n",
772 wmm_ie, wmm_param_ie,
818 "info: WMM: process assoc req: bss->wmm_ie=%#x\n",
836 ret_len =
sizeof(wmm_tlv->
header)
839 *assoc_buf += ret_len;
859 struct timeval out_tstamp, in_tstamp;
863 in_tstamp = ktime_to_timeval(skb->
tstamp);
865 queue_delay = (out_tstamp.
tv_sec - in_tstamp.
tv_sec) * 1000;
874 ret_val = (
u8) (
min(queue_delay, priv->
wmm.drv_pkt_delay_max) >> 1);
877 " %d ms sent to FW\n", queue_delay, ret_val);
898 for (j = adapter->
priv_num - 1; j >= 0; --j) {
903 spin_unlock_irqrestore(&adapter->
bss_prio_tbl[j].bss_prio_lock,
919 bssprio_head = bssprio_node;
922 priv_tmp = bssprio_node->
priv;
923 hqp = &priv_tmp->
wmm.highest_queued_prio;
927 tid_ptr = &(priv_tmp)->wmm.
928 tid_tbl_ptr[tos_to_tid[i]];
981 }
while (ptr != head);
1000 &bssprio_node->
list,
1003 }
while (bssprio_node != bssprio_head);
1011 spin_unlock_irqrestore(&priv_tmp->
wmm.ra_list_spinlock, flags);
1014 *tid = tos_to_tid[
i];
1035 max_amsdu_size = max_buf_size;
1037 skb_queue_walk_safe(&ptr->
skb_head, skb, tmp) {
1054 unsigned long ra_list_flags)
1062 if (skb_queue_empty(&ptr->
skb_head)) {
1063 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1065 dev_dbg(adapter->
dev,
"data: nothing to send\n");
1071 tx_info = MWIFIEX_SKB_TXCB(skb);
1072 dev_dbg(adapter->
dev,
"data: dequeuing the packet %p %p\n", ptr, skb);
1076 if (!skb_queue_empty(&ptr->
skb_head))
1077 skb_next = skb_peek(&ptr->
skb_head);
1081 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, ra_list_flags);
1083 tx_param.next_pkt_len = ((skb_next) ? skb_next->
len +
1084 sizeof(
struct txpd) : 0);
1091 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1102 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1107 priv->
wmm.packets_out[ptr_index]++;
1108 priv->
wmm.tid_tbl_ptr[ptr_index].ra_list_curr =
ptr;
1113 .bss_prio_cur->list,
1117 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1133 if (skb_queue_empty(&ptr->
skb_head))
1138 tx_info = MWIFIEX_SKB_TXCB(skb);
1152 unsigned long ra_list_flags)
1161 if (skb_queue_empty(&ptr->
skb_head)) {
1162 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1169 if (!skb_queue_empty(&ptr->
skb_head))
1170 skb_next = skb_peek(&ptr->
skb_head);
1174 tx_info = MWIFIEX_SKB_TXCB(skb);
1176 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, ra_list_flags);
1183 tx_param.next_pkt_len =
1184 ((skb_next) ? skb_next->
len +
1185 sizeof(
struct txpd) : 0);
1192 dev_dbg(adapter->
dev,
"data: -EBUSY is returned\n");
1196 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1205 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1210 dev_err(adapter->
dev,
"host_to_card failed: %#x\n", ret);
1211 adapter->
dbg.num_tx_host_to_card_failure++;
1219 if (ret != -
EBUSY) {
1222 priv->
wmm.packets_out[ptr_index]++;
1223 priv->
wmm.tid_tbl_ptr[ptr_index].ra_list_curr =
ptr;
1228 .bss_prio_cur->list,
1232 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock,
1248 int tid_del = 0, tid = 0;
1249 unsigned long flags;
1251 ptr = mwifiex_wmm_get_highest_priolist_ptr(adapter, &priv, &ptr_index);
1255 tid = mwifiex_get_tid(ptr);
1257 dev_dbg(adapter->
dev,
"data: tid=%d\n", tid);
1261 spin_unlock_irqrestore(&priv->
wmm.ra_list_spinlock, flags);
1265 if (mwifiex_is_ptr_processed(priv, ptr)) {
1266 mwifiex_send_processed_packet(priv, ptr, ptr_index, flags);
1273 mwifiex_is_ba_stream_setup(priv, ptr, tid) ||
1274 priv->
wps.session_enable ||
1278 mwifiex_send_single_packet(priv, ptr, ptr_index, flags);
1282 if (mwifiex_is_ampdu_allowed(priv, tid) &&
1284 if (mwifiex_space_avail_for_new_ba_stream(adapter)) {
1288 }
else if (mwifiex_find_stream_to_delete
1289 (priv, tid, &tid_del, ra)) {
1295 if (mwifiex_is_amsdu_allowed(priv, tid) &&
1296 mwifiex_is_11n_aggragation_possible(priv, ptr,
1303 mwifiex_send_single_packet(priv, ptr, ptr_index, flags);
1322 if (mwifiex_dequeue_tx_packet(adapter))