P4C
The P4 Compiler
Loading...
Searching...
No Matches
error_mode.h
1
17
18#ifndef BACKENDS_TOFINO_BF_ASM_ERROR_MODE_H_
19#define BACKENDS_TOFINO_BF_ASM_ERROR_MODE_H_
20
21#include "sections.h"
22
23class Stage;
24
25class ErrorMode {
26 public:
27 typedef enum {
28 NO_CONFIG = 0,
29 PROPAGATE,
30 MAP_TO_IMMEDIATE,
31 DISABLE_ALL_TABLES,
32 PROPAGATE_AND_MAP,
33 PROPAGATE_AND_DISABLE
34 } mode_t;
35 typedef enum {
36 TCAM_MATCH,
37 TIND_ECC,
38 GFM_PARITY,
39 EMM_ECC,
40 PREV_ERROR,
41 ACTIONDATA_ERROR,
42 IMEM_PARITY_ERROR,
43 NUM_TYPE_T,
44 LATE_ERROR = ACTIONDATA_ERROR, // this (and after) is limited
45 } type_t;
46
47 mode_t mode[NUM_TYPE_T] = {NO_CONFIG};
48 mode_t &operator[](type_t t) { return mode[t]; }
49 static mode_t str2mode(const value_t &);
50 static const char *mode2str(mode_t m);
51 static type_t str2type(const value_t &);
52 static const char *type2str(type_t t);
53
54 void input(value_t data);
55 template <class REGS>
56 void write_regs(REGS &, const Stage *, gress_t);
57};
58
59class DefaultErrorMode : public Section, public ErrorMode {
60 DefaultErrorMode() : Section("error_mode") {
61 // This code sets the default error mode when the assembler is used with an older
62 // compiler. Current compiler should always set or override this in the .bfa file
63 for (auto &m : mode) m = PROPAGATE_AND_DISABLE;
64 }
65 static DefaultErrorMode singleton;
66
67 public:
68 void input(VECTOR(value_t) args, value_t data) override { ErrorMode::input(data); }
69 void output(json::map &) override {}
70 static ErrorMode get() { return singleton; }
71};
72
73#endif /* BACKENDS_TOFINO_BF_ASM_ERROR_MODE_H_ */
Definition error_mode.h:25
Definition stage.h:123
Definition backends/tofino/bf-asm/json.h:300
Definition asm-types.h:114