MCPcopy Create free account
hub / github.com/NetSys/bess / PacketPool

Method PacketPool

core/packet_pool.cc:62–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62PacketPool::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
86PacketPool::~PacketPool() {
87 // munmap is triggered by the registered callback DoMunmap()

Callers

nothing calls this directly

Calls 2

IsDpdkInitializedFunction · 0.85
InitDpdkFunction · 0.85

Tested by

no test coverage detected