Skip to content

Commit 05a797d

Browse files
authored
Merge pull request sonic-net#267 from michaelli10/cpu_packet_debug_counters
Updating CPU Packet Debug Counters HLD
2 parents 6599556 + 900c900 commit 05a797d

File tree

1 file changed

+320
-34
lines changed

1 file changed

+320
-34
lines changed

system/SONiC_CPU_Packet_Debug_Counters.md

+320-34
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ SONiC CPU Packet Debug Counters
1616
# Revision
1717
| Rev | Date | Author | Change Description |
1818
|:---:|:-----------:|:------------------:|-----------------------------------|
19-
| 0.1 | 04/13/2019 | Michael Li | Initial version |
19+
| 0.1 | 04/13/2021 | Michael Li | Initial version |
20+
| 0.2 | 08/16/2021 | Michael Li | Design detail updates |
2021

2122
# About this Manual
2223
This document provides general information about the SONiC CPU Packet Debug Counters feature implementation in SONiC.
@@ -28,50 +29,335 @@ This document describes the high level design of SONiC CPU Packet Debug Counters
2829
### Table 1: Abbreviations
2930
| **Term** | **Meaning** |
3031
|--------------------------|-------------------------------------|
31-
| XYZ | Term description |
32+
| KNET | Kernel Network Driver |
3233

3334
# 1 Feature Overview
34-
The CPU Packet Debug Counters provides BRCM KNET driver level Rx and Tx statistics for each protocol type. SONiC KNET currently provides CPU packet counters based on CPU queues which indirectly provides Rx per protocol counters since each protocol is assigned a separate CPU queue. This feature enhances CPU packet statistics by adding per protocol counters for CPU Rx and Tx directions.
35+
The CPU Packet Debug Counters provides BRCM KNET driver level Rx and Tx statistics for each protocol type at switch and interface levels. SONiC KNET currently provides CPU packet counters based on CPU queues which indirectly provides Rx per protocol counters since each protocol is assigned a separate CPU queue. This feature enhances CPU packet statistics by adding per protocol counters per interface for CPU Rx and Tx directions. Packet drop reason details per protocol/queue per interface are also added for more debug visibility.
3536

3637
## 1.1 Requirements
3738

3839
### 1.1.1 Functional Requirements
3940

40-
1. Support Tx and Rx per protocol KNET driver level packet counters from KNET procfs
41-
2. Support Tx and Rx per protocol Linux/KNET dropped packet counters from KNET procfs
42-
3. Support clearing of Tx and Rx counters
43-
4. Output of statistics will be similar to the following format:
41+
1. Support switch and per interface Tx and Rx per protocol KNET driver level packet counters
42+
2. Support switch and per interface Tx and Rx per protocol Linux/KNET dropped packet counters
43+
3. Support switch and per interface Tx and Rx KNET error reason detail counters
44+
4. Support switch and per interface clearing of Tx and Rx counters
4445

