Lines Matching refs: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()
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
248 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
253 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
255 status = ath6kl_hif_pipe_send(target->dev->ar, in htc_issue_packets()
269 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
274 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
294 send_packet_completion(target, packet); in htc_issue_packets()
301 static enum htc_send_queue_result htc_try_send(struct htc_target *target, in htc_try_send() argument
307 struct ath6kl *ar = target->dev->ar; in htc_try_send()
330 spin_lock_bh(&target->tx_lock); in htc_try_send()
332 spin_unlock_bh(&target->tx_lock); in htc_try_send()
388 action = ep->ep_cb.tx_full(ep->target, packet); in htc_try_send()
419 spin_lock_bh(&target->tx_lock); in htc_try_send()
425 spin_unlock_bh(&target->tx_lock); in htc_try_send()
441 spin_unlock_bh(&target->tx_lock); in htc_try_send()
463 get_htc_packet_credit_based(target, ep, &send_queue); in htc_try_send()
469 get_htc_packet(target, ep, &send_queue, tx_resources); in htc_try_send()
480 spin_unlock_bh(&target->tx_lock); in htc_try_send()
483 htc_issue_packets(target, ep, &send_queue); in htc_try_send()
491 spin_lock_bh(&target->tx_lock); in htc_try_send()
496 spin_unlock_bh(&target->tx_lock); in htc_try_send()
530 static void htc_free_txctrl_packet(struct htc_target *target, in htc_free_txctrl_packet() argument
536 static struct htc_packet *htc_alloc_txctrl_packet(struct htc_target *target) in htc_alloc_txctrl_packet() argument
541 static void htc_txctrl_complete(struct htc_target *target, in htc_txctrl_complete() argument
544 htc_free_txctrl_packet(target, packet); in htc_txctrl_complete()
549 static int htc_setup_target_buffer_assignments(struct htc_target *target) in htc_setup_target_buffer_assignments() argument
555 credit_per_maxmsg = MAX_MESSAGE_SIZE / target->tgt_cred_sz; in htc_setup_target_buffer_assignments()
556 if (MAX_MESSAGE_SIZE % target->tgt_cred_sz) in htc_setup_target_buffer_assignments()
561 credits = target->tgt_creds; in htc_setup_target_buffer_assignments()
562 entry = &target->pipe.txcredit_alloc[0]; in htc_setup_target_buffer_assignments()
640 if (target->pipe.txcredit_alloc[i].service_id != 0) { in htc_setup_target_buffer_assignments()
644 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
646 target->pipe.txcredit_alloc[i]. in htc_setup_target_buffer_assignments()
655 static void htc_process_credit_report(struct htc_target *target, in htc_process_credit_report() argument
664 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
669 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
673 ep = &target->endpoint[rpt->eid]; in htc_process_credit_report()
677 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
678 htc_try_send(target, ep, NULL); in htc_process_credit_report()
679 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
688 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
692 static void htc_flush_tx_endpoint(struct htc_target *target, in htc_flush_tx_endpoint() argument
697 spin_lock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
702 send_packet_completion(target, packet); in htc_flush_tx_endpoint()
704 spin_unlock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
714 static struct htc_packet *htc_lookup_tx_packet(struct htc_target *target, in htc_lookup_tx_packet() argument
720 spin_lock_bh(&target->tx_lock); in htc_lookup_tx_packet()
738 spin_unlock_bh(&target->tx_lock); in htc_lookup_tx_packet()
745 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_tx_complete() local
758 ep = &target->endpoint[ep_id]; in ath6kl_htc_pipe_tx_complete()
760 packet = htc_lookup_tx_packet(target, ep, skb); in ath6kl_htc_pipe_tx_complete()
767 send_packet_completion(target, packet); in ath6kl_htc_pipe_tx_complete()
777 htc_try_send(target, ep, NULL); in ath6kl_htc_pipe_tx_complete()
783 static int htc_send_packets_multiple(struct htc_target *target, in htc_send_packets_multiple() argument
799 ep = &target->endpoint[packet->endpoint]; in htc_send_packets_multiple()
801 htc_try_send(target, ep, pkt_queue); in htc_send_packets_multiple()
816 static struct htc_packet *alloc_htc_packet_container(struct htc_target *target) in alloc_htc_packet_container() argument
819 spin_lock_bh(&target->rx_lock); in alloc_htc_packet_container()
821 if (target->pipe.htc_packet_pool == NULL) { in alloc_htc_packet_container()
822 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
826 packet = target->pipe.htc_packet_pool; in alloc_htc_packet_container()
827 target->pipe.htc_packet_pool = (struct htc_packet *) packet->list.next; in alloc_htc_packet_container()
829 spin_unlock_bh(&target->rx_lock); in alloc_htc_packet_container()
835 static void free_htc_packet_container(struct htc_target *target, in free_htc_packet_container() argument
840 spin_lock_bh(&target->rx_lock); in free_htc_packet_container()
842 if (target->pipe.htc_packet_pool == NULL) { in free_htc_packet_container()
843 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
846 lh = (struct list_head *) target->pipe.htc_packet_pool; in free_htc_packet_container()
848 target->pipe.htc_packet_pool = packet; in free_htc_packet_container()
851 spin_unlock_bh(&target->rx_lock); in free_htc_packet_container()
854 static int htc_process_trailer(struct htc_target *target, u8 *buffer, in htc_process_trailer() argument
897 htc_process_credit_report(target, report, in htc_process_trailer()
934 ep->ep_cb.rx(ep->target, packet); in do_recv_completion()
940 static void recv_packet_completion(struct htc_target *target, in recv_packet_completion() argument
955 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_rx_complete() local
973 if (WARN_ON_ONCE(!target)) { in ath6kl_htc_pipe_rx_complete()
992 ep = &target->endpoint[htc_hdr->eid]; in ath6kl_htc_pipe_rx_complete()
1022 status = htc_process_trailer(target, trailer, hdr_info, in ath6kl_htc_pipe_rx_complete()
1035 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) { in ath6kl_htc_pipe_rx_complete()
1052 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1054 target->pipe.ctrl_response_valid = true; in ath6kl_htc_pipe_rx_complete()
1055 target->pipe.ctrl_response_len = min_t(int, netlen, in ath6kl_htc_pipe_rx_complete()
1057 memcpy(target->pipe.ctrl_response_buf, netdata, in ath6kl_htc_pipe_rx_complete()
1058 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_rx_complete()
1060 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_rx_complete()
1073 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_rx_complete()
1093 recv_packet_completion(target, ep, packet); in ath6kl_htc_pipe_rx_complete()
1096 free_htc_packet_container(target, packet); in ath6kl_htc_pipe_rx_complete()
1105 static void htc_flush_rx_queue(struct htc_target *target, in htc_flush_rx_queue() argument
1111 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1121 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1135 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1138 spin_unlock_bh(&target->rx_lock); in htc_flush_rx_queue()
1142 static int htc_wait_recv_ctrl_message(struct htc_target *target) in htc_wait_recv_ctrl_message() argument
1147 spin_lock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1149 if (target->pipe.ctrl_response_valid) { in htc_wait_recv_ctrl_message()
1150 target->pipe.ctrl_response_valid = false; in htc_wait_recv_ctrl_message()
1151 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1155 spin_unlock_bh(&target->rx_lock); in htc_wait_recv_ctrl_message()
1182 static void reset_endpoint_states(struct htc_target *target) in reset_endpoint_states() argument
1188 ep = &target->endpoint[i]; in reset_endpoint_states()
1196 ep->target = target; in reset_endpoint_states()
1202 static int htc_config_target_hif_pipe(struct htc_target *target) in htc_config_target_hif_pipe() argument
1208 static u8 htc_get_credit_alloc(struct htc_target *target, u16 service_id) in htc_get_credit_alloc() argument
1214 if (target->pipe.txcredit_alloc[i].service_id == service_id) in htc_get_credit_alloc()
1216 target->pipe.txcredit_alloc[i].credit_alloc; in htc_get_credit_alloc()
1228 static int ath6kl_htc_pipe_conn_service(struct htc_target *target, in ath6kl_htc_pipe_conn_service() argument
1232 struct ath6kl *ar = target->dev->ar; in ath6kl_htc_pipe_conn_service()
1258 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1265 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_conn_service()
1305 status = ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_conn_service()
1313 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_conn_service()
1321 target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_conn_service()
1324 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) { in ath6kl_htc_pipe_conn_service()
1363 ep = &target->endpoint[assigned_epid]; in ath6kl_htc_pipe_conn_service()
1380 ep->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1381 ep->cred_dist.cred_per_msg = max_msg_size / target->tgt_cred_sz; in ath6kl_htc_pipe_conn_service()
1382 if (max_msg_size % target->tgt_cred_sz) in ath6kl_htc_pipe_conn_service()
1411 htc_free_txctrl_packet(target, packet); in ath6kl_htc_pipe_conn_service()
1420 struct htc_target *target = NULL; in ath6kl_htc_pipe_create() local
1424 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); in ath6kl_htc_pipe_create()
1425 if (target == NULL) { in ath6kl_htc_pipe_create()
1431 spin_lock_init(&target->htc_lock); in ath6kl_htc_pipe_create()
1432 spin_lock_init(&target->rx_lock); in ath6kl_htc_pipe_create()
1433 spin_lock_init(&target->tx_lock); in ath6kl_htc_pipe_create()
1435 reset_endpoint_states(target); in ath6kl_htc_pipe_create()
1441 free_htc_packet_container(target, packet); in ath6kl_htc_pipe_create()
1444 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_pipe_create()
1445 if (!target->dev) { in ath6kl_htc_pipe_create()
1450 target->dev->ar = ar; in ath6kl_htc_pipe_create()
1451 target->dev->htc_cnxt = target; in ath6kl_htc_pipe_create()
1454 ep = &target->endpoint[ENDPOINT_0]; in ath6kl_htc_pipe_create()
1459 return target; in ath6kl_htc_pipe_create()
1463 if (target != NULL) in ath6kl_htc_pipe_create()
1464 ath6kl_htc_pipe_cleanup(target); in ath6kl_htc_pipe_create()
1466 target = NULL; in ath6kl_htc_pipe_create()
1468 return target; in ath6kl_htc_pipe_create()
1472 static void ath6kl_htc_pipe_cleanup(struct htc_target *target) in ath6kl_htc_pipe_cleanup() argument
1477 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_cleanup()
1483 kfree(target->dev); in ath6kl_htc_pipe_cleanup()
1486 kfree(target); in ath6kl_htc_pipe_cleanup()
1489 static int ath6kl_htc_pipe_start(struct htc_target *target) in ath6kl_htc_pipe_start() argument
1495 htc_config_target_hif_pipe(target); in ath6kl_htc_pipe_start()
1498 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_start()
1518 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_start()
1520 return ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_start()
1523 static void ath6kl_htc_pipe_stop(struct htc_target *target) in ath6kl_htc_pipe_stop() argument
1530 ep = &target->endpoint[i]; in ath6kl_htc_pipe_stop()
1531 htc_flush_rx_queue(target, ep); in ath6kl_htc_pipe_stop()
1532 htc_flush_tx_endpoint(target, ep, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_pipe_stop()
1535 reset_endpoint_states(target); in ath6kl_htc_pipe_stop()
1536 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_stop()
1539 static int ath6kl_htc_pipe_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_pipe_get_rxbuf_num() argument
1544 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1545 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_pipe_get_rxbuf_num()
1546 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_get_rxbuf_num()
1551 static int ath6kl_htc_pipe_tx(struct htc_target *target, in ath6kl_htc_pipe_tx() argument
1564 return htc_send_packets_multiple(target, &queue); in ath6kl_htc_pipe_tx()
1567 static int ath6kl_htc_pipe_wait_target(struct htc_target *target) in ath6kl_htc_pipe_wait_target() argument
1574 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_wait_target()
1579 if (target->pipe.ctrl_response_len < sizeof(*ready_msg)) { in ath6kl_htc_pipe_wait_target()
1581 target->pipe.ctrl_response_len); in ath6kl_htc_pipe_wait_target()
1585 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_wait_target()
1598 target->tgt_creds = le16_to_cpu(ready_msg->ver2_0_info.cred_cnt); in ath6kl_htc_pipe_wait_target()
1599 target->tgt_cred_sz = le16_to_cpu(ready_msg->ver2_0_info.cred_sz); in ath6kl_htc_pipe_wait_target()
1601 if ((target->tgt_creds == 0) || (target->tgt_cred_sz == 0)) in ath6kl_htc_pipe_wait_target()
1604 htc_setup_target_buffer_assignments(target); in ath6kl_htc_pipe_wait_target()
1615 status = ath6kl_htc_pipe_conn_service(target, &connect, &resp); in ath6kl_htc_pipe_wait_target()
1620 static void ath6kl_htc_pipe_flush_txep(struct htc_target *target, in ath6kl_htc_pipe_flush_txep() argument
1623 struct htc_endpoint *ep = &target->endpoint[endpoint]; in ath6kl_htc_pipe_flush_txep()
1631 htc_flush_tx_endpoint(target, ep, tag); in ath6kl_htc_pipe_flush_txep()
1634 static int ath6kl_htc_pipe_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_pipe_add_rxbuf_multiple() argument
1655 ep = &target->endpoint[first->endpoint]; in ath6kl_htc_pipe_add_rxbuf_multiple()
1657 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1662 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1676 static void ath6kl_htc_pipe_activity_changed(struct htc_target *target, in ath6kl_htc_pipe_activity_changed() argument
1683 static void ath6kl_htc_pipe_flush_rx_buf(struct htc_target *target) in ath6kl_htc_pipe_flush_rx_buf() argument
1690 endpoint = &target->endpoint[i]; in ath6kl_htc_pipe_flush_rx_buf()
1692 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1697 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1703 spin_lock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1706 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_flush_rx_buf()
1710 static int ath6kl_htc_pipe_credit_setup(struct htc_target *target, in ath6kl_htc_pipe_credit_setup() argument