MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_vhost_async_dma_unconfigure

Function rte_vhost_async_dma_unconfigure

dpdk/lib/vhost/vhost.c:2279–2330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2277}
2278
2279int
2280rte_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
2327error:
2328 pthread_mutex_unlock(&vhost_dma_lock);
2329 return -1;
2330}
2331
2332RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
2333RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);

Callers 1

mainFunction · 0.85

Calls 6

pthread_mutex_lockFunction · 0.85
rte_dma_is_validFunction · 0.85
rte_dma_info_getFunction · 0.85
rte_dma_stats_getFunction · 0.85
rte_freeFunction · 0.85
pthread_mutex_unlockFunction · 0.85

Tested by

no test coverage detected