| 2277 | } |
| 2278 | |
| 2279 | int |
| 2280 | rte_vhost_async_dma_unconfigure(int16_t dma_id, uint16_t vchan_id) |
| 2281 | { |
| 2282 | struct rte_dma_info info; |
| 2283 | struct rte_dma_stats stats = { 0 }; |
| 2284 | |
| 2285 | pthread_mutex_lock(&vhost_dma_lock); |
| 2286 | |
| 2287 | if (!rte_dma_is_valid(dma_id)) { |
| 2288 | VHOST_LOG_CONFIG("dma", ERR, "DMA %d is not found.\n", dma_id); |
| 2289 | goto error; |
| 2290 | } |
| 2291 | |
| 2292 | if (rte_dma_info_get(dma_id, &info) != 0) { |
| 2293 | VHOST_LOG_CONFIG("dma", ERR, "Fail to get DMA %d information.\n", dma_id); |
| 2294 | goto error; |
| 2295 | } |
| 2296 | |
| 2297 | if (vchan_id >= info.max_vchans || !dma_copy_track[dma_id].vchans || |
| 2298 | !dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr) { |
| 2299 | VHOST_LOG_CONFIG("dma", ERR, "Invalid channel %d:%u.\n", dma_id, vchan_id); |
| 2300 | goto error; |
| 2301 | } |
| 2302 | |
| 2303 | if (rte_dma_stats_get(dma_id, vchan_id, &stats) != 0) { |
| 2304 | VHOST_LOG_CONFIG("dma", ERR, |
| 2305 | "Failed to get stats for DMA %d vChannel %u.\n", dma_id, vchan_id); |
| 2306 | goto error; |
| 2307 | } |
| 2308 | |
| 2309 | if (stats.submitted - stats.completed != 0) { |
| 2310 | VHOST_LOG_CONFIG("dma", ERR, |
| 2311 | "Do not unconfigure when there are inflight packets.\n"); |
| 2312 | goto error; |
| 2313 | } |
| 2314 | |
| 2315 | rte_free(dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr); |
| 2316 | dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr = NULL; |
| 2317 | dma_copy_track[dma_id].nr_vchans--; |
| 2318 | |
| 2319 | if (dma_copy_track[dma_id].nr_vchans == 0) { |
| 2320 | rte_free(dma_copy_track[dma_id].vchans); |
| 2321 | dma_copy_track[dma_id].vchans = NULL; |
| 2322 | } |
| 2323 | |
| 2324 | pthread_mutex_unlock(&vhost_dma_lock); |
| 2325 | return 0; |
| 2326 | |
| 2327 | error: |
| 2328 | pthread_mutex_unlock(&vhost_dma_lock); |
| 2329 | return -1; |
| 2330 | } |
| 2331 | |
| 2332 | RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO); |
| 2333 | RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING); |
no test coverage detected