Skip to content

Commit 786f0dc

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 ca2bdd7 commit 786f0dc

File tree

6 files changed

+631
-0
lines changed

6 files changed

+631
-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: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
Building and Running
13+
********************
14+
15+
Build like this:
16+
17+
.. zephyr-app-commands::
18+
:zephyr-app: samples/net/qos/ethernet
19+
:board: <board_to_use>
20+
:goals: build
21+
:compact:
22+
23+
This sample only works with the native simulator. After the sample starts, it
24+
fakes incoming network pakets on a fake network interface and prints
25+
statistics about it.
26+
27+
Run with ``./build/zephyr/zephyr.exe``
28+
29+
30+
Statistics (With Quality of Service Filtering)
31+
**********************************************
32+
33+
c (x) := command service for priority x (high means higher priority)
34+
35+
e (x) := echo service for priority x (high means higher priority)
36+
37+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
38+
| 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) |
39+
+=========+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+
40+
| 800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
41+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
42+
| 850 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 53 |
43+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
44+
| 900 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 35 | 0 |
45+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
46+
| 950 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 2 | 0 |
47+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
48+
| 1000 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 0 | 0 | 0 |
49+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
50+
| 1100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 9 | 0 | 0 | 0 |
51+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
52+
| 1200 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 0 | 0 | 0 | 0 | 0 |
53+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
54+
| 1300 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 10 | 0 | 0 | 0 | 0 | 0 |
55+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
56+
| 1400 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 29 | 0 | 0 | 0 | 0 | 0 | 0 |
57+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
58+
| 1600 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
59+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
60+
| 1800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 11 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
61+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
62+
| 2000 | 100 | 100 | 100 | 100 | 100 | 100 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
63+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
64+
| 3000 | 100 | 100 | 100 | 100 | 12 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
65+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
66+
| 4000 | 100 | 100 | 99 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
67+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
68+
| 5000 | 100 | 100 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
69+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
70+
| 6000 | 100 | 100 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
71+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
72+
| 7000 | 100 | 85 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
73+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
74+
| 8000 | 100 | 49 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
75+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
76+
| 9000 | 100 | 22 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
77+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
78+
| 10000 | 99 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
79+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
80+
| 15000 | 44 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
81+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
82+
83+
84+
Statistics (No Quality of Service Filtering)
85+
**********************************************
86+
87+
c (x) := command service for priority x (high means higher priority)
88+
89+
e (x) := echo service for priority x (high means higher priority)
90+
91+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
92+
| 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) |
93+
+=========+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+======+
94+
| 800 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
95+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
96+
| 850 | 100 | 53 | 100 | 99 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
97+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
98+
| 900 | 100 | 1 | 100 | 23 | 100 | 99 | 100 | 99 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
99+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
100+
| 950 | 100 | 1 | 100 | 1 | 100 | 7 | 100 | 99 | 100 | 99 | 100 | 99 | 100 | 99 | 100 | 100 |
101+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
102+
| 1000 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 98 | 100 | 99 | 100 | 99 | 100 | 99 |
103+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
104+
| 1100 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 19 | 100 | 97 | 100 | 97 |
105+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
106+
| 1200 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 1 | 100 | 59 |
107+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
108+
| 1300 | 39 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
109+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
110+
| 1400 | 1 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
111+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
112+
| 1600 | 1 | 0 | 1 | 0 | 99 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
113+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
114+
| 1800 | 1 | 0 | 1 | 0 | 12 | 0 | 99 | 0 | 99 | 0 | 100 | 0 | 100 | 0 | 100 | 0 |
115+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
116+
| 2000 | 1 | 0 | 1 | 0 | 1 | 0 | 99 | 0 | 99 | 0 | 99 | 0 | 99 | 0 | 100 | 0 |
117+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
118+
| 3000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 98 | 0 | 98 | 0 | 99 | 0 |
119+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
120+
| 4000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 97 | 0 | 98 | 0 |
121+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
122+
| 5000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 96 | 0 | 97 | 0 |
123+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
124+
| 6000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 33 | 0 | 96 | 0 |
125+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
126+
| 7000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 95 | 0 |
127+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
128+
| 8000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 94 | 0 |
129+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
130+
| 9000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 93 | 0 |
131+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
132+
| 10000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 92 | 0 |
133+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
134+
| 15000 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 30 | 0 |
135+
+---------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+

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)