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

Method ProcessBatch

core/modules/bypass.cc:41–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void Bypass::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
42 uint64_t start_tsc = rdtsc();
43 uint64_t cycles = cycles_per_batch_ + cycles_per_packet_ * batch->cnt();
44
45 if (cycles_per_byte_) {
46 uint64_t total_bytes = 0;
47 int cnt = batch->cnt();
48 for (int i = 0; i < cnt; i++) {
49 total_bytes = batch->pkts()[i]->total_len();
50 }
51 cycles += cycles_per_byte_ * total_bytes;
52 }
53
54 if (cycles) {
55 uint64_t target_tsc = start_tsc + cycles;
56 // burn cycles until it comsumes target cycles
57 while (rdtsc() < target_tsc) {
58 _mm_pause();
59 }
60 }
61 RunChooseModule(ctx, ctx->current_igate, batch);
62}
63
64ADD_MODULE(Bypass, "bypass", "bypasses packets without any processing")

Callers

nothing calls this directly

Calls 4

rdtscFunction · 0.85
total_lenMethod · 0.80
cntMethod · 0.45
pktsMethod · 0.45

Tested by

no test coverage detected