Search in sources :

Example 36 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.

the class FabricInterpreterTest method testNextVlanTreatment.

/**
 * Map treatment to set_vlan_output action.
 */
@Test
public void testNextVlanTreatment() throws Exception {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setVlanId(VLAN_100).build();
    PiAction mappedAction = interpreter.mapTreatment(treatment, P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_VLAN);
    PiActionParam vlanParam = new PiActionParam(P4InfoConstants.VLAN_ID, VLAN_100.toShort());
    PiAction expectedAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_SET_VLAN).withParameter(vlanParam).build();
    assertEquals(expectedAction, mappedAction);
}
Also used : DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 37 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.

the class FabricPipelinerTest method buildFwdClsRule.

private FlowRule buildFwdClsRule(long port, Short etherType, short ipEtherType, byte fwdType, int priority) {
    final TrafficSelector.Builder fwdClsSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(port)).matchPi(PiCriterion.builder().matchExact(P4InfoConstants.HDR_IP_ETH_TYPE, ipEtherType).build());
    if (etherType != null) {
        fwdClsSelector.matchEthType(etherType);
    }
    final TrafficTreatment cpuFwdClsTreatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(new PiActionParam(P4InfoConstants.FWD_TYPE, fwdType)).build()).build();
    return DefaultFlowRule.builder().withSelector(fwdClsSelector.build()).withTreatment(cpuFwdClsTreatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).makePermanent().withPriority(priority).forDevice(DEVICE_ID).fromApp(APP_ID).build();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam)

Example 38 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.

the class FabricUpfTranslator method upfTerminationUplinkToFabricEntry.

/**
 * Translate a Uplink UpfTermination to a FlowRule to be inserted into the fabric.p4 pipeline.
 *
 * @param upfTermination The uplink UPF Termination to be translated
 * @param deviceId       the ID of the device the FlowRule should be installed on
 * @param appId          the ID of the application that will insert the FlowRule
 * @param priority       the FlowRule's priority
 * @return the uplink UPF Termination translated to a FlowRule
 * @throws UpfProgrammableException if the UPF Termination cannot be translated
 */
public FlowRule upfTerminationUplinkToFabricEntry(UpfTerminationUplink upfTermination, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
    final PiCriterion match = PiCriterion.builder().matchExact(HDR_UE_SESSION_ID, upfTermination.ueSessionId().toInt()).matchExact(HDR_APP_ID, upfTermination.applicationId()).build();
    final PiAction.Builder actionBuilder = PiAction.builder();
    List<PiActionParam> paramList = new ArrayList<>(Arrays.asList(new PiActionParam(CTR_ID, upfTermination.counterId())));
    if (upfTermination.needsDropping()) {
        actionBuilder.withId(FABRIC_INGRESS_UPF_UPLINK_DROP);
    } else {
        actionBuilder.withId(FABRIC_INGRESS_UPF_APP_FWD);
        paramList.add(new PiActionParam(APP_METER_IDX, (short) upfTermination.appMeterIdx()));
        paramList.add(new PiActionParam(TC, upfTermination.trafficClass()));
    }
    actionBuilder.withParameters(paramList);
    return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_UPLINK_TERMINATIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(actionBuilder.build()).build()).withPriority(priority).build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) ArrayList(java.util.ArrayList) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 39 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.

the class FabricUpfTranslator method gtpTunnelPeerToFabricEntry.

/**
 * Translate a UpfGtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
 *
 * @param gtpTunnelPeer the GTP tunnel peer to be translated
 * @param deviceId      the ID of the device the FlowRule should be installed on
 * @param appId         the ID of the application that will insert the FlowRule
 * @param priority      the FlowRules' priority
 * @return a pair of FlowRules translated from GTP tunnel peer
 * @throws UpfProgrammableException if the interface cannot be translated
 */
public Pair<FlowRule, FlowRule> gtpTunnelPeerToFabricEntry(UpfGtpTunnelPeer gtpTunnelPeer, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
    FlowRule ingressEntry;
    FlowRule egressEntry;
    if (gtpTunnelPeer.src() == null || gtpTunnelPeer.dst() == null) {
        throw new UpfProgrammableException("Not all action parameters present when translating " + "intermediate GTP tunnel peer to physical representation!");
    }
    PiCriterion match = PiCriterion.builder().matchExact(HDR_TUN_PEER_ID, gtpTunnelPeer.tunPeerId()).build();
    FlowRule.Builder base = DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().withPriority(priority).withSelector(DefaultTrafficSelector.builder().matchPi(match).build());
    PiAction ingressAction = PiAction.builder().withId(FABRIC_INGRESS_UPF_SET_ROUTING_IPV4_DST).withParameter(new PiActionParam(TUN_DST_ADDR, gtpTunnelPeer.dst().toInt())).build();
    ingressEntry = base.forTable(FABRIC_INGRESS_UPF_IG_TUNNEL_PEERS).withTreatment(DefaultTrafficTreatment.builder().piTableAction(ingressAction).build()).build();
    PiAction egressAction = PiAction.builder().withId(FABRIC_EGRESS_UPF_LOAD_TUNNEL_PARAMS).withParameters(Arrays.asList(new PiActionParam(TUNNEL_SRC_ADDR, gtpTunnelPeer.src().toInt()), new PiActionParam(TUNNEL_DST_ADDR, gtpTunnelPeer.dst().toInt()), new PiActionParam(TUNNEL_SRC_PORT, gtpTunnelPeer.srcPort()))).build();
    egressEntry = base.forTable(FABRIC_EGRESS_UPF_EG_TUNNEL_PEERS).withTreatment(DefaultTrafficTreatment.builder().piTableAction(egressAction).build()).build();
    return Pair.of(ingressEntry, egressEntry);
}
Also used : UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 40 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.

the class FabricUpfTranslator method sessionDownlinkToFabricEntry.

/**
 * Translate a downlink session to a FlowRule to be inserted into the fabric.p4 pipeline.
 *
 * @param ueSession The downlink UE Session to be translated
 * @param deviceId  the ID of the device the FlowRule should be installed on
 * @param appId     the ID of the application that will insert the FlowRule
 * @param priority  the FlowRule's priority
 * @return the downlink ue session translated to a FlowRule
 * @throws UpfProgrammableException if the UE session cannot be translated
 */
public FlowRule sessionDownlinkToFabricEntry(UpfSessionDownlink ueSession, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
    final PiCriterion match;
    final PiAction.Builder actionBuilder = PiAction.builder();
    match = PiCriterion.builder().matchExact(HDR_UE_ADDR, ueSession.ueAddress().toOctets()).build();
    if (ueSession.needsDropping() && ueSession.needsBuffering()) {
        actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_BUF_DROP);
    } else if (ueSession.needsDropping()) {
        actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_DROP);
    } else {
        actionBuilder.withParameter(new PiActionParam(TUN_PEER_ID, ueSession.tunPeerId())).withParameter(new PiActionParam(SESSION_METER_IDX, (short) ueSession.sessionMeterIdx()));
        if (ueSession.needsBuffering()) {
            actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_BUF);
        } else {
            actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION);
        }
    }
    return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_DOWNLINK_SESSIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(actionBuilder.build()).build()).withPriority(priority).build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)102 PiAction (org.onosproject.net.pi.runtime.PiAction)90 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)50 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)50 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)39 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)39 Test (org.junit.Test)30 FlowRule (org.onosproject.net.flow.FlowRule)27 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)21 GroupDescription (org.onosproject.net.group.GroupDescription)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)8 NextObjective (org.onosproject.net.flowobjective.NextObjective)8 PortNumber (org.onosproject.net.PortNumber)7 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)7 GroupBucket (org.onosproject.net.group.GroupBucket)7 GroupBuckets (org.onosproject.net.group.GroupBuckets)7 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)7 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)6