Nathan Skrzypczak | a2c9509 | 2021-10-08 14:05:58 +0200 | [diff] [blame] | 1 | .. _handoff_queue_demo_plugin: |
| 2 | |
| 3 | Handoff queue in a plugin |
| 4 | ========================= |
| 5 | |
| 6 | This plugin provides a simplified example of how to hand off packets |
| 7 | between threads. I used it to debug packet-tracer handoff tracing |
| 8 | support. |
| 9 | |
| 10 | Packet generator input script |
| 11 | ----------------------------- |
| 12 | |
| 13 | :: |
| 14 | |
| 15 | packet-generator new { |
| 16 | name x |
| 17 | limit 5 |
| 18 | size 128-128 |
| 19 | interface local0 |
| 20 | node handoffdemo-1 |
| 21 | data { |
| 22 | incrementing 30 |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | Start vpp with 2 worker threads |
| 27 | ------------------------------- |
| 28 | |
| 29 | The demo plugin hands packets from worker 1 to worker 2. |
| 30 | |
| 31 | Enable tracing, and start the packet generator |
| 32 | ---------------------------------------------- |
| 33 | |
| 34 | :: |
| 35 | |
| 36 | trace add pg-input 100 |
| 37 | packet-generator enable |
| 38 | |
| 39 | Sample Run |
| 40 | ---------- |
| 41 | |
| 42 | :: |
| 43 | |
| 44 | DBGvpp# ex /tmp/pg_input_script |
| 45 | DBGvpp# pa en |
| 46 | DBGvpp# sh err |
| 47 | Count Node Reason |
| 48 | 5 handoffdemo-1 packets handed off processed |
| 49 | 5 handoffdemo-2 completed packets |
| 50 | DBGvpp# show run |
| 51 | Thread 1 vpp_wk_0 (lcore 0) |
| 52 | Time 133.9, average vectors/node 5.00, last 128 main loops 0.00 per node 0.00 |
| 53 | vector rates in 3.7331e-2, out 0.0000e0, drop 0.0000e0, punt 0.0000e0 |
| 54 | Name State Calls Vectors Suspends Clocks Vectors/Call |
| 55 | handoffdemo-1 active 1 5 0 4.76e3 5.00 |
| 56 | pg-input disabled 2 5 0 5.58e4 2.50 |
| 57 | unix-epoll-input polling 22760 0 0 2.14e7 0.00 |
| 58 | --------------- |
| 59 | Thread 2 vpp_wk_1 (lcore 2) |
| 60 | Time 133.9, average vectors/node 5.00, last 128 main loops 0.00 per node 0.00 |
| 61 | vector rates in 0.0000e0, out 0.0000e0, drop 3.7331e-2, punt 0.0000e0 |
| 62 | Name State Calls Vectors Suspends Clocks Vectors/Call |
| 63 | drop active 1 5 0 1.35e4 5.00 |
| 64 | error-drop active 1 5 0 2.52e4 5.00 |
| 65 | handoffdemo-2 active 1 5 0 2.56e4 5.00 |
| 66 | unix-epoll-input polling 22406 0 0 2.18e7 0.00 |
| 67 | |
| 68 | Enable the packet tracer and run it again… |
| 69 | |
| 70 | :: |
| 71 | |
| 72 | DBGvpp# trace add pg-input 100 |
| 73 | DBGvpp# pa en |
| 74 | DBGvpp# sh trace |
| 75 | sh trace |
| 76 | ------------------- Start of thread 0 vpp_main ------------------- |
| 77 | No packets in trace buffer |
| 78 | ------------------- Start of thread 1 vpp_wk_0 ------------------- |
| 79 | Packet 1 |
| 80 | |
| 81 | 00:06:50:520688: pg-input |
| 82 | stream x, 128 bytes, 0 sw_if_index |
| 83 | current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000000 |
| 84 | 00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000 |
| 85 | 00000020: 0000000000000000000000000000000000000000000000000000000000000000 |
| 86 | 00000040: 0000000000000000000000000000000000000000000000000000000000000000 |
| 87 | 00000060: 0000000000000000000000000000000000000000000000000000000000000000 |
| 88 | 00:06:50:520762: handoffdemo-1 |
| 89 | HANDOFFDEMO: current thread 1 |
| 90 | |
| 91 | Packet 2 |
| 92 | |
| 93 | 00:06:50:520688: pg-input |
| 94 | stream x, 128 bytes, 0 sw_if_index |
| 95 | current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000001 |
| 96 | 00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000 |
| 97 | 00000020: 0000000000000000000000000000000000000000000000000000000000000000 |
| 98 | 00000040: 0000000000000000000000000000000000000000000000000000000000000000 |
| 99 | 00000060: 0000000000000000000000000000000000000000000000000000000000000000 |
| 100 | 00:06:50:520762: handoffdemo-1 |
| 101 | HANDOFFDEMO: current thread 1 |
| 102 | |
| 103 | Packet 3 |
| 104 | |
| 105 | 00:06:50:520688: pg-input |
| 106 | stream x, 128 bytes, 0 sw_if_index |
| 107 | current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000002 |
| 108 | 00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000 |
| 109 | 00000020: 0000000000000000000000000000000000000000000000000000000000000000 |
| 110 | 00000040: 0000000000000000000000000000000000000000000000000000000000000000 |
| 111 | 00000060: 0000000000000000000000000000000000000000000000000000000000000000 |
| 112 | 00:06:50:520762: handoffdemo-1 |
| 113 | HANDOFFDEMO: current thread 1 |
| 114 | |
| 115 | Packet 4 |
| 116 | |
| 117 | 00:06:50:520688: pg-input |
| 118 | stream x, 128 bytes, 0 sw_if_index |
| 119 | current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000003 |
| 120 | 00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000 |
| 121 | 00000020: 0000000000000000000000000000000000000000000000000000000000000000 |
| 122 | 00000040: 0000000000000000000000000000000000000000000000000000000000000000 |
| 123 | 00000060: 0000000000000000000000000000000000000000000000000000000000000000 |
| 124 | 00:06:50:520762: handoffdemo-1 |
| 125 | HANDOFFDEMO: current thread 1 |
| 126 | |
| 127 | Packet 5 |
| 128 | |
| 129 | 00:06:50:520688: pg-input |
| 130 | stream x, 128 bytes, 0 sw_if_index |
| 131 | current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000004 |
| 132 | 00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000 |
| 133 | 00000020: 0000000000000000000000000000000000000000000000000000000000000000 |
| 134 | 00000040: 0000000000000000000000000000000000000000000000000000000000000000 |
| 135 | 00000060: 0000000000000000000000000000000000000000000000000000000000000000 |
| 136 | 00:06:50:520762: handoffdemo-1 |
| 137 | HANDOFFDEMO: current thread 1 |
| 138 | |
| 139 | ------------------- Start of thread 2 vpp_wk_1 ------------------- |
| 140 | Packet 1 |
| 141 | |
| 142 | 00:06:50:520796: handoff_trace |
| 143 | HANDED-OFF: from thread 1 trace index 0 |
| 144 | 00:06:50:520796: handoffdemo-2 |
| 145 | HANDOFFDEMO: current thread 2 |
| 146 | 00:06:50:520867: error-drop |
| 147 | rx:local0 |
| 148 | 00:06:50:520914: drop |
| 149 | handoffdemo-2: completed packets |
| 150 | |
| 151 | Packet 2 |
| 152 | |
| 153 | 00:06:50:520796: handoff_trace |
| 154 | HANDED-OFF: from thread 1 trace index 1 |
| 155 | 00:06:50:520796: handoffdemo-2 |
| 156 | HANDOFFDEMO: current thread 2 |
| 157 | 00:06:50:520867: error-drop |
| 158 | rx:local0 |
| 159 | 00:06:50:520914: drop |
| 160 | handoffdemo-2: completed packets |
| 161 | |
| 162 | Packet 3 |
| 163 | |
| 164 | 00:06:50:520796: handoff_trace |
| 165 | HANDED-OFF: from thread 1 trace index 2 |
| 166 | 00:06:50:520796: handoffdemo-2 |
| 167 | HANDOFFDEMO: current thread 2 |
| 168 | 00:06:50:520867: error-drop |
| 169 | rx:local0 |
| 170 | 00:06:50:520914: drop |
| 171 | handoffdemo-2: completed packets |
| 172 | |
| 173 | Packet 4 |
| 174 | |
| 175 | 00:06:50:520796: handoff_trace |
| 176 | HANDED-OFF: from thread 1 trace index 3 |
| 177 | 00:06:50:520796: handoffdemo-2 |
| 178 | HANDOFFDEMO: current thread 2 |
| 179 | 00:06:50:520867: error-drop |
| 180 | rx:local0 |
| 181 | 00:06:50:520914: drop |
| 182 | handoffdemo-2: completed packets |
| 183 | |
| 184 | Packet 5 |
| 185 | |
| 186 | 00:06:50:520796: handoff_trace |
| 187 | HANDED-OFF: from thread 1 trace index 4 |
| 188 | 00:06:50:520796: handoffdemo-2 |
| 189 | HANDOFFDEMO: current thread 2 |
| 190 | 00:06:50:520867: error-drop |
| 191 | rx:local0 |
| 192 | 00:06:50:520914: drop |
| 193 | handoffdemo-2: completed packets |
| 194 | DBGvpp# |