blob: 8d061008f2430eadacc0e4dc6c81d4ea68ff3c6e [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.net.pi.model;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.driver.HandlerBehaviour;
Carmelo Cascone00a59962017-06-16 17:51:49 +090021import org.onosproject.net.flow.FlowRule;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040022import org.onosproject.net.flow.TrafficTreatment;
23import org.onosproject.net.flow.criteria.Criterion;
24import org.onosproject.net.pi.runtime.PiHeaderFieldId;
25import org.onosproject.net.pi.runtime.PiTableAction;
Carmelo Cascone00a59962017-06-16 17:51:49 +090026import org.onosproject.net.pi.runtime.PiTableId;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040027
28import java.util.Optional;
29
30/**
Carmelo Cascone00a59962017-06-16 17:51:49 +090031 * An interpreter of a protocol-independent pipeline model.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040032 */
33@Beta
34public interface PiPipelineInterpreter extends HandlerBehaviour {
35
36 /**
37 * Returns the protocol-independent header field identifier that is equivalent to the given
38 * criterion type, if present. If not present, it means that the given criterion type is not
39 * supported by this interpreter.
40 *
41 * @param type criterion type
42 * @return optional header field identifier
43 */
44 Optional<PiHeaderFieldId> mapCriterionType(Criterion.Type type);
45
46 /**
47 * Returns the criterion type that is equivalent to the given protocol-independent header field
48 * identifier, if present. If not present, it means that the given field identifier is not
49 * supported by this interpreter.
50 *
51 * @param headerFieldId header field identifier
52 * @return optional criterion type
53 */
54 Optional<Criterion.Type> mapPiHeaderFieldId(PiHeaderFieldId headerFieldId);
55
56 /**
Carmelo Cascone00a59962017-06-16 17:51:49 +090057 * Returns a protocol-independent table id equivalent to the given numeric table id (as in
58 * {@link FlowRule#tableId()}). If not present, it means that the given numeric table id cannot
59 * be mapped to any table of the pipeline model.
60 *
61 * @param flowRuleTableId a numeric table id
62 * @return a protocol-independent table id
63 */
64 Optional<PiTableId> mapFlowRuleTableId(int flowRuleTableId);
65
66 /**
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040067 * Returns a table action of a protocol-independent pipeline that is functionally equivalent to
68 * the given ONOS traffic treatment for the given pipeline configuration.
69 *
70 * @param treatment a ONOS traffic treatment
71 * @param pipeconf a pipeline configuration
72 * @return a table action object
73 * @throws PiInterpreterException if the treatment cannot be mapped to any table action
74 */
75 PiTableAction mapTreatment(TrafficTreatment treatment, PiPipeconf pipeconf)
76 throws PiInterpreterException;
77
78 /**
79 * Signals that an error was encountered while executing the interpreter.
80 */
81 @Beta
82 class PiInterpreterException extends Exception {
83 public PiInterpreterException(String message) {
84 super(message);
85 }
86 }
Carmelo Cascone00a59962017-06-16 17:51:49 +090087}