Lines Matching full:queue

306 static int iwl_mvm_invalidate_sta_queue(struct iwl_mvm *mvm, int queue,
319 sta_id = mvm->queue_info[queue].ra_sta_id;
347 /* Notify FW of queue removal from the STA queues */
357 int queue = *queueptr;
359 .scd_queue = queue,
387 iwl_trans_txq_free(mvm->trans, queue);
393 if (WARN_ON(mvm->queue_info[queue].tid_bitmap == 0))
396 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid);
398 cmd.action = mvm->queue_info[queue].tid_bitmap ?
401 mvm->queue_info[queue].status = IWL_MVM_QUEUE_FREE;
405 queue,
406 mvm->queue_info[queue].tid_bitmap);
408 /* If the queue is still enabled - nothing left to do in this func */
412 cmd.sta_id = mvm->queue_info[queue].ra_sta_id;
413 cmd.tid = mvm->queue_info[queue].txq_tid;
415 /* Make sure queue info is correct even though we overwrite it */
416 WARN(mvm->queue_info[queue].tid_bitmap,
418 queue, mvm->queue_info[queue].tid_bitmap);
420 /* If we are here - the queue is freed and we can zero out these vals */
421 mvm->queue_info[queue].tid_bitmap = 0;
435 mvm->queue_info[queue].reserved = false;
437 iwl_trans_txq_disable(mvm->trans, queue, false);
442 IWL_ERR(mvm, "Failed to disable queue %d (ret=%d)\n",
443 queue, ret);
447 static int iwl_mvm_get_queue_agg_tids(struct iwl_mvm *mvm, int queue)
461 sta_id = mvm->queue_info[queue].ra_sta_id;
462 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
483 * Remove a queue from a station's resources.
485 * doesn't disable the queue
487 static int iwl_mvm_remove_sta_queue_marking(struct iwl_mvm *mvm, int queue)
501 sta_id = mvm->queue_info[queue].ra_sta_id;
502 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
516 /* Unmap MAC queues and TIDs from this queue */
532 mvmsta->tfd_queue_msk &= ~BIT(queue); /* Don't use this queue anymore */
543 * the queue while still sending frames to it.
550 static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
558 u16 queue_tmp = queue;
566 sta_id = mvm->queue_info[queue].ra_sta_id;
567 tid = mvm->queue_info[queue].txq_tid;
575 disable_agg_tids = iwl_mvm_remove_sta_queue_marking(mvm, queue);
576 /* Disable the queue */
578 iwl_mvm_invalidate_sta_queue(mvm, queue,
584 "Failed to free inactive queue %d (ret=%d)\n",
585 queue, ret);
592 iwl_mvm_invalidate_sta_queue(mvm, queue, 0, true);
600 int queue = 0;
605 * This protects us against grabbing a queue that's being reconfigured
626 * The queue to share is chosen only from DATA queues as follows (in
628 * 1. An AC_BE queue
629 * 2. Same AC queue
630 * 3. Highest AC queue that is lower than new AC
631 * 4. Any existing AC (there always is at least 1 DATA queue)
634 /* Priority 1: An AC_BE queue */
636 queue = ac_to_queue[IEEE80211_AC_BE];
637 /* Priority 2: Same AC queue */
639 queue = ac_to_queue[ac];
643 queue = ac_to_queue[IEEE80211_AC_VI];
646 queue = ac_to_queue[IEEE80211_AC_BK];
649 queue = ac_to_queue[IEEE80211_AC_VI];
652 queue = ac_to_queue[IEEE80211_AC_VO];
654 /* Make sure queue found (or not) is legal */
655 if (!iwl_mvm_is_dqa_data_queue(mvm, queue) &&
656 !iwl_mvm_is_dqa_mgmt_queue(mvm, queue) &&
657 (queue != IWL_MVM_DQA_BSS_CLIENT_QUEUE)) {
662 return queue;
665 /* Re-configure the SCD for a queue that has already been configured */
666 static int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo,
670 .scd_queue = queue,
676 .aggregate = (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE ||
677 queue == IWL_MVM_DQA_BSS_CLIENT_QUEUE),
685 if (WARN(mvm->queue_info[queue].tid_bitmap == 0,
686 "Trying to reconfig unallocated queue %d\n", queue))
689 IWL_DEBUG_TX_QUEUES(mvm, "Reconfig SCD for TXQ #%d\n", queue);
692 WARN_ONCE(ret, "Failed to re-configure queue %d on FIFO %d, ret=%d\n",
693 queue, fifo, ret);
699 * If a given queue has a higher AC than the TID stream that is being compared
700 * to, the queue needs to be redirected to the lower AC. This function does that
704 static int iwl_mvm_redirect_queue(struct iwl_mvm *mvm, int queue, int tid,
709 .scd_queue = queue,
720 * the lowest one of the streams in the queue. Check if this is needed
726 if (ac <= mvm->queue_info[queue].mac80211_ac && !force) {
729 queue);
733 cmd.sta_id = mvm->queue_info[queue].ra_sta_id;
734 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[mvm->queue_info[queue].mac80211_ac];
735 cmd.tid = mvm->queue_info[queue].txq_tid;
736 shared_queue = hweight16(mvm->queue_info[queue].tid_bitmap) > 1;
739 queue, iwl_mvm_ac_to_tx_fifo[ac]);
741 /* Stop the queue and wait for it to empty */
744 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(queue));
746 IWL_ERR(mvm, "Error draining queue %d before reconfig\n",
747 queue);
752 /* Before redirecting the queue we need to de-activate it */
753 iwl_trans_txq_disable(mvm->trans, queue, false);
756 IWL_ERR(mvm, "Failed SCD disable TXQ %d (ret=%d)\n", queue,
760 iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, NULL, wdg_timeout);
762 /* Update the TID "owner" of the queue */
763 mvm->queue_info[queue].txq_tid = tid;
768 iwl_mvm_reconfig_scd(mvm, queue, iwl_mvm_ac_to_tx_fifo[ac],
771 /* Update AC marking of the queue */
772 mvm->queue_info[queue].mac80211_ac = ac;
775 * Mark queue as shared in transport if shared
776 * Note this has to be done after queue enablement because enablement
781 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true);
784 /* Continue using the queue */
798 "max queue %d >= num_of_queues (%d)", maxq,
806 /* Start by looking for a free queue */
820 /* this queue isn't used for traffic (cab_queue) */
852 int queue, size;
887 queue = iwl_trans_txq_alloc(mvm->trans, 0, sta_mask,
890 if (queue >= 0)
893 queue, sta_mask, tid);
895 return queue;
907 int queue = -1;
912 "Allocating queue for sta %d on tid %d\n",
914 queue = iwl_mvm_tvqm_enable_txq(mvm, sta, mvmsta->deflink.sta_id,
916 if (queue < 0)
917 return queue;
919 mvmtxq->txq_id = queue;
920 mvm->tvqm_info[queue].txq_tid = tid;
921 mvm->tvqm_info[queue].sta_id = mvmsta->deflink.sta_id;
923 IWL_DEBUG_TX_QUEUES(mvm, "Allocated queue is %d\n", queue);
926 mvmsta->tid_data[tid].txq_id = queue;
934 int queue, u8 sta_id, u8 tid)
939 if (mvm->queue_info[queue].tid_bitmap & BIT(tid)) {
941 queue, tid);
946 if (mvm->queue_info[queue].tid_bitmap)
949 mvm->queue_info[queue].tid_bitmap |= BIT(tid);
950 mvm->queue_info[queue].ra_sta_id = sta_id;
954 mvm->queue_info[queue].mac80211_ac =
957 mvm->queue_info[queue].mac80211_ac = IEEE80211_AC_VO;
959 mvm->queue_info[queue].txq_tid = tid;
966 mvmtxq->txq_id = queue;
971 queue, mvm->queue_info[queue].tid_bitmap);
977 int queue, u16 ssn,
982 .scd_queue = queue,
997 if (!iwl_mvm_update_txq_mapping(mvm, sta, queue, cfg->sta_id, cfg->tid))
1000 inc_ssn = iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn,
1006 "Failed to configure queue %d on FIFO %d\n", queue, cfg->fifo);
1011 static void iwl_mvm_change_queue_tid(struct iwl_mvm *mvm, int queue)
1014 .scd_queue = queue,
1026 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
1028 if (WARN(!tid_bitmap, "TXQ %d has no tids assigned to it\n", queue))
1031 /* Find any TID for queue */
1039 queue, ret);
1043 mvm->queue_info[queue].txq_tid = tid;
1045 queue, tid);
1048 static void iwl_mvm_unshare_queue(struct iwl_mvm *mvm, int queue)
1059 /* queue sharing is disabled on new TX path */
1065 sta_id = mvm->queue_info[queue].ra_sta_id;
1066 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
1068 /* Find TID for queue, and make sure it is the only one on the queue */
1072 queue, tid_bitmap);
1076 IWL_DEBUG_TX_QUEUES(mvm, "Unsharing TXQ %d, keeping tid %d\n", queue,
1090 ret = iwl_mvm_redirect_queue(mvm, queue, tid,
1095 IWL_ERR(mvm, "Failed to redirect TXQ %d\n", queue);
1117 queue);
1119 /* Mark queue intenally as aggregating again */
1120 iwl_trans_txq_set_shared_mode(mvm->trans, queue, false);
1124 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY;
1128 * Remove inactive TIDs of a given queue.
1129 * If all queue TIDs are inactive - mark the queue as inactive
1130 * If only some the queue TIDs are inactive - unmap them from the queue
1132 * Returns %true if all TIDs were removed and the queue could be reused.
1135 struct iwl_mvm_sta *mvmsta, int queue,
1159 /* If all TIDs in the queue are inactive - return it can be reused */
1160 if (tid_bitmap == mvm->queue_info[queue].tid_bitmap) {
1161 IWL_DEBUG_TX_QUEUES(mvm, "Queue %d is inactive\n", queue);
1166 * If we are here, this is a shared queue and not all TIDs timed-out.
1173 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid);
1175 q_tid_bitmap = mvm->queue_info[queue].tid_bitmap;
1182 * This is mainly because if TID x continues - a new queue can't
1185 * Mark this queue in the right bitmap, we'll send the command
1188 if (!(q_tid_bitmap & BIT(mvm->queue_info[queue].txq_tid)))
1189 set_bit(queue, changetid_queues);
1193 tid, queue);
1197 "TXQ #%d left with tid bitmap 0x%x\n", queue,
1198 mvm->queue_info[queue].tid_bitmap);
1204 tid_bitmap = mvm->queue_info[queue].tid_bitmap;
1206 /* If the queue is marked as shared - "unshare" it */
1207 if (hweight16(mvm->queue_info[queue].tid_bitmap) == 1 &&
1208 mvm->queue_info[queue].status == IWL_MVM_QUEUE_SHARED) {
1210 queue);
1211 set_bit(queue, unshare_queues);
1218 * Check for inactivity - this includes checking if any queue
1224 * Returns the queue number, or -ENOSPC.
1241 /* we skip the CMD queue below by starting at 1 */
1261 /* Check to see if there are inactive TIDs on this queue */
1271 /* If all TIDs are active - finish check on this queue */
1276 * If we are here - the queue hadn't been served recently and is
1302 /* only unlock sta lock - we still need the queue info lock */
1337 int queue = -1;
1357 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id,
1360 if (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE)
1361 IWL_DEBUG_TX_QUEUES(mvm, "Found free MGMT queue #%d\n",
1362 queue);
1364 /* If no such queue is found, we'll use a DATA queue instead */
1367 if ((queue < 0 && mvmsta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) &&
1370 queue = mvmsta->reserved_queue;
1371 mvm->queue_info[queue].reserved = true;
1372 IWL_DEBUG_TX_QUEUES(mvm, "Using reserved queue #%d\n", queue);
1375 if (queue < 0)
1376 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id,
1379 if (queue < 0) {
1380 /* try harder - perhaps kill an inactive queue */
1381 queue = iwl_mvm_inactivity_check(mvm, mvmsta->deflink.sta_id);
1384 /* No free queue - we'll have to share */
1385 if (queue <= 0) {
1386 queue = iwl_mvm_get_shared_queue(mvm, tfd_queue_mask, ac);
1387 if (queue > 0) {
1389 mvm->queue_info[queue].status = IWL_MVM_QUEUE_SHARED;
1399 if (queue > 0 && !shared_queue)
1400 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY;
1403 if (WARN_ON(queue <= 0)) {
1406 return queue;
1411 * but for configuring the SCD to send A-MPDUs we need to mark the queue
1415 cfg.aggregate = (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE ||
1416 queue == IWL_MVM_DQA_BSS_CLIENT_QUEUE);
1420 shared_queue ? "shared " : "", queue,
1424 /* Disable any open aggs on this queue */
1425 disable_agg_tids = iwl_mvm_get_queue_agg_tids(mvm, queue);
1428 IWL_DEBUG_TX_QUEUES(mvm, "Disabling aggs on queue %d\n",
1429 queue);
1430 iwl_mvm_invalidate_sta_queue(mvm, queue,
1435 inc_ssn = iwl_mvm_enable_txq(mvm, sta, queue, ssn, &cfg, wdg_timeout);
1438 * Mark queue as shared in transport if shared
1439 * Note this has to be done after queue enablement because enablement
1444 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true);
1450 * need to allocate a new TFD queue.
1456 mvmsta->tid_data[tid].txq_id = queue;
1457 mvmsta->tfd_queue_msk |= BIT(queue);
1460 if (mvmsta->reserved_queue == queue)
1471 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true);
1476 /* Redirect queue, if needed */
1477 ret = iwl_mvm_redirect_queue(mvm, queue, tid, ac, ssn,
1487 queue_tmp = queue;
1548 * a queue in the function itself.
1579 int queue;
1581 /* queue reserving is disabled on new TX path */
1593 queue = IWL_MVM_DQA_BSS_CLIENT_QUEUE;
1595 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id,
1598 if (queue < 0) {
1599 /* try again - this time kick out a queue if needed */
1600 queue = iwl_mvm_inactivity_check(mvm, mvmsta->deflink.sta_id);
1601 if (queue < 0) {
1606 mvm->queue_info[queue].status = IWL_MVM_QUEUE_RESERVED;
1608 mvmsta->reserved_queue = queue;
1610 IWL_DEBUG_TX_QUEUES(mvm, "Reserving data queue #%d for sta_id %d\n",
1611 queue, mvmsta->deflink.sta_id);
1619 * does the re-mapping and queue allocation.
1635 /* Make sure reserved queue is still marked as such (if allocated) */
1683 "Re-mapping sta %d tid %d to queue %d\n",
1784 * frames until the queue is allocated
1884 * a queue requires a valid station
2202 static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 queue,
2217 iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg, wdg_timeout);
2234 u16 *queue, int fifo)
2238 /* Map queue to fifo - needs to happen before adding station */
2240 iwl_mvm_enable_aux_snif_queue(mvm, *queue, sta->sta_id, fifo);
2245 iwl_mvm_disable_txq(mvm, NULL, sta->sta_id, queue,
2251 * For 22000 firmware and on we cannot add queue to a station unknown
2252 * to firmware so enable queue here - after the station was added
2263 *queue = txq;
2277 /* Allocate aux station and assign to it the aux queue */
2367 int queue;
2384 queue = mvm->probe_queue;
2386 queue = mvm->p2p_dev_queue;
2392 bsta->tfd_queue_msk |= BIT(queue);
2394 iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg, wdg_timeout);
2409 * For 22000 firmware and on we cannot add queue to a station unknown
2410 * to firmware so enable queue here - after the station was added
2413 queue = iwl_mvm_tvqm_enable_txq(mvm, NULL, bsta->sta_id,
2416 if (queue < 0) {
2418 return queue;
2423 /* for queue management */
2424 mvm->probe_queue = queue;
2426 mvmvif->deflink.mgmt_queue = queue;
2428 mvm->p2p_dev_queue = queue;
2443 u16 *queueptr, queue;
2459 WARN(1, "Can't free bcast queue on vif type %d\n",
2464 queue = *queueptr;
2474 WARN_ON(!(mvmvif->deflink.bcast_sta.tfd_queue_msk & BIT(queue)));
2475 mvmvif->deflink.bcast_sta.tfd_queue_msk &= ~BIT(queue);
2590 * invalid, so make sure we use the queue we want.
2598 * While in previous FWs we had to exclude cab queue from TFD queue
2599 * mask, now it is needed as any other queue.
2614 * Enable cab queue after the ADD_STA command is sent.
2617 * station API since the cab queue is not included in the
2621 int queue = iwl_mvm_tvqm_enable_txq(mvm, NULL, msta->sta_id,
2623 if (queue < 0) {
2624 ret = queue;
2627 mvmvif->deflink.cab_queue = queue;
2777 reorder_buf->queue = i;
2932 * line for each queue, to avoid sharing cache lines between
3037 int tid, u8 queue, bool start)
3047 mvm_sta->tfd_queue_msk |= BIT(queue);
3050 /* In DQA-mode the queue isn't removed on agg termination */
3151 IWL_ERR(mvm, "Failed to allocate agg queue\n");
3169 "Can't start tid %d agg on shared queue!\n",
3175 "AGG for tid %d will be on queue #%d\n",
3184 "Start AGG: sta %d tid %d queue %d - ssn = %d, next_recl = %d\n",
3219 int queue, ret;
3243 queue = tid_data->txq_id;
3252 * If there is no queue for this tid, iwl_mvm_sta_tx_agg_start()
3254 * allocate a queue.
3265 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true);
3273 queue_status = mvm->queue_info[queue].status;
3275 /* Maybe there is no need to even alloc a queue... */
3276 if (mvm->queue_info[queue].status == IWL_MVM_QUEUE_READY)
3280 * Only reconfig the SCD for the queue if the window size has
3285 * If reconfiguring an existing queue, it first must be
3289 BIT(queue));
3292 "Error draining queue before reconfig\n");
3296 ret = iwl_mvm_reconfig_scd(mvm, queue, cfg.fifo,
3301 "Error reconfiguring TXQ #%d\n", queue);
3307 iwl_mvm_enable_txq(mvm, sta, queue, ssn,
3310 /* Send ADD_STA command to enable aggs only if the queue isn't shared */
3312 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true);
3318 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY;
3354 * we no longer have use for the queue. Since it hasn't even been
3467 IWL_ERR(mvm, "Couldn't flush the AGG queue\n");
3471 IWL_ERR(mvm, "Couldn't flush the AGG queue\n");
4335 u16 queue;
4350 &queue,
4356 &queue,
4427 bool tx, int queue)
4445 queue_counter = &mvm_sta->mpdu_counters[queue];