Lines Matching full:htc

44 static inline void ath10k_htc_restore_tx_skb(struct ath10k_htc *htc,  in ath10k_htc_restore_tx_skb()  argument
49 if (htc->ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) in ath10k_htc_restore_tx_skb()
50 dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE); in ath10k_htc_restore_tx_skb()
57 struct ath10k *ar = ep->htc->ar; in ath10k_htc_notify_tx_completion()
73 ath10k_htc_restore_tx_skb(ep->htc, skb); in ath10k_htc_notify_tx_completion()
86 ep->ep_ops.ep_tx_complete(ep->htc->ar, skb); in ath10k_htc_notify_tx_completion()
104 spin_lock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
106 spin_unlock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
113 struct ath10k_htc *htc = ep->htc; in ath10k_htc_consume_credit() local
114 struct ath10k *ar = htc->ar; in ath10k_htc_consume_credit()
122 spin_lock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
126 "htc insufficient credits ep %d required %d available %d consume %d\n", in ath10k_htc_consume_credit()
135 "htc ep %d consumed %d credits total %d\n", in ath10k_htc_consume_credit()
140 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
146 struct ath10k_htc *htc = ep->htc; in ath10k_htc_release_credit() local
147 struct ath10k *ar = htc->ar; in ath10k_htc_release_credit()
155 spin_lock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
158 "htc ep %d reverted %d credits back total %d\n", in ath10k_htc_release_credit()
160 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
163 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_release_credit()
166 int ath10k_htc_send(struct ath10k_htc *htc, in ath10k_htc_send() argument
170 struct ath10k *ar = htc->ar; in ath10k_htc_send()
171 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send()
174 struct device *dev = htc->ar->dev; in ath10k_htc_send()
178 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send()
212 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send()
230 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_tx_completion_handler() local
238 ep = &htc->endpoint[skb_cb->eid]; in ath10k_htc_tx_completion_handler()
250 ath10k_htc_process_credit_report(struct ath10k_htc *htc, in ath10k_htc_process_credit_report() argument
255 struct ath10k *ar = htc->ar; in ath10k_htc_process_credit_report()
264 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
269 ep = &htc->endpoint[report->eid]; in ath10k_htc_process_credit_report()
272 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc ep %d got %d credits (total %d)\n", in ath10k_htc_process_credit_report()
276 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
277 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_process_credit_report()
278 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
281 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
285 ath10k_htc_process_lookahead(struct ath10k_htc *htc, in ath10k_htc_process_lookahead() argument
292 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead()
295 * the target in the HTC control message. in ath10k_htc_process_lookahead()
304 "htc rx lookahead found pre_valid 0x%x post_valid 0x%x\n", in ath10k_htc_process_lookahead()
317 ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc, in ath10k_htc_process_lookahead_bundle() argument
324 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead_bundle()
327 if (!bundle_cnt || (bundle_cnt > htc->max_msgs_per_htc_bundle)) { in ath10k_htc_process_lookahead_bundle()
348 int ath10k_htc_process_trailer(struct ath10k_htc *htc, in ath10k_htc_process_trailer() argument
356 struct ath10k *ar = htc->ar; in ath10k_htc_process_trailer()
390 ath10k_htc_process_credit_report(htc, in ath10k_htc_process_trailer()
402 status = ath10k_htc_process_lookahead(htc, in ath10k_htc_process_trailer()
411 status = ath10k_htc_process_lookahead_bundle(htc, in ath10k_htc_process_trailer()
433 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc rx bad trailer", "", in ath10k_htc_process_trailer()
443 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_rx_completion_handler() local
458 ath10k_warn(ar, "HTC Rx: invalid eid %d\n", eid); in ath10k_htc_rx_completion_handler()
459 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad header", "", in ath10k_htc_rx_completion_handler()
464 ep = &htc->endpoint[eid]; in ath10k_htc_rx_completion_handler()
466 ath10k_warn(ar, "htc rx endpoint %d is not connected\n", eid); in ath10k_htc_rx_completion_handler()
473 ath10k_warn(ar, "HTC rx frame too long, len: %zu\n", in ath10k_htc_rx_completion_handler()
475 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", "", in ath10k_htc_rx_completion_handler()
482 "HTC Rx: insufficient length, got %d, expected %d\n", in ath10k_htc_rx_completion_handler()
484 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", in ath10k_htc_rx_completion_handler()
508 status = ath10k_htc_process_trailer(htc, trailer, in ath10k_htc_rx_completion_handler()
521 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc rx completion ep %d skb %p\n", in ath10k_htc_rx_completion_handler()
535 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_control_rx_complete() local
541 /* handle HTC control message */ in ath10k_htc_control_rx_complete()
542 if (completion_done(&htc->ctl_resp)) { in ath10k_htc_control_rx_complete()
546 ath10k_warn(ar, "HTC rx ctrl still processing\n"); in ath10k_htc_control_rx_complete()
547 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
551 htc->control_resp_len = in ath10k_htc_control_rx_complete()
555 memcpy(htc->control_resp_buffer, skb->data, in ath10k_htc_control_rx_complete()
556 htc->control_resp_len); in ath10k_htc_control_rx_complete()
558 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
561 htc->htc_ops.target_send_suspend_complete(ar); in ath10k_htc_control_rx_complete()
564 ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n"); in ath10k_htc_control_rx_complete()
612 static void ath10k_htc_reset_endpoint_states(struct ath10k_htc *htc) in ath10k_htc_reset_endpoint_states() argument
618 ep = &htc->endpoint[i]; in ath10k_htc_reset_endpoint_states()
623 ep->htc = htc; in ath10k_htc_reset_endpoint_states()
628 static u8 ath10k_htc_get_credit_allocation(struct ath10k_htc *htc, in ath10k_htc_get_credit_allocation() argument
637 allocation = htc->total_transmit_credits; in ath10k_htc_get_credit_allocation()
647 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle() local
648 struct ath10k *ar = htc->ar; in ath10k_htc_send_bundle()
663 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send_bundle()
691 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_one_skb() local
692 struct ath10k *ar = htc->ar; in ath10k_htc_send_one_skb()
695 ret = ath10k_htc_send(htc, ep->eid, skb); in ath10k_htc_send_one_skb()
706 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle_skbs() local
713 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send_bundle_skbs()
812 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_bundle_tx_work()
813 ep = &ar->htc.endpoint[i]; in ath10k_htc_bundle_tx_work()
842 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_tx_complete_work()
843 ep = &ar->htc.endpoint[i]; in ath10k_htc_tx_complete_work()
859 int ath10k_htc_send_hl(struct ath10k_htc *htc, in ath10k_htc_send_hl() argument
863 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send_hl()
864 struct ath10k *ar = htc->ar; in ath10k_htc_send_hl()
871 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc send hl eid %d bundle %d tx count %d len %d\n", in ath10k_htc_send_hl()
879 return ath10k_htc_send(htc, eid, skb); in ath10k_htc_send_hl()
885 if (ep->htc->max_msgs_per_htc_bundle >= ATH10K_MIN_MSG_PER_HTC_TX_BUNDLE && in ath10k_htc_setup_tx_req()
901 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_stop_hl()
902 ep = &ar->htc.endpoint[i]; in ath10k_htc_stop_hl()
914 int ath10k_htc_wait_target(struct ath10k_htc *htc) in ath10k_htc_wait_target() argument
916 struct ath10k *ar = htc->ar; in ath10k_htc_wait_target()
922 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
934 ath10k_hif_send_complete_check(htc->ar, i, 1); in ath10k_htc_wait_target()
937 wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
949 if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) { in ath10k_htc_wait_target()
950 ath10k_err(ar, "Invalid HTC ready msg len:%d\n", in ath10k_htc_wait_target()
951 htc->control_resp_len); in ath10k_htc_wait_target()
955 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_wait_target()
959 ath10k_err(ar, "Invalid HTC ready msg: 0x%x\n", message_id); in ath10k_htc_wait_target()
964 htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count); in ath10k_htc_wait_target()
966 htc->total_transmit_credits = 1; in ath10k_htc_wait_target()
968 htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size); in ath10k_htc_wait_target()
972 htc->total_transmit_credits, in ath10k_htc_wait_target()
973 htc->target_credit_size, in ath10k_htc_wait_target()
976 if ((htc->total_transmit_credits == 0) || in ath10k_htc_wait_target()
977 (htc->target_credit_size == 0)) { in ath10k_htc_wait_target()
985 if (htc->control_resp_len >= in ath10k_htc_wait_target()
987 htc->alt_data_credit_size = in ath10k_htc_wait_target()
990 htc->max_msgs_per_htc_bundle = in ath10k_htc_wait_target()
995 htc->max_msgs_per_htc_bundle, in ath10k_htc_wait_target()
996 htc->alt_data_credit_size); in ath10k_htc_wait_target()
1005 void ath10k_htc_change_tx_credit_flow(struct ath10k_htc *htc, in ath10k_htc_change_tx_credit_flow() argument
1009 struct ath10k *ar = htc->ar; in ath10k_htc_change_tx_credit_flow()
1010 struct ath10k_htc_ep *ep = &ar->htc.endpoint[eid]; in ath10k_htc_change_tx_credit_flow()
1015 int ath10k_htc_connect_service(struct ath10k_htc *htc, in ath10k_htc_connect_service() argument
1019 struct ath10k *ar = htc->ar; in ath10k_htc_connect_service()
1034 /* special case for HTC pseudo control service */ in ath10k_htc_connect_service()
1043 tx_alloc = ath10k_htc_get_credit_allocation(htc, in ath10k_htc_connect_service()
1047 "boot htc service %s does not allocate target credits\n", in ath10k_htc_connect_service()
1050 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_connect_service()
1052 ath10k_err(ar, "Failed to allocate HTC packet\n"); in ath10k_htc_connect_service()
1076 reinit_completion(&htc->ctl_resp); in ath10k_htc_connect_service()
1078 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_connect_service()
1085 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_connect_service()
1093 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_connect_service()
1099 (htc->control_resp_len < sizeof(msg->hdr) + in ath10k_htc_connect_service()
1106 "HTC Service %s connect response: status: 0x%x, assigned ep: 0x%x\n", in ath10k_htc_connect_service()
1114 ath10k_err(ar, "HTC Service %s connect request failed: 0x%x)\n", in ath10k_htc_connect_service()
1131 ep = &htc->endpoint[assigned_eid]; in ath10k_htc_connect_service()
1146 ep->tx_credit_size = htc->target_credit_size; in ath10k_htc_connect_service()
1149 htc->alt_data_credit_size != 0) in ath10k_htc_connect_service()
1150 ep->tx_credit_size = htc->alt_data_credit_size; in ath10k_htc_connect_service()
1155 status = ath10k_hif_map_service_to_pipe(htc->ar, in ath10k_htc_connect_service()
1160 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC service id: %d\n", in ath10k_htc_connect_service()
1166 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath10k_htc_connect_service()
1173 "boot htc service '%s' eid %d TX flow control disabled\n", in ath10k_htc_connect_service()
1190 /* FW/HTC requires 4-byte aligned streams */ in ath10k_htc_alloc_skb()
1192 ath10k_warn(ar, "Unaligned HTC tx skb\n"); in ath10k_htc_alloc_skb()
1218 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); in ath10k_htc_pktlog_connect()
1238 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC pktlog service id: %d\n", in ath10k_htc_pktlog_svc_supported()
1247 int ath10k_htc_start(struct ath10k_htc *htc) in ath10k_htc_start() argument
1249 struct ath10k *ar = htc->ar; in ath10k_htc_start()
1254 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_start()
1270 htc->max_msgs_per_htc_bundle; in ath10k_htc_start()
1272 ath10k_dbg(ar, ATH10K_DBG_HTC, "HTC is using TX credit flow control\n"); in ath10k_htc_start()
1274 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_start()
1295 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_init() local
1299 spin_lock_init(&htc->tx_lock); in ath10k_htc_init()
1301 ath10k_htc_reset_endpoint_states(htc); in ath10k_htc_init()
1303 htc->ar = ar; in ath10k_htc_init()
1305 /* setup our pseudo HTC control endpoint connection */ in ath10k_htc_init()
1314 status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp); in ath10k_htc_init()
1316 ath10k_err(ar, "could not connect to htc service (%d)\n", in ath10k_htc_init()
1321 init_completion(&htc->ctl_resp); in ath10k_htc_init()