blob: ff7bbe38660c91158aaa378e1b7035e893d931db [file] [log] [blame]
Carmelo Cascone17fc9e42016-05-31 11:29:21 -07001/*
Brian O'Connorce2a03d2017-08-03 19:21:03 -07002 * Copyright 2016-present Open Networking Foundation
Carmelo Cascone17fc9e42016-05-31 11:29:21 -07003 *
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.bmv2.api.context;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.bmv2.api.runtime.Bmv2TableEntry;
21import org.onosproject.net.flow.FlowRule;
22
23/**
24 * Translator of ONOS flow rules to BMv2 table entries.
25 */
26@Beta
27public interface Bmv2FlowRuleTranslator {
28
29 /**
30 * Returns a BMv2 table entry equivalent to the given flow rule for the given context.
31 * <p>
32 * Translation is performed according to the following logic:
33 * <ul>
34 * <li> table name: obtained from the context interpreter {@link Bmv2Interpreter#tableIdMap() table ID map}.
35 * <li> match key: is built using both the context interpreter {@link Bmv2Interpreter#criterionTypeMap() criterion
36 * map} and all {@link org.onosproject.bmv2.api.runtime.Bmv2ExtensionSelector extension selectors} (if any).
37 * <li> action: is built using the context interpreter
38 * {@link Bmv2Interpreter#mapTreatment(org.onosproject.net.flow.TrafficTreatment, Bmv2Configuration)
39 * treatment mapping function} or the flow rule
Carmelo Cascone9e39e312016-06-16 14:47:09 -070040 * {@link org.onosproject.bmv2.api.runtime.Bmv2ExtensionTreatment extension treatment} (if any).
41 * <li> timeout: if the table supports timeout, use the same as the flow rule, otherwise none (i.e. returns a
42 * permanent entry).
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070043 * </ul>
44 *
45 * @param rule a flow rule
46 * @param context a context
47 * @return a BMv2 table entry
48 * @throws Bmv2FlowRuleTranslatorException if the flow rule cannot be translated
49 */
50 Bmv2TableEntry translate(FlowRule rule, Bmv2DeviceContext context) throws Bmv2FlowRuleTranslatorException;
51}