Lines Matching full:htc
21 /* FW/HTC requires 4-byte aligned streams */ in ath11k_htc_alloc_skb()
23 ath11k_warn(ab, "Unaligned HTC tx skb\n"); in ath11k_htc_alloc_skb()
68 spin_lock_bh(&ep->htc->tx_lock); in ath11k_htc_prepare_tx_skb()
70 spin_unlock_bh(&ep->htc->tx_lock); in ath11k_htc_prepare_tx_skb()
73 int ath11k_htc_send(struct ath11k_htc *htc, in ath11k_htc_send() argument
77 struct ath11k_htc_ep *ep = &htc->endpoint[eid]; in ath11k_htc_send()
79 struct device *dev = htc->ab->dev; in ath11k_htc_send()
80 struct ath11k_base *ab = htc->ab; in ath11k_htc_send()
94 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size); in ath11k_htc_send()
95 spin_lock_bh(&htc->tx_lock); in ath11k_htc_send()
100 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
108 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
124 ret = ath11k_ce_send(htc->ab, skb, ep->ul_pipe_id, ep->eid); in ath11k_htc_send()
134 spin_lock_bh(&htc->tx_lock); in ath11k_htc_send()
139 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_send()
142 ep->ep_ops.ep_tx_credits(htc->ab); in ath11k_htc_send()
150 ath11k_htc_process_credit_report(struct ath11k_htc *htc, in ath11k_htc_process_credit_report() argument
155 struct ath11k_base *ab = htc->ab; in ath11k_htc_process_credit_report()
164 spin_lock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
169 ep = &htc->endpoint[report->eid]; in ath11k_htc_process_credit_report()
176 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
177 ep->ep_ops.ep_tx_credits(htc->ab); in ath11k_htc_process_credit_report()
178 spin_lock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
181 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_process_credit_report()
184 static int ath11k_htc_process_trailer(struct ath11k_htc *htc, in ath11k_htc_process_trailer() argument
189 struct ath11k_base *ab = htc->ab; in ath11k_htc_process_trailer()
219 ath11k_htc_process_credit_report(htc, in ath11k_htc_process_trailer()
257 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_tx_completion_handler() local
268 ep = &htc->endpoint[eid]; in ath11k_htc_tx_completion_handler()
269 spin_lock_bh(&htc->tx_lock); in ath11k_htc_tx_completion_handler()
271 spin_unlock_bh(&htc->tx_lock); in ath11k_htc_tx_completion_handler()
276 ep_tx_complete(htc->ab, skb); in ath11k_htc_tx_completion_handler()
288 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_rx_completion_handler() local
303 ath11k_warn(ab, "HTC Rx: invalid eid %d\n", eid); in ath11k_htc_rx_completion_handler()
307 ep = &htc->endpoint[eid]; in ath11k_htc_rx_completion_handler()
312 ath11k_warn(ab, "HTC rx frame too long, len: %zu\n", in ath11k_htc_rx_completion_handler()
318 ath11k_warn(ab, "HTC Rx: insufficient length, got %d, expected %d\n", in ath11k_htc_rx_completion_handler()
347 status = ath11k_htc_process_trailer(htc, trailer, in ath11k_htc_rx_completion_handler()
370 /* handle HTC control message */ in ath11k_htc_rx_completion_handler()
371 if (completion_done(&htc->ctl_resp)) { in ath11k_htc_rx_completion_handler()
375 ath11k_warn(ab, "HTC rx ctrl still processing\n"); in ath11k_htc_rx_completion_handler()
376 complete(&htc->ctl_resp); in ath11k_htc_rx_completion_handler()
380 htc->control_resp_len = in ath11k_htc_rx_completion_handler()
384 memcpy(htc->control_resp_buffer, skb->data, in ath11k_htc_rx_completion_handler()
385 htc->control_resp_len); in ath11k_htc_rx_completion_handler()
387 complete(&htc->ctl_resp); in ath11k_htc_rx_completion_handler()
399 ath11k_warn(ab, "ignoring unsolicited htc ep0 event %ld\n", in ath11k_htc_rx_completion_handler()
423 ath11k_warn(ab, "unexpected htc rx\n"); in ath11k_htc_control_rx_complete()
465 static void ath11k_htc_reset_endpoint_states(struct ath11k_htc *htc) in ath11k_htc_reset_endpoint_states() argument
471 ep = &htc->endpoint[i]; in ath11k_htc_reset_endpoint_states()
476 ep->htc = htc; in ath11k_htc_reset_endpoint_states()
481 static u8 ath11k_htc_get_credit_allocation(struct ath11k_htc *htc, in ath11k_htc_get_credit_allocation() argument
487 if (htc->service_alloc_table[i].service_id == service_id) { in ath11k_htc_get_credit_allocation()
489 htc->service_alloc_table[i].credit_allocation; in ath11k_htc_get_credit_allocation()
496 static int ath11k_htc_setup_target_buffer_assignments(struct ath11k_htc *htc) in ath11k_htc_setup_target_buffer_assignments() argument
506 credits = htc->total_transmit_credits; in ath11k_htc_setup_target_buffer_assignments()
507 serv_entry = htc->service_alloc_table; in ath11k_htc_setup_target_buffer_assignments()
509 if ((htc->wmi_ep_count == 0) || in ath11k_htc_setup_target_buffer_assignments()
510 (htc->wmi_ep_count > ARRAY_SIZE(svc_id))) in ath11k_htc_setup_target_buffer_assignments()
514 credits = credits / htc->wmi_ep_count; in ath11k_htc_setup_target_buffer_assignments()
515 for (i = 0; i < htc->wmi_ep_count; i++) { in ath11k_htc_setup_target_buffer_assignments()
523 int ath11k_htc_wait_target(struct ath11k_htc *htc) in ath11k_htc_wait_target() argument
526 struct ath11k_base *ab = htc->ab; in ath11k_htc_wait_target()
533 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_wait_target()
539 ath11k_ce_per_engine_service(htc->ab, i); in ath11k_htc_wait_target()
542 wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_wait_target()
554 if (htc->control_resp_len < sizeof(*ready)) { in ath11k_htc_wait_target()
555 ath11k_warn(ab, "Invalid HTC ready msg len:%d\n", in ath11k_htc_wait_target()
556 htc->control_resp_len); in ath11k_htc_wait_target()
560 ready = (struct ath11k_htc_ready *)htc->control_resp_buffer; in ath11k_htc_wait_target()
567 ath11k_warn(ab, "Invalid HTC ready msg: 0x%x\n", message_id); in ath11k_htc_wait_target()
571 htc->total_transmit_credits = credit_count; in ath11k_htc_wait_target()
572 htc->target_credit_size = credit_size; in ath11k_htc_wait_target()
576 htc->total_transmit_credits, htc->target_credit_size); in ath11k_htc_wait_target()
578 if ((htc->total_transmit_credits == 0) || in ath11k_htc_wait_target()
579 (htc->target_credit_size == 0)) { in ath11k_htc_wait_target()
588 htc->total_transmit_credits = 1; in ath11k_htc_wait_target()
590 ath11k_htc_setup_target_buffer_assignments(htc); in ath11k_htc_wait_target()
595 int ath11k_htc_connect_service(struct ath11k_htc *htc, in ath11k_htc_connect_service() argument
599 struct ath11k_base *ab = htc->ab; in ath11k_htc_connect_service()
613 /* special case for HTC pseudo control service */ in ath11k_htc_connect_service()
622 tx_alloc = ath11k_htc_get_credit_allocation(htc, in ath11k_htc_connect_service()
626 "htc service %s does not allocate target credits\n", in ath11k_htc_connect_service()
629 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab); in ath11k_htc_connect_service()
631 ath11k_warn(ab, "Failed to allocate HTC packet\n"); in ath11k_htc_connect_service()
662 reinit_completion(&htc->ctl_resp); in ath11k_htc_connect_service()
664 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb); in ath11k_htc_connect_service()
671 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath11k_htc_connect_service()
679 resp_msg = (struct ath11k_htc_conn_svc_resp *)htc->control_resp_buffer; in ath11k_htc_connect_service()
685 (htc->control_resp_len < sizeof(*resp_msg))) { in ath11k_htc_connect_service()
701 ath11k_err(ab, "HTC Service %s connect request failed: 0x%x)\n", in ath11k_htc_connect_service()
722 ep = &htc->endpoint[assigned_eid]; in ath11k_htc_connect_service()
743 status = ath11k_hif_map_service_to_pipe(htc->ab, in ath11k_htc_connect_service()
751 "htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath11k_htc_connect_service()
758 "htc service '%s' eid %d tx flow control disabled\n", in ath11k_htc_connect_service()
765 int ath11k_htc_start(struct ath11k_htc *htc) in ath11k_htc_start() argument
769 struct ath11k_base *ab = htc->ab; in ath11k_htc_start()
772 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab); in ath11k_htc_start()
788 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb); in ath11k_htc_start()
799 struct ath11k_htc *htc = &ab->htc; in ath11k_htc_init() local
804 spin_lock_init(&htc->tx_lock); in ath11k_htc_init()
806 ath11k_htc_reset_endpoint_states(htc); in ath11k_htc_init()
808 htc->ab = ab; in ath11k_htc_init()
812 htc->wmi_ep_count = 1; in ath11k_htc_init()
816 htc->wmi_ep_count = 2; in ath11k_htc_init()
819 htc->wmi_ep_count = 3; in ath11k_htc_init()
822 htc->wmi_ep_count = ab->hw_params.max_radios; in ath11k_htc_init()
826 /* setup our pseudo HTC control endpoint connection */ in ath11k_htc_init()
835 ret = ath11k_htc_connect_service(htc, &conn_req, &conn_resp); in ath11k_htc_init()
837 ath11k_err(ab, "could not connect to htc service (%d)\n", ret); in ath11k_htc_init()
841 init_completion(&htc->ctl_resp); in ath11k_htc_init()