| 39 | } |
| 40 | |
| 41 | void 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 | |
| 64 | ADD_MODULE(Bypass, "bypass", "bypasses packets without any processing") |