Lines Matching full:target

56 		ep->ep_cb.tx_comp_multi(ep->target, queue_to_indicate);  in do_send_completion()
72 ep->ep_cb.tx_complete(ep->target, packet); in do_send_completion()
77 static void send_packet_completion(struct htc_target *target, in send_packet_completion() argument
80 struct htc_endpoint *ep = &target->endpoint[packet->endpoint]; in send_packet_completion()
91 static void get_htc_packet_credit_based(struct htc_target *target, in get_htc_packet_credit_based() argument
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()
146 /* check if we need credits back from the target */ in get_htc_packet_credit_based()
149 /* tell the target we need credits ASAP! */ in get_htc_packet_credit_based()
173 static void get_htc_packet(struct htc_target *target, in get_htc_packet() argument
203 static int htc_issue_packets(struct htc_target *target, in htc_issue_packets() argument
246 spin_lock_bh(&target->tx_lock); 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()
267 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
272 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
292 send_packet_completion(target, packet); in htc_issue_packets()
299 static enum htc_send_queue_result htc_try_send(struct htc_target *target, in htc_try_send() argument
305 struct ath6kl *ar = target->dev->ar; in htc_try_send()
328 spin_lock_bh(&target->tx_lock); in htc_try_send()
330 spin_unlock_bh(&target->tx_lock); in htc_try_send()
386 action = ep->ep_cb.tx_full(ep->target, packet); in htc_try_send()
417 spin_lock_bh(&target->tx_lock); in htc_try_send()
423 spin_unlock_bh(&target->tx_lock); in htc_try_send()
439 spin_unlock_bh(&target->tx_lock); in htc_try_send()
456 * based on target transmit resource availability, in htc_try_send()
458 * bus resources greater than target transmit in htc_try_send()
461 get_htc_packet_credit_based(target, ep, &send_queue); in htc_try_send()
467 get_htc_packet(target, ep, &send_queue, tx_resources); in htc_try_send()
478 spin_unlock_bh(&target->tx_lock); in htc_try_send()
481 htc_issue_packets(target, ep, &send_queue); in htc_try_send()
489 spin_lock_bh(&target->tx_lock); in htc_try_send()
494 spin_unlock_bh(&target->tx_lock); in htc_try_send()
528 static void htc_free_txctrl_packet(struct htc_target *target, in htc_free_txctrl_packet() argument
534 static struct htc_packet *htc_alloc_txctrl_packet(struct htc_target *target) in htc_alloc_txctrl_packet() argument
539 static void htc_txctrl_complete(struct htc_target *target, in htc_txctrl_complete() argument
542 htc_free_txctrl_packet(target, packet); in htc_txctrl_complete()
547 static int htc_setup_target_buffer_assignments(struct htc_target *target) in htc_setup_target_buffer_assignments() argument
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()
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()
653 static void htc_process_credit_report(struct htc_target *target, in htc_process_credit_report() argument
662 spin_lock_bh(&target->tx_lock); 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()
675 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
676 htc_try_send(target, ep, NULL); in htc_process_credit_report()
677 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
686 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
690 static void htc_flush_tx_endpoint(struct htc_target *target, in htc_flush_tx_endpoint() argument
695 spin_lock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
700 send_packet_completion(target, packet); in htc_flush_tx_endpoint()
702 spin_unlock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
712 static struct htc_packet *htc_lookup_tx_packet(struct htc_target *target, in htc_lookup_tx_packet() argument
718 spin_lock_bh(&target->tx_lock); 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() local
754 ep = &target->endpoint[ep_id]; in ath6kl_htc_pipe_tx_complete()
756 packet = htc_lookup_tx_packet(target, ep, skb); in ath6kl_htc_pipe_tx_complete()
763 send_packet_completion(target, packet); in ath6kl_htc_pipe_tx_complete()
770 * happens when credits flow back from the target. in the in ath6kl_htc_pipe_tx_complete()
773 htc_try_send(target, ep, NULL); in ath6kl_htc_pipe_tx_complete()
779 static int htc_send_packets_multiple(struct htc_target *target, in htc_send_packets_multiple() argument
795 ep = &target->endpoint[packet->endpoint]; in htc_send_packets_multiple()
797 htc_try_send(target, ep, pkt_queue); in htc_send_packets_multiple()
812 static struct htc_packet *alloc_htc_packet_container(struct htc_target *target) in alloc_htc_packet_container() argument
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()
831 static void free_htc_packet_container(struct htc_target *target, in free_htc_packet_container() argument
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()
842 lh = (struct list_head *) target->pipe.htc_packet_pool; 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()
850 static int htc_process_trailer(struct htc_target *target, u8 *buffer, in htc_process_trailer() argument
889 htc_process_credit_report(target, report, in htc_process_trailer()
923 ep->ep_cb.rx(ep->target, packet); in do_recv_completion()
929 static void recv_packet_completion(struct htc_target *target, in recv_packet_completion() argument
944 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_rx_complete() local
962 if (!target) { in ath6kl_htc_pipe_rx_complete()
963 ath6kl_dbg(ATH6KL_DBG_HTC, "Target not yet initialized\n"); in ath6kl_htc_pipe_rx_complete()
981 ep = &target->endpoint[htc_hdr->eid]; in ath6kl_htc_pipe_rx_complete()
1011 status = htc_process_trailer(target, trailer, hdr_info, in ath6kl_htc_pipe_rx_complete()
1024 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) { in ath6kl_htc_pipe_rx_complete()
1026 * fatal: target should not send unsolicited 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()
1062 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_rx_complete()
1082 recv_packet_completion(target, ep, packet); in ath6kl_htc_pipe_rx_complete()
1085 free_htc_packet_container(target, packet); in ath6kl_htc_pipe_rx_complete()
1094 static void htc_flush_rx_queue(struct htc_target *target, in htc_flush_rx_queue() argument
1100 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1110 spin_unlock_bh(&target->rx_lock); 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()
1131 static int htc_wait_recv_ctrl_message(struct htc_target *target) in htc_wait_recv_ctrl_message() argument
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()
1171 static void reset_endpoint_states(struct htc_target *target) in reset_endpoint_states() argument
1177 ep = &target->endpoint[i]; in reset_endpoint_states()
1185 ep->target = target; in reset_endpoint_states()
1191 static int htc_config_target_hif_pipe(struct htc_target *target) in htc_config_target_hif_pipe() argument
1197 static u8 htc_get_credit_alloc(struct htc_target *target, u16 service_id) in htc_get_credit_alloc() argument
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()
1217 static int ath6kl_htc_pipe_conn_service(struct htc_target *target, in ath6kl_htc_pipe_conn_service() argument
1221 struct ath6kl *ar = target->dev->ar; in ath6kl_htc_pipe_conn_service()
1247 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1253 /* allocate a packet to send to the target */ in ath6kl_htc_pipe_conn_service()
1254 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_conn_service()
1280 /* tell target desired recv alloc for this ep */ in ath6kl_htc_pipe_conn_service()
1293 status = ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_conn_service()
1301 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_conn_service()
1309 target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_conn_service()
1312 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) { in ath6kl_htc_pipe_conn_service()
1328 "Target failed service 0x%X connect request (status:%d)\n", in ath6kl_htc_pipe_conn_service()
1351 ep = &target->endpoint[assigned_epid]; 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()
1399 htc_free_txctrl_packet(target, packet); in ath6kl_htc_pipe_conn_service()
1408 struct htc_target *target = NULL; in ath6kl_htc_pipe_create() local
1412 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); in ath6kl_htc_pipe_create()
1413 if (target == NULL) { 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()
1423 reset_endpoint_states(target); in ath6kl_htc_pipe_create()
1429 free_htc_packet_container(target, packet); 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()
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()
1447 return target; in ath6kl_htc_pipe_create()
1451 if (target != NULL) in ath6kl_htc_pipe_create()
1452 ath6kl_htc_pipe_cleanup(target); in ath6kl_htc_pipe_create()
1454 target = NULL; in ath6kl_htc_pipe_create()
1456 return target; in ath6kl_htc_pipe_create()
1460 static void ath6kl_htc_pipe_cleanup(struct htc_target *target) in ath6kl_htc_pipe_cleanup() argument
1465 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_cleanup()
1471 kfree(target->dev); in ath6kl_htc_pipe_cleanup()
1474 kfree(target); in ath6kl_htc_pipe_cleanup()
1477 static int ath6kl_htc_pipe_start(struct htc_target *target) in ath6kl_htc_pipe_start() argument
1483 htc_config_target_hif_pipe(target); in ath6kl_htc_pipe_start()
1486 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_start()
1505 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_start()
1507 return ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_start()
1510 static void ath6kl_htc_pipe_stop(struct htc_target *target) in ath6kl_htc_pipe_stop() argument
1517 ep = &target->endpoint[i]; in ath6kl_htc_pipe_stop()
1518 htc_flush_rx_queue(target, ep); in ath6kl_htc_pipe_stop()
1519 htc_flush_tx_endpoint(target, ep, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_pipe_stop()
1522 reset_endpoint_states(target); in ath6kl_htc_pipe_stop()
1523 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_stop()
1526 static int ath6kl_htc_pipe_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_pipe_get_rxbuf_num() argument
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()
1538 static int ath6kl_htc_pipe_tx(struct htc_target *target, in ath6kl_htc_pipe_tx() argument
1551 return htc_send_packets_multiple(target, &queue); in ath6kl_htc_pipe_tx()
1554 static int ath6kl_htc_pipe_wait_target(struct htc_target *target) in ath6kl_htc_pipe_wait_target() argument
1561 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_wait_target()
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()
1572 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_wait_target()
1581 "Target Ready! : transmit resources : %d size:%d\n", 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()
1591 htc_setup_target_buffer_assignments(target); in ath6kl_htc_pipe_wait_target()
1602 status = ath6kl_htc_pipe_conn_service(target, &connect, &resp); in ath6kl_htc_pipe_wait_target()
1607 static void ath6kl_htc_pipe_flush_txep(struct htc_target *target, in ath6kl_htc_pipe_flush_txep() argument
1610 struct htc_endpoint *ep = &target->endpoint[endpoint]; in ath6kl_htc_pipe_flush_txep()
1618 htc_flush_tx_endpoint(target, ep, tag); in ath6kl_htc_pipe_flush_txep()
1621 static int ath6kl_htc_pipe_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_pipe_add_rxbuf_multiple() argument
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()
1649 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1663 static void ath6kl_htc_pipe_activity_changed(struct htc_target *target, in ath6kl_htc_pipe_activity_changed() argument
1670 static void ath6kl_htc_pipe_flush_rx_buf(struct htc_target *target) in ath6kl_htc_pipe_flush_rx_buf() argument
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()
1684 spin_unlock_bh(&target->rx_lock); 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()
1697 static int ath6kl_htc_pipe_credit_setup(struct htc_target *target, in ath6kl_htc_pipe_credit_setup() argument