1 .. _handoff_queue_demo_plugin:
3 Handoff queue in a plugin
4 =========================
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
10 Packet generator input script
11 -----------------------------
15 packet-generator new {
26 Start vpp with 2 worker threads
27 -------------------------------
29 The demo plugin hands packets from worker 1 to worker 2.
31 Enable tracing, and start the packet generator
32 ----------------------------------------------
36 trace add pg-input 100
37 packet-generator enable
44 DBGvpp# ex /tmp/pg_input_script
48 5 handoffdemo-1 packets handed off processed
49 5 handoffdemo-2 completed packets
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
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
68 Enable the packet tracer and run it again…
72 DBGvpp# trace add pg-input 100
76 ------------------- Start of thread 0 vpp_main -------------------
77 No packets in trace buffer
78 ------------------- Start of thread 1 vpp_wk_0 -------------------
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
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
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
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
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
139 ------------------- Start of thread 2 vpp_wk_1 -------------------
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
148 00:06:50:520914: drop
149 handoffdemo-2: completed packets
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
159 00:06:50:520914: drop
160 handoffdemo-2: completed packets
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
170 00:06:50:520914: drop
171 handoffdemo-2: completed packets
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
181 00:06:50:520914: drop
182 handoffdemo-2: completed packets
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
192 00:06:50:520914: drop
193 handoffdemo-2: completed packets