Lines Matching full:htc

41 static inline void ath10k_htc_restore_tx_skb(struct ath10k_htc *htc,  in ath10k_htc_restore_tx_skb()  argument
46 if (htc->ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) in ath10k_htc_restore_tx_skb()
47 dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE); in ath10k_htc_restore_tx_skb()
54 struct ath10k *ar = ep->htc->ar; in ath10k_htc_notify_tx_completion()
70 ath10k_htc_restore_tx_skb(ep->htc, skb); in ath10k_htc_notify_tx_completion()
83 ep->ep_ops.ep_tx_complete(ep->htc->ar, skb); in ath10k_htc_notify_tx_completion()
101 spin_lock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
103 spin_unlock_bh(&ep->htc->tx_lock); in ath10k_htc_prepare_tx_skb()
110 struct ath10k_htc *htc = ep->htc; in ath10k_htc_consume_credit() local
111 struct ath10k *ar = htc->ar; in ath10k_htc_consume_credit()
119 spin_lock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
123 "htc insufficient credits ep %d required %d available %d consume %d\n", in ath10k_htc_consume_credit()
132 "htc ep %d consumed %d credits total %d\n", in ath10k_htc_consume_credit()
137 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_consume_credit()
143 struct ath10k_htc *htc = ep->htc; in ath10k_htc_release_credit() local
144 struct ath10k *ar = htc->ar; in ath10k_htc_release_credit()
152 spin_lock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
155 "htc ep %d reverted %d credits back total %d\n", in ath10k_htc_release_credit()
157 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_release_credit()
160 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_release_credit()
163 int ath10k_htc_send(struct ath10k_htc *htc, in ath10k_htc_send() argument
167 struct ath10k *ar = htc->ar; in ath10k_htc_send()
168 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send()
171 struct device *dev = htc->ar->dev; in ath10k_htc_send()
175 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send()
209 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send()
227 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_tx_completion_handler() local
235 ep = &htc->endpoint[skb_cb->eid]; in ath10k_htc_tx_completion_handler()
247 ath10k_htc_process_credit_report(struct ath10k_htc *htc, in ath10k_htc_process_credit_report() argument
252 struct ath10k *ar = htc->ar; in ath10k_htc_process_credit_report()
261 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
266 ep = &htc->endpoint[report->eid]; in ath10k_htc_process_credit_report()
269 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc ep %d got %d credits (total %d)\n", in ath10k_htc_process_credit_report()
273 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
274 ep->ep_ops.ep_tx_credits(htc->ar); in ath10k_htc_process_credit_report()
275 spin_lock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
278 spin_unlock_bh(&htc->tx_lock); in ath10k_htc_process_credit_report()
282 ath10k_htc_process_lookahead(struct ath10k_htc *htc, in ath10k_htc_process_lookahead() argument
289 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead()
292 * the target in the HTC control message. in ath10k_htc_process_lookahead()
301 "htc rx lookahead found pre_valid 0x%x post_valid 0x%x\n", in ath10k_htc_process_lookahead()
314 ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc, in ath10k_htc_process_lookahead_bundle() argument
321 struct ath10k *ar = htc->ar; in ath10k_htc_process_lookahead_bundle()
324 if (!bundle_cnt || (bundle_cnt > htc->max_msgs_per_htc_bundle)) { in ath10k_htc_process_lookahead_bundle()
345 int ath10k_htc_process_trailer(struct ath10k_htc *htc, in ath10k_htc_process_trailer() argument
353 struct ath10k *ar = htc->ar; in ath10k_htc_process_trailer()
387 ath10k_htc_process_credit_report(htc, in ath10k_htc_process_trailer()
399 status = ath10k_htc_process_lookahead(htc, in ath10k_htc_process_trailer()
408 status = ath10k_htc_process_lookahead_bundle(htc, in ath10k_htc_process_trailer()
430 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc rx bad trailer", "", in ath10k_htc_process_trailer()
440 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_rx_completion_handler() local
455 ath10k_warn(ar, "HTC Rx: invalid eid %d\n", eid); in ath10k_htc_rx_completion_handler()
456 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad header", "", in ath10k_htc_rx_completion_handler()
461 ep = &htc->endpoint[eid]; in ath10k_htc_rx_completion_handler()
463 ath10k_warn(ar, "htc rx endpoint %d is not connected\n", eid); in ath10k_htc_rx_completion_handler()
470 ath10k_warn(ar, "HTC rx frame too long, len: %zu\n", in ath10k_htc_rx_completion_handler()
472 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", "", in ath10k_htc_rx_completion_handler()
479 "HTC Rx: insufficient length, got %d, expected %d\n", in ath10k_htc_rx_completion_handler()
481 ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", in ath10k_htc_rx_completion_handler()
505 status = ath10k_htc_process_trailer(htc, trailer, in ath10k_htc_rx_completion_handler()
518 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc rx completion ep %d skb %pK\n", in ath10k_htc_rx_completion_handler()
532 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_control_rx_complete() local
538 /* handle HTC control message */ in ath10k_htc_control_rx_complete()
539 if (completion_done(&htc->ctl_resp)) { in ath10k_htc_control_rx_complete()
543 ath10k_warn(ar, "HTC rx ctrl still processing\n"); in ath10k_htc_control_rx_complete()
544 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
548 htc->control_resp_len = in ath10k_htc_control_rx_complete()
552 memcpy(htc->control_resp_buffer, skb->data, in ath10k_htc_control_rx_complete()
553 htc->control_resp_len); in ath10k_htc_control_rx_complete()
555 complete(&htc->ctl_resp); in ath10k_htc_control_rx_complete()
558 htc->htc_ops.target_send_suspend_complete(ar); in ath10k_htc_control_rx_complete()
561 ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n"); in ath10k_htc_control_rx_complete()
609 static void ath10k_htc_reset_endpoint_states(struct ath10k_htc *htc) in ath10k_htc_reset_endpoint_states() argument
615 ep = &htc->endpoint[i]; in ath10k_htc_reset_endpoint_states()
620 ep->htc = htc; in ath10k_htc_reset_endpoint_states()
625 static u8 ath10k_htc_get_credit_allocation(struct ath10k_htc *htc, in ath10k_htc_get_credit_allocation() argument
634 allocation = htc->total_transmit_credits; in ath10k_htc_get_credit_allocation()
644 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle() local
645 struct ath10k *ar = htc->ar; in ath10k_htc_send_bundle()
660 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1); in ath10k_htc_send_bundle()
688 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_one_skb() local
689 struct ath10k *ar = htc->ar; in ath10k_htc_send_one_skb()
692 ret = ath10k_htc_send(htc, ep->eid, skb); in ath10k_htc_send_one_skb()
703 struct ath10k_htc *htc = ep->htc; in ath10k_htc_send_bundle_skbs() local
710 if (htc->ar->state == ATH10K_STATE_WEDGED) in ath10k_htc_send_bundle_skbs()
809 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_bundle_tx_work()
810 ep = &ar->htc.endpoint[i]; in ath10k_htc_bundle_tx_work()
839 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_tx_complete_work()
840 ep = &ar->htc.endpoint[i]; in ath10k_htc_tx_complete_work()
856 int ath10k_htc_send_hl(struct ath10k_htc *htc, in ath10k_htc_send_hl() argument
860 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; in ath10k_htc_send_hl()
861 struct ath10k *ar = htc->ar; in ath10k_htc_send_hl()
868 ath10k_dbg(ar, ATH10K_DBG_HTC, "htc send hl eid %d bundle %d tx count %d len %d\n", in ath10k_htc_send_hl()
876 return ath10k_htc_send(htc, eid, skb); in ath10k_htc_send_hl()
882 if (ep->htc->max_msgs_per_htc_bundle >= ATH10K_MIN_MSG_PER_HTC_TX_BUNDLE && in ath10k_htc_setup_tx_req()
898 for (i = 0; i < ARRAY_SIZE(ar->htc.endpoint); i++) { in ath10k_htc_stop_hl()
899 ep = &ar->htc.endpoint[i]; in ath10k_htc_stop_hl()
911 int ath10k_htc_wait_target(struct ath10k_htc *htc) in ath10k_htc_wait_target() argument
913 struct ath10k *ar = htc->ar; in ath10k_htc_wait_target()
919 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
931 ath10k_hif_send_complete_check(htc->ar, i, 1); in ath10k_htc_wait_target()
934 wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_wait_target()
946 if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) { in ath10k_htc_wait_target()
947 ath10k_err(ar, "Invalid HTC ready msg len:%d\n", in ath10k_htc_wait_target()
948 htc->control_resp_len); in ath10k_htc_wait_target()
952 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_wait_target()
956 ath10k_err(ar, "Invalid HTC ready msg: 0x%x\n", message_id); in ath10k_htc_wait_target()
961 htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count); in ath10k_htc_wait_target()
963 htc->total_transmit_credits = 1; in ath10k_htc_wait_target()
965 htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size); in ath10k_htc_wait_target()
969 htc->total_transmit_credits, in ath10k_htc_wait_target()
970 htc->target_credit_size, in ath10k_htc_wait_target()
973 if ((htc->total_transmit_credits == 0) || in ath10k_htc_wait_target()
974 (htc->target_credit_size == 0)) { in ath10k_htc_wait_target()
982 if (htc->control_resp_len >= in ath10k_htc_wait_target()
984 htc->alt_data_credit_size = in ath10k_htc_wait_target()
987 htc->max_msgs_per_htc_bundle = in ath10k_htc_wait_target()
992 htc->max_msgs_per_htc_bundle, in ath10k_htc_wait_target()
993 htc->alt_data_credit_size); in ath10k_htc_wait_target()
1002 void ath10k_htc_change_tx_credit_flow(struct ath10k_htc *htc, in ath10k_htc_change_tx_credit_flow() argument
1006 struct ath10k *ar = htc->ar; in ath10k_htc_change_tx_credit_flow()
1007 struct ath10k_htc_ep *ep = &ar->htc.endpoint[eid]; in ath10k_htc_change_tx_credit_flow()
1012 int ath10k_htc_connect_service(struct ath10k_htc *htc, in ath10k_htc_connect_service() argument
1016 struct ath10k *ar = htc->ar; in ath10k_htc_connect_service()
1031 /* special case for HTC pseudo control service */ in ath10k_htc_connect_service()
1040 tx_alloc = ath10k_htc_get_credit_allocation(htc, in ath10k_htc_connect_service()
1044 "boot htc service %s does not allocate target credits\n", in ath10k_htc_connect_service()
1047 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_connect_service()
1049 ath10k_err(ar, "Failed to allocate HTC packet\n"); in ath10k_htc_connect_service()
1073 reinit_completion(&htc->ctl_resp); in ath10k_htc_connect_service()
1075 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_connect_service()
1082 time_left = wait_for_completion_timeout(&htc->ctl_resp, in ath10k_htc_connect_service()
1090 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; in ath10k_htc_connect_service()
1096 (htc->control_resp_len < sizeof(msg->hdr) + in ath10k_htc_connect_service()
1103 "HTC Service %s connect response: status: 0x%x, assigned ep: 0x%x\n", in ath10k_htc_connect_service()
1111 ath10k_err(ar, "HTC Service %s connect request failed: 0x%x)\n", in ath10k_htc_connect_service()
1128 ep = &htc->endpoint[assigned_eid]; in ath10k_htc_connect_service()
1143 ep->tx_credit_size = htc->target_credit_size; in ath10k_htc_connect_service()
1146 htc->alt_data_credit_size != 0) in ath10k_htc_connect_service()
1147 ep->tx_credit_size = htc->alt_data_credit_size; in ath10k_htc_connect_service()
1152 status = ath10k_hif_map_service_to_pipe(htc->ar, in ath10k_htc_connect_service()
1157 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC service id: %d\n", in ath10k_htc_connect_service()
1163 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n", in ath10k_htc_connect_service()
1170 "boot htc service '%s' eid %d TX flow control disabled\n", in ath10k_htc_connect_service()
1187 /* FW/HTC requires 4-byte aligned streams */ in ath10k_htc_alloc_skb()
1189 ath10k_warn(ar, "Unaligned HTC tx skb\n"); in ath10k_htc_alloc_skb()
1215 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); in ath10k_htc_pktlog_connect()
1235 ath10k_dbg(ar, ATH10K_DBG_BOOT, "unsupported HTC pktlog service id: %d\n", in ath10k_htc_pktlog_svc_supported()
1244 int ath10k_htc_start(struct ath10k_htc *htc) in ath10k_htc_start() argument
1246 struct ath10k *ar = htc->ar; in ath10k_htc_start()
1251 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); in ath10k_htc_start()
1267 htc->max_msgs_per_htc_bundle; in ath10k_htc_start()
1269 ath10k_dbg(ar, ATH10K_DBG_HTC, "HTC is using TX credit flow control\n"); in ath10k_htc_start()
1271 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); in ath10k_htc_start()
1292 struct ath10k_htc *htc = &ar->htc; in ath10k_htc_init() local
1296 spin_lock_init(&htc->tx_lock); in ath10k_htc_init()
1298 ath10k_htc_reset_endpoint_states(htc); in ath10k_htc_init()
1300 htc->ar = ar; in ath10k_htc_init()
1302 /* setup our pseudo HTC control endpoint connection */ in ath10k_htc_init()
1311 status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp); in ath10k_htc_init()
1313 ath10k_err(ar, "could not connect to htc service (%d)\n", in ath10k_htc_init()
1318 init_completion(&htc->ctl_resp); in ath10k_htc_init()