P4C
The P4 Compiler
Loading...
Searching...
No Matches
jbay/match_table.cpp
1
17
18/* mau table template specializations for jbay -- #included directly in match_tables.cpp */
19
22template <>
23void MatchTable::write_next_table_regs(Target::JBay::mau_regs &regs, Table *tbl) {
24 auto &merge = regs.rams.match.merge;
25 if (!hit_next.empty() || !extra_next_lut.empty()) {
26 merge.next_table_map_en |= (1U << logical_id);
27 int i = 0;
28 for (auto &n : hit_next) {
29 merge.pred_map_loca[logical_id][i].pred_map_loca_next_table = n.next_table_id();
30 merge.pred_map_loca[logical_id][i].pred_map_loca_exec =
31 n.next_in_stage(stage->stageno) >> 1;
32 merge.pred_map_glob[logical_id][i].pred_map_glob_exec =
33 n.next_in_stage(stage->stageno + 1);
34 merge.pred_map_glob[logical_id][i].pred_map_long_brch |= n.long_branch_tags();
35 ++i;
36 }
37 for (auto &n : extra_next_lut) {
38 merge.pred_map_loca[logical_id][i].pred_map_loca_next_table = n.next_table_id();
39 merge.pred_map_loca[logical_id][i].pred_map_loca_exec =
40 n.next_in_stage(stage->stageno) >> 1;
41 merge.pred_map_glob[logical_id][i].pred_map_glob_exec =
42 n.next_in_stage(stage->stageno + 1);
43 merge.pred_map_glob[logical_id][i].pred_map_long_brch |= n.long_branch_tags();
44 ++i;
45 }
46 // is this needed? The model complains if we leave the unused slots as 0
47 while (i < Target::NEXT_TABLE_SUCCESSOR_TABLE_DEPTH())
48 merge.pred_map_loca[logical_id][i++].pred_map_loca_next_table = 0x1ff;
49 }
50
51 merge.next_table_format_data[logical_id].match_next_table_adr_mask = next_table_adr_mask;
52 merge.next_table_format_data[logical_id].match_next_table_adr_miss_value =
53 miss_next.next_table_id();
54 merge.pred_miss_exec[logical_id].pred_miss_loca_exec =
55 miss_next.next_in_stage(stage->stageno) >> 1;
56 merge.pred_miss_exec[logical_id].pred_miss_glob_exec =
57 miss_next.next_in_stage(stage->stageno + 1);
58 merge.pred_miss_long_brch[logical_id] = miss_next.long_branch_tags();
59}
60
61template <>
62void MatchTable::write_regs(Target::JBay::mau_regs &regs, int type, Table *result) {
63 write_common_regs<Target::JBay>(regs, type, result);
64 // FIXME -- factor this with JBay GatewayTable::standalone_write_regs
65 auto &merge = regs.rams.match.merge;
66 if (gress == GHOST) merge.pred_ghost_thread |= 1 << logical_id;
67 merge.pred_glob_exec_thread[gress] |= 1 << logical_id;
68 if (always_run || pred.empty()) merge.pred_always_run[gress] |= 1 << logical_id;
69
70 if (long_branch_input >= 0)
71 setup_muxctl(merge.pred_long_brch_lt_src[logical_id], long_branch_input);
72
73 if (result == nullptr) result = this;
74
75 bool is_branch = (miss_next.next_table() != nullptr);
76 if (!is_branch && gateway && gateway->is_branch()) is_branch = true;
77 if (!is_branch)
78 for (auto &n : hit_next)
79 if (n.next_table() != nullptr) {
80 is_branch = true;
81 break;
82 }
83 if (!is_branch)
84 for (auto &n : extra_next_lut)
85 if (n.next_table() != nullptr) {
86 is_branch = true;
87 break;
88 }
89
90 if (!is_branch && result->get_format_field_size("next") > 3) is_branch = true;
91
92 // Check if any table actions have a next table miss set up
93 // if yes, the pred_is_a_brch register must be set on the table to override the next table
94 // configuration with this value.
95 //
96 // E.g.
97 // switch (mc_filter.apply().action_run) {
98 // NoAction : { // Has @defaultonly
99 // ttl_thr_check.apply();
100 // }
101 // }
102 //
103 // Generated bfa
104 // ...
105 // hit: [ END ]
106 // miss: END
107 // ...
108 // NoAction(-1, 1):
109 // - hit_allowed: { allowed: false, reason: user_indicated_default_only }
110 // - default_only_action: { allowed: true, is_constant: true }
111 // - handle: 0x20000015
112 // - next_table_miss: ttl_thr_check_0
113 //
114 // If merge.pred_is_a_brch is not set in this usecase, the default miss configuration of 'END'
115 // or 'End of Pipe' is executed and next table ttl_thr_check_0 will not be executed.
116 if (!is_branch) {
117 for (auto &act : *result->actions) {
118 if (act.next_table_miss_ref.next_table()) {
119 is_branch = true;
120 break;
121 }
122 }
123 }
124
125 if (is_branch) merge.pred_is_a_brch |= 1 << logical_id;
126
127 merge.mpr_glob_exec_thread |= merge.logical_table_thread[0].logical_table_thread_egress &
128 ~merge.logical_table_thread[0].logical_table_thread_ingress &
129 ~merge.pred_ghost_thread;
130}
Definition tables.h:98