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