Lines Matching full:target

28 static void ath6kl_htc_mbox_cleanup(struct htc_target *target);
29 static void ath6kl_htc_mbox_stop(struct htc_target *target);
30 static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target,
32 static void ath6kl_htc_set_credit_dist(struct htc_target *target,
374 static void htc_reclaim_txctrl_buf(struct htc_target *target, in htc_reclaim_txctrl_buf() argument
377 spin_lock_bh(&target->htc_lock); in htc_reclaim_txctrl_buf()
378 list_add_tail(&pkt->list, &target->free_ctrl_txbuf); in htc_reclaim_txctrl_buf()
379 spin_unlock_bh(&target->htc_lock); in htc_reclaim_txctrl_buf()
382 static struct htc_packet *htc_get_control_buf(struct htc_target *target, in htc_get_control_buf() argument
388 buf_list = tx ? &target->free_ctrl_txbuf : &target->free_ctrl_rxbuf; in htc_get_control_buf()
390 spin_lock_bh(&target->htc_lock); in htc_get_control_buf()
393 spin_unlock_bh(&target->htc_lock); in htc_get_control_buf()
399 spin_unlock_bh(&target->htc_lock); in htc_get_control_buf()
407 static void htc_tx_comp_update(struct htc_target *target, in htc_tx_comp_update() argument
422 spin_lock_bh(&target->tx_lock); in htc_tx_comp_update()
428 target->credit_info, &target->cred_dist_list); in htc_tx_comp_update()
430 ath6kl_credit_distribute(target->credit_info, in htc_tx_comp_update()
431 &target->cred_dist_list, in htc_tx_comp_update()
434 spin_unlock_bh(&target->tx_lock); in htc_tx_comp_update()
447 ath6kl_tx_complete(endpoint->target, txq); in htc_tx_complete()
450 static void htc_tx_comp_handler(struct htc_target *target, in htc_tx_comp_handler() argument
453 struct htc_endpoint *endpoint = &target->endpoint[packet->endpoint]; in htc_tx_comp_handler()
459 htc_tx_comp_update(target, endpoint, packet); in htc_tx_comp_handler()
466 static void htc_async_tx_scat_complete(struct htc_target *target, in htc_async_tx_scat_complete() argument
484 endpoint = &target->endpoint[packet->endpoint]; in htc_async_tx_scat_complete()
495 htc_tx_comp_update(target, endpoint, packet); in htc_async_tx_scat_complete()
500 hif_scatter_req_add(target->dev->ar, scat_req); in htc_async_tx_scat_complete()
506 static int ath6kl_htc_tx_issue(struct htc_target *target, in ath6kl_htc_tx_issue() argument
518 padded_len = CALC_TXRX_PADDED_LEN(target, send_len); in ath6kl_htc_tx_issue()
523 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
527 status = hif_read_write_sync(target->dev->ar, in ath6kl_htc_tx_issue()
528 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
535 status = hif_write_async(target->dev->ar, in ath6kl_htc_tx_issue()
536 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
545 static int htc_check_credits(struct htc_target *target, in htc_check_credits() argument
550 *req_cred = (len > target->tgt_cred_sz) ? in htc_check_credits()
551 DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; in htc_check_credits()
563 ath6kl_credit_seek(target->credit_info, &ep->cred_dist); in htc_check_credits()
583 ath6kl_credit_seek(target->credit_info, &ep->cred_dist); in htc_check_credits()
587 /* tell the target we need credits ASAP! */ in htc_check_credits()
598 static void ath6kl_htc_tx_pkts_get(struct htc_target *target, in ath6kl_htc_tx_pkts_get() argument
619 len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_tx_pkts_get()
622 if (htc_check_credits(target, endpoint, &flags, in ath6kl_htc_tx_pkts_get()
636 packet->context = target; in ath6kl_htc_tx_pkts_get()
678 static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, in ath6kl_htc_tx_setup_scat_list() argument
689 rem_scat = target->max_tx_bndl_sz; in ath6kl_htc_tx_setup_scat_list()
698 len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_tx_setup_scat_list()
701 cred_pad = htc_get_credit_padding(target->tgt_cred_sz, in ath6kl_htc_tx_setup_scat_list()
758 struct htc_target *target = endpoint->target; in ath6kl_htc_tx_bundle() local
768 ac = target->dev->ar->ep2ac_map[endpoint->eid]; in ath6kl_htc_tx_bundle()
773 n_scat = min(n_scat, target->msg_per_bndl_max); in ath6kl_htc_tx_bundle()
779 scat_req = hif_scatter_req_get(target->dev->ar); in ath6kl_htc_tx_bundle()
809 target->tx_bndl_mask &= ~txb_mask; in ath6kl_htc_tx_bundle()
811 target->tx_bndl_mask |= txb_mask; in ath6kl_htc_tx_bundle()
820 status = ath6kl_htc_tx_setup_scat_list(target, endpoint, in ath6kl_htc_tx_bundle()
824 hif_scatter_req_add(target->dev->ar, scat_req); in ath6kl_htc_tx_bundle()
843 ath6kl_hif_submit_scat_req(target->dev, scat_req, false); in ath6kl_htc_tx_bundle()
857 static void ath6kl_htc_tx_from_queue(struct htc_target *target, in ath6kl_htc_tx_from_queue() argument
867 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
872 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
885 ac = target->dev->ar->ep2ac_map[endpoint->eid]; in ath6kl_htc_tx_from_queue()
891 ath6kl_htc_tx_pkts_get(target, endpoint, &txq); in ath6kl_htc_tx_from_queue()
896 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
903 if ((target->tx_bndl_mask) && in ath6kl_htc_tx_from_queue()
909 if (target->tx_bndl_mask & (1 << ac)) { in ath6kl_htc_tx_from_queue()
926 status = ath6kl_htc_tx_issue(target, packet); in ath6kl_htc_tx_from_queue()
934 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
945 if (!(target->tx_bndl_mask & (1 << ac)) && in ath6kl_htc_tx_from_queue()
947 if (++target->ac_tx_count[ac] >= in ath6kl_htc_tx_from_queue()
949 target->ac_tx_count[ac] = 0; in ath6kl_htc_tx_from_queue()
950 target->tx_bndl_mask |= (1 << ac); in ath6kl_htc_tx_from_queue()
956 target->ac_tx_count[ac] = 0; in ath6kl_htc_tx_from_queue()
961 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
964 static bool ath6kl_htc_tx_try(struct htc_target *target, in ath6kl_htc_tx_try() argument
974 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
976 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
988 if (ep_cb.tx_full(endpoint->target, tx_pkt) == in ath6kl_htc_tx_try()
995 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
997 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
999 ath6kl_htc_tx_from_queue(target, endpoint); in ath6kl_htc_tx_try()
1004 static void htc_chk_ep_txq(struct htc_target *target) in htc_chk_ep_txq() argument
1015 list_for_each_entry(cred_dist, &target->cred_dist_list, list) { in htc_chk_ep_txq()
1018 spin_lock_bh(&target->tx_lock); in htc_chk_ep_txq()
1025 spin_unlock_bh(&target->tx_lock); in htc_chk_ep_txq()
1033 ath6kl_htc_tx_from_queue(target, endpoint); in htc_chk_ep_txq()
1034 spin_lock_bh(&target->tx_lock); in htc_chk_ep_txq()
1036 spin_unlock_bh(&target->tx_lock); in htc_chk_ep_txq()
1040 static int htc_setup_tx_complete(struct htc_target *target) in htc_setup_tx_complete() argument
1045 send_pkt = htc_get_control_buf(target, true); in htc_setup_tx_complete()
1050 if (target->htc_tgt_ver >= HTC_VERSION_2P1) { in htc_setup_tx_complete()
1060 if (target->msg_per_bndl_max > 0) { in htc_setup_tx_complete()
1061 /* Indicate HTC bundling to the target */ in htc_setup_tx_complete()
1064 target->msg_per_bndl_max; in htc_setup_tx_complete()
1086 status = ath6kl_htc_tx_issue(target, send_pkt); in htc_setup_tx_complete()
1087 htc_reclaim_txctrl_buf(target, send_pkt); in htc_setup_tx_complete()
1092 static void ath6kl_htc_set_credit_dist(struct htc_target *target, in ath6kl_htc_set_credit_dist() argument
1099 target->credit_info = credit_info; in ath6kl_htc_set_credit_dist()
1101 list_add_tail(&target->endpoint[ENDPOINT_0].cred_dist.list, in ath6kl_htc_set_credit_dist()
1102 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1106 endpoint = &target->endpoint[ep]; in ath6kl_htc_set_credit_dist()
1109 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1120 static int ath6kl_htc_mbox_tx(struct htc_target *target, in ath6kl_htc_mbox_tx() argument
1135 endpoint = &target->endpoint[packet->endpoint]; in ath6kl_htc_mbox_tx()
1137 if (!ath6kl_htc_tx_try(target, endpoint, packet)) { in ath6kl_htc_mbox_tx()
1138 packet->status = (target->htc_flags & HTC_OP_STATE_STOPPING) ? in ath6kl_htc_mbox_tx()
1149 static void ath6kl_htc_mbox_flush_txep(struct htc_target *target, in ath6kl_htc_mbox_flush_txep() argument
1154 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_flush_txep()
1164 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1172 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1188 static void ath6kl_htc_flush_txep_all(struct htc_target *target) in ath6kl_htc_flush_txep_all() argument
1193 dump_cred_dist_stats(target); in ath6kl_htc_flush_txep_all()
1196 endpoint = &target->endpoint[i]; in ath6kl_htc_flush_txep_all()
1200 ath6kl_htc_mbox_flush_txep(target, i, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_flush_txep_all()
1204 static void ath6kl_htc_mbox_activity_changed(struct htc_target *target, in ath6kl_htc_mbox_activity_changed() argument
1208 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_activity_changed()
1216 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1236 target->credit_info, &target->cred_dist_list); in ath6kl_htc_mbox_activity_changed()
1238 ath6kl_credit_distribute(target->credit_info, in ath6kl_htc_mbox_activity_changed()
1239 &target->cred_dist_list, in ath6kl_htc_mbox_activity_changed()
1243 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1246 htc_chk_ep_txq(target); in ath6kl_htc_mbox_activity_changed()
1261 static inline bool htc_valid_rx_frame_len(struct htc_target *target, in htc_valid_rx_frame_len() argument
1264 return (eid == target->dev->ar->ctrl_ep) ? in htc_valid_rx_frame_len()
1268 static int htc_add_rxbuf(struct htc_target *target, struct htc_packet *packet) in htc_add_rxbuf() argument
1274 return ath6kl_htc_mbox_add_rxbuf_multiple(target, &queue); in htc_add_rxbuf()
1277 static void htc_reclaim_rxbuf(struct htc_target *target, in htc_reclaim_rxbuf() argument
1284 ep->ep_cb.rx(ep->target, packet); in htc_reclaim_rxbuf()
1287 htc_add_rxbuf((void *)(target), packet); in htc_reclaim_rxbuf()
1291 static void reclaim_rx_ctrl_buf(struct htc_target *target, in reclaim_rx_ctrl_buf() argument
1294 spin_lock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1295 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in reclaim_rx_ctrl_buf()
1296 spin_unlock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1299 static int ath6kl_htc_rx_packet(struct htc_target *target, in ath6kl_htc_rx_packet() argument
1303 struct ath6kl_device *dev = target->dev; in ath6kl_htc_rx_packet()
1307 padded_len = CALC_TXRX_PADDED_LEN(target, rx_len); in ath6kl_htc_rx_packet()
1353 spin_lock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1356 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1357 ep_cb.rx_refill(endpoint->target, endpoint->eid); in ath6kl_htc_rx_chk_water_mark()
1360 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1365 static int ath6kl_htc_rx_setup(struct htc_target *target, in ath6kl_htc_rx_setup() argument
1376 full_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_setup()
1380 if (!htc_valid_rx_frame_len(target, ep->eid, full_len)) { in ath6kl_htc_rx_setup()
1402 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1405 packet = ep_cb.rx_allocthresh(ep->target, ep->eid, in ath6kl_htc_rx_setup()
1407 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1412 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1413 ep_cb.rx_refill(ep->target, ep->eid); in ath6kl_htc_rx_setup()
1414 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1428 target->rx_st_flags |= HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_rx_setup()
1429 target->ep_waiting = ep->eid; in ath6kl_htc_rx_setup()
1449 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rx_setup()
1468 static int ath6kl_htc_rx_alloc(struct htc_target *target, in ath6kl_htc_rx_alloc() argument
1478 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1522 if (n_msg > target->msg_per_bndl_max) { in ath6kl_htc_rx_alloc()
1536 status = ath6kl_htc_rx_setup(target, endpoint, &lk_ahds[i], in ath6kl_htc_rx_alloc()
1545 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1553 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1558 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_alloc()
1559 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_alloc()
1591 static void htc_proc_cred_rpt(struct htc_target *target, in htc_proc_cred_rpt() argument
1600 spin_lock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1605 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1609 endpoint = &target->endpoint[rpt->eid]; in htc_proc_cred_rpt()
1658 ath6kl_credit_distribute(target->credit_info, in htc_proc_cred_rpt()
1659 &target->cred_dist_list, in htc_proc_cred_rpt()
1663 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1666 htc_chk_ep_txq(target); in htc_proc_cred_rpt()
1669 static int htc_parse_trailer(struct htc_target *target, in htc_parse_trailer() argument
1687 htc_proc_cred_rpt(target, in htc_parse_trailer()
1749 static int htc_proc_trailer(struct htc_target *target, in htc_proc_trailer() argument
1784 status = htc_parse_trailer(target, record, record_buf, in htc_proc_trailer()
1802 static int ath6kl_htc_rx_process_hdr(struct htc_target *target, in ath6kl_htc_rx_process_hdr() argument
1877 status = htc_proc_trailer(target, packet->buf + HTC_HDR_LENGTH in ath6kl_htc_rx_process_hdr()
1906 endpoint->ep_cb.rx(endpoint->target, packet); in ath6kl_htc_rx_complete()
1909 static int ath6kl_htc_rx_bundle(struct htc_target *target, in ath6kl_htc_rx_bundle() argument
1916 int rem_space = target->max_rx_bndl_sz; in ath6kl_htc_rx_bundle()
1920 n_scat_pkt = min(n_scat_pkt, target->msg_per_bndl_max); in ath6kl_htc_rx_bundle()
1931 * This would only happen if the target ignored our max in ath6kl_htc_rx_bundle()
1944 scat_req = hif_scatter_req_get(target->dev->ar); in ath6kl_htc_rx_bundle()
1955 pad_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_bundle()
1989 status = ath6kl_hif_submit_scat_req(target->dev, scat_req, true); in ath6kl_htc_rx_bundle()
1995 hif_scatter_req_add(target->dev->ar, scat_req); in ath6kl_htc_rx_bundle()
2002 static int ath6kl_htc_rx_process_packets(struct htc_target *target, in ath6kl_htc_rx_process_packets() argument
2012 ep = &target->endpoint[packet->endpoint]; in ath6kl_htc_rx_process_packets()
2018 status = ath6kl_htc_rx_process_hdr(target, packet, lk_ahds, in ath6kl_htc_rx_process_packets()
2052 static int ath6kl_htc_rx_fetch(struct htc_target *target, in ath6kl_htc_rx_fetch() argument
2068 if (target->rx_bndl_enable && (get_queue_depth(rx_pktq) > 1)) { in ath6kl_htc_rx_fetch()
2074 status = ath6kl_htc_rx_bundle(target, rx_pktq, in ath6kl_htc_rx_fetch()
2104 status = ath6kl_htc_rx_packet(target, packet, in ath6kl_htc_rx_fetch()
2127 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2128 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2133 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2134 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2140 int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, in ath6kl_htc_rxmsg_pending_handler() argument
2167 endpoint = &target->endpoint[id]; in ath6kl_htc_rxmsg_pending_handler()
2183 status = ath6kl_htc_rx_alloc(target, look_aheads, in ath6kl_htc_rxmsg_pending_handler()
2194 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2200 status = ath6kl_htc_rx_fetch(target, &rx_pktq, &comp_pktq); in ath6kl_htc_rxmsg_pending_handler()
2206 status = ath6kl_htc_rx_process_packets(target, &comp_pktq, in ath6kl_htc_rxmsg_pending_handler()
2220 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2231 htc_reclaim_rxbuf(target, packets, in ath6kl_htc_rxmsg_pending_handler()
2232 &target->endpoint[packets->endpoint]); in ath6kl_htc_rxmsg_pending_handler()
2235 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rxmsg_pending_handler()
2237 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2245 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_rxmsg_pending_handler()
2247 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2255 * Synchronously wait for a control message from the target,
2259 static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) in htc_wait_for_ctrl_msg() argument
2264 if (ath6kl_hif_poll_mboxmsg_rx(target->dev, &look_ahead.word, in htc_wait_for_ctrl_msg()
2274 packet = htc_get_control_buf(target, false); in htc_wait_for_ctrl_msg()
2290 if (ath6kl_htc_rx_packet(target, packet, packet->act_len)) in htc_wait_for_ctrl_msg()
2297 packet->status = ath6kl_htc_rx_process_hdr(target, packet, NULL, NULL); in htc_wait_for_ctrl_msg()
2310 reclaim_rx_ctrl_buf(target, packet); in htc_wait_for_ctrl_msg()
2316 static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_mbox_add_rxbuf_multiple() argument
2338 endpoint = &target->endpoint[first_pkt->endpoint]; in ath6kl_htc_mbox_add_rxbuf_multiple()
2340 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2353 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2358 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2359 if (target->ep_waiting == first_pkt->endpoint) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2362 target->ep_waiting); in ath6kl_htc_mbox_add_rxbuf_multiple()
2363 target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_mbox_add_rxbuf_multiple()
2364 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_add_rxbuf_multiple()
2369 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2371 if (rx_unblock && !(target->htc_flags & HTC_OP_STATE_STOPPING)) in ath6kl_htc_mbox_add_rxbuf_multiple()
2373 ath6kl_hif_rx_control(target->dev, true); in ath6kl_htc_mbox_add_rxbuf_multiple()
2378 static void ath6kl_htc_mbox_flush_rx_buf(struct htc_target *target) in ath6kl_htc_mbox_flush_rx_buf() argument
2385 endpoint = &target->endpoint[i]; in ath6kl_htc_mbox_flush_rx_buf()
2390 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2394 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2401 * been queued from target->free_ctrl_rxbuf where in ath6kl_htc_mbox_flush_rx_buf()
2414 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2416 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2420 static int ath6kl_htc_mbox_conn_service(struct htc_target *target, in ath6kl_htc_mbox_conn_service() argument
2435 "htc connect service target 0x%p service id 0x%x\n", in ath6kl_htc_mbox_conn_service()
2436 target, conn_req->svc_id); in ath6kl_htc_mbox_conn_service()
2443 /* allocate a packet to send to the target */ in ath6kl_htc_mbox_conn_service()
2444 tx_pkt = htc_get_control_buf(target, true); in ath6kl_htc_mbox_conn_service()
2462 status = ath6kl_htc_tx_issue(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2468 rx_pkt = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_conn_service()
2487 ath6kl_err("target failed service 0x%X connect request (status:%d)\n", in ath6kl_htc_mbox_conn_service()
2503 endpoint = &target->endpoint[assigned_ep]; in ath6kl_htc_mbox_conn_service()
2525 endpoint->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2547 conn_req->max_rxmsg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2550 max_msg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2560 htc_reclaim_txctrl_buf(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2564 reclaim_rx_ctrl_buf(target, rx_pkt); in ath6kl_htc_mbox_conn_service()
2570 static void reset_ep_state(struct htc_target *target) in reset_ep_state() argument
2576 endpoint = &target->endpoint[i]; in reset_ep_state()
2585 endpoint->target = target; in reset_ep_state()
2590 INIT_LIST_HEAD(&target->cred_dist_list); in reset_ep_state()
2593 static int ath6kl_htc_mbox_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_mbox_get_rxbuf_num() argument
2598 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2599 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_mbox_get_rxbuf_num()
2600 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2604 static void htc_setup_msg_bndl(struct htc_target *target) in htc_setup_msg_bndl() argument
2607 target->msg_per_bndl_max = min(HTC_HOST_MAX_MSG_PER_BUNDLE, in htc_setup_msg_bndl()
2608 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2610 if (ath6kl_hif_enable_scatter(target->dev->ar)) { in htc_setup_msg_bndl()
2611 target->msg_per_bndl_max = 0; in htc_setup_msg_bndl()
2616 target->msg_per_bndl_max = min(target->max_scat_entries, in htc_setup_msg_bndl()
2617 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2621 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2624 target->max_rx_bndl_sz = target->max_xfer_szper_scatreq; in htc_setup_msg_bndl()
2626 target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, in htc_setup_msg_bndl()
2627 target->max_xfer_szper_scatreq); in htc_setup_msg_bndl()
2630 target->max_rx_bndl_sz, target->max_tx_bndl_sz); in htc_setup_msg_bndl()
2632 if (target->max_tx_bndl_sz) in htc_setup_msg_bndl()
2634 target->tx_bndl_mask = (1 << WMM_NUM_AC) - 1; in htc_setup_msg_bndl()
2636 if (target->max_rx_bndl_sz) in htc_setup_msg_bndl()
2637 target->rx_bndl_enable = true; in htc_setup_msg_bndl()
2639 if ((target->tgt_cred_sz % target->block_sz) != 0) { in htc_setup_msg_bndl()
2641 target->tgt_cred_sz); in htc_setup_msg_bndl()
2649 target->tx_bndl_mask = 0; in htc_setup_msg_bndl()
2653 static int ath6kl_htc_mbox_wait_target(struct htc_target *target) in ath6kl_htc_mbox_wait_target() argument
2661 /* we should be getting 1 control message that the target is ready */ in ath6kl_htc_mbox_wait_target()
2662 packet = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_wait_target()
2681 target->tgt_creds = le16_to_cpu(rdy_msg->ver2_0_info.cred_cnt); in ath6kl_htc_mbox_wait_target()
2682 target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); in ath6kl_htc_mbox_wait_target()
2685 "htc target ready credits %d size %d\n", in ath6kl_htc_mbox_wait_target()
2686 target->tgt_creds, target->tgt_cred_sz); in ath6kl_htc_mbox_wait_target()
2691 target->htc_tgt_ver = rdy_msg->htc_ver; in ath6kl_htc_mbox_wait_target()
2692 target->msg_per_bndl_max = rdy_msg->msg_per_htc_bndl; in ath6kl_htc_mbox_wait_target()
2695 target->htc_tgt_ver = HTC_VERSION_2P0; in ath6kl_htc_mbox_wait_target()
2696 target->msg_per_bndl_max = 0; in ath6kl_htc_mbox_wait_target()
2700 (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", in ath6kl_htc_mbox_wait_target()
2701 target->htc_tgt_ver); in ath6kl_htc_mbox_wait_target()
2703 if (target->msg_per_bndl_max > 0) in ath6kl_htc_mbox_wait_target()
2704 htc_setup_msg_bndl(target); in ath6kl_htc_mbox_wait_target()
2716 status = ath6kl_htc_mbox_conn_service((void *)target, &connect, &resp); in ath6kl_htc_mbox_wait_target()
2723 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_wait_target()
2728 reclaim_rx_ctrl_buf(target, packet); in ath6kl_htc_mbox_wait_target()
2735 * Start HTC, enable interrupts and let the target know
2738 static int ath6kl_htc_mbox_start(struct htc_target *target) in ath6kl_htc_mbox_start() argument
2743 memset(&target->dev->irq_proc_reg, 0, in ath6kl_htc_mbox_start()
2744 sizeof(target->dev->irq_proc_reg)); in ath6kl_htc_mbox_start()
2747 ath6kl_hif_disable_intrs(target->dev); in ath6kl_htc_mbox_start()
2749 target->htc_flags = 0; in ath6kl_htc_mbox_start()
2750 target->rx_st_flags = 0; in ath6kl_htc_mbox_start()
2753 while ((packet = htc_get_control_buf(target, false)) != NULL) { in ath6kl_htc_mbox_start()
2754 status = htc_add_rxbuf(target, packet); in ath6kl_htc_mbox_start()
2760 ath6kl_credit_init(target->credit_info, &target->cred_dist_list, in ath6kl_htc_mbox_start()
2761 target->tgt_creds); in ath6kl_htc_mbox_start()
2763 dump_cred_dist_stats(target); in ath6kl_htc_mbox_start()
2765 /* Indicate to the target of the setup completion */ in ath6kl_htc_mbox_start()
2766 status = htc_setup_tx_complete(target); in ath6kl_htc_mbox_start()
2772 status = ath6kl_hif_unmask_intrs(target->dev); in ath6kl_htc_mbox_start()
2775 ath6kl_htc_mbox_stop(target); in ath6kl_htc_mbox_start()
2780 static int ath6kl_htc_reset(struct htc_target *target) in ath6kl_htc_reset() argument
2786 reset_ep_state(target); in ath6kl_htc_reset()
2788 block_size = target->dev->ar->mbox_info.block_size; in ath6kl_htc_reset()
2810 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in ath6kl_htc_reset()
2812 list_add_tail(&packet->list, &target->free_ctrl_txbuf); in ath6kl_htc_reset()
2820 static void ath6kl_htc_mbox_stop(struct htc_target *target) in ath6kl_htc_mbox_stop() argument
2822 spin_lock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2823 target->htc_flags |= HTC_OP_STATE_STOPPING; in ath6kl_htc_mbox_stop()
2824 spin_unlock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2831 ath6kl_hif_mask_intrs(target->dev); in ath6kl_htc_mbox_stop()
2833 ath6kl_htc_flush_txep_all(target); in ath6kl_htc_mbox_stop()
2835 ath6kl_htc_mbox_flush_rx_buf(target); in ath6kl_htc_mbox_stop()
2837 ath6kl_htc_reset(target); in ath6kl_htc_mbox_stop()
2842 struct htc_target *target = NULL; in ath6kl_htc_mbox_create() local
2845 target = kzalloc(sizeof(*target), GFP_KERNEL); in ath6kl_htc_mbox_create()
2846 if (!target) { in ath6kl_htc_mbox_create()
2851 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_mbox_create()
2852 if (!target->dev) { in ath6kl_htc_mbox_create()
2854 kfree(target); in ath6kl_htc_mbox_create()
2858 spin_lock_init(&target->htc_lock); in ath6kl_htc_mbox_create()
2859 spin_lock_init(&target->rx_lock); in ath6kl_htc_mbox_create()
2860 spin_lock_init(&target->tx_lock); in ath6kl_htc_mbox_create()
2862 INIT_LIST_HEAD(&target->free_ctrl_txbuf); in ath6kl_htc_mbox_create()
2863 INIT_LIST_HEAD(&target->free_ctrl_rxbuf); in ath6kl_htc_mbox_create()
2864 INIT_LIST_HEAD(&target->cred_dist_list); in ath6kl_htc_mbox_create()
2866 target->dev->ar = ar; in ath6kl_htc_mbox_create()
2867 target->dev->htc_cnxt = target; in ath6kl_htc_mbox_create()
2868 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_create()
2870 status = ath6kl_hif_setup(target->dev); in ath6kl_htc_mbox_create()
2874 status = ath6kl_htc_reset(target); in ath6kl_htc_mbox_create()
2878 return target; in ath6kl_htc_mbox_create()
2881 ath6kl_htc_mbox_cleanup(target); in ath6kl_htc_mbox_create()
2887 static void ath6kl_htc_mbox_cleanup(struct htc_target *target) in ath6kl_htc_mbox_cleanup() argument
2891 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_cleanup()
2894 &target->free_ctrl_txbuf, list) { in ath6kl_htc_mbox_cleanup()
2901 &target->free_ctrl_rxbuf, list) { in ath6kl_htc_mbox_cleanup()
2907 kfree(target->dev); in ath6kl_htc_mbox_cleanup()
2908 kfree(target); in ath6kl_htc_mbox_cleanup()