htt_tx.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. * Copyright (c) 2005-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include <linux/etherdevice.h>
  18. #include "htt.h"
  19. #include "mac.h"
  20. #include "hif.h"
  21. #include "txrx.h"
  22. #include "debug.h"
  23. void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt)
  24. {
  25. htt->num_pending_tx--;
  26. if (htt->num_pending_tx == htt->max_num_pending_tx - 1)
  27. ieee80211_wake_queues(htt->ar->hw);
  28. }
  29. static void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt)
  30. {
  31. spin_lock_bh(&htt->tx_lock);
  32. __ath10k_htt_tx_dec_pending(htt);
  33. spin_unlock_bh(&htt->tx_lock);
  34. }
  35. static int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt)
  36. {
  37. int ret = 0;
  38. spin_lock_bh(&htt->tx_lock);
  39. if (htt->num_pending_tx >= htt->max_num_pending_tx) {
  40. ret = -EBUSY;
  41. goto exit;
  42. }
  43. htt->num_pending_tx++;
  44. if (htt->num_pending_tx == htt->max_num_pending_tx)
  45. ieee80211_stop_queues(htt->ar->hw);
  46. exit:
  47. spin_unlock_bh(&htt->tx_lock);
  48. return ret;
  49. }
  50. int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt)
  51. {
  52. int msdu_id;
  53. lockdep_assert_held(&htt->tx_lock);
  54. msdu_id = find_first_zero_bit(htt->used_msdu_ids,
  55. htt->max_num_pending_tx);
  56. if (msdu_id == htt->max_num_pending_tx)
  57. return -ENOBUFS;
  58. ath10k_dbg(ATH10K_DBG_HTT, "htt tx alloc msdu_id %d\n", msdu_id);
  59. __set_bit(msdu_id, htt->used_msdu_ids);
  60. return msdu_id;
  61. }
  62. void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id)
  63. {
  64. lockdep_assert_held(&htt->tx_lock);
  65. if (!test_bit(msdu_id, htt->used_msdu_ids))
  66. ath10k_warn("trying to free unallocated msdu_id %d\n", msdu_id);
  67. ath10k_dbg(ATH10K_DBG_HTT, "htt tx free msdu_id %hu\n", msdu_id);
  68. __clear_bit(msdu_id, htt->used_msdu_ids);
  69. }
  70. int ath10k_htt_tx_alloc(struct ath10k_htt *htt)
  71. {
  72. spin_lock_init(&htt->tx_lock);
  73. init_waitqueue_head(&htt->empty_tx_wq);
  74. if (test_bit(ATH10K_FW_FEATURE_WMI_10X, htt->ar->fw_features))
  75. htt->max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC;
  76. else
  77. htt->max_num_pending_tx = TARGET_NUM_MSDU_DESC;
  78. ath10k_dbg(ATH10K_DBG_BOOT, "htt tx max num pending tx %d\n",
  79. htt->max_num_pending_tx);
  80. htt->pending_tx = kzalloc(sizeof(*htt->pending_tx) *
  81. htt->max_num_pending_tx, GFP_KERNEL);
  82. if (!htt->pending_tx)
  83. return -ENOMEM;
  84. htt->used_msdu_ids = kzalloc(sizeof(unsigned long) *
  85. BITS_TO_LONGS(htt->max_num_pending_tx),
  86. GFP_KERNEL);
  87. if (!htt->used_msdu_ids) {
  88. kfree(htt->pending_tx);
  89. return -ENOMEM;
  90. }
  91. htt->tx_pool = dma_pool_create("ath10k htt tx pool", htt->ar->dev,
  92. sizeof(struct ath10k_htt_txbuf), 4, 0);
  93. if (!htt->tx_pool) {
  94. kfree(htt->used_msdu_ids);
  95. kfree(htt->pending_tx);
  96. return -ENOMEM;
  97. }
  98. return 0;
  99. }
  100. static void ath10k_htt_tx_free_pending(struct ath10k_htt *htt)
  101. {
  102. struct htt_tx_done tx_done = {0};
  103. int msdu_id;
  104. spin_lock_bh(&htt->tx_lock);
  105. for (msdu_id = 0; msdu_id < htt->max_num_pending_tx; msdu_id++) {
  106. if (!test_bit(msdu_id, htt->used_msdu_ids))
  107. continue;
  108. ath10k_dbg(ATH10K_DBG_HTT, "force cleanup msdu_id %hu\n",
  109. msdu_id);
  110. tx_done.discard = 1;
  111. tx_done.msdu_id = msdu_id;
  112. ath10k_txrx_tx_unref(htt, &tx_done);
  113. }
  114. spin_unlock_bh(&htt->tx_lock);
  115. }
  116. void ath10k_htt_tx_free(struct ath10k_htt *htt)
  117. {
  118. ath10k_htt_tx_free_pending(htt);
  119. kfree(htt->pending_tx);
  120. kfree(htt->used_msdu_ids);
  121. dma_pool_destroy(htt->tx_pool);
  122. return;
  123. }
  124. void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
  125. {
  126. dev_kfree_skb_any(skb);
  127. }
  128. int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
  129. {
  130. struct sk_buff *skb;
  131. struct htt_cmd *cmd;
  132. int len = 0;
  133. int ret;
  134. len += sizeof(cmd->hdr);
  135. len += sizeof(cmd->ver_req);
  136. skb = ath10k_htc_alloc_skb(len);
  137. if (!skb)
  138. return -ENOMEM;
  139. skb_put(skb, len);
  140. cmd = (struct htt_cmd *)skb->data;
  141. cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_VERSION_REQ;
  142. ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
  143. if (ret) {
  144. dev_kfree_skb_any(skb);
  145. return ret;
  146. }
  147. return 0;
  148. }
  149. int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie)
  150. {
  151. struct htt_stats_req *req;
  152. struct sk_buff *skb;
  153. struct htt_cmd *cmd;
  154. int len = 0, ret;
  155. len += sizeof(cmd->hdr);
  156. len += sizeof(cmd->stats_req);
  157. skb = ath10k_htc_alloc_skb(len);
  158. if (!skb)
  159. return -ENOMEM;
  160. skb_put(skb, len);
  161. cmd = (struct htt_cmd *)skb->data;
  162. cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_STATS_REQ;
  163. req = &cmd->stats_req;
  164. memset(req, 0, sizeof(*req));
  165. /* currently we support only max 8 bit masks so no need to worry
  166. * about endian support */
  167. req->upload_types[0] = mask;
  168. req->reset_types[0] = mask;
  169. req->stat_type = HTT_STATS_REQ_CFG_STAT_TYPE_INVALID;
  170. req->cookie_lsb = cpu_to_le32(cookie & 0xffffffff);
  171. req->cookie_msb = cpu_to_le32((cookie & 0xffffffff00000000ULL) >> 32);
  172. ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
  173. if (ret) {
  174. ath10k_warn("failed to send htt type stats request: %d", ret);
  175. dev_kfree_skb_any(skb);
  176. return ret;
  177. }
  178. return 0;
  179. }
  180. int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
  181. {
  182. struct sk_buff *skb;
  183. struct htt_cmd *cmd;
  184. struct htt_rx_ring_setup_ring *ring;
  185. const int num_rx_ring = 1;
  186. u16 flags;
  187. u32 fw_idx;
  188. int len;
  189. int ret;
  190. /*
  191. * the HW expects the buffer to be an integral number of 4-byte
  192. * "words"
  193. */
  194. BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4));
  195. BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0);
  196. len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup.hdr)
  197. + (sizeof(*ring) * num_rx_ring);
  198. skb = ath10k_htc_alloc_skb(len);
  199. if (!skb)
  200. return -ENOMEM;
  201. skb_put(skb, len);
  202. cmd = (struct htt_cmd *)skb->data;
  203. ring = &cmd->rx_setup.rings[0];
  204. cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_RX_RING_CFG;
  205. cmd->rx_setup.hdr.num_rings = 1;
  206. /* FIXME: do we need all of this? */
  207. flags = 0;
  208. flags |= HTT_RX_RING_FLAGS_MAC80211_HDR;
  209. flags |= HTT_RX_RING_FLAGS_MSDU_PAYLOAD;
  210. flags |= HTT_RX_RING_FLAGS_PPDU_START;
  211. flags |= HTT_RX_RING_FLAGS_PPDU_END;
  212. flags |= HTT_RX_RING_FLAGS_MPDU_START;
  213. flags |= HTT_RX_RING_FLAGS_MPDU_END;
  214. flags |= HTT_RX_RING_FLAGS_MSDU_START;
  215. flags |= HTT_RX_RING_FLAGS_MSDU_END;
  216. flags |= HTT_RX_RING_FLAGS_RX_ATTENTION;
  217. flags |= HTT_RX_RING_FLAGS_FRAG_INFO;
  218. flags |= HTT_RX_RING_FLAGS_UNICAST_RX;
  219. flags |= HTT_RX_RING_FLAGS_MULTICAST_RX;
  220. flags |= HTT_RX_RING_FLAGS_CTRL_RX;
  221. flags |= HTT_RX_RING_FLAGS_MGMT_RX;
  222. flags |= HTT_RX_RING_FLAGS_NULL_RX;
  223. flags |= HTT_RX_RING_FLAGS_PHY_DATA_RX;
  224. fw_idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr);
  225. ring->fw_idx_shadow_reg_paddr =
  226. __cpu_to_le32(htt->rx_ring.alloc_idx.paddr);
  227. ring->rx_ring_base_paddr = __cpu_to_le32(htt->rx_ring.base_paddr);
  228. ring->rx_ring_len = __cpu_to_le16(htt->rx_ring.size);
  229. ring->rx_ring_bufsize = __cpu_to_le16(HTT_RX_BUF_SIZE);
  230. ring->flags = __cpu_to_le16(flags);
  231. ring->fw_idx_init_val = __cpu_to_le16(fw_idx);
  232. #define desc_offset(x) (offsetof(struct htt_rx_desc, x) / 4)
  233. ring->mac80211_hdr_offset = __cpu_to_le16(desc_offset(rx_hdr_status));
  234. ring->msdu_payload_offset = __cpu_to_le16(desc_offset(msdu_payload));
  235. ring->ppdu_start_offset = __cpu_to_le16(desc_offset(ppdu_start));
  236. ring->ppdu_end_offset = __cpu_to_le16(desc_offset(ppdu_end));
  237. ring->mpdu_start_offset = __cpu_to_le16(desc_offset(mpdu_start));
  238. ring->mpdu_end_offset = __cpu_to_le16(desc_offset(mpdu_end));
  239. ring->msdu_start_offset = __cpu_to_le16(desc_offset(msdu_start));
  240. ring->msdu_end_offset = __cpu_to_le16(desc_offset(msdu_end));
  241. ring->rx_attention_offset = __cpu_to_le16(desc_offset(attention));
  242. ring->frag_info_offset = __cpu_to_le16(desc_offset(frag_info));
  243. #undef desc_offset
  244. ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
  245. if (ret) {
  246. dev_kfree_skb_any(skb);
  247. return ret;
  248. }
  249. return 0;
  250. }
  251. int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
  252. {
  253. struct device *dev = htt->ar->dev;
  254. struct sk_buff *txdesc = NULL;
  255. struct htt_cmd *cmd;
  256. struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
  257. u8 vdev_id = skb_cb->vdev_id;
  258. int len = 0;
  259. int msdu_id = -1;
  260. int res;
  261. res = ath10k_htt_tx_inc_pending(htt);
  262. if (res)
  263. goto err;
  264. len += sizeof(cmd->hdr);
  265. len += sizeof(cmd->mgmt_tx);
  266. spin_lock_bh(&htt->tx_lock);
  267. res = ath10k_htt_tx_alloc_msdu_id(htt);
  268. if (res < 0) {
  269. spin_unlock_bh(&htt->tx_lock);
  270. goto err_tx_dec;
  271. }
  272. msdu_id = res;
  273. htt->pending_tx[msdu_id] = msdu;
  274. spin_unlock_bh(&htt->tx_lock);
  275. txdesc = ath10k_htc_alloc_skb(len);
  276. if (!txdesc) {
  277. res = -ENOMEM;
  278. goto err_free_msdu_id;
  279. }
  280. skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
  281. DMA_TO_DEVICE);
  282. res = dma_mapping_error(dev, skb_cb->paddr);
  283. if (res)
  284. goto err_free_txdesc;
  285. skb_put(txdesc, len);
  286. cmd = (struct htt_cmd *)txdesc->data;
  287. cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_MGMT_TX;
  288. cmd->mgmt_tx.msdu_paddr = __cpu_to_le32(ATH10K_SKB_CB(msdu)->paddr);
  289. cmd->mgmt_tx.len = __cpu_to_le32(msdu->len);
  290. cmd->mgmt_tx.desc_id = __cpu_to_le32(msdu_id);
  291. cmd->mgmt_tx.vdev_id = __cpu_to_le32(vdev_id);
  292. memcpy(cmd->mgmt_tx.hdr, msdu->data,
  293. min_t(int, msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
  294. skb_cb->htt.txbuf = NULL;
  295. res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
  296. if (res)
  297. goto err_unmap_msdu;
  298. return 0;
  299. err_unmap_msdu:
  300. dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
  301. err_free_txdesc:
  302. dev_kfree_skb_any(txdesc);
  303. err_free_msdu_id:
  304. spin_lock_bh(&htt->tx_lock);
  305. htt->pending_tx[msdu_id] = NULL;
  306. ath10k_htt_tx_free_msdu_id(htt, msdu_id);
  307. spin_unlock_bh(&htt->tx_lock);
  308. err_tx_dec:
  309. ath10k_htt_tx_dec_pending(htt);
  310. err:
  311. return res;
  312. }
  313. int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
  314. {
  315. struct device *dev = htt->ar->dev;
  316. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
  317. struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
  318. struct ath10k_hif_sg_item sg_items[2];
  319. struct htt_data_tx_desc_frag *frags;
  320. u8 vdev_id = skb_cb->vdev_id;
  321. u8 tid = skb_cb->htt.tid;
  322. int prefetch_len;
  323. int res;
  324. u8 flags0 = 0;
  325. u16 msdu_id, flags1 = 0;
  326. dma_addr_t paddr;
  327. u32 frags_paddr;
  328. bool use_frags;
  329. res = ath10k_htt_tx_inc_pending(htt);
  330. if (res)
  331. goto err;
  332. spin_lock_bh(&htt->tx_lock);
  333. res = ath10k_htt_tx_alloc_msdu_id(htt);
  334. if (res < 0) {
  335. spin_unlock_bh(&htt->tx_lock);
  336. goto err_tx_dec;
  337. }
  338. msdu_id = res;
  339. htt->pending_tx[msdu_id] = msdu;
  340. spin_unlock_bh(&htt->tx_lock);
  341. prefetch_len = min(htt->prefetch_len, msdu->len);
  342. prefetch_len = roundup(prefetch_len, 4);
  343. /* Since HTT 3.0 there is no separate mgmt tx command. However in case
  344. * of mgmt tx using TX_FRM there is not tx fragment list. Instead of tx
  345. * fragment list host driver specifies directly frame pointer. */
  346. use_frags = htt->target_version_major < 3 ||
  347. !ieee80211_is_mgmt(hdr->frame_control);
  348. skb_cb->htt.txbuf = dma_pool_alloc(htt->tx_pool, GFP_ATOMIC,
  349. &paddr);
  350. if (!skb_cb->htt.txbuf)
  351. goto err_free_msdu_id;
  352. skb_cb->htt.txbuf_paddr = paddr;
  353. skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
  354. DMA_TO_DEVICE);
  355. res = dma_mapping_error(dev, skb_cb->paddr);
  356. if (res)
  357. goto err_free_txbuf;
  358. if (likely(use_frags)) {
  359. frags = skb_cb->htt.txbuf->frags;
  360. frags[0].paddr = __cpu_to_le32(skb_cb->paddr);
  361. frags[0].len = __cpu_to_le32(msdu->len);
  362. frags[1].paddr = 0;
  363. frags[1].len = 0;
  364. flags0 |= SM(ATH10K_HW_TXRX_NATIVE_WIFI,
  365. HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
  366. frags_paddr = skb_cb->htt.txbuf_paddr;
  367. } else {
  368. flags0 |= SM(ATH10K_HW_TXRX_MGMT,
  369. HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
  370. frags_paddr = skb_cb->paddr;
  371. }
  372. /* Normally all commands go through HTC which manages tx credits for
  373. * each endpoint and notifies when tx is completed.
  374. *
  375. * HTT endpoint is creditless so there's no need to care about HTC
  376. * flags. In that case it is trivial to fill the HTC header here.
  377. *
  378. * MSDU transmission is considered completed upon HTT event. This
  379. * implies no relevant resources can be freed until after the event is
  380. * received. That's why HTC tx completion handler itself is ignored by
  381. * setting NULL to transfer_context for all sg items.
  382. *
  383. * There is simply no point in pushing HTT TX_FRM through HTC tx path
  384. * as it's a waste of resources. By bypassing HTC it is possible to
  385. * avoid extra memory allocations, compress data structures and thus
  386. * improve performance. */
  387. skb_cb->htt.txbuf->htc_hdr.eid = htt->eid;
  388. skb_cb->htt.txbuf->htc_hdr.len = __cpu_to_le16(
  389. sizeof(skb_cb->htt.txbuf->cmd_hdr) +
  390. sizeof(skb_cb->htt.txbuf->cmd_tx) +
  391. prefetch_len);
  392. skb_cb->htt.txbuf->htc_hdr.flags = 0;
  393. if (!ieee80211_has_protected(hdr->frame_control))
  394. flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
  395. flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
  396. flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID);
  397. flags1 |= SM((u16)tid, HTT_DATA_TX_DESC_FLAGS1_EXT_TID);
  398. flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
  399. flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
  400. skb_cb->htt.txbuf->cmd_hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
  401. skb_cb->htt.txbuf->cmd_tx.flags0 = flags0;
  402. skb_cb->htt.txbuf->cmd_tx.flags1 = __cpu_to_le16(flags1);
  403. skb_cb->htt.txbuf->cmd_tx.len = __cpu_to_le16(msdu->len);
  404. skb_cb->htt.txbuf->cmd_tx.id = __cpu_to_le16(msdu_id);
  405. skb_cb->htt.txbuf->cmd_tx.frags_paddr = __cpu_to_le32(frags_paddr);
  406. skb_cb->htt.txbuf->cmd_tx.peerid = __cpu_to_le32(HTT_INVALID_PEERID);
  407. ath10k_dbg(ATH10K_DBG_HTT,
  408. "htt tx flags0 %hhu flags1 %hu len %d id %hu frags_paddr %08x, msdu_paddr %08x vdev %hhu tid %hhu\n",
  409. flags0, flags1, msdu->len, msdu_id, frags_paddr,
  410. (u32)skb_cb->paddr, vdev_id, tid);
  411. ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ",
  412. msdu->data, msdu->len);
  413. sg_items[0].transfer_id = 0;
  414. sg_items[0].transfer_context = NULL;
  415. sg_items[0].vaddr = &skb_cb->htt.txbuf->htc_hdr;
  416. sg_items[0].paddr = skb_cb->htt.txbuf_paddr +
  417. sizeof(skb_cb->htt.txbuf->frags);
  418. sg_items[0].len = sizeof(skb_cb->htt.txbuf->htc_hdr) +
  419. sizeof(skb_cb->htt.txbuf->cmd_hdr) +
  420. sizeof(skb_cb->htt.txbuf->cmd_tx);
  421. sg_items[1].transfer_id = 0;
  422. sg_items[1].transfer_context = NULL;
  423. sg_items[1].vaddr = msdu->data;
  424. sg_items[1].paddr = skb_cb->paddr;
  425. sg_items[1].len = prefetch_len;
  426. res = ath10k_hif_tx_sg(htt->ar,
  427. htt->ar->htc.endpoint[htt->eid].ul_pipe_id,
  428. sg_items, ARRAY_SIZE(sg_items));
  429. if (res)
  430. goto err_unmap_msdu;
  431. return 0;
  432. err_unmap_msdu:
  433. dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
  434. err_free_txbuf:
  435. dma_pool_free(htt->tx_pool,
  436. skb_cb->htt.txbuf,
  437. skb_cb->htt.txbuf_paddr);
  438. err_free_msdu_id:
  439. spin_lock_bh(&htt->tx_lock);
  440. htt->pending_tx[msdu_id] = NULL;
  441. ath10k_htt_tx_free_msdu_id(htt, msdu_id);
  442. spin_unlock_bh(&htt->tx_lock);
  443. err_tx_dec:
  444. ath10k_htt_tx_dec_pending(htt);
  445. err:
  446. return res;
  447. }