Lines Matching refs:trans

22 static void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans *trans,  in iwl_pcie_gen2_update_byte_tbl()  argument
46 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { in iwl_pcie_gen2_update_byte_tbl()
50 WARN_ON(trans->txqs.bc_table_dword); in iwl_pcie_gen2_update_byte_tbl()
58 WARN_ON(!trans->txqs.bc_table_dword); in iwl_pcie_gen2_update_byte_tbl()
69 void iwl_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_inc_wr_ptr() argument
73 IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq->id, txq->write_ptr); in iwl_txq_inc_wr_ptr()
79 iwl_write32(trans, HBUS_TARG_WRPTR, txq->write_ptr | (txq->id << 16)); in iwl_txq_inc_wr_ptr()
82 static u8 iwl_txq_gen2_get_num_tbs(struct iwl_trans *trans, in iwl_txq_gen2_get_num_tbs() argument
88 int iwl_txq_gen2_set_tb(struct iwl_trans *trans, struct iwl_tfh_tfd *tfd, in iwl_txq_gen2_set_tb() argument
91 int idx = iwl_txq_gen2_get_num_tbs(trans, tfd); in iwl_txq_gen2_set_tb()
109 if (le16_to_cpu(tfd->num_tbs) >= trans->txqs.tfd.max_tbs) { in iwl_txq_gen2_set_tb()
110 IWL_ERR(trans, "Error can not send more than %d chunks\n", in iwl_txq_gen2_set_tb()
111 trans->txqs.tfd.max_tbs); in iwl_txq_gen2_set_tb()
123 static void iwl_txq_set_tfd_invalid_gen2(struct iwl_trans *trans, in iwl_txq_set_tfd_invalid_gen2() argument
128 iwl_txq_gen2_set_tb(trans, tfd, trans->invalid_tx_cmd.dma, in iwl_txq_set_tfd_invalid_gen2()
129 trans->invalid_tx_cmd.size); in iwl_txq_set_tfd_invalid_gen2()
132 void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, struct iwl_cmd_meta *meta, in iwl_txq_gen2_tfd_unmap() argument
138 num_tbs = iwl_txq_gen2_get_num_tbs(trans, tfd); in iwl_txq_gen2_tfd_unmap()
140 if (num_tbs > trans->txqs.tfd.max_tbs) { in iwl_txq_gen2_tfd_unmap()
141 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); in iwl_txq_gen2_tfd_unmap()
148 dma_unmap_page(trans->dev, in iwl_txq_gen2_tfd_unmap()
153 dma_unmap_single(trans->dev, in iwl_txq_gen2_tfd_unmap()
159 iwl_txq_set_tfd_invalid_gen2(trans, tfd); in iwl_txq_gen2_tfd_unmap()
162 void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_gen2_free_tfd() argument
175 iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, in iwl_txq_gen2_free_tfd()
176 iwl_txq_get_tfd(trans, txq, idx)); in iwl_txq_gen2_free_tfd()
185 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_gen2_free_tfd()
190 static struct page *get_workaround_page(struct iwl_trans *trans, in get_workaround_page() argument
196 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in get_workaround_page()
215 static int iwl_txq_gen2_set_tb_with_wa(struct iwl_trans *trans, in iwl_txq_gen2_set_tb_with_wa() argument
225 if (unlikely(dma_mapping_error(trans->dev, phys))) in iwl_txq_gen2_set_tb_with_wa()
229 ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); in iwl_txq_gen2_set_tb_with_wa()
255 page = get_workaround_page(trans, skb); in iwl_txq_gen2_set_tb_with_wa()
263 phys = dma_map_single(trans->dev, page_address(page), len, in iwl_txq_gen2_set_tb_with_wa()
265 if (unlikely(dma_mapping_error(trans->dev, phys))) in iwl_txq_gen2_set_tb_with_wa()
267 ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); in iwl_txq_gen2_set_tb_with_wa()
274 IWL_WARN(trans, in iwl_txq_gen2_set_tb_with_wa()
281 dma_unmap_page(trans->dev, oldphys, len, DMA_TO_DEVICE); in iwl_txq_gen2_set_tb_with_wa()
283 dma_unmap_single(trans->dev, oldphys, len, DMA_TO_DEVICE); in iwl_txq_gen2_set_tb_with_wa()
285 trace_iwlwifi_dev_tx_tb(trans->dev, skb, virt, phys, len); in iwl_txq_gen2_set_tb_with_wa()
291 struct iwl_tso_hdr_page *get_page_hdr(struct iwl_trans *trans, size_t len, in get_page_hdr() argument
294 struct iwl_tso_hdr_page *p = this_cpu_ptr(trans->txqs.tso_hdr_page); in get_page_hdr()
297 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in get_page_hdr()
336 static int iwl_txq_gen2_build_amsdu(struct iwl_trans *trans, in iwl_txq_gen2_build_amsdu() argument
352 trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), in iwl_txq_gen2_build_amsdu()
365 hdr_page = get_page_hdr(trans, hdr_room, skb); in iwl_txq_gen2_build_amsdu()
417 tb_phys = dma_map_single(trans->dev, start_hdr, in iwl_txq_gen2_build_amsdu()
419 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_amsdu()
426 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb_len); in iwl_txq_gen2_build_amsdu()
427 trace_iwlwifi_dev_tx_tb(trans->dev, skb, start_hdr, in iwl_txq_gen2_build_amsdu()
440 tb_phys = dma_map_single(trans->dev, tso.data, in iwl_txq_gen2_build_amsdu()
442 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, in iwl_txq_gen2_build_amsdu()
464 iwl_tfh_tfd *iwl_txq_gen2_build_tx_amsdu(struct iwl_trans *trans, in iwl_txq_gen2_build_tx_amsdu() argument
473 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tx_amsdu()
485 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); in iwl_txq_gen2_build_tx_amsdu()
500 tb_phys = dma_map_single(trans->dev, tb1_addr, len, DMA_TO_DEVICE); in iwl_txq_gen2_build_tx_amsdu()
501 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_tx_amsdu()
507 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, len); in iwl_txq_gen2_build_tx_amsdu()
509 if (iwl_txq_gen2_build_amsdu(trans, skb, tfd, len + IWL_FIRST_TB_SIZE, in iwl_txq_gen2_build_tx_amsdu()
518 iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); in iwl_txq_gen2_build_tx_amsdu()
522 static int iwl_txq_gen2_tx_add_frags(struct iwl_trans *trans, in iwl_txq_gen2_tx_add_frags() argument
538 tb_phys = skb_frag_dma_map(trans->dev, frag, 0, in iwl_txq_gen2_tx_add_frags()
540 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_tx_add_frags()
551 iwl_tfh_tfd *iwl_txq_gen2_build_tx(struct iwl_trans *trans, in iwl_txq_gen2_build_tx() argument
561 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tx()
577 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); in iwl_txq_gen2_build_tx()
595 tb_phys = dma_map_single(trans->dev, tb1_addr, tb1_len, DMA_TO_DEVICE); in iwl_txq_gen2_build_tx()
596 if (unlikely(dma_mapping_error(trans->dev, tb_phys))) in iwl_txq_gen2_build_tx()
602 iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb1_len); in iwl_txq_gen2_build_tx()
603 trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), &dev_cmd->hdr, in iwl_txq_gen2_build_tx()
612 tb_phys = dma_map_single(trans->dev, skb->data + hdr_len, in iwl_txq_gen2_build_tx()
614 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_build_tx()
621 if (iwl_txq_gen2_tx_add_frags(trans, skb, tfd, out_meta)) in iwl_txq_gen2_build_tx()
627 tb_phys = dma_map_single(trans->dev, frag->data, in iwl_txq_gen2_build_tx()
629 ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, in iwl_txq_gen2_build_tx()
634 if (iwl_txq_gen2_tx_add_frags(trans, frag, tfd, out_meta)) in iwl_txq_gen2_build_tx()
641 iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); in iwl_txq_gen2_build_tx()
646 struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans, in iwl_txq_gen2_build_tfd() argument
654 struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); in iwl_txq_gen2_build_tfd()
670 if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) in iwl_txq_gen2_build_tfd()
687 return iwl_txq_gen2_build_tx_amsdu(trans, txq, dev_cmd, skb, in iwl_txq_gen2_build_tfd()
689 return iwl_txq_gen2_build_tx(trans, txq, dev_cmd, skb, out_meta, in iwl_txq_gen2_build_tfd()
693 int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q) in iwl_txq_space() argument
704 if (q->n_window < trans->trans_cfg->base_params->max_tfd_queue_size) in iwl_txq_space()
707 max = trans->trans_cfg->base_params->max_tfd_queue_size - 1; in iwl_txq_space()
714 (trans->trans_cfg->base_params->max_tfd_queue_size - 1); in iwl_txq_space()
722 int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, in iwl_txq_gen2_tx() argument
726 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_tx()
735 if (WARN_ONCE(!test_bit(txq_id, trans->txqs.queue_used), in iwl_txq_gen2_tx()
740 skb_shinfo(skb)->nr_frags > IWL_TRANS_MAX_FRAGS(trans) && in iwl_txq_gen2_tx()
746 if (iwl_txq_space(trans, txq) < txq->high_mark) { in iwl_txq_gen2_tx()
747 iwl_txq_stop(trans, txq); in iwl_txq_gen2_tx()
750 if (unlikely(iwl_txq_space(trans, txq) < 3)) { in iwl_txq_gen2_tx()
754 trans->txqs.dev_cmd_offs); in iwl_txq_gen2_tx()
777 tfd = iwl_txq_gen2_build_tfd(trans, txq, dev_cmd, skb, out_meta); in iwl_txq_gen2_tx()
783 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { in iwl_txq_gen2_tx()
796 iwl_pcie_gen2_update_byte_tbl(trans, txq, cmd_len, in iwl_txq_gen2_tx()
797 iwl_txq_gen2_get_num_tbs(trans, tfd)); in iwl_txq_gen2_tx()
804 txq->write_ptr = iwl_txq_inc_wrap(trans, txq->write_ptr); in iwl_txq_gen2_tx()
805 iwl_txq_inc_wr_ptr(trans, txq); in iwl_txq_gen2_tx()
819 void iwl_txq_gen2_unmap(struct iwl_trans *trans, int txq_id) in iwl_txq_gen2_unmap() argument
821 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_unmap()
825 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", in iwl_txq_gen2_unmap()
828 if (txq_id != trans->txqs.cmd.q_id) { in iwl_txq_gen2_unmap()
833 iwl_txq_free_tso_page(trans, skb); in iwl_txq_gen2_unmap()
835 iwl_txq_gen2_free_tfd(trans, txq); in iwl_txq_gen2_unmap()
836 txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr); in iwl_txq_gen2_unmap()
842 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_gen2_unmap()
848 iwl_wake_queue(trans, txq); in iwl_txq_gen2_unmap()
851 static void iwl_txq_gen2_free_memory(struct iwl_trans *trans, in iwl_txq_gen2_free_memory() argument
854 struct device *dev = trans->dev; in iwl_txq_gen2_free_memory()
859 trans->txqs.tfd.size * txq->n_window, in iwl_txq_gen2_free_memory()
868 dma_pool_free(trans->txqs.bc_pool, in iwl_txq_gen2_free_memory()
881 static void iwl_txq_gen2_free(struct iwl_trans *trans, int txq_id) in iwl_txq_gen2_free() argument
890 txq = trans->txqs.txq[txq_id]; in iwl_txq_gen2_free()
895 iwl_txq_gen2_unmap(trans, txq_id); in iwl_txq_gen2_free()
898 if (txq_id == trans->txqs.cmd.q_id) in iwl_txq_gen2_free()
905 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_gen2_free()
907 trans->txqs.txq[txq_id] = NULL; in iwl_txq_gen2_free()
909 clear_bit(txq_id, trans->txqs.queue_used); in iwl_txq_gen2_free()
938 int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, in iwl_txq_init() argument
943 trans->trans_cfg->base_params->max_tfd_queue_size; in iwl_txq_init()
972 void iwl_txq_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb) in iwl_txq_free_tso_page() argument
977 page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); in iwl_txq_free_tso_page()
990 void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_log_scd_error() argument
997 if (trans->trans_cfg->gen2) { in iwl_txq_log_scd_error()
998 IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, in iwl_txq_log_scd_error()
1004 status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id)); in iwl_txq_log_scd_error()
1008 IWL_ERR(trans, in iwl_txq_log_scd_error()
1013 iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & in iwl_txq_log_scd_error()
1014 (trans->trans_cfg->base_params->max_tfd_queue_size - 1), in iwl_txq_log_scd_error()
1015 iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)) & in iwl_txq_log_scd_error()
1016 (trans->trans_cfg->base_params->max_tfd_queue_size - 1), in iwl_txq_log_scd_error()
1017 iwl_read_direct32(trans, FH_TX_TRB_REG(fifo))); in iwl_txq_log_scd_error()
1023 struct iwl_trans *trans = txq->trans; in iwl_txq_stuck_timer() local
1033 iwl_txq_log_scd_error(trans, txq); in iwl_txq_stuck_timer()
1035 iwl_force_nmi(trans); in iwl_txq_stuck_timer()
1038 static void iwl_txq_set_tfd_invalid_gen1(struct iwl_trans *trans, in iwl_txq_set_tfd_invalid_gen1() argument
1043 iwl_pcie_gen1_tfd_set_tb(trans, tfd, 0, trans->invalid_tx_cmd.dma, in iwl_txq_set_tfd_invalid_gen1()
1044 trans->invalid_tx_cmd.size); in iwl_txq_set_tfd_invalid_gen1()
1047 int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, in iwl_txq_alloc() argument
1050 size_t num_entries = trans->trans_cfg->gen2 ? in iwl_txq_alloc()
1051 slots_num : trans->trans_cfg->base_params->max_tfd_queue_size; in iwl_txq_alloc()
1062 tfd_sz = trans->txqs.tfd.size * num_entries; in iwl_txq_alloc()
1065 txq->trans = trans; in iwl_txq_alloc()
1087 txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, in iwl_txq_alloc()
1096 txq->first_tb_bufs = dma_alloc_coherent(trans->dev, tb0_buf_sz, in iwl_txq_alloc()
1103 void *tfd = iwl_txq_get_tfd(trans, txq, i); in iwl_txq_alloc()
1105 if (trans->trans_cfg->gen2) in iwl_txq_alloc()
1106 iwl_txq_set_tfd_invalid_gen2(trans, tfd); in iwl_txq_alloc()
1108 iwl_txq_set_tfd_invalid_gen1(trans, tfd); in iwl_txq_alloc()
1113 dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr); in iwl_txq_alloc()
1126 iwl_txq_dyn_alloc_dma(struct iwl_trans *trans, int size, unsigned int timeout) in iwl_txq_dyn_alloc_dma() argument
1132 WARN_ON(!trans->txqs.bc_tbl_size); in iwl_txq_dyn_alloc_dma()
1134 bc_tbl_size = trans->txqs.bc_tbl_size; in iwl_txq_dyn_alloc_dma()
1144 txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL, in iwl_txq_dyn_alloc_dma()
1147 IWL_ERR(trans, "Scheduler BC Table allocation failed\n"); in iwl_txq_dyn_alloc_dma()
1152 ret = iwl_txq_alloc(trans, txq, size, false); in iwl_txq_dyn_alloc_dma()
1154 IWL_ERR(trans, "Tx queue alloc failed\n"); in iwl_txq_dyn_alloc_dma()
1157 ret = iwl_txq_init(trans, txq, size, false); in iwl_txq_dyn_alloc_dma()
1159 IWL_ERR(trans, "Tx queue init failed\n"); in iwl_txq_dyn_alloc_dma()
1168 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_dyn_alloc_dma()
1172 static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq, in iwl_txq_alloc_response() argument
1189 if (qid >= ARRAY_SIZE(trans->txqs.txq)) { in iwl_txq_alloc_response()
1195 if (test_and_set_bit(qid, trans->txqs.queue_used)) { in iwl_txq_alloc_response()
1201 if (WARN_ONCE(trans->txqs.txq[qid], in iwl_txq_alloc_response()
1208 trans->txqs.txq[qid] = txq; in iwl_txq_alloc_response()
1209 wr_ptr &= (trans->trans_cfg->base_params->max_tfd_queue_size - 1); in iwl_txq_alloc_response()
1215 IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d\n", qid); in iwl_txq_alloc_response()
1222 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_alloc_response()
1226 int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, in iwl_txq_dyn_alloc() argument
1239 if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_BZ && in iwl_txq_dyn_alloc()
1240 trans->hw_rev_step == SILICON_A_STEP) in iwl_txq_dyn_alloc()
1243 txq = iwl_txq_dyn_alloc_dma(trans, size, timeout); in iwl_txq_dyn_alloc()
1247 if (trans->txqs.queue_alloc_cmd_ver == 0) { in iwl_txq_dyn_alloc()
1264 } else if (trans->txqs.queue_alloc_cmd_ver == 3) { in iwl_txq_dyn_alloc()
1282 ret = iwl_trans_send_cmd(trans, &hcmd); in iwl_txq_dyn_alloc()
1286 return iwl_txq_alloc_response(trans, txq, &hcmd); in iwl_txq_dyn_alloc()
1289 iwl_txq_gen2_free_memory(trans, txq); in iwl_txq_dyn_alloc()
1293 void iwl_txq_dyn_free(struct iwl_trans *trans, int queue) in iwl_txq_dyn_free() argument
1305 if (!test_and_clear_bit(queue, trans->txqs.queue_used)) { in iwl_txq_dyn_free()
1306 WARN_ONCE(test_bit(STATUS_DEVICE_ENABLED, &trans->status), in iwl_txq_dyn_free()
1311 iwl_txq_gen2_free(trans, queue); in iwl_txq_dyn_free()
1313 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", queue); in iwl_txq_dyn_free()
1316 void iwl_txq_gen2_tx_free(struct iwl_trans *trans) in iwl_txq_gen2_tx_free() argument
1320 memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); in iwl_txq_gen2_tx_free()
1323 for (i = 0; i < ARRAY_SIZE(trans->txqs.txq); i++) { in iwl_txq_gen2_tx_free()
1324 if (!trans->txqs.txq[i]) in iwl_txq_gen2_tx_free()
1327 iwl_txq_gen2_free(trans, i); in iwl_txq_gen2_tx_free()
1331 int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, int queue_size) in iwl_txq_gen2_init() argument
1337 if (!trans->txqs.txq[txq_id]) { in iwl_txq_gen2_init()
1340 IWL_ERR(trans, "Not enough memory for tx queue\n"); in iwl_txq_gen2_init()
1343 trans->txqs.txq[txq_id] = queue; in iwl_txq_gen2_init()
1344 ret = iwl_txq_alloc(trans, queue, queue_size, true); in iwl_txq_gen2_init()
1346 IWL_ERR(trans, "Tx %d queue init failed\n", txq_id); in iwl_txq_gen2_init()
1350 queue = trans->txqs.txq[txq_id]; in iwl_txq_gen2_init()
1353 ret = iwl_txq_init(trans, queue, queue_size, in iwl_txq_gen2_init()
1354 (txq_id == trans->txqs.cmd.q_id)); in iwl_txq_gen2_init()
1356 IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id); in iwl_txq_gen2_init()
1359 trans->txqs.txq[txq_id]->id = txq_id; in iwl_txq_gen2_init()
1360 set_bit(txq_id, trans->txqs.queue_used); in iwl_txq_gen2_init()
1365 iwl_txq_gen2_tx_free(trans); in iwl_txq_gen2_init()
1369 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
1391 void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans, in iwl_txq_gen1_tfd_unmap() argument
1396 struct iwl_tfd *tfd = iwl_txq_get_tfd(trans, txq, index); in iwl_txq_gen1_tfd_unmap()
1399 num_tbs = iwl_txq_gen1_tfd_get_num_tbs(trans, tfd); in iwl_txq_gen1_tfd_unmap()
1401 if (num_tbs > trans->txqs.tfd.max_tbs) { in iwl_txq_gen1_tfd_unmap()
1402 IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); in iwl_txq_gen1_tfd_unmap()
1411 dma_unmap_page(trans->dev, in iwl_txq_gen1_tfd_unmap()
1412 iwl_txq_gen1_tfd_tb_get_addr(trans, in iwl_txq_gen1_tfd_unmap()
1414 iwl_txq_gen1_tfd_tb_get_len(trans, in iwl_txq_gen1_tfd_unmap()
1418 dma_unmap_single(trans->dev, in iwl_txq_gen1_tfd_unmap()
1419 iwl_txq_gen1_tfd_tb_get_addr(trans, in iwl_txq_gen1_tfd_unmap()
1421 iwl_txq_gen1_tfd_tb_get_len(trans, in iwl_txq_gen1_tfd_unmap()
1428 iwl_txq_set_tfd_invalid_gen1(trans, tfd); in iwl_txq_gen1_tfd_unmap()
1437 void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans, in iwl_txq_gen1_update_byte_cnt_tbl() argument
1451 scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; in iwl_txq_gen1_update_byte_cnt_tbl()
1466 if (trans->txqs.bc_table_dword) in iwl_txq_gen1_update_byte_cnt_tbl()
1481 void iwl_txq_gen1_inval_byte_cnt_tbl(struct iwl_trans *trans, in iwl_txq_gen1_inval_byte_cnt_tbl() argument
1484 struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; in iwl_txq_gen1_inval_byte_cnt_tbl()
1494 if (txq_id != trans->txqs.cmd.q_id) in iwl_txq_gen1_inval_byte_cnt_tbl()
1515 void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) in iwl_txq_free_tfd() argument
1532 if (trans->trans_cfg->gen2) in iwl_txq_free_tfd()
1533 iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, in iwl_txq_free_tfd()
1534 iwl_txq_get_tfd(trans, txq, rd_ptr)); in iwl_txq_free_tfd()
1536 iwl_txq_gen1_tfd_unmap(trans, &txq->entries[idx].meta, in iwl_txq_free_tfd()
1547 iwl_op_mode_free_skb(trans->op_mode, skb); in iwl_txq_free_tfd()
1577 void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn, in iwl_txq_reclaim() argument
1580 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_reclaim()
1584 if (WARN_ON(txq_id == trans->txqs.cmd.q_id)) in iwl_txq_reclaim()
1595 if (!test_bit(txq_id, trans->txqs.queue_used)) { in iwl_txq_reclaim()
1596 IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n", in iwl_txq_reclaim()
1604 IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n", in iwl_txq_reclaim()
1609 last_to_free = iwl_txq_dec_wrap(trans, tfd_num); in iwl_txq_reclaim()
1612 IWL_ERR(trans, in iwl_txq_reclaim()
1615 trans->trans_cfg->base_params->max_tfd_queue_size, in iwl_txq_reclaim()
1618 iwl_op_mode_time_point(trans->op_mode, in iwl_txq_reclaim()
1629 txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr), in iwl_txq_reclaim()
1636 iwl_txq_free_tso_page(trans, skb); in iwl_txq_reclaim()
1642 if (!trans->trans_cfg->gen2) in iwl_txq_reclaim()
1643 iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq); in iwl_txq_reclaim()
1645 iwl_txq_free_tfd(trans, txq); in iwl_txq_reclaim()
1650 if (iwl_txq_space(trans, txq) > txq->low_mark && in iwl_txq_reclaim()
1651 test_bit(txq_id, trans->txqs.queue_stopped)) { in iwl_txq_reclaim()
1680 trans->txqs.dev_cmd_offs); in iwl_txq_reclaim()
1687 iwl_trans_tx(trans, skb, dev_cmd_ptr, txq_id); in iwl_txq_reclaim()
1690 if (iwl_txq_space(trans, txq) > txq->low_mark) in iwl_txq_reclaim()
1691 iwl_wake_queue(trans, txq); in iwl_txq_reclaim()
1702 void iwl_txq_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr) in iwl_txq_set_q_ptrs() argument
1704 struct iwl_txq *txq = trans->txqs.txq[txq_id]; in iwl_txq_set_q_ptrs()
1714 void iwl_trans_txq_freeze_timer(struct iwl_trans *trans, unsigned long txqs, in iwl_trans_txq_freeze_timer() argument
1720 struct iwl_txq *txq = trans->txqs.txq[queue]; in iwl_trans_txq_freeze_timer()
1730 IWL_DEBUG_TX_QUEUES(trans, "%s TXQ %d\n", in iwl_trans_txq_freeze_timer()
1768 static int iwl_trans_txq_send_hcmd_sync(struct iwl_trans *trans, in iwl_trans_txq_send_hcmd_sync() argument
1771 const char *cmd_str = iwl_get_cmd_string(trans, cmd->id); in iwl_trans_txq_send_hcmd_sync()
1772 struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; in iwl_trans_txq_send_hcmd_sync()
1776 IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1779 &trans->status), in iwl_trans_txq_send_hcmd_sync()
1783 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1785 cmd_idx = trans->ops->send_cmd(trans, cmd); in iwl_trans_txq_send_hcmd_sync()
1788 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); in iwl_trans_txq_send_hcmd_sync()
1789 IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", in iwl_trans_txq_send_hcmd_sync()
1794 ret = wait_event_timeout(trans->wait_command_queue, in iwl_trans_txq_send_hcmd_sync()
1796 &trans->status), in iwl_trans_txq_send_hcmd_sync()
1799 IWL_ERR(trans, "Error sending %s: time out after %dms.\n", in iwl_trans_txq_send_hcmd_sync()
1802 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", in iwl_trans_txq_send_hcmd_sync()
1805 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); in iwl_trans_txq_send_hcmd_sync()
1806 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", in iwl_trans_txq_send_hcmd_sync()
1810 iwl_trans_sync_nmi(trans); in iwl_trans_txq_send_hcmd_sync()
1814 if (test_bit(STATUS_FW_ERROR, &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1816 &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1817 IWL_ERR(trans, "FW error in SYNC CMD %s\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1825 test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { in iwl_trans_txq_send_hcmd_sync()
1826 IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n"); in iwl_trans_txq_send_hcmd_sync()
1832 IWL_ERR(trans, "Error: Response NULL in '%s'\n", cmd_str); in iwl_trans_txq_send_hcmd_sync()
1858 int iwl_trans_txq_send_hcmd(struct iwl_trans *trans, in iwl_trans_txq_send_hcmd() argument
1862 if (test_bit(STATUS_TRANS_DEAD, &trans->status)) in iwl_trans_txq_send_hcmd()
1866 test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { in iwl_trans_txq_send_hcmd()
1867 IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n", in iwl_trans_txq_send_hcmd()
1872 if (unlikely(trans->system_pm_mode == IWL_PLAT_PM_MODE_D3 && in iwl_trans_txq_send_hcmd()
1874 IWL_DEBUG_WOWLAN(trans, "Dropping CMD 0x%x: D3\n", cmd->id); in iwl_trans_txq_send_hcmd()
1885 ret = trans->ops->send_cmd(trans, cmd); in iwl_trans_txq_send_hcmd()
1887 IWL_ERR(trans, in iwl_trans_txq_send_hcmd()
1889 iwl_get_cmd_string(trans, cmd->id), ret); in iwl_trans_txq_send_hcmd()
1895 return iwl_trans_txq_send_hcmd_sync(trans, cmd); in iwl_trans_txq_send_hcmd()