FD.io VPP  v19.08-24-ge6a5712
Vector Packet Processing
Handoff queue demo plugin

This plugin provides a simplified example of how to hand off packets between threads. I used it to debug packet-tracer handoff tracing support.

Packet generator input script

1 packet-generator new {
2  name x
3  limit 5
4  size 128-128
5  interface local0
6  node handoffdemo-1
7  data {
8  incrementing 30
9  }
10 }

Start vpp with 2 worker threads

The demo plugin hands packets from worker 1 to worker 2.

Enable tracing, and start the packet generator

1 trace add pg-input 100
2 packet-generator enable

Sample Run

1 DBGvpp# ex /tmp/pg_input_script
2 DBGvpp# pa en
3 DBGvpp# sh err
4  Count Node Reason
5  5 handoffdemo-1 packets handed off processed
6  5 handoffdemo-2 completed packets
7 DBGvpp# show run
8 Thread 1 vpp_wk_0 (lcore 0)
9 Time 133.9, average vectors/node 5.00, last 128 main loops 0.00 per node 0.00
10  vector rates in 3.7331e-2, out 0.0000e0, drop 0.0000e0, punt 0.0000e0
11  Name State Calls Vectors Suspends Clocks Vectors/Call
12 handoffdemo-1 active 1 5 0 4.76e3 5.00
13 pg-input disabled 2 5 0 5.58e4 2.50
14 unix-epoll-input polling 22760 0 0 2.14e7 0.00
15 ---------------
16 Thread 2 vpp_wk_1 (lcore 2)
17 Time 133.9, average vectors/node 5.00, last 128 main loops 0.00 per node 0.00
18  vector rates in 0.0000e0, out 0.0000e0, drop 3.7331e-2, punt 0.0000e0
19  Name State Calls Vectors Suspends Clocks Vectors/Call
20 drop active 1 5 0 1.35e4 5.00
21 error-drop active 1 5 0 2.52e4 5.00
22 handoffdemo-2 active 1 5 0 2.56e4 5.00
23 unix-epoll-input polling 22406 0 0 2.18e7 0.00

Enable the packet tracer and run it again...

1  DBGvpp# trace add pg-input 100
2  DBGvpp# pa en
3  DBGvpp# sh trace
4  sh trace
5  ------------------- Start of thread 0 vpp_main -------------------
6  No packets in trace buffer
7  ------------------- Start of thread 1 vpp_wk_0 -------------------
8  Packet 1
9 
10  00:06:50:520688: pg-input
11  stream x, 128 bytes, 0 sw_if_index
12  current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000000
13  00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000
14  00000020: 0000000000000000000000000000000000000000000000000000000000000000
15  00000040: 0000000000000000000000000000000000000000000000000000000000000000
16  00000060: 0000000000000000000000000000000000000000000000000000000000000000
17  00:06:50:520762: handoffdemo-1
18  HANDOFFDEMO: current thread 1
19 
20  Packet 2
21 
22  00:06:50:520688: pg-input
23  stream x, 128 bytes, 0 sw_if_index
24  current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000001
25  00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000
26  00000020: 0000000000000000000000000000000000000000000000000000000000000000
27  00000040: 0000000000000000000000000000000000000000000000000000000000000000
28  00000060: 0000000000000000000000000000000000000000000000000000000000000000
29  00:06:50:520762: handoffdemo-1
30  HANDOFFDEMO: current thread 1
31 
32  Packet 3
33 
34  00:06:50:520688: pg-input
35  stream x, 128 bytes, 0 sw_if_index
36  current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000002
37  00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000
38  00000020: 0000000000000000000000000000000000000000000000000000000000000000
39  00000040: 0000000000000000000000000000000000000000000000000000000000000000
40  00000060: 0000000000000000000000000000000000000000000000000000000000000000
41  00:06:50:520762: handoffdemo-1
42  HANDOFFDEMO: current thread 1
43 
44  Packet 4
45 
46  00:06:50:520688: pg-input
47  stream x, 128 bytes, 0 sw_if_index
48  current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000003
49  00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000
50  00000020: 0000000000000000000000000000000000000000000000000000000000000000
51  00000040: 0000000000000000000000000000000000000000000000000000000000000000
52  00000060: 0000000000000000000000000000000000000000000000000000000000000000
53  00:06:50:520762: handoffdemo-1
54  HANDOFFDEMO: current thread 1
55 
56  Packet 5
57 
58  00:06:50:520688: pg-input
59  stream x, 128 bytes, 0 sw_if_index
60  current data 0, length 128, buffer-pool 0, ref-count 1, trace handle 0x1000004
61  00000000: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d0000
62  00000020: 0000000000000000000000000000000000000000000000000000000000000000
63  00000040: 0000000000000000000000000000000000000000000000000000000000000000
64  00000060: 0000000000000000000000000000000000000000000000000000000000000000
65  00:06:50:520762: handoffdemo-1
66  HANDOFFDEMO: current thread 1
67 
68  ------------------- Start of thread 2 vpp_wk_1 -------------------
69  Packet 1
70 
71  00:06:50:520796: handoff_trace
72  HANDED-OFF: from thread 1 trace index 0
73  00:06:50:520796: handoffdemo-2
74  HANDOFFDEMO: current thread 2
75  00:06:50:520867: error-drop
76  rx:local0
77  00:06:50:520914: drop
78  handoffdemo-2: completed packets
79 
80  Packet 2
81 
82  00:06:50:520796: handoff_trace
83  HANDED-OFF: from thread 1 trace index 1
84  00:06:50:520796: handoffdemo-2
85  HANDOFFDEMO: current thread 2
86  00:06:50:520867: error-drop
87  rx:local0
88  00:06:50:520914: drop
89  handoffdemo-2: completed packets
90 
91  Packet 3
92 
93  00:06:50:520796: handoff_trace
94  HANDED-OFF: from thread 1 trace index 2
95  00:06:50:520796: handoffdemo-2
96  HANDOFFDEMO: current thread 2
97  00:06:50:520867: error-drop
98  rx:local0
99  00:06:50:520914: drop
100  handoffdemo-2: completed packets
101 
102  Packet 4
103 
104  00:06:50:520796: handoff_trace
105  HANDED-OFF: from thread 1 trace index 3
106  00:06:50:520796: handoffdemo-2
107  HANDOFFDEMO: current thread 2
108  00:06:50:520867: error-drop
109  rx:local0
110  00:06:50:520914: drop
111  handoffdemo-2: completed packets
112 
113  Packet 5
114 
115  00:06:50:520796: handoff_trace
116  HANDED-OFF: from thread 1 trace index 4
117  00:06:50:520796: handoffdemo-2
118  HANDOFFDEMO: current thread 2
119  00:06:50:520867: error-drop
120  rx:local0
121  00:06:50:520914: drop
122  handoffdemo-2: completed packets
123 DBGvpp#