Lines Matching full:htc
22 /* FW/HTC requires 4-byte aligned streams */ in ath12k_htc_alloc_skb()
24 ath12k_warn(ab, "Unaligned HTC tx skb\n"); in ath12k_htc_alloc_skb()
69 spin_lock_bh(&ep->htc->tx_lock); in ath12k_htc_prepare_tx_skb()
71 spin_unlock_bh(&ep->htc->tx_lock); in ath12k_htc_prepare_tx_skb()
74 int ath12k_htc_send(struct ath12k_htc *htc, in ath12k_htc_send() argument
78 struct ath12k_htc_ep *ep = &htc->endpoint[eid]; in ath12k_htc_send()
80 struct device *dev = htc->ab->dev; in ath12k_htc_send()
81 struct ath12k_base *ab = htc->ab; in ath12k_htc_send()
93 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size); in ath12k_htc_send()
94 spin_lock_bh(&htc->tx_lock); in ath12k_htc_send()
97 "htc insufficient credits ep %d required %d available %d\n", in ath12k_htc_send()
99 spin_unlock_bh(&htc->tx_lock); in ath12k_htc_send()
105 "htc ep %d consumed %d credits (total %d)\n", in ath12k_htc_send()
107 spin_unlock_bh(&htc->tx_lock); in ath12k_htc_send()
119 ret = ath12k_ce_send(htc->ab, skb, ep->ul_pipe_id, ep->eid); in ath12k_htc_send()
129 spin_lock_bh(&htc->tx_lock); in ath12k_htc_send()
132 "htc ep %d reverted %d credits back (total %d)\n", in ath12k_htc_send()
134 spin_unlock_bh(&htc->tx_lock); in ath12k_htc_send()
137 ep->ep_ops.ep_tx_credits(htc->ab); in ath12k_htc_send()
145 ath12k_htc_process_credit_report(struct ath12k_htc *htc, in ath12k_htc_process_credit_report() argument
150 struct ath12k_base *ab = htc->ab; in ath12k_htc_process_credit_report()
159 spin_lock_bh(&htc->tx_lock); in ath12k_htc_process_credit_report()
164 ep = &htc->endpoint[report->eid]; in ath12k_htc_process_credit_report()
167 ath12k_dbg(ab, ATH12K_DBG_HTC, "htc ep %d got %d credits (total %d)\n", in ath12k_htc_process_credit_report()
171 spin_unlock_bh(&htc->tx_lock); in ath12k_htc_process_credit_report()
172 ep->ep_ops.ep_tx_credits(htc->ab); in ath12k_htc_process_credit_report()
173 spin_lock_bh(&htc->tx_lock); in ath12k_htc_process_credit_report()
176 spin_unlock_bh(&htc->tx_lock); in ath12k_htc_process_credit_report()
179 static int ath12k_htc_process_trailer(struct ath12k_htc *htc, in ath12k_htc_process_trailer() argument
184 struct ath12k_base *ab = htc->ab; in ath12k_htc_process_trailer()
213 ath12k_htc_process_credit_report(htc, in ath12k_htc_process_trailer()
251 struct ath12k_htc *htc = &ab->htc; in ath12k_htc_rx_completion_handler() local
266 ath12k_warn(ab, "HTC Rx: invalid eid %d\n", eid); in ath12k_htc_rx_completion_handler()
270 ep = &htc->endpoint[eid]; in ath12k_htc_rx_completion_handler()
275 ath12k_warn(ab, "HTC rx frame too long, len: %zu\n", in ath12k_htc_rx_completion_handler()
281 ath12k_warn(ab, "HTC Rx: insufficient length, got %d, expected %d\n", in ath12k_htc_rx_completion_handler()
308 status = ath12k_htc_process_trailer(htc, trailer, in ath12k_htc_rx_completion_handler()
326 /* handle HTC control message */ in ath12k_htc_rx_completion_handler()
327 if (completion_done(&htc->ctl_resp)) { in ath12k_htc_rx_completion_handler()
331 ath12k_warn(ab, "HTC rx ctrl still processing\n"); in ath12k_htc_rx_completion_handler()
332 complete(&htc->ctl_resp); in ath12k_htc_rx_completion_handler()
336 htc->control_resp_len = in ath12k_htc_rx_completion_handler()
340 memcpy(htc->control_resp_buffer, skb->data, in ath12k_htc_rx_completion_handler()
341 htc->control_resp_len); in ath12k_htc_rx_completion_handler()
343 complete(&htc->ctl_resp); in ath12k_htc_rx_completion_handler()
354 ath12k_warn(ab, "ignoring unsolicited htc ep0 event %u\n", in ath12k_htc_rx_completion_handler()
361 ath12k_dbg(ab, ATH12K_DBG_HTC, "htc rx completion ep %d skb %pK\n", in ath12k_htc_rx_completion_handler()
380 ath12k_warn(ab, "unexpected htc rx\n"); in ath12k_htc_control_rx_complete()
424 static void ath12k_htc_reset_endpoint_states(struct ath12k_htc *htc) in ath12k_htc_reset_endpoint_states() argument
430 ep = &htc->endpoint[i]; in ath12k_htc_reset_endpoint_states()
435 ep->htc = htc; in ath12k_htc_reset_endpoint_states()
440 static u8 ath12k_htc_get_credit_allocation(struct ath12k_htc *htc, in ath12k_htc_get_credit_allocation() argument
446 serv_entry = htc->service_alloc_table; in ath12k_htc_get_credit_allocation()
458 static int ath12k_htc_setup_target_buffer_assignments(struct ath12k_htc *htc) in ath12k_htc_setup_target_buffer_assignments() argument
468 credits = htc->total_transmit_credits; in ath12k_htc_setup_target_buffer_assignments()
469 serv_entry = htc->service_alloc_table; in ath12k_htc_setup_target_buffer_assignments()
471 if ((htc->wmi_ep_count == 0) || in ath12k_htc_setup_target_buffer_assignments()
472 (htc->wmi_ep_count > ARRAY_SIZE(svc_id))) in ath12k_htc_setup_target_buffer_assignments()
476 credits = credits / htc->wmi_ep_count; in ath12k_htc_setup_target_buffer_assignments()
477 for (i = 0; i < htc->wmi_ep_count; i++) { in ath12k_htc_setup_target_buffer_assignments()
485 int ath12k_htc_wait_target(struct ath12k_htc *htc) in ath12k_htc_wait_target() argument
488 struct ath12k_base *ab = htc->ab; in ath12k_htc_wait_target()
495 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath12k_htc_wait_target()
501 ath12k_ce_per_engine_service(htc->ab, i); in ath12k_htc_wait_target()
504 wait_for_completion_timeout(&htc->ctl_resp, in ath12k_htc_wait_target()
516 if (htc->control_resp_len < sizeof(*ready)) { in ath12k_htc_wait_target()
517 ath12k_warn(ab, "Invalid HTC ready msg len:%d\n", in ath12k_htc_wait_target()
518 htc->control_resp_len); in ath12k_htc_wait_target()
522 ready = (struct ath12k_htc_ready *)htc->control_resp_buffer; in ath12k_htc_wait_target()
529 ath12k_warn(ab, "Invalid HTC ready msg: 0x%x\n", message_id); in ath12k_htc_wait_target()
533 htc->total_transmit_credits = credit_count; in ath12k_htc_wait_target()
534 htc->target_credit_size = credit_size; in ath12k_htc_wait_target()
538 htc->total_transmit_credits, htc->target_credit_size); in ath12k_htc_wait_target()
540 if ((htc->total_transmit_credits == 0) || in ath12k_htc_wait_target()
541 (htc->target_credit_size == 0)) { in ath12k_htc_wait_target()
546 ath12k_htc_setup_target_buffer_assignments(htc); in ath12k_htc_wait_target()
551 int ath12k_htc_connect_service(struct ath12k_htc *htc, in ath12k_htc_connect_service() argument
555 struct ath12k_base *ab = htc->ab; in ath12k_htc_connect_service()
569 /* special case for HTC pseudo control service */ in ath12k_htc_connect_service()
578 tx_alloc = ath12k_htc_get_credit_allocation(htc, in ath12k_htc_connect_service()
582 "boot htc service %s does not allocate target credits\n", in ath12k_htc_connect_service()
587 ath12k_warn(ab, "Failed to allocate HTC packet\n"); in ath12k_htc_connect_service()
613 reinit_completion(&htc->ctl_resp); in ath12k_htc_connect_service()
615 status = ath12k_htc_send(htc, ATH12K_HTC_EP_0, skb); in ath12k_htc_connect_service()
622 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath12k_htc_connect_service()
630 resp_msg = (struct ath12k_htc_conn_svc_resp *)htc->control_resp_buffer; in ath12k_htc_connect_service()
636 (htc->control_resp_len < sizeof(*resp_msg))) { in ath12k_htc_connect_service()
642 "HTC Service %s connect response: status: %u, assigned ep: %u\n", in ath12k_htc_connect_service()
652 ath12k_err(ab, "HTC Service %s connect request failed: 0x%x)\n", in ath12k_htc_connect_service()
672 ep = &htc->endpoint[assigned_eid]; in ath12k_htc_connect_service()
693 status = ath12k_hif_map_service_to_pipe(htc->ab, in ath12k_htc_connect_service()
701 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath12k_htc_connect_service()
708 "boot htc service '%s' eid %d TX flow control disabled\n", in ath12k_htc_connect_service()
715 int ath12k_htc_start(struct ath12k_htc *htc) in ath12k_htc_start() argument
719 struct ath12k_base *ab = htc->ab; in ath12k_htc_start()
733 ath12k_dbg(ab, ATH12K_DBG_HTC, "HTC is using TX credit flow control\n"); in ath12k_htc_start()
735 status = ath12k_htc_send(htc, ATH12K_HTC_EP_0, skb); in ath12k_htc_start()
746 struct ath12k_htc *htc = &ab->htc; in ath12k_htc_init() local
751 spin_lock_init(&htc->tx_lock); in ath12k_htc_init()
753 ath12k_htc_reset_endpoint_states(htc); in ath12k_htc_init()
755 htc->ab = ab; in ath12k_htc_init()
759 htc->wmi_ep_count = 1; in ath12k_htc_init()
763 htc->wmi_ep_count = 2; in ath12k_htc_init()
766 htc->wmi_ep_count = 3; in ath12k_htc_init()
769 htc->wmi_ep_count = ab->hw_params->max_radios; in ath12k_htc_init()
773 /* setup our pseudo HTC control endpoint connection */ in ath12k_htc_init()
780 ret = ath12k_htc_connect_service(htc, &conn_req, &conn_resp); in ath12k_htc_init()
782 ath12k_err(ab, "could not connect to htc service (%d)\n", ret); in ath12k_htc_init()
786 init_completion(&htc->ctl_resp); in ath12k_htc_init()