Skip to content

Commit b363c93

Browse files
committed
samples: net: QoS: Add quality of service sample
Add a sample, that shows the power of quality of service in Zephyr. Signed-off-by: Cla Mattia Galliard <[email protected]>
1 parent bf282d3 commit b363c93

File tree

6 files changed

+634
-0
lines changed

6 files changed

+634
-0
lines changed

samples/net/qos/QoS.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. zephyr:code-sample-category:: QoS
2+
:name: Quality of Service
3+
:show-listing:
4+
5+
These samples demonstrate packet filters for Quality of Service (QoS).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(ethernet_qos_demo)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
.. zephyr:code-sample:: quality-of-service
2+
:name: Quality of Service
3+
:relevant-api: ethernet
4+
5+
Implements a demo of quality of service on the ethernet layer.
6+
7+
Overview
8+
********
9+
10+
The purpose of this sample is to show quality-of-service (QoS) on the ethernet layer.
11+
12+
The source code for this sample application can be found at:
13+
:zephyr_file:`samples/net/qos/ethernet`.
14+
15+
Building and Running
16+
********************
17+
18+
Build like this:
19+
20+
.. zephyr-app-commands::
21+
:zephyr-app: samples/net/qos/ethernet
22+
:board: <board_to_use>
23+
:goals: build
24+
:compact:
25+
26+
This sample only works with the native simulator. After the sample starts, it
27+
fakes incoming network pakets on a fake network interface and prints
28+
statistics about it.
29+
30+
Run with ``./build/zephyr/zephyr.exe``
31+
32+
33+
Statistics (With Quality of Service Filtering)
34+
**********************************************
35+
36+
c (x) := command service for priority x (high means higher priority)
37+
38+
e (x) := echo service for priority x (high means higher priority)
39+
40+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
41+
| work us | c(7) | e(7) | c(6) | e(6) | c(5) | e(5) | c(4) | e(4) | c(3) | e(3) | c(2) | e(2) | c(1) | e(1) | c(0) | e(0) |
42+
+=========+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+
43+
| 800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
44+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
45+
| 850 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 53 |
46+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
47+
| 900 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 35 | 0 |
48+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
49+
| 950 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 2 | 0 |
50+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
51+
| 1000 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 0 | 0 | 0 |
52+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
53+
| 1100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 9 | 0 | 0 | 0 |
54+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
55+
| 1200 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 0 | 0 | 0 | 0 | 0 |
56+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
57+
| 1300 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 10 | 0 | 0 | 0 | 0 | 0 |
58+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
59+
| 1400 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 29 | 0 | 0 | 0 | 0 | 0 | 0 |
60+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
61+
| 1600 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
62+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
63+
| 1800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 11 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
64+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
65+
| 2000 | 100 | 100 | 100 | 100 | 100 | 100 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
66+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
67+
| 3000 | 100 | 100 | 100 | 100 | 12 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
68+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
69+
| 4000 | 100 | 100 | 99 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
70+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
71+
| 5000 | 100 | 100 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
72+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
73+
| 6000 | 100 | 100 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
74+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
75+
| 7000 | 100 | 85 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
76+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
77+
| 8000 | 100 | 49 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
78+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
79+
| 9000 | 100 | 22 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
80+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
81+
| 10000 | 99 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
82+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
83+
| 15000 | 44 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
84+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
85+
86+
87+
Statistics (No Quality of Service Filtering)
88+
**********************************************
89+
90+
c (x) := command service for priority x (high means higher priority)
91+
92+
e (x) := echo service for priority x (high means higher priority)
93+
94+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
95+
| work us | c(7) | e(7) | c(6) | e(6) | c(5) | e(5) | c(4) | e(4) | c(3) | e(3) | c(2) | e(2) | c(1) | e(1) | c(0) | e(0) |
96+
+=========+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+
97+
| 800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
98+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
99+
| 850 | 100 | 53 | 100 | 99 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
100+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
101+
| 900 | 100 | 1 | 100 | 23 | 100 | 99 | 100 | 99 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
102+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
103+
| 950 | 100 | 1 | 100 | 1 | 100 | 7 | 100 | 99 | 100 | 99 | 100 | 99 | 100 | 99 | 100 | 100 |
104+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
105+
| 1000 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 98 | 100 | 99 | 100 | 99 | 100 | 99 |
106+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
107+
| 1100 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 19 | 100 | 97 | 100 | 97 |
108+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
109+
| 1200 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 59 |
110+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
111+
| 1300 | 39 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
112+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
113+
| 1400 | 1 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
114+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
115+
| 1600 | 1 | 0 | 1 | 0 | 99 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
116+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
117+
| 1800 | 1 | 0 | 1 | 0 | 12 | 0 | 99 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
118+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
119+
| 2000 | 1 | 0 | 1 | 0 | 1 | 0 | 99 | 0 | 99 | 0 | 99 | 0 | 99 | 0 | 100 | 0 |
120+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
121+
| 3000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 98 | 0 | 98 | 0 | 99 | 0 |
122+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
123+
| 4000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 97 | 0 | 98 | 0 |
124+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
125+
| 5000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 96 | 0 | 97 | 0 |
126+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
127+
| 6000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 33 | 0 | 96 | 0 |
128+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
129+
| 7000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 95 | 0 |
130+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
131+
| 8000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 94 | 0 |
132+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
133+
| 9000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 93 | 0 |
134+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
135+
| 10000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 92 | 0 |
136+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
137+
| 15000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 30 | 0 |
138+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+

