Lines Matching refs:trans
26 static void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans *trans, in iwl_pcie_gen2_update_byte_tbl() argument
50 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { in iwl_pcie_gen2_update_byte_tbl()
54 WARN_ON(trans->txqs.bc_table_dword); in iwl_pcie_gen2_update_byte_tbl()
62 WARN_ON(!trans->txqs.bc_table_dword); in iwl_pcie_gen2_update_byte_tbl()
73 void iwl_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_inc_wr_ptr() argument
77 IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq->id, txq->write_ptr); in iwl_txq_inc_wr_ptr()
83 iwl_write32(trans, HBUS_TARG_WRPTR, txq->write_ptr | (txq->id << 16)); in iwl_txq_inc_wr_ptr()
86 static u8 iwl_txq_gen2_get_num_tbs(struct iwl_trans *trans, in iwl_txq_gen2_get_num_tbs() argument
92 void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, struct iwl_cmd_meta *meta, in iwl_txq_gen2_tfd_unmap() argument
98 num_tbs = iwl_txq_gen2_get_num_tbs(trans, tfd); in iwl_txq_gen2_tfd_unmap()
100 if (num_tbs > trans->txqs.tfd.max_tbs) { in iwl_txq_gen2_tfd_unmap()
101 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); in iwl_txq_gen2_tfd_unmap()
108 dma_unmap_page(trans->dev, in iwl_txq_gen2_tfd_unmap()
113 dma_unmap_single(trans->dev, in iwl_txq_gen2_tfd_unmap()
122 void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_gen2_free_tfd() argument
135 iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, in iwl_txq_gen2_free_tfd()
136 iwl_txq_get_tfd(trans, txq, idx)); in iwl_txq_gen2_free_tfd()
145 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_gen2_free_tfd()
150 int iwl_txq_gen2_set_tb(struct iwl_trans *trans, struct iwl_tfh_tfd *tfd, in iwl_txq_gen2_set_tb() argument
153 int idx = iwl_txq_gen2_get_num_tbs(trans, tfd); in iwl_txq_gen2_set_tb()
172 if (le16_to_cpu(tfd->num_tbs) >= trans->txqs.tfd.max_tbs) { in iwl_txq_gen2_set_tb()
173 IWL_ERR(trans, "Error can not send more than %d chunks\n", in iwl_txq_gen2_set_tb()
174 trans->txqs.tfd.max_tbs); in iwl_txq_gen2_set_tb()
186 static struct page *get_workaround_page(struct iwl_trans *trans, in get_workaround_page() argument
192 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in get_workaround_page()
211 static int iwl_txq_gen2_set_tb_with_wa(struct iwl_trans *trans, in iwl_txq_gen2_set_tb_with_wa() argument
221 if (unlikely(dma_mapping_error(trans->dev, phys))) in iwl_txq_gen2_set_tb_with_wa()
225 ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); in iwl_txq_gen2_set_tb_with_wa()
251 page = get_workaround_page(trans, skb); in iwl_txq_gen2_set_tb_with_wa()
259 phys = dma_map_single(trans->dev, page_address(page), len, in iwl_txq_gen2_set_tb_with_wa()
261 if (unlikely(dma_mapping_error(trans->dev, phys))) in iwl_txq_gen2_set_tb_with_wa()
263 ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); in iwl_txq_gen2_set_tb_with_wa()
270 IWL_WARN(trans, in iwl_txq_gen2_set_tb_with_wa()
277 dma_unmap_page(trans->dev, oldphys, len, DMA_TO_DEVICE); in iwl_txq_gen2_set_tb_with_wa()
279 dma_unmap_single(trans->dev, oldphys, len, DMA_TO_DEVICE); in iwl_txq_gen2_set_tb_with_wa()
281 trace_iwlwifi_dev_tx_tb(trans->dev, skb, virt, phys, len); in iwl_txq_gen2_set_tb_with_wa()
287 struct iwl_tso_hdr_page *get_page_hdr(struct iwl_trans *trans, size_t len, in get_page_hdr() argument
290 struct iwl_tso_hdr_page *p = this_cpu_ptr(trans->txqs.tso_hdr_page); in get_page_hdr()
293 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in get_page_hdr()
332 static int iwl_txq_gen2_build_amsdu(struct iwl_trans *trans, in iwl_txq_gen2_build_amsdu() argument
348 trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), in iwl_txq_gen2_build_amsdu()
361 hdr_page = get_page_hdr(trans, hdr_room, skb); in iwl_txq_gen2_build_amsdu()
413 tb_phys = dma_map_single(trans->dev, start_hdr, in iwl_txq_gen2_build_amsdu()
415 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_amsdu()
422 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb_len); in iwl_txq_gen2_build_amsdu()
423 trace_iwlwifi_dev_tx_tb(trans->dev, skb, start_hdr, in iwl_txq_gen2_build_amsdu()
436 tb_phys = dma_map_single(trans->dev, tso.data, in iwl_txq_gen2_build_amsdu()
438 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, in iwl_txq_gen2_build_amsdu()
460 iwl_tfh_tfd *iwl_txq_gen2_build_tx_amsdu(struct iwl_trans *trans, in iwl_txq_gen2_build_tx_amsdu() argument
469 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tx_amsdu()
481 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); in iwl_txq_gen2_build_tx_amsdu()
496 tb_phys = dma_map_single(trans->dev, tb1_addr, len, DMA_TO_DEVICE); in iwl_txq_gen2_build_tx_amsdu()
497 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_tx_amsdu()
503 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, len); in iwl_txq_gen2_build_tx_amsdu()
505 if (iwl_txq_gen2_build_amsdu(trans, skb, tfd, len + IWL_FIRST_TB_SIZE, in iwl_txq_gen2_build_tx_amsdu()
514 iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); in iwl_txq_gen2_build_tx_amsdu()
518 static int iwl_txq_gen2_tx_add_frags(struct iwl_trans *trans, in iwl_txq_gen2_tx_add_frags() argument
534 tb_phys = skb_frag_dma_map(trans->dev, frag, 0, in iwl_txq_gen2_tx_add_frags()
536 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_tx_add_frags()
547 iwl_tfh_tfd *iwl_txq_gen2_build_tx(struct iwl_trans *trans, in iwl_txq_gen2_build_tx() argument
557 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tx()
573 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); in iwl_txq_gen2_build_tx()
591 tb_phys = dma_map_single(trans->dev, tb1_addr, tb1_len, DMA_TO_DEVICE); in iwl_txq_gen2_build_tx()
592 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_tx()
598 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb1_len); in iwl_txq_gen2_build_tx()
599 trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), &dev_cmd->hdr, in iwl_txq_gen2_build_tx()
608 tb_phys = dma_map_single(trans->dev, skb->data + hdr_len, in iwl_txq_gen2_build_tx()
610 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_build_tx()
617 if (iwl_txq_gen2_tx_add_frags(trans, skb, tfd, out_meta)) in iwl_txq_gen2_build_tx()
623 tb_phys = dma_map_single(trans->dev, frag->data, in iwl_txq_gen2_build_tx()
625 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_build_tx()
630 if (iwl_txq_gen2_tx_add_frags(trans, frag, tfd, out_meta)) in iwl_txq_gen2_build_tx()
637 iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); in iwl_txq_gen2_build_tx()
642 struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans, in iwl_txq_gen2_build_tfd() argument
650 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tfd()
666 if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) in iwl_txq_gen2_build_tfd()
683 return iwl_txq_gen2_build_tx_amsdu(trans, txq, dev_cmd, skb, in iwl_txq_gen2_build_tfd()
685 return iwl_txq_gen2_build_tx(trans, txq, dev_cmd, skb, out_meta, in iwl_txq_gen2_build_tfd()
689 int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q) in iwl_txq_space() argument
700 if (q->n_window < trans->trans_cfg->base_params->max_tfd_queue_size) in iwl_txq_space()
703 max = trans->trans_cfg->base_params->max_tfd_queue_size - 1; in iwl_txq_space()
710 (trans->trans_cfg->base_params->max_tfd_queue_size - 1); in iwl_txq_space()
718 int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, in iwl_txq_gen2_tx() argument
722 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_tx()
731 if (WARN_ONCE(!test_bit(txq_id, trans->txqs.queue_used), in iwl_txq_gen2_tx()
736 skb_shinfo(skb)->nr_frags > IWL_TRANS_MAX_FRAGS(trans) && in iwl_txq_gen2_tx()
742 if (iwl_txq_space(trans, txq) < txq->high_mark) { in iwl_txq_gen2_tx()
743 iwl_txq_stop(trans, txq); in iwl_txq_gen2_tx()
746 if (unlikely(iwl_txq_space(trans, txq) < 3)) { in iwl_txq_gen2_tx()
750 trans->txqs.dev_cmd_offs); in iwl_txq_gen2_tx()
773 tfd = iwl_txq_gen2_build_tfd(trans, txq, dev_cmd, skb, out_meta); in iwl_txq_gen2_tx()
779 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { in iwl_txq_gen2_tx()
792 iwl_pcie_gen2_update_byte_tbl(trans, txq, cmd_len, in iwl_txq_gen2_tx()
793 iwl_txq_gen2_get_num_tbs(trans, tfd)); in iwl_txq_gen2_tx()
800 txq->write_ptr = iwl_txq_inc_wrap(trans, txq->write_ptr); in iwl_txq_gen2_tx()
801 iwl_txq_inc_wr_ptr(trans, txq); in iwl_txq_gen2_tx()
815 void iwl_txq_gen2_unmap(struct iwl_trans *trans, int txq_id) in iwl_txq_gen2_unmap() argument
817 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_unmap()
821 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", in iwl_txq_gen2_unmap()
824 if (txq_id != trans->txqs.cmd.q_id) { in iwl_txq_gen2_unmap()
829 iwl_txq_free_tso_page(trans, skb); in iwl_txq_gen2_unmap()
831 iwl_txq_gen2_free_tfd(trans, txq); in iwl_txq_gen2_unmap()
832 txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr); in iwl_txq_gen2_unmap()
838 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_gen2_unmap()
844 iwl_wake_queue(trans, txq); in iwl_txq_gen2_unmap()
847 static void iwl_txq_gen2_free_memory(struct iwl_trans *trans, in iwl_txq_gen2_free_memory() argument
850 struct device *dev = trans->dev; in iwl_txq_gen2_free_memory()
855 trans->txqs.tfd.size * txq->n_window, in iwl_txq_gen2_free_memory()
864 dma_pool_free(trans->txqs.bc_pool, in iwl_txq_gen2_free_memory()
877 static void iwl_txq_gen2_free(struct iwl_trans *trans, int txq_id) in iwl_txq_gen2_free() argument
886 txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_free()
891 iwl_txq_gen2_unmap(trans, txq_id); in iwl_txq_gen2_free()
894 if (txq_id == trans->txqs.cmd.q_id) in iwl_txq_gen2_free()
901 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_gen2_free()
903 trans->txqs.txq[txq_id] = NULL; in iwl_txq_gen2_free()
905 clear_bit(txq_id, trans->txqs.queue_used); in iwl_txq_gen2_free()
934 int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, in iwl_txq_init() argument
939 trans->trans_cfg->base_params->max_tfd_queue_size; in iwl_txq_init()
970 void iwl_txq_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb) in iwl_txq_free_tso_page() argument
975 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in iwl_txq_free_tso_page()
988 void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_log_scd_error() argument
995 if (trans->trans_cfg->gen2) { in iwl_txq_log_scd_error()
996 IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, in iwl_txq_log_scd_error()
1003 IWL_ERR(trans, " need_update %d frozen %d ampdu %d " in iwl_txq_log_scd_error()
1015 status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id)); in iwl_txq_log_scd_error()
1019 IWL_ERR(trans, in iwl_txq_log_scd_error()
1024 iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & in iwl_txq_log_scd_error()
1025 (trans->trans_cfg->base_params->max_tfd_queue_size - 1), in iwl_txq_log_scd_error()
1026 iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)) & in iwl_txq_log_scd_error()
1027 (trans->trans_cfg->base_params->max_tfd_queue_size - 1), in iwl_txq_log_scd_error()
1028 iwl_read_direct32(trans, FH_TX_TRB_REG(fifo))); in iwl_txq_log_scd_error()
1034 struct iwl_trans *trans = txq->trans; in iwl_txq_stuck_timer() local
1044 iwl_txq_log_scd_error(trans, txq); in iwl_txq_stuck_timer()
1046 iwl_force_nmi(trans); in iwl_txq_stuck_timer()
1049 int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, in iwl_txq_alloc() argument
1052 size_t tfd_sz = trans->txqs.tfd.size * in iwl_txq_alloc()
1053 trans->trans_cfg->base_params->max_tfd_queue_size; in iwl_txq_alloc()
1063 if (trans->trans_cfg->gen2) in iwl_txq_alloc()
1064 tfd_sz = trans->txqs.tfd.size * slots_num; in iwl_txq_alloc()
1067 txq->trans = trans; in iwl_txq_alloc()
1089 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, in iwl_txq_alloc()
1098 txq->first_tb_bufs = dma_alloc_coherent(trans->dev, tb0_buf_sz, in iwl_txq_alloc()
1106 dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr); in iwl_txq_alloc()
1119 iwl_txq_dyn_alloc_dma(struct iwl_trans *trans, int size, unsigned int timeout) in iwl_txq_dyn_alloc_dma() argument
1125 WARN_ON(!trans->txqs.bc_tbl_size); in iwl_txq_dyn_alloc_dma()
1127 bc_tbl_size = trans->txqs.bc_tbl_size; in iwl_txq_dyn_alloc_dma()
1137 txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL, in iwl_txq_dyn_alloc_dma()
1140 IWL_ERR(trans, "Scheduler BC Table allocation failed\n"); in iwl_txq_dyn_alloc_dma()
1145 ret = iwl_txq_alloc(trans, txq, size, false); in iwl_txq_dyn_alloc_dma()
1147 IWL_ERR(trans, "Tx queue alloc failed\n"); in iwl_txq_dyn_alloc_dma()
1150 ret = iwl_txq_init(trans, txq, size, false); in iwl_txq_dyn_alloc_dma()
1152 IWL_ERR(trans, "Tx queue init failed\n"); in iwl_txq_dyn_alloc_dma()
1161 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_dyn_alloc_dma()
1165 static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq, in iwl_txq_alloc_response() argument
1182 if (qid >= ARRAY_SIZE(trans->txqs.txq)) { in iwl_txq_alloc_response()
1188 if (test_and_set_bit(qid, trans->txqs.queue_used)) { in iwl_txq_alloc_response()
1194 if (WARN_ONCE(trans->txqs.txq[qid], in iwl_txq_alloc_response()
1201 trans->txqs.txq[qid] = txq; in iwl_txq_alloc_response()
1202 wr_ptr &= (trans->trans_cfg->base_params->max_tfd_queue_size - 1); in iwl_txq_alloc_response()
1208 IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d\n", qid); in iwl_txq_alloc_response()
1215 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_alloc_response()
1219 int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, in iwl_txq_dyn_alloc() argument
1232 if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_BZ && in iwl_txq_dyn_alloc()
1233 trans->hw_rev_step == SILICON_A_STEP) in iwl_txq_dyn_alloc()
1236 txq = iwl_txq_dyn_alloc_dma(trans, size, timeout); in iwl_txq_dyn_alloc()
1240 if (trans->txqs.queue_alloc_cmd_ver == 0) { in iwl_txq_dyn_alloc()
1257 } else if (trans->txqs.queue_alloc_cmd_ver == 3) { in iwl_txq_dyn_alloc()
1275 ret = iwl_trans_send_cmd(trans, &hcmd); in iwl_txq_dyn_alloc()
1279 return iwl_txq_alloc_response(trans, txq, &hcmd); in iwl_txq_dyn_alloc()
1282 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_dyn_alloc()
1286 void iwl_txq_dyn_free(struct iwl_trans *trans, int queue) in iwl_txq_dyn_free() argument
1298 if (!test_and_clear_bit(queue, trans->txqs.queue_used)) { in iwl_txq_dyn_free()
1299 WARN_ONCE(test_bit(STATUS_DEVICE_ENABLED, &trans->status), in iwl_txq_dyn_free()
1304 iwl_txq_gen2_free(trans, queue); in iwl_txq_dyn_free()
1306 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", queue); in iwl_txq_dyn_free()
1309 void iwl_txq_gen2_tx_free(struct iwl_trans *trans) in iwl_txq_gen2_tx_free() argument
1313 memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); in iwl_txq_gen2_tx_free()
1316 for (i = 0; i < ARRAY_SIZE(trans->txqs.txq); i++) { in iwl_txq_gen2_tx_free()
1317 if (!trans->txqs.txq[i]) in iwl_txq_gen2_tx_free()
1320 iwl_txq_gen2_free(trans, i); in iwl_txq_gen2_tx_free()
1324 int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, int queue_size) in iwl_txq_gen2_init() argument
1330 if (!trans->txqs.txq[txq_id]) { in iwl_txq_gen2_init()
1333 IWL_ERR(trans, "Not enough memory for tx queue\n"); in iwl_txq_gen2_init()
1336 trans->txqs.txq[txq_id] = queue; in iwl_txq_gen2_init()
1337 ret = iwl_txq_alloc(trans, queue, queue_size, true); in iwl_txq_gen2_init()
1339 IWL_ERR(trans, "Tx %d queue init failed\n", txq_id); in iwl_txq_gen2_init()
1343 queue = trans->txqs.txq[txq_id]; in iwl_txq_gen2_init()
1346 ret = iwl_txq_init(trans, queue, queue_size, in iwl_txq_gen2_init()
1347 (txq_id == trans->txqs.cmd.q_id)); in iwl_txq_gen2_init()
1349 IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id); in iwl_txq_gen2_init()
1352 trans->txqs.txq[txq_id]->id = txq_id; in iwl_txq_gen2_init()
1353 set_bit(txq_id, trans->txqs.queue_used); in iwl_txq_gen2_init()
1358 iwl_txq_gen2_tx_free(trans); in iwl_txq_gen2_init()
1362 static inline dma_addr_t iwl_txq_gen1_tfd_tb_get_addr(struct iwl_trans *trans, in iwl_txq_gen1_tfd_tb_get_addr() argument
1370 if (trans->trans_cfg->gen2) { in iwl_txq_gen1_tfd_tb_get_addr()
1394 void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans, in iwl_txq_gen1_tfd_unmap() argument
1399 void *tfd = iwl_txq_get_tfd(trans, txq, index); in iwl_txq_gen1_tfd_unmap()
1402 num_tbs = iwl_txq_gen1_tfd_get_num_tbs(trans, tfd); in iwl_txq_gen1_tfd_unmap()
1404 if (num_tbs > trans->txqs.tfd.max_tbs) { in iwl_txq_gen1_tfd_unmap()
1405 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); in iwl_txq_gen1_tfd_unmap()
1414 dma_unmap_page(trans->dev, in iwl_txq_gen1_tfd_unmap()
1415 iwl_txq_gen1_tfd_tb_get_addr(trans, in iwl_txq_gen1_tfd_unmap()
1417 iwl_txq_gen1_tfd_tb_get_len(trans, in iwl_txq_gen1_tfd_unmap()
1421 dma_unmap_single(trans->dev, in iwl_txq_gen1_tfd_unmap()
1422 iwl_txq_gen1_tfd_tb_get_addr(trans, in iwl_txq_gen1_tfd_unmap()
1424 iwl_txq_gen1_tfd_tb_get_len(trans, in iwl_txq_gen1_tfd_unmap()
1431 if (trans->trans_cfg->gen2) { in iwl_txq_gen1_tfd_unmap()
1448 void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans, in iwl_txq_gen1_update_byte_cnt_tbl() argument
1462 scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; in iwl_txq_gen1_update_byte_cnt_tbl()
1477 if (trans->txqs.bc_table_dword) in iwl_txq_gen1_update_byte_cnt_tbl()
1492 void iwl_txq_gen1_inval_byte_cnt_tbl(struct iwl_trans *trans, in iwl_txq_gen1_inval_byte_cnt_tbl() argument
1495 struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; in iwl_txq_gen1_inval_byte_cnt_tbl()
1505 if (txq_id != trans->txqs.cmd.q_id) in iwl_txq_gen1_inval_byte_cnt_tbl()
1526 void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_free_tfd() argument
1543 iwl_txq_gen1_tfd_unmap(trans, &txq->entries[idx].meta, txq, rd_ptr); in iwl_txq_free_tfd()
1553 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_free_tfd()
1583 void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn, in iwl_txq_reclaim() argument
1586 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_reclaim()
1590 if (WARN_ON(txq_id == trans->txqs.cmd.q_id)) in iwl_txq_reclaim()
1601 if (!test_bit(txq_id, trans->txqs.queue_used)) { in iwl_txq_reclaim()
1602 IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n", in iwl_txq_reclaim()
1610 IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n", in iwl_txq_reclaim()
1615 last_to_free = iwl_txq_dec_wrap(trans, tfd_num); in iwl_txq_reclaim()
1618 IWL_ERR(trans, in iwl_txq_reclaim()
1621 trans->trans_cfg->base_params->max_tfd_queue_size, in iwl_txq_reclaim()
1624 iwl_op_mode_time_point(trans->op_mode, in iwl_txq_reclaim()
1635 txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr), in iwl_txq_reclaim()
1642 iwl_txq_free_tso_page(trans, skb); in iwl_txq_reclaim()
1648 if (!trans->trans_cfg->gen2) in iwl_txq_reclaim()
1649 iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq); in iwl_txq_reclaim()
1651 iwl_txq_free_tfd(trans, txq); in iwl_txq_reclaim()
1656 if (iwl_txq_space(trans, txq) > txq->low_mark && in iwl_txq_reclaim()
1657 test_bit(txq_id, trans->txqs.queue_stopped)) { in iwl_txq_reclaim()
1686 trans->txqs.dev_cmd_offs); in iwl_txq_reclaim()
1693 iwl_trans_tx(trans, skb, dev_cmd_ptr, txq_id); in iwl_txq_reclaim()
1696 if (iwl_txq_space(trans, txq) > txq->low_mark) in iwl_txq_reclaim()
1697 iwl_wake_queue(trans, txq); in iwl_txq_reclaim()
1708 void iwl_txq_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr) in iwl_txq_set_q_ptrs() argument
1710 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_set_q_ptrs()
1720 void iwl_trans_txq_freeze_timer(struct iwl_trans *trans, unsigned long txqs, in iwl_trans_txq_freeze_timer() argument
1726 struct iwl_txq *txq = trans->txqs.txq[queue]; in iwl_trans_txq_freeze_timer()
1736 IWL_DEBUG_TX_QUEUES(trans, "%s TXQ %d\n", in iwl_trans_txq_freeze_timer()
1774 static int iwl_trans_txq_send_hcmd_sync(struct iwl_trans *trans, in iwl_trans_txq_send_hcmd_sync() argument
1777 const char *cmd_str = iwl_get_cmd_string(trans, cmd->id); in iwl_trans_txq_send_hcmd_sync()
1778 struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; in iwl_trans_txq_send_hcmd_sync()
1782 IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1785 &trans->status), in iwl_trans_txq_send_hcmd_sync()
1789 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1791 cmd_idx = trans->ops->send_cmd(trans, cmd); in iwl_trans_txq_send_hcmd_sync()
1794 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); in iwl_trans_txq_send_hcmd_sync()
1795 IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", in iwl_trans_txq_send_hcmd_sync()
1800 ret = wait_event_timeout(trans->wait_command_queue, in iwl_trans_txq_send_hcmd_sync()
1802 &trans->status), in iwl_trans_txq_send_hcmd_sync()
1805 IWL_ERR(trans, "Error sending %s: time out after %dms.\n", in iwl_trans_txq_send_hcmd_sync()
1808 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", in iwl_trans_txq_send_hcmd_sync()
1811 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); in iwl_trans_txq_send_hcmd_sync()
1812 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", in iwl_trans_txq_send_hcmd_sync()
1816 iwl_trans_sync_nmi(trans); in iwl_trans_txq_send_hcmd_sync()
1820 if (test_bit(STATUS_FW_ERROR, &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1822 &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1823 IWL_ERR(trans, "FW error in SYNC CMD %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1831 test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1832 IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n"); in iwl_trans_txq_send_hcmd_sync()
1838 IWL_ERR(trans, "Error: Response NULL in '%s'\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1864 int iwl_trans_txq_send_hcmd(struct iwl_trans *trans, in iwl_trans_txq_send_hcmd() argument
1868 if (test_bit(STATUS_TRANS_DEAD, &trans->status)) in iwl_trans_txq_send_hcmd()
1872 test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { in iwl_trans_txq_send_hcmd()
1873 IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n", in iwl_trans_txq_send_hcmd()
1878 if (unlikely(trans->system_pm_mode == IWL_PLAT_PM_MODE_D3 && in iwl_trans_txq_send_hcmd()
1880 IWL_DEBUG_WOWLAN(trans, "Dropping CMD 0x%x: D3\n", cmd->id); in iwl_trans_txq_send_hcmd()
1891 ret = trans->ops->send_cmd(trans, cmd); in iwl_trans_txq_send_hcmd()
1893 IWL_ERR(trans, in iwl_trans_txq_send_hcmd()
1895 iwl_get_cmd_string(trans, cmd->id), ret); in iwl_trans_txq_send_hcmd()
1901 return iwl_trans_txq_send_hcmd_sync(trans, cmd); in iwl_trans_txq_send_hcmd()