Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Multicore Navigator driver for TI Keystone 2 devices. |
| 4 | * |
| 5 | * (C) Copyright 2012-2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 7 | */ |
| 8 | #include <common.h> |
| 9 | #include <asm/io.h> |
Khoronzhuk, Ivan | 7954b86 | 2014-09-05 19:02:47 +0300 | [diff] [blame] | 10 | #include <asm/ti-common/keystone_nav.h> |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 11 | |
Khoronzhuk, Ivan | 29310e7 | 2014-09-05 19:02:45 +0300 | [diff] [blame] | 12 | struct qm_config qm_memmap = { |
Khoronzhuk, Ivan | 7954b86 | 2014-09-05 19:02:47 +0300 | [diff] [blame] | 13 | .stat_cfg = CONFIG_KSNAV_QM_QUEUE_STATUS_BASE, |
| 14 | .queue = (void *)CONFIG_KSNAV_QM_MANAGER_QUEUES_BASE, |
| 15 | .mngr_vbusm = CONFIG_KSNAV_QM_BASE_ADDRESS, |
| 16 | .i_lram = CONFIG_KSNAV_QM_LINK_RAM_BASE, |
| 17 | .proxy = (void *)CONFIG_KSNAV_QM_MANAGER_Q_PROXY_BASE, |
| 18 | .status_ram = CONFIG_KSNAV_QM_STATUS_RAM_BASE, |
| 19 | .mngr_cfg = (void *)CONFIG_KSNAV_QM_CONF_BASE, |
| 20 | .intd_cfg = CONFIG_KSNAV_QM_INTD_CONF_BASE, |
| 21 | .desc_mem = (void *)CONFIG_KSNAV_QM_DESC_SETUP_BASE, |
| 22 | .region_num = CONFIG_KSNAV_QM_REGION_NUM, |
| 23 | .pdsp_cmd = CONFIG_KSNAV_QM_PDSP1_CMD_BASE, |
| 24 | .pdsp_ctl = CONFIG_KSNAV_QM_PDSP1_CTRL_BASE, |
| 25 | .pdsp_iram = CONFIG_KSNAV_QM_PDSP1_IRAM_BASE, |
| 26 | .qpool_num = CONFIG_KSNAV_QM_QPOOL_NUM, |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | /* |
| 30 | * We are going to use only one type of descriptors - host packet |
| 31 | * descriptors. We staticaly allocate memory for them here |
| 32 | */ |
| 33 | struct qm_host_desc desc_pool[HDESC_NUM] __aligned(sizeof(struct qm_host_desc)); |
| 34 | |
| 35 | static struct qm_config *qm_cfg; |
| 36 | |
| 37 | inline int num_of_desc_to_reg(int num_descr) |
| 38 | { |
| 39 | int j, num; |
| 40 | |
| 41 | for (j = 0, num = 32; j < 15; j++, num *= 2) { |
| 42 | if (num_descr <= num) |
| 43 | return j; |
| 44 | } |
| 45 | |
| 46 | return 15; |
| 47 | } |
| 48 | |
Khoronzhuk, Ivan | 29310e7 | 2014-09-05 19:02:45 +0300 | [diff] [blame] | 49 | int _qm_init(struct qm_config *cfg) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 50 | { |
Khoronzhuk, Ivan | 29310e7 | 2014-09-05 19:02:45 +0300 | [diff] [blame] | 51 | u32 j; |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 52 | |
| 53 | qm_cfg = cfg; |
| 54 | |
| 55 | qm_cfg->mngr_cfg->link_ram_base0 = qm_cfg->i_lram; |
Vitaly Andrianov | 1e2b17e | 2015-09-19 16:26:49 +0530 | [diff] [blame] | 56 | qm_cfg->mngr_cfg->link_ram_size0 = HDESC_NUM * 8 - 1; |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 57 | qm_cfg->mngr_cfg->link_ram_base1 = 0; |
| 58 | qm_cfg->mngr_cfg->link_ram_size1 = 0; |
| 59 | qm_cfg->mngr_cfg->link_ram_base2 = 0; |
| 60 | |
| 61 | qm_cfg->desc_mem[0].base_addr = (u32)desc_pool; |
| 62 | qm_cfg->desc_mem[0].start_idx = 0; |
| 63 | qm_cfg->desc_mem[0].desc_reg_size = |
| 64 | (((sizeof(struct qm_host_desc) >> 4) - 1) << 16) | |
| 65 | num_of_desc_to_reg(HDESC_NUM); |
| 66 | |
| 67 | memset(desc_pool, 0, sizeof(desc_pool)); |
| 68 | for (j = 0; j < HDESC_NUM; j++) |
| 69 | qm_push(&desc_pool[j], qm_cfg->qpool_num); |
| 70 | |
| 71 | return QM_OK; |
| 72 | } |
| 73 | |
| 74 | int qm_init(void) |
| 75 | { |
Khoronzhuk, Ivan | 29310e7 | 2014-09-05 19:02:45 +0300 | [diff] [blame] | 76 | return _qm_init(&qm_memmap); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | void qm_close(void) |
| 80 | { |
| 81 | u32 j; |
| 82 | |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 83 | queue_close(qm_cfg->qpool_num); |
| 84 | |
| 85 | qm_cfg->mngr_cfg->link_ram_base0 = 0; |
| 86 | qm_cfg->mngr_cfg->link_ram_size0 = 0; |
| 87 | qm_cfg->mngr_cfg->link_ram_base1 = 0; |
| 88 | qm_cfg->mngr_cfg->link_ram_size1 = 0; |
| 89 | qm_cfg->mngr_cfg->link_ram_base2 = 0; |
| 90 | |
| 91 | for (j = 0; j < qm_cfg->region_num; j++) { |
| 92 | qm_cfg->desc_mem[j].base_addr = 0; |
| 93 | qm_cfg->desc_mem[j].start_idx = 0; |
| 94 | qm_cfg->desc_mem[j].desc_reg_size = 0; |
| 95 | } |
| 96 | |
| 97 | qm_cfg = NULL; |
| 98 | } |
| 99 | |
| 100 | void qm_push(struct qm_host_desc *hd, u32 qnum) |
| 101 | { |
| 102 | u32 regd; |
| 103 | |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 104 | cpu_to_bus((u32 *)hd, sizeof(struct qm_host_desc)/4); |
| 105 | regd = (u32)hd | ((sizeof(struct qm_host_desc) >> 4) - 1); |
| 106 | writel(regd, &qm_cfg->queue[qnum].ptr_size_thresh); |
| 107 | } |
| 108 | |
| 109 | void qm_buff_push(struct qm_host_desc *hd, u32 qnum, |
| 110 | void *buff_ptr, u32 buff_len) |
| 111 | { |
| 112 | hd->orig_buff_len = buff_len; |
| 113 | hd->buff_len = buff_len; |
| 114 | hd->orig_buff_ptr = (u32)buff_ptr; |
| 115 | hd->buff_ptr = (u32)buff_ptr; |
| 116 | qm_push(hd, qnum); |
| 117 | } |
| 118 | |
| 119 | struct qm_host_desc *qm_pop(u32 qnum) |
| 120 | { |
| 121 | u32 uhd; |
| 122 | |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 123 | uhd = readl(&qm_cfg->queue[qnum].ptr_size_thresh) & ~0xf; |
| 124 | if (uhd) |
| 125 | cpu_to_bus((u32 *)uhd, sizeof(struct qm_host_desc)/4); |
| 126 | |
| 127 | return (struct qm_host_desc *)uhd; |
| 128 | } |
| 129 | |
| 130 | struct qm_host_desc *qm_pop_from_free_pool(void) |
| 131 | { |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 132 | return qm_pop(qm_cfg->qpool_num); |
| 133 | } |
| 134 | |
| 135 | void queue_close(u32 qnum) |
| 136 | { |
| 137 | struct qm_host_desc *hd; |
| 138 | |
| 139 | while ((hd = qm_pop(qnum))) |
| 140 | ; |
| 141 | } |
| 142 | |
Khoronzhuk, Ivan | 89a6652 | 2014-09-05 19:02:46 +0300 | [diff] [blame] | 143 | /** |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 144 | * DMA API |
| 145 | */ |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 146 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 147 | static int ksnav_rx_disable(struct pktdma_cfg *pktdma) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 148 | { |
| 149 | u32 j, v, k; |
| 150 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 151 | for (j = 0; j < pktdma->rx_ch_num; j++) { |
| 152 | v = readl(&pktdma->rx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 153 | if (!(v & CPDMA_CHAN_A_ENABLE)) |
| 154 | continue; |
| 155 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 156 | writel(v | CPDMA_CHAN_A_TDOWN, &pktdma->rx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 157 | for (k = 0; k < TDOWN_TIMEOUT_COUNT; k++) { |
| 158 | udelay(100); |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 159 | v = readl(&pktdma->rx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 160 | if (!(v & CPDMA_CHAN_A_ENABLE)) |
| 161 | continue; |
| 162 | } |
| 163 | /* TODO: teardown error on if TDOWN_TIMEOUT_COUNT is reached */ |
| 164 | } |
| 165 | |
| 166 | /* Clear all of the flow registers */ |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 167 | for (j = 0; j < pktdma->rx_flow_num; j++) { |
| 168 | writel(0, &pktdma->rx_flows[j].control); |
| 169 | writel(0, &pktdma->rx_flows[j].tags); |
| 170 | writel(0, &pktdma->rx_flows[j].tag_sel); |
| 171 | writel(0, &pktdma->rx_flows[j].fdq_sel[0]); |
| 172 | writel(0, &pktdma->rx_flows[j].fdq_sel[1]); |
| 173 | writel(0, &pktdma->rx_flows[j].thresh[0]); |
| 174 | writel(0, &pktdma->rx_flows[j].thresh[1]); |
| 175 | writel(0, &pktdma->rx_flows[j].thresh[2]); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | return QM_OK; |
| 179 | } |
| 180 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 181 | static int ksnav_tx_disable(struct pktdma_cfg *pktdma) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 182 | { |
| 183 | u32 j, v, k; |
| 184 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 185 | for (j = 0; j < pktdma->tx_ch_num; j++) { |
| 186 | v = readl(&pktdma->tx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 187 | if (!(v & CPDMA_CHAN_A_ENABLE)) |
| 188 | continue; |
| 189 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 190 | writel(v | CPDMA_CHAN_A_TDOWN, &pktdma->tx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 191 | for (k = 0; k < TDOWN_TIMEOUT_COUNT; k++) { |
| 192 | udelay(100); |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 193 | v = readl(&pktdma->tx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 194 | if (!(v & CPDMA_CHAN_A_ENABLE)) |
| 195 | continue; |
| 196 | } |
| 197 | /* TODO: teardown error on if TDOWN_TIMEOUT_COUNT is reached */ |
| 198 | } |
| 199 | |
| 200 | return QM_OK; |
| 201 | } |
| 202 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 203 | int ksnav_init(struct pktdma_cfg *pktdma, struct rx_buff_desc *rx_buffers) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 204 | { |
| 205 | u32 j, v; |
| 206 | struct qm_host_desc *hd; |
| 207 | u8 *rx_ptr; |
| 208 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 209 | if (pktdma == NULL || rx_buffers == NULL || |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 210 | rx_buffers->buff_ptr == NULL || qm_cfg == NULL) |
| 211 | return QM_ERR; |
| 212 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 213 | pktdma->rx_flow = rx_buffers->rx_flow; |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 214 | |
| 215 | /* init rx queue */ |
| 216 | rx_ptr = rx_buffers->buff_ptr; |
| 217 | |
| 218 | for (j = 0; j < rx_buffers->num_buffs; j++) { |
| 219 | hd = qm_pop(qm_cfg->qpool_num); |
| 220 | if (hd == NULL) |
| 221 | return QM_ERR; |
| 222 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 223 | qm_buff_push(hd, pktdma->rx_free_q, |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 224 | rx_ptr, rx_buffers->buff_len); |
| 225 | |
| 226 | rx_ptr += rx_buffers->buff_len; |
| 227 | } |
| 228 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 229 | ksnav_rx_disable(pktdma); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 230 | |
| 231 | /* configure rx channels */ |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 232 | v = CPDMA_REG_VAL_MAKE_RX_FLOW_A(1, 1, 0, 0, 0, 0, 0, pktdma->rx_rcv_q); |
| 233 | writel(v, &pktdma->rx_flows[pktdma->rx_flow].control); |
| 234 | writel(0, &pktdma->rx_flows[pktdma->rx_flow].tags); |
| 235 | writel(0, &pktdma->rx_flows[pktdma->rx_flow].tag_sel); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 236 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 237 | v = CPDMA_REG_VAL_MAKE_RX_FLOW_D(0, pktdma->rx_free_q, 0, |
| 238 | pktdma->rx_free_q); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 239 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 240 | writel(v, &pktdma->rx_flows[pktdma->rx_flow].fdq_sel[0]); |
| 241 | writel(v, &pktdma->rx_flows[pktdma->rx_flow].fdq_sel[1]); |
| 242 | writel(0, &pktdma->rx_flows[pktdma->rx_flow].thresh[0]); |
| 243 | writel(0, &pktdma->rx_flows[pktdma->rx_flow].thresh[1]); |
| 244 | writel(0, &pktdma->rx_flows[pktdma->rx_flow].thresh[2]); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 245 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 246 | for (j = 0; j < pktdma->rx_ch_num; j++) |
| 247 | writel(CPDMA_CHAN_A_ENABLE, &pktdma->rx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 248 | |
| 249 | /* configure tx channels */ |
| 250 | /* Disable loopback in the tx direction */ |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 251 | writel(0, &pktdma->global->emulation_control); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 252 | |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 253 | /* Set QM base address, only for K2x devices */ |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 254 | writel(CONFIG_KSNAV_QM_BASE_ADDRESS, &pktdma->global->qm_base_addr[0]); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 255 | |
| 256 | /* Enable all channels. The current state isn't important */ |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 257 | for (j = 0; j < pktdma->tx_ch_num; j++) { |
| 258 | writel(0, &pktdma->tx_ch[j].cfg_b); |
| 259 | writel(CPDMA_CHAN_A_ENABLE, &pktdma->tx_ch[j].cfg_a); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | return QM_OK; |
| 263 | } |
| 264 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 265 | int ksnav_close(struct pktdma_cfg *pktdma) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 266 | { |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 267 | if (!pktdma) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 268 | return QM_ERR; |
| 269 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 270 | ksnav_tx_disable(pktdma); |
| 271 | ksnav_rx_disable(pktdma); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 272 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 273 | queue_close(pktdma->rx_free_q); |
| 274 | queue_close(pktdma->rx_rcv_q); |
| 275 | queue_close(pktdma->tx_snd_q); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 276 | |
| 277 | return QM_OK; |
| 278 | } |
| 279 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 280 | int ksnav_send(struct pktdma_cfg *pktdma, u32 *pkt, int num_bytes, u32 swinfo2) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 281 | { |
| 282 | struct qm_host_desc *hd; |
| 283 | |
| 284 | hd = qm_pop(qm_cfg->qpool_num); |
| 285 | if (hd == NULL) |
| 286 | return QM_ERR; |
| 287 | |
| 288 | hd->desc_info = num_bytes; |
| 289 | hd->swinfo[2] = swinfo2; |
| 290 | hd->packet_info = qm_cfg->qpool_num; |
| 291 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 292 | qm_buff_push(hd, pktdma->tx_snd_q, pkt, num_bytes); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 293 | |
| 294 | return QM_OK; |
| 295 | } |
| 296 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 297 | void *ksnav_recv(struct pktdma_cfg *pktdma, u32 **pkt, int *num_bytes) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 298 | { |
| 299 | struct qm_host_desc *hd; |
| 300 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 301 | hd = qm_pop(pktdma->rx_rcv_q); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 302 | if (!hd) |
| 303 | return NULL; |
| 304 | |
| 305 | *pkt = (u32 *)hd->buff_ptr; |
| 306 | *num_bytes = hd->desc_info & 0x3fffff; |
| 307 | |
| 308 | return hd; |
| 309 | } |
| 310 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 311 | void ksnav_release_rxhd(struct pktdma_cfg *pktdma, void *hd) |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 312 | { |
| 313 | struct qm_host_desc *_hd = (struct qm_host_desc *)hd; |
| 314 | |
| 315 | _hd->buff_len = _hd->orig_buff_len; |
| 316 | _hd->buff_ptr = _hd->orig_buff_ptr; |
| 317 | |
Khoronzhuk, Ivan | fa2105a | 2014-09-05 19:02:48 +0300 | [diff] [blame] | 318 | qm_push(_hd, pktdma->rx_free_q); |
Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame] | 319 | } |