Lines Matching full:htc
43 static inline void ath10k_htc_restore_tx_skb(struct ath10k_htc *htc, in ath10k_htc_restore_tx_skb() argument
48 if (htc->ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) in ath10k_htc_restore_tx_skb()
49 dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE); in ath10k_htc_restore_tx_skb()
56 struct ath10k *ar = ep->htc->ar; in ath10k_htc_notify_tx_completion()
72 ath10k_htc_restore_tx_skb(ep->htc, skb); in ath10k_htc_notify_tx_completion()
85 ep->ep_ops.ep_tx_complete(ep->htc->ar, skb); in ath10k_htc_notify_tx_completion()
103 spin_lock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
105 spin_unlock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
112 struct ath10k_htc *htc = ep->htc; in ath10k_htc_consume_credit() local
113 struct ath10k *ar = htc->ar; in ath10k_htc_consume_credit()
121 spin_lock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
125 "htc insufficient credits ep %d required %d available %d consume %d\n", in ath10k_htc_consume_credit()
134 "htc ep %d consumed %d credits total %d\n", in ath10k_htc_consume_credit()
139 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
145 struct ath10k_htc *htc = ep->htc; in ath10k_htc_release_credit() local
146 struct ath10k *ar = htc->ar; in ath10k_htc_release_credit()
154 spin_lock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
157 "htc ep %d reverted %d credits back total %d\n", in ath10k_htc_release_credit()
159 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
162 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_release_credit()
165 int ath10k_htc_send(struct ath10k_htc *htc, in ath10k_htc_send() argument
169 struct ath10k *ar = htc->ar; in ath10k_htc_send()
170 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send()
173 struct device *dev = htc->ar->dev; in ath10k_htc_send()
177 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send()
211 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send()
229 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_tx_completion_handler() local
237 ep = &htc->endpoint[skb_cb->eid]; in ath10k_htc_tx_completion_handler()
249 ath10k_htc_process_credit_report(struct ath10k_htc *htc, in ath10k_htc_process_credit_report() argument
254 struct ath10k *ar = htc->ar; in ath10k_htc_process_credit_report()
263 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
268 ep = &htc->endpoint[report->eid]; in ath10k_htc_process_credit_report()
271 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc ep %d got %d credits (total %d)\n", in ath10k_htc_process_credit_report()
275 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
276 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_process_credit_report()
277 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
280 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
284 ath10k_htc_process_lookahead(struct ath10k_htc *htc, in ath10k_htc_process_lookahead() argument
291 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead()
294 * the target in the HTC control message. in ath10k_htc_process_lookahead()
303 "htc rx lookahead found pre_valid 0x%x post_valid 0x%x\n", in ath10k_htc_process_lookahead()
316 ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc, in ath10k_htc_process_lookahead_bundle() argument
323 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead_bundle()
326 if (!bundle_cnt || (bundle_cnt > htc->max_msgs_per_htc_bundle)) { in ath10k_htc_process_lookahead_bundle()
347 int ath10k_htc_process_trailer(struct ath10k_htc *htc, in ath10k_htc_process_trailer() argument
355 struct ath10k *ar = htc->ar; in ath10k_htc_process_trailer()
389 ath10k_htc_process_credit_report(htc, in ath10k_htc_process_trailer()
401 status = ath10k_htc_process_lookahead(htc, in ath10k_htc_process_trailer()
410 status = ath10k_htc_process_lookahead_bundle(htc, in ath10k_htc_process_trailer()
432 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc rx bad trailer", "", in ath10k_htc_process_trailer()
442 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_rx_completion_handler() local
457 ath10k_warn(ar, "HTC Rx: invalid eid %d\n", eid); in ath10k_htc_rx_completion_handler()
458 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad header", "", in ath10k_htc_rx_completion_handler()
463 ep = &htc->endpoint[eid]; in ath10k_htc_rx_completion_handler()
465 ath10k_warn(ar, "htc rx endpoint %d is not connected\n", eid); in ath10k_htc_rx_completion_handler()
472 ath10k_warn(ar, "HTC rx frame too long, len: %zu\n", in ath10k_htc_rx_completion_handler()
474 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", "", in ath10k_htc_rx_completion_handler()
481 "HTC Rx: insufficient length, got %d, expected %d\n", in ath10k_htc_rx_completion_handler()
483 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", in ath10k_htc_rx_completion_handler()
507 status = ath10k_htc_process_trailer(htc, trailer, in ath10k_htc_rx_completion_handler()
520 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc rx completion ep %d skb %pK\n", in ath10k_htc_rx_completion_handler()
534 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_control_rx_complete() local
540 /* handle HTC control message */ in ath10k_htc_control_rx_complete()
541 if (completion_done(&htc->ctl_resp)) { in ath10k_htc_control_rx_complete()
545 ath10k_warn(ar, "HTC rx ctrl still processing\n"); in ath10k_htc_control_rx_complete()
546 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
550 htc->control_resp_len = in ath10k_htc_control_rx_complete()
554 memcpy(htc->control_resp_buffer, skb->data, in ath10k_htc_control_rx_complete()
555 htc->control_resp_len); in ath10k_htc_control_rx_complete()
557 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
560 htc->htc_ops.target_send_suspend_complete(ar); in ath10k_htc_control_rx_complete()
563 ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n"); in ath10k_htc_control_rx_complete()
611 static void ath10k_htc_reset_endpoint_states(struct ath10k_htc *htc) in ath10k_htc_reset_endpoint_states() argument
617 ep = &htc->endpoint[i]; in ath10k_htc_reset_endpoint_states()
622 ep->htc = htc; in ath10k_htc_reset_endpoint_states()
627 static u8 ath10k_htc_get_credit_allocation(struct ath10k_htc *htc, in ath10k_htc_get_credit_allocation() argument
636 allocation = htc->total_transmit_credits; in ath10k_htc_get_credit_allocation()
646 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle() local
647 struct ath10k *ar = htc->ar; in ath10k_htc_send_bundle()
662 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send_bundle()
690 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_one_skb() local
691 struct ath10k *ar = htc->ar; in ath10k_htc_send_one_skb()
694 ret = ath10k_htc_send(htc, ep->eid, skb); in ath10k_htc_send_one_skb()
705 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle_skbs() local
712 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send_bundle_skbs()
811 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_bundle_tx_work()
812 ep = &ar->htc.endpoint[i]; in ath10k_htc_bundle_tx_work()
841 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_tx_complete_work()
842 ep = &ar->htc.endpoint[i]; in ath10k_htc_tx_complete_work()
858 int ath10k_htc_send_hl(struct ath10k_htc *htc, in ath10k_htc_send_hl() argument
862 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send_hl()
863 struct ath10k *ar = htc->ar; in ath10k_htc_send_hl()
870 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc send hl eid %d bundle %d tx count %d len %d\n", in ath10k_htc_send_hl()
878 return ath10k_htc_send(htc, eid, skb); in ath10k_htc_send_hl()
884 if (ep->htc->max_msgs_per_htc_bundle >= ATH10K_MIN_MSG_PER_HTC_TX_BUNDLE && in ath10k_htc_setup_tx_req()
900 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_stop_hl()
901 ep = &ar->htc.endpoint[i]; in ath10k_htc_stop_hl()
913 int ath10k_htc_wait_target(struct ath10k_htc *htc) in ath10k_htc_wait_target() argument
915 struct ath10k *ar = htc->ar; in ath10k_htc_wait_target()
921 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
933 ath10k_hif_send_complete_check(htc->ar, i, 1); in ath10k_htc_wait_target()
936 wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
948 if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) { in ath10k_htc_wait_target()
949 ath10k_err(ar, "Invalid HTC ready msg len:%d\n", in ath10k_htc_wait_target()
950 htc->control_resp_len); in ath10k_htc_wait_target()
954 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_wait_target()
958 ath10k_err(ar, "Invalid HTC ready msg: 0x%x\n", message_id); in ath10k_htc_wait_target()
963 htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count); in ath10k_htc_wait_target()
965 htc->total_transmit_credits = 1; in ath10k_htc_wait_target()
967 htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size); in ath10k_htc_wait_target()
971 htc->total_transmit_credits, in ath10k_htc_wait_target()
972 htc->target_credit_size, in ath10k_htc_wait_target()
975 if ((htc->total_transmit_credits == 0) || in ath10k_htc_wait_target()
976 (htc->target_credit_size == 0)) { in ath10k_htc_wait_target()
984 if (htc->control_resp_len >= in ath10k_htc_wait_target()
986 htc->alt_data_credit_size = in ath10k_htc_wait_target()
989 htc->max_msgs_per_htc_bundle = in ath10k_htc_wait_target()
994 htc->max_msgs_per_htc_bundle, in ath10k_htc_wait_target()
995 htc->alt_data_credit_size); in ath10k_htc_wait_target()
1004 void ath10k_htc_change_tx_credit_flow(struct ath10k_htc *htc, in ath10k_htc_change_tx_credit_flow() argument
1008 struct ath10k *ar = htc->ar; in ath10k_htc_change_tx_credit_flow()
1009 struct ath10k_htc_ep *ep = &ar->htc.endpoint[eid]; in ath10k_htc_change_tx_credit_flow()
1014 int ath10k_htc_connect_service(struct ath10k_htc *htc, in ath10k_htc_connect_service() argument
1018 struct ath10k *ar = htc->ar; in ath10k_htc_connect_service()
1033 /* special case for HTC pseudo control service */ in ath10k_htc_connect_service()
1042 tx_alloc = ath10k_htc_get_credit_allocation(htc, in ath10k_htc_connect_service()
1046 "boot htc service %s does not allocate target credits\n", in ath10k_htc_connect_service()
1049 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_connect_service()
1051 ath10k_err(ar, "Failed to allocate HTC packet\n"); in ath10k_htc_connect_service()
1075 reinit_completion(&htc->ctl_resp); in ath10k_htc_connect_service()
1077 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_connect_service()
1084 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_connect_service()
1092 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_connect_service()
1098 (htc->control_resp_len < sizeof(msg->hdr) + in ath10k_htc_connect_service()
1105 "HTC Service %s connect response: status: 0x%x, assigned ep: 0x%x\n", in ath10k_htc_connect_service()
1113 ath10k_err(ar, "HTC Service %s connect request failed: 0x%x)\n", in ath10k_htc_connect_service()
1130 ep = &htc->endpoint[assigned_eid]; in ath10k_htc_connect_service()
1145 ep->tx_credit_size = htc->target_credit_size; in ath10k_htc_connect_service()
1148 htc->alt_data_credit_size != 0) in ath10k_htc_connect_service()
1149 ep->tx_credit_size = htc->alt_data_credit_size; in ath10k_htc_connect_service()
1154 status = ath10k_hif_map_service_to_pipe(htc->ar, in ath10k_htc_connect_service()
1159 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC service id: %d\n", in ath10k_htc_connect_service()
1165 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath10k_htc_connect_service()
1172 "boot htc service '%s' eid %d TX flow control disabled\n", in ath10k_htc_connect_service()
1189 /* FW/HTC requires 4-byte aligned streams */ in ath10k_htc_alloc_skb()
1191 ath10k_warn(ar, "Unaligned HTC tx skb\n"); in ath10k_htc_alloc_skb()
1217 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); in ath10k_htc_pktlog_connect()
1237 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC pktlog service id: %d\n", in ath10k_htc_pktlog_svc_supported()
1246 int ath10k_htc_start(struct ath10k_htc *htc) in ath10k_htc_start() argument
1248 struct ath10k *ar = htc->ar; in ath10k_htc_start()
1253 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_start()
1269 htc->max_msgs_per_htc_bundle; in ath10k_htc_start()
1271 ath10k_dbg(ar, ATH10K_DBG_HTC, "HTC is using TX credit flow control\n"); in ath10k_htc_start()
1273 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_start()
1294 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_init() local
1298 spin_lock_init(&htc->tx_lock); in ath10k_htc_init()
1300 ath10k_htc_reset_endpoint_states(htc); in ath10k_htc_init()
1302 htc->ar = ar; in ath10k_htc_init()
1304 /* setup our pseudo HTC control endpoint connection */ in ath10k_htc_init()
1313 status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp); in ath10k_htc_init()
1315 ath10k_err(ar, "could not connect to htc service (%d)\n", in ath10k_htc_init()
1320 init_completion(&htc->ctl_resp); in ath10k_htc_init()