use of p4.config.v1.P4InfoOuterClass.ActionProfile in project onos by opennetworkinglab.
the class P4InfoParser method parseActionProfiles.
private static Map<Integer, PiActionProfileModel> parseActionProfiles(P4Info p4info) throws P4InfoParserException {
final Map<Integer, PiActionProfileModel> actProfileMap = Maps.newHashMap();
for (ActionProfile actProfileMsg : p4info.getActionProfilesList()) {
final ImmutableSet.Builder<PiTableId> tableIdSetBuilder = ImmutableSet.builder();
for (int tableId : actProfileMsg.getTableIdsList()) {
tableIdSetBuilder.add(PiTableId.of(getTableName(tableId, p4info)));
}
// TODO: we should copy all annotations to model classes for later
// use in the PI framework.
// This is a temporary workaround to the inability of p4c to
// correctly interpret P4Runtime-defined max_group_size annotation:
// https://s3-us-west-2.amazonaws.com/p4runtime/docs/master/
// P4Runtime-Spec.html#sec-p4info-action-profile
final String maxSizeAnnString = getAnnotationValue(MAX_GROUP_SIZE_ANNOTATION, actProfileMsg.getPreamble());
final int maxSizeAnn = maxSizeAnnString != null ? Integer.valueOf(maxSizeAnnString) : 0;
final int maxGroupSize;
if (actProfileMsg.getMaxGroupSize() == 0 && maxSizeAnn != 0) {
log.warn("Found valid 'max_group_size' annotation for " + "ActionProfile {}, using that...", actProfileMsg.getPreamble().getName());
maxGroupSize = maxSizeAnn;
} else {
maxGroupSize = actProfileMsg.getMaxGroupSize();
}
actProfileMap.put(actProfileMsg.getPreamble().getId(), new P4ActionProfileModel(PiActionProfileId.of(actProfileMsg.getPreamble().getName()), tableIdSetBuilder.build(), actProfileMsg.getWithSelector(), actProfileMsg.getSize(), maxGroupSize));
}
return actProfileMap;
}
Aggregations