Search in sources :

Example 56 with PiAction

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

the class P4RuntimeGroupTest method outputMember.

private static PiActionProfileMember outputMember(short portNum) {
    PiActionParam param = new PiActionParam(PORT_PARAM_ID, ImmutableByteSequence.copyFrom(portNum));
    PiAction piAction = PiAction.builder().withId(EGRESS_PORT_ACTION_ID).withParameter(param).build();
    return PiActionProfileMember.builder().forActionProfile(ACT_PROF_ID).withAction(piAction).withId(PiActionProfileMemberId.of(BASE_MEM_ID + portNum)).build();
}
Also used : PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 57 with PiAction

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

the class ActionCodec method decode.

@Override
protected PiAction decode(P4RuntimeOuterClass.Action message, Object ignored, PiPipeconf pipeconf, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException, CodecException {
    final P4InfoBrowser.EntityBrowser<P4InfoOuterClass.Action.Param> paramInfo = browser.actionParams(message.getActionId());
    final String actionName = browser.actions().getById(message.getActionId()).getPreamble().getName();
    final PiAction.Builder builder = PiAction.builder().withId(PiActionId.of(actionName));
    for (P4RuntimeOuterClass.Action.Param p : message.getParamsList()) {
        final P4InfoOuterClass.Action.Param actionParam = paramInfo.getById(p.getParamId());
        final ImmutableByteSequence value;
        if (browser.isTypeString(actionParam.getTypeName())) {
            value = copyFrom(new String(p.getValue().toByteArray()));
        } else {
            try {
                value = copyAndFit(p.getValue().asReadOnlyByteBuffer(), actionParam.getBitwidth());
            } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
                throw new CodecException(e.getMessage());
            }
        }
        builder.withParameter(new PiActionParam(PiActionParamId.of(actionParam.getName()), value));
    }
    return builder.build();
}
Also used : PiAction(org.onosproject.net.pi.runtime.PiAction) ByteString(com.google.protobuf.ByteString) PiAction(org.onosproject.net.pi.runtime.PiAction) P4InfoOuterClass(p4.config.v1.P4InfoOuterClass) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) P4InfoBrowser(org.onosproject.p4runtime.ctl.utils.P4InfoBrowser) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence)

Aggregations

PiAction (org.onosproject.net.pi.runtime.PiAction)57 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)39 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)39 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)31 TrafficSelector (org.onosproject.net.flow.TrafficSelector)31 Test (org.junit.Test)25 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)19 FlowRule (org.onosproject.net.flow.FlowRule)19 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)17 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 GroupDescription (org.onosproject.net.group.GroupDescription)10 ImmutableList (com.google.common.collect.ImmutableList)6 List (java.util.List)6 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)6 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)6 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 NextObjective (org.onosproject.net.flowobjective.NextObjective)5 GroupBucket (org.onosproject.net.group.GroupBucket)5 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)5