Lines Matching +full:num +full:- +full:txq

2  * Copyright (c) 2007-2011 Atheros Communications Inc.
19 #include "hif-ops.h"
31 if (packet->info.tx.flags & HTC_FLAGS_TX_FIXUP_NETBUF) { in restore_tx_packet()
32 skb_pull(packet->skb, sizeof(struct htc_frame_hdr)); in restore_tx_packet()
33 packet->info.tx.flags &= ~HTC_FLAGS_TX_FIXUP_NETBUF; in restore_tx_packet()
47 if (ep->ep_cb.tx_comp_multi != NULL) { in do_send_completion()
50 __func__, ep->eid, in do_send_completion()
56 ep->ep_cb.tx_comp_multi(ep->target, queue_to_indicate); in do_send_completion()
68 list_del(&packet->list); in do_send_completion()
71 __func__, ep->eid, packet); in do_send_completion()
72 ep->ep_cb.tx_complete(ep->target, packet); in do_send_completion()
80 struct htc_endpoint *ep = &target->endpoint[packet->endpoint]; in send_packet_completion()
85 list_add_tail(&packet->list, &container); in send_packet_completion()
106 if (list_empty(&ep->txq)) in get_htc_packet_credit_based()
110 packet = list_first_entry(&ep->txq, struct htc_packet, list); in get_htc_packet_credit_based()
114 __func__, packet, get_queue_depth(&ep->txq)); in get_htc_packet_credit_based()
116 transfer_len = packet->act_len + HTC_HDR_LENGTH; in get_htc_packet_credit_based()
118 if (transfer_len <= target->tgt_cred_sz) { in get_htc_packet_credit_based()
122 credits_required = transfer_len / target->tgt_cred_sz; in get_htc_packet_credit_based()
123 remainder = transfer_len % target->tgt_cred_sz; in get_htc_packet_credit_based()
130 __func__, credits_required, ep->cred_dist.credits); in get_htc_packet_credit_based()
132 if (ep->eid == ENDPOINT_0) { in get_htc_packet_credit_based()
140 if (ep->cred_dist.credits < credits_required) in get_htc_packet_credit_based()
143 ep->cred_dist.credits -= credits_required; in get_htc_packet_credit_based()
144 ep->ep_st.cred_cosumd += credits_required; in get_htc_packet_credit_based()
147 if (ep->cred_dist.credits < in get_htc_packet_credit_based()
148 ep->cred_dist.cred_per_msg) { in get_htc_packet_credit_based()
151 ep->ep_st.cred_low_indicate += 1; in get_htc_packet_credit_based()
159 packet = list_first_entry(&ep->txq, struct htc_packet, list); in get_htc_packet_credit_based()
161 list_del(&packet->list); in get_htc_packet_credit_based()
163 packet->info.tx.cred_used = credits_required; in get_htc_packet_credit_based()
165 packet->info.tx.flags = send_flags; in get_htc_packet_credit_based()
166 packet->info.tx.seqno = ep->seqno; in get_htc_packet_credit_based()
167 ep->seqno++; in get_htc_packet_credit_based()
169 list_add_tail(&packet->list, queue); in get_htc_packet_credit_based()
183 if (list_empty(&ep->txq)) in get_htc_packet()
186 packet = list_first_entry(&ep->txq, struct htc_packet, list); in get_htc_packet()
187 list_del(&packet->list); in get_htc_packet()
191 __func__, packet, get_queue_depth(&ep->txq)); in get_htc_packet()
192 packet->info.tx.seqno = ep->seqno; in get_htc_packet()
193 packet->info.tx.flags = 0; in get_htc_packet()
194 packet->info.tx.cred_used = 0; in get_htc_packet()
195 ep->seqno++; in get_htc_packet()
198 list_add_tail(&packet->list, queue); in get_htc_packet()
199 resources--; in get_htc_packet()
219 list_del(&packet->list); in htc_issue_packets()
221 skb = packet->skb; in htc_issue_packets()
224 status = -EINVAL; in htc_issue_packets()
228 payload_len = packet->act_len; in htc_issue_packets()
234 status = -EINVAL; in htc_issue_packets()
238 packet->info.tx.flags |= HTC_FLAGS_TX_FIXUP_NETBUF; in htc_issue_packets()
240 put_unaligned_le16(payload_len, &htc_hdr->payld_len); in htc_issue_packets()
241 htc_hdr->flags = packet->info.tx.flags; in htc_issue_packets()
242 htc_hdr->eid = (u8) packet->endpoint; in htc_issue_packets()
243 htc_hdr->ctrl[0] = 0; in htc_issue_packets()
244 htc_hdr->ctrl[1] = (u8) packet->info.tx.seqno; in htc_issue_packets()
246 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
249 list_add_tail(&packet->list, &ep->pipe.tx_lookup_queue); in htc_issue_packets()
250 ep->ep_st.tx_issued += 1; in htc_issue_packets()
251 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
253 status = ath6kl_hif_pipe_send(target->dev->ar, in htc_issue_packets()
254 ep->pipe.pipeid_ul, NULL, skb); in htc_issue_packets()
257 if (status != -ENOMEM) { in htc_issue_packets()
267 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
268 list_del(&packet->list); in htc_issue_packets()
271 ep->cred_dist.credits += packet->info.tx.cred_used; in htc_issue_packets()
272 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
275 list_add(&packet->list, pkt_queue); in htc_issue_packets()
282 if (status != -ENOMEM) { in htc_issue_packets()
290 list_del(&packet->list); in htc_issue_packets()
291 packet->status = status; in htc_issue_packets()
301 struct list_head *txq) in htc_try_send() argument
305 struct ath6kl *ar = target->dev->ar; in htc_try_send()
311 __func__, txq, in htc_try_send()
312 (txq == NULL) ? 0 : get_queue_depth(txq)); in htc_try_send()
318 * txq equals to NULL means in htc_try_send()
322 if (txq != NULL) { in htc_try_send()
323 if (list_empty(txq)) { in htc_try_send()
328 spin_lock_bh(&target->tx_lock); in htc_try_send()
329 txqueue_depth = get_queue_depth(&ep->txq); in htc_try_send()
330 spin_unlock_bh(&target->tx_lock); in htc_try_send()
332 if (txqueue_depth >= ep->max_txq_depth) { in htc_try_send()
334 overflow = get_queue_depth(txq); in htc_try_send()
338 overflow += get_queue_depth(txq); in htc_try_send()
340 overflow -= ep->max_txq_depth; in htc_try_send()
347 __func__, ep->eid, overflow, txqueue_depth, in htc_try_send()
348 ep->max_txq_depth); in htc_try_send()
351 (ep->ep_cb.tx_full == NULL)) { in htc_try_send()
354 * full indication handler -- just move all of them in htc_try_send()
357 list_splice_tail_init(txq, &send_queue); in htc_try_send()
359 good_pkts = get_queue_depth(txq) - overflow; in htc_try_send()
366 /* dequeue all non-overflow packets to the sendqueue */ in htc_try_send()
369 packet = list_first_entry(txq, in htc_try_send()
373 list_move_tail(&packet->list, &send_queue); in htc_try_send()
382 txq, list) { in htc_try_send()
386 action = ep->ep_cb.tx_full(ep->target, packet); in htc_try_send()
389 ep->ep_st.tx_dropped += 1; in htc_try_send()
397 list_move_tail(&packet->list, in htc_try_send()
409 if (!ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
412 ep->pipe.pipeid_ul); in htc_try_send()
417 spin_lock_bh(&target->tx_lock); in htc_try_send()
420 list_splice_tail_init(&send_queue, &ep->txq); in htc_try_send()
423 spin_unlock_bh(&target->tx_lock); in htc_try_send()
430 ep->tx_proc_cnt++; in htc_try_send()
432 if (ep->tx_proc_cnt > 1) { in htc_try_send()
438 ep->tx_proc_cnt--; in htc_try_send()
439 spin_unlock_bh(&target->tx_lock); in htc_try_send()
450 if (get_queue_depth(&ep->txq) == 0) in htc_try_send()
453 if (ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
478 spin_unlock_bh(&target->tx_lock); in htc_try_send()
483 if (!ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
484 pipeid = ep->pipe.pipeid_ul; in htc_try_send()
489 spin_lock_bh(&target->tx_lock); in htc_try_send()
493 ep->tx_proc_cnt = 0; in htc_try_send()
494 spin_unlock_bh(&target->tx_lock); in htc_try_send()
503 skb = packet->skb; in destroy_htc_txctrl_packet()
523 packet->skb = skb; in build_htc_txctrl_packet()
553 credit_per_maxmsg = MAX_MESSAGE_SIZE / target->tgt_cred_sz; in htc_setup_target_buffer_assignments()
554 if (MAX_MESSAGE_SIZE % target->tgt_cred_sz) in htc_setup_target_buffer_assignments()
559 credits = target->tgt_creds; in htc_setup_target_buffer_assignments()
560 entry = &target->pipe.txcredit_alloc[0]; in htc_setup_target_buffer_assignments()
562 status = -ENOMEM; in htc_setup_target_buffer_assignments()
567 "%s: For USB Audio Class- Total:%d\n", in htc_setup_target_buffer_assignments()
572 entry->service_id = WMI_DATA_VO_SVC; in htc_setup_target_buffer_assignments()
573 entry->credit_alloc = (credits - 6); in htc_setup_target_buffer_assignments()
574 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
575 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
577 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
582 entry->service_id = WMI_CONTROL_SVC; in htc_setup_target_buffer_assignments()
583 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
584 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
591 entry->service_id = WMI_DATA_BE_SVC; in htc_setup_target_buffer_assignments()
592 entry->credit_alloc = (u8) credits; in htc_setup_target_buffer_assignments()
596 entry->service_id = WMI_DATA_VI_SVC; in htc_setup_target_buffer_assignments()
597 entry->credit_alloc = credits / 4; in htc_setup_target_buffer_assignments()
598 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
599 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
601 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
606 entry->service_id = WMI_DATA_VO_SVC; in htc_setup_target_buffer_assignments()
607 entry->credit_alloc = credits / 4; in htc_setup_target_buffer_assignments()
608 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
609 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
611 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
616 entry->service_id = WMI_CONTROL_SVC; in htc_setup_target_buffer_assignments()
617 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
618 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
623 entry->service_id = WMI_DATA_BK_SVC; in htc_setup_target_buffer_assignments()
624 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
625 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
631 entry->service_id = WMI_DATA_BE_SVC; in htc_setup_target_buffer_assignments()
632 entry->credit_alloc = (u8) credits; in htc_setup_target_buffer_assignments()
638 if (target->pipe.txcredit_alloc[i].service_id != 0) { in htc_setup_target_buffer_assignments()
642 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
644 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
662 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
665 if (rpt->eid >= ENDPOINT_MAX) { in htc_process_credit_report()
667 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
671 ep = &target->endpoint[rpt->eid]; in htc_process_credit_report()
672 ep->cred_dist.credits += rpt->credits; in htc_process_credit_report()
674 if (ep->cred_dist.credits && get_queue_depth(&ep->txq)) { in htc_process_credit_report()
675 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
677 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
680 total_credits += rpt->credits; in htc_process_credit_report()
686 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
695 spin_lock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
696 while (get_queue_depth(&ep->txq)) { in htc_flush_tx_endpoint()
697 packet = list_first_entry(&ep->txq, struct htc_packet, list); in htc_flush_tx_endpoint()
698 list_del(&packet->list); in htc_flush_tx_endpoint()
699 packet->status = 0; in htc_flush_tx_endpoint()
702 spin_unlock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
709 * This is extra overhead that can be fixed by re-aligning HIF interfaces with
718 spin_lock_bh(&target->tx_lock); in htc_lookup_tx_packet()
722 * this lookup should be fast since lower layers completes in-order and in htc_lookup_tx_packet()
725 list_for_each_entry_safe(packet, tmp_pkt, &ep->pipe.tx_lookup_queue, in htc_lookup_tx_packet()
728 if (skb == packet->skb) { in htc_lookup_tx_packet()
730 list_del(&packet->list); in htc_lookup_tx_packet()
736 spin_unlock_bh(&target->tx_lock); in htc_lookup_tx_packet()
743 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_tx_complete()
749 netdata = skb->data; in ath6kl_htc_pipe_tx_complete()
753 ep_id = htc_hdr->eid; in ath6kl_htc_pipe_tx_complete()
754 ep = &target->endpoint[ep_id]; in ath6kl_htc_pipe_tx_complete()
762 packet->status = 0; in ath6kl_htc_pipe_tx_complete()
767 if (!ep->pipe.tx_credit_flow_enabled) { in ath6kl_htc_pipe_tx_complete()
769 * note: when using TX credit flow, the re-checking of queues in ath6kl_htc_pipe_tx_complete()
771 * non-TX credit case, we recheck after the packet completes in ath6kl_htc_pipe_tx_complete()
786 return -EINVAL; in htc_send_packets_multiple()
791 if (packet->endpoint >= ENDPOINT_MAX) { in htc_send_packets_multiple()
793 return -EINVAL; in htc_send_packets_multiple()
795 ep = &target->endpoint[packet->endpoint]; in htc_send_packets_multiple()
802 packet->status = -ENOMEM; in htc_send_packets_multiple()
815 spin_lock_bh(&target->rx_lock); in alloc_htc_packet_container()
817 if (target->pipe.htc_packet_pool == NULL) { in alloc_htc_packet_container()
818 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
822 packet = target->pipe.htc_packet_pool; in alloc_htc_packet_container()
823 target->pipe.htc_packet_pool = (struct htc_packet *) packet->list.next; in alloc_htc_packet_container()
825 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
827 packet->list.next = NULL; in alloc_htc_packet_container()
836 spin_lock_bh(&target->rx_lock); in free_htc_packet_container()
838 if (target->pipe.htc_packet_pool == NULL) { in free_htc_packet_container()
839 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
840 packet->list.next = NULL; in free_htc_packet_container()
842 lh = (struct list_head *) target->pipe.htc_packet_pool; in free_htc_packet_container()
843 packet->list.next = lh; in free_htc_packet_container()
844 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
847 spin_unlock_bh(&target->rx_lock); in free_htc_packet_container()
860 status = -EINVAL; in htc_process_trailer()
866 len -= sizeof(struct htc_record_hdr); in htc_process_trailer()
869 if (record->len > len) { in htc_process_trailer()
873 record->len, record->rec_id, len); in htc_process_trailer()
874 status = -EINVAL; in htc_process_trailer()
881 switch (record->rec_id) { in htc_process_trailer()
883 if (record->len < sizeof(struct htc_credit_report)) { in htc_process_trailer()
885 return -EINVAL; in htc_process_trailer()
890 record->len / sizeof(*report), in htc_process_trailer()
896 record->rec_id, record->len); in htc_process_trailer()
901 buffer += record->len; in htc_process_trailer()
902 len -= record->len; in htc_process_trailer()
922 list_del(&packet->list); in do_recv_completion()
923 ep->ep_cb.rx(ep->target, packet); in do_recv_completion()
935 list_add_tail(&packet->list, &container); in recv_packet_completion()
944 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_rx_complete()
954 * ar->htc_target can be NULL due to a race condition that can occur in ath6kl_htc_pipe_rx_complete()
956 * initializing 'ar->htc_target' via 'ath6kl_htc_create'). in ath6kl_htc_pipe_rx_complete()
959 * Thus the possibility of ar->htc_target being NULL in ath6kl_htc_pipe_rx_complete()
960 * via ath6kl_recv_complete -> ath6kl_usb_io_comp_work. in ath6kl_htc_pipe_rx_complete()
964 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
969 netdata = skb->data; in ath6kl_htc_pipe_rx_complete()
970 netlen = skb->len; in ath6kl_htc_pipe_rx_complete()
974 if (htc_hdr->eid >= ENDPOINT_MAX) { in ath6kl_htc_pipe_rx_complete()
977 htc_hdr->eid); in ath6kl_htc_pipe_rx_complete()
978 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
981 ep = &target->endpoint[htc_hdr->eid]; in ath6kl_htc_pipe_rx_complete()
983 payload_len = le16_to_cpu(get_unaligned(&htc_hdr->payld_len)); in ath6kl_htc_pipe_rx_complete()
989 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
994 hdr_info = htc_hdr->flags; in ath6kl_htc_pipe_rx_complete()
997 hdr_info = htc_hdr->ctrl[0]; in ath6kl_htc_pipe_rx_complete()
1003 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
1010 payload_len - hdr_info; in ath6kl_htc_pipe_rx_complete()
1012 htc_hdr->eid); in ath6kl_htc_pipe_rx_complete()
1017 if (((int) payload_len - (int) trailerlen) <= 0) { in ath6kl_htc_pipe_rx_complete()
1022 if (htc_hdr->eid == ENDPOINT_0) { in ath6kl_htc_pipe_rx_complete()
1024 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) { in ath6kl_htc_pipe_rx_complete()
1031 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
1038 netdata = skb->data; in ath6kl_htc_pipe_rx_complete()
1039 netlen = skb->len; in ath6kl_htc_pipe_rx_complete()
1041 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1043 target->pipe.ctrl_response_valid = true; in ath6kl_htc_pipe_rx_complete()
1044 target->pipe.ctrl_response_len = min_t(int, netlen, in ath6kl_htc_pipe_rx_complete()
1046 memcpy(target->pipe.ctrl_response_buf, netdata, in ath6kl_htc_pipe_rx_complete()
1047 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_rx_complete()
1049 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1064 status = -ENOMEM; in ath6kl_htc_pipe_rx_complete()
1068 packet->status = 0; in ath6kl_htc_pipe_rx_complete()
1069 packet->endpoint = htc_hdr->eid; in ath6kl_htc_pipe_rx_complete()
1070 packet->pkt_cntxt = skb; in ath6kl_htc_pipe_rx_complete()
1073 packet->buf = skb_push(skb, 0) + HTC_HDR_LENGTH; in ath6kl_htc_pipe_rx_complete()
1074 packet->act_len = netlen - HTC_HDR_LENGTH - trailerlen; in ath6kl_htc_pipe_rx_complete()
1100 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1103 if (list_empty(&ep->rx_bufq)) in htc_flush_rx_queue()
1106 packet = list_first_entry(&ep->rx_bufq, in htc_flush_rx_queue()
1108 list_del(&packet->list); in htc_flush_rx_queue()
1110 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1111 packet->status = -ECANCELED; in htc_flush_rx_queue()
1112 packet->act_len = 0; in htc_flush_rx_queue()
1116 packet, packet->buf_len, in htc_flush_rx_queue()
1117 packet->endpoint); in htc_flush_rx_queue()
1120 list_add_tail(&packet->list, &container); in htc_flush_rx_queue()
1124 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1127 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1136 spin_lock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1138 if (target->pipe.ctrl_response_valid) { in htc_wait_recv_ctrl_message()
1139 target->pipe.ctrl_response_valid = false; in htc_wait_recv_ctrl_message()
1140 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1144 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1146 count--; in htc_wait_recv_ctrl_message()
1153 return -ETIMEDOUT; in htc_wait_recv_ctrl_message()
1162 struct sk_buff *skb = packet->skb; in htc_rxctrl_complete()
1164 if (packet->endpoint == ENDPOINT_0 && in htc_rxctrl_complete()
1165 packet->status == -ECANCELED && in htc_rxctrl_complete()
1177 ep = &target->endpoint[i]; in reset_endpoint_states()
1178 ep->svc_id = 0; in reset_endpoint_states()
1179 ep->len_max = 0; in reset_endpoint_states()
1180 ep->max_txq_depth = 0; in reset_endpoint_states()
1181 ep->eid = i; in reset_endpoint_states()
1182 INIT_LIST_HEAD(&ep->txq); in reset_endpoint_states()
1183 INIT_LIST_HEAD(&ep->pipe.tx_lookup_queue); in reset_endpoint_states()
1184 INIT_LIST_HEAD(&ep->rx_bufq); in reset_endpoint_states()
1185 ep->target = target; in reset_endpoint_states()
1186 ep->pipe.tx_credit_flow_enabled = true; in reset_endpoint_states()
1203 if (target->pipe.txcredit_alloc[i].service_id == service_id) in htc_get_credit_alloc()
1205 target->pipe.txcredit_alloc[i].credit_alloc; in htc_get_credit_alloc()
1221 struct ath6kl *ar = target->dev->ar; in ath6kl_htc_pipe_conn_service()
1234 if (conn_req->svc_id == 0) { in ath6kl_htc_pipe_conn_service()
1236 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1240 if (conn_req->svc_id == HTC_CTRL_RSVD_SVC) { in ath6kl_htc_pipe_conn_service()
1247 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1249 status = -ENOMEM; in ath6kl_htc_pipe_conn_service()
1258 status = -ENOMEM; in ath6kl_htc_pipe_conn_service()
1262 skb = packet->skb; in ath6kl_htc_pipe_conn_service()
1269 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1275 conn_msg->msg_id = cpu_to_le16(HTC_MSG_CONN_SVC_ID); in ath6kl_htc_pipe_conn_service()
1276 conn_msg->svc_id = cpu_to_le16(conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1277 conn_msg->conn_flags = cpu_to_le16(conn_req->conn_flags & in ath6kl_htc_pipe_conn_service()
1282 conn_msg->conn_flags |= cpu_to_le16(flags); in ath6kl_htc_pipe_conn_service()
1284 if (conn_req->conn_flags & in ath6kl_htc_pipe_conn_service()
1309 target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_conn_service()
1311 if (resp_msg->msg_id != cpu_to_le16(HTC_MSG_CONN_SVC_RESP_ID) || in ath6kl_htc_pipe_conn_service()
1312 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) { in ath6kl_htc_pipe_conn_service()
1315 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1321 __func__, resp_msg->svc_id, resp_msg->status, in ath6kl_htc_pipe_conn_service()
1322 resp_msg->eid); in ath6kl_htc_pipe_conn_service()
1324 conn_resp->resp_code = resp_msg->status; in ath6kl_htc_pipe_conn_service()
1326 if (resp_msg->status != HTC_SERVICE_SUCCESS) { in ath6kl_htc_pipe_conn_service()
1329 resp_msg->svc_id, resp_msg->status); in ath6kl_htc_pipe_conn_service()
1330 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1334 assigned_epid = (enum htc_endpoint_id) resp_msg->eid; in ath6kl_htc_pipe_conn_service()
1335 max_msg_size = le16_to_cpu(resp_msg->max_msg_sz); in ath6kl_htc_pipe_conn_service()
1339 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1351 ep = &target->endpoint[assigned_epid]; in ath6kl_htc_pipe_conn_service()
1352 ep->eid = assigned_epid; in ath6kl_htc_pipe_conn_service()
1353 if (ep->svc_id != 0) { in ath6kl_htc_pipe_conn_service()
1360 conn_resp->endpoint = assigned_epid; in ath6kl_htc_pipe_conn_service()
1361 conn_resp->len_max = max_msg_size; in ath6kl_htc_pipe_conn_service()
1364 ep->svc_id = conn_req->svc_id; /* this marks ep in use */ in ath6kl_htc_pipe_conn_service()
1365 ep->max_txq_depth = conn_req->max_txq_depth; in ath6kl_htc_pipe_conn_service()
1366 ep->len_max = max_msg_size; in ath6kl_htc_pipe_conn_service()
1367 ep->cred_dist.credits = tx_alloc; in ath6kl_htc_pipe_conn_service()
1368 ep->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1369 ep->cred_dist.cred_per_msg = max_msg_size / target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1370 if (max_msg_size % target->tgt_cred_sz) in ath6kl_htc_pipe_conn_service()
1371 ep->cred_dist.cred_per_msg++; in ath6kl_htc_pipe_conn_service()
1374 ep->ep_cb = conn_req->ep_cb; in ath6kl_htc_pipe_conn_service()
1377 ep->tx_drop_packet_threshold = MAX_HI_COOKIE_NUM; in ath6kl_htc_pipe_conn_service()
1379 status = ath6kl_hif_pipe_map_service(ar, ep->svc_id, in ath6kl_htc_pipe_conn_service()
1380 &ep->pipe.pipeid_ul, in ath6kl_htc_pipe_conn_service()
1381 &ep->pipe.pipeid_dl); in ath6kl_htc_pipe_conn_service()
1387 ep->svc_id, ep->pipe.pipeid_ul, in ath6kl_htc_pipe_conn_service()
1388 ep->pipe.pipeid_dl, ep->eid); in ath6kl_htc_pipe_conn_service()
1390 if (disable_credit_flowctrl && ep->pipe.tx_credit_flow_enabled) { in ath6kl_htc_pipe_conn_service()
1391 ep->pipe.tx_credit_flow_enabled = false; in ath6kl_htc_pipe_conn_service()
1394 ep->svc_id, assigned_epid); in ath6kl_htc_pipe_conn_service()
1415 status = -ENOMEM; in ath6kl_htc_pipe_create()
1419 spin_lock_init(&target->htc_lock); in ath6kl_htc_pipe_create()
1420 spin_lock_init(&target->rx_lock); in ath6kl_htc_pipe_create()
1421 spin_lock_init(&target->tx_lock); in ath6kl_htc_pipe_create()
1432 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_pipe_create()
1433 if (!target->dev) { in ath6kl_htc_pipe_create()
1435 status = -ENOMEM; in ath6kl_htc_pipe_create()
1438 target->dev->ar = ar; in ath6kl_htc_pipe_create()
1439 target->dev->htc_cnxt = target; in ath6kl_htc_pipe_create()
1442 ep = &target->endpoint[ENDPOINT_0]; in ath6kl_htc_pipe_create()
1444 ath6kl_hif_pipe_get_default(ar, &ep->pipe.pipeid_ul, in ath6kl_htc_pipe_create()
1445 &ep->pipe.pipeid_dl); in ath6kl_htc_pipe_create()
1471 kfree(target->dev); in ath6kl_htc_pipe_cleanup()
1489 return -ENOMEM; in ath6kl_htc_pipe_start()
1492 skb = packet->skb; in ath6kl_htc_pipe_start()
1497 setup->msg_id = cpu_to_le16(HTC_MSG_SETUP_COMPLETE_EX_ID); in ath6kl_htc_pipe_start()
1505 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_start()
1517 ep = &target->endpoint[i]; in ath6kl_htc_pipe_stop()
1523 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_stop()
1529 int num; in ath6kl_htc_pipe_get_rxbuf_num() local
1531 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1532 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_pipe_get_rxbuf_num()
1533 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1535 return num; in ath6kl_htc_pipe_get_rxbuf_num()
1545 __func__, packet->endpoint, packet->buf, in ath6kl_htc_pipe_tx()
1546 packet->act_len); in ath6kl_htc_pipe_tx()
1549 list_add_tail(&packet->list, &queue); in ath6kl_htc_pipe_tx()
1566 if (target->pipe.ctrl_response_len < sizeof(*ready_msg)) { in ath6kl_htc_pipe_wait_target()
1568 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_wait_target()
1569 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1572 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_wait_target()
1574 if (ready_msg->ver2_0_info.msg_id != cpu_to_le16(HTC_MSG_READY_ID)) { in ath6kl_htc_pipe_wait_target()
1576 ready_msg->ver2_0_info.msg_id); in ath6kl_htc_pipe_wait_target()
1577 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1582 ready_msg->ver2_0_info.cred_cnt, in ath6kl_htc_pipe_wait_target()
1583 ready_msg->ver2_0_info.cred_sz); in ath6kl_htc_pipe_wait_target()
1585 target->tgt_creds = le16_to_cpu(ready_msg->ver2_0_info.cred_cnt); in ath6kl_htc_pipe_wait_target()
1586 target->tgt_cred_sz = le16_to_cpu(ready_msg->ver2_0_info.cred_sz); in ath6kl_htc_pipe_wait_target()
1588 if ((target->tgt_creds == 0) || (target->tgt_cred_sz == 0)) in ath6kl_htc_pipe_wait_target()
1589 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1610 struct htc_endpoint *ep = &target->endpoint[endpoint]; in ath6kl_htc_pipe_flush_txep()
1612 if (ep->svc_id == 0) { in ath6kl_htc_pipe_flush_txep()
1629 return -EINVAL; in ath6kl_htc_pipe_add_rxbuf_multiple()
1633 if (first->endpoint >= ENDPOINT_MAX) { in ath6kl_htc_pipe_add_rxbuf_multiple()
1635 return -EINVAL; in ath6kl_htc_pipe_add_rxbuf_multiple()
1639 __func__, first->endpoint, get_queue_depth(pkt_queue), in ath6kl_htc_pipe_add_rxbuf_multiple()
1640 first->buf_len); in ath6kl_htc_pipe_add_rxbuf_multiple()
1642 ep = &target->endpoint[first->endpoint]; in ath6kl_htc_pipe_add_rxbuf_multiple()
1644 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1647 list_splice_tail_init(pkt_queue, &ep->rx_bufq); in ath6kl_htc_pipe_add_rxbuf_multiple()
1649 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1654 packet->status = -ECANCELED; in ath6kl_htc_pipe_add_rxbuf_multiple()
1677 endpoint = &target->endpoint[i]; in ath6kl_htc_pipe_flush_rx_buf()
1679 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1682 &endpoint->rx_bufq, list) { in ath6kl_htc_pipe_flush_rx_buf()
1683 list_del(&packet->list); in ath6kl_htc_pipe_flush_rx_buf()
1684 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1687 packet, packet->buf_len, in ath6kl_htc_pipe_flush_rx_buf()
1688 packet->endpoint); in ath6kl_htc_pipe_flush_rx_buf()
1689 dev_kfree_skb(packet->pkt_cntxt); in ath6kl_htc_pipe_flush_rx_buf()
1690 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1693 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1723 ar->htc_ops = &ath6kl_htc_pipe_ops; in ath6kl_htc_pipe_attach()