free the ring */
| 315 | |
| 316 | /* free the ring */ |
| 317 | void |
| 318 | rte_ring_free(struct rte_ring *r) |
| 319 | { |
| 320 | struct rte_ring_list *ring_list = NULL; |
| 321 | struct rte_tailq_entry *te; |
| 322 | |
| 323 | if (r == NULL) |
| 324 | return; |
| 325 | |
| 326 | /* |
| 327 | * Ring was not created with rte_ring_create, |
| 328 | * therefore, there is no memzone to free. |
| 329 | */ |
| 330 | if (r->memzone == NULL) { |
| 331 | RTE_LOG(ERR, RING, |
| 332 | "Cannot free ring, not created with rte_ring_create()\n"); |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); |
| 337 | rte_mcfg_tailq_write_lock(); |
| 338 | |
| 339 | /* find out tailq entry */ |
| 340 | TAILQ_FOREACH(te, ring_list, next) { |
| 341 | if (te->data == (void *) r) |
| 342 | break; |
| 343 | } |
| 344 | |
| 345 | if (te == NULL) { |
| 346 | rte_mcfg_tailq_write_unlock(); |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | TAILQ_REMOVE(ring_list, te, next); |
| 351 | |
| 352 | rte_mcfg_tailq_write_unlock(); |
| 353 | |
| 354 | if (rte_memzone_free(r->memzone) != 0) |
| 355 | RTE_LOG(ERR, RING, "Cannot free memory\n"); |
| 356 | |
| 357 | rte_free(te); |
| 358 | } |
| 359 | |
| 360 | /* dump the status of the ring on the console */ |
| 361 | void |