| 60 | } |
| 61 | |
| 62 | PacketPool::PacketPool(size_t capacity, int socket_id) { |
| 63 | if (!IsDpdkInitialized()) { |
| 64 | InitDpdk(0); |
| 65 | } |
| 66 | |
| 67 | static int next_id_; |
| 68 | name_ = "PacketPool" + std::to_string(next_id_++); |
| 69 | |
| 70 | LOG(INFO) << name_ << " requests for " << capacity << " packets"; |
| 71 | |
| 72 | pool_ = rte_mempool_create_empty(name_.c_str(), capacity, sizeof(Packet), |
| 73 | capacity > 1024 ? kMaxCacheSize : 0, |
| 74 | sizeof(PoolPrivate), socket_id, 0); |
| 75 | if (!pool_) { |
| 76 | LOG(FATAL) << "rte_mempool_create() failed: " << rte_strerror(rte_errno) |
| 77 | << " (rte_errno=" << rte_errno << ")"; |
| 78 | } |
| 79 | |
| 80 | int ret = rte_mempool_set_ops_byname(pool_, "ring_mp_mc", NULL); |
| 81 | if (ret < 0) { |
| 82 | LOG(FATAL) << "rte_mempool_set_ops_byname() returned " << ret; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | PacketPool::~PacketPool() { |
| 87 | // munmap is triggered by the registered callback DoMunmap() |
nothing calls this directly
no test coverage detected