Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | ce2a03d | 2017-08-03 19:21:03 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Foundation |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.bmv2.api.context; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import org.onosproject.bmv2.api.runtime.Bmv2TableEntry; |
| 21 | import org.onosproject.net.flow.FlowRule; |
| 22 | |
| 23 | /** |
| 24 | * Translator of ONOS flow rules to BMv2 table entries. |
| 25 | */ |
| 26 | @Beta |
| 27 | public 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 Cascone | 9e39e31 | 2016-06-16 14:47:09 -0700 | [diff] [blame] | 40 | * {@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 Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 43 | * </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 | } |