use of org.onosproject.net.pi.model.PiActionId in project fabric-tna by stratum.
the class FabricUpfTranslator method fabricEntryToUpfTerminationDownlink.
/**
* Translate a fabric.p4 termination table entry to a downlink UpfTermination instance for easier handling.
*
* @param entry the fabric.p4 entry to translate
* @return the corresponding UpfTerminationDownlink
* @throws UpfProgrammableException if the entry cannot be translated
*/
public UpfTerminationDownlink fabricEntryToUpfTerminationDownlink(FlowRule entry) throws UpfProgrammableException {
assertTableId(entry, FABRIC_INGRESS_UPF_DOWNLINK_TERMINATIONS);
UpfTerminationDownlink.Builder builder = UpfTerminationDownlink.builder();
Pair<PiCriterion, PiTableAction> matchActionPair = FabricUpfTranslatorUtil.fabricEntryToPiPair(entry);
PiCriterion match = matchActionPair.getLeft();
PiAction action = (PiAction) matchActionPair.getRight();
if (!FabricUpfTranslatorUtil.fieldIsPresent(match, HDR_UE_SESSION_ID) || !FabricUpfTranslatorUtil.fieldIsPresent(match, HDR_APP_ID)) {
throw new UpfProgrammableException("Malformed downlink termination from dataplane!: " + entry);
}
// Match keys
Ip4Address ueSessionId = FabricUpfTranslatorUtil.getFieldAddress(match, HDR_UE_SESSION_ID);
builder.withUeSessionId(ueSessionId);
byte applicationId = FabricUpfTranslatorUtil.getFieldByte(match, HDR_APP_ID);
builder.withApplicationId(applicationId);
PiActionId actionId = action.id();
builder.withCounterId(FabricUpfTranslatorUtil.getParamInt(action, CTR_ID));
if (actionId.equals(FABRIC_INGRESS_UPF_DOWNLINK_DROP)) {
builder.needsDropping(true);
} else {
builder.withTeid(FabricUpfTranslatorUtil.getParamInt(action, TEID)).withQfi(FabricUpfTranslatorUtil.getParamByte(action, QFI)).withAppMeterIdx(FabricUpfTranslatorUtil.getParamShort(action, APP_METER_IDX));
if (actionId.equals(FABRIC_INGRESS_UPF_DOWNLINK_FWD_ENCAP)) {
builder.withTrafficClass(FabricUpfTranslatorUtil.getParamByte(action, TC));
}
}
return builder.build();
}
Aggregations