Debian Codegraph @

src/net_def.h

raw symbols SCIP
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3 * Copyright (C) 2022-2023 Linutronix GmbH
4 * Author Kurt Kanzenbach <[email protected]>
5 */
6
7 #ifndef _NET_DEF_H_
8 #define _NET_DEF_H_
9
10 #include <linux/if_ether.h>
11 #include <linux/if_link.h>
12 #include <linux/if_vlan.h>
13
14 #define ETH_P_PROFINET_RT (0x8892)
15 #ifndef ETH_P_LLDP
16 #define ETH_P_LLDP (0x88cc)
17 #endif
18 #ifndef ETH_P_OPCUA_PUBSUB
19 #define ETH_P_OPCUA_PUBSUB (0xb62c)
20 #endif
21 #ifndef ETH_P_AVTP
22 #define ETH_P_AVTP (0x22f0)
23 #endif
24
25 #define VLAN_ID_MASK 0x0fff
26 #define VLAN_PCP_SHIFT 13
27
28 /* PROFINET VID values are predefined too. */
29 #define PROFINET_RT_VID_VALUE 0
30 #define TSN_LOW_VID_VALUE 0x102
31 #define TSN_HIGH_VID_VALUE 0x101
32
33 /* PROFINET PCP values are predefined. */
34 #define DCP_PCP_VALUE 2
35 #define RTA_PCP_VALUE 3
36 #define RTC_PCP_VALUE 4
37 #define TSN_LOW_PCP_VALUE 5
38 #define TSN_HIGH_PCP_VALUE 6
39
40 /* PROFINET FrameIds used by Testbench. */
41 #define TSN_HIGH_FRAMEID 0x0100
42 #define TSN_HIGH_SEC_FRAMEID 0x0101
43 #define TSN_LOW_FRAMEID 0x0200
44 #define TSN_LOW_SEC_FRAMEID 0x0201
45 #define RTC_FRAMEID 0x8000
46 #define RTC_SEC_FRAMEID 0x8001
47 #define RTA_FRAMEID 0xfc01
48 #define RTA_SEC_FRAMEID 0xfc02
49 #define DCP_FRAMEID 0xfefe
50
51 /* VLAN 802.1Q frame. */
52 struct vlan_ethernet_header {
53 unsigned char destination[ETH_ALEN];
54 unsigned char source[ETH_ALEN];
55 __be16 vlan_proto;
56 __be16 vlantci;
57 __be16 vlan_encapsulated_proto;
58 } __attribute__((packed));
59
60 /* VLAN header. */
61 struct vlan_header {
62 __be16 vlan_proto;
63 __be16 vlantci;
64 } __attribute__((packed));
65
66 /* MetaData for testing, error checking and coordination. */
67 struct reference_meta_data {
68 __be32 frame_counter;
69 __be32 cycle_counter;
70 __be64 tx_timestamp;
71 } __attribute__((packed));
72
73 /* PROFINET RT header. */
74 struct profinet_rt_header {
75 __be16 frame_id;
76 struct reference_meta_data meta_data;
77 } __attribute__((packed));
78
79 struct security_meta_data {
80 /*
81 * Bit 0: SecurityInformation.ProtectionMode
82 * Bit 1-7: Reserved
83 */
84 __u8 security_information;
85 /*
86 * Bit 0-3: NextContextID
87 * Bit 4-7: CurrentContextID
88 */
89 __u8 security_control;
90 /*
91 * Bit 0-31: SequenceCounter
92 */
93 __be32 security_sequence_counter;
94 /*
95 * Bit 0-10: Length
96 * Bit 11-15: Reserved
97 */
98 __be16 security_length;
99 } __attribute__((packed));
100
101 struct security_checksum {
102 __u8 checksum[16];
103 } __attribute__((packed));
104
105 /* PROFINET Secure header. */
106 struct profinet_secure_header {
107 __be16 frame_id;
108 struct security_meta_data security_meta_data;
109 struct reference_meta_data meta_data;
110 } __attribute__((packed));
111
112 /* Generic Layer 2 header. */
113 struct generic_l2_header {
114 struct reference_meta_data meta_data;
115 } __attribute__((packed));
116
117 #endif /* _NET_DEF_H_ */