P4C
The P4 Compiler
Toggle main menu visibility
Main Page
P4C Repository Organization
Getting Started
P4C Intermediate Representation (IR)
Frontend
Midend
Backends
Behavioral Model Backend
DPDK Backend
eBPF Backend
TC Backend
uBPF Backend
P4test Backend
Graphs Backend
p4fmt (P4 Formatter)
P4Tools
P4Smith
P4Testgen
Contribute to the P4 Compiler Project
Releases
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
w
x
z
Functions
a
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
w
x
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Typedefs
Enumerations
Enumerator
Related Symbols
•
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
Loading...
Searching...
No Matches
egress_packet_length.h
1
19
#ifndef BF_P4C_ARCH_FROMV1_0_EGRESS_PACKET_LENGTH_H_
20
#define BF_P4C_ARCH_FROMV1_0_EGRESS_PACKET_LENGTH_H_
21
22
#include "frontends/common/resolveReferences/referenceMap.h"
23
#include "frontends/p4/typeMap.h"
24
#include "ir/ir.h"
25
#include "ir/pass_manager.h"
26
27
// Issue:
28
//
29
// When packet is sent from ingress to egress, packet length presented to egress pipeline is
30
// the original packet length as the packet entered the ingress pipeline (including FCS).
31
// There is no addition/subtraction based on headers added/removed or if bridged metadata is added.
32
//
33
// For mirrored packets, the packet length presented to the egress pipeline is different:
34
// = the original packet length as it entered ingress (including FCS) + the mirror header size
35
// We have to perform adjustment for mirrored packets to exclude the mirror header size from
36
// the packet length.
37
//
38
//
39
// Implementation:
40
//
41
// 1) In each mirror field list parser state, we insert an assignment which writes the adjust
42
// amount to a field, "egress_pkt_len_adjust". The value to assign, a compile time constant,
43
// returned by "sizeInBytes(<header>)", is known after PHV allocation, when we known which
44
// containers mirror metadata is allocated in, and therefore can calculate total number of
45
// bytes to adjust (in terms of container size). To carry this late binding constant in the IR,
46
// we introduce the IR::BFN::TotalContainerSize type. We resolve these in the LowerParser pass.
47
//
48
// 2) Insert a no-match table that runs the action below, in the front of the egress table sequence
49
// before the first use of "egress_pkt_length":
50
// egress_pkt_length = egress_pkt_length - egress_pkt_len_adjust
51
//
52
53
class
AdjustEgressPacketLength
:
public
PassManager {
54
bool
egressParsesMirror =
false
;
55
bool
egressUsesPacketLength =
false
;
56
57
public
:
58
AdjustEgressPacketLength
(
P4::ReferenceMap
*refMap,
P4::TypeMap
*typeMap);
59
};
53
class
AdjustEgressPacketLength
:
public
PassManager {
…
};
60
61
#endif
/* BF_P4C_ARCH_FROMV1_0_EGRESS_PACKET_LENGTH_H_ */
AdjustEgressPacketLength
Definition
egress_packet_length.h:53
P4::ReferenceMap
Class used to encode maps from paths to declarations.
Definition
referenceMap.h:66
P4::TypeMap
Definition
typeMap.h:41
backends
tofino
bf-p4c
arch
fromv1.0
egress_packet_length.h
Generated by
1.12.0