P4C
The P4 Compiler
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
};
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