| 619 | } |
| 620 | |
| 621 | void |
| 622 | rte_hash_reset(struct rte_hash *h) |
| 623 | { |
| 624 | uint32_t tot_ring_cnt, i; |
| 625 | unsigned int pending; |
| 626 | |
| 627 | if (h == NULL) |
| 628 | return; |
| 629 | |
| 630 | __hash_rw_writer_lock(h); |
| 631 | |
| 632 | if (h->dq) { |
| 633 | /* Reclaim all the resources */ |
| 634 | rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL); |
| 635 | if (pending != 0) |
| 636 | RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n"); |
| 637 | } |
| 638 | |
| 639 | memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket)); |
| 640 | memset(h->key_store, 0, h->key_entry_size * (h->entries + 1)); |
| 641 | *h->tbl_chng_cnt = 0; |
| 642 | |
| 643 | /* reset the free ring */ |
| 644 | rte_ring_reset(h->free_slots); |
| 645 | |
| 646 | /* flush free extendable bucket ring and memory */ |
| 647 | if (h->ext_table_support) { |
| 648 | memset(h->buckets_ext, 0, h->num_buckets * |
| 649 | sizeof(struct rte_hash_bucket)); |
| 650 | rte_ring_reset(h->free_ext_bkts); |
| 651 | } |
| 652 | |
| 653 | /* Repopulate the free slots ring. Entry zero is reserved for key misses */ |
| 654 | if (h->use_local_cache) |
| 655 | tot_ring_cnt = h->entries + (RTE_MAX_LCORE - 1) * |
| 656 | (LCORE_CACHE_SIZE - 1); |
| 657 | else |
| 658 | tot_ring_cnt = h->entries; |
| 659 | |
| 660 | for (i = 1; i < tot_ring_cnt + 1; i++) |
| 661 | rte_ring_sp_enqueue_elem(h->free_slots, &i, sizeof(uint32_t)); |
| 662 | |
| 663 | /* Repopulate the free ext bkt ring. */ |
| 664 | if (h->ext_table_support) { |
| 665 | for (i = 1; i <= h->num_buckets; i++) |
| 666 | rte_ring_sp_enqueue_elem(h->free_ext_bkts, &i, |
| 667 | sizeof(uint32_t)); |
| 668 | } |
| 669 | |
| 670 | if (h->use_local_cache) { |
| 671 | /* Reset local caches per lcore */ |
| 672 | for (i = 0; i < RTE_MAX_LCORE; i++) |
| 673 | h->local_free_slots[i].len = 0; |
| 674 | } |
| 675 | __hash_rw_writer_unlock(h); |
| 676 | } |
| 677 | |
| 678 | /* |