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()
241 put_unaligned((u16) payload_len, &htc_hdr->payld_len); in htc_issue_packets()
242 htc_hdr->flags = packet->info.tx.flags; in htc_issue_packets()
243 htc_hdr->eid = (u8) packet->endpoint; in htc_issue_packets()
244 htc_hdr->ctrl[0] = 0; in htc_issue_packets()
245 htc_hdr->ctrl[1] = (u8) packet->info.tx.seqno; in htc_issue_packets()
247 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
250 list_add_tail(&packet->list, &ep->pipe.tx_lookup_queue); in htc_issue_packets()
251 ep->ep_st.tx_issued += 1; in htc_issue_packets()
252 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
254 status = ath6kl_hif_pipe_send(target->dev->ar, in htc_issue_packets()
255 ep->pipe.pipeid_ul, NULL, skb); in htc_issue_packets()
258 if (status != -ENOMEM) { in htc_issue_packets()
268 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
269 list_del(&packet->list); in htc_issue_packets()
272 ep->cred_dist.credits += packet->info.tx.cred_used; in htc_issue_packets()
273 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
276 list_add(&packet->list, pkt_queue); in htc_issue_packets()
283 if (status != -ENOMEM) { in htc_issue_packets()
291 list_del(&packet->list); in htc_issue_packets()
292 packet->status = status; in htc_issue_packets()
302 struct list_head *txq) in htc_try_send() argument
306 struct ath6kl *ar = target->dev->ar; in htc_try_send()
312 __func__, txq, in htc_try_send()
313 (txq == NULL) ? 0 : get_queue_depth(txq)); in htc_try_send()
319 * txq equals to NULL means in htc_try_send()
323 if (txq != NULL) { in htc_try_send()
324 if (list_empty(txq)) { in htc_try_send()
329 spin_lock_bh(&target->tx_lock); in htc_try_send()
330 txqueue_depth = get_queue_depth(&ep->txq); in htc_try_send()
331 spin_unlock_bh(&target->tx_lock); in htc_try_send()
333 if (txqueue_depth >= ep->max_txq_depth) { in htc_try_send()
335 overflow = get_queue_depth(txq); in htc_try_send()
339 overflow += get_queue_depth(txq); in htc_try_send()
341 overflow -= ep->max_txq_depth; in htc_try_send()
348 __func__, ep->eid, overflow, txqueue_depth, in htc_try_send()
349 ep->max_txq_depth); in htc_try_send()
352 (ep->ep_cb.tx_full == NULL)) { in htc_try_send()
355 * full indication handler -- just move all of them in htc_try_send()
358 list_splice_tail_init(txq, &send_queue); in htc_try_send()
360 good_pkts = get_queue_depth(txq) - overflow; in htc_try_send()
367 /* dequeue all non-overflow packets to the sendqueue */ in htc_try_send()
370 packet = list_first_entry(txq, in htc_try_send()
374 list_move_tail(&packet->list, &send_queue); in htc_try_send()
383 txq, list) { in htc_try_send()
387 action = ep->ep_cb.tx_full(ep->target, packet); in htc_try_send()
390 ep->ep_st.tx_dropped += 1; in htc_try_send()
398 list_move_tail(&packet->list, in htc_try_send()
410 if (!ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
413 ep->pipe.pipeid_ul); in htc_try_send()
418 spin_lock_bh(&target->tx_lock); in htc_try_send()
421 list_splice_tail_init(&send_queue, &ep->txq); in htc_try_send()
424 spin_unlock_bh(&target->tx_lock); in htc_try_send()
431 ep->tx_proc_cnt++; in htc_try_send()
433 if (ep->tx_proc_cnt > 1) { in htc_try_send()
439 ep->tx_proc_cnt--; in htc_try_send()
440 spin_unlock_bh(&target->tx_lock); in htc_try_send()
451 if (get_queue_depth(&ep->txq) == 0) in htc_try_send()
454 if (ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
479 spin_unlock_bh(&target->tx_lock); in htc_try_send()
484 if (!ep->pipe.tx_credit_flow_enabled) { in htc_try_send()
485 pipeid = ep->pipe.pipeid_ul; in htc_try_send()
490 spin_lock_bh(&target->tx_lock); in htc_try_send()
494 ep->tx_proc_cnt = 0; in htc_try_send()
495 spin_unlock_bh(&target->tx_lock); in htc_try_send()
504 skb = packet->skb; in destroy_htc_txctrl_packet()
524 packet->skb = skb; in build_htc_txctrl_packet()
554 credit_per_maxmsg = MAX_MESSAGE_SIZE / target->tgt_cred_sz; in htc_setup_target_buffer_assignments()
555 if (MAX_MESSAGE_SIZE % target->tgt_cred_sz) in htc_setup_target_buffer_assignments()
560 credits = target->tgt_creds; in htc_setup_target_buffer_assignments()
561 entry = &target->pipe.txcredit_alloc[0]; in htc_setup_target_buffer_assignments()
563 status = -ENOMEM; in htc_setup_target_buffer_assignments()
568 "%s: For USB Audio Class- Total:%d\n", in htc_setup_target_buffer_assignments()
573 entry->service_id = WMI_DATA_VO_SVC; in htc_setup_target_buffer_assignments()
574 entry->credit_alloc = (credits - 6); in htc_setup_target_buffer_assignments()
575 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
576 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
578 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
583 entry->service_id = WMI_CONTROL_SVC; in htc_setup_target_buffer_assignments()
584 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
585 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
592 entry->service_id = WMI_DATA_BE_SVC; in htc_setup_target_buffer_assignments()
593 entry->credit_alloc = (u8) credits; in htc_setup_target_buffer_assignments()
597 entry->service_id = WMI_DATA_VI_SVC; in htc_setup_target_buffer_assignments()
598 entry->credit_alloc = credits / 4; in htc_setup_target_buffer_assignments()
599 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
600 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
602 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
607 entry->service_id = WMI_DATA_VO_SVC; in htc_setup_target_buffer_assignments()
608 entry->credit_alloc = credits / 4; in htc_setup_target_buffer_assignments()
609 if (entry->credit_alloc == 0) in htc_setup_target_buffer_assignments()
610 entry->credit_alloc++; in htc_setup_target_buffer_assignments()
612 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
617 entry->service_id = WMI_CONTROL_SVC; in htc_setup_target_buffer_assignments()
618 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
619 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
624 entry->service_id = WMI_DATA_BK_SVC; in htc_setup_target_buffer_assignments()
625 entry->credit_alloc = credit_per_maxmsg; in htc_setup_target_buffer_assignments()
626 credits -= (int) entry->credit_alloc; in htc_setup_target_buffer_assignments()
632 entry->service_id = WMI_DATA_BE_SVC; in htc_setup_target_buffer_assignments()
633 entry->credit_alloc = (u8) credits; in htc_setup_target_buffer_assignments()
639 if (target->pipe.txcredit_alloc[i].service_id != 0) { in htc_setup_target_buffer_assignments()
643 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
645 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
663 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
666 if (rpt->eid >= ENDPOINT_MAX) { in htc_process_credit_report()
668 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
672 ep = &target->endpoint[rpt->eid]; in htc_process_credit_report()
673 ep->cred_dist.credits += rpt->credits; in htc_process_credit_report()
675 if (ep->cred_dist.credits && get_queue_depth(&ep->txq)) { in htc_process_credit_report()
676 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
678 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
681 total_credits += rpt->credits; in htc_process_credit_report()
687 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
696 spin_lock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
697 while (get_queue_depth(&ep->txq)) { in htc_flush_tx_endpoint()
698 packet = list_first_entry(&ep->txq, struct htc_packet, list); in htc_flush_tx_endpoint()
699 list_del(&packet->list); in htc_flush_tx_endpoint()
700 packet->status = 0; in htc_flush_tx_endpoint()
703 spin_unlock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
710 * This is extra overhead that can be fixed by re-aligning HIF interfaces with
719 spin_lock_bh(&target->tx_lock); in htc_lookup_tx_packet()
723 * this lookup should be fast since lower layers completes in-order and in htc_lookup_tx_packet()
726 list_for_each_entry_safe(packet, tmp_pkt, &ep->pipe.tx_lookup_queue, in htc_lookup_tx_packet()
729 if (skb == packet->skb) { in htc_lookup_tx_packet()
731 list_del(&packet->list); in htc_lookup_tx_packet()
737 spin_unlock_bh(&target->tx_lock); in htc_lookup_tx_packet()
744 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_tx_complete()
750 netdata = skb->data; in ath6kl_htc_pipe_tx_complete()
754 ep_id = htc_hdr->eid; in ath6kl_htc_pipe_tx_complete()
755 ep = &target->endpoint[ep_id]; in ath6kl_htc_pipe_tx_complete()
763 packet->status = 0; in ath6kl_htc_pipe_tx_complete()
768 if (!ep->pipe.tx_credit_flow_enabled) { in ath6kl_htc_pipe_tx_complete()
770 * note: when using TX credit flow, the re-checking of queues in ath6kl_htc_pipe_tx_complete()
772 * non-TX credit case, we recheck after the packet completes in ath6kl_htc_pipe_tx_complete()
787 return -EINVAL; in htc_send_packets_multiple()
792 if (packet->endpoint >= ENDPOINT_MAX) { in htc_send_packets_multiple()
794 return -EINVAL; in htc_send_packets_multiple()
796 ep = &target->endpoint[packet->endpoint]; in htc_send_packets_multiple()
803 packet->status = -ENOMEM; in htc_send_packets_multiple()
816 spin_lock_bh(&target->rx_lock); in alloc_htc_packet_container()
818 if (target->pipe.htc_packet_pool == NULL) { in alloc_htc_packet_container()
819 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
823 packet = target->pipe.htc_packet_pool; in alloc_htc_packet_container()
824 target->pipe.htc_packet_pool = (struct htc_packet *) packet->list.next; in alloc_htc_packet_container()
826 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
828 packet->list.next = NULL; in alloc_htc_packet_container()
837 spin_lock_bh(&target->rx_lock); in free_htc_packet_container()
839 if (target->pipe.htc_packet_pool == NULL) { in free_htc_packet_container()
840 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
841 packet->list.next = NULL; in free_htc_packet_container()
843 lh = (struct list_head *) target->pipe.htc_packet_pool; in free_htc_packet_container()
844 packet->list.next = lh; in free_htc_packet_container()
845 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
848 spin_unlock_bh(&target->rx_lock); in free_htc_packet_container()
861 status = -EINVAL; in htc_process_trailer()
867 len -= sizeof(struct htc_record_hdr); in htc_process_trailer()
870 if (record->len > len) { in htc_process_trailer()
874 record->len, record->rec_id, len); in htc_process_trailer()
875 status = -EINVAL; in htc_process_trailer()
882 switch (record->rec_id) { in htc_process_trailer()
884 if (record->len < sizeof(struct htc_credit_report)) { in htc_process_trailer()
886 return -EINVAL; in htc_process_trailer()
891 record->len / sizeof(*report), in htc_process_trailer()
897 record->rec_id, record->len); in htc_process_trailer()
902 buffer += record->len; in htc_process_trailer()
903 len -= record->len; in htc_process_trailer()
923 list_del(&packet->list); in do_recv_completion()
924 ep->ep_cb.rx(ep->target, packet); in do_recv_completion()
936 list_add_tail(&packet->list, &container); in recv_packet_completion()
945 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_rx_complete()
955 * ar->htc_target can be NULL due to a race condition that can occur in ath6kl_htc_pipe_rx_complete()
957 * initializing 'ar->htc_target' via 'ath6kl_htc_create'). in ath6kl_htc_pipe_rx_complete()
960 * Thus the possibility of ar->htc_target being NULL in ath6kl_htc_pipe_rx_complete()
961 * via ath6kl_recv_complete -> ath6kl_usb_io_comp_work. in ath6kl_htc_pipe_rx_complete()
965 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
970 netdata = skb->data; in ath6kl_htc_pipe_rx_complete()
971 netlen = skb->len; in ath6kl_htc_pipe_rx_complete()
975 if (htc_hdr->eid >= ENDPOINT_MAX) { in ath6kl_htc_pipe_rx_complete()
978 htc_hdr->eid); in ath6kl_htc_pipe_rx_complete()
979 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
982 ep = &target->endpoint[htc_hdr->eid]; in ath6kl_htc_pipe_rx_complete()
984 payload_len = le16_to_cpu(get_unaligned(&htc_hdr->payld_len)); in ath6kl_htc_pipe_rx_complete()
990 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
995 hdr_info = htc_hdr->flags; in ath6kl_htc_pipe_rx_complete()
998 hdr_info = htc_hdr->ctrl[0]; in ath6kl_htc_pipe_rx_complete()
1004 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
1011 payload_len - hdr_info; in ath6kl_htc_pipe_rx_complete()
1013 htc_hdr->eid); in ath6kl_htc_pipe_rx_complete()
1018 if (((int) payload_len - (int) trailerlen) <= 0) { in ath6kl_htc_pipe_rx_complete()
1023 if (htc_hdr->eid == ENDPOINT_0) { in ath6kl_htc_pipe_rx_complete()
1025 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) { in ath6kl_htc_pipe_rx_complete()
1032 status = -EINVAL; in ath6kl_htc_pipe_rx_complete()
1039 netdata = skb->data; in ath6kl_htc_pipe_rx_complete()
1040 netlen = skb->len; in ath6kl_htc_pipe_rx_complete()
1042 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1044 target->pipe.ctrl_response_valid = true; in ath6kl_htc_pipe_rx_complete()
1045 target->pipe.ctrl_response_len = min_t(int, netlen, in ath6kl_htc_pipe_rx_complete()
1047 memcpy(target->pipe.ctrl_response_buf, netdata, in ath6kl_htc_pipe_rx_complete()
1048 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_rx_complete()
1050 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1065 status = -ENOMEM; in ath6kl_htc_pipe_rx_complete()
1069 packet->status = 0; in ath6kl_htc_pipe_rx_complete()
1070 packet->endpoint = htc_hdr->eid; in ath6kl_htc_pipe_rx_complete()
1071 packet->pkt_cntxt = skb; in ath6kl_htc_pipe_rx_complete()
1074 packet->buf = skb_push(skb, 0) + HTC_HDR_LENGTH; in ath6kl_htc_pipe_rx_complete()
1075 packet->act_len = netlen - HTC_HDR_LENGTH - trailerlen; in ath6kl_htc_pipe_rx_complete()
1101 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1104 if (list_empty(&ep->rx_bufq)) in htc_flush_rx_queue()
1107 packet = list_first_entry(&ep->rx_bufq, in htc_flush_rx_queue()
1109 list_del(&packet->list); in htc_flush_rx_queue()
1111 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1112 packet->status = -ECANCELED; in htc_flush_rx_queue()
1113 packet->act_len = 0; in htc_flush_rx_queue()
1117 packet, packet->buf_len, in htc_flush_rx_queue()
1118 packet->endpoint); in htc_flush_rx_queue()
1121 list_add_tail(&packet->list, &container); in htc_flush_rx_queue()
1125 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1128 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1137 spin_lock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1139 if (target->pipe.ctrl_response_valid) { in htc_wait_recv_ctrl_message()
1140 target->pipe.ctrl_response_valid = false; in htc_wait_recv_ctrl_message()
1141 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1145 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1147 count--; in htc_wait_recv_ctrl_message()
1154 return -ETIMEDOUT; in htc_wait_recv_ctrl_message()
1163 struct sk_buff *skb = packet->skb; in htc_rxctrl_complete()
1165 if (packet->endpoint == ENDPOINT_0 && in htc_rxctrl_complete()
1166 packet->status == -ECANCELED && in htc_rxctrl_complete()
1178 ep = &target->endpoint[i]; in reset_endpoint_states()
1179 ep->svc_id = 0; in reset_endpoint_states()
1180 ep->len_max = 0; in reset_endpoint_states()
1181 ep->max_txq_depth = 0; in reset_endpoint_states()
1182 ep->eid = i; in reset_endpoint_states()
1183 INIT_LIST_HEAD(&ep->txq); in reset_endpoint_states()
1184 INIT_LIST_HEAD(&ep->pipe.tx_lookup_queue); in reset_endpoint_states()
1185 INIT_LIST_HEAD(&ep->rx_bufq); in reset_endpoint_states()
1186 ep->target = target; in reset_endpoint_states()
1187 ep->pipe.tx_credit_flow_enabled = true; in reset_endpoint_states()
1204 if (target->pipe.txcredit_alloc[i].service_id == service_id) in htc_get_credit_alloc()
1206 target->pipe.txcredit_alloc[i].credit_alloc; in htc_get_credit_alloc()
1222 struct ath6kl *ar = target->dev->ar; in ath6kl_htc_pipe_conn_service()
1235 if (conn_req->svc_id == 0) { in ath6kl_htc_pipe_conn_service()
1237 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1241 if (conn_req->svc_id == HTC_CTRL_RSVD_SVC) { in ath6kl_htc_pipe_conn_service()
1248 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1250 status = -ENOMEM; in ath6kl_htc_pipe_conn_service()
1259 status = -ENOMEM; in ath6kl_htc_pipe_conn_service()
1263 skb = packet->skb; in ath6kl_htc_pipe_conn_service()
1270 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1276 conn_msg->msg_id = cpu_to_le16(HTC_MSG_CONN_SVC_ID); in ath6kl_htc_pipe_conn_service()
1277 conn_msg->svc_id = cpu_to_le16(conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1278 conn_msg->conn_flags = cpu_to_le16(conn_req->conn_flags & in ath6kl_htc_pipe_conn_service()
1283 conn_msg->conn_flags |= cpu_to_le16(flags); in ath6kl_htc_pipe_conn_service()
1285 if (conn_req->conn_flags & in ath6kl_htc_pipe_conn_service()
1310 target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_conn_service()
1312 if (resp_msg->msg_id != cpu_to_le16(HTC_MSG_CONN_SVC_RESP_ID) || in ath6kl_htc_pipe_conn_service()
1313 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) { in ath6kl_htc_pipe_conn_service()
1316 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1322 __func__, resp_msg->svc_id, resp_msg->status, in ath6kl_htc_pipe_conn_service()
1323 resp_msg->eid); in ath6kl_htc_pipe_conn_service()
1325 conn_resp->resp_code = resp_msg->status; in ath6kl_htc_pipe_conn_service()
1327 if (resp_msg->status != HTC_SERVICE_SUCCESS) { in ath6kl_htc_pipe_conn_service()
1330 resp_msg->svc_id, resp_msg->status); in ath6kl_htc_pipe_conn_service()
1331 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1335 assigned_epid = (enum htc_endpoint_id) resp_msg->eid; in ath6kl_htc_pipe_conn_service()
1336 max_msg_size = le16_to_cpu(resp_msg->max_msg_sz); in ath6kl_htc_pipe_conn_service()
1340 status = -EINVAL; in ath6kl_htc_pipe_conn_service()
1352 ep = &target->endpoint[assigned_epid]; in ath6kl_htc_pipe_conn_service()
1353 ep->eid = assigned_epid; in ath6kl_htc_pipe_conn_service()
1354 if (ep->svc_id != 0) { in ath6kl_htc_pipe_conn_service()
1361 conn_resp->endpoint = assigned_epid; in ath6kl_htc_pipe_conn_service()
1362 conn_resp->len_max = max_msg_size; in ath6kl_htc_pipe_conn_service()
1365 ep->svc_id = conn_req->svc_id; /* this marks ep in use */ in ath6kl_htc_pipe_conn_service()
1366 ep->max_txq_depth = conn_req->max_txq_depth; in ath6kl_htc_pipe_conn_service()
1367 ep->len_max = max_msg_size; in ath6kl_htc_pipe_conn_service()
1368 ep->cred_dist.credits = tx_alloc; in ath6kl_htc_pipe_conn_service()
1369 ep->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1370 ep->cred_dist.cred_per_msg = max_msg_size / target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1371 if (max_msg_size % target->tgt_cred_sz) in ath6kl_htc_pipe_conn_service()
1372 ep->cred_dist.cred_per_msg++; in ath6kl_htc_pipe_conn_service()
1375 ep->ep_cb = conn_req->ep_cb; in ath6kl_htc_pipe_conn_service()
1378 ep->tx_drop_packet_threshold = MAX_HI_COOKIE_NUM; in ath6kl_htc_pipe_conn_service()
1380 status = ath6kl_hif_pipe_map_service(ar, ep->svc_id, in ath6kl_htc_pipe_conn_service()
1381 &ep->pipe.pipeid_ul, in ath6kl_htc_pipe_conn_service()
1382 &ep->pipe.pipeid_dl); in ath6kl_htc_pipe_conn_service()
1388 ep->svc_id, ep->pipe.pipeid_ul, in ath6kl_htc_pipe_conn_service()
1389 ep->pipe.pipeid_dl, ep->eid); in ath6kl_htc_pipe_conn_service()
1391 if (disable_credit_flowctrl && ep->pipe.tx_credit_flow_enabled) { in ath6kl_htc_pipe_conn_service()
1392 ep->pipe.tx_credit_flow_enabled = false; in ath6kl_htc_pipe_conn_service()
1395 ep->svc_id, assigned_epid); in ath6kl_htc_pipe_conn_service()
1416 status = -ENOMEM; in ath6kl_htc_pipe_create()
1420 spin_lock_init(&target->htc_lock); in ath6kl_htc_pipe_create()
1421 spin_lock_init(&target->rx_lock); in ath6kl_htc_pipe_create()
1422 spin_lock_init(&target->tx_lock); in ath6kl_htc_pipe_create()
1433 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_pipe_create()
1434 if (!target->dev) { in ath6kl_htc_pipe_create()
1436 status = -ENOMEM; in ath6kl_htc_pipe_create()
1439 target->dev->ar = ar; in ath6kl_htc_pipe_create()
1440 target->dev->htc_cnxt = target; in ath6kl_htc_pipe_create()
1443 ep = &target->endpoint[ENDPOINT_0]; in ath6kl_htc_pipe_create()
1445 ath6kl_hif_pipe_get_default(ar, &ep->pipe.pipeid_ul, in ath6kl_htc_pipe_create()
1446 &ep->pipe.pipeid_dl); in ath6kl_htc_pipe_create()
1472 kfree(target->dev); in ath6kl_htc_pipe_cleanup()
1490 return -ENOMEM; in ath6kl_htc_pipe_start()
1493 skb = packet->skb; in ath6kl_htc_pipe_start()
1498 setup->msg_id = cpu_to_le16(HTC_MSG_SETUP_COMPLETE_EX_ID); in ath6kl_htc_pipe_start()
1506 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_start()
1518 ep = &target->endpoint[i]; in ath6kl_htc_pipe_stop()
1524 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_stop()
1530 int num; in ath6kl_htc_pipe_get_rxbuf_num() local
1532 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1533 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_pipe_get_rxbuf_num()
1534 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1536 return num; in ath6kl_htc_pipe_get_rxbuf_num()
1546 __func__, packet->endpoint, packet->buf, in ath6kl_htc_pipe_tx()
1547 packet->act_len); in ath6kl_htc_pipe_tx()
1550 list_add_tail(&packet->list, &queue); in ath6kl_htc_pipe_tx()
1567 if (target->pipe.ctrl_response_len < sizeof(*ready_msg)) { in ath6kl_htc_pipe_wait_target()
1569 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_wait_target()
1570 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1573 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_wait_target()
1575 if (ready_msg->ver2_0_info.msg_id != cpu_to_le16(HTC_MSG_READY_ID)) { in ath6kl_htc_pipe_wait_target()
1577 ready_msg->ver2_0_info.msg_id); in ath6kl_htc_pipe_wait_target()
1578 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1583 ready_msg->ver2_0_info.cred_cnt, in ath6kl_htc_pipe_wait_target()
1584 ready_msg->ver2_0_info.cred_sz); in ath6kl_htc_pipe_wait_target()
1586 target->tgt_creds = le16_to_cpu(ready_msg->ver2_0_info.cred_cnt); in ath6kl_htc_pipe_wait_target()
1587 target->tgt_cred_sz = le16_to_cpu(ready_msg->ver2_0_info.cred_sz); in ath6kl_htc_pipe_wait_target()
1589 if ((target->tgt_creds == 0) || (target->tgt_cred_sz == 0)) in ath6kl_htc_pipe_wait_target()
1590 return -ECOMM; in ath6kl_htc_pipe_wait_target()
1611 struct htc_endpoint *ep = &target->endpoint[endpoint]; in ath6kl_htc_pipe_flush_txep()
1613 if (ep->svc_id == 0) { in ath6kl_htc_pipe_flush_txep()
1630 return -EINVAL; in ath6kl_htc_pipe_add_rxbuf_multiple()
1634 if (first->endpoint >= ENDPOINT_MAX) { in ath6kl_htc_pipe_add_rxbuf_multiple()
1636 return -EINVAL; in ath6kl_htc_pipe_add_rxbuf_multiple()
1640 __func__, first->endpoint, get_queue_depth(pkt_queue), in ath6kl_htc_pipe_add_rxbuf_multiple()
1641 first->buf_len); in ath6kl_htc_pipe_add_rxbuf_multiple()
1643 ep = &target->endpoint[first->endpoint]; in ath6kl_htc_pipe_add_rxbuf_multiple()
1645 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1648 list_splice_tail_init(pkt_queue, &ep->rx_bufq); in ath6kl_htc_pipe_add_rxbuf_multiple()
1650 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1655 packet->status = -ECANCELED; in ath6kl_htc_pipe_add_rxbuf_multiple()
1678 endpoint = &target->endpoint[i]; in ath6kl_htc_pipe_flush_rx_buf()
1680 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1683 &endpoint->rx_bufq, list) { in ath6kl_htc_pipe_flush_rx_buf()
1684 list_del(&packet->list); in ath6kl_htc_pipe_flush_rx_buf()
1685 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1688 packet, packet->buf_len, in ath6kl_htc_pipe_flush_rx_buf()
1689 packet->endpoint); in ath6kl_htc_pipe_flush_rx_buf()
1690 dev_kfree_skb(packet->pkt_cntxt); in ath6kl_htc_pipe_flush_rx_buf()
1691 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1694 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1724 ar->htc_ops = &ath6kl_htc_pipe_ops; in ath6kl_htc_pipe_attach()