Lines Matching +full:hdr +full:- +full:engine
1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
34 WARN_ONCE((unsigned long)skb->data & 3, "unaligned skb"); in ath10k_htc_build_tx_ctrl_skb()
48 if (htc->ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) in ath10k_htc_restore_tx_skb()
49 dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE); in ath10k_htc_restore_tx_skb()
56 struct ath10k *ar = ep->htc->ar; in ath10k_htc_notify_tx_completion()
57 struct ath10k_htc_hdr *hdr; in ath10k_htc_notify_tx_completion() local
60 ep->eid, skb); in ath10k_htc_notify_tx_completion()
63 * copy engine is processing it due to which host unmaps corresponding in ath10k_htc_notify_tx_completion()
67 if (ar->hw_params.delay_unmap_buffer && in ath10k_htc_notify_tx_completion()
68 ep->ul_pipe_id == 3) in ath10k_htc_notify_tx_completion()
71 hdr = (struct ath10k_htc_hdr *)skb->data; in ath10k_htc_notify_tx_completion()
72 ath10k_htc_restore_tx_skb(ep->htc, skb); in ath10k_htc_notify_tx_completion()
74 if (!ep->ep_ops.ep_tx_complete) { in ath10k_htc_notify_tx_completion()
75 ath10k_warn(ar, "no tx handler for eid %d\n", ep->eid); in ath10k_htc_notify_tx_completion()
80 if (hdr->flags & ATH10K_HTC_FLAG_SEND_BUNDLE) { in ath10k_htc_notify_tx_completion()
85 ep->ep_ops.ep_tx_complete(ep->htc->ar, skb); in ath10k_htc_notify_tx_completion()
92 struct ath10k_htc_hdr *hdr; in ath10k_htc_prepare_tx_skb() local
94 hdr = (struct ath10k_htc_hdr *)skb->data; in ath10k_htc_prepare_tx_skb()
95 memset(hdr, 0, sizeof(struct ath10k_htc_hdr)); in ath10k_htc_prepare_tx_skb()
97 hdr->eid = ep->eid; in ath10k_htc_prepare_tx_skb()
98 hdr->len = __cpu_to_le16(skb->len - sizeof(*hdr)); in ath10k_htc_prepare_tx_skb()
99 hdr->flags = 0; in ath10k_htc_prepare_tx_skb()
100 if (ep->tx_credit_flow_enabled && !ep->bundle_tx) in ath10k_htc_prepare_tx_skb()
101 hdr->flags |= ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE; in ath10k_htc_prepare_tx_skb()
103 spin_lock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
104 hdr->seq_no = ep->seq_no++; in ath10k_htc_prepare_tx_skb()
105 spin_unlock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
112 struct ath10k_htc *htc = ep->htc; in ath10k_htc_consume_credit()
113 struct ath10k *ar = htc->ar; in ath10k_htc_consume_credit()
114 enum ath10k_htc_ep_id eid = ep->eid; in ath10k_htc_consume_credit()
117 if (!ep->tx_credit_flow_enabled) in ath10k_htc_consume_credit()
120 credits = DIV_ROUND_UP(len, ep->tx_credit_size); in ath10k_htc_consume_credit()
121 spin_lock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
123 if (ep->tx_credits < credits) { in ath10k_htc_consume_credit()
126 eid, credits, ep->tx_credits, consume); in ath10k_htc_consume_credit()
127 ret = -EAGAIN; in ath10k_htc_consume_credit()
132 ep->tx_credits -= credits; in ath10k_htc_consume_credit()
135 eid, credits, ep->tx_credits); in ath10k_htc_consume_credit()
139 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
145 struct ath10k_htc *htc = ep->htc; in ath10k_htc_release_credit()
146 struct ath10k *ar = htc->ar; in ath10k_htc_release_credit()
147 enum ath10k_htc_ep_id eid = ep->eid; in ath10k_htc_release_credit()
150 if (!ep->tx_credit_flow_enabled) in ath10k_htc_release_credit()
153 credits = DIV_ROUND_UP(len, ep->tx_credit_size); in ath10k_htc_release_credit()
154 spin_lock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
155 ep->tx_credits += credits; in ath10k_htc_release_credit()
158 eid, credits, ep->tx_credits); in ath10k_htc_release_credit()
159 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
161 if (ep->ep_ops.ep_tx_credits) in ath10k_htc_release_credit()
162 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_release_credit()
169 struct ath10k *ar = htc->ar; in ath10k_htc_send()
170 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send()
173 struct device *dev = htc->ar->dev; in ath10k_htc_send()
177 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send()
178 return -ECOMM; in ath10k_htc_send()
182 return -ENOENT; in ath10k_htc_send()
187 skb_len = skb->len; in ath10k_htc_send()
194 skb_cb->eid = eid; in ath10k_htc_send()
195 if (ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) { in ath10k_htc_send()
196 skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, in ath10k_htc_send()
198 ret = dma_mapping_error(dev, skb_cb->paddr); in ath10k_htc_send()
200 ret = -EIO; in ath10k_htc_send()
205 sg_item.transfer_id = ep->eid; in ath10k_htc_send()
207 sg_item.vaddr = skb->data; in ath10k_htc_send()
208 sg_item.paddr = skb_cb->paddr; in ath10k_htc_send()
209 sg_item.len = skb->len; in ath10k_htc_send()
211 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send()
218 if (ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) in ath10k_htc_send()
219 dma_unmap_single(dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE); in ath10k_htc_send()
229 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_tx_completion_handler()
237 ep = &htc->endpoint[skb_cb->eid]; in ath10k_htc_tx_completion_handler()
254 struct ath10k *ar = htc->ar; in ath10k_htc_process_credit_report()
263 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
265 if (report->eid >= ATH10K_HTC_EP_COUNT) in ath10k_htc_process_credit_report()
268 ep = &htc->endpoint[report->eid]; in ath10k_htc_process_credit_report()
269 ep->tx_credits += report->credits; in ath10k_htc_process_credit_report()
272 report->eid, report->credits, ep->tx_credits); in ath10k_htc_process_credit_report()
274 if (ep->ep_ops.ep_tx_credits) { in ath10k_htc_process_credit_report()
275 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
276 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_process_credit_report()
277 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
280 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
291 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead()
298 if (report->pre_valid != ((~report->post_valid) & 0xFF)) in ath10k_htc_process_lookahead()
304 report->pre_valid, report->post_valid); in ath10k_htc_process_lookahead()
307 memcpy((u8 *)next_lookaheads, report->lookahead, 4); in ath10k_htc_process_lookahead()
323 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead_bundle()
326 if (!bundle_cnt || (bundle_cnt > htc->max_msgs_per_htc_bundle)) { in ath10k_htc_process_lookahead_bundle()
329 return -EINVAL; in ath10k_htc_process_lookahead_bundle()
337 report->lookahead, 4); in ath10k_htc_process_lookahead_bundle()
355 struct ath10k *ar = htc->ar; in ath10k_htc_process_trailer()
368 if (length < sizeof(record->hdr)) { in ath10k_htc_process_trailer()
369 status = -EINVAL; in ath10k_htc_process_trailer()
373 if (record->hdr.len > length) { in ath10k_htc_process_trailer()
376 record->hdr.len); in ath10k_htc_process_trailer()
377 status = -EINVAL; in ath10k_htc_process_trailer()
381 switch (record->hdr.id) { in ath10k_htc_process_trailer()
384 if (record->hdr.len < len) { in ath10k_htc_process_trailer()
386 status = -EINVAL; in ath10k_htc_process_trailer()
390 record->credit_report, in ath10k_htc_process_trailer()
391 record->hdr.len, in ath10k_htc_process_trailer()
396 if (record->hdr.len < len) { in ath10k_htc_process_trailer()
398 status = -EINVAL; in ath10k_htc_process_trailer()
402 record->lookahead_report, in ath10k_htc_process_trailer()
403 record->hdr.len, in ath10k_htc_process_trailer()
409 bundle = record->lookahead_bundle; in ath10k_htc_process_trailer()
412 record->hdr.len, in ath10k_htc_process_trailer()
419 record->hdr.id, record->hdr.len); in ath10k_htc_process_trailer()
427 buffer += sizeof(record->hdr) + record->hdr.len; in ath10k_htc_process_trailer()
428 length -= sizeof(record->hdr) + record->hdr.len; in ath10k_htc_process_trailer()
442 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_rx_completion_handler()
443 struct ath10k_htc_hdr *hdr; in ath10k_htc_rx_completion_handler() local
451 hdr = (struct ath10k_htc_hdr *)skb->data; in ath10k_htc_rx_completion_handler()
452 skb_pull(skb, sizeof(*hdr)); in ath10k_htc_rx_completion_handler()
454 eid = hdr->eid; in ath10k_htc_rx_completion_handler()
459 hdr, sizeof(*hdr)); in ath10k_htc_rx_completion_handler()
463 ep = &htc->endpoint[eid]; in ath10k_htc_rx_completion_handler()
464 if (ep->service_id == ATH10K_HTC_SVC_ID_UNUSED) { in ath10k_htc_rx_completion_handler()
469 payload_len = __le16_to_cpu(hdr->len); in ath10k_htc_rx_completion_handler()
471 if (payload_len + sizeof(*hdr) > ATH10K_HTC_MAX_LEN) { in ath10k_htc_rx_completion_handler()
473 payload_len + sizeof(*hdr)); in ath10k_htc_rx_completion_handler()
475 hdr, sizeof(*hdr)); in ath10k_htc_rx_completion_handler()
479 if (skb->len < payload_len) { in ath10k_htc_rx_completion_handler()
482 skb->len, payload_len); in ath10k_htc_rx_completion_handler()
484 "", hdr, sizeof(*hdr)); in ath10k_htc_rx_completion_handler()
489 trailer_present = hdr->flags & ATH10K_HTC_FLAG_TRAILER_PRESENT; in ath10k_htc_rx_completion_handler()
493 trailer_len = hdr->trailer_len; in ath10k_htc_rx_completion_handler()
503 trailer = (u8 *)hdr; in ath10k_htc_rx_completion_handler()
504 trailer += sizeof(*hdr); in ath10k_htc_rx_completion_handler()
506 trailer -= trailer_len; in ath10k_htc_rx_completion_handler()
508 trailer_len, hdr->eid, in ath10k_htc_rx_completion_handler()
513 skb_trim(skb, skb->len - trailer_len); in ath10k_htc_rx_completion_handler()
516 if (((int)payload_len - (int)trailer_len) <= 0) in ath10k_htc_rx_completion_handler()
522 ep->ep_ops.ep_rx_complete(ar, skb); in ath10k_htc_rx_completion_handler()
534 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_control_rx_complete()
535 struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data; in ath10k_htc_control_rx_complete()
537 switch (__le16_to_cpu(msg->hdr.message_id)) { in ath10k_htc_control_rx_complete()
541 if (completion_done(&htc->ctl_resp)) { in ath10k_htc_control_rx_complete()
546 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
550 htc->control_resp_len = in ath10k_htc_control_rx_complete()
551 min_t(int, skb->len, in ath10k_htc_control_rx_complete()
554 memcpy(htc->control_resp_buffer, skb->data, in ath10k_htc_control_rx_complete()
555 htc->control_resp_len); in ath10k_htc_control_rx_complete()
557 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
560 htc->htc_ops.target_send_suspend_complete(ar); in ath10k_htc_control_rx_complete()
617 ep = &htc->endpoint[i]; in ath10k_htc_reset_endpoint_states()
618 ep->service_id = ATH10K_HTC_SVC_ID_UNUSED; in ath10k_htc_reset_endpoint_states()
619 ep->max_ep_message_len = 0; in ath10k_htc_reset_endpoint_states()
620 ep->max_tx_queue_depth = 0; in ath10k_htc_reset_endpoint_states()
621 ep->eid = i; in ath10k_htc_reset_endpoint_states()
622 ep->htc = htc; in ath10k_htc_reset_endpoint_states()
623 ep->tx_credit_flow_enabled = true; in ath10k_htc_reset_endpoint_states()
636 allocation = htc->total_transmit_credits; in ath10k_htc_get_credit_allocation()
646 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle()
647 struct ath10k *ar = htc->ar; in ath10k_htc_send_bundle()
652 ath10k_dbg(ar, ATH10K_DBG_HTC, "bundle skb len %d\n", bundle_skb->len); in ath10k_htc_send_bundle()
653 skb_len = bundle_skb->len; in ath10k_htc_send_bundle()
657 sg_item.transfer_id = ep->eid; in ath10k_htc_send_bundle()
659 sg_item.vaddr = bundle_skb->data; in ath10k_htc_send_bundle()
660 sg_item.len = bundle_skb->len; in ath10k_htc_send_bundle()
662 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send_bundle()
673 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_bundle()
675 skb_queue_tail(&ep->tx_complete_head, skb); in ath10k_htc_send_bundle()
680 queue_work(ar->workqueue_tx_complete, &ar->tx_complete_work); in ath10k_htc_send_bundle()
684 ret, ep->eid, skb_queue_len(&ep->tx_req_head), cn, skb_len); in ath10k_htc_send_bundle()
690 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_one_skb()
691 struct ath10k *ar = htc->ar; in ath10k_htc_send_one_skb()
694 ret = ath10k_htc_send(htc, ep->eid, skb); in ath10k_htc_send_one_skb()
697 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_one_skb()
700 ret, ep->eid, skb->len, skb_queue_len(&ep->tx_req_head)); in ath10k_htc_send_one_skb()
705 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle_skbs()
708 struct ath10k_htc_hdr *hdr; in ath10k_htc_send_bundle_skbs() local
712 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send_bundle_skbs()
713 return -ECOMM; in ath10k_htc_send_bundle_skbs()
715 if (ep->tx_credit_flow_enabled && in ath10k_htc_send_bundle_skbs()
716 ep->tx_credits < ATH10K_MIN_CREDIT_PER_HTC_TX_BUNDLE) in ath10k_htc_send_bundle_skbs()
719 bundles_left = ATH10K_MAX_MSG_PER_HTC_TX_BUNDLE * ep->tx_credit_size; in ath10k_htc_send_bundle_skbs()
723 return -ENOMEM; in ath10k_htc_send_bundle_skbs()
725 bundle_buf = bundle_skb->data; in ath10k_htc_send_bundle_skbs()
729 skb = skb_dequeue(&ep->tx_req_head); in ath10k_htc_send_bundle_skbs()
734 trans_len = skb->len + sizeof(*hdr); in ath10k_htc_send_bundle_skbs()
735 credit_remainder = trans_len % ep->tx_credit_size; in ath10k_htc_send_bundle_skbs()
738 credit_pad = ep->tx_credit_size - credit_remainder; in ath10k_htc_send_bundle_skbs()
743 bundle_buf + trans_len - bundle_skb->data, in ath10k_htc_send_bundle_skbs()
746 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_bundle_skbs()
751 bundle_skb->len = bundle_buf - bundle_skb->data; in ath10k_htc_send_bundle_skbs()
755 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_bundle_skbs()
759 if (skb_queue_len(&ep->tx_req_head) == 0) { in ath10k_htc_send_bundle_skbs()
764 if (ep->tx_credit_flow_enabled && in ath10k_htc_send_bundle_skbs()
765 ep->tx_credits < ATH10K_MIN_CREDIT_PER_HTC_TX_BUNDLE) { in ath10k_htc_send_bundle_skbs()
766 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_bundle_skbs()
771 ATH10K_MAX_MSG_PER_HTC_TX_BUNDLE * ep->tx_credit_size; in ath10k_htc_send_bundle_skbs()
775 skb_queue_head(&ep->tx_req_head, skb); in ath10k_htc_send_bundle_skbs()
776 return -ENOMEM; in ath10k_htc_send_bundle_skbs()
778 bundle_buf = bundle_skb->data; in ath10k_htc_send_bundle_skbs()
785 memcpy(bundle_buf, skb->data, skb->len); in ath10k_htc_send_bundle_skbs()
786 hdr = (struct ath10k_htc_hdr *)bundle_buf; in ath10k_htc_send_bundle_skbs()
787 hdr->flags |= ATH10K_HTC_FLAG_SEND_BUNDLE; in ath10k_htc_send_bundle_skbs()
788 hdr->pad_len = __cpu_to_le16(credit_pad); in ath10k_htc_send_bundle_skbs()
790 bundles_left -= trans_len; in ath10k_htc_send_bundle_skbs()
794 if (bundle_buf != bundle_skb->data) { in ath10k_htc_send_bundle_skbs()
795 bundle_skb->len = bundle_buf - bundle_skb->data; in ath10k_htc_send_bundle_skbs()
811 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_bundle_tx_work()
812 ep = &ar->htc.endpoint[i]; in ath10k_htc_bundle_tx_work()
814 if (!ep->bundle_tx) in ath10k_htc_bundle_tx_work()
818 ep->eid, skb_queue_len(&ep->tx_req_head)); in ath10k_htc_bundle_tx_work()
820 if (skb_queue_len(&ep->tx_req_head) >= in ath10k_htc_bundle_tx_work()
824 skb = skb_dequeue(&ep->tx_req_head); in ath10k_htc_bundle_tx_work()
841 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_tx_complete_work()
842 ep = &ar->htc.endpoint[i]; in ath10k_htc_tx_complete_work()
843 eid = ep->eid; in ath10k_htc_tx_complete_work()
844 if (ep->bundle_tx && eid == ar->htt.eid) { in ath10k_htc_tx_complete_work()
846 ep->eid, skb_queue_len(&ep->tx_complete_head)); in ath10k_htc_tx_complete_work()
849 skb = skb_dequeue(&ep->tx_complete_head); in ath10k_htc_tx_complete_work()
862 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send_hl()
863 struct ath10k *ar = htc->ar; in ath10k_htc_send_hl()
865 if (sizeof(struct ath10k_htc_hdr) + skb->len > ep->tx_credit_size) { in ath10k_htc_send_hl()
866 ath10k_dbg(ar, ATH10K_DBG_HTC, "tx exceed max len %d\n", skb->len); in ath10k_htc_send_hl()
867 return -ENOMEM; in ath10k_htc_send_hl()
871 eid, ep->bundle_tx, skb_queue_len(&ep->tx_req_head), skb->len); in ath10k_htc_send_hl()
873 if (ep->bundle_tx) { in ath10k_htc_send_hl()
874 skb_queue_tail(&ep->tx_req_head, skb); in ath10k_htc_send_hl()
875 queue_work(ar->workqueue, &ar->bundle_tx_work); in ath10k_htc_send_hl()
884 if (ep->htc->max_msgs_per_htc_bundle >= ATH10K_MIN_MSG_PER_HTC_TX_BUNDLE && in ath10k_htc_setup_tx_req()
885 !ep->bundle_tx) { in ath10k_htc_setup_tx_req()
886 ep->bundle_tx = true; in ath10k_htc_setup_tx_req()
887 skb_queue_head_init(&ep->tx_req_head); in ath10k_htc_setup_tx_req()
888 skb_queue_head_init(&ep->tx_complete_head); in ath10k_htc_setup_tx_req()
897 cancel_work_sync(&ar->bundle_tx_work); in ath10k_htc_stop_hl()
898 cancel_work_sync(&ar->tx_complete_work); in ath10k_htc_stop_hl()
900 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_stop_hl()
901 ep = &ar->htc.endpoint[i]; in ath10k_htc_stop_hl()
903 if (!ep->bundle_tx) in ath10k_htc_stop_hl()
907 ep->eid, skb_queue_len(&ep->tx_req_head)); in ath10k_htc_stop_hl()
909 skb_queue_purge(&ep->tx_req_head); in ath10k_htc_stop_hl()
915 struct ath10k *ar = htc->ar; in ath10k_htc_wait_target()
921 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
928 * properly in KVM PCI-passthrough sometimes. in ath10k_htc_wait_target()
933 ath10k_hif_send_complete_check(htc->ar, i, 1); in ath10k_htc_wait_target()
936 wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
940 status = -ETIMEDOUT; in ath10k_htc_wait_target()
948 if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) { in ath10k_htc_wait_target()
950 htc->control_resp_len); in ath10k_htc_wait_target()
951 return -ECOMM; in ath10k_htc_wait_target()
954 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_wait_target()
955 message_id = __le16_to_cpu(msg->hdr.message_id); in ath10k_htc_wait_target()
959 return -ECOMM; in ath10k_htc_wait_target()
962 if (ar->hw_params.use_fw_tx_credits) in ath10k_htc_wait_target()
963 htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count); in ath10k_htc_wait_target()
965 htc->total_transmit_credits = 1; in ath10k_htc_wait_target()
967 htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size); in ath10k_htc_wait_target()
971 htc->total_transmit_credits, in ath10k_htc_wait_target()
972 htc->target_credit_size, in ath10k_htc_wait_target()
973 msg->ready.credit_count); in ath10k_htc_wait_target()
975 if ((htc->total_transmit_credits == 0) || in ath10k_htc_wait_target()
976 (htc->target_credit_size == 0)) { in ath10k_htc_wait_target()
978 return -ECOMM; in ath10k_htc_wait_target()
984 if (htc->control_resp_len >= in ath10k_htc_wait_target()
985 sizeof(msg->hdr) + sizeof(msg->ready_ext)) { in ath10k_htc_wait_target()
986 htc->alt_data_credit_size = in ath10k_htc_wait_target()
987 __le16_to_cpu(msg->ready_ext.reserved) & in ath10k_htc_wait_target()
989 htc->max_msgs_per_htc_bundle = in ath10k_htc_wait_target()
990 min_t(u8, msg->ready_ext.max_msgs_per_htc_bundle, in ath10k_htc_wait_target()
994 htc->max_msgs_per_htc_bundle, in ath10k_htc_wait_target()
995 htc->alt_data_credit_size); in ath10k_htc_wait_target()
998 INIT_WORK(&ar->bundle_tx_work, ath10k_htc_bundle_tx_work); in ath10k_htc_wait_target()
999 INIT_WORK(&ar->tx_complete_work, ath10k_htc_tx_complete_work); in ath10k_htc_wait_target()
1008 struct ath10k *ar = htc->ar; in ath10k_htc_change_tx_credit_flow()
1009 struct ath10k_htc_ep *ep = &ar->htc.endpoint[eid]; in ath10k_htc_change_tx_credit_flow()
1011 ep->tx_credit_flow_enabled = enable; in ath10k_htc_change_tx_credit_flow()
1018 struct ath10k *ar = htc->ar; in ath10k_htc_connect_service()
1034 if (conn_req->service_id == ATH10K_HTC_SVC_ID_RSVD_CTRL) { in ath10k_htc_connect_service()
1043 conn_req->service_id); in ath10k_htc_connect_service()
1047 htc_service_name(conn_req->service_id)); in ath10k_htc_connect_service()
1049 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_connect_service()
1052 return -ENOMEM; in ath10k_htc_connect_service()
1055 length = sizeof(msg->hdr) + sizeof(msg->connect_service); in ath10k_htc_connect_service()
1057 memset(skb->data, 0, length); in ath10k_htc_connect_service()
1059 msg = (struct ath10k_htc_msg *)skb->data; in ath10k_htc_connect_service()
1060 msg->hdr.message_id = in ath10k_htc_connect_service()
1066 if (conn_req->service_id != ATH10K_HTC_SVC_ID_WMI_CONTROL) { in ath10k_htc_connect_service()
1071 req_msg = &msg->connect_service; in ath10k_htc_connect_service()
1072 req_msg->flags = __cpu_to_le16(flags); in ath10k_htc_connect_service()
1073 req_msg->service_id = __cpu_to_le16(conn_req->service_id); in ath10k_htc_connect_service()
1075 reinit_completion(&htc->ctl_resp); in ath10k_htc_connect_service()
1084 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_connect_service()
1088 return -ETIMEDOUT; in ath10k_htc_connect_service()
1092 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_connect_service()
1093 resp_msg = &msg->connect_service_response; in ath10k_htc_connect_service()
1094 message_id = __le16_to_cpu(msg->hdr.message_id); in ath10k_htc_connect_service()
1095 service_id = __le16_to_cpu(resp_msg->service_id); in ath10k_htc_connect_service()
1098 (htc->control_resp_len < sizeof(msg->hdr) + in ath10k_htc_connect_service()
1099 sizeof(msg->connect_service_response))) { in ath10k_htc_connect_service()
1101 return -EPROTO; in ath10k_htc_connect_service()
1107 resp_msg->status, resp_msg->eid); in ath10k_htc_connect_service()
1109 conn_resp->connect_resp_code = resp_msg->status; in ath10k_htc_connect_service()
1112 if (resp_msg->status != ATH10K_HTC_CONN_SVC_STATUS_SUCCESS) { in ath10k_htc_connect_service()
1115 resp_msg->status); in ath10k_htc_connect_service()
1116 return -EPROTO; in ath10k_htc_connect_service()
1119 assigned_eid = (enum ath10k_htc_ep_id)resp_msg->eid; in ath10k_htc_connect_service()
1120 max_msg_size = __le16_to_cpu(resp_msg->max_msg_size); in ath10k_htc_connect_service()
1125 return -EPROTO; in ath10k_htc_connect_service()
1128 return -EPROTO; in ath10k_htc_connect_service()
1130 ep = &htc->endpoint[assigned_eid]; in ath10k_htc_connect_service()
1131 ep->eid = assigned_eid; in ath10k_htc_connect_service()
1133 if (ep->service_id != ATH10K_HTC_SVC_ID_UNUSED) in ath10k_htc_connect_service()
1134 return -EPROTO; in ath10k_htc_connect_service()
1137 conn_resp->eid = assigned_eid; in ath10k_htc_connect_service()
1138 conn_resp->max_msg_len = __le16_to_cpu(resp_msg->max_msg_size); in ath10k_htc_connect_service()
1141 ep->service_id = conn_req->service_id; in ath10k_htc_connect_service()
1142 ep->max_tx_queue_depth = conn_req->max_send_queue_depth; in ath10k_htc_connect_service()
1143 ep->max_ep_message_len = __le16_to_cpu(resp_msg->max_msg_size); in ath10k_htc_connect_service()
1144 ep->tx_credits = tx_alloc; in ath10k_htc_connect_service()
1145 ep->tx_credit_size = htc->target_credit_size; in ath10k_htc_connect_service()
1147 if (conn_req->service_id == ATH10K_HTC_SVC_ID_HTT_DATA_MSG && in ath10k_htc_connect_service()
1148 htc->alt_data_credit_size != 0) in ath10k_htc_connect_service()
1149 ep->tx_credit_size = htc->alt_data_credit_size; in ath10k_htc_connect_service()
1152 ep->ep_ops = conn_req->ep_ops; in ath10k_htc_connect_service()
1154 status = ath10k_hif_map_service_to_pipe(htc->ar, in ath10k_htc_connect_service()
1155 ep->service_id, in ath10k_htc_connect_service()
1156 &ep->ul_pipe_id, in ath10k_htc_connect_service()
1157 &ep->dl_pipe_id); in ath10k_htc_connect_service()
1160 ep->service_id); in ath10k_htc_connect_service()
1166 htc_service_name(ep->service_id), ep->ul_pipe_id, in ath10k_htc_connect_service()
1167 ep->dl_pipe_id, ep->eid); in ath10k_htc_connect_service()
1169 if (disable_credit_flow_ctrl && ep->tx_credit_flow_enabled) { in ath10k_htc_connect_service()
1170 ep->tx_credit_flow_enabled = false; in ath10k_htc_connect_service()
1173 htc_service_name(ep->service_id), assigned_eid); in ath10k_htc_connect_service()
1189 /* FW/HTC requires 4-byte aligned streams */ in ath10k_htc_alloc_skb()
1190 if (!IS_ALIGNED((unsigned long)skb->data, 4)) in ath10k_htc_alloc_skb()
1198 trace_ath10k_htt_pktlog(ar, skb->data, skb->len); in ath10k_htc_pktlog_process_rx()
1217 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); in ath10k_htc_pktlog_connect()
1248 struct ath10k *ar = htc->ar; in ath10k_htc_start()
1253 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_start()
1255 return -ENOMEM; in ath10k_htc_start()
1257 skb_put(skb, sizeof(msg->hdr) + sizeof(msg->setup_complete_ext)); in ath10k_htc_start()
1258 memset(skb->data, 0, skb->len); in ath10k_htc_start()
1260 msg = (struct ath10k_htc_msg *)skb->data; in ath10k_htc_start()
1261 msg->hdr.message_id = in ath10k_htc_start()
1264 if (ar->hif.bus == ATH10K_BUS_SDIO) { in ath10k_htc_start()
1266 msg->setup_complete_ext.flags = in ath10k_htc_start()
1268 msg->setup_complete_ext.max_msgs_per_bundled_recv = in ath10k_htc_start()
1269 htc->max_msgs_per_htc_bundle; in ath10k_htc_start()
1294 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_init()
1298 spin_lock_init(&htc->tx_lock); in ath10k_htc_init()
1302 htc->ar = ar; in ath10k_htc_init()
1320 init_completion(&htc->ctl_resp); in ath10k_htc_init()