Lines Matching refs:htc
67 spin_lock_bh(&ep->htc->tx_lock);
69 spin_unlock_bh(&ep->htc->tx_lock);
72 int ath11k_htc_send(struct ath11k_htc *htc,
76 struct ath11k_htc_ep *ep = &htc->endpoint[eid];
78 struct device *dev = htc->ab->dev;
79 struct ath11k_base *ab = htc->ab;
91 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size);
92 spin_lock_bh(&htc->tx_lock);
95 "htc insufficient credits ep %d required %d available %d\n",
97 spin_unlock_bh(&htc->tx_lock);
103 "htc ep %d consumed %d credits (total %d)\n",
105 spin_unlock_bh(&htc->tx_lock);
118 ret = ath11k_ce_send(htc->ab, skb, ep->ul_pipe_id, ep->eid);
128 spin_lock_bh(&htc->tx_lock);
131 "htc ep %d reverted %d credits back (total %d)\n",
133 spin_unlock_bh(&htc->tx_lock);
136 ep->ep_ops.ep_tx_credits(htc->ab);
144 ath11k_htc_process_credit_report(struct ath11k_htc *htc,
149 struct ath11k_base *ab = htc->ab;
158 spin_lock_bh(&htc->tx_lock);
163 ep = &htc->endpoint[report->eid];
166 ath11k_dbg(ab, ATH11K_DBG_HTC, "htc ep %d got %d credits (total %d)\n",
170 spin_unlock_bh(&htc->tx_lock);
171 ep->ep_ops.ep_tx_credits(htc->ab);
172 spin_lock_bh(&htc->tx_lock);
175 spin_unlock_bh(&htc->tx_lock);
178 static int ath11k_htc_process_trailer(struct ath11k_htc *htc,
183 struct ath11k_base *ab = htc->ab;
212 ath11k_htc_process_credit_report(htc,
238 struct ath11k_htc *htc = &ab->htc;
257 ep = &htc->endpoint[eid];
294 status = ath11k_htc_process_trailer(htc, trailer,
313 if (completion_done(&htc->ctl_resp)) {
318 complete(&htc->ctl_resp);
322 htc->control_resp_len =
326 memcpy(htc->control_resp_buffer, skb->data,
327 htc->control_resp_len);
329 complete(&htc->ctl_resp);
332 ath11k_warn(ab, "ignoring unsolicited htc ep0 event\n");
338 ath11k_dbg(ab, ATH11K_DBG_HTC, "htc rx completion ep %d skb %pK\n",
357 ath11k_warn(ab, "unexpected htc rx\n");
399 static void ath11k_htc_reset_endpoint_states(struct ath11k_htc *htc)
405 ep = &htc->endpoint[i];
410 ep->htc = htc;
415 static u8 ath11k_htc_get_credit_allocation(struct ath11k_htc *htc,
421 if (htc->service_alloc_table[i].service_id == service_id) {
423 htc->service_alloc_table[i].credit_allocation;
430 static int ath11k_htc_setup_target_buffer_assignments(struct ath11k_htc *htc)
440 credits = htc->total_transmit_credits;
441 serv_entry = htc->service_alloc_table;
443 if ((htc->wmi_ep_count == 0) ||
444 (htc->wmi_ep_count > ARRAY_SIZE(svc_id)))
448 credits = credits / htc->wmi_ep_count;
449 for (i = 0; i < htc->wmi_ep_count; i++) {
457 int ath11k_htc_wait_target(struct ath11k_htc *htc)
460 struct ath11k_base *ab = htc->ab;
467 time_left = wait_for_completion_timeout(&htc->ctl_resp,
473 ath11k_ce_per_engine_service(htc->ab, i);
476 wait_for_completion_timeout(&htc->ctl_resp,
488 if (htc->control_resp_len < sizeof(*ready)) {
490 htc->control_resp_len);
494 ready = (struct ath11k_htc_ready *)htc->control_resp_buffer;
505 htc->total_transmit_credits = credit_count;
506 htc->target_credit_size = credit_size;
510 htc->total_transmit_credits, htc->target_credit_size);
512 if ((htc->total_transmit_credits == 0) ||
513 (htc->target_credit_size == 0)) {
522 htc->total_transmit_credits = 1;
524 ath11k_htc_setup_target_buffer_assignments(htc);
529 int ath11k_htc_connect_service(struct ath11k_htc *htc,
533 struct ath11k_base *ab = htc->ab;
556 tx_alloc = ath11k_htc_get_credit_allocation(htc,
560 "boot htc service %s does not allocate target credits\n",
563 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab);
591 reinit_completion(&htc->ctl_resp);
593 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb);
600 time_left = wait_for_completion_timeout(&htc->ctl_resp,
608 resp_msg = (struct ath11k_htc_conn_svc_resp *)htc->control_resp_buffer;
614 (htc->control_resp_len < sizeof(*resp_msg))) {
651 ep = &htc->endpoint[assigned_eid];
672 status = ath11k_hif_map_service_to_pipe(htc->ab,
680 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n",
687 "boot htc service '%s' eid %d TX flow control disabled\n",
694 int ath11k_htc_start(struct ath11k_htc *htc)
698 struct ath11k_base *ab = htc->ab;
701 skb = ath11k_htc_build_tx_ctrl_skb(htc->ab);
714 status = ath11k_htc_send(htc, ATH11K_HTC_EP_0, skb);
725 struct ath11k_htc *htc = &ab->htc;
730 spin_lock_init(&htc->tx_lock);
732 ath11k_htc_reset_endpoint_states(htc);
734 htc->ab = ab;
738 htc->wmi_ep_count = 1;
742 htc->wmi_ep_count = 2;
745 htc->wmi_ep_count = 3;
748 htc->wmi_ep_count = ab->hw_params.max_radios;
761 ret = ath11k_htc_connect_service(htc, &conn_req, &conn_resp);
763 ath11k_err(ab, "could not connect to htc service (%d)\n", ret);
767 init_completion(&htc->ctl_resp);