samples/net/qos/ethernet/prj.conf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Networking config
2+
CONFIG_NETWORKING=y
3+
CONFIG_NET_IPV4=y
4+
CONFIG_NET_IPV6=n
5+
CONFIG_NET_IF_MAX_IPV4_COUNT=2
6+
CONFIG_NET_RX_DEFAULT_PRIORITY=7
7+
CONFIG_NET_TX_DEFAULT_PRIORITY=7
8+
9+
# Logging
10+
CONFIG_LOG=y
11+
CONFIG_NET_LOG=y
12+
CONFIG_LOG_THREAD_ID_PREFIX=y
13+
CONFIG_THREAD_NAME=y
14+
15+
# Network buffers
16+
CONFIG_NET_PKT_RX_COUNT=128
17+
CONFIG_NET_BUF_RX_COUNT=1800
18+
CONFIG_NET_PKT_TX_COUNT=64
19+
CONFIG_NET_BUF_TX_COUNT=900
20+
21+
# Network traffic class queues
22+
CONFIG_NET_TC_THREAD_PRIO_CUSTOM=y
23+
CONFIG_NET_TC_TX_THREAD_BASE_PRIO=16
24+
CONFIG_NET_TC_TX_THREAD_PRIO_SPREAD=2
25+
CONFIG_NET_TC_RX_THREAD_BASE_PRIO=15
26+
CONFIG_NET_TC_RX_THREAD_PRIO_SPREAD=2
27+
CONFIG_NET_TC_THREAD_PREEMPTIVE=y
28+
CONFIG_NET_TC_RX_COUNT=8
29+
CONFIG_NET_TC_TX_COUNT=8
30+
CONFIG_NET_TC_LOG_LEVEL_DBG=y
31+
32+
# Network Packet filters
33+
CONFIG_NET_PKT_FILTER=y
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sample:
2+
description: demo of quality of service for ethernet layer
3+
name: quality_of_service
4+
common:
5+
harness: net
6+
tests:
7+
sample.net.Qos:
8+
tags:
9+
- net
10+
- socket
11+
platform_allow:
12+
- native_sim
13+
- native_sim/native/64
14+
integration_platforms:
15+
- native_sim

0 commit comments

Comments
 (0)