63 enum BFRuntimeDataFieldIds : P4Id {
69 BF_RT_DATA_START = TD_DATA_END,
71 BF_RT_DATA_MATCH_PRIORITY,
74 BF_RT_DATA_WRED_INDEX,
76 BF_RT_DATA_ACTION_MEMBER_ID,
77 BF_RT_DATA_SELECTOR_GROUP_ID,
78 BF_RT_DATA_ACTION_MEMBER_STATUS,
79 BF_RT_DATA_MAX_GROUP_SIZE,
80 BF_RT_DATA_ADT_OFFSET,
82 BF_RT_DATA_LPF_SPEC_TYPE,
83 BF_RT_DATA_LPF_SPEC_GAIN_TIME_CONSTANT_NS,
84 BF_RT_DATA_LPF_SPEC_DECAY_TIME_CONSTANT_NS,
85 BF_RT_DATA_LPF_SPEC_OUT_SCALE_DOWN_FACTOR,
87 BF_RT_DATA_WRED_SPEC_TIME_CONSTANT_NS,
88 BF_RT_DATA_WRED_SPEC_MIN_THRESH_CELLS,
89 BF_RT_DATA_WRED_SPEC_MAX_THRESH_CELLS,
90 BF_RT_DATA_WRED_SPEC_MAX_PROBABILITY,
92 BF_RT_DATA_PORT_METADATA_PORT,
93 BF_RT_DATA_PORT_METADATA_DEFAULT_FIELD,
95 BF_RT_DATA_HASH_ALGORITHM_ROTATE,
96 BF_RT_DATA_HASH_ALGORITHM_SEED,
97 BF_RT_DATA_HASH_ALGORITHM_MSB,
98 BF_RT_DATA_HASH_ALGORITHM_EXTEND,
99 BF_RT_DATA_HASH_ALGORITHM_PRE_DEFINED,
100 BF_RT_DATA_HASH_ALGORITHM_USER_DEFINED,
101 BF_RT_DATA_HASH_VALUE,
102 BF_RT_DATA_HASH_CONFIGURE_START_BIT,
103 BF_RT_DATA_HASH_CONFIGURE_LENGTH,
104 BF_RT_DATA_HASH_CONFIGURE_ORDER,
106 BF_RT_DATA_SNAPSHOT_START_STAGE,
107 BF_RT_DATA_SNAPSHOT_END_STAGE,
108 BF_RT_DATA_SNAPSHOT_ENABLE,
109 BF_RT_DATA_SNAPSHOT_TRIGGER_STATE,
110 BF_RT_DATA_SNAPSHOT_TIMER_ENABLE,
111 BF_RT_DATA_SNAPSHOT_TIMER_TRIGGER,
112 BF_RT_DATA_SNAPSHOT_TIMER_VALUE_USECS,
113 BF_RT_DATA_SNAPSHOT_FIELD_INFO,
114 BF_RT_DATA_SNAPSHOT_CONTROL_INFO,
115 BF_RT_DATA_SNAPSHOT_TABLE_INFO,
116 BF_RT_DATA_SNAPSHOT_METER_ALU_INFO,
117 BF_RT_DATA_SNAPSHOT_STAGE_ID,
118 BF_RT_DATA_SNAPSHOT_PREV_STAGE_TRIGGER,
119 BF_RT_DATA_SNAPSHOT_INGRESS_TRIGGER_MODE,
120 BF_RT_DATA_SNAPSHOT_LOCAL_STAGE_TRIGGER,
121 BF_RT_DATA_SNAPSHOT_NEXT_TABLE_ID,
122 BF_RT_DATA_SNAPSHOT_NEXT_TABLE_NAME,
123 BF_RT_DATA_SNAPSHOT_ENABLED_NEXT_TABLES,
124 BF_RT_DATA_SNAPSHOT_GLOBAL_EXECUTE_TABLES,
125 BF_RT_DATA_SNAPSHOT_ENABLED_GLOBAL_EXECUTE_TABLES,
126 BF_RT_DATA_SNAPSHOT_LONG_BRANCH_TABLES,
127 BF_RT_DATA_SNAPSHOT_ENABLED_LONG_BRANCH_TABLES,
128 BF_RT_DATA_SNAPSHOT_DEPARSER_ERROR,
129 BF_RT_DATA_SNAPSHOT_TABLE_ID,
130 BF_RT_DATA_SNAPSHOT_TABLE_NAME,
131 BF_RT_DATA_SNAPSHOT_METER_TABLE_NAME,
132 BF_RT_DATA_SNAPSHOT_METER_ALU_OPERATION_TYPE,
133 BF_RT_DATA_SNAPSHOT_MATCH_HIT_HANDLE,
134 BF_RT_DATA_SNAPSHOT_TABLE_HIT,
135 BF_RT_DATA_SNAPSHOT_TABLE_INHIBITED,
136 BF_RT_DATA_SNAPSHOT_TABLE_EXECUTED,
137 BF_RT_DATA_SNAPSHOT_LIVENESS_FIELD_NAME,
138 BF_RT_DATA_SNAPSHOT_LIVENESS_VALID_STAGES,
139 BF_RT_DATA_SNAPSHOT_THREAD,
140 BF_RT_DATA_SNAPSHOT_INGRESS_CAPTURE,
141 BF_RT_DATA_SNAPSHOT_EGRESS_CAPTURE,
142 BF_RT_DATA_SNAPSHOT_GHOST_CAPTURE,
144 BF_RT_DATA_PARSER_INSTANCE,
145 BF_RT_DATA_PARSER_NAME,
147 BF_RT_DATA_DEBUG_CNT_TABLE_NAME,
148 BF_RT_DATA_DEBUG_CNT_TYPE,
149 BF_RT_DATA_DEBUG_CNT_VALUE,
180 P4Id idOffset = 1)
const;
185 void addDirectResources(
const p4configv1::Table &table,
Util::JsonArray *dataJson,
187 P4Id maxActionParamId)
const override;
194 bool addActionProfIds(
const p4configv1::Table &table,
197 std::optional<bool> actProfHasSelector(P4Id actProfId)
const override;
199 std::optional<Lpf> getDirectLpf(P4Id lpfId)
const;
200 std::optional<Wred> getDirectWred(P4Id wredId)
const;
201 std::optional<Counter> getDirectCounter(P4Id counterId)
const override;
202 std::optional<Meter> getDirectMeter(P4Id meterId)
const override;
203 std::optional<Register> getDirectRegister(P4Id registerId)
const;
205 static std::optional<ActionProf> fromTNAActionProfile(
206 const p4configv1::P4Info &p4info,
const p4configv1::ExternInstance &externInstance) {
207 const auto &pre = externInstance.preamble();
208 ::barefoot::ActionProfile actionProfile;
209 if (!externInstance.info().UnpackTo(&actionProfile)) {
210 error(
"Extern instance %1% does not pack an ActionProfile object", pre.name());
213 auto tableIds = collectTableIds(p4info, actionProfile.table_ids().begin(),
214 actionProfile.table_ids().end());
215 return ActionProf{pre.name(), pre.id(), actionProfile.size(), tableIds,
216 transformAnnotations(pre)};
219 static std::optional<Counter> fromTNACounter(
const p4configv1::ExternInstance &externInstance) {
220 const auto &pre = externInstance.preamble();
221 ::barefoot::Counter counter;
222 if (!externInstance.info().UnpackTo(&counter)) {
223 error(
"Extern instance %1% does not pack a Counter object", pre.name());
226 auto unit =
static_cast<Counter::Unit
>(counter.spec().unit());
227 return Counter{pre.name(), pre.id(), counter.size(), unit, transformAnnotations(pre)};
230 static std::optional<Counter> fromTNADirectCounter(
231 const p4configv1::ExternInstance &externInstance) {
232 const auto &pre = externInstance.preamble();
233 ::barefoot::DirectCounter counter;
234 if (!externInstance.info().UnpackTo(&counter)) {
235 error(
"Extern instance %1% does not pack a DirectCounter object", pre.name());
238 auto unit =
static_cast<Counter::Unit
>(counter.spec().unit());
239 return Counter{pre.name(), pre.id(), 0, unit, transformAnnotations(pre)};
242 static std::optional<Meter> fromTNAMeter(
const p4configv1::ExternInstance &externInstance) {
243 const auto &pre = externInstance.preamble();
244 ::barefoot::Meter meter;
245 if (!externInstance.info().UnpackTo(&meter)) {
246 error(
"Extern instance %1% does not pack a Meter object", pre.name());
249 auto unit =
static_cast<Meter::Unit
>(meter.spec().unit());
250 auto type =
static_cast<Meter::Type
>(meter.spec().type());
251 return Meter{pre.name(), pre.id(), meter.size(), unit, type, transformAnnotations(pre)};
254 static std::optional<Meter> fromTNADirectMeter(
255 const p4configv1::ExternInstance &externInstance) {
256 const auto &pre = externInstance.preamble();
257 ::barefoot::DirectMeter meter;
258 if (!externInstance.info().UnpackTo(&meter)) {
259 error(
"Extern instance %1% does not pack a Meter object", pre.name());
262 auto unit =
static_cast<Meter::Unit
>(meter.spec().unit());
263 auto type =
static_cast<Meter::Type
>(meter.spec().type());
264 return Meter{pre.name(), pre.id(), 0, unit, type, transformAnnotations(pre)};
267 static std::optional<Digest> fromTNADigest(
const p4configv1::ExternInstance &externInstance) {
268 const auto &pre = externInstance.preamble();
269 ::barefoot::Digest digest;
270 if (!externInstance.info().UnpackTo(&digest)) {
271 error(
"Extern instance %1% does not pack a Digest object", pre.name());
274 return Digest{pre.name(), pre.id(), digest.type_spec(), transformAnnotations(pre)};
277 static std::optional<Register> fromTNARegister(
278 const p4configv1::ExternInstance &externInstance) {
279 const auto &pre = externInstance.preamble();
280 ::barefoot::Register register_;
281 if (!externInstance.info().UnpackTo(®ister_)) {
282 error(
"Extern instance %1% does not pack a Register object", pre.name());
285 return Register{pre.name(), register_.data_field_name(), pre.id(),
286 register_.size(), register_.type_spec(), transformAnnotations(pre)};
289 static std::optional<Register> fromTNADirectRegister(
290 const p4configv1::ExternInstance &externInstance) {
291 const auto &pre = externInstance.preamble();
292 ::barefoot::DirectRegister register_;
293 if (!externInstance.info().UnpackTo(®ister_)) {
294 error(
"Extern instance %1% does not pack a Register object", pre.name());
297 return Register{pre.name(), register_.data_field_name(), pre.id(),
298 0, register_.type_spec(), transformAnnotations(pre)};