Search in sources :

Example 96 with PiActionParam

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

the class FabricPipeliner method fwdClassifierRule.

public FlowRule fwdClassifierRule(long port, Short ethType, short ipEthType, byte fwdType, int priority) {
    final TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(port)).matchPi(PiCriterion.builder().matchExact(P4InfoConstants.HDR_IP_ETH_TYPE, ipEthType).build());
    if (ethType != null) {
        selectorBuilder.matchEthType(ethType);
    }
    final TrafficTreatment treatment = 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(selectorBuilder.build()).withTreatment(treatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).makePermanent().withPriority(priority).forDevice(deviceId).fromApp(appId).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 97 with PiActionParam

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

the class FabricPipeliner method ingressVlanRule.

public FlowRule ingressVlanRule(long port, boolean vlanValid, int vlanId, byte portType) {
    final TrafficSelector selector = DefaultTrafficSelector.builder().add(Criteria.matchInPort(PortNumber.portNumber(port))).add(PiCriterion.builder().matchExact(P4InfoConstants.HDR_VLAN_IS_VALID, vlanValid ? ONE : ZERO).build()).build();
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(vlanValid ? P4InfoConstants.FABRIC_INGRESS_FILTERING_PERMIT : P4InfoConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN).withParameter(new PiActionParam(P4InfoConstants.VLAN_ID, vlanId)).withParameter(new PiActionParam(P4InfoConstants.PORT_TYPE, portType)).build()).build();
    return DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN).makePermanent().withPriority(DEFAULT_FLOW_PRIORITY).forDevice(deviceId).fromApp(appId).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 98 with PiActionParam

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

the class FilteringObjectiveTranslator method fwdClassifierTreatment.

private TrafficTreatment fwdClassifierTreatment(byte fwdType) {
    final PiActionParam param = new PiActionParam(P4InfoConstants.FWD_TYPE, fwdType);
    final PiAction action = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(param).build();
    return DefaultTrafficTreatment.builder().piTableAction(action).build();
}
Also used : PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 99 with PiActionParam

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

the class FabricUpfTranslator method upfTerminationDownlinkToFabricEntry.

/**
 * Translate a downlink UpfTermination to a FlowRule to be inserted into the fabric.p4 pipeline.
 *
 * @param upfTermination The downlink 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 downlink UPF Termination translated to a FlowRule
 * @throws UpfProgrammableException if the UPF Termination cannot be translated
 */
public FlowRule upfTerminationDownlinkToFabricEntry(UpfTerminationDownlink 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_DOWNLINK_DROP);
    } else {
        actionBuilder.withId(FABRIC_INGRESS_UPF_DOWNLINK_FWD_ENCAP);
        paramList.add(new PiActionParam(TEID, upfTermination.teid()));
        paramList.add(new PiActionParam(QFI, upfTermination.qfi()));
        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_DOWNLINK_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 100 with PiActionParam

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

the class FabricUpfTranslator method sessionUplinkToFabricEntry.

/**
 * Translate a uplink session to a FlowRule to be inserted into the fabric.p4 pipeline.
 *
 * @param ueSession The uplink 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 uplink ue session translated to a FlowRule
 * @throws UpfProgrammableException if the UE session cannot be translated
 */
public FlowRule sessionUplinkToFabricEntry(UpfSessionUplink ueSession, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
    final PiCriterion match;
    final PiAction.Builder actionBuilder = PiAction.builder();
    match = PiCriterion.builder().matchExact(HDR_TEID, ueSession.teid()).matchExact(HDR_TUNNEL_IPV4_DST, ueSession.tunDstAddr().toOctets()).build();
    if (ueSession.needsDropping()) {
        actionBuilder.withId(FABRIC_INGRESS_UPF_SET_UPLINK_SESSION_DROP);
    } else {
        actionBuilder.withId(FABRIC_INGRESS_UPF_SET_UPLINK_SESSION);
        actionBuilder.withParameter(new PiActionParam(SESSION_METER_IDX, (short) ueSession.sessionMeterIdx()));
    }
    return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_UPLINK_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