2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 static inline void ath10k_htc_send_complete_check(struct ath10k_htc_ep *ep,
30 * Check whether HIF has any prior sends that have finished,
31 * have not had the post-processing done.
33 ath10k_hif_send_complete_check(ep->htc->ar, ep->ul_pipe_id, force);
36 static void ath10k_htc_control_tx_complete(struct ath10k *ar,
42 static struct sk_buff *ath10k_htc_build_tx_ctrl_skb(void *ar)
45 struct ath10k_skb_cb *skb_cb;
47 skb = dev_alloc_skb(ATH10K_HTC_CONTROL_BUFFER_SIZE);
49 ath10k_warn("Unable to allocate ctrl skb\n");
53 skb_reserve(skb, 20); /* FIXME: why 20 bytes? */
54 WARN_ONCE((unsigned long)skb->data & 3, "unaligned skb");
56 skb_cb = ATH10K_SKB_CB(skb);
57 memset(skb_cb, 0, sizeof(*skb_cb));
59 ath10k_dbg(ATH10K_DBG_HTC, "%s: skb %p\n", __func__, skb);
63 static inline void ath10k_htc_restore_tx_skb(struct ath10k_htc *htc,
66 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
68 dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE);
69 skb_pull(skb, sizeof(struct ath10k_htc_hdr));
72 static void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
75 ath10k_dbg(ATH10K_DBG_HTC, "%s: ep %d skb %p\n", __func__,
78 ath10k_htc_restore_tx_skb(ep->htc, skb);
80 if (!ep->ep_ops.ep_tx_complete) {
81 ath10k_warn("no tx handler for eid %d\n", ep->eid);
82 dev_kfree_skb_any(skb);
86 ep->ep_ops.ep_tx_complete(ep->htc->ar, skb);
89 /* assumes tx_lock is held */
90 static bool ath10k_htc_ep_need_credit_update(struct ath10k_htc_ep *ep)
92 if (!ep->tx_credit_flow_enabled)
94 if (ep->tx_credits >= ep->tx_credits_per_max_message)
97 ath10k_dbg(ATH10K_DBG_HTC, "HTC: endpoint %d needs credit update\n",
102 static void ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,
105 struct ath10k_htc_hdr *hdr;
107 hdr = (struct ath10k_htc_hdr *)skb->data;
110 hdr->len = __cpu_to_le16(skb->len - sizeof(*hdr));
113 spin_lock_bh(&ep->htc->tx_lock);
114 hdr->seq_no = ep->seq_no++;
116 if (ath10k_htc_ep_need_credit_update(ep))
117 hdr->flags |= ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE;
119 spin_unlock_bh(&ep->htc->tx_lock);
122 int ath10k_htc_send(struct ath10k_htc *htc,
123 enum ath10k_htc_ep_id eid,
126 struct ath10k_htc_ep *ep = &htc->endpoint[eid];
127 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
128 struct ath10k_hif_sg_item sg_item;
129 struct device *dev = htc->ar->dev;
133 if (htc->ar->state == ATH10K_STATE_WEDGED)
136 if (eid >= ATH10K_HTC_EP_COUNT) {
137 ath10k_warn("Invalid endpoint id: %d\n", eid);
141 /* FIXME: This looks ugly, can we fix it? */
142 spin_lock_bh(&htc->tx_lock);
144 spin_unlock_bh(&htc->tx_lock);
147 spin_unlock_bh(&htc->tx_lock);
149 skb_push(skb, sizeof(struct ath10k_htc_hdr));
151 if (ep->tx_credit_flow_enabled) {
152 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size);
153 spin_lock_bh(&htc->tx_lock);
154 if (ep->tx_credits < credits) {
155 spin_unlock_bh(&htc->tx_lock);
159 ep->tx_credits -= credits;
160 ath10k_dbg(ATH10K_DBG_HTC,
161 "htc ep %d consumed %d credits (total %d)\n",
162 eid, credits, ep->tx_credits);
163 spin_unlock_bh(&htc->tx_lock);
166 ath10k_htc_prepare_tx_skb(ep, skb);
168 skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
169 ret = dma_mapping_error(dev, skb_cb->paddr);
173 sg_item.transfer_id = ep->eid;
174 sg_item.transfer_context = skb;
175 sg_item.vaddr = skb->data;
176 sg_item.paddr = skb_cb->paddr;
177 sg_item.len = skb->len;
179 ret = ath10k_hif_tx_sg(htc->ar, ep->ul_pipe_id, &sg_item, 1);
186 dma_unmap_single(dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE);
188 if (ep->tx_credit_flow_enabled) {
189 spin_lock_bh(&htc->tx_lock);
190 ep->tx_credits += credits;
191 ath10k_dbg(ATH10K_DBG_HTC,
192 "htc ep %d reverted %d credits back (total %d)\n",
193 eid, credits, ep->tx_credits);
194 spin_unlock_bh(&htc->tx_lock);
196 if (ep->ep_ops.ep_tx_credits)
197 ep->ep_ops.ep_tx_credits(htc->ar);
200 skb_pull(skb, sizeof(struct ath10k_htc_hdr));
204 static int ath10k_htc_tx_completion_handler(struct ath10k *ar,
208 struct ath10k_htc *htc = &ar->htc;
209 struct ath10k_htc_ep *ep = &htc->endpoint[eid];
211 if (WARN_ON_ONCE(!skb))
214 ath10k_htc_notify_tx_completion(ep, skb);
215 /* the skb now belongs to the completion handler */
225 ath10k_htc_process_credit_report(struct ath10k_htc *htc,
226 const struct ath10k_htc_credit_report *report,
228 enum ath10k_htc_ep_id eid)
230 struct ath10k_htc_ep *ep;
233 if (len % sizeof(*report))
234 ath10k_warn("Uneven credit report len %d", len);
236 n_reports = len / sizeof(*report);
238 spin_lock_bh(&htc->tx_lock);
239 for (i = 0; i < n_reports; i++, report++) {
240 if (report->eid >= ATH10K_HTC_EP_COUNT)
243 ep = &htc->endpoint[report->eid];
244 ep->tx_credits += report->credits;
246 ath10k_dbg(ATH10K_DBG_HTC, "htc ep %d got %d credits (total %d)\n",
247 report->eid, report->credits, ep->tx_credits);
249 if (ep->ep_ops.ep_tx_credits) {
250 spin_unlock_bh(&htc->tx_lock);
251 ep->ep_ops.ep_tx_credits(htc->ar);
252 spin_lock_bh(&htc->tx_lock);
255 spin_unlock_bh(&htc->tx_lock);
258 static int ath10k_htc_process_trailer(struct ath10k_htc *htc,
261 enum ath10k_htc_ep_id src_eid)
264 struct ath10k_htc_record *record;
269 orig_buffer = buffer;
270 orig_length = length;
273 record = (struct ath10k_htc_record *)buffer;
275 if (length < sizeof(record->hdr)) {
280 if (record->hdr.len > length) {
281 /* no room left in buffer for record */
282 ath10k_warn("Invalid record length: %d\n",
288 switch (record->hdr.id) {
289 case ATH10K_HTC_RECORD_CREDITS:
290 len = sizeof(struct ath10k_htc_credit_report);
291 if (record->hdr.len < len) {
292 ath10k_warn("Credit report too long\n");
296 ath10k_htc_process_credit_report(htc,
297 record->credit_report,
302 ath10k_warn("Unhandled record: id:%d length:%d\n",
303 record->hdr.id, record->hdr.len);
310 /* multiple records may be present in a trailer */
311 buffer += sizeof(record->hdr) + record->hdr.len;
312 length -= sizeof(record->hdr) + record->hdr.len;
316 ath10k_dbg_dump(ATH10K_DBG_HTC, "htc rx bad trailer", "",
317 orig_buffer, orig_length);
322 static int ath10k_htc_rx_completion_handler(struct ath10k *ar,
327 struct ath10k_htc *htc = &ar->htc;
328 struct ath10k_htc_hdr *hdr;
329 struct ath10k_htc_ep *ep;
334 bool trailer_present;
336 hdr = (struct ath10k_htc_hdr *)skb->data;
337 skb_pull(skb, sizeof(*hdr));
341 if (eid >= ATH10K_HTC_EP_COUNT) {
342 ath10k_warn("HTC Rx: invalid eid %d\n", eid);
343 ath10k_dbg_dump(ATH10K_DBG_HTC, "htc bad header", "",
349 ep = &htc->endpoint[eid];
352 * If this endpoint that received a message from the target has
353 * a to-target HIF pipe whose send completions are polled rather
354 * than interrupt-driven, this is a good point to ask HIF to check
355 * whether it has any completed sends to handle.
357 if (ep->ul_is_polled)
358 ath10k_htc_send_complete_check(ep, 1);
360 payload_len = __le16_to_cpu(hdr->len);
362 if (payload_len + sizeof(*hdr) > ATH10K_HTC_MAX_LEN) {
363 ath10k_warn("HTC rx frame too long, len: %zu\n",
364 payload_len + sizeof(*hdr));
365 ath10k_dbg_dump(ATH10K_DBG_HTC, "htc bad rx pkt len", "",
371 if (skb->len < payload_len) {
372 ath10k_dbg(ATH10K_DBG_HTC,
373 "HTC Rx: insufficient length, got %d, expected %d\n",
374 skb->len, payload_len);
375 ath10k_dbg_dump(ATH10K_DBG_HTC, "htc bad rx pkt len",
376 "", hdr, sizeof(*hdr));
381 /* get flags to check for trailer */
382 trailer_present = hdr->flags & ATH10K_HTC_FLAG_TRAILER_PRESENT;
383 if (trailer_present) {
386 trailer_len = hdr->trailer_len;
387 min_len = sizeof(struct ath10k_ath10k_htc_record_hdr);
389 if ((trailer_len < min_len) ||
390 (trailer_len > payload_len)) {
391 ath10k_warn("Invalid trailer length: %d\n",
398 trailer += sizeof(*hdr);
399 trailer += payload_len;
400 trailer -= trailer_len;
401 status = ath10k_htc_process_trailer(htc, trailer,
402 trailer_len, hdr->eid);
406 skb_trim(skb, skb->len - trailer_len);
409 if (((int)payload_len - (int)trailer_len) <= 0)
410 /* zero length packet with trailer data, just drop these */
413 if (eid == ATH10K_HTC_EP_0) {
414 struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data;
416 switch (__le16_to_cpu(msg->hdr.message_id)) {
418 /* handle HTC control message */
419 if (completion_done(&htc->ctl_resp)) {
421 * this is a fatal error, target should not be
422 * sending unsolicited messages on the ep 0
424 ath10k_warn("HTC rx ctrl still processing\n");
426 complete(&htc->ctl_resp);
430 htc->control_resp_len =
432 ATH10K_HTC_MAX_CTRL_MSG_LEN);
434 memcpy(htc->control_resp_buffer, skb->data,
435 htc->control_resp_len);
437 complete(&htc->ctl_resp);
439 case ATH10K_HTC_MSG_SEND_SUSPEND_COMPLETE:
440 htc->htc_ops.target_send_suspend_complete(ar);
445 ath10k_dbg(ATH10K_DBG_HTC, "htc rx completion ep %d skb %p\n",
447 ep->ep_ops.ep_rx_complete(ar, skb);
449 /* skb is now owned by the rx completion handler */
457 static void ath10k_htc_control_rx_complete(struct ath10k *ar,
460 /* This is unexpected. FW is not supposed to send regular rx on this
462 ath10k_warn("unexpected htc rx\n");
470 static const char *htc_service_name(enum ath10k_htc_svc_id id)
473 case ATH10K_HTC_SVC_ID_RESERVED:
475 case ATH10K_HTC_SVC_ID_RSVD_CTRL:
477 case ATH10K_HTC_SVC_ID_WMI_CONTROL:
479 case ATH10K_HTC_SVC_ID_WMI_DATA_BE:
481 case ATH10K_HTC_SVC_ID_WMI_DATA_BK:
483 case ATH10K_HTC_SVC_ID_WMI_DATA_VI:
485 case ATH10K_HTC_SVC_ID_WMI_DATA_VO:
487 case ATH10K_HTC_SVC_ID_NMI_CONTROL:
488 return "NMI Control";
489 case ATH10K_HTC_SVC_ID_NMI_DATA:
491 case ATH10K_HTC_SVC_ID_HTT_DATA_MSG:
493 case ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS:
500 static void ath10k_htc_reset_endpoint_states(struct ath10k_htc *htc)
502 struct ath10k_htc_ep *ep;
505 for (i = ATH10K_HTC_EP_0; i < ATH10K_HTC_EP_COUNT; i++) {
506 ep = &htc->endpoint[i];
507 ep->service_id = ATH10K_HTC_SVC_ID_UNUSED;
508 ep->max_ep_message_len = 0;
509 ep->max_tx_queue_depth = 0;
512 ep->tx_credit_flow_enabled = true;
516 static void ath10k_htc_setup_target_buffer_assignments(struct ath10k_htc *htc)
518 struct ath10k_htc_svc_tx_credits *entry;
520 entry = &htc->service_tx_alloc[0];
523 * for PCIE allocate all credists/HTC buffers to WMI.
524 * no buffers are used/required for data. data always
528 entry->service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
529 entry->credit_allocation = htc->total_transmit_credits;
532 static u8 ath10k_htc_get_credit_allocation(struct ath10k_htc *htc,
538 for (i = 0; i < ATH10K_HTC_EP_COUNT; i++) {
539 if (htc->service_tx_alloc[i].service_id == service_id)
541 htc->service_tx_alloc[i].credit_allocation;
547 int ath10k_htc_wait_target(struct ath10k_htc *htc)
550 struct ath10k_htc_svc_conn_req conn_req;
551 struct ath10k_htc_svc_conn_resp conn_resp;
552 struct ath10k_htc_msg *msg;
557 status = wait_for_completion_timeout(&htc->ctl_resp,
558 ATH10K_HTC_WAIT_TIMEOUT_HZ);
563 ath10k_err("ctl_resp never came in (%d)\n", status);
567 if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) {
568 ath10k_err("Invalid HTC ready msg len:%d\n",
569 htc->control_resp_len);
573 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer;
574 message_id = __le16_to_cpu(msg->hdr.message_id);
575 credit_count = __le16_to_cpu(msg->ready.credit_count);
576 credit_size = __le16_to_cpu(msg->ready.credit_size);
578 if (message_id != ATH10K_HTC_MSG_READY_ID) {
579 ath10k_err("Invalid HTC ready msg: 0x%x\n", message_id);
583 htc->total_transmit_credits = credit_count;
584 htc->target_credit_size = credit_size;
586 ath10k_dbg(ATH10K_DBG_HTC,
587 "Target ready! transmit resources: %d size:%d\n",
588 htc->total_transmit_credits,
589 htc->target_credit_size);
591 if ((htc->total_transmit_credits == 0) ||
592 (htc->target_credit_size == 0)) {
593 ath10k_err("Invalid credit size received\n");
597 ath10k_htc_setup_target_buffer_assignments(htc);
599 /* setup our pseudo HTC control endpoint connection */
600 memset(&conn_req, 0, sizeof(conn_req));
601 memset(&conn_resp, 0, sizeof(conn_resp));
602 conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete;
603 conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete;
604 conn_req.max_send_queue_depth = ATH10K_NUM_CONTROL_TX_BUFFERS;
605 conn_req.service_id = ATH10K_HTC_SVC_ID_RSVD_CTRL;
607 /* connect fake service */
608 status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp);
610 ath10k_err("could not connect to htc service (%d)\n", status);
617 int ath10k_htc_connect_service(struct ath10k_htc *htc,
618 struct ath10k_htc_svc_conn_req *conn_req,
619 struct ath10k_htc_svc_conn_resp *conn_resp)
621 struct ath10k_htc_msg *msg;
622 struct ath10k_htc_conn_svc *req_msg;
623 struct ath10k_htc_conn_svc_response resp_msg_dummy;
624 struct ath10k_htc_conn_svc_response *resp_msg = &resp_msg_dummy;
625 enum ath10k_htc_ep_id assigned_eid = ATH10K_HTC_EP_COUNT;
626 struct ath10k_htc_ep *ep;
628 unsigned int max_msg_size = 0;
630 bool disable_credit_flow_ctrl = false;
631 u16 message_id, service_id, flags = 0;
634 /* special case for HTC pseudo control service */
635 if (conn_req->service_id == ATH10K_HTC_SVC_ID_RSVD_CTRL) {
636 disable_credit_flow_ctrl = true;
637 assigned_eid = ATH10K_HTC_EP_0;
638 max_msg_size = ATH10K_HTC_MAX_CTRL_MSG_LEN;
639 memset(&resp_msg_dummy, 0, sizeof(resp_msg_dummy));
643 tx_alloc = ath10k_htc_get_credit_allocation(htc,
644 conn_req->service_id);
646 ath10k_dbg(ATH10K_DBG_BOOT,
647 "boot htc service %s does not allocate target credits\n",
648 htc_service_name(conn_req->service_id));
650 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar);
652 ath10k_err("Failed to allocate HTC packet\n");
656 length = sizeof(msg->hdr) + sizeof(msg->connect_service);
657 skb_put(skb, length);
658 memset(skb->data, 0, length);
660 msg = (struct ath10k_htc_msg *)skb->data;
661 msg->hdr.message_id =
662 __cpu_to_le16(ATH10K_HTC_MSG_CONNECT_SERVICE_ID);
664 flags |= SM(tx_alloc, ATH10K_HTC_CONN_FLAGS_RECV_ALLOC);
666 /* Only enable credit flow control for WMI ctrl service */
667 if (conn_req->service_id != ATH10K_HTC_SVC_ID_WMI_CONTROL) {
668 flags |= ATH10K_HTC_CONN_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
669 disable_credit_flow_ctrl = true;
672 req_msg = &msg->connect_service;
673 req_msg->flags = __cpu_to_le16(flags);
674 req_msg->service_id = __cpu_to_le16(conn_req->service_id);
676 reinit_completion(&htc->ctl_resp);
678 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb);
684 /* wait for response */
685 status = wait_for_completion_timeout(&htc->ctl_resp,
686 ATH10K_HTC_CONN_SVC_TIMEOUT_HZ);
690 ath10k_err("Service connect timeout: %d\n", status);
694 /* we controlled the buffer creation, it's aligned */
695 msg = (struct ath10k_htc_msg *)htc->control_resp_buffer;
696 resp_msg = &msg->connect_service_response;
697 message_id = __le16_to_cpu(msg->hdr.message_id);
698 service_id = __le16_to_cpu(resp_msg->service_id);
700 if ((message_id != ATH10K_HTC_MSG_CONNECT_SERVICE_RESP_ID) ||
701 (htc->control_resp_len < sizeof(msg->hdr) +
702 sizeof(msg->connect_service_response))) {
703 ath10k_err("Invalid resp message ID 0x%x", message_id);
707 ath10k_dbg(ATH10K_DBG_HTC,
708 "HTC Service %s connect response: status: 0x%x, assigned ep: 0x%x\n",
709 htc_service_name(service_id),
710 resp_msg->status, resp_msg->eid);
712 conn_resp->connect_resp_code = resp_msg->status;
714 /* check response status */
715 if (resp_msg->status != ATH10K_HTC_CONN_SVC_STATUS_SUCCESS) {
716 ath10k_err("HTC Service %s connect request failed: 0x%x)\n",
717 htc_service_name(service_id),
722 assigned_eid = (enum ath10k_htc_ep_id)resp_msg->eid;
723 max_msg_size = __le16_to_cpu(resp_msg->max_msg_size);
727 if (assigned_eid >= ATH10K_HTC_EP_COUNT)
730 if (max_msg_size == 0)
733 ep = &htc->endpoint[assigned_eid];
734 ep->eid = assigned_eid;
736 if (ep->service_id != ATH10K_HTC_SVC_ID_UNUSED)
739 /* return assigned endpoint to caller */
740 conn_resp->eid = assigned_eid;
741 conn_resp->max_msg_len = __le16_to_cpu(resp_msg->max_msg_size);
743 /* setup the endpoint */
744 ep->service_id = conn_req->service_id;
745 ep->max_tx_queue_depth = conn_req->max_send_queue_depth;
746 ep->max_ep_message_len = __le16_to_cpu(resp_msg->max_msg_size);
747 ep->tx_credits = tx_alloc;
748 ep->tx_credit_size = htc->target_credit_size;
749 ep->tx_credits_per_max_message = ep->max_ep_message_len /
750 htc->target_credit_size;
752 if (ep->max_ep_message_len % htc->target_credit_size)
753 ep->tx_credits_per_max_message++;
755 /* copy all the callbacks */
756 ep->ep_ops = conn_req->ep_ops;
758 status = ath10k_hif_map_service_to_pipe(htc->ar,
767 ath10k_dbg(ATH10K_DBG_BOOT,
768 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n",
769 htc_service_name(ep->service_id), ep->ul_pipe_id,
770 ep->dl_pipe_id, ep->eid);
772 ath10k_dbg(ATH10K_DBG_BOOT,
773 "boot htc ep %d ul polled %d dl polled %d\n",
774 ep->eid, ep->ul_is_polled, ep->dl_is_polled);
776 if (disable_credit_flow_ctrl && ep->tx_credit_flow_enabled) {
777 ep->tx_credit_flow_enabled = false;
778 ath10k_dbg(ATH10K_DBG_BOOT,
779 "boot htc service '%s' eid %d TX flow control disabled\n",
780 htc_service_name(ep->service_id), assigned_eid);
786 struct sk_buff *ath10k_htc_alloc_skb(int size)
790 skb = dev_alloc_skb(size + sizeof(struct ath10k_htc_hdr));
792 ath10k_warn("could not allocate HTC tx skb\n");
796 skb_reserve(skb, sizeof(struct ath10k_htc_hdr));
798 /* FW/HTC requires 4-byte aligned streams */
799 if (!IS_ALIGNED((unsigned long)skb->data, 4))
800 ath10k_warn("Unaligned HTC tx skb\n");
805 int ath10k_htc_start(struct ath10k_htc *htc)
809 struct ath10k_htc_msg *msg;
811 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar);
815 skb_put(skb, sizeof(msg->hdr) + sizeof(msg->setup_complete_ext));
816 memset(skb->data, 0, skb->len);
818 msg = (struct ath10k_htc_msg *)skb->data;
819 msg->hdr.message_id =
820 __cpu_to_le16(ATH10K_HTC_MSG_SETUP_COMPLETE_EX_ID);
822 ath10k_dbg(ATH10K_DBG_HTC, "HTC is using TX credit flow control\n");
824 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb);
833 void ath10k_htc_stop(struct ath10k_htc *htc)
835 spin_lock_bh(&htc->tx_lock);
837 spin_unlock_bh(&htc->tx_lock);
840 /* registered target arrival callback from the HIF layer */
841 int ath10k_htc_init(struct ath10k *ar)
843 struct ath10k_hif_cb htc_callbacks;
844 struct ath10k_htc_ep *ep = NULL;
845 struct ath10k_htc *htc = &ar->htc;
847 spin_lock_init(&htc->tx_lock);
849 htc->stopped = false;
850 ath10k_htc_reset_endpoint_states(htc);
852 /* setup HIF layer callbacks */
853 htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
854 htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
857 /* Get HIF default pipe for HTC message exchange */
858 ep = &htc->endpoint[ATH10K_HTC_EP_0];
860 ath10k_hif_set_callbacks(ar, &htc_callbacks);
861 ath10k_hif_get_default_pipe(ar, &ep->ul_pipe_id, &ep->dl_pipe_id);
863 init_completion(&htc->ctl_resp);