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()
1090 htc_reclaim_txctrl_buf(target, send_pkt); in htc_setup_tx_complete()
1095 static void ath6kl_htc_set_credit_dist(struct htc_target *target, in ath6kl_htc_set_credit_dist() argument
1102 target->credit_info = credit_info; in ath6kl_htc_set_credit_dist()
1104 list_add_tail(&target->endpoint[ENDPOINT_0].cred_dist.list, in ath6kl_htc_set_credit_dist()
1105 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1109 endpoint = &target->endpoint[ep]; in ath6kl_htc_set_credit_dist()
1112 &target->cred_dist_list); in ath6kl_htc_set_credit_dist()
1123 static int ath6kl_htc_mbox_tx(struct htc_target *target, in ath6kl_htc_mbox_tx() argument
1138 endpoint = &target->endpoint[packet->endpoint]; in ath6kl_htc_mbox_tx()
1140 if (!ath6kl_htc_tx_try(target, endpoint, packet)) { in ath6kl_htc_mbox_tx()
1141 packet->status = (target->htc_flags & HTC_OP_STATE_STOPPING) ? in ath6kl_htc_mbox_tx()
1152 static void ath6kl_htc_mbox_flush_txep(struct htc_target *target, in ath6kl_htc_mbox_flush_txep() argument
1157 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_flush_txep()
1167 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1175 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_flush_txep()
1191 static void ath6kl_htc_flush_txep_all(struct htc_target *target) in ath6kl_htc_flush_txep_all() argument
1196 dump_cred_dist_stats(target); in ath6kl_htc_flush_txep_all()
1199 endpoint = &target->endpoint[i]; in ath6kl_htc_flush_txep_all()
1203 ath6kl_htc_mbox_flush_txep(target, i, HTC_TX_PACKET_TAG_ALL); in ath6kl_htc_flush_txep_all()
1207 static void ath6kl_htc_mbox_activity_changed(struct htc_target *target, in ath6kl_htc_mbox_activity_changed() argument
1211 struct htc_endpoint *endpoint = &target->endpoint[eid]; in ath6kl_htc_mbox_activity_changed()
1219 spin_lock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1239 target->credit_info, &target->cred_dist_list); in ath6kl_htc_mbox_activity_changed()
1241 ath6kl_credit_distribute(target->credit_info, in ath6kl_htc_mbox_activity_changed()
1242 &target->cred_dist_list, in ath6kl_htc_mbox_activity_changed()
1246 spin_unlock_bh(&target->tx_lock); in ath6kl_htc_mbox_activity_changed()
1249 htc_chk_ep_txq(target); in ath6kl_htc_mbox_activity_changed()
1264 static inline bool htc_valid_rx_frame_len(struct htc_target *target, in htc_valid_rx_frame_len() argument
1267 return (eid == target->dev->ar->ctrl_ep) ? in htc_valid_rx_frame_len()
1271 static int htc_add_rxbuf(struct htc_target *target, struct htc_packet *packet) in htc_add_rxbuf() argument
1277 return ath6kl_htc_mbox_add_rxbuf_multiple(target, &queue); in htc_add_rxbuf()
1280 static void htc_reclaim_rxbuf(struct htc_target *target, in htc_reclaim_rxbuf() argument
1287 ep->ep_cb.rx(ep->target, packet); in htc_reclaim_rxbuf()
1290 htc_add_rxbuf((void *)(target), packet); in htc_reclaim_rxbuf()
1294 static void reclaim_rx_ctrl_buf(struct htc_target *target, in reclaim_rx_ctrl_buf() argument
1297 spin_lock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1298 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in reclaim_rx_ctrl_buf()
1299 spin_unlock_bh(&target->htc_lock); in reclaim_rx_ctrl_buf()
1302 static int ath6kl_htc_rx_packet(struct htc_target *target, in ath6kl_htc_rx_packet() argument
1306 struct ath6kl_device *dev = target->dev; in ath6kl_htc_rx_packet()
1310 padded_len = CALC_TXRX_PADDED_LEN(target, rx_len); in ath6kl_htc_rx_packet()
1356 spin_lock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1359 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1360 ep_cb.rx_refill(endpoint->target, endpoint->eid); in ath6kl_htc_rx_chk_water_mark()
1363 spin_unlock_bh(&endpoint->target->rx_lock); in ath6kl_htc_rx_chk_water_mark()
1368 static int ath6kl_htc_rx_setup(struct htc_target *target, in ath6kl_htc_rx_setup() argument
1379 full_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_setup()
1383 if (!htc_valid_rx_frame_len(target, ep->eid, full_len)) { in ath6kl_htc_rx_setup()
1405 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1408 packet = ep_cb.rx_allocthresh(ep->target, ep->eid, in ath6kl_htc_rx_setup()
1410 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1415 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1416 ep_cb.rx_refill(ep->target, ep->eid); in ath6kl_htc_rx_setup()
1417 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_setup()
1431 target->rx_st_flags |= HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_rx_setup()
1432 target->ep_waiting = ep->eid; in ath6kl_htc_rx_setup()
1452 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rx_setup()
1471 static int ath6kl_htc_rx_alloc(struct htc_target *target, in ath6kl_htc_rx_alloc() argument
1481 spin_lock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1525 if (n_msg > target->msg_per_bndl_max) { in ath6kl_htc_rx_alloc()
1539 status = ath6kl_htc_rx_setup(target, endpoint, &lk_ahds[i], in ath6kl_htc_rx_alloc()
1548 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1556 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_rx_alloc()
1561 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_alloc()
1562 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_alloc()
1594 static void htc_proc_cred_rpt(struct htc_target *target, in htc_proc_cred_rpt() argument
1603 spin_lock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1608 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1612 endpoint = &target->endpoint[rpt->eid]; in htc_proc_cred_rpt()
1661 ath6kl_credit_distribute(target->credit_info, in htc_proc_cred_rpt()
1662 &target->cred_dist_list, in htc_proc_cred_rpt()
1666 spin_unlock_bh(&target->tx_lock); in htc_proc_cred_rpt()
1669 htc_chk_ep_txq(target); in htc_proc_cred_rpt()
1672 static int htc_parse_trailer(struct htc_target *target, in htc_parse_trailer() argument
1690 htc_proc_cred_rpt(target, in htc_parse_trailer()
1752 static int htc_proc_trailer(struct htc_target *target, in htc_proc_trailer() argument
1787 status = htc_parse_trailer(target, record, record_buf, in htc_proc_trailer()
1805 static int ath6kl_htc_rx_process_hdr(struct htc_target *target, in ath6kl_htc_rx_process_hdr() argument
1880 status = htc_proc_trailer(target, packet->buf + HTC_HDR_LENGTH in ath6kl_htc_rx_process_hdr()
1909 endpoint->ep_cb.rx(endpoint->target, packet); in ath6kl_htc_rx_complete()
1912 static int ath6kl_htc_rx_bundle(struct htc_target *target, in ath6kl_htc_rx_bundle() argument
1919 int rem_space = target->max_rx_bndl_sz; in ath6kl_htc_rx_bundle()
1923 n_scat_pkt = min(n_scat_pkt, target->msg_per_bndl_max); in ath6kl_htc_rx_bundle()
1947 scat_req = hif_scatter_req_get(target->dev->ar); in ath6kl_htc_rx_bundle()
1958 pad_len = CALC_TXRX_PADDED_LEN(target, in ath6kl_htc_rx_bundle()
1992 status = ath6kl_hif_submit_scat_req(target->dev, scat_req, true); in ath6kl_htc_rx_bundle()
1998 hif_scatter_req_add(target->dev->ar, scat_req); in ath6kl_htc_rx_bundle()
2005 static int ath6kl_htc_rx_process_packets(struct htc_target *target, in ath6kl_htc_rx_process_packets() argument
2015 ep = &target->endpoint[packet->endpoint]; in ath6kl_htc_rx_process_packets()
2021 status = ath6kl_htc_rx_process_hdr(target, packet, lk_ahds, in ath6kl_htc_rx_process_packets()
2055 static int ath6kl_htc_rx_fetch(struct htc_target *target, in ath6kl_htc_rx_fetch() argument
2071 if (target->rx_bndl_enable && (get_queue_depth(rx_pktq) > 1)) { in ath6kl_htc_rx_fetch()
2077 status = ath6kl_htc_rx_bundle(target, rx_pktq, in ath6kl_htc_rx_fetch()
2107 status = ath6kl_htc_rx_packet(target, packet, in ath6kl_htc_rx_fetch()
2130 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2131 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2136 htc_reclaim_rxbuf(target, packet, in ath6kl_htc_rx_fetch()
2137 &target->endpoint[packet->endpoint]); in ath6kl_htc_rx_fetch()
2143 int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, in ath6kl_htc_rxmsg_pending_handler() argument
2170 endpoint = &target->endpoint[id]; in ath6kl_htc_rxmsg_pending_handler()
2186 status = ath6kl_htc_rx_alloc(target, look_aheads, in ath6kl_htc_rxmsg_pending_handler()
2197 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2203 status = ath6kl_htc_rx_fetch(target, &rx_pktq, &comp_pktq); in ath6kl_htc_rxmsg_pending_handler()
2209 status = ath6kl_htc_rx_process_packets(target, &comp_pktq, in ath6kl_htc_rxmsg_pending_handler()
2223 target->chk_irq_status_cnt = 1; in ath6kl_htc_rxmsg_pending_handler()
2233 htc_reclaim_rxbuf(target, packets, in ath6kl_htc_rxmsg_pending_handler()
2234 &target->endpoint[packets->endpoint]); in ath6kl_htc_rxmsg_pending_handler()
2237 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_rxmsg_pending_handler()
2239 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2247 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_rxmsg_pending_handler()
2249 ath6kl_hif_rx_control(target->dev, false); in ath6kl_htc_rxmsg_pending_handler()
2261 static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) in htc_wait_for_ctrl_msg() argument
2267 if (ath6kl_hif_poll_mboxmsg_rx(target->dev, &look_ahead, in htc_wait_for_ctrl_msg()
2279 packet = htc_get_control_buf(target, false); in htc_wait_for_ctrl_msg()
2295 if (ath6kl_htc_rx_packet(target, packet, packet->act_len)) in htc_wait_for_ctrl_msg()
2302 packet->status = ath6kl_htc_rx_process_hdr(target, packet, NULL, NULL); in htc_wait_for_ctrl_msg()
2315 reclaim_rx_ctrl_buf(target, packet); in htc_wait_for_ctrl_msg()
2321 static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target, in ath6kl_htc_mbox_add_rxbuf_multiple() argument
2343 endpoint = &target->endpoint[first_pkt->endpoint]; in ath6kl_htc_mbox_add_rxbuf_multiple()
2345 if (target->htc_flags & HTC_OP_STATE_STOPPING) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2358 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2363 if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2364 if (target->ep_waiting == first_pkt->endpoint) { in ath6kl_htc_mbox_add_rxbuf_multiple()
2367 target->ep_waiting); in ath6kl_htc_mbox_add_rxbuf_multiple()
2368 target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; in ath6kl_htc_mbox_add_rxbuf_multiple()
2369 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_add_rxbuf_multiple()
2374 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_add_rxbuf_multiple()
2376 if (rx_unblock && !(target->htc_flags & HTC_OP_STATE_STOPPING)) in ath6kl_htc_mbox_add_rxbuf_multiple()
2378 ath6kl_hif_rx_control(target->dev, true); in ath6kl_htc_mbox_add_rxbuf_multiple()
2383 static void ath6kl_htc_mbox_flush_rx_buf(struct htc_target *target) in ath6kl_htc_mbox_flush_rx_buf() argument
2390 endpoint = &target->endpoint[i]; in ath6kl_htc_mbox_flush_rx_buf()
2395 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2399 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2419 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2421 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_flush_rx_buf()
2425 static int ath6kl_htc_mbox_conn_service(struct htc_target *target, in ath6kl_htc_mbox_conn_service() argument
2441 target, conn_req->svc_id); in ath6kl_htc_mbox_conn_service()
2449 tx_pkt = htc_get_control_buf(target, true); in ath6kl_htc_mbox_conn_service()
2467 status = ath6kl_htc_tx_issue(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2473 rx_pkt = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_conn_service()
2508 endpoint = &target->endpoint[assigned_ep]; in ath6kl_htc_mbox_conn_service()
2530 endpoint->cred_dist.cred_sz = target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2552 conn_req->max_rxmsg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2555 max_msg_sz / target->tgt_cred_sz; in ath6kl_htc_mbox_conn_service()
2565 htc_reclaim_txctrl_buf(target, tx_pkt); in ath6kl_htc_mbox_conn_service()
2569 reclaim_rx_ctrl_buf(target, rx_pkt); in ath6kl_htc_mbox_conn_service()
2575 static void reset_ep_state(struct htc_target *target) in reset_ep_state() argument
2581 endpoint = &target->endpoint[i]; in reset_ep_state()
2590 endpoint->target = target; in reset_ep_state()
2595 INIT_LIST_HEAD(&target->cred_dist_list); in reset_ep_state()
2598 static int ath6kl_htc_mbox_get_rxbuf_num(struct htc_target *target, in ath6kl_htc_mbox_get_rxbuf_num() argument
2603 spin_lock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2604 num = get_queue_depth(&(target->endpoint[endpoint].rx_bufq)); in ath6kl_htc_mbox_get_rxbuf_num()
2605 spin_unlock_bh(&target->rx_lock); in ath6kl_htc_mbox_get_rxbuf_num()
2609 static void htc_setup_msg_bndl(struct htc_target *target) in htc_setup_msg_bndl() argument
2612 target->msg_per_bndl_max = min(HTC_HOST_MAX_MSG_PER_BUNDLE, in htc_setup_msg_bndl()
2613 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2615 if (ath6kl_hif_enable_scatter(target->dev->ar)) { in htc_setup_msg_bndl()
2616 target->msg_per_bndl_max = 0; in htc_setup_msg_bndl()
2621 target->msg_per_bndl_max = min(target->max_scat_entries, in htc_setup_msg_bndl()
2622 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2626 target->msg_per_bndl_max); in htc_setup_msg_bndl()
2629 target->max_rx_bndl_sz = target->max_xfer_szper_scatreq; in htc_setup_msg_bndl()
2631 target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, in htc_setup_msg_bndl()
2632 target->max_xfer_szper_scatreq); in htc_setup_msg_bndl()
2635 target->max_rx_bndl_sz, target->max_tx_bndl_sz); in htc_setup_msg_bndl()
2637 if (target->max_tx_bndl_sz) in htc_setup_msg_bndl()
2639 target->tx_bndl_mask = (1 << WMM_NUM_AC) - 1; in htc_setup_msg_bndl()
2641 if (target->max_rx_bndl_sz) in htc_setup_msg_bndl()
2642 target->rx_bndl_enable = true; in htc_setup_msg_bndl()
2644 if ((target->tgt_cred_sz % target->block_sz) != 0) { in htc_setup_msg_bndl()
2646 target->tgt_cred_sz); in htc_setup_msg_bndl()
2654 target->tx_bndl_mask = 0; in htc_setup_msg_bndl()
2658 static int ath6kl_htc_mbox_wait_target(struct htc_target *target) in ath6kl_htc_mbox_wait_target() argument
2667 packet = htc_wait_for_ctrl_msg(target); in ath6kl_htc_mbox_wait_target()
2686 target->tgt_creds = le16_to_cpu(rdy_msg->ver2_0_info.cred_cnt); in ath6kl_htc_mbox_wait_target()
2687 target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); in ath6kl_htc_mbox_wait_target()
2691 target->tgt_creds, target->tgt_cred_sz); in ath6kl_htc_mbox_wait_target()
2696 target->htc_tgt_ver = rdy_msg->htc_ver; in ath6kl_htc_mbox_wait_target()
2697 target->msg_per_bndl_max = rdy_msg->msg_per_htc_bndl; in ath6kl_htc_mbox_wait_target()
2700 target->htc_tgt_ver = HTC_VERSION_2P0; in ath6kl_htc_mbox_wait_target()
2701 target->msg_per_bndl_max = 0; in ath6kl_htc_mbox_wait_target()
2705 (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", in ath6kl_htc_mbox_wait_target()
2706 target->htc_tgt_ver); in ath6kl_htc_mbox_wait_target()
2708 if (target->msg_per_bndl_max > 0) in ath6kl_htc_mbox_wait_target()
2709 htc_setup_msg_bndl(target); in ath6kl_htc_mbox_wait_target()
2721 status = ath6kl_htc_mbox_conn_service((void *)target, &connect, &resp); in ath6kl_htc_mbox_wait_target()
2728 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_wait_target()
2733 reclaim_rx_ctrl_buf(target, packet); in ath6kl_htc_mbox_wait_target()
2743 static int ath6kl_htc_mbox_start(struct htc_target *target) in ath6kl_htc_mbox_start() argument
2748 memset(&target->dev->irq_proc_reg, 0, in ath6kl_htc_mbox_start()
2749 sizeof(target->dev->irq_proc_reg)); in ath6kl_htc_mbox_start()
2752 ath6kl_hif_disable_intrs(target->dev); in ath6kl_htc_mbox_start()
2754 target->htc_flags = 0; in ath6kl_htc_mbox_start()
2755 target->rx_st_flags = 0; in ath6kl_htc_mbox_start()
2758 while ((packet = htc_get_control_buf(target, false)) != NULL) { in ath6kl_htc_mbox_start()
2759 status = htc_add_rxbuf(target, packet); in ath6kl_htc_mbox_start()
2765 ath6kl_credit_init(target->credit_info, &target->cred_dist_list, in ath6kl_htc_mbox_start()
2766 target->tgt_creds); in ath6kl_htc_mbox_start()
2768 dump_cred_dist_stats(target); in ath6kl_htc_mbox_start()
2771 status = htc_setup_tx_complete(target); in ath6kl_htc_mbox_start()
2777 status = ath6kl_hif_unmask_intrs(target->dev); in ath6kl_htc_mbox_start()
2780 ath6kl_htc_mbox_stop(target); in ath6kl_htc_mbox_start()
2785 static int ath6kl_htc_reset(struct htc_target *target) in ath6kl_htc_reset() argument
2791 reset_ep_state(target); in ath6kl_htc_reset()
2793 block_size = target->dev->ar->mbox_info.block_size; in ath6kl_htc_reset()
2815 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); in ath6kl_htc_reset()
2817 list_add_tail(&packet->list, &target->free_ctrl_txbuf); in ath6kl_htc_reset()
2825 static void ath6kl_htc_mbox_stop(struct htc_target *target) in ath6kl_htc_mbox_stop() argument
2827 spin_lock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2828 target->htc_flags |= HTC_OP_STATE_STOPPING; in ath6kl_htc_mbox_stop()
2829 spin_unlock_bh(&target->htc_lock); in ath6kl_htc_mbox_stop()
2836 ath6kl_hif_mask_intrs(target->dev); in ath6kl_htc_mbox_stop()
2838 ath6kl_htc_flush_txep_all(target); in ath6kl_htc_mbox_stop()
2840 ath6kl_htc_mbox_flush_rx_buf(target); in ath6kl_htc_mbox_stop()
2842 ath6kl_htc_reset(target); in ath6kl_htc_mbox_stop()
2847 struct htc_target *target = NULL; in ath6kl_htc_mbox_create() local
2850 target = kzalloc(sizeof(*target), GFP_KERNEL); in ath6kl_htc_mbox_create()
2851 if (!target) { in ath6kl_htc_mbox_create()
2856 target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL); in ath6kl_htc_mbox_create()
2857 if (!target->dev) { in ath6kl_htc_mbox_create()
2863 spin_lock_init(&target->htc_lock); in ath6kl_htc_mbox_create()
2864 spin_lock_init(&target->rx_lock); in ath6kl_htc_mbox_create()
2865 spin_lock_init(&target->tx_lock); in ath6kl_htc_mbox_create()
2867 INIT_LIST_HEAD(&target->free_ctrl_txbuf); in ath6kl_htc_mbox_create()
2868 INIT_LIST_HEAD(&target->free_ctrl_rxbuf); in ath6kl_htc_mbox_create()
2869 INIT_LIST_HEAD(&target->cred_dist_list); in ath6kl_htc_mbox_create()
2871 target->dev->ar = ar; in ath6kl_htc_mbox_create()
2872 target->dev->htc_cnxt = target; in ath6kl_htc_mbox_create()
2873 target->ep_waiting = ENDPOINT_MAX; in ath6kl_htc_mbox_create()
2875 status = ath6kl_hif_setup(target->dev); in ath6kl_htc_mbox_create()
2879 status = ath6kl_htc_reset(target); in ath6kl_htc_mbox_create()
2883 return target; in ath6kl_htc_mbox_create()
2886 ath6kl_htc_mbox_cleanup(target); in ath6kl_htc_mbox_create()
2892 static void ath6kl_htc_mbox_cleanup(struct htc_target *target) in ath6kl_htc_mbox_cleanup() argument
2896 ath6kl_hif_cleanup_scatter(target->dev->ar); in ath6kl_htc_mbox_cleanup()
2899 &target->free_ctrl_txbuf, list) { in ath6kl_htc_mbox_cleanup()
2906 &target->free_ctrl_rxbuf, list) { in ath6kl_htc_mbox_cleanup()
2912 kfree(target->dev); in ath6kl_htc_mbox_cleanup()
2913 kfree(target); in ath6kl_htc_mbox_cleanup()