net/core/ieee8021q_helpers.c
Source file repositories/reference/linux-study-clean/net/core/ieee8021q_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/ieee8021q_helpers.c- Extension
.c- Size
- 7506 bytes
- Lines
- 225
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/array_size.hlinux/printk.hlinux/types.hnet/dscp.hnet/ieee8021q.h
Detected Declarations
function ieee8021q_tt_to_tcfunction ietf_dscp_to_ieee8021q_ttexport ieee8021q_tt_to_tcexport ietf_dscp_to_ieee8021q_tt
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2024 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
#include <linux/array_size.h>
#include <linux/printk.h>
#include <linux/types.h>
#include <net/dscp.h>
#include <net/ieee8021q.h>
/* verify that table covers all 8 traffic types */
#define TT_MAP_SIZE_OK(tbl) \
compiletime_assert(ARRAY_SIZE(tbl) == IEEE8021Q_TT_MAX, \
#tbl " size mismatch")
/* The following arrays map Traffic Types (TT) to traffic classes (TC) for
* different number of queues as shown in the example provided by
* IEEE 802.1Q-2022 in Annex I "I.3 Traffic type to traffic class mapping" and
* Table I-1 "Traffic type to traffic class mapping".
*/
static const u8 ieee8021q_8queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0,
[IEEE8021Q_TT_BE] = 1,
[IEEE8021Q_TT_EE] = 2,
[IEEE8021Q_TT_CA] = 3,
[IEEE8021Q_TT_VI] = 4,
[IEEE8021Q_TT_VO] = 5,
[IEEE8021Q_TT_IC] = 6,
[IEEE8021Q_TT_NC] = 7,
};
static const u8 ieee8021q_7queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0,
[IEEE8021Q_TT_BE] = 1,
[IEEE8021Q_TT_EE] = 2,
[IEEE8021Q_TT_CA] = 3,
[IEEE8021Q_TT_VI] = 4, [IEEE8021Q_TT_VO] = 4,
[IEEE8021Q_TT_IC] = 5,
[IEEE8021Q_TT_NC] = 6,
};
static const u8 ieee8021q_6queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0,
[IEEE8021Q_TT_BE] = 1,
[IEEE8021Q_TT_EE] = 2, [IEEE8021Q_TT_CA] = 2,
[IEEE8021Q_TT_VI] = 3, [IEEE8021Q_TT_VO] = 3,
[IEEE8021Q_TT_IC] = 4,
[IEEE8021Q_TT_NC] = 5,
};
static const u8 ieee8021q_5queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0, [IEEE8021Q_TT_BE] = 0,
[IEEE8021Q_TT_EE] = 1, [IEEE8021Q_TT_CA] = 1,
[IEEE8021Q_TT_VI] = 2, [IEEE8021Q_TT_VO] = 2,
[IEEE8021Q_TT_IC] = 3,
[IEEE8021Q_TT_NC] = 4,
};
static const u8 ieee8021q_4queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0, [IEEE8021Q_TT_BE] = 0,
[IEEE8021Q_TT_EE] = 1, [IEEE8021Q_TT_CA] = 1,
[IEEE8021Q_TT_VI] = 2, [IEEE8021Q_TT_VO] = 2,
[IEEE8021Q_TT_IC] = 3, [IEEE8021Q_TT_NC] = 3,
};
static const u8 ieee8021q_3queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0, [IEEE8021Q_TT_BE] = 0,
[IEEE8021Q_TT_EE] = 0, [IEEE8021Q_TT_CA] = 0,
[IEEE8021Q_TT_VI] = 1, [IEEE8021Q_TT_VO] = 1,
[IEEE8021Q_TT_IC] = 2, [IEEE8021Q_TT_NC] = 2,
};
static const u8 ieee8021q_2queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0, [IEEE8021Q_TT_BE] = 0,
[IEEE8021Q_TT_EE] = 0, [IEEE8021Q_TT_CA] = 0,
[IEEE8021Q_TT_VI] = 1, [IEEE8021Q_TT_VO] = 1,
[IEEE8021Q_TT_IC] = 1, [IEEE8021Q_TT_NC] = 1,
};
static const u8 ieee8021q_1queue_tt_tc_map[] = {
[IEEE8021Q_TT_BK] = 0, [IEEE8021Q_TT_BE] = 0,
[IEEE8021Q_TT_EE] = 0, [IEEE8021Q_TT_CA] = 0,
[IEEE8021Q_TT_VI] = 0, [IEEE8021Q_TT_VO] = 0,
[IEEE8021Q_TT_IC] = 0, [IEEE8021Q_TT_NC] = 0,
};
/**
* ieee8021q_tt_to_tc - Map IEEE 802.1Q Traffic Type to Traffic Class
* @tt: IEEE 802.1Q Traffic Type
* @num_queues: Number of queues
*
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/printk.h`, `linux/types.h`, `net/dscp.h`, `net/ieee8021q.h`.
- Detected declarations: `function ieee8021q_tt_to_tc`, `function ietf_dscp_to_ieee8021q_tt`, `export ieee8021q_tt_to_tc`, `export ietf_dscp_to_ieee8021q_tt`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.