Search in sources :

Example 16 with PiActionId

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();
}
Also used : UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) PiActionId(org.onosproject.net.pi.model.PiActionId) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiTableAction(org.onosproject.net.pi.runtime.PiTableAction) Ip4Address(org.onlab.packet.Ip4Address) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiActionId (org.onosproject.net.pi.model.PiActionId)16 PiAction (org.onosproject.net.pi.runtime.PiAction)9 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)8 Test (org.junit.Test)6 PiTableId (org.onosproject.net.pi.model.PiTableId)6 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)6 UpfProgrammableException (org.onosproject.net.behaviour.upf.UpfProgrammableException)5 PiActionParamId (org.onosproject.net.pi.model.PiActionParamId)5 PiTableAction (org.onosproject.net.pi.runtime.PiTableAction)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 PiMatchFieldId (org.onosproject.net.pi.model.PiMatchFieldId)4 PiMatchFieldModel (org.onosproject.net.pi.model.PiMatchFieldModel)4 PiTableModel (org.onosproject.net.pi.model.PiTableModel)4 IOException (java.io.IOException)3 Ip4Address (org.onlab.packet.Ip4Address)3 PiActionModel (org.onosproject.net.pi.model.PiActionModel)3 ActionRef (p4.config.v1.P4InfoOuterClass.ActionRef)3 MatchField (p4.config.v1.P4InfoOuterClass.MatchField)3 P4Info (p4.config.v1.P4InfoOuterClass.P4Info)3 Table (p4.config.v1.P4InfoOuterClass.Table)3