46+
### 1.1.2 Configuration and Management Requirements
47+
Statistics will be provided via click CLIs and KNET procfs files
48+
49+
### 1.1.3 Scaling and Performance Requirements
50+
51+
There should be minimal impact on CPU Pkt IO performance and latencies. CPU Pkt IO performance will be profiled to measure the impact of adding pkt type processing on CPU Pkt IO performance and latencies.
52+
53+
### 1.1.4 Warm Boot Requirements
54+
Not applicable
55+
56+
# 2 Functionality
57+
## 2.1 Target Deployment Use Cases
58+
This debugging enhancement provides more granular debug counters and additional visibility into the CPU Pkt IO network driver (KNET) and Linux kernel pkt path that will help with debugging SONiC systems.
59+
60+
## 2.2 Functional Description
61+
See feature overview
62+
63+
# 3 Design
64+
## 3.1 Overview
65+
Protocol classification logic will be added to the Broadcom KNET driver pkt Tx and Rx callbacks to identify protocols and enable pkt protocol type accounting per physical interface. The statistics output will be available via KNET driver procfs files and click CLIs for convenience.
66+
67+
### 3.1.1 Rx Classification and Packet drop counting
68+
The Broadcom KNET driver filter infrastructure will be used to classify Rx packets (and CPU queues from pkt metadata) and tag the protocol type from added logic in the KNET callback module. This will allow managing KNET packet stats accounting to have per protocol and per interface information when managing stats accounting.
69+
70+
Any drops before KNET filter processing (matching src port) will not have src port information so pkt drops will count towards the global protocol switch counters and will not update the protocol interface counters. After KNET filter processing determines the src port, both global and per interface protocol counters will be updated.
71+
72+
### 3.1.2 Tx Classification
73+
The Broadcom KNET driver will be modified to provide a similar KNET filter infrastructure as the Rx path to allow classification of pkt types as they are received by the KNET driver from the Linux kernel. The pkt skbuff will have destination port information from the Linux kernel so per interface protocol counters and any drop counters will be updated.
74+
75+
### 3.1.3 Protocol Classification Criteria
76+
Packets will be parsed and classified according to the criteria in the following table. Any packets that cannot be classified will have counters updated in the "unknown" category.
77+
78+
References:
79+
- https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml
80+
- https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
81+
- https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
82+
- SAI Hostinterface protocol qualifier implementations
83+
84+
### **Table 1: Protocol Classification Criteria**
85+
86+
| Protocols | Queue | Classification Criteria
87+
|----------------------|-------|----------------------------
88+
| LACP | 23 | (EType==0x8809) && (MAC DA == {01:80:C2:00:00:02})
89+
| UDLD | 22 | (MAC DA == {01:00:0C:CC:CC:CC})
90+
| STP | 21 | (MAC DA == {01:80:C2:00:00:00})
91+
| PVRSTP | 21 | (MAC DA == {01:00:0C:CC:CC:CD}
92+
| BFDv4 | 20 | (EType==0x800) && (IpProtocol == 17) && (L4DstPort == 3784 or 4784)
93+
| BFDv6 | 20 | (EType==0x86DD) && (IpProtocol == 17) && (L4DstPort == 3784 or 4784)
94+
| PTP | 19 | (EType==0x88F7)
95+
| LLDP | 18 | (EType==0x88CC) && (MAC DA == {01:80:C2:00:00:00} or {01:80:C2:00:00:03} or {01:80:C2:00:00:0e})
96+
| VRRP | 17 | (EType==0x800) && (IpProtocol == 112)
97+
| ICCP | 16 | (IpProtocol == 6) && (IpProtocol == 8888)
98+
| OSPFv4 | 15 | (EType==0x800) && (IpProtocol == 89)
99+
| BGPv4 | 14 | (EType==0x800) && (IpProtocol == 6) && (L4Port == 179)
100+
| BGPv6 | 14 | (EType==0x86DD) && (IpProtocol == 6) && (L4Port == 179)
101+
| PIM | 13 | (IpProtocol == 103)
102+
| IGMP | 12 | (EType==0x800) && (IpProtocol == 2)
103+
| ARP Request | 10 | (EType == 0x806) && (ArpOpCode == 1)
104+
| ARP Reply | 10 | (EType == 0x806) && (ArpOpCode == 2)
105+
| ARP | 10 | (EType == 0x806)
106+
| NDP | 10 | (EType == 0x86DD) && (IPv6NextHeader == 58) && (IPv6HopLimit == 255) && (Type Code is 133 ~ 137)
107+
| DHCPv4 | 9 | (EType == 0x800) && (IpProtocol == 17) && ((L4SrcPort == 68) && (L4DstPort == 67)) or (L4SrcPort == 67) && (L4DstPort == 68))
108+
| DHCPv6 | 9 | (EType == 0x86DD) && (IpProtocol == 17) && (L4DstPort == 547 or 546)
109+
| ICMP Echo Request | 8 | (IpProtocol == 1) && (ICMP type == 0)
110+
| ICMP Echo Reply | 8 | (IpProtocol == 1) && (ICMP type == 8)
111+
| ICMP | 8 | (IpProtocol == 1)
112+
| SSH | 7 | (IpProtocol == 6) && ((L4Port == 22))|
113+
| INET | 7 | (Etype==0x800)
114+
| INETv6 | 7 | (Etype==0x88DD)
115+
| Subnet | 6 | Not classified (Rx queue counters only)
116+
| NAT | 5 | Not classified (Rx queue counters only)
117+
| MTU | 4 | Not classified (Rx queue counters only)
118+
| Sflow | 3 | Rx: Pkt sample metadata, Tx: (L4Port == 6343 for inband sflow datagram to collector)
119+
| TTL | 0 | TTL == 0 or TTL == 1
120+
121+
### 3.1.4 Packet Drop Error types
122+
Errors in KNET (and in Rx kernel path) which result in packet drops are counted per protocol/queue on each interface. Some common errors are listed below.
123+
### **Table 2: Packet Drop Errors**
124+
| Error | Description
125+
|----------------------|-----------------------------------
126+
| LINK_DOWN | Kernel network interface was in down state
127+
| NO_SKB | Packet SKB alloc failed
128+
| NO_BUFFER | No DMA buffer resource available (congested PktIO)
129+
| KERNEL_DROP | Rx packet drop in Linux kernel network stack
130+
| NO_FILTER_MATCH | Rx packet did not match any KNET filters (no handlers)
131+
| UNKN_NETIF | Unknown src network interface for Rx packet
132+
| HW_RESET | Packet dropped due to HW reset cleanup in progress
133+
134+
## 3.2 DB Changes
135+
There are no new changes to SONiC DBs.
136+
137+
## 3.3 Switch State Service Design
138+
### 3.3.1 Orchestration Agent
139+
There are no new changes to Orchagent.
140+
## 3.4 SyncD
141+
There are no new changes to SyncD.
142+
143+
## 3.5 Manageability
144+
There are no new changes to manageability infrastructure
145+
146+
## 3.6 CLI
147+
KNET Packet stats at switch and interface levels can be shown through click commands or by dumping KNET pkt_stats procfs file. Rx and Tx error counter details are available for protocol and rx queue counters at switch and interface levels.
148+
149+
### 3.6.1 Protocol Stats
150+
* Show protocol stats (real output will not show entries with zero counts)
45151
```
46-
DUT# cat /proc/bcm/knet-cb/pkt_stats
152+
DUT# show knet stats protocol
153+
or
154+
DUT# cat /proc/bcm/knet/stats/protocol
155+
47156
Total rx = 101127
48157
Total tx = 235644
49-
protocol rx rx_err tx tx_err
50-
--------------------------------------------------
51-
UDLD 0 0 0 0
52-
STP 0 0 0 0
53-
BFD 0 0 0 0
54-
PTP 0 0 0 0
55-
LLDP 24291 0 54 0
56-
VRRP 0 0 0 0
57-
ICCP 0 0 0 0
58-
OSPF 0 0 0 0
59-
BGP 0 0 0 0
60-
PIM 0 0 0 0
61-
IGMP 0 0 0 0
62-
ARP_SUPPRESS 0 0 0 0
63-
ARP 8953 0 9103 0
64-
DHCP 0 0 0 0
65-
ICMP 0 0 0 0
66-
IP2ME 0 0 0 0
67-
IP2ME_SUBNET 0 0 0 0
68-
NAT 0 0 0 0
69-
IPMTU 0 0 0 0
70-
SFLOW 0 0 0 0
71-
DROP 0 0 0 0
72-
UNSPEC 0 0 0 0
158+
protocol rx rx_err tx tx_err
159+
------------------------------------------------------------
160+
LACP 0 0 0 0
161+
UDLD 0 0 0 0
162+
STP 0 0 0 0
163+
PVRSTP 0 0 0 0
164+
BFDv4 0 0 0 0
165+
BFDv6 0 0 0 0
166+
PTP 0 0 0 0
167+
LLDP 24291 0 54 0
168+
VRRP 0 0 0 0
169+
ICCP 0 0 0 0
170+
OSPF 0 0 0 0
171+
BGPv4 0 0 0 0
172+
BGPv6 0 0 0 0
173+
PIM 0 0 0 0
174+
IGMP 0 0 0 0
175+
ARP Req 4428 0 4428 0
176+
ARP Rply 4428 0 4428 0
177+
ARP 8856 0 8856 0
178+
NDP 0 0 0 0
179+
DHCPv4 0 0 0 0
180+
DHCPv6 0 0 0 0
181+
ICMP EchoReq 0 0 0 0
182+
ICMP EchoRply 0 0 0 0
183+
ICMP 0 0 0 0
184+
SSH 0 0 0 0
185+
SFLOW 0 0 0 0
186+
TTL 0 0 0 0
187+
INETv4 0 0 0 0
188+
INETv6 0 0 0 0
189+
UNKNOWN 0 0 0 0
190+
```
191+
* Show interface level protocol stats
192+
```
193+
DUT# show knet Ethernet0 stats protocol
194+
or
195+
DUT# cat /proc/bcm/knet/Ethernet0/stats/protocol
196+
197+
Total Ethernet0 rx = 101127
198+
Total Ethernet0 tx = 235644
199+
protocol rx rx_err tx tx_err
200+
------------------------------------------------------------
201+
LACP 0 0 0 0
202+
UDLD 0 0 0 0
203+
STP 0 0 0 0
204+
PVRSTP 0 0 0 0
205+
BFDv4 0 0 0 0
206+
...
207+
```
208+
* Show interface level protocol stats with error details
209+
```
210+
DUT# show knet Ethernet0 stats protocol details
211+
or
212+
DUT# echo "detail=1" > /proc/bcm/knet/Ethernet0/stats/protocol
213+
DUT# cat /proc/bcm/knet/Ethernet0/stats/protocol
214+
DUT# echo "detail=0" > /proc/bcm/knet/Ethernet0/stats/protocol
215+
216+
Total Ethernet0 rx = 101127
217+
Total Ethernet0 tx = 235644
218+
protocol rx rx_err tx tx_err
219+
------------------------------------------------------------
220+
LACP 0 0 0 0
221+
UDLD 0 0 0 0
222+
STP 0 0 0 0
223+
PVRSTP 685 222 0 193
224+
LINK_DOWN 208 168
225+
NO_SKB 2 5
226+
NO_BUFFER 0 20
227+
KERNEL_DROP 12 0
228+
BFDv4 0 0 0 0
229+
...
73230
```
74231

75-
### 1.1.2 Configuration and Management Requirements
76-
Statistics will be provided via KNET procfs file
77232

233+
* Clear protocol pkt statistics
234+
```
235+
DUT# sonic-clear knet stats protocol
236+
DUT# sonic-clear knet Ethernet0 stats protocol
237+
or
238+
DUT# echo "clear" > /proc/bcm/knet/stats/protocol
239+
DUT# echo "clear" > /proc/bcm/knet/Ethernet0/stats/protocol
240+
```
241+
### 3.6.2 Rx Queue Stats
242+
```
243+
DUT# show knet stats rx_queue
244+
or
245+
DUT# cat /proc/bcm/knet/stats/rx_queue
246+
247+
Total rx = 24918
248+
name queue rx rx_err
249+
----------------------------------------------
250+
SFLOW 3 0 0
251+
ARP 10 238 0
252+
LLDP 18 24291 0
253+
LACP 23 389 0
254+
```
255+
256+
* Show interface level rx queue stats
257+
```
258+
DUT# show knet Ethernet0 stats rx_queue
259+
or
260+
DUT# cat /proc/bcm/knet/Ethernet0/stats/rx_queue
261+
262+
Total Ethernet0 rx = 24918
263+
name queue rx rx_err
264+
----------------------------------------------
265+
SFLOW 3 0 0
266+
ARP 10 238 0
267+
LLDP 18 24291 0
268+
LACP 23 389 0
269+
```
270+
271+
* Show interface level rx queue stats with error details
272+
```
273+
DUT# show knet Ethernet0 stats rx_queue details
274+
or
275+
DUT# echo "detail=1" > /proc/bcm/knet/Ethernet0/stats/rx_queue
276+
DUT# cat /proc/bcm/knet/Ethernet0/stats/rx_queue
277+
DUT# echo "detail=0" > /proc/bcm/knet/Ethernet0/stats/rx_queue
278+
279+
Total Ethernet0 rx = 24918
280+
name queue rx rx_err
281+
----------------------------------------------
282+
SFLOW 3 0 0
283+
ARP 10 238 220
284+
LINK_DOWN 208
285+
KERNEL_DROP 12
286+
LLDP 18 24291 15
287+
KERNEL_DROP 15
288+
LACP 23 389 0
289+
DEFAULT 0 0 7
290+
NO_FILTER_MATCH 2
291+
UNKN_NETIF 2
292+
UNKN_DEST_TYPE 3
293+
```
294+
295+
* Clear Rx Queue stats
296+
```
297+
DUT# sonic-clear knet stats rx_queue
298+
DUT# sonic-clear knet Ethernet0 stats rx_queue
299+
or
300+
DUT# echo "clear" > /proc/bcm/knet/stats/rx_queue
301+
DUT# echo "clear" > /proc/bcm/knet/Ethernet0/stats/rx_queue
302+
```
303+
304+
# 4 Flow Diagrams
305+
306+
# 5 Error Handling
307+
Not applicable
308+
309+
# 6 Serviceability and Debug
310+
The new debug counters introduced at switch and interface levels (with drop details) will be added to techsupport collection with 2 samples each
311+
312+
# 7 Warm Boot Support
313+
No warmboot support. CPU Pkt IO counters are maintained in KNET kernel network driver which gets cleared on CPU reset on a warmboot operation.
314+
315+
# 8 Scalability
316+
## 8.1 Profiling and Tuning
317+
The CPU packet IO performance impact on throughput and latency with the addition of processing to identify pkt type for counters will be profiled. It is expected there will be minimal impact.
318+
319+
# 9 Unit Test
320+
## 9.1 Functional Test Cases
321+
### 9.1.1 Protocol Stats
322+
1. Verify Rx and Tx pkt counters on switch/interface levels for each protocol
323+
2. Verify KERNEL_DROP Rx drop counter on switch/interface levels for selected protocols
324+
3. Verify LINK_DOWN Rx and Tx drop counters on switch/interface levels for selected protocols
325+
4. Verify NO_BUFFER Tx drop counters on switch/interface levels for selected protocols
326+
5. Verify clear stats for switch and interface level protocol counters
327+
328+
### 9.1.2 Rx Queue Stats
329+
1. Verify Rx queues and description match COPP config
330+
2. Verify Rx queue pkt counters on switch/interface levels for each protocol
331+
3. Verify KERNEL_DROP Rx queue drop counter on switch/interface levels for selected protocols
332+
4. Verify LINK_DOWN Rx queue drop counters on switch/interface levels for selected protocols
333+
5. Verify clear stats for switch and interface level Rx queue counters
334+
335+
336+
## 9.2 Warm Boot Test Cases
337+
Not applicable
338+
339+
## 9.3 Negative Test Cases
340+
341+
# 10 Internal Design Information
342+
## 10.1 Guidance on simulating triggers for testing packet drops
343+
### 10.1.1 LINK_DOWN pkt drops
344+
* The following command can directly set netdevice link status down while physical link is up. Packets will continue to be punted up to CPU but will drop with LINK_DOWN reason. CPU Tx direction should also show drops
345+
```
346+
DUT# echo "Ethernet0=down" > /proc/bcm/knet/link
347+
DUT# cat /proc/bcm/knet/link
348+
Software link status:
349+
Ethernet0 down
350+
```
351+
### 10.1.2 KERNEL_DROP Rx pkt drops
352+
* Send LACP packets to the DUT without the src port configured on a portchannel. The Linux kernel will drop the packet since the src port has not been registered as a portchannel member in the teamd kernel module (portchannel kernel component).
353+
354+
### 10.1.3 NO_BUFFER Tx pkt drops
355+
* Decrease the KNET Tx buffers to a low value (8 or 4) to increase chance of congestion then send flood ping to congest the CPU Tx path and induce out of DMA buffer resource Tx drops. This operation should be used for testing only with all interfaces down. Changing the max number of Tx buffers may cause a crash if packets are being processed in KNET.
356+
```
357+
echo "max_tx_dcbs=4" > /proc/bcm/knet/dma
358+
```
359+
* Then check the Tx high watermark stats after sending CPU Tx burst.
360+
```
361+
DUT# cat /proc/bcm/knet/dstats | grep "Tx used DCBs hi wm"
362+
Tx used DCBs hi wm 4
363+
```

0 commit comments

Comments
 (0)