|
| 1 | +#ifndef BACKENDS_P4TOOLS_MODULES_P4RTSMITH_TARGETS_TOFINO_CONSTANTS_H_ |
| 2 | +#define BACKENDS_P4TOOLS_MODULES_P4RTSMITH_TARGETS_TOFINO_CONSTANTS_H_ |
| 3 | + |
| 4 | +#include <cstdint> |
| 5 | + |
| 6 | +namespace P4Tools::RTSmith::Tna { |
| 7 | + |
| 8 | +enum Vtofino_gress_t { TOFINO_INGRESS, TOFINO_EGRESS }; |
| 9 | + |
| 10 | +/// TODO: Merge these with the P4Testgen constants. They are the same. |
| 11 | +class TnaConstants { |
| 12 | + public: |
| 13 | + /// Match bits exactly or not at all. |
| 14 | + static constexpr const char *MATCH_KIND_OPT = "optional"; |
| 15 | + /// A match that is used as an argument for the selector. |
| 16 | + static constexpr const char *MATCH_KIND_SELECTOR = "selector"; |
| 17 | + /// Entries that can match a range. |
| 18 | + static constexpr const char *MATCH_KIND_RANGE = "range"; |
| 19 | + /// These definitions are derived from the numerical values of the enum |
| 20 | + /// named "PktInstanceType" in the p4lang/behavioral-model source file |
| 21 | + /// targets/simple_switch/simple_switch.h |
| 22 | + /// https://github.com/p4lang/behavioral-model/blob/main/targets/simple_switch/simple_switch.h#L146 |
| 23 | + static constexpr uint64_t PKT_INSTANCE_TYPE_NORMAL = 0x0000; |
| 24 | + static constexpr uint64_t PKT_INSTANCE_TYPE_INGRESS_CLONE = 0x0001; |
| 25 | + static constexpr uint64_t PKT_INSTANCE_TYPE_EGRESS_CLONE = 0x0002; |
| 26 | + static constexpr uint64_t PKT_INSTANCE_TYPE_COALESCED = 0x0003; |
| 27 | + static constexpr uint64_t PKT_INSTANCE_TYPE_RECIRC = 0x0004; |
| 28 | + static constexpr uint64_t PKT_INSTANCE_TYPE_REPLICATION = 0x005; |
| 29 | + static constexpr uint64_t PKT_INSTANCE_TYPE_RESUBMIT = 0x006; |
| 30 | + /// The session IDs for clone are limited to a specific range. |
| 31 | + /// Details: https://github.com/p4lang/PI/pull/588 |
| 32 | + static constexpr uint16_t CLONE_SESSION_ID_MIN = 1; |
| 33 | + static constexpr uint16_t CLONE_SESSION_ID_MAX = 32767; |
| 34 | + /// Clone type is derived from v1model.p4 |
| 35 | + enum CloneType { I2E = 0, E2E = 1 }; |
| 36 | + /// Meter colors are defined in v1model.p4 |
| 37 | + enum METER_COLOR { GREEN = 0, YELLOW = 1, RED = 2 }; |
| 38 | + |
| 39 | + /// Other useful constants |
| 40 | + static constexpr int STF_MIN_PKT_SIZE = 22; |
| 41 | + static constexpr int ETH_HDR_SIZE = 112; |
| 42 | + static constexpr int DROP_PORT = 511; |
| 43 | +}; |
| 44 | + |
| 45 | +} // namespace P4Tools::RTSmith::Tna |
| 46 | + |
| 47 | +#endif /* BACKENDS_P4TOOLS_MODULES_P4RTSMITH_TARGETS_TOFINO_CONSTANTS_H_ */ |
0 commit comments