Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Lin Bai | 1a73a41 | 2018-12-13 16:40:14 +0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2019 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 19 | #include <qdf_atomic.h> /* qdf_atomic_inc, etc. */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 20 | #include <qdf_lock.h> /* qdf_os_spinlock */ |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 21 | #include <qdf_time.h> /* qdf_system_ticks, etc. */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 22 | #include <qdf_nbuf.h> /* qdf_nbuf_t */ |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 23 | #include <qdf_net_types.h> /* QDF_NBUF_TX_EXT_TID_INVALID */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 24 | |
Ashish Kumar Dhanotiya | 94ffbd1 | 2019-08-08 18:00:59 +0530 | [diff] [blame] | 25 | #include "queue.h" /* TAILQ */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 26 | #ifdef QCA_COMPUTE_TX_DELAY |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 27 | #include <enet.h> /* ethernet_hdr_t, etc. */ |
| 28 | #include <ipv6_defs.h> /* ipv6_traffic_class */ |
| 29 | #endif |
| 30 | |
| 31 | #include <ol_txrx_api.h> /* ol_txrx_vdev_handle, etc. */ |
| 32 | #include <ol_htt_tx_api.h> /* htt_tx_compl_desc_id */ |
| 33 | #include <ol_txrx_htt_api.h> /* htt_tx_status */ |
| 34 | |
| 35 | #include <ol_ctrl_txrx_api.h> |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 36 | #include <cdp_txrx_tx_delay.h> |
| 37 | #include <ol_txrx_types.h> /* ol_txrx_vdev_t, etc */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #include <ol_tx_desc.h> /* ol_tx_desc_find, ol_tx_desc_frame_free */ |
| 39 | #ifdef QCA_COMPUTE_TX_DELAY |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 40 | #include <ol_tx_classify.h> /* ol_tx_dest_addr_find */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #endif |
| 42 | #include <ol_txrx_internal.h> /* OL_TX_DESC_NO_REFS, etc. */ |
| 43 | #include <ol_osif_txrx_api.h> |
| 44 | #include <ol_tx.h> /* ol_tx_reinject */ |
Jeff Johnson | f89f58f | 2016-10-14 09:58:29 -0700 | [diff] [blame] | 45 | #include <ol_tx_send.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 46 | |
| 47 | #include <ol_cfg.h> /* ol_cfg_is_high_latency */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 48 | #include <ol_tx_sched.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 49 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 50 | #include <ol_txrx_encap.h> /* OL_TX_RESTORE_HDR, etc */ |
| 51 | #endif |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 52 | #include <ol_tx_queue.h> |
| 53 | #include <ol_txrx.h> |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 54 | #include <pktlog_ac_fmt.h> |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 55 | #include <cdp_txrx_handle.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 56 | |
| 57 | #ifdef TX_CREDIT_RECLAIM_SUPPORT |
| 58 | |
| 59 | #define OL_TX_CREDIT_RECLAIM(pdev) \ |
| 60 | do { \ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 61 | if (qdf_atomic_read(&pdev->target_tx_credit) < \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | ol_cfg_tx_credit_lwm(pdev->ctrl_pdev)) { \ |
| 63 | ol_osif_ath_tasklet(pdev->osdev); \ |
| 64 | } \ |
| 65 | } while (0) |
| 66 | |
| 67 | #else |
| 68 | |
| 69 | #define OL_TX_CREDIT_RECLAIM(pdev) |
| 70 | |
| 71 | #endif /* TX_CREDIT_RECLAIM_SUPPORT */ |
| 72 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 73 | #if defined(CONFIG_HL_SUPPORT) || defined(TX_CREDIT_RECLAIM_SUPPORT) |
| 74 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | /* |
| 76 | * HL needs to keep track of the amount of credit available to download |
| 77 | * tx frames to the target - the download scheduler decides when to |
| 78 | * download frames, and which frames to download, based on the credit |
| 79 | * availability. |
| 80 | * LL systems that use TX_CREDIT_RECLAIM_SUPPORT also need to keep track |
| 81 | * of the target_tx_credit, to determine when to poll for tx completion |
| 82 | * messages. |
| 83 | */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 84 | static inline void |
| 85 | ol_tx_target_credit_decr_int(struct ol_txrx_pdev_t *pdev, int delta) |
| 86 | { |
| 87 | qdf_atomic_add(-1 * delta, &pdev->target_tx_credit); |
| 88 | } |
| 89 | |
| 90 | static inline void |
| 91 | ol_tx_target_credit_incr_int(struct ol_txrx_pdev_t *pdev, int delta) |
| 92 | { |
| 93 | qdf_atomic_add(delta, &pdev->target_tx_credit); |
| 94 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | #else |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 96 | |
| 97 | static inline void |
| 98 | ol_tx_target_credit_decr_int(struct ol_txrx_pdev_t *pdev, int delta) |
| 99 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static inline void |
| 103 | ol_tx_target_credit_incr_int(struct ol_txrx_pdev_t *pdev, int delta) |
| 104 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 105 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 106 | #endif |
| 107 | |
Rakshith Suresh Patkar | 384a28a | 2018-11-02 16:43:43 +0530 | [diff] [blame] | 108 | #ifdef DESC_TIMESTAMP_DEBUG_INFO |
| 109 | static inline void ol_tx_desc_update_comp_ts(struct ol_tx_desc_t *tx_desc) |
| 110 | { |
| 111 | tx_desc->desc_debug_info.last_comp_ts = qdf_get_log_timestamp(); |
| 112 | } |
| 113 | #else |
| 114 | static inline void ol_tx_desc_update_comp_ts(struct ol_tx_desc_t *tx_desc) |
| 115 | { |
| 116 | } |
| 117 | #endif |
| 118 | |
Ajit Pal Singh | aa4a47f | 2018-04-23 14:11:44 +0530 | [diff] [blame] | 119 | #if defined(CONFIG_HL_SUPPORT) && defined(QCA_HL_NETDEV_FLOW_CONTROL) |
Nirav Shah | c4aa1ab | 2018-04-21 12:38:44 +0530 | [diff] [blame] | 120 | void ol_tx_flow_ct_unpause_os_q(ol_txrx_pdev_handle pdev) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 121 | { |
| 122 | struct ol_txrx_vdev_t *vdev; |
Nirav Shah | fb9b1df | 2019-11-15 11:40:52 +0530 | [diff] [blame^] | 123 | bool trigger_unpause = false; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 124 | |
Ajit Pal Singh | aa4a47f | 2018-04-23 14:11:44 +0530 | [diff] [blame] | 125 | qdf_spin_lock_bh(&pdev->tx_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 126 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
Ajit Pal Singh | aa4a47f | 2018-04-23 14:11:44 +0530 | [diff] [blame] | 127 | if (vdev->tx_desc_limit == 0) |
| 128 | continue; |
| 129 | |
| 130 | /* un-pause high priority queue */ |
| 131 | if (vdev->prio_q_paused && |
| 132 | (qdf_atomic_read(&vdev->tx_desc_count) |
| 133 | < vdev->tx_desc_limit)) { |
| 134 | pdev->pause_cb(vdev->vdev_id, |
| 135 | WLAN_NETIF_PRIORITY_QUEUE_ON, |
| 136 | WLAN_DATA_FLOW_CONTROL_PRIORITY); |
| 137 | vdev->prio_q_paused = 0; |
| 138 | } |
| 139 | /* un-pause non priority queues */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 140 | if (qdf_atomic_read(&vdev->os_q_paused) && |
Ajit Pal Singh | aa4a47f | 2018-04-23 14:11:44 +0530 | [diff] [blame] | 141 | (qdf_atomic_read(&vdev->tx_desc_count) |
| 142 | <= vdev->queue_restart_th)) { |
| 143 | pdev->pause_cb(vdev->vdev_id, |
| 144 | WLAN_WAKE_NON_PRIORITY_QUEUE, |
| 145 | WLAN_DATA_FLOW_CONTROL); |
| 146 | qdf_atomic_set(&vdev->os_q_paused, 0); |
Nirav Shah | fb9b1df | 2019-11-15 11:40:52 +0530 | [diff] [blame^] | 147 | trigger_unpause = true; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 148 | } |
| 149 | } |
Ajit Pal Singh | aa4a47f | 2018-04-23 14:11:44 +0530 | [diff] [blame] | 150 | qdf_spin_unlock_bh(&pdev->tx_mutex); |
Nirav Shah | fb9b1df | 2019-11-15 11:40:52 +0530 | [diff] [blame^] | 151 | if (trigger_unpause) |
| 152 | ol_tx_hl_pdev_queue_send_all(pdev); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 153 | } |
Nirav Shah | c4aa1ab | 2018-04-21 12:38:44 +0530 | [diff] [blame] | 154 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 155 | |
| 156 | static inline uint16_t |
| 157 | ol_tx_send_base(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 158 | struct ol_tx_desc_t *tx_desc, qdf_nbuf_t msdu) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | { |
| 160 | int msdu_credit_consumed; |
| 161 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 162 | TX_CREDIT_DEBUG_PRINT("TX %d bytes\n", qdf_nbuf_len(msdu)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | TX_CREDIT_DEBUG_PRINT(" <HTT> Decrease credit %d - 1 = %d, len:%d.\n", |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 164 | qdf_atomic_read(&pdev->target_tx_credit), |
| 165 | qdf_atomic_read(&pdev->target_tx_credit) - 1, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 166 | qdf_nbuf_len(msdu)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 167 | |
| 168 | msdu_credit_consumed = htt_tx_msdu_credit(msdu); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 169 | ol_tx_target_credit_decr_int(pdev, msdu_credit_consumed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 170 | OL_TX_CREDIT_RECLAIM(pdev); |
| 171 | |
| 172 | /* |
| 173 | * When the tx frame is downloaded to the target, there are two |
| 174 | * outstanding references: |
| 175 | * 1. The host download SW (HTT, HTC, HIF) |
| 176 | * This reference is cleared by the ol_tx_send_done callback |
| 177 | * functions. |
| 178 | * 2. The target FW |
| 179 | * This reference is cleared by the ol_tx_completion_handler |
| 180 | * function. |
| 181 | * It is extremely probable that the download completion is processed |
| 182 | * before the tx completion message. However, under exceptional |
| 183 | * conditions the tx completion may be processed first. Thus, rather |
| 184 | * that assuming that reference (1) is done before reference (2), |
| 185 | * explicit reference tracking is needed. |
| 186 | * Double-increment the ref count to account for both references |
| 187 | * described above. |
| 188 | */ |
| 189 | |
| 190 | OL_TX_DESC_REF_INIT(tx_desc); |
| 191 | OL_TX_DESC_REF_INC(tx_desc); |
| 192 | OL_TX_DESC_REF_INC(tx_desc); |
| 193 | |
| 194 | return msdu_credit_consumed; |
| 195 | } |
| 196 | |
| 197 | void |
| 198 | ol_tx_send(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 199 | struct ol_tx_desc_t *tx_desc, qdf_nbuf_t msdu, uint8_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 200 | { |
| 201 | int msdu_credit_consumed; |
| 202 | uint16_t id; |
| 203 | int failed; |
| 204 | |
| 205 | msdu_credit_consumed = ol_tx_send_base(pdev, tx_desc, msdu); |
| 206 | id = ol_tx_desc_id(pdev, tx_desc); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 207 | QDF_NBUF_UPDATE_TX_PKT_COUNT(msdu, QDF_NBUF_TX_PKT_TXRX); |
Nirav Shah | 07e39a6 | 2016-04-25 17:46:40 +0530 | [diff] [blame] | 208 | DPTRACE(qdf_dp_trace_ptr(msdu, QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 209 | QDF_TRACE_DEFAULT_PDEV_ID, |
Nirav Shah | 07e39a6 | 2016-04-25 17:46:40 +0530 | [diff] [blame] | 210 | qdf_nbuf_data_addr(msdu), |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 211 | sizeof(qdf_nbuf_data(msdu)), tx_desc->id, |
| 212 | vdev_id)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 213 | failed = htt_tx_send_std(pdev->htt_pdev, msdu, id); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 214 | if (qdf_unlikely(failed)) { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 215 | ol_tx_target_credit_incr_int(pdev, msdu_credit_consumed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 216 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, 1 /* had error */); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void |
| 221 | ol_tx_send_batch(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 222 | qdf_nbuf_t head_msdu, int num_msdus) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 224 | qdf_nbuf_t rejected; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 225 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | OL_TX_CREDIT_RECLAIM(pdev); |
| 227 | |
| 228 | rejected = htt_tx_send_batch(pdev->htt_pdev, head_msdu, num_msdus); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 229 | while (qdf_unlikely(rejected)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 230 | struct ol_tx_desc_t *tx_desc; |
| 231 | uint16_t *msdu_id_storage; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 232 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 233 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 234 | next = qdf_nbuf_next(rejected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 235 | msdu_id_storage = ol_tx_msdu_id_storage(rejected); |
| 236 | tx_desc = ol_tx_desc_find(pdev, *msdu_id_storage); |
| 237 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 238 | ol_tx_target_credit_incr(pdev, rejected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 239 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, 1 /* had error */); |
| 240 | |
| 241 | rejected = next; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | void |
| 246 | ol_tx_send_nonstd(struct ol_txrx_pdev_t *pdev, |
| 247 | struct ol_tx_desc_t *tx_desc, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 248 | qdf_nbuf_t msdu, enum htt_pkt_type pkt_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 249 | { |
| 250 | int msdu_credit_consumed; |
| 251 | uint16_t id; |
| 252 | int failed; |
| 253 | |
| 254 | msdu_credit_consumed = ol_tx_send_base(pdev, tx_desc, msdu); |
| 255 | id = ol_tx_desc_id(pdev, tx_desc); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 256 | QDF_NBUF_UPDATE_TX_PKT_COUNT(msdu, QDF_NBUF_TX_PKT_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 257 | failed = htt_tx_send_nonstd(pdev->htt_pdev, msdu, id, pkt_type); |
| 258 | if (failed) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 259 | ol_txrx_err( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 260 | "Error: freeing tx frame after htt_tx failed"); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 261 | ol_tx_target_credit_incr_int(pdev, msdu_credit_consumed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 262 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, 1 /* had error */); |
| 263 | } |
| 264 | } |
| 265 | |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 266 | static inline bool |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 267 | ol_tx_download_done_base(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 268 | A_STATUS status, qdf_nbuf_t msdu, uint16_t msdu_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 269 | { |
| 270 | struct ol_tx_desc_t *tx_desc; |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 271 | bool is_frame_freed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | |
| 273 | tx_desc = ol_tx_desc_find(pdev, msdu_id); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 274 | qdf_assert(tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 275 | |
| 276 | /* |
| 277 | * If the download is done for |
| 278 | * the Management frame then |
| 279 | * call the download callback if registered |
| 280 | */ |
| 281 | if (tx_desc->pkt_type >= OL_TXRX_MGMT_TYPE_BASE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 282 | ol_txrx_mgmt_tx_cb download_cb = |
Sravan Kumar Kairam | 905b4c5 | 2017-10-17 19:38:14 +0530 | [diff] [blame] | 283 | pdev->tx_mgmt_cb.download_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 284 | if (download_cb) { |
Sravan Kumar Kairam | 905b4c5 | 2017-10-17 19:38:14 +0530 | [diff] [blame] | 285 | download_cb(pdev->tx_mgmt_cb.ctxt, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 286 | tx_desc->netbuf, status != A_OK); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | if (status != A_OK) { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 291 | ol_tx_target_credit_incr(pdev, msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 292 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, |
| 293 | 1 /* download err */); |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 294 | is_frame_freed = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 295 | } else { |
| 296 | if (OL_TX_DESC_NO_REFS(tx_desc)) { |
| 297 | /* |
| 298 | * The decremented value was zero - free the frame. |
| 299 | * Use the tx status recorded previously during |
| 300 | * tx completion handling. |
| 301 | */ |
| 302 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, |
| 303 | tx_desc->status != |
| 304 | htt_tx_status_ok); |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 305 | is_frame_freed = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 306 | } |
| 307 | } |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 308 | return is_frame_freed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | void |
| 312 | ol_tx_download_done_ll(void *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 313 | A_STATUS status, qdf_nbuf_t msdu, uint16_t msdu_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 314 | { |
| 315 | ol_tx_download_done_base((struct ol_txrx_pdev_t *)pdev, status, msdu, |
| 316 | msdu_id); |
| 317 | } |
| 318 | |
| 319 | void |
| 320 | ol_tx_download_done_hl_retain(void *txrx_pdev, |
| 321 | A_STATUS status, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 322 | qdf_nbuf_t msdu, uint16_t msdu_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 323 | { |
| 324 | struct ol_txrx_pdev_t *pdev = txrx_pdev; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 325 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | ol_tx_download_done_base(pdev, status, msdu, msdu_id); |
| 327 | } |
| 328 | |
| 329 | void |
| 330 | ol_tx_download_done_hl_free(void *txrx_pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 331 | A_STATUS status, qdf_nbuf_t msdu, uint16_t msdu_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | { |
| 333 | struct ol_txrx_pdev_t *pdev = txrx_pdev; |
| 334 | struct ol_tx_desc_t *tx_desc; |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 335 | bool is_frame_freed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | |
| 337 | tx_desc = ol_tx_desc_find(pdev, msdu_id); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 338 | qdf_assert(tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 339 | |
Nirav Shah | 38ccf5b | 2019-07-03 10:22:11 +0530 | [diff] [blame] | 340 | DPTRACE(qdf_dp_trace_ptr(msdu, |
| 341 | QDF_DP_TRACE_FREE_PACKET_PTR_RECORD, |
| 342 | QDF_TRACE_DEFAULT_PDEV_ID, |
| 343 | qdf_nbuf_data_addr(msdu), |
| 344 | sizeof(qdf_nbuf_data(msdu)), tx_desc->id, |
| 345 | status)); |
| 346 | |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 347 | is_frame_freed = ol_tx_download_done_base(pdev, status, msdu, msdu_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 348 | |
Ajit Pal Singh | cdbe69a | 2019-06-06 11:24:23 +0530 | [diff] [blame] | 349 | /* |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 350 | * if frame is freed in ol_tx_download_done_base then return. |
Ajit Pal Singh | cdbe69a | 2019-06-06 11:24:23 +0530 | [diff] [blame] | 351 | */ |
Nirav Shah | fc0848c | 2019-10-16 11:46:29 +0530 | [diff] [blame] | 352 | if (is_frame_freed) { |
Ajit Pal Singh | cdbe69a | 2019-06-06 11:24:23 +0530 | [diff] [blame] | 353 | qdf_atomic_add(1, &pdev->tx_queue.rsrc_cnt); |
| 354 | return; |
| 355 | } |
| 356 | |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 357 | if ((tx_desc->pkt_type != OL_TX_FRM_NO_FREE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 358 | (tx_desc->pkt_type < OL_TXRX_MGMT_TYPE_BASE)) { |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 359 | qdf_atomic_add(1, &pdev->tx_queue.rsrc_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 360 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, status != A_OK); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | void ol_tx_target_credit_init(struct ol_txrx_pdev_t *pdev, int credit_delta) |
| 365 | { |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 366 | qdf_atomic_add(credit_delta, &pdev->orig_target_tx_credit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | void ol_tx_target_credit_update(struct ol_txrx_pdev_t *pdev, int credit_delta) |
| 370 | { |
| 371 | TX_CREDIT_DEBUG_PRINT(" <HTT> Increase credit %d + %d = %d\n", |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 372 | qdf_atomic_read(&pdev->target_tx_credit), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 373 | credit_delta, |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 374 | qdf_atomic_read(&pdev->target_tx_credit) + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 375 | credit_delta); |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 376 | qdf_atomic_add(credit_delta, &pdev->target_tx_credit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | #ifdef QCA_COMPUTE_TX_DELAY |
| 380 | |
| 381 | static void |
| 382 | ol_tx_delay_compute(struct ol_txrx_pdev_t *pdev, |
| 383 | enum htt_tx_status status, |
| 384 | uint16_t *desc_ids, int num_msdus); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 385 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 386 | #else |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 387 | static inline void |
| 388 | ol_tx_delay_compute(struct ol_txrx_pdev_t *pdev, |
| 389 | enum htt_tx_status status, |
| 390 | uint16_t *desc_ids, int num_msdus) |
| 391 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 392 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | #endif /* QCA_COMPUTE_TX_DELAY */ |
| 394 | |
Ajit Pal Singh | 407d6d8 | 2019-08-02 23:50:35 +0530 | [diff] [blame] | 395 | #if defined(CONFIG_HL_SUPPORT) |
| 396 | int ol_tx_deduct_one_credit(struct ol_txrx_pdev_t *pdev) |
| 397 | { |
| 398 | /* TODO: Check if enough credits */ |
| 399 | |
| 400 | if (!pdev->cfg.default_tx_comp_req) { |
| 401 | ol_tx_target_credit_update(pdev, -1); |
| 402 | ol_tx_deduct_one_any_group_credit(pdev); |
| 403 | } |
| 404 | return 0; |
| 405 | } |
| 406 | #endif /* CONFIG_HL_SUPPORT */ |
| 407 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 408 | #ifndef OL_TX_RESTORE_HDR |
| 409 | #define OL_TX_RESTORE_HDR(__tx_desc, __msdu) |
| 410 | #endif |
| 411 | /* |
| 412 | * The following macros could have been inline functions too. |
| 413 | * The only rationale for choosing macros, is to force the compiler to inline |
| 414 | * the implementation, which cannot be controlled for actual "inline" functions, |
| 415 | * since "inline" is only a hint to the compiler. |
| 416 | * In the performance path, we choose to force the inlining, in preference to |
| 417 | * type-checking offered by the actual inlined functions. |
| 418 | */ |
| 419 | #define ol_tx_msdu_complete_batch(_pdev, _tx_desc, _tx_descs, _status) \ |
| 420 | TAILQ_INSERT_TAIL(&(_tx_descs), (_tx_desc), tx_desc_list_elem) |
| 421 | #ifndef ATH_11AC_TXCOMPACT |
| 422 | #define ol_tx_msdu_complete_single(_pdev, _tx_desc, _netbuf,\ |
| 423 | _lcl_freelist, _tx_desc_last) \ |
| 424 | do { \ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 425 | qdf_atomic_init(&(_tx_desc)->ref_cnt); \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 426 | /* restore orginal hdr offset */ \ |
| 427 | OL_TX_RESTORE_HDR((_tx_desc), (_netbuf)); \ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 428 | qdf_nbuf_unmap((_pdev)->osdev, (_netbuf), QDF_DMA_TO_DEVICE); \ |
| 429 | qdf_nbuf_free((_netbuf)); \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 430 | ((union ol_tx_desc_list_elem_t *)(_tx_desc))->next = \ |
| 431 | (_lcl_freelist); \ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 432 | if (qdf_unlikely(!lcl_freelist)) { \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 433 | (_tx_desc_last) = (union ol_tx_desc_list_elem_t *)\ |
| 434 | (_tx_desc); \ |
| 435 | } \ |
| 436 | (_lcl_freelist) = (union ol_tx_desc_list_elem_t *)(_tx_desc); \ |
| 437 | } while (0) |
| 438 | #else /*!ATH_11AC_TXCOMPACT */ |
| 439 | #define ol_tx_msdu_complete_single(_pdev, _tx_desc, _netbuf,\ |
| 440 | _lcl_freelist, _tx_desc_last) \ |
| 441 | do { \ |
| 442 | /* restore orginal hdr offset */ \ |
| 443 | OL_TX_RESTORE_HDR((_tx_desc), (_netbuf)); \ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 444 | qdf_nbuf_unmap((_pdev)->osdev, (_netbuf), QDF_DMA_TO_DEVICE); \ |
| 445 | qdf_nbuf_free((_netbuf)); \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 446 | ((union ol_tx_desc_list_elem_t *)(_tx_desc))->next = \ |
| 447 | (_lcl_freelist); \ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 448 | if (qdf_unlikely(!lcl_freelist)) { \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | (_tx_desc_last) = (union ol_tx_desc_list_elem_t *)\ |
| 450 | (_tx_desc); \ |
| 451 | } \ |
| 452 | (_lcl_freelist) = (union ol_tx_desc_list_elem_t *)(_tx_desc); \ |
| 453 | } while (0) |
| 454 | |
| 455 | #endif /*!ATH_11AC_TXCOMPACT */ |
| 456 | |
| 457 | #ifdef QCA_TX_SINGLE_COMPLETIONS |
| 458 | #ifdef QCA_TX_STD_PATH_ONLY |
| 459 | #define ol_tx_msdu_complete(_pdev, _tx_desc, _tx_descs, \ |
| 460 | _netbuf, _lcl_freelist, \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 461 | _tx_desc_last, _status, is_tx_desc_freed) \ |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 462 | { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 463 | is_tx_desc_freed = 0; \ |
| 464 | ol_tx_msdu_complete_single((_pdev), (_tx_desc), \ |
| 465 | (_netbuf), (_lcl_freelist), \ |
| 466 | _tx_desc_last) \ |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 467 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 468 | #else /* !QCA_TX_STD_PATH_ONLY */ |
| 469 | #define ol_tx_msdu_complete(_pdev, _tx_desc, _tx_descs, \ |
| 470 | _netbuf, _lcl_freelist, \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 471 | _tx_desc_last, _status, is_tx_desc_freed) \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 472 | do { \ |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 473 | if (qdf_likely((_tx_desc)->pkt_type == OL_TX_FRM_STD)) { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 474 | is_tx_desc_freed = 0; \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | ol_tx_msdu_complete_single((_pdev), (_tx_desc),\ |
| 476 | (_netbuf), (_lcl_freelist), \ |
| 477 | (_tx_desc_last)); \ |
| 478 | } else { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 479 | is_tx_desc_freed = 1; \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 480 | ol_tx_desc_frame_free_nonstd( \ |
| 481 | (_pdev), (_tx_desc), \ |
| 482 | (_status) != htt_tx_status_ok); \ |
| 483 | } \ |
| 484 | } while (0) |
| 485 | #endif /* !QCA_TX_STD_PATH_ONLY */ |
| 486 | #else /* !QCA_TX_SINGLE_COMPLETIONS */ |
| 487 | #ifdef QCA_TX_STD_PATH_ONLY |
| 488 | #define ol_tx_msdu_complete(_pdev, _tx_desc, _tx_descs, \ |
| 489 | _netbuf, _lcl_freelist, \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 490 | _tx_desc_last, _status, is_tx_desc_freed) \ |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 491 | { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 492 | is_tx_desc_freed = 0; \ |
| 493 | ol_tx_msdu_complete_batch((_pdev), (_tx_desc), \ |
| 494 | (_tx_descs), (_status)) \ |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 495 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | #else /* !QCA_TX_STD_PATH_ONLY */ |
| 497 | #define ol_tx_msdu_complete(_pdev, _tx_desc, _tx_descs, \ |
| 498 | _netbuf, _lcl_freelist, \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 499 | _tx_desc_last, _status, is_tx_desc_freed) \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 500 | do { \ |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 501 | if (qdf_likely((_tx_desc)->pkt_type == OL_TX_FRM_STD)) { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 502 | is_tx_desc_freed = 0; \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 503 | ol_tx_msdu_complete_batch((_pdev), (_tx_desc), \ |
| 504 | (_tx_descs), (_status)); \ |
| 505 | } else { \ |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 506 | is_tx_desc_freed = 1; \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 507 | ol_tx_desc_frame_free_nonstd((_pdev), (_tx_desc), \ |
| 508 | (_status) != \ |
| 509 | htt_tx_status_ok); \ |
| 510 | } \ |
| 511 | } while (0) |
| 512 | #endif /* !QCA_TX_STD_PATH_ONLY */ |
| 513 | #endif /* QCA_TX_SINGLE_COMPLETIONS */ |
| 514 | |
Yu Wang | 053d3e7 | 2017-02-08 18:48:24 +0800 | [diff] [blame] | 515 | #if !defined(CONFIG_HL_SUPPORT) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 516 | void ol_tx_discard_target_frms(ol_txrx_pdev_handle pdev) |
| 517 | { |
| 518 | int i = 0; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 519 | struct ol_tx_desc_t *tx_desc; |
Mohit Khanna | c3b069b | 2017-02-17 14:51:51 -0800 | [diff] [blame] | 520 | int num_disarded = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 521 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 522 | for (i = 0; i < pdev->tx_desc.pool_size; i++) { |
| 523 | tx_desc = ol_tx_desc_find(pdev, i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 524 | /* |
| 525 | * Confirm that each tx descriptor is "empty", i.e. it has |
| 526 | * no tx frame attached. |
| 527 | * In particular, check that there are no frames that have |
| 528 | * been given to the target to transmit, for which the |
| 529 | * target has never provided a response. |
| 530 | */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 531 | if (qdf_atomic_read(&tx_desc->ref_cnt)) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 532 | ol_txrx_dbg( |
Mohit Khanna | c3b069b | 2017-02-17 14:51:51 -0800 | [diff] [blame] | 533 | "Warning: freeing tx desc %d", tx_desc->id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | ol_tx_desc_frame_free_nonstd(pdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 535 | tx_desc, 1); |
Mohit Khanna | c3b069b | 2017-02-17 14:51:51 -0800 | [diff] [blame] | 536 | num_disarded++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 537 | } |
| 538 | } |
Mohit Khanna | c3b069b | 2017-02-17 14:51:51 -0800 | [diff] [blame] | 539 | |
| 540 | if (num_disarded) |
| 541 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO, |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 542 | "Warning: freed %d tx descs for which no tx completion rcvd from the target", |
| 543 | num_disarded); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | } |
Yu Wang | 053d3e7 | 2017-02-08 18:48:24 +0800 | [diff] [blame] | 545 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | |
| 547 | void ol_tx_credit_completion_handler(ol_txrx_pdev_handle pdev, int credits) |
| 548 | { |
| 549 | ol_tx_target_credit_update(pdev, credits); |
| 550 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 551 | if (pdev->cfg.is_high_latency) |
| 552 | ol_tx_sched(pdev); |
| 553 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | /* UNPAUSE OS Q */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 555 | ol_tx_flow_ct_unpause_os_q(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 558 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 559 | /** |
| 560 | * ol_tx_flow_pool_lock() - take flow pool lock |
| 561 | * @tx_desc: tx desc |
| 562 | * |
| 563 | * Return: None |
| 564 | */ |
| 565 | static inline |
| 566 | void ol_tx_flow_pool_lock(struct ol_tx_desc_t *tx_desc) |
| 567 | { |
| 568 | struct ol_tx_flow_pool_t *pool; |
| 569 | |
| 570 | pool = tx_desc->pool; |
| 571 | qdf_spin_lock_bh(&pool->flow_pool_lock); |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * ol_tx_flow_pool_unlock() - release flow pool lock |
| 576 | * @tx_desc: tx desc |
| 577 | * |
| 578 | * Return: None |
| 579 | */ |
| 580 | static inline |
| 581 | void ol_tx_flow_pool_unlock(struct ol_tx_desc_t *tx_desc) |
| 582 | { |
| 583 | struct ol_tx_flow_pool_t *pool; |
| 584 | |
| 585 | pool = tx_desc->pool; |
| 586 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
| 587 | } |
| 588 | #else |
| 589 | static inline |
| 590 | void ol_tx_flow_pool_lock(struct ol_tx_desc_t *tx_desc) |
| 591 | { |
| 592 | } |
| 593 | |
| 594 | static inline |
| 595 | void ol_tx_flow_pool_unlock(struct ol_tx_desc_t *tx_desc) |
| 596 | { |
| 597 | } |
| 598 | #endif |
| 599 | |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 600 | #ifdef WLAN_FEATURE_TSF_PLUS |
| 601 | static inline struct htt_tx_compl_ind_append_tx_tstamp *ol_tx_get_txtstamps( |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 602 | u_int32_t *msg_word_header, u_int32_t **msg_word_payload, |
| 603 | int num_msdus) |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 604 | { |
| 605 | u_int32_t has_tx_tsf; |
| 606 | u_int32_t has_retry; |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 607 | |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 608 | struct htt_tx_compl_ind_append_tx_tstamp *txtstamp_list = NULL; |
| 609 | struct htt_tx_compl_ind_append_retries *retry_list = NULL; |
| 610 | int offset_dwords; |
| 611 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 612 | if (num_msdus <= 0) |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 613 | return NULL; |
| 614 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 615 | has_tx_tsf = HTT_TX_COMPL_IND_APPEND1_GET(*msg_word_header); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 616 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 617 | /* skip header and MSDUx ID part*/ |
| 618 | offset_dwords = ((num_msdus + 1) >> 1); |
| 619 | *msg_word_payload += offset_dwords; |
| 620 | |
| 621 | if (!has_tx_tsf) |
| 622 | return NULL; |
| 623 | |
| 624 | has_retry = HTT_TX_COMPL_IND_APPEND_GET(*msg_word_header); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 625 | if (has_retry) { |
| 626 | int retry_index = 0; |
| 627 | int width_for_each_retry = |
| 628 | (sizeof(struct htt_tx_compl_ind_append_retries) + |
| 629 | 3) >> 2; |
| 630 | |
| 631 | retry_list = (struct htt_tx_compl_ind_append_retries *) |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 632 | (*msg_word_payload + offset_dwords); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 633 | while (retry_list) { |
| 634 | if (retry_list[retry_index++].flag == 0) |
| 635 | break; |
| 636 | } |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 637 | offset_dwords = retry_index * width_for_each_retry; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 638 | } |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 639 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 640 | *msg_word_payload += offset_dwords; |
| 641 | txtstamp_list = (struct htt_tx_compl_ind_append_tx_tstamp *) |
| 642 | (*msg_word_payload); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 643 | return txtstamp_list; |
| 644 | } |
| 645 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 646 | static inline |
| 647 | struct htt_tx_compl_ind_append_tx_tsf64 *ol_tx_get_txtstamp64s( |
| 648 | u_int32_t *msg_word_header, u_int32_t **msg_word_payload, |
| 649 | int num_msdus) |
| 650 | { |
| 651 | u_int32_t has_tx_tstamp64; |
| 652 | u_int32_t has_rssi; |
| 653 | struct htt_tx_compl_ind_append_tx_tsf64 *txtstamp64_list = NULL; |
| 654 | |
| 655 | int offset_dwords = 0; |
| 656 | |
| 657 | if (num_msdus <= 0) |
| 658 | return NULL; |
| 659 | |
| 660 | has_tx_tstamp64 = HTT_TX_COMPL_IND_APPEND3_GET(*msg_word_header); |
| 661 | if (!has_tx_tstamp64) |
| 662 | return NULL; |
| 663 | |
| 664 | /*skip MSDUx ACK RSSI part*/ |
| 665 | has_rssi = HTT_TX_COMPL_IND_APPEND2_GET(*msg_word_header); |
| 666 | if (has_rssi) |
| 667 | offset_dwords = ((num_msdus + 1) >> 1); |
| 668 | |
| 669 | *msg_word_payload = *msg_word_payload + offset_dwords; |
| 670 | txtstamp64_list = |
| 671 | (struct htt_tx_compl_ind_append_tx_tsf64 *) |
| 672 | (*msg_word_payload); |
| 673 | |
| 674 | return txtstamp64_list; |
| 675 | } |
| 676 | |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 677 | static inline void ol_tx_timestamp(ol_txrx_pdev_handle pdev, |
| 678 | qdf_nbuf_t netbuf, u_int64_t ts) |
| 679 | { |
| 680 | if (!netbuf) |
| 681 | return; |
| 682 | |
| 683 | if (pdev->ol_tx_timestamp_cb) |
| 684 | pdev->ol_tx_timestamp_cb(netbuf, ts); |
| 685 | } |
| 686 | #else |
| 687 | static inline struct htt_tx_compl_ind_append_tx_tstamp *ol_tx_get_txtstamps( |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 688 | u_int32_t *msg_word_header, u_int32_t **msg_word_payload, |
| 689 | int num_msdus) |
| 690 | { |
| 691 | return NULL; |
| 692 | } |
| 693 | |
| 694 | static inline |
| 695 | struct htt_tx_compl_ind_append_tx_tsf64 *ol_tx_get_txtstamp64s( |
| 696 | u_int32_t *msg_word_header, u_int32_t **msg_word_payload, |
| 697 | int num_msdus) |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 698 | { |
| 699 | return NULL; |
| 700 | } |
| 701 | |
| 702 | static inline void ol_tx_timestamp(ol_txrx_pdev_handle pdev, |
| 703 | qdf_nbuf_t netbuf, u_int64_t ts) |
| 704 | { |
| 705 | } |
| 706 | #endif |
| 707 | |
Alok Kumar | 75355aa | 2018-03-19 17:32:58 +0530 | [diff] [blame] | 708 | static void ol_tx_update_ack_count(struct ol_tx_desc_t *tx_desc, |
| 709 | enum htt_tx_status status) |
| 710 | { |
| 711 | if (!tx_desc->vdev) |
| 712 | return; |
| 713 | |
| 714 | if (status == htt_tx_status_ok) |
| 715 | ++tx_desc->vdev->txrx_stats.txack_success; |
| 716 | else |
| 717 | ++tx_desc->vdev->txrx_stats.txack_failed; |
| 718 | } |
Alok Kumar | 4696fb0 | 2018-06-06 00:10:18 +0530 | [diff] [blame] | 719 | |
| 720 | /** |
| 721 | * ol_tx_notify_completion() - Notify tx completion for this desc |
| 722 | * @tx_desc: tx desc |
| 723 | * @netbuf: buffer |
| 724 | * |
| 725 | * Return: none |
| 726 | */ |
| 727 | static void ol_tx_notify_completion(struct ol_tx_desc_t *tx_desc, |
| 728 | qdf_nbuf_t netbuf) |
| 729 | { |
| 730 | void *osif_dev; |
| 731 | ol_txrx_completion_fp tx_compl_cbk = NULL; |
| 732 | |
| 733 | qdf_assert(tx_desc); |
| 734 | |
| 735 | ol_tx_flow_pool_lock(tx_desc); |
| 736 | |
| 737 | if (!tx_desc->vdev || |
| 738 | !tx_desc->vdev->osif_dev) { |
| 739 | ol_tx_flow_pool_unlock(tx_desc); |
| 740 | return; |
| 741 | } |
| 742 | osif_dev = tx_desc->vdev->osif_dev; |
| 743 | tx_compl_cbk = tx_desc->vdev->tx_comp; |
| 744 | ol_tx_flow_pool_unlock(tx_desc); |
| 745 | |
| 746 | if (tx_compl_cbk) |
| 747 | tx_compl_cbk(netbuf, osif_dev); |
| 748 | } |
| 749 | |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 750 | /** |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 751 | * ol_tx_update_connectivity_stats() - update connectivity stats |
| 752 | * @tx_desc: tx desc |
| 753 | * @netbuf: buffer |
| 754 | * @status: htt status |
| 755 | * |
| 756 | * |
| 757 | * Return: none |
| 758 | */ |
| 759 | static void ol_tx_update_connectivity_stats(struct ol_tx_desc_t *tx_desc, |
| 760 | qdf_nbuf_t netbuf, |
| 761 | enum htt_tx_status status) |
| 762 | { |
| 763 | void *osif_dev; |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 764 | uint32_t pkt_type_bitmap; |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 765 | ol_txrx_stats_rx_fp stats_rx = NULL; |
| 766 | uint8_t pkt_type = 0; |
| 767 | |
| 768 | qdf_assert(tx_desc); |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 769 | |
| 770 | ol_tx_flow_pool_lock(tx_desc); |
| 771 | /* |
| 772 | * In cases when vdev has gone down and tx completion |
| 773 | * are received, leads to NULL vdev access. |
| 774 | * So, check for NULL before dereferencing it. |
| 775 | */ |
| 776 | if (!tx_desc->vdev || |
| 777 | !tx_desc->vdev->osif_dev || |
| 778 | !tx_desc->vdev->stats_rx) { |
| 779 | ol_tx_flow_pool_unlock(tx_desc); |
| 780 | return; |
| 781 | } |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 782 | osif_dev = tx_desc->vdev->osif_dev; |
| 783 | stats_rx = tx_desc->vdev->stats_rx; |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 784 | ol_tx_flow_pool_unlock(tx_desc); |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 785 | |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 786 | pkt_type_bitmap = cds_get_connectivity_stats_pkt_bitmap(osif_dev); |
| 787 | |
| 788 | if (pkt_type_bitmap) { |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 789 | if (status != htt_tx_status_download_fail) |
| 790 | stats_rx(netbuf, osif_dev, |
| 791 | PKT_TYPE_TX_HOST_FW_SENT, &pkt_type); |
| 792 | if (status == htt_tx_status_ok) |
| 793 | stats_rx(netbuf, osif_dev, |
| 794 | PKT_TYPE_TX_ACK_CNT, &pkt_type); |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | /** |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 799 | * ol_tx_update_arp_stats() - update ARP packet TX stats |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 800 | * @tx_desc: tx desc |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 801 | * @netbuf: buffer |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 802 | * @status: htt status |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 803 | * |
| 804 | * |
| 805 | * Return: none |
| 806 | */ |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 807 | static void ol_tx_update_arp_stats(struct ol_tx_desc_t *tx_desc, |
| 808 | qdf_nbuf_t netbuf, |
| 809 | enum htt_tx_status status) |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 810 | { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 811 | uint32_t tgt_ip; |
| 812 | |
| 813 | qdf_assert(tx_desc); |
Manjunathappa Prakash | 7c985c7 | 2018-04-09 18:22:11 -0700 | [diff] [blame] | 814 | |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 815 | ol_tx_flow_pool_lock(tx_desc); |
Manjunathappa Prakash | 7c985c7 | 2018-04-09 18:22:11 -0700 | [diff] [blame] | 816 | if (!tx_desc->vdev) { |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 817 | ol_tx_flow_pool_unlock(tx_desc); |
Manjunathappa Prakash | 7c985c7 | 2018-04-09 18:22:11 -0700 | [diff] [blame] | 818 | return; |
| 819 | } |
| 820 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 821 | tgt_ip = cds_get_arp_stats_gw_ip(tx_desc->vdev->osif_dev); |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 822 | ol_tx_flow_pool_unlock(tx_desc); |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 823 | |
| 824 | if (tgt_ip == qdf_nbuf_get_arp_tgt_ip(netbuf)) { |
| 825 | if (status != htt_tx_status_download_fail) |
| 826 | cds_incr_arp_stats_tx_tgt_delivered(); |
| 827 | if (status == htt_tx_status_ok) |
| 828 | cds_incr_arp_stats_tx_tgt_acked(); |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | /** |
Jeff Johnson | 3dca222 | 2018-05-12 15:10:43 -0700 | [diff] [blame] | 833 | * WARNING: ol_tx_inspect_handler()'s behavior is similar to that of |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 834 | * ol_tx_completion_handler(). |
| 835 | * any change in ol_tx_completion_handler() must be mirrored in |
| 836 | * ol_tx_inspect_handler(). |
| 837 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | void |
| 839 | ol_tx_completion_handler(ol_txrx_pdev_handle pdev, |
| 840 | int num_msdus, |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 841 | enum htt_tx_status status, void *msg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | { |
| 843 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | uint16_t tx_desc_id; |
| 845 | struct ol_tx_desc_t *tx_desc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | uint32_t byte_cnt = 0; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 847 | qdf_nbuf_t netbuf; |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 848 | #if !defined(REMOVE_PKT_LOG) |
Lin Bai | 1a73a41 | 2018-12-13 16:40:14 +0800 | [diff] [blame] | 849 | ol_txrx_pktdump_cb packetdump_cb; |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 850 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 851 | #endif |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 852 | uint32_t is_tx_desc_freed = 0; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 853 | struct htt_tx_compl_ind_append_tx_tstamp *txtstamp_list = NULL; |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 854 | struct htt_tx_compl_ind_append_tx_tsf64 *txtstamp64_list = NULL; |
| 855 | u_int32_t *msg_word_header = (u_int32_t *)msg; |
| 856 | /*msg_word skip header*/ |
| 857 | u_int32_t *msg_word_payload = msg_word_header + 1; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 858 | u_int32_t *msg_word = (u_int32_t *)msg; |
| 859 | u_int16_t *desc_ids = (u_int16_t *)(msg_word + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | union ol_tx_desc_list_elem_t *lcl_freelist = NULL; |
| 861 | union ol_tx_desc_list_elem_t *tx_desc_last = NULL; |
| 862 | ol_tx_desc_list tx_descs; |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 863 | uint64_t tx_tsf64; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 864 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 865 | TAILQ_INIT(&tx_descs); |
| 866 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 867 | ol_tx_delay_compute(pdev, status, desc_ids, num_msdus); |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 868 | if (status == htt_tx_status_ok) { |
| 869 | txtstamp_list = ol_tx_get_txtstamps( |
| 870 | msg_word_header, &msg_word_payload, num_msdus); |
| 871 | if (pdev->enable_tx_compl_tsf64) |
| 872 | txtstamp64_list = ol_tx_get_txtstamp64s( |
| 873 | msg_word_header, &msg_word_payload, num_msdus); |
| 874 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 875 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | for (i = 0; i < num_msdus; i++) { |
| 877 | tx_desc_id = desc_ids[i]; |
Alok Kumar | 88f50c1 | 2018-01-11 14:51:07 +0530 | [diff] [blame] | 878 | if (tx_desc_id >= pdev->tx_desc.pool_size) { |
| 879 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG, |
| 880 | "%s: drop due to invalid msdu id = %x\n", |
| 881 | __func__, tx_desc_id); |
| 882 | continue; |
| 883 | } |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 884 | tx_desc = ol_tx_desc_find(pdev, tx_desc_id); |
Alok Kumar | 88f50c1 | 2018-01-11 14:51:07 +0530 | [diff] [blame] | 885 | qdf_assert(tx_desc); |
Rakshith Suresh Patkar | 384a28a | 2018-11-02 16:43:43 +0530 | [diff] [blame] | 886 | ol_tx_desc_update_comp_ts(tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 887 | tx_desc->status = status; |
| 888 | netbuf = tx_desc->netbuf; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 889 | |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 890 | if (txtstamp64_list) { |
| 891 | tx_tsf64 = |
| 892 | (u_int64_t)txtstamp64_list[i].tx_tsf64_high << 32 | |
| 893 | txtstamp64_list[i].tx_tsf64_low; |
| 894 | |
| 895 | ol_tx_timestamp(pdev, netbuf, tx_tsf64); |
| 896 | } else if (txtstamp_list) |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 897 | ol_tx_timestamp(pdev, netbuf, |
| 898 | (u_int64_t)txtstamp_list->timestamp[i] |
| 899 | ); |
| 900 | |
Himanshu Agarwal | 8903461 | 2016-07-19 15:59:52 +0530 | [diff] [blame] | 901 | QDF_NBUF_UPDATE_TX_PKT_COUNT(netbuf, QDF_NBUF_TX_PKT_FREE); |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 902 | |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 903 | if (QDF_NBUF_CB_GET_PACKET_TYPE(netbuf) == |
| 904 | QDF_NBUF_CB_PACKET_TYPE_ARP) { |
| 905 | if (qdf_nbuf_data_is_arp_req(netbuf)) |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 906 | ol_tx_update_arp_stats(tx_desc, netbuf, |
| 907 | status); |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 908 | } |
| 909 | |
Alok Kumar | 4696fb0 | 2018-06-06 00:10:18 +0530 | [diff] [blame] | 910 | /* check tx completion notification */ |
| 911 | if (QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(netbuf)) |
| 912 | ol_tx_notify_completion(tx_desc, netbuf); |
| 913 | |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 914 | /* track connectivity stats */ |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 915 | ol_tx_update_connectivity_stats(tx_desc, netbuf, |
| 916 | status); |
Alok Kumar | 75355aa | 2018-03-19 17:32:58 +0530 | [diff] [blame] | 917 | ol_tx_update_ack_count(tx_desc, status); |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 918 | |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 919 | #if !defined(REMOVE_PKT_LOG) |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 920 | if (tx_desc->pkt_type != OL_TX_FRM_TSO) { |
Himanshu Agarwal | bb226bc | 2017-01-18 20:45:01 +0530 | [diff] [blame] | 921 | packetdump_cb = pdev->ol_tx_packetdump_cb; |
| 922 | if (packetdump_cb) |
Rakesh Pillai | 6a36b0a | 2019-09-06 16:30:05 +0530 | [diff] [blame] | 923 | packetdump_cb(soc, pdev->id, |
| 924 | tx_desc->vdev_id, |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 925 | netbuf, status, TX_DATA_PKT); |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 926 | } |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 927 | #endif |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 928 | |
Nirav Shah | 07e39a6 | 2016-04-25 17:46:40 +0530 | [diff] [blame] | 929 | DPTRACE(qdf_dp_trace_ptr(netbuf, |
| 930 | QDF_DP_TRACE_FREE_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 931 | QDF_TRACE_DEFAULT_PDEV_ID, |
Nirav Shah | 07e39a6 | 2016-04-25 17:46:40 +0530 | [diff] [blame] | 932 | qdf_nbuf_data_addr(netbuf), |
| 933 | sizeof(qdf_nbuf_data(netbuf)), tx_desc->id, status)); |
Houston Hoffman | c2c4762 | 2016-07-12 13:05:31 -0700 | [diff] [blame] | 934 | htc_pm_runtime_put(pdev->htt_pdev->htc_pdev); |
Ajit Pal Singh | c31d101 | 2018-06-07 19:47:22 +0530 | [diff] [blame] | 935 | /* |
| 936 | * If credits are reported through credit_update_ind then do not |
| 937 | * update group credits on tx_complete_ind. |
| 938 | */ |
| 939 | if (!pdev->cfg.credit_update_enabled) |
| 940 | ol_tx_desc_update_group_credit(pdev, |
| 941 | tx_desc_id, |
| 942 | 1, 0, status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 943 | /* Per SDU update of byte count */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 944 | byte_cnt += qdf_nbuf_len(netbuf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | if (OL_TX_DESC_NO_REFS(tx_desc)) { |
| 946 | ol_tx_statistics( |
| 947 | pdev->ctrl_pdev, |
| 948 | HTT_TX_DESC_VDEV_ID_GET(*((uint32_t *) |
| 949 | (tx_desc-> |
| 950 | htt_tx_desc))), |
| 951 | status != htt_tx_status_ok); |
| 952 | ol_tx_msdu_complete(pdev, tx_desc, tx_descs, netbuf, |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 953 | lcl_freelist, tx_desc_last, status, |
| 954 | is_tx_desc_freed); |
| 955 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 956 | #ifdef QCA_SUPPORT_TXDESC_SANITY_CHECKS |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 957 | if (!is_tx_desc_freed) { |
| 958 | tx_desc->pkt_type = ol_tx_frm_freed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 959 | #ifdef QCA_COMPUTE_TX_DELAY |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 960 | tx_desc->entry_timestamp_ticks = 0xffffffff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 961 | #endif |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 962 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 963 | #endif |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 964 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | /* One shot protected access to pdev freelist, when setup */ |
| 968 | if (lcl_freelist) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 969 | qdf_spin_lock(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | tx_desc_last->next = pdev->tx_desc.freelist; |
| 971 | pdev->tx_desc.freelist = lcl_freelist; |
| 972 | pdev->tx_desc.num_free += (uint16_t) num_msdus; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 973 | qdf_spin_unlock(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | } else { |
| 975 | ol_tx_desc_frame_list_free(pdev, &tx_descs, |
| 976 | status != htt_tx_status_ok); |
| 977 | } |
| 978 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 979 | if (pdev->cfg.is_high_latency) { |
| 980 | /* |
| 981 | * Credit was already explicitly updated by HTT, |
| 982 | * but update the number of available tx descriptors, |
| 983 | * then invoke the scheduler, since new credit is probably |
| 984 | * available now. |
| 985 | */ |
| 986 | qdf_atomic_add(num_msdus, &pdev->tx_queue.rsrc_cnt); |
| 987 | ol_tx_sched(pdev); |
| 988 | } else { |
| 989 | ol_tx_target_credit_adjust(num_msdus, pdev, NULL); |
| 990 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 991 | |
| 992 | /* UNPAUSE OS Q */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 993 | ol_tx_flow_ct_unpause_os_q(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | /* Do one shot statistics */ |
| 995 | TXRX_STATS_UPDATE_TX_STATS(pdev, status, num_msdus, byte_cnt); |
| 996 | } |
| 997 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 998 | #ifdef FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL |
| 999 | |
| 1000 | void ol_tx_desc_update_group_credit(ol_txrx_pdev_handle pdev, |
| 1001 | u_int16_t tx_desc_id, int credit, u_int8_t absolute, |
| 1002 | enum htt_tx_status status) |
| 1003 | { |
| 1004 | uint8_t i, is_member; |
| 1005 | uint16_t vdev_id_mask; |
| 1006 | struct ol_tx_desc_t *tx_desc; |
| 1007 | |
Sravan Kumar Kairam | 2be2792 | 2018-05-09 17:16:12 +0530 | [diff] [blame] | 1008 | if (tx_desc_id >= pdev->tx_desc.pool_size) { |
Nirav Shah | 7c8c171 | 2018-09-10 16:01:31 +0530 | [diff] [blame] | 1009 | qdf_print("Invalid desc id"); |
Sravan Kumar Kairam | 2be2792 | 2018-05-09 17:16:12 +0530 | [diff] [blame] | 1010 | return; |
| 1011 | } |
| 1012 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1013 | tx_desc = ol_tx_desc_find(pdev, tx_desc_id); |
| 1014 | for (i = 0; i < OL_TX_MAX_TXQ_GROUPS; i++) { |
| 1015 | vdev_id_mask = |
| 1016 | OL_TXQ_GROUP_VDEV_ID_MASK_GET( |
| 1017 | pdev->txq_grps[i].membership); |
| 1018 | is_member = OL_TXQ_GROUP_VDEV_ID_BIT_MASK_GET(vdev_id_mask, |
gbian | 016a42e | 2017-03-01 18:49:11 +0800 | [diff] [blame] | 1019 | tx_desc->vdev_id); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1020 | if (is_member) { |
| 1021 | ol_txrx_update_group_credit(&pdev->txq_grps[i], |
| 1022 | credit, absolute); |
| 1023 | break; |
| 1024 | } |
| 1025 | } |
| 1026 | ol_tx_update_group_credit_stats(pdev); |
| 1027 | } |
| 1028 | |
Ajit Pal Singh | 407d6d8 | 2019-08-02 23:50:35 +0530 | [diff] [blame] | 1029 | void ol_tx_deduct_one_any_group_credit(ol_txrx_pdev_handle pdev) |
| 1030 | { |
| 1031 | int credits_group_0, credits_group_1; |
| 1032 | |
| 1033 | qdf_spin_lock_bh(&pdev->tx_queue_spinlock); |
| 1034 | credits_group_0 = qdf_atomic_read(&pdev->txq_grps[0].credit); |
| 1035 | credits_group_1 = qdf_atomic_read(&pdev->txq_grps[1].credit); |
| 1036 | |
| 1037 | if (credits_group_0 > credits_group_1) |
| 1038 | ol_txrx_update_group_credit(&pdev->txq_grps[0], -1, 0); |
| 1039 | else if (credits_group_1 != 0) |
| 1040 | ol_txrx_update_group_credit(&pdev->txq_grps[1], -1, 0); |
| 1041 | |
| 1042 | qdf_spin_unlock_bh(&pdev->tx_queue_spinlock); |
| 1043 | } |
| 1044 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1045 | #ifdef DEBUG_HL_LOGGING |
| 1046 | |
| 1047 | void ol_tx_update_group_credit_stats(ol_txrx_pdev_handle pdev) |
| 1048 | { |
| 1049 | uint16_t curr_index; |
| 1050 | uint8_t i; |
| 1051 | |
| 1052 | qdf_spin_lock_bh(&pdev->grp_stat_spinlock); |
| 1053 | pdev->grp_stats.last_valid_index++; |
| 1054 | if (pdev->grp_stats.last_valid_index > (OL_TX_GROUP_STATS_LOG_SIZE |
| 1055 | - 1)) { |
| 1056 | pdev->grp_stats.last_valid_index -= OL_TX_GROUP_STATS_LOG_SIZE; |
| 1057 | pdev->grp_stats.wrap_around = 1; |
| 1058 | } |
| 1059 | curr_index = pdev->grp_stats.last_valid_index; |
| 1060 | |
| 1061 | for (i = 0; i < OL_TX_MAX_TXQ_GROUPS; i++) { |
| 1062 | pdev->grp_stats.stats[curr_index].grp[i].member_vdevs = |
| 1063 | OL_TXQ_GROUP_VDEV_ID_MASK_GET( |
| 1064 | pdev->txq_grps[i].membership); |
| 1065 | pdev->grp_stats.stats[curr_index].grp[i].credit = |
| 1066 | qdf_atomic_read(&pdev->txq_grps[i].credit); |
| 1067 | } |
| 1068 | |
| 1069 | qdf_spin_unlock_bh(&pdev->grp_stat_spinlock); |
| 1070 | } |
| 1071 | |
| 1072 | void ol_tx_dump_group_credit_stats(ol_txrx_pdev_handle pdev) |
| 1073 | { |
| 1074 | uint16_t i, j, is_break = 0; |
| 1075 | int16_t curr_index, old_index, wrap_around; |
bings | 39e70db | 2019-07-23 18:16:23 +0800 | [diff] [blame] | 1076 | uint16_t curr_credit, mem_vdevs; |
| 1077 | uint16_t old_credit = 0; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1078 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 1079 | txrx_nofl_info("Group credit stats:"); |
| 1080 | txrx_nofl_info(" No: GrpID: Credit: Change: vdev_map"); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1081 | |
| 1082 | qdf_spin_lock_bh(&pdev->grp_stat_spinlock); |
| 1083 | curr_index = pdev->grp_stats.last_valid_index; |
| 1084 | wrap_around = pdev->grp_stats.wrap_around; |
| 1085 | qdf_spin_unlock_bh(&pdev->grp_stat_spinlock); |
| 1086 | |
| 1087 | if (curr_index < 0) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 1088 | txrx_nofl_info("Not initialized"); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1089 | return; |
| 1090 | } |
| 1091 | |
| 1092 | for (i = 0; i < OL_TX_GROUP_STATS_LOG_SIZE; i++) { |
| 1093 | old_index = curr_index - 1; |
| 1094 | if (old_index < 0) { |
| 1095 | if (wrap_around == 0) |
| 1096 | is_break = 1; |
| 1097 | else |
| 1098 | old_index = OL_TX_GROUP_STATS_LOG_SIZE - 1; |
| 1099 | } |
| 1100 | |
| 1101 | for (j = 0; j < OL_TX_MAX_TXQ_GROUPS; j++) { |
| 1102 | qdf_spin_lock_bh(&pdev->grp_stat_spinlock); |
| 1103 | curr_credit = |
| 1104 | pdev->grp_stats.stats[curr_index]. |
| 1105 | grp[j].credit; |
| 1106 | if (!is_break) |
| 1107 | old_credit = |
| 1108 | pdev->grp_stats.stats[old_index]. |
| 1109 | grp[j].credit; |
| 1110 | |
| 1111 | mem_vdevs = |
| 1112 | pdev->grp_stats.stats[curr_index].grp[j]. |
| 1113 | member_vdevs; |
| 1114 | qdf_spin_unlock_bh(&pdev->grp_stat_spinlock); |
| 1115 | |
| 1116 | if (!is_break) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 1117 | txrx_nofl_info("%4d: %5d: %6d %6d %8x", |
| 1118 | curr_index, j, |
| 1119 | curr_credit, |
| 1120 | (curr_credit - old_credit), |
| 1121 | mem_vdevs); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1122 | else |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 1123 | txrx_nofl_info("%4d: %5d: %6d %6s %8x", |
| 1124 | curr_index, j, |
| 1125 | curr_credit, "NA", mem_vdevs); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | if (is_break) |
| 1129 | break; |
| 1130 | |
| 1131 | curr_index = old_index; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | void ol_tx_clear_group_credit_stats(ol_txrx_pdev_handle pdev) |
| 1136 | { |
| 1137 | qdf_spin_lock_bh(&pdev->grp_stat_spinlock); |
| 1138 | qdf_mem_zero(&pdev->grp_stats, sizeof(pdev->grp_stats)); |
| 1139 | pdev->grp_stats.last_valid_index = -1; |
| 1140 | pdev->grp_stats.wrap_around = 0; |
| 1141 | qdf_spin_unlock_bh(&pdev->grp_stat_spinlock); |
| 1142 | } |
| 1143 | #endif |
| 1144 | #endif |
| 1145 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1146 | /* |
| 1147 | * ol_tx_single_completion_handler performs the same tx completion |
| 1148 | * processing as ol_tx_completion_handler, but for a single frame. |
| 1149 | * ol_tx_completion_handler is optimized to handle batch completions |
| 1150 | * as efficiently as possible; in contrast ol_tx_single_completion_handler |
| 1151 | * handles single frames as simply and generally as possible. |
| 1152 | * Thus, this ol_tx_single_completion_handler function is suitable for |
| 1153 | * intermittent usage, such as for tx mgmt frames. |
| 1154 | */ |
| 1155 | void |
| 1156 | ol_tx_single_completion_handler(ol_txrx_pdev_handle pdev, |
| 1157 | enum htt_tx_status status, uint16_t tx_desc_id) |
| 1158 | { |
| 1159 | struct ol_tx_desc_t *tx_desc; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1160 | qdf_nbuf_t netbuf; |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 1161 | #if !defined(REMOVE_PKT_LOG) |
Lin Bai | 1a73a41 | 2018-12-13 16:40:14 +0800 | [diff] [blame] | 1162 | ol_txrx_pktdump_cb packetdump_cb; |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 1163 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1164 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1166 | tx_desc = ol_tx_desc_find_check(pdev, tx_desc_id); |
Jeff Johnson | 6795c3a | 2019-03-18 13:43:04 -0700 | [diff] [blame] | 1167 | if (!tx_desc) { |
Nirav Shah | 7c8c171 | 2018-09-10 16:01:31 +0530 | [diff] [blame] | 1168 | ol_txrx_err("invalid desc_id(%u), ignore it", tx_desc_id); |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1169 | return; |
| 1170 | } |
| 1171 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | tx_desc->status = status; |
| 1173 | netbuf = tx_desc->netbuf; |
| 1174 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1175 | QDF_NBUF_UPDATE_TX_PKT_COUNT(netbuf, QDF_NBUF_TX_PKT_FREE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1176 | /* Do one shot statistics */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1177 | TXRX_STATS_UPDATE_TX_STATS(pdev, status, 1, qdf_nbuf_len(netbuf)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1178 | |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 1179 | #if !defined(REMOVE_PKT_LOG) |
Himanshu Agarwal | bb226bc | 2017-01-18 20:45:01 +0530 | [diff] [blame] | 1180 | packetdump_cb = pdev->ol_tx_packetdump_cb; |
| 1181 | if (packetdump_cb) |
Rakesh Pillai | 6a36b0a | 2019-09-06 16:30:05 +0530 | [diff] [blame] | 1182 | packetdump_cb(soc, pdev->id, tx_desc->vdev_id, |
Jingxiang Ge | bd540b1 | 2019-03-13 14:58:52 +0800 | [diff] [blame] | 1183 | netbuf, status, TX_MGMT_PKT); |
| 1184 | #endif |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 1185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1186 | if (OL_TX_DESC_NO_REFS(tx_desc)) { |
| 1187 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, |
| 1188 | status != htt_tx_status_ok); |
| 1189 | } |
| 1190 | |
| 1191 | TX_CREDIT_DEBUG_PRINT(" <HTT> Increase credit %d + %d = %d\n", |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1192 | qdf_atomic_read(&pdev->target_tx_credit), |
| 1193 | 1, qdf_atomic_read(&pdev->target_tx_credit) + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1194 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1195 | if (pdev->cfg.is_high_latency) { |
| 1196 | /* |
| 1197 | * Credit was already explicitly updated by HTT, |
| 1198 | * but update the number of available tx descriptors, |
| 1199 | * then invoke the scheduler, since new credit is probably |
| 1200 | * available now. |
| 1201 | */ |
| 1202 | qdf_atomic_add(1, &pdev->tx_queue.rsrc_cnt); |
| 1203 | ol_tx_sched(pdev); |
| 1204 | } else { |
| 1205 | qdf_atomic_add(1, &pdev->target_tx_credit); |
| 1206 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | } |
| 1208 | |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1209 | /** |
Jeff Johnson | 3dca222 | 2018-05-12 15:10:43 -0700 | [diff] [blame] | 1210 | * WARNING: ol_tx_inspect_handler()'s behavior is similar to that of |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1211 | * ol_tx_completion_handler(). |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | * any change in ol_tx_completion_handler() must be mirrored here. |
| 1213 | */ |
| 1214 | void |
| 1215 | ol_tx_inspect_handler(ol_txrx_pdev_handle pdev, |
| 1216 | int num_msdus, void *tx_desc_id_iterator) |
| 1217 | { |
| 1218 | uint16_t vdev_id, i; |
| 1219 | struct ol_txrx_vdev_t *vdev; |
| 1220 | uint16_t *desc_ids = (uint16_t *) tx_desc_id_iterator; |
| 1221 | uint16_t tx_desc_id; |
| 1222 | struct ol_tx_desc_t *tx_desc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | union ol_tx_desc_list_elem_t *lcl_freelist = NULL; |
| 1224 | union ol_tx_desc_list_elem_t *tx_desc_last = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1225 | qdf_nbuf_t netbuf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | ol_tx_desc_list tx_descs; |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 1227 | uint32_t is_tx_desc_freed = 0; |
| 1228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | TAILQ_INIT(&tx_descs); |
| 1230 | |
| 1231 | for (i = 0; i < num_msdus; i++) { |
| 1232 | tx_desc_id = desc_ids[i]; |
Alok Kumar | 88f50c1 | 2018-01-11 14:51:07 +0530 | [diff] [blame] | 1233 | if (tx_desc_id >= pdev->tx_desc.pool_size) { |
| 1234 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG, |
| 1235 | "%s: drop due to invalid msdu id = %x\n", |
| 1236 | __func__, tx_desc_id); |
| 1237 | continue; |
| 1238 | } |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1239 | tx_desc = ol_tx_desc_find(pdev, tx_desc_id); |
Alok Kumar | 88f50c1 | 2018-01-11 14:51:07 +0530 | [diff] [blame] | 1240 | qdf_assert(tx_desc); |
Rakshith Suresh Patkar | 384a28a | 2018-11-02 16:43:43 +0530 | [diff] [blame] | 1241 | ol_tx_desc_update_comp_ts(tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | netbuf = tx_desc->netbuf; |
| 1243 | |
| 1244 | /* find the "vdev" this tx_desc belongs to */ |
| 1245 | vdev_id = HTT_TX_DESC_VDEV_ID_GET(*((uint32_t *) |
| 1246 | (tx_desc->htt_tx_desc))); |
| 1247 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 1248 | if (vdev->vdev_id == vdev_id) |
| 1249 | break; |
| 1250 | } |
| 1251 | |
| 1252 | /* vdev now points to the vdev for this descriptor. */ |
| 1253 | |
| 1254 | #ifndef ATH_11AC_TXCOMPACT |
| 1255 | /* save this multicast packet to local free list */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1256 | if (qdf_atomic_dec_and_test(&tx_desc->ref_cnt)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1257 | #endif |
| 1258 | { |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1259 | /* |
| 1260 | * For this function only, force htt status to be |
| 1261 | * "htt_tx_status_ok" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | * for graceful freeing of this multicast frame |
| 1263 | */ |
| 1264 | ol_tx_msdu_complete(pdev, tx_desc, tx_descs, netbuf, |
| 1265 | lcl_freelist, tx_desc_last, |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 1266 | htt_tx_status_ok, |
| 1267 | is_tx_desc_freed); |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1268 | #ifdef QCA_SUPPORT_TXDESC_SANITY_CHECKS |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 1269 | if (!is_tx_desc_freed) { |
| 1270 | tx_desc->pkt_type = ol_tx_frm_freed; |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1271 | #ifdef QCA_COMPUTE_TX_DELAY |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 1272 | tx_desc->entry_timestamp_ticks = 0xffffffff; |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1273 | #endif |
gbian | 1bd297c | 2016-12-07 11:12:29 +0800 | [diff] [blame] | 1274 | } |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame] | 1275 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | if (lcl_freelist) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1280 | qdf_spin_lock(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1281 | tx_desc_last->next = pdev->tx_desc.freelist; |
| 1282 | pdev->tx_desc.freelist = lcl_freelist; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1283 | qdf_spin_unlock(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1284 | } else { |
| 1285 | ol_tx_desc_frame_list_free(pdev, &tx_descs, |
| 1286 | htt_tx_status_discard); |
| 1287 | } |
| 1288 | TX_CREDIT_DEBUG_PRINT(" <HTT> Increase HTT credit %d + %d = %d..\n", |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1289 | qdf_atomic_read(&pdev->target_tx_credit), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1290 | num_msdus, |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1291 | qdf_atomic_read(&pdev->target_tx_credit) + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1292 | num_msdus); |
| 1293 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1294 | if (pdev->cfg.is_high_latency) { |
| 1295 | /* credit was already explicitly updated by HTT */ |
| 1296 | ol_tx_sched(pdev); |
| 1297 | } else { |
| 1298 | ol_tx_target_credit_adjust(num_msdus, pdev, NULL); |
| 1299 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | #ifdef QCA_COMPUTE_TX_DELAY |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 1303 | /** |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1304 | * ol_tx_set_compute_interval - updates the compute interval |
| 1305 | * period for TSM stats. |
| 1306 | * @soc_hdl: Datapath soc handle |
| 1307 | * @pdev_id: id of data path pdev handle |
| 1308 | * @param interval: interval for stats computation |
| 1309 | * |
| 1310 | * Return: None |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 1311 | */ |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1312 | void ol_tx_set_compute_interval(struct cdp_soc_t *soc_hdl, |
| 1313 | uint8_t pdev_id, uint32_t interval) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1314 | { |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1315 | struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl); |
| 1316 | ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id); |
| 1317 | |
| 1318 | if (!pdev) { |
| 1319 | ol_txrx_err("pdev is NULL"); |
| 1320 | return; |
| 1321 | } |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 1322 | |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1323 | pdev->tx_delay.avg_period_ticks = qdf_system_msecs_to_ticks(interval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1324 | } |
| 1325 | |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 1326 | /** |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1327 | * ol_tx_packet_count() - Return the uplink (transmitted) packet count |
| 1328 | and loss count. |
| 1329 | * @soc_hdl: soc handle |
| 1330 | * @pdev_id: pdev identifier |
| 1331 | * @out_packet_count - number of packets transmitted |
| 1332 | * @out_packet_loss_count - number of packets lost |
| 1333 | * @category - access category of interest |
| 1334 | * |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 1335 | * This function will be called for getting uplink packet count and |
| 1336 | * loss count for given stream (access category) a regular interval. |
| 1337 | * This also resets the counters hence, the value returned is packets |
| 1338 | * counted in last 5(default) second interval. These counter are |
| 1339 | * incremented per access category in ol_tx_completion_handler() |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 1340 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1341 | void |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1342 | ol_tx_packet_count(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1343 | uint16_t *out_packet_count, |
| 1344 | uint16_t *out_packet_loss_count, int category) |
| 1345 | { |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1346 | struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl); |
| 1347 | ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id); |
| 1348 | |
| 1349 | if (!pdev) { |
| 1350 | ol_txrx_err("pdev is NULL"); |
| 1351 | return; |
| 1352 | } |
| 1353 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1354 | *out_packet_count = pdev->packet_count[category]; |
| 1355 | *out_packet_loss_count = pdev->packet_loss_count[category]; |
| 1356 | pdev->packet_count[category] = 0; |
| 1357 | pdev->packet_loss_count[category] = 0; |
| 1358 | } |
| 1359 | |
Jeff Johnson | f89f58f | 2016-10-14 09:58:29 -0700 | [diff] [blame] | 1360 | static uint32_t ol_tx_delay_avg(uint64_t sum, uint32_t num) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | { |
| 1362 | uint32_t sum32; |
| 1363 | int shift = 0; |
| 1364 | /* |
| 1365 | * To avoid doing a 64-bit divide, shift the sum down until it is |
| 1366 | * no more than 32 bits (and shift the denominator to match). |
| 1367 | */ |
| 1368 | while ((sum >> 32) != 0) { |
| 1369 | sum >>= 1; |
| 1370 | shift++; |
| 1371 | } |
| 1372 | sum32 = (uint32_t) sum; |
| 1373 | num >>= shift; |
| 1374 | return (sum32 + (num >> 1)) / num; /* round to nearest */ |
| 1375 | } |
| 1376 | |
| 1377 | void |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1378 | ol_tx_delay(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1379 | uint32_t *queue_delay_microsec, |
| 1380 | uint32_t *tx_delay_microsec, int category) |
| 1381 | { |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1382 | struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl); |
| 1383 | ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1384 | int index; |
| 1385 | uint32_t avg_delay_ticks; |
| 1386 | struct ol_tx_delay_data *data; |
| 1387 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1388 | qdf_assert(category >= 0 && category < QCA_TX_DELAY_NUM_CATEGORIES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1389 | |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1390 | if (!pdev) { |
| 1391 | ol_txrx_err("pdev is NULL"); |
| 1392 | return; |
| 1393 | } |
| 1394 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1395 | qdf_spin_lock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1396 | index = 1 - pdev->tx_delay.cats[category].in_progress_idx; |
| 1397 | |
| 1398 | data = &pdev->tx_delay.cats[category].copies[index]; |
| 1399 | |
| 1400 | if (data->avgs.transmit_num > 0) { |
| 1401 | avg_delay_ticks = |
| 1402 | ol_tx_delay_avg(data->avgs.transmit_sum_ticks, |
| 1403 | data->avgs.transmit_num); |
| 1404 | *tx_delay_microsec = |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1405 | qdf_system_ticks_to_msecs(avg_delay_ticks * 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1406 | } else { |
| 1407 | /* |
| 1408 | * This case should only happen if there's a query |
| 1409 | * within 5 sec after the first tx data frame. |
| 1410 | */ |
| 1411 | *tx_delay_microsec = 0; |
| 1412 | } |
| 1413 | if (data->avgs.queue_num > 0) { |
| 1414 | avg_delay_ticks = |
| 1415 | ol_tx_delay_avg(data->avgs.queue_sum_ticks, |
| 1416 | data->avgs.queue_num); |
| 1417 | *queue_delay_microsec = |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1418 | qdf_system_ticks_to_msecs(avg_delay_ticks * 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1419 | } else { |
| 1420 | /* |
| 1421 | * This case should only happen if there's a query |
| 1422 | * within 5 sec after the first tx data frame. |
| 1423 | */ |
| 1424 | *queue_delay_microsec = 0; |
| 1425 | } |
| 1426 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1427 | qdf_spin_unlock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | void |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1431 | ol_tx_delay_hist(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1432 | uint16_t *report_bin_values, int category) |
| 1433 | { |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1434 | struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl); |
| 1435 | ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | int index, i, j; |
| 1437 | struct ol_tx_delay_data *data; |
| 1438 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1439 | qdf_assert(category >= 0 && category < QCA_TX_DELAY_NUM_CATEGORIES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | |
Rakesh Pillai | ef35fab | 2019-07-04 20:13:09 +0530 | [diff] [blame] | 1441 | if (!pdev) { |
| 1442 | ol_txrx_err("pdev is NULL"); |
| 1443 | return; |
| 1444 | } |
| 1445 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1446 | qdf_spin_lock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1447 | index = 1 - pdev->tx_delay.cats[category].in_progress_idx; |
| 1448 | |
| 1449 | data = &pdev->tx_delay.cats[category].copies[index]; |
| 1450 | |
| 1451 | for (i = 0, j = 0; i < QCA_TX_DELAY_HIST_REPORT_BINS - 1; i++) { |
| 1452 | uint16_t internal_bin_sum = 0; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1453 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | while (j < (1 << i)) |
| 1455 | internal_bin_sum += data->hist_bins_queue[j++]; |
| 1456 | |
| 1457 | report_bin_values[i] = internal_bin_sum; |
| 1458 | } |
| 1459 | report_bin_values[i] = data->hist_bins_queue[j]; /* overflow */ |
| 1460 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1461 | qdf_spin_unlock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | #ifdef QCA_COMPUTE_TX_DELAY_PER_TID |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | static uint8_t |
| 1466 | ol_tx_delay_tid_from_l3_hdr(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1467 | qdf_nbuf_t msdu, struct ol_tx_desc_t *tx_desc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | { |
| 1469 | uint16_t ethertype; |
| 1470 | uint8_t *dest_addr, *l3_hdr; |
| 1471 | int is_mgmt, is_mcast; |
| 1472 | int l2_hdr_size; |
| 1473 | |
| 1474 | dest_addr = ol_tx_dest_addr_find(pdev, msdu); |
Jeff Johnson | 6795c3a | 2019-03-18 13:43:04 -0700 | [diff] [blame] | 1475 | if (!dest_addr) |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 1476 | return QDF_NBUF_TX_EXT_TID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1477 | |
| 1478 | is_mcast = IEEE80211_IS_MULTICAST(dest_addr); |
| 1479 | is_mgmt = tx_desc->pkt_type >= OL_TXRX_MGMT_TYPE_BASE; |
| 1480 | if (is_mgmt) { |
| 1481 | return (is_mcast) ? |
| 1482 | OL_TX_NUM_TIDS + OL_TX_VDEV_DEFAULT_MGMT : |
| 1483 | HTT_TX_EXT_TID_MGMT; |
| 1484 | } |
| 1485 | if (is_mcast) |
| 1486 | return OL_TX_NUM_TIDS + OL_TX_VDEV_MCAST_BCAST; |
| 1487 | |
| 1488 | if (pdev->frame_format == wlan_frm_fmt_802_3) { |
| 1489 | struct ethernet_hdr_t *enet_hdr; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1490 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1491 | enet_hdr = (struct ethernet_hdr_t *)qdf_nbuf_data(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | l2_hdr_size = sizeof(struct ethernet_hdr_t); |
| 1493 | ethertype = |
| 1494 | (enet_hdr->ethertype[0] << 8) | enet_hdr->ethertype[1]; |
| 1495 | if (!IS_ETHERTYPE(ethertype)) { |
| 1496 | struct llc_snap_hdr_t *llc_hdr; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1497 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | llc_hdr = (struct llc_snap_hdr_t *) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1499 | (qdf_nbuf_data(msdu) + l2_hdr_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | l2_hdr_size += sizeof(struct llc_snap_hdr_t); |
| 1501 | ethertype = |
| 1502 | (llc_hdr->ethertype[0] << 8) | llc_hdr-> |
| 1503 | ethertype[1]; |
| 1504 | } |
| 1505 | } else { |
| 1506 | struct llc_snap_hdr_t *llc_hdr; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1508 | l2_hdr_size = sizeof(struct ieee80211_frame); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1509 | llc_hdr = (struct llc_snap_hdr_t *)(qdf_nbuf_data(msdu) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | + l2_hdr_size); |
| 1511 | l2_hdr_size += sizeof(struct llc_snap_hdr_t); |
| 1512 | ethertype = |
| 1513 | (llc_hdr->ethertype[0] << 8) | llc_hdr->ethertype[1]; |
| 1514 | } |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1515 | l3_hdr = qdf_nbuf_data(msdu) + l2_hdr_size; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | if (ETHERTYPE_IPV4 == ethertype) { |
| 1517 | return (((struct ipv4_hdr_t *)l3_hdr)->tos >> 5) & 0x7; |
| 1518 | } else if (ETHERTYPE_IPV6 == ethertype) { |
| 1519 | return (ipv6_traffic_class((struct ipv6_hdr_t *)l3_hdr) >> 5) & |
| 1520 | 0x7; |
| 1521 | } else { |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 1522 | return QDF_NBUF_TX_EXT_TID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | } |
| 1524 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1525 | |
| 1526 | static int ol_tx_delay_category(struct ol_txrx_pdev_t *pdev, uint16_t msdu_id) |
| 1527 | { |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1528 | struct ol_tx_desc_t *tx_desc = ol_tx_desc_find(pdev, msdu_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | uint8_t tid; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1530 | qdf_nbuf_t msdu = tx_desc->netbuf; |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1531 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1532 | tid = qdf_nbuf_get_tid(msdu); |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 1533 | if (tid == QDF_NBUF_TX_EXT_TID_INVALID) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1534 | tid = ol_tx_delay_tid_from_l3_hdr(pdev, msdu, tx_desc); |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 1535 | if (tid == QDF_NBUF_TX_EXT_TID_INVALID) { |
Yun Park | f967715 | 2017-04-08 13:29:34 -0700 | [diff] [blame] | 1536 | /* |
| 1537 | * TID could not be determined |
| 1538 | * (this is not an IP frame?) |
| 1539 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1540 | return -EINVAL; |
| 1541 | } |
| 1542 | } |
| 1543 | return tid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | } |
Nirav Shah | 52d85aa | 2018-04-26 14:03:00 +0530 | [diff] [blame] | 1545 | #else |
| 1546 | static int ol_tx_delay_category(struct ol_txrx_pdev_t *pdev, uint16_t msdu_id) |
| 1547 | { |
| 1548 | return 0; |
| 1549 | } |
| 1550 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1551 | |
| 1552 | static inline int |
| 1553 | ol_tx_delay_hist_bin(struct ol_txrx_pdev_t *pdev, uint32_t delay_ticks) |
| 1554 | { |
| 1555 | int bin; |
| 1556 | /* |
| 1557 | * For speed, multiply and shift to approximate a divide. This causes |
| 1558 | * a small error, but the approximation error should be much less |
| 1559 | * than the other uncertainties in the tx delay computation. |
| 1560 | */ |
| 1561 | bin = (delay_ticks * pdev->tx_delay.hist_internal_bin_width_mult) >> |
| 1562 | pdev->tx_delay.hist_internal_bin_width_shift; |
| 1563 | if (bin >= QCA_TX_DELAY_HIST_INTERNAL_BINS) |
| 1564 | bin = QCA_TX_DELAY_HIST_INTERNAL_BINS - 1; |
| 1565 | |
| 1566 | return bin; |
| 1567 | } |
| 1568 | |
| 1569 | static void |
| 1570 | ol_tx_delay_compute(struct ol_txrx_pdev_t *pdev, |
| 1571 | enum htt_tx_status status, |
| 1572 | uint16_t *desc_ids, int num_msdus) |
| 1573 | { |
| 1574 | int i, index, cat; |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1575 | uint32_t now_ticks = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1576 | uint32_t tx_delay_transmit_ticks, tx_delay_queue_ticks; |
| 1577 | uint32_t avg_time_ticks; |
| 1578 | struct ol_tx_delay_data *data; |
| 1579 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1580 | qdf_assert(num_msdus > 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
| 1582 | /* |
| 1583 | * keep static counters for total packet and lost packets |
| 1584 | * reset them in ol_tx_delay(), function used to fetch the stats |
| 1585 | */ |
| 1586 | |
| 1587 | cat = ol_tx_delay_category(pdev, desc_ids[0]); |
| 1588 | if (cat < 0 || cat >= QCA_TX_DELAY_NUM_CATEGORIES) |
| 1589 | return; |
| 1590 | |
| 1591 | pdev->packet_count[cat] = pdev->packet_count[cat] + num_msdus; |
| 1592 | if (status != htt_tx_status_ok) { |
| 1593 | for (i = 0; i < num_msdus; i++) { |
| 1594 | cat = ol_tx_delay_category(pdev, desc_ids[i]); |
| 1595 | if (cat < 0 || cat >= QCA_TX_DELAY_NUM_CATEGORIES) |
| 1596 | return; |
| 1597 | pdev->packet_loss_count[cat]++; |
| 1598 | } |
| 1599 | return; |
| 1600 | } |
| 1601 | |
| 1602 | /* since we may switch the ping-pong index, provide mutex w. readers */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1603 | qdf_spin_lock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | index = pdev->tx_delay.cats[cat].in_progress_idx; |
| 1605 | |
| 1606 | data = &pdev->tx_delay.cats[cat].copies[index]; |
| 1607 | |
| 1608 | if (pdev->tx_delay.tx_compl_timestamp_ticks != 0) { |
| 1609 | tx_delay_transmit_ticks = |
| 1610 | now_ticks - pdev->tx_delay.tx_compl_timestamp_ticks; |
| 1611 | /* |
| 1612 | * We'd like to account for the number of MSDUs that were |
| 1613 | * transmitted together, but we don't know this. All we know |
| 1614 | * is the number of MSDUs that were acked together. |
| 1615 | * Since the frame error rate is small, this is nearly the same |
| 1616 | * as the number of frames transmitted together. |
| 1617 | */ |
| 1618 | data->avgs.transmit_sum_ticks += tx_delay_transmit_ticks; |
| 1619 | data->avgs.transmit_num += num_msdus; |
| 1620 | } |
| 1621 | pdev->tx_delay.tx_compl_timestamp_ticks = now_ticks; |
| 1622 | |
| 1623 | for (i = 0; i < num_msdus; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1624 | int bin; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1625 | uint16_t id = desc_ids[i]; |
| 1626 | struct ol_tx_desc_t *tx_desc = ol_tx_desc_find(pdev, id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1627 | |
| 1628 | tx_delay_queue_ticks = |
| 1629 | now_ticks - tx_desc->entry_timestamp_ticks; |
| 1630 | |
| 1631 | data->avgs.queue_sum_ticks += tx_delay_queue_ticks; |
| 1632 | data->avgs.queue_num++; |
| 1633 | bin = ol_tx_delay_hist_bin(pdev, tx_delay_queue_ticks); |
| 1634 | data->hist_bins_queue[bin]++; |
| 1635 | } |
| 1636 | |
| 1637 | /* check if it's time to start a new average */ |
| 1638 | avg_time_ticks = |
| 1639 | now_ticks - pdev->tx_delay.cats[cat].avg_start_time_ticks; |
| 1640 | if (avg_time_ticks > pdev->tx_delay.avg_period_ticks) { |
| 1641 | pdev->tx_delay.cats[cat].avg_start_time_ticks = now_ticks; |
| 1642 | index = 1 - index; |
| 1643 | pdev->tx_delay.cats[cat].in_progress_idx = index; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1644 | qdf_mem_zero(&pdev->tx_delay.cats[cat].copies[index], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1645 | sizeof(pdev->tx_delay.cats[cat].copies[index])); |
| 1646 | } |
| 1647 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1648 | qdf_spin_unlock_bh(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | } |
| 1650 | |
| 1651 | #endif /* QCA_COMPUTE_TX_DELAY */ |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 1652 | |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1653 | #ifdef WLAN_FEATURE_TSF_PLUS |
| 1654 | void ol_register_timestamp_callback(tp_ol_timestamp_cb ol_tx_timestamp_cb) |
| 1655 | { |
Rakesh Pillai | 6c5af2f | 2019-09-25 15:33:07 +0530 | [diff] [blame] | 1656 | struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1657 | ol_txrx_pdev_handle pdev; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1658 | |
Rakesh Pillai | 6c5af2f | 2019-09-25 15:33:07 +0530 | [diff] [blame] | 1659 | if (qdf_unlikely(!soc)) { |
| 1660 | ol_txrx_err("soc is NULL"); |
| 1661 | return; |
| 1662 | } |
| 1663 | |
| 1664 | pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1665 | if (!pdev) { |
Nirav Shah | 7c8c171 | 2018-09-10 16:01:31 +0530 | [diff] [blame] | 1666 | ol_txrx_err("pdev is NULL"); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1667 | return; |
| 1668 | } |
| 1669 | pdev->ol_tx_timestamp_cb = ol_tx_timestamp_cb; |
| 1670 | } |
| 1671 | |
| 1672 | void ol_deregister_timestamp_callback(void) |
| 1673 | { |
Rakesh Pillai | 6c5af2f | 2019-09-25 15:33:07 +0530 | [diff] [blame] | 1674 | struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1675 | ol_txrx_pdev_handle pdev; |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1676 | |
Rakesh Pillai | 6c5af2f | 2019-09-25 15:33:07 +0530 | [diff] [blame] | 1677 | pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1678 | if (!pdev) { |
Nirav Shah | 7c8c171 | 2018-09-10 16:01:31 +0530 | [diff] [blame] | 1679 | ol_txrx_err("pdev is NULL"); |
Yu Wang | ceb357b | 2017-06-01 12:04:18 +0800 | [diff] [blame] | 1680 | return; |
| 1681 | } |
| 1682 | pdev->ol_tx_timestamp_cb = NULL; |
| 1683 | } |
| 1684 | #endif |