Lines Matching full:htc
22 /* FW/HTC requires 4-byte aligned streams */ in ath11k_htc_alloc_skb()
24 ath11k_warn(ab, "Unaligned HTC tx skb\n"); in ath11k_htc_alloc_skb()
69 spin_lock_bh(&ep->htc->tx_lock); in ath11k_htc_prepare_tx_skb()
71 spin_unlock_bh(&ep->htc->tx_lock); in ath11k_htc_prepare_tx_skb()
74 int ath11k_htc_send(struct ath11k_htc *htc, in ath11k_htc_send() argument
78 struct ath11k_htc_ep *ep = &htc->endpoint[eid]; in ath11k_htc_send()
80 struct device *dev = htc->ab->dev; in ath11k_htc_send()
81 struct ath11k_base *ab = htc->ab; in ath11k_htc_send()
95 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size); in ath11k_htc_send()
96 spin_lock_bh(&htc->tx_lock); in ath11k_htc_send()
101 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
109 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
125 ret = ath11k_ce_send(htc->ab, skb, ep->ul_pipe_id, ep->eid); in ath11k_htc_send()
135 spin_lock_bh(&htc->tx_lock); in ath11k_htc_send()
140 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
143 ep->ep_ops.ep_tx_credits(htc->ab); in ath11k_htc_send()
151 ath11k_htc_process_credit_report(struct ath11k_htc *htc, in ath11k_htc_process_credit_report() argument
156 struct ath11k_base *ab = htc->ab; in ath11k_htc_process_credit_report()
165 spin_lock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
170 ep = &htc->endpoint[report->eid]; in ath11k_htc_process_credit_report()
177 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
178 ep->ep_ops.ep_tx_credits(htc->ab); in ath11k_htc_process_credit_report()
179 spin_lock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
182 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
185 static int ath11k_htc_process_trailer(struct ath11k_htc *htc, in ath11k_htc_process_trailer() argument
190 struct ath11k_base *ab = htc->ab; in ath11k_htc_process_trailer()
220 ath11k_htc_process_credit_report(htc, in ath11k_htc_process_trailer()
258 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_tx_completion_handler() local
269 ep = &htc->endpoint[eid]; in ath11k_htc_tx_completion_handler()
270 spin_lock_bh(&htc->tx_lock); in ath11k_htc_tx_completion_handler()
272 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_tx_completion_handler()
277 ep_tx_complete(htc->ab, skb); in ath11k_htc_tx_completion_handler()
289 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_rx_completion_handler() local
304 ath11k_warn(ab, "HTC Rx: invalid eid %d\n", eid); in ath11k_htc_rx_completion_handler()
308 ep = &htc->endpoint[eid]; in ath11k_htc_rx_completion_handler()
313 ath11k_warn(ab, "HTC rx frame too long, len: %zu\n", in ath11k_htc_rx_completion_handler()
319 ath11k_warn(ab, "HTC Rx: insufficient length, got %d, expected %d\n", in ath11k_htc_rx_completion_handler()
348 status = ath11k_htc_process_trailer(htc, trailer, in ath11k_htc_rx_completion_handler()
371 /* handle HTC control message */ in ath11k_htc_rx_completion_handler()
372 if (completion_done(&htc->ctl_resp)) { in ath11k_htc_rx_completion_handler()
376 ath11k_warn(ab, "HTC rx ctrl still processing\n"); in ath11k_htc_rx_completion_handler()
377 complete(&htc->ctl_resp); in ath11k_htc_rx_completion_handler()
381 htc->control_resp_len = in ath11k_htc_rx_completion_handler()
385 memcpy(htc->control_resp_buffer, skb->data, in ath11k_htc_rx_completion_handler()
386 htc->control_resp_len); in ath11k_htc_rx_completion_handler()
388 complete(&htc->ctl_resp); in ath11k_htc_rx_completion_handler()
400 ath11k_warn(ab, "ignoring unsolicited htc ep0 event %ld\n", in ath11k_htc_rx_completion_handler()
424 ath11k_warn(ab, "unexpected htc rx\n"); in ath11k_htc_control_rx_complete()
466 static void ath11k_htc_reset_endpoint_states(struct ath11k_htc *htc) in ath11k_htc_reset_endpoint_states() argument
472 ep = &htc->endpoint[i]; in ath11k_htc_reset_endpoint_states()
477 ep->htc = htc; in ath11k_htc_reset_endpoint_states()
482 static u8 ath11k_htc_get_credit_allocation(struct ath11k_htc *htc, in ath11k_htc_get_credit_allocation() argument
488 if (htc->service_alloc_table[i].service_id == service_id) { in ath11k_htc_get_credit_allocation()
490 htc->service_alloc_table[i].credit_allocation; in ath11k_htc_get_credit_allocation()
497 static int ath11k_htc_setup_target_buffer_assignments(struct ath11k_htc *htc) in ath11k_htc_setup_target_buffer_assignments() argument
507 credits = htc->total_transmit_credits; in ath11k_htc_setup_target_buffer_assignments()
508 serv_entry = htc->service_alloc_table; in ath11k_htc_setup_target_buffer_assignments()
510 if ((htc->wmi_ep_count == 0) || in ath11k_htc_setup_target_buffer_assignments()
511 (htc->wmi_ep_count > ARRAY_SIZE(svc_id))) in ath11k_htc_setup_target_buffer_assignments()
515 credits = credits / htc->wmi_ep_count; in ath11k_htc_setup_target_buffer_assignments()
516 for (i = 0; i < htc->wmi_ep_count; i++) { in ath11k_htc_setup_target_buffer_assignments()
524 int ath11k_htc_wait_target(struct ath11k_htc *htc) in ath11k_htc_wait_target() argument
527 struct ath11k_base *ab = htc->ab; in ath11k_htc_wait_target()
534 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_wait_target()
540 ath11k_ce_per_engine_service(htc->ab, i); in ath11k_htc_wait_target()
543 wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_wait_target()
555 if (htc->control_resp_len < sizeof(*ready)) { in ath11k_htc_wait_target()
556 ath11k_warn(ab, "Invalid HTC ready msg len:%d\n", in ath11k_htc_wait_target()
557 htc->control_resp_len); in ath11k_htc_wait_target()
561 ready = (struct ath11k_htc_ready *)htc->control_resp_buffer; in ath11k_htc_wait_target()
568 ath11k_warn(ab, "Invalid HTC ready msg: 0x%x\n", message_id); in ath11k_htc_wait_target()
572 htc->total_transmit_credits = credit_count; in ath11k_htc_wait_target()
573 htc->target_credit_size = credit_size; in ath11k_htc_wait_target()
577 htc->total_transmit_credits, htc->target_credit_size); in ath11k_htc_wait_target()
579 if ((htc->total_transmit_credits == 0) || in ath11k_htc_wait_target()
580 (htc->target_credit_size == 0)) { in ath11k_htc_wait_target()
589 htc->total_transmit_credits = 1; in ath11k_htc_wait_target()
591 ath11k_htc_setup_target_buffer_assignments(htc); in ath11k_htc_wait_target()
596 int ath11k_htc_connect_service(struct ath11k_htc *htc, in ath11k_htc_connect_service() argument
600 struct ath11k_base *ab = htc->ab; in ath11k_htc_connect_service()
614 /* special case for HTC pseudo control service */ in ath11k_htc_connect_service()
623 tx_alloc = ath11k_htc_get_credit_allocation(htc, in ath11k_htc_connect_service()
627 "htc service %s does not allocate target credits\n", in ath11k_htc_connect_service()
630 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab); in ath11k_htc_connect_service()
632 ath11k_warn(ab, "Failed to allocate HTC packet\n"); in ath11k_htc_connect_service()
663 reinit_completion(&htc->ctl_resp); in ath11k_htc_connect_service()
665 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb); in ath11k_htc_connect_service()
672 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_connect_service()
680 resp_msg = (struct ath11k_htc_conn_svc_resp *)htc->control_resp_buffer; in ath11k_htc_connect_service()
686 (htc->control_resp_len < sizeof(*resp_msg))) { in ath11k_htc_connect_service()
702 ath11k_err(ab, "HTC Service %s connect request failed: 0x%x)\n", in ath11k_htc_connect_service()
723 ep = &htc->endpoint[assigned_eid]; in ath11k_htc_connect_service()
744 status = ath11k_hif_map_service_to_pipe(htc->ab, in ath11k_htc_connect_service()
752 "htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath11k_htc_connect_service()
759 "htc service '%s' eid %d tx flow control disabled\n", in ath11k_htc_connect_service()
766 int ath11k_htc_start(struct ath11k_htc *htc) in ath11k_htc_start() argument
770 struct ath11k_base *ab = htc->ab; in ath11k_htc_start()
773 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab); in ath11k_htc_start()
789 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb); in ath11k_htc_start()
800 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_init() local
805 spin_lock_init(&htc->tx_lock); in ath11k_htc_init()
807 ath11k_htc_reset_endpoint_states(htc); in ath11k_htc_init()
809 htc->ab = ab; in ath11k_htc_init()
813 htc->wmi_ep_count = 1; in ath11k_htc_init()
817 htc->wmi_ep_count = 2; in ath11k_htc_init()
820 htc->wmi_ep_count = 3; in ath11k_htc_init()
823 htc->wmi_ep_count = ab->hw_params.max_radios; in ath11k_htc_init()
827 /* setup our pseudo HTC control endpoint connection */ in ath11k_htc_init()
836 ret = ath11k_htc_connect_service(htc, &conn_req, &conn_resp); in ath11k_htc_init()
838 ath11k_err(ab, "could not connect to htc service (%d)\n", ret); in ath11k_htc_init()
842 init_completion(&htc->ctl_resp); in ath11k_htc_init()