zephyr/subsys/net/ip/net_tc_mapping.h
Jukka Rissanen f5fb80750e net: Enable running without TX or RX threads
Set the default behaviour of the networking subsystem so that
no TX or RX threads are created. This will save RAM as there
is no need to allocate stack space for the RX/TX threads.
Also this will give small improvement to network packet latency
shown here:
* with 1 traffic class (1 TX and RX thread)

Avg TX net_pkt (42707) time 60 us	[0->22->15->22=59 us]
Avg RX net_pkt (42697) time 36 us	[0->10->3->12->7=32 us]

* with 0 traffic classes (no TX and RX threads)

Avg TX net_pkt (41608) time 42 us	[0->21->20=41 us]
Avg RX net_pkt (41593) time 31 us	[0->9->12->8=29 us]

In this qemu_x86 test run, 40k UDP packets was transferred between
echo-server and echo-client. In TX the speed increase was 30% and
in RX it was 14%.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00

151 lines
5.2 KiB
C

/** @file
* @brief Various priority to traffic class mappings
*
* This is not to be included by the application.
*/
/*
* Copyright (c) 2018 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __TC_MAPPING_H
#define __TC_MAPPING_H
#include <zephyr/types.h>
/* All the maps below use priorities and indexes, below is the list of them
* according to 802.1Q - table I-2.
*
* Priority Acronym Traffic types
* 1 (lowest) BK Background
* 0 (default) BE Best effort
* 2 EE Excellent effort
* 3 CA Critical applications
* 4 VI Video, < 100 ms latency and jitter
* 5 VO Voice, < 10 ms latency and jitter
* 6 IC Internetwork control
* 7 (highest) NC Network control
*/
/* Helper macros used to generate the map to use */
#define PRIORITY2TC_GEN_INNER(TYPE, COUNT) priority2tc_ ## TYPE ## _ ## COUNT
#define PRIORITY2TC_GEN(TYPE, COUNT) PRIORITY2TC_GEN_INNER(TYPE, COUNT)
#if defined(CONFIG_NET_TC_MAPPING_STRICT) && (NET_TC_COUNT > 0)
/* This is the recommended priority to traffic class mapping for
* implementations that do not support the credit-based shaper transmission
* selection algorithm.
* Ref: 802.1Q - chapter 8.6.6 - table 8-4
*/
#if NET_TC_TX_COUNT == 1 || NET_TC_RX_COUNT == 1
static const uint8_t priority2tc_strict_1[] = {0, 0, 0, 0, 0, 0, 0, 0};
#endif
#if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2
static const uint8_t priority2tc_strict_2[] = {0, 0, 0, 0, 1, 1, 1, 1};
#endif
#if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3
static const uint8_t priority2tc_strict_3[] = {0, 0, 0, 0, 1, 1, 2, 2};
#endif
#if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4
static const uint8_t priority2tc_strict_4[] = {0, 0, 1, 1, 2, 2, 3, 3};
#endif
#if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5
static const uint8_t priority2tc_strict_5[] = {0, 0, 1, 1, 2, 2, 3, 4};
#endif
#if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6
static const uint8_t priority2tc_strict_6[] = {1, 0, 2, 2, 3, 3, 4, 5};
#endif
#if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7
static const uint8_t priority2tc_strict_7[] = {1, 0, 2, 3, 4, 4, 5, 6};
#endif
#if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8
static const uint8_t priority2tc_strict_8[] = {1, 0, 2, 3, 4, 5, 6, 7};
#endif
#if NET_TC_TX_COUNT > 0
static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(strict, NET_TC_TX_COUNT);
#endif
#if NET_TC_RX_COUNT > 0
static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(strict, NET_TC_RX_COUNT);
#endif
#elif defined(CONFIG_NET_TC_MAPPING_SR_CLASS_A_AND_B) && (NET_TC_COUNT > 0)
/* This is the recommended priority to traffic class mapping for a system that
* supports SR (Stream Reservation) class A and SR class B.
* Ref: 802.1Q - chapter 34.5 - table 34-1
*/
#if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2
static const uint8_t priority2tc_sr_ab_2[] = {0, 0, 1, 1, 0, 0, 0, 0};
#endif
#if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3
static const uint8_t priority2tc_sr_ab_3[] = {0, 0, 1, 2, 0, 0, 0, 0};
#endif
#if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4
static const uint8_t priority2tc_sr_ab_4[] = {0, 0, 2, 3, 1, 1, 1, 1};
#endif
#if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5
static const uint8_t priority2tc_sr_ab_5[] = {0, 0, 3, 4, 1, 1, 2, 2};
#endif
#if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6
static const uint8_t priority2tc_sr_ab_6[] = {0, 0, 4, 5, 1, 1, 2, 3};
#endif
#if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7
static const uint8_t priority2tc_sr_ab_7[] = {0, 0, 5, 6, 1, 2, 3, 4};
#endif
#if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8
static const uint8_t priority2tc_sr_ab_8[] = {1, 0, 6, 7, 2, 3, 4, 5};
#endif
#if NET_TC_TX_COUNT > 0
static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(sr_ab, NET_TC_TX_COUNT);
#endif
#if NET_TC_RX_COUNT > 0
static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(sr_ab, NET_TC_RX_COUNT);
#endif
#elif defined(CONFIG_NET_TC_MAPPING_SR_CLASS_B_ONLY) && (NET_TC_COUNT > 0)
/* This is the recommended priority to traffic class mapping for a system that
* supports SR (Stream Reservation) class B only.
* Ref: 802.1Q - chapter 34.5 - table 34-2
*/
#if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2
static const uint8_t priority2tc_sr_b_2[] = {0, 0, 1, 0, 0, 0, 0, 0};
#endif
#if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3
static const uint8_t priority2tc_sr_b_3[] = {0, 0, 2, 0, 1, 1, 1, 1};
#endif
#if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4
static const uint8_t priority2tc_sr_b_4[] = {0, 0, 3, 0, 1, 1, 2, 2};
#endif
#if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5
static const uint8_t priority2tc_sr_b_5[] = {0, 0, 4, 1, 2, 2, 3, 3};
#endif
#if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6
static const uint8_t priority2tc_sr_b_6[] = {0, 0, 5, 1, 2, 2, 3, 4};
#endif
#if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7
static const uint8_t priority2tc_sr_b_7[] = {1, 0, 6, 2, 3, 3, 4, 5};
#endif
#if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8
static const uint8_t priority2tc_sr_b_8[] = {1, 0, 7, 2, 3, 4, 5, 6};
#endif
#if NET_TC_TX_COUNT > 0
static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(sr_b, NET_TC_TX_COUNT);
#endif
#if NET_TC_RX_COUNT > 0
static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(sr_b, NET_TC_RX_COUNT);
#endif
#endif
#endif /* __TC_MAPPING_H */