Lines Matching refs:target

56 		ep->ep_cb.tx_comp_multi(ep->target, queue_to_indicate);
72 ep->ep_cb.tx_complete(ep->target, packet);
77 static void send_packet_completion(struct htc_target *target,
80 struct htc_endpoint *ep = &target->endpoint[packet->endpoint];
91 static void get_htc_packet_credit_based(struct htc_target *target,
118 if (transfer_len <= target->tgt_cred_sz) {
122 credits_required = transfer_len / target->tgt_cred_sz;
123 remainder = transfer_len % target->tgt_cred_sz;
146 /* check if we need credits back from the target */
149 /* tell the target we need credits ASAP! */
173 static void get_htc_packet(struct htc_target *target,
203 static int htc_issue_packets(struct htc_target *target,
247 spin_lock_bh(&target->tx_lock);
252 spin_unlock_bh(&target->tx_lock);
254 status = ath6kl_hif_pipe_send(target->dev->ar,
268 spin_lock_bh(&target->tx_lock);
273 spin_unlock_bh(&target->tx_lock);
293 send_packet_completion(target, packet);
300 static enum htc_send_queue_result htc_try_send(struct htc_target *target,
306 struct ath6kl *ar = target->dev->ar;
329 spin_lock_bh(&target->tx_lock);
331 spin_unlock_bh(&target->tx_lock);
387 action = ep->ep_cb.tx_full(ep->target, packet);
418 spin_lock_bh(&target->tx_lock);
424 spin_unlock_bh(&target->tx_lock);
440 spin_unlock_bh(&target->tx_lock);
457 * based on target transmit resource availability,
459 * bus resources greater than target transmit
462 get_htc_packet_credit_based(target, ep, &send_queue);
468 get_htc_packet(target, ep, &send_queue, tx_resources);
479 spin_unlock_bh(&target->tx_lock);
482 htc_issue_packets(target, ep, &send_queue);
490 spin_lock_bh(&target->tx_lock);
495 spin_unlock_bh(&target->tx_lock);
529 static void htc_free_txctrl_packet(struct htc_target *target,
535 static struct htc_packet *htc_alloc_txctrl_packet(struct htc_target *target)
540 static void htc_txctrl_complete(struct htc_target *target,
543 htc_free_txctrl_packet(target, packet);
548 static int htc_setup_target_buffer_assignments(struct htc_target *target)
554 credit_per_maxmsg = MAX_MESSAGE_SIZE / target->tgt_cred_sz;
555 if (MAX_MESSAGE_SIZE % target->tgt_cred_sz)
560 credits = target->tgt_creds;
561 entry = &target->pipe.txcredit_alloc[0];
639 if (target->pipe.txcredit_alloc[i].service_id != 0) {
643 target->pipe.txcredit_alloc[i].
645 target->pipe.txcredit_alloc[i].
654 static void htc_process_credit_report(struct htc_target *target,
663 spin_lock_bh(&target->tx_lock);
668 spin_unlock_bh(&target->tx_lock);
672 ep = &target->endpoint[rpt->eid];
676 spin_unlock_bh(&target->tx_lock);
677 htc_try_send(target, ep, NULL);
678 spin_lock_bh(&target->tx_lock);
687 spin_unlock_bh(&target->tx_lock);
691 static void htc_flush_tx_endpoint(struct htc_target *target,
696 spin_lock_bh(&target->tx_lock);
701 send_packet_completion(target, packet);
703 spin_unlock_bh(&target->tx_lock);
713 static struct htc_packet *htc_lookup_tx_packet(struct htc_target *target,
719 spin_lock_bh(&target->tx_lock);
737 spin_unlock_bh(&target->tx_lock);
744 struct htc_target *target = ar->htc_target;
755 ep = &target->endpoint[ep_id];
757 packet = htc_lookup_tx_packet(target, ep, skb);
764 send_packet_completion(target, packet);
771 * happens when credits flow back from the target. in the
774 htc_try_send(target, ep, NULL);
780 static int htc_send_packets_multiple(struct htc_target *target,
796 ep = &target->endpoint[packet->endpoint];
798 htc_try_send(target, ep, pkt_queue);
813 static struct htc_packet *alloc_htc_packet_container(struct htc_target *target)
816 spin_lock_bh(&target->rx_lock);
818 if (target->pipe.htc_packet_pool == NULL) {
819 spin_unlock_bh(&target->rx_lock);
823 packet = target->pipe.htc_packet_pool;
824 target->pipe.htc_packet_pool = (struct htc_packet *) packet->list.next;
826 spin_unlock_bh(&target->rx_lock);
832 static void free_htc_packet_container(struct htc_target *target,
837 spin_lock_bh(&target->rx_lock);
839 if (target->pipe.htc_packet_pool == NULL) {
840 target->pipe.htc_packet_pool = packet;
843 lh = (struct list_head *) target->pipe.htc_packet_pool;
845 target->pipe.htc_packet_pool = packet;
848 spin_unlock_bh(&target->rx_lock);
851 static int htc_process_trailer(struct htc_target *target, u8 *buffer,
890 htc_process_credit_report(target, report,
924 ep->ep_cb.rx(ep->target, packet);
930 static void recv_packet_completion(struct htc_target *target,
945 struct htc_target *target = ar->htc_target;
963 if (!target) {
982 ep = &target->endpoint[htc_hdr->eid];
1012 status = htc_process_trailer(target, trailer, hdr_info,
1025 if (target->htc_flags & HTC_OP_STATE_SETUP_COMPLETE) {
1027 * fatal: target should not send unsolicited
1042 spin_lock_bh(&target->rx_lock);
1044 target->pipe.ctrl_response_valid = true;
1045 target->pipe.ctrl_response_len = min_t(int, netlen,
1047 memcpy(target->pipe.ctrl_response_buf, netdata,
1048 target->pipe.ctrl_response_len);
1050 spin_unlock_bh(&target->rx_lock);
1063 packet = alloc_htc_packet_container(target);
1083 recv_packet_completion(target, ep, packet);
1086 free_htc_packet_container(target, packet);
1095 static void htc_flush_rx_queue(struct htc_target *target,
1101 spin_lock_bh(&target->rx_lock);
1111 spin_unlock_bh(&target->rx_lock);
1125 spin_lock_bh(&target->rx_lock);
1128 spin_unlock_bh(&target->rx_lock);
1132 static int htc_wait_recv_ctrl_message(struct htc_target *target)
1137 spin_lock_bh(&target->rx_lock);
1139 if (target->pipe.ctrl_response_valid) {
1140 target->pipe.ctrl_response_valid = false;
1141 spin_unlock_bh(&target->rx_lock);
1145 spin_unlock_bh(&target->rx_lock);
1172 static void reset_endpoint_states(struct htc_target *target)
1178 ep = &target->endpoint[i];
1186 ep->target = target;
1192 static int htc_config_target_hif_pipe(struct htc_target *target)
1198 static u8 htc_get_credit_alloc(struct htc_target *target, u16 service_id)
1204 if (target->pipe.txcredit_alloc[i].service_id == service_id)
1206 target->pipe.txcredit_alloc[i].credit_alloc;
1218 static int ath6kl_htc_pipe_conn_service(struct htc_target *target,
1222 struct ath6kl *ar = target->dev->ar;
1248 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id);
1254 /* allocate a packet to send to the target */
1255 packet = htc_alloc_txctrl_packet(target);
1281 /* tell target desired recv alloc for this ep */
1294 status = ath6kl_htc_pipe_tx(target, packet);
1302 status = htc_wait_recv_ctrl_message(target);
1310 target->pipe.ctrl_response_buf;
1313 (target->pipe.ctrl_response_len < sizeof(*resp_msg))) {
1352 ep = &target->endpoint[assigned_epid];
1369 ep->cred_dist.cred_sz = target->tgt_cred_sz;
1370 ep->cred_dist.cred_per_msg = max_msg_size / target->tgt_cred_sz;
1371 if (max_msg_size % target->tgt_cred_sz)
1400 htc_free_txctrl_packet(target, packet);
1409 struct htc_target *target = NULL;
1413 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL);
1414 if (target == NULL) {
1420 spin_lock_init(&target->htc_lock);
1421 spin_lock_init(&target->rx_lock);
1422 spin_lock_init(&target->tx_lock);
1424 reset_endpoint_states(target);
1430 free_htc_packet_container(target, packet);
1433 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL);
1434 if (!target->dev) {
1439 target->dev->ar = ar;
1440 target->dev->htc_cnxt = target;
1443 ep = &target->endpoint[ENDPOINT_0];
1448 return target;
1452 if (target != NULL)
1453 ath6kl_htc_pipe_cleanup(target);
1455 target = NULL;
1457 return target;
1461 static void ath6kl_htc_pipe_cleanup(struct htc_target *target)
1466 packet = alloc_htc_packet_container(target);
1472 kfree(target->dev);
1475 kfree(target);
1478 static int ath6kl_htc_pipe_start(struct htc_target *target)
1484 htc_config_target_hif_pipe(target);
1487 packet = htc_alloc_txctrl_packet(target);
1506 target->htc_flags |= HTC_OP_STATE_SETUP_COMPLETE;
1508 return ath6kl_htc_pipe_tx(target, packet);
1511 static void ath6kl_htc_pipe_stop(struct htc_target *target)
1518 ep = &target->endpoint[i];
1519 htc_flush_rx_queue(target, ep);
1520 htc_flush_tx_endpoint(target, ep, HTC_TX_PACKET_TAG_ALL);
1523 reset_endpoint_states(target);
1524 target->htc_flags &= ~HTC_OP_STATE_SETUP_COMPLETE;
1527 static int ath6kl_htc_pipe_get_rxbuf_num(struct htc_target *target,
1532 spin_lock_bh(&target->rx_lock);
1533 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq));
1534 spin_unlock_bh(&target->rx_lock);
1539 static int ath6kl_htc_pipe_tx(struct htc_target *target,
1552 return htc_send_packets_multiple(target, &queue);
1555 static int ath6kl_htc_pipe_wait_target(struct htc_target *target)
1562 status = htc_wait_recv_ctrl_message(target);
1567 if (target->pipe.ctrl_response_len < sizeof(*ready_msg)) {
1569 target->pipe.ctrl_response_len);
1573 ready_msg = (struct htc_ready_ext_msg *) target->pipe.ctrl_response_buf;
1586 target->tgt_creds = le16_to_cpu(ready_msg->ver2_0_info.cred_cnt);
1587 target->tgt_cred_sz = le16_to_cpu(ready_msg->ver2_0_info.cred_sz);
1589 if ((target->tgt_creds == 0) || (target->tgt_cred_sz == 0))
1592 htc_setup_target_buffer_assignments(target);
1603 status = ath6kl_htc_pipe_conn_service(target, &connect, &resp);
1608 static void ath6kl_htc_pipe_flush_txep(struct htc_target *target,
1611 struct htc_endpoint *ep = &target->endpoint[endpoint];
1619 htc_flush_tx_endpoint(target, ep, tag);
1622 static int ath6kl_htc_pipe_add_rxbuf_multiple(struct htc_target *target,
1643 ep = &target->endpoint[first->endpoint];
1645 spin_lock_bh(&target->rx_lock);
1650 spin_unlock_bh(&target->rx_lock);
1664 static void ath6kl_htc_pipe_activity_changed(struct htc_target *target,
1671 static void ath6kl_htc_pipe_flush_rx_buf(struct htc_target *target)
1678 endpoint = &target->endpoint[i];
1680 spin_lock_bh(&target->rx_lock);
1685 spin_unlock_bh(&target->rx_lock);
1691 spin_lock_bh(&target->rx_lock);
1694 spin_unlock_bh(&target->rx_lock);
1698 static int ath6kl_htc_pipe_credit_setup(struct htc_target *target,