Lines Matching refs: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,
375 static void htc_reclaim_txctrl_buf(struct htc_target *target, in htc_reclaim_txctrl_buf() argument
378 spin_lock_bh(&target->htc_lock); in htc_reclaim_txctrl_buf()
379 list_add_tail(&pkt->list, &target->free_ctrl_txbuf); in htc_reclaim_txctrl_buf()
380 spin_unlock_bh(&target->htc_lock); in htc_reclaim_txctrl_buf()
383 static struct htc_packet *htc_get_control_buf(struct htc_target *target, in htc_get_control_buf() argument
389 buf_list = tx ? &target->free_ctrl_txbuf : &target->free_ctrl_rxbuf; in htc_get_control_buf()
391 spin_lock_bh(&target->htc_lock); in htc_get_control_buf()
394 spin_unlock_bh(&target->htc_lock); in htc_get_control_buf()
400 spin_unlock_bh(&target->htc_lock); in htc_get_control_buf()
408 static void htc_tx_comp_update(struct htc_target *target, in htc_tx_comp_update() argument
423 spin_lock_bh(&target->tx_lock); in htc_tx_comp_update()
429 target->credit_info, &target->cred_dist_list); in htc_tx_comp_update()
431 ath6kl_credit_distribute(target->credit_info, in htc_tx_comp_update()
432 &target->cred_dist_list, in htc_tx_comp_update()
435 spin_unlock_bh(&target->tx_lock); in htc_tx_comp_update()
448 ath6kl_tx_complete(endpoint->target, txq); in htc_tx_complete()
451 static void htc_tx_comp_handler(struct htc_target *target, in htc_tx_comp_handler() argument
454 struct htc_endpoint *endpoint = &target->endpoint[packet->endpoint]; in htc_tx_comp_handler()
460 htc_tx_comp_update(target, endpoint, packet); in htc_tx_comp_handler()
467 static void htc_async_tx_scat_complete(struct htc_target *target, in htc_async_tx_scat_complete() argument
485 endpoint = &target->endpoint[packet->endpoint]; in htc_async_tx_scat_complete()
496 htc_tx_comp_update(target, endpoint, packet); in htc_async_tx_scat_complete()
501 hif_scatter_req_add(target->dev->ar, scat_req); in htc_async_tx_scat_complete()
507 static int ath6kl_htc_tx_issue(struct htc_target *target, in ath6kl_htc_tx_issue() argument
519 padded_len = CALC_TXRX_PADDED_LEN(target, send_len); in ath6kl_htc_tx_issue()
524 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
528 status = hif_read_write_sync(target->dev->ar, in ath6kl_htc_tx_issue()
529 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
536 status = hif_write_async(target->dev->ar, in ath6kl_htc_tx_issue()
537 target->dev->ar->mbox_info.htc_addr, in ath6kl_htc_tx_issue()
546 static int htc_check_credits(struct htc_target *target, in htc_check_credits() argument
551 *req_cred = (len > target->tgt_cred_sz) ? in htc_check_credits()
552 DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; in htc_check_credits()
564 ath6kl_credit_seek(target->credit_info, &ep->cred_dist); in htc_check_credits()
584 ath6kl_credit_seek(target->credit_info, &ep->cred_dist); in htc_check_credits()
599 static void ath6kl_htc_tx_pkts_get(struct htc_target *target, in ath6kl_htc_tx_pkts_get() argument
620 len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_tx_pkts_get()
623 if (htc_check_credits(target, endpoint, &flags, in ath6kl_htc_tx_pkts_get()
637 packet->context = target; in ath6kl_htc_tx_pkts_get()
679 static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, in ath6kl_htc_tx_setup_scat_list() argument
690 rem_scat = target->max_tx_bndl_sz; in ath6kl_htc_tx_setup_scat_list()
699 len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_tx_setup_scat_list()
702 cred_pad = htc_get_credit_padding(target->tgt_cred_sz, in ath6kl_htc_tx_setup_scat_list()
759 struct htc_target *target = endpoint->target; in ath6kl_htc_tx_bundle() local
769 ac = target->dev->ar->ep2ac_map[endpoint->eid]; in ath6kl_htc_tx_bundle()
774 n_scat = min(n_scat, target->msg_per_bndl_max); in ath6kl_htc_tx_bundle()
780 scat_req = hif_scatter_req_get(target->dev->ar); in ath6kl_htc_tx_bundle()
810 target->tx_bndl_mask &= ~txb_mask; in ath6kl_htc_tx_bundle()
812 target->tx_bndl_mask |= txb_mask; in ath6kl_htc_tx_bundle()
821 status = ath6kl_htc_tx_setup_scat_list(target, endpoint, in ath6kl_htc_tx_bundle()
825 hif_scatter_req_add(target->dev->ar, scat_req); in ath6kl_htc_tx_bundle()
844 ath6kl_hif_submit_scat_req(target->dev, scat_req, false); in ath6kl_htc_tx_bundle()
858 static void ath6kl_htc_tx_from_queue(struct htc_target *target, in ath6kl_htc_tx_from_queue() argument
868 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
873 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
886 ac = target->dev->ar->ep2ac_map[endpoint->eid]; in ath6kl_htc_tx_from_queue()
892 ath6kl_htc_tx_pkts_get(target, endpoint, &txq); in ath6kl_htc_tx_from_queue()
897 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
904 if ((target->tx_bndl_mask) && in ath6kl_htc_tx_from_queue()
910 if (target->tx_bndl_mask & (1 << ac)) { in ath6kl_htc_tx_from_queue()
927 status = ath6kl_htc_tx_issue(target, packet); in ath6kl_htc_tx_from_queue()
935 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
946 if (!(target->tx_bndl_mask & (1 << ac)) && in ath6kl_htc_tx_from_queue()
948 if (++target->ac_tx_count[ac] >= in ath6kl_htc_tx_from_queue()
950 target->ac_tx_count[ac] = 0; in ath6kl_htc_tx_from_queue()
951 target->tx_bndl_mask |= (1 << ac); in ath6kl_htc_tx_from_queue()
957 target->ac_tx_count[ac] = 0; in ath6kl_htc_tx_from_queue()
962 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_from_queue()
965 static bool ath6kl_htc_tx_try(struct htc_target *target, in ath6kl_htc_tx_try() argument
975 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
977 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
989 if (ep_cb.tx_full(endpoint->target, tx_pkt) == in ath6kl_htc_tx_try()
996 spin_lock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
998 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_tx_try()
1000 ath6kl_htc_tx_from_queue(target, endpoint); in ath6kl_htc_tx_try()
1005 static void htc_chk_ep_txq(struct htc_target *target) in htc_chk_ep_txq() argument
1016 list_for_each_entry(cred_dist, &target->cred_dist_list, list) { in htc_chk_ep_txq()
1019 spin_lock_bh(&target->tx_lock); in htc_chk_ep_txq()
1026 spin_unlock_bh(&target->tx_lock); in htc_chk_ep_txq()
1034 ath6kl_htc_tx_from_queue(target, endpoint); in htc_chk_ep_txq()
1035 spin_lock_bh(&target->tx_lock); in htc_chk_ep_txq()
1037 spin_unlock_bh(&target->tx_lock); in htc_chk_ep_txq()
1041 static int htc_setup_tx_complete(struct htc_target *target) in htc_setup_tx_complete() argument
1046 send_pkt = htc_get_control_buf(target, true); in htc_setup_tx_complete()
1051 if (target->htc_tgt_ver >= HTC_VERSION_2P1) { in htc_setup_tx_complete()
1061 if (target->msg_per_bndl_max > 0) { in htc_setup_tx_complete()
1065 target->msg_per_bndl_max; in htc_setup_tx_complete()
1087 status = ath6kl_htc_tx_issue(target, send_pkt); in htc_setup_tx_complete()
1088 htc_reclaim_txctrl_buf(target, send_pkt); in htc_setup_tx_complete()
1093 static void ath6kl_htc_set_credit_dist(struct htc_target *target, in ath6kl_htc_set_credit_dist() argument
1100 target->credit_info = credit_info; in ath6kl_htc_set_credit_dist()
1102 list_add_tail(&target->endpoint[ENDPOINT_0].cred_dist.list, in ath6kl_htc_set_credit_dist()
1103 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1107 endpoint = &target->endpoint[ep]; in ath6kl_htc_set_credit_dist()
1110 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1121 static int ath6kl_htc_mbox_tx(struct htc_target *target, in ath6kl_htc_mbox_tx() argument
1136 endpoint = &target->endpoint[packet->endpoint]; in ath6kl_htc_mbox_tx()
1138 if (!ath6kl_htc_tx_try(target, endpoint, packet)) { in ath6kl_htc_mbox_tx()
1139 packet->status = (target->htc_flags & HTC_OP_STATE_STOPPING) ? in ath6kl_htc_mbox_tx()
1150 static void ath6kl_htc_mbox_flush_txep(struct htc_target *target, in ath6kl_htc_mbox_flush_txep() argument
1155 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_flush_txep()
1165 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1173 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1189 static void ath6kl_htc_flush_txep_all(struct htc_target *target) in ath6kl_htc_flush_txep_all() argument
1194 dump_cred_dist_stats(target); in ath6kl_htc_flush_txep_all()
1197 endpoint = &target->endpoint[i]; in ath6kl_htc_flush_txep_all()
1201 ath6kl_htc_mbox_flush_txep(target, i, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_flush_txep_all()
1205 static void ath6kl_htc_mbox_activity_changed(struct htc_target *target, in ath6kl_htc_mbox_activity_changed() argument
1209 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_activity_changed()
1217 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1237 target->credit_info, &target->cred_dist_list); in ath6kl_htc_mbox_activity_changed()
1239 ath6kl_credit_distribute(target->credit_info, in ath6kl_htc_mbox_activity_changed()
1240 &target->cred_dist_list, in ath6kl_htc_mbox_activity_changed()
1244 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1247 htc_chk_ep_txq(target); in ath6kl_htc_mbox_activity_changed()
1262 static inline bool htc_valid_rx_frame_len(struct htc_target *target, in htc_valid_rx_frame_len() argument
1265 return (eid == target->dev->ar->ctrl_ep) ? in htc_valid_rx_frame_len()
1269 static int htc_add_rxbuf(struct htc_target *target, struct htc_packet *packet) in htc_add_rxbuf() argument
1275 return ath6kl_htc_mbox_add_rxbuf_multiple(target, &queue); in htc_add_rxbuf()
1278 static void htc_reclaim_rxbuf(struct htc_target *target, in htc_reclaim_rxbuf() argument
1285 ep->ep_cb.rx(ep->target, packet); in htc_reclaim_rxbuf()
1288 htc_add_rxbuf((void *)(target), packet); in htc_reclaim_rxbuf()
1292 static void reclaim_rx_ctrl_buf(struct htc_target *target, in reclaim_rx_ctrl_buf() argument
1295 spin_lock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1296 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in reclaim_rx_ctrl_buf()
1297 spin_unlock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1300 static int ath6kl_htc_rx_packet(struct htc_target *target, in ath6kl_htc_rx_packet() argument
1304 struct ath6kl_device *dev = target->dev; in ath6kl_htc_rx_packet()
1308 padded_len = CALC_TXRX_PADDED_LEN(target, rx_len); in ath6kl_htc_rx_packet()
1354 spin_lock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1357 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1358 ep_cb.rx_refill(endpoint->target, endpoint->eid); in ath6kl_htc_rx_chk_water_mark()
1361 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1366 static int ath6kl_htc_rx_setup(struct htc_target *target, in ath6kl_htc_rx_setup() argument
1377 full_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_setup()
1381 if (!htc_valid_rx_frame_len(target, ep->eid, full_len)) { in ath6kl_htc_rx_setup()
1403 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1406 packet = ep_cb.rx_allocthresh(ep->target, ep->eid, in ath6kl_htc_rx_setup()
1408 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1413 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1414 ep_cb.rx_refill(ep->target, ep->eid); in ath6kl_htc_rx_setup()
1415 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1429 target->rx_st_flags |= HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_rx_setup()
1430 target->ep_waiting = ep->eid; in ath6kl_htc_rx_setup()
1450 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rx_setup()
1469 static int ath6kl_htc_rx_alloc(struct htc_target *target, in ath6kl_htc_rx_alloc() argument
1479 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1523 if (n_msg > target->msg_per_bndl_max) { in ath6kl_htc_rx_alloc()
1537 status = ath6kl_htc_rx_setup(target, endpoint, &lk_ahds[i], in ath6kl_htc_rx_alloc()
1546 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1554 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1559 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_alloc()
1560 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_alloc()
1592 static void htc_proc_cred_rpt(struct htc_target *target, in htc_proc_cred_rpt() argument
1601 spin_lock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1606 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1610 endpoint = &target->endpoint[rpt->eid]; in htc_proc_cred_rpt()
1659 ath6kl_credit_distribute(target->credit_info, in htc_proc_cred_rpt()
1660 &target->cred_dist_list, in htc_proc_cred_rpt()
1664 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1667 htc_chk_ep_txq(target); in htc_proc_cred_rpt()
1670 static int htc_parse_trailer(struct htc_target *target, in htc_parse_trailer() argument
1688 htc_proc_cred_rpt(target, in htc_parse_trailer()
1750 static int htc_proc_trailer(struct htc_target *target, in htc_proc_trailer() argument
1785 status = htc_parse_trailer(target, record, record_buf, in htc_proc_trailer()
1803 static int ath6kl_htc_rx_process_hdr(struct htc_target *target, in ath6kl_htc_rx_process_hdr() argument
1878 status = htc_proc_trailer(target, packet->buf + HTC_HDR_LENGTH in ath6kl_htc_rx_process_hdr()
1907 endpoint->ep_cb.rx(endpoint->target, packet); in ath6kl_htc_rx_complete()
1910 static int ath6kl_htc_rx_bundle(struct htc_target *target, in ath6kl_htc_rx_bundle() argument
1917 int rem_space = target->max_rx_bndl_sz; in ath6kl_htc_rx_bundle()
1921 n_scat_pkt = min(n_scat_pkt, target->msg_per_bndl_max); in ath6kl_htc_rx_bundle()
1945 scat_req = hif_scatter_req_get(target->dev->ar); in ath6kl_htc_rx_bundle()
1956 pad_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_bundle()
1990 status = ath6kl_hif_submit_scat_req(target->dev, scat_req, true); in ath6kl_htc_rx_bundle()
1996 hif_scatter_req_add(target->dev->ar, scat_req); in ath6kl_htc_rx_bundle()
2003 static int ath6kl_htc_rx_process_packets(struct htc_target *target, in ath6kl_htc_rx_process_packets() argument
2013 ep = &target->endpoint[packet->endpoint]; in ath6kl_htc_rx_process_packets()
2019 status = ath6kl_htc_rx_process_hdr(target, packet, lk_ahds, in ath6kl_htc_rx_process_packets()
2053 static int ath6kl_htc_rx_fetch(struct htc_target *target, in ath6kl_htc_rx_fetch() argument
2069 if (target->rx_bndl_enable && (get_queue_depth(rx_pktq) > 1)) { in ath6kl_htc_rx_fetch()
2075 status = ath6kl_htc_rx_bundle(target, rx_pktq, in ath6kl_htc_rx_fetch()
2105 status = ath6kl_htc_rx_packet(target, packet, in ath6kl_htc_rx_fetch()
2128 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2129 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2134 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2135 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2141 int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, in ath6kl_htc_rxmsg_pending_handler() argument
2168 endpoint = &target->endpoint[id]; in ath6kl_htc_rxmsg_pending_handler()
2184 status = ath6kl_htc_rx_alloc(target, look_aheads, in ath6kl_htc_rxmsg_pending_handler()
2195 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2201 status = ath6kl_htc_rx_fetch(target, &rx_pktq, &comp_pktq); in ath6kl_htc_rxmsg_pending_handler()
2207 status = ath6kl_htc_rx_process_packets(target, &comp_pktq, in ath6kl_htc_rxmsg_pending_handler()
2221 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2232 htc_reclaim_rxbuf(target, packets, in ath6kl_htc_rxmsg_pending_handler()
2233 &target->endpoint[packets->endpoint]); in ath6kl_htc_rxmsg_pending_handler()
2236 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rxmsg_pending_handler()
2238 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2246 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_rxmsg_pending_handler()
2248 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2260 static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) in htc_wait_for_ctrl_msg() argument
2266 if (ath6kl_hif_poll_mboxmsg_rx(target->dev, &look_ahead, in htc_wait_for_ctrl_msg()
2278 packet = htc_get_control_buf(target, false); in htc_wait_for_ctrl_msg()
2294 if (ath6kl_htc_rx_packet(target, packet, packet->act_len)) in htc_wait_for_ctrl_msg()
2301 packet->status = ath6kl_htc_rx_process_hdr(target, packet, NULL, NULL); in htc_wait_for_ctrl_msg()
2314 reclaim_rx_ctrl_buf(target, packet); in htc_wait_for_ctrl_msg()
2320 static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_mbox_add_rxbuf_multiple() argument
2342 endpoint = &target->endpoint[first_pkt->endpoint]; in ath6kl_htc_mbox_add_rxbuf_multiple()
2344 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2357 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2362 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2363 if (target->ep_waiting == first_pkt->endpoint) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2366 target->ep_waiting); in ath6kl_htc_mbox_add_rxbuf_multiple()
2367 target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_mbox_add_rxbuf_multiple()
2368 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_add_rxbuf_multiple()
2373 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2375 if (rx_unblock && !(target->htc_flags & HTC_OP_STATE_STOPPING)) in ath6kl_htc_mbox_add_rxbuf_multiple()
2377 ath6kl_hif_rx_control(target->dev, true); in ath6kl_htc_mbox_add_rxbuf_multiple()
2382 static void ath6kl_htc_mbox_flush_rx_buf(struct htc_target *target) in ath6kl_htc_mbox_flush_rx_buf() argument
2389 endpoint = &target->endpoint[i]; in ath6kl_htc_mbox_flush_rx_buf()
2394 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2398 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2418 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2420 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2424 static int ath6kl_htc_mbox_conn_service(struct htc_target *target, in ath6kl_htc_mbox_conn_service() argument
2440 target, conn_req->svc_id); in ath6kl_htc_mbox_conn_service()
2448 tx_pkt = htc_get_control_buf(target, true); in ath6kl_htc_mbox_conn_service()
2466 status = ath6kl_htc_tx_issue(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2472 rx_pkt = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_conn_service()
2507 endpoint = &target->endpoint[assigned_ep]; in ath6kl_htc_mbox_conn_service()
2529 endpoint->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2551 conn_req->max_rxmsg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2554 max_msg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2564 htc_reclaim_txctrl_buf(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2568 reclaim_rx_ctrl_buf(target, rx_pkt); in ath6kl_htc_mbox_conn_service()
2574 static void reset_ep_state(struct htc_target *target) in reset_ep_state() argument
2580 endpoint = &target->endpoint[i]; in reset_ep_state()
2589 endpoint->target = target; in reset_ep_state()
2594 INIT_LIST_HEAD(&target->cred_dist_list); in reset_ep_state()
2597 static int ath6kl_htc_mbox_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_mbox_get_rxbuf_num() argument
2602 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2603 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_mbox_get_rxbuf_num()
2604 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2608 static void htc_setup_msg_bndl(struct htc_target *target) in htc_setup_msg_bndl() argument
2611 target->msg_per_bndl_max = min(HTC_HOST_MAX_MSG_PER_BUNDLE, in htc_setup_msg_bndl()
2612 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2614 if (ath6kl_hif_enable_scatter(target->dev->ar)) { in htc_setup_msg_bndl()
2615 target->msg_per_bndl_max = 0; in htc_setup_msg_bndl()
2620 target->msg_per_bndl_max = min(target->max_scat_entries, in htc_setup_msg_bndl()
2621 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2625 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2628 target->max_rx_bndl_sz = target->max_xfer_szper_scatreq; in htc_setup_msg_bndl()
2630 target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, in htc_setup_msg_bndl()
2631 target->max_xfer_szper_scatreq); in htc_setup_msg_bndl()
2634 target->max_rx_bndl_sz, target->max_tx_bndl_sz); in htc_setup_msg_bndl()
2636 if (target->max_tx_bndl_sz) in htc_setup_msg_bndl()
2638 target->tx_bndl_mask = (1 << WMM_NUM_AC) - 1; in htc_setup_msg_bndl()
2640 if (target->max_rx_bndl_sz) in htc_setup_msg_bndl()
2641 target->rx_bndl_enable = true; in htc_setup_msg_bndl()
2643 if ((target->tgt_cred_sz % target->block_sz) != 0) { in htc_setup_msg_bndl()
2645 target->tgt_cred_sz); in htc_setup_msg_bndl()
2653 target->tx_bndl_mask = 0; in htc_setup_msg_bndl()
2657 static int ath6kl_htc_mbox_wait_target(struct htc_target *target) in ath6kl_htc_mbox_wait_target() argument
2666 packet = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_wait_target()
2685 target->tgt_creds = le16_to_cpu(rdy_msg->ver2_0_info.cred_cnt); in ath6kl_htc_mbox_wait_target()
2686 target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); in ath6kl_htc_mbox_wait_target()
2690 target->tgt_creds, target->tgt_cred_sz); in ath6kl_htc_mbox_wait_target()
2695 target->htc_tgt_ver = rdy_msg->htc_ver; in ath6kl_htc_mbox_wait_target()
2696 target->msg_per_bndl_max = rdy_msg->msg_per_htc_bndl; in ath6kl_htc_mbox_wait_target()
2699 target->htc_tgt_ver = HTC_VERSION_2P0; in ath6kl_htc_mbox_wait_target()
2700 target->msg_per_bndl_max = 0; in ath6kl_htc_mbox_wait_target()
2704 (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", in ath6kl_htc_mbox_wait_target()
2705 target->htc_tgt_ver); in ath6kl_htc_mbox_wait_target()
2707 if (target->msg_per_bndl_max > 0) in ath6kl_htc_mbox_wait_target()
2708 htc_setup_msg_bndl(target); in ath6kl_htc_mbox_wait_target()
2720 status = ath6kl_htc_mbox_conn_service((void *)target, &connect, &resp); in ath6kl_htc_mbox_wait_target()
2727 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_wait_target()
2732 reclaim_rx_ctrl_buf(target, packet); in ath6kl_htc_mbox_wait_target()
2742 static int ath6kl_htc_mbox_start(struct htc_target *target) in ath6kl_htc_mbox_start() argument
2747 memset(&target->dev->irq_proc_reg, 0, in ath6kl_htc_mbox_start()
2748 sizeof(target->dev->irq_proc_reg)); in ath6kl_htc_mbox_start()
2751 ath6kl_hif_disable_intrs(target->dev); in ath6kl_htc_mbox_start()
2753 target->htc_flags = 0; in ath6kl_htc_mbox_start()
2754 target->rx_st_flags = 0; in ath6kl_htc_mbox_start()
2757 while ((packet = htc_get_control_buf(target, false)) != NULL) { in ath6kl_htc_mbox_start()
2758 status = htc_add_rxbuf(target, packet); in ath6kl_htc_mbox_start()
2764 ath6kl_credit_init(target->credit_info, &target->cred_dist_list, in ath6kl_htc_mbox_start()
2765 target->tgt_creds); in ath6kl_htc_mbox_start()
2767 dump_cred_dist_stats(target); in ath6kl_htc_mbox_start()
2770 status = htc_setup_tx_complete(target); in ath6kl_htc_mbox_start()
2776 status = ath6kl_hif_unmask_intrs(target->dev); in ath6kl_htc_mbox_start()
2779 ath6kl_htc_mbox_stop(target); in ath6kl_htc_mbox_start()
2784 static int ath6kl_htc_reset(struct htc_target *target) in ath6kl_htc_reset() argument
2790 reset_ep_state(target); in ath6kl_htc_reset()
2792 block_size = target->dev->ar->mbox_info.block_size; in ath6kl_htc_reset()
2814 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in ath6kl_htc_reset()
2816 list_add_tail(&packet->list, &target->free_ctrl_txbuf); in ath6kl_htc_reset()
2824 static void ath6kl_htc_mbox_stop(struct htc_target *target) in ath6kl_htc_mbox_stop() argument
2826 spin_lock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2827 target->htc_flags |= HTC_OP_STATE_STOPPING; in ath6kl_htc_mbox_stop()
2828 spin_unlock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2835 ath6kl_hif_mask_intrs(target->dev); in ath6kl_htc_mbox_stop()
2837 ath6kl_htc_flush_txep_all(target); in ath6kl_htc_mbox_stop()
2839 ath6kl_htc_mbox_flush_rx_buf(target); in ath6kl_htc_mbox_stop()
2841 ath6kl_htc_reset(target); in ath6kl_htc_mbox_stop()
2846 struct htc_target *target = NULL; in ath6kl_htc_mbox_create() local
2849 target = kzalloc(sizeof(*target), GFP_KERNEL); in ath6kl_htc_mbox_create()
2850 if (!target) { in ath6kl_htc_mbox_create()
2855 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_mbox_create()
2856 if (!target->dev) { in ath6kl_htc_mbox_create()
2858 kfree(target); in ath6kl_htc_mbox_create()
2862 spin_lock_init(&target->htc_lock); in ath6kl_htc_mbox_create()
2863 spin_lock_init(&target->rx_lock); in ath6kl_htc_mbox_create()
2864 spin_lock_init(&target->tx_lock); in ath6kl_htc_mbox_create()
2866 INIT_LIST_HEAD(&target->free_ctrl_txbuf); in ath6kl_htc_mbox_create()
2867 INIT_LIST_HEAD(&target->free_ctrl_rxbuf); in ath6kl_htc_mbox_create()
2868 INIT_LIST_HEAD(&target->cred_dist_list); in ath6kl_htc_mbox_create()
2870 target->dev->ar = ar; in ath6kl_htc_mbox_create()
2871 target->dev->htc_cnxt = target; in ath6kl_htc_mbox_create()
2872 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_create()
2874 status = ath6kl_hif_setup(target->dev); in ath6kl_htc_mbox_create()
2878 status = ath6kl_htc_reset(target); in ath6kl_htc_mbox_create()
2882 return target; in ath6kl_htc_mbox_create()
2885 ath6kl_htc_mbox_cleanup(target); in ath6kl_htc_mbox_create()
2891 static void ath6kl_htc_mbox_cleanup(struct htc_target *target) in ath6kl_htc_mbox_cleanup() argument
2895 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_cleanup()
2898 &target->free_ctrl_txbuf, list) { in ath6kl_htc_mbox_cleanup()
2905 &target->free_ctrl_rxbuf, list) { in ath6kl_htc_mbox_cleanup()
2911 kfree(target->dev); in ath6kl_htc_mbox_cleanup()
2912 kfree(target); in ath6kl_htc_mbox_cleanup()