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
247 spin_lock_bh(&target->tx_lock); 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()
268 spin_lock_bh(&target->tx_lock); in htc_issue_packets()
273 spin_unlock_bh(&target->tx_lock); in htc_issue_packets()
293 send_packet_completion(target, packet); in htc_issue_packets()
300 static enum htc_send_queue_result htc_try_send(struct htc_target *target, in htc_try_send() argument
306 struct ath6kl *ar = target->dev->ar; in htc_try_send()
329 spin_lock_bh(&target->tx_lock); in htc_try_send()
331 spin_unlock_bh(&target->tx_lock); in htc_try_send()
387 action = ep->ep_cb.tx_full(ep->target, packet); in htc_try_send()
418 spin_lock_bh(&target->tx_lock); in htc_try_send()
424 spin_unlock_bh(&target->tx_lock); in htc_try_send()
440 spin_unlock_bh(&target->tx_lock); in htc_try_send()
462 get_htc_packet_credit_based(target, ep, &send_queue); in htc_try_send()
468 get_htc_packet(target, ep, &send_queue, tx_resources); in htc_try_send()
479 spin_unlock_bh(&target->tx_lock); in htc_try_send()
482 htc_issue_packets(target, ep, &send_queue); in htc_try_send()
490 spin_lock_bh(&target->tx_lock); in htc_try_send()
495 spin_unlock_bh(&target->tx_lock); in htc_try_send()
529 static void htc_free_txctrl_packet(struct htc_target *target, in htc_free_txctrl_packet() argument
535 static struct htc_packet *htc_alloc_txctrl_packet(struct htc_target *target) in htc_alloc_txctrl_packet() argument
540 static void htc_txctrl_complete(struct htc_target *target, in htc_txctrl_complete() argument
543 htc_free_txctrl_packet(target, packet); in htc_txctrl_complete()
548 static int htc_setup_target_buffer_assignments(struct htc_target *target) in htc_setup_target_buffer_assignments() argument
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()
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()
654 static void htc_process_credit_report(struct htc_target *target, in htc_process_credit_report() argument
663 spin_lock_bh(&target->tx_lock); 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()
676 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
677 htc_try_send(target, ep, NULL); in htc_process_credit_report()
678 spin_lock_bh(&target->tx_lock); in htc_process_credit_report()
687 spin_unlock_bh(&target->tx_lock); in htc_process_credit_report()
691 static void htc_flush_tx_endpoint(struct htc_target *target, in htc_flush_tx_endpoint() argument
696 spin_lock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
701 send_packet_completion(target, packet); in htc_flush_tx_endpoint()
703 spin_unlock_bh(&target->tx_lock); in htc_flush_tx_endpoint()
713 static struct htc_packet *htc_lookup_tx_packet(struct htc_target *target, in htc_lookup_tx_packet() argument
719 spin_lock_bh(&target->tx_lock); 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() local
755 ep = &target->endpoint[ep_id]; in ath6kl_htc_pipe_tx_complete()
757 packet = htc_lookup_tx_packet(target, ep, skb); in ath6kl_htc_pipe_tx_complete()
764 send_packet_completion(target, packet); in ath6kl_htc_pipe_tx_complete()
774 htc_try_send(target, ep, NULL); in ath6kl_htc_pipe_tx_complete()
780 static int htc_send_packets_multiple(struct htc_target *target, in htc_send_packets_multiple() argument
796 ep = &target->endpoint[packet->endpoint]; in htc_send_packets_multiple()
798 htc_try_send(target, ep, pkt_queue); in htc_send_packets_multiple()
813 static struct htc_packet *alloc_htc_packet_container(struct htc_target *target) in alloc_htc_packet_container() argument
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()
832 static void free_htc_packet_container(struct htc_target *target, in free_htc_packet_container() argument
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()
843 lh = (struct list_head *) target->pipe.htc_packet_pool; 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()
851 static int htc_process_trailer(struct htc_target *target, u8 *buffer, in htc_process_trailer() argument
890 htc_process_credit_report(target, report, in htc_process_trailer()
924 ep->ep_cb.rx(ep->target, packet); in do_recv_completion()
930 static void recv_packet_completion(struct htc_target *target, in recv_packet_completion() argument
945 struct htc_target *target = ar->htc_target; in ath6kl_htc_pipe_rx_complete() local
963 if (!target) { in ath6kl_htc_pipe_rx_complete()
982 ep = &target->endpoint[htc_hdr->eid]; in ath6kl_htc_pipe_rx_complete()
1012 status = htc_process_trailer(target, trailer, hdr_info, in ath6kl_htc_pipe_rx_complete()
1025 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) { 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()
1063 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_rx_complete()
1083 recv_packet_completion(target, ep, packet); in ath6kl_htc_pipe_rx_complete()
1086 free_htc_packet_container(target, packet); in ath6kl_htc_pipe_rx_complete()
1095 static void htc_flush_rx_queue(struct htc_target *target, in htc_flush_rx_queue() argument
1101 spin_lock_bh(&target->rx_lock); in htc_flush_rx_queue()
1111 spin_unlock_bh(&target->rx_lock); 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()
1132 static int htc_wait_recv_ctrl_message(struct htc_target *target) in htc_wait_recv_ctrl_message() argument
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()
1172 static void reset_endpoint_states(struct htc_target *target) in reset_endpoint_states() argument
1178 ep = &target->endpoint[i]; in reset_endpoint_states()
1186 ep->target = target; in reset_endpoint_states()
1192 static int htc_config_target_hif_pipe(struct htc_target *target) in htc_config_target_hif_pipe() argument
1198 static u8 htc_get_credit_alloc(struct htc_target *target, u16 service_id) in htc_get_credit_alloc() argument
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()
1218 static int ath6kl_htc_pipe_conn_service(struct htc_target *target, in ath6kl_htc_pipe_conn_service() argument
1222 struct ath6kl *ar = target->dev->ar; in ath6kl_htc_pipe_conn_service()
1248 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); in ath6kl_htc_pipe_conn_service()
1255 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_conn_service()
1294 status = ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_conn_service()
1302 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_conn_service()
1310 target->pipe.ctrl_response_buf; in ath6kl_htc_pipe_conn_service()
1313 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) { in ath6kl_htc_pipe_conn_service()
1352 ep = &target->endpoint[assigned_epid]; 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()
1400 htc_free_txctrl_packet(target, packet); in ath6kl_htc_pipe_conn_service()
1409 struct htc_target *target = NULL; in ath6kl_htc_pipe_create() local
1413 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); in ath6kl_htc_pipe_create()
1414 if (target == NULL) { 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()
1424 reset_endpoint_states(target); in ath6kl_htc_pipe_create()
1430 free_htc_packet_container(target, packet); 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()
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()
1448 return target; in ath6kl_htc_pipe_create()
1452 if (target != NULL) in ath6kl_htc_pipe_create()
1453 ath6kl_htc_pipe_cleanup(target); in ath6kl_htc_pipe_create()
1455 target = NULL; in ath6kl_htc_pipe_create()
1457 return target; in ath6kl_htc_pipe_create()
1461 static void ath6kl_htc_pipe_cleanup(struct htc_target *target) in ath6kl_htc_pipe_cleanup() argument
1466 packet = alloc_htc_packet_container(target); in ath6kl_htc_pipe_cleanup()
1472 kfree(target->dev); in ath6kl_htc_pipe_cleanup()
1475 kfree(target); in ath6kl_htc_pipe_cleanup()
1478 static int ath6kl_htc_pipe_start(struct htc_target *target) in ath6kl_htc_pipe_start() argument
1484 htc_config_target_hif_pipe(target); in ath6kl_htc_pipe_start()
1487 packet = htc_alloc_txctrl_packet(target); in ath6kl_htc_pipe_start()
1506 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_start()
1508 return ath6kl_htc_pipe_tx(target, packet); in ath6kl_htc_pipe_start()
1511 static void ath6kl_htc_pipe_stop(struct htc_target *target) in ath6kl_htc_pipe_stop() argument
1518 ep = &target->endpoint[i]; in ath6kl_htc_pipe_stop()
1519 htc_flush_rx_queue(target, ep); in ath6kl_htc_pipe_stop()
1520 htc_flush_tx_endpoint(target, ep, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_pipe_stop()
1523 reset_endpoint_states(target); in ath6kl_htc_pipe_stop()
1524 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE; in ath6kl_htc_pipe_stop()
1527 static int ath6kl_htc_pipe_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_pipe_get_rxbuf_num() argument
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()
1539 static int ath6kl_htc_pipe_tx(struct htc_target *target, in ath6kl_htc_pipe_tx() argument
1552 return htc_send_packets_multiple(target, &queue); in ath6kl_htc_pipe_tx()
1555 static int ath6kl_htc_pipe_wait_target(struct htc_target *target) in ath6kl_htc_pipe_wait_target() argument
1562 status = htc_wait_recv_ctrl_message(target); in ath6kl_htc_pipe_wait_target()
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()
1573 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf; 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()
1592 htc_setup_target_buffer_assignments(target); in ath6kl_htc_pipe_wait_target()
1603 status = ath6kl_htc_pipe_conn_service(target, &connect, &resp); in ath6kl_htc_pipe_wait_target()
1608 static void ath6kl_htc_pipe_flush_txep(struct htc_target *target, in ath6kl_htc_pipe_flush_txep() argument
1611 struct htc_endpoint *ep = &target->endpoint[endpoint]; in ath6kl_htc_pipe_flush_txep()
1619 htc_flush_tx_endpoint(target, ep, tag); in ath6kl_htc_pipe_flush_txep()
1622 static int ath6kl_htc_pipe_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_pipe_add_rxbuf_multiple() argument
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()
1650 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_pipe_add_rxbuf_multiple()
1664 static void ath6kl_htc_pipe_activity_changed(struct htc_target *target, in ath6kl_htc_pipe_activity_changed() argument
1671 static void ath6kl_htc_pipe_flush_rx_buf(struct htc_target *target) in ath6kl_htc_pipe_flush_rx_buf() argument
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()
1685 spin_unlock_bh(&target->rx_lock); 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()
1698 static int ath6kl_htc_pipe_credit_setup(struct htc_target *target, in ath6kl_htc_pipe_credit_setup() argument