Search in sources :

Example 6 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricInterpreterTest method testNextTreatmentSimpleOutput.

/* Next control block */
/**
 * Map treatment to output action.
 */
@Test
public void testNextTreatmentSimpleOutput() throws Exception {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PORT_1).build();
    PiAction mappedAction = interpreter.mapTreatment(treatment, FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE);
    PiActionParam param = new PiActionParam(FabricConstants.PORT_NUM, PORT_1.toLong());
    PiAction expectedAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT_SIMPLE).withParameter(param).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 7 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

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, FabricConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_VLAN);
    PiActionParam vlanParam = new PiActionParam(FabricConstants.VLAN_ID, VLAN_100.toShort());
    PiAction expectedAction = PiAction.builder().withId(FabricConstants.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 8 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricInterpreterTest method testNextTreatmentHashedRoutingV4.

/**
 * Map treatment for hashed table to routing v4 action.
 */
@Test
public void testNextTreatmentHashedRoutingV4() throws Exception {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(SRC_MAC).setEthDst(DST_MAC).setOutput(PORT_1).build();
    PiAction mappedAction = interpreter.mapTreatment(treatment, FabricConstants.FABRIC_INGRESS_NEXT_HASHED);
    PiActionParam ethSrcParam = new PiActionParam(FabricConstants.SMAC, SRC_MAC.toBytes());
    PiActionParam ethDstParam = new PiActionParam(FabricConstants.DMAC, DST_MAC.toBytes());
    PiActionParam portParam = new PiActionParam(FabricConstants.PORT_NUM, PORT_1.toLong());
    PiAction expectedAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameters(ImmutableList.of(ethSrcParam, ethDstParam, portParam)).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 9 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class PiFlowRuleTranslatorImpl method checkPiAction.

private static PiTableAction checkPiAction(PiAction piAction, PiTableModel table) throws PiTranslationException {
    // Table supports this action?
    PiActionModel actionModel = table.action(piAction.id()).orElseThrow(() -> new PiTranslationException(format("Not such action '%s' for table '%s'", piAction.id(), table.id())));
    // Is the number of runtime parameters correct?
    if (actionModel.params().size() != piAction.parameters().size()) {
        throw new PiTranslationException(format("Wrong number of runtime parameters for action '%s', expected %d but found %d", actionModel.id(), actionModel.params().size(), piAction.parameters().size()));
    }
    // Forge a new action instance with well-sized parameters.
    // The same comment as in typeCheckFieldMatch() about duplicating field match instances applies here.
    PiAction.Builder newActionBuilder = PiAction.builder().withId(piAction.id());
    for (PiActionParam param : piAction.parameters()) {
        PiActionParamModel paramModel = actionModel.param(param.id()).orElseThrow(() -> new PiTranslationException(format("Not such parameter '%s' for action '%s'", param.id(), actionModel)));
        try {
            newActionBuilder.withParameter(new PiActionParam(param.id(), paramModel.hasBitWidth() ? param.value().fit(paramModel.bitWidth()) : param.value()));
        } catch (ByteSequenceTrimException e) {
            throw new PiTranslationException(format("Size mismatch for parameter '%s' of action '%s': %s", param.id(), piAction.id(), e.getMessage()));
        }
    }
    return newActionBuilder.build();
}
Also used : PiActionModel(org.onosproject.net.pi.model.PiActionModel) PiActionParamModel(org.onosproject.net.pi.model.PiActionParamModel) PiTranslationException(org.onosproject.net.pi.service.PiTranslationException) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) ByteSequenceTrimException(org.onlab.util.ImmutableByteSequence.ByteSequenceTrimException) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 10 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricPipeliner method ingressVlanRule.

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

Aggregations

PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)52 PiAction (org.onosproject.net.pi.runtime.PiAction)45 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)32 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)32 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)24 TrafficSelector (org.onosproject.net.flow.TrafficSelector)24 Test (org.junit.Test)21 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)11 FlowRule (org.onosproject.net.flow.FlowRule)11 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)7 GroupDescription (org.onosproject.net.group.GroupDescription)6 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 NextObjective (org.onosproject.net.flowobjective.NextObjective)5 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)5 PortNumber (org.onosproject.net.PortNumber)4 PiInstruction (org.onosproject.net.flow.instructions.PiInstruction)4 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)4 GroupBucket (org.onosproject.net.group.GroupBucket)4 GroupBuckets (org.onosproject.net.group.GroupBuckets)4