Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-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 | |
| 17 | package org.onosproject.bmv2.api.context; |
| 18 | |
| 19 | import com.eclipsesource.json.JsonObject; |
| 20 | import com.google.common.annotations.Beta; |
| 21 | |
| 22 | import java.util.List; |
| 23 | |
| 24 | /** |
| 25 | * BMv2 packet processing configuration. Such a configuration is used to define the way BMv2 should process packets |
| 26 | * (i.e. it defines the device ingress/egress pipelines, parser, tables, actions, etc.). It must be noted that this |
| 27 | * class exposes only a subset of the configuration properties of a BMv2 device (only those that are needed for the |
| 28 | * purpose of translating ONOS structures to BMv2 structures). Such a configuration is backed by a JSON object. |
| 29 | * BMv2 JSON configuration files are usually generated using a P4 frontend compiler such as p4c-bmv2. |
| 30 | */ |
| 31 | @Beta |
| 32 | public interface Bmv2Configuration { |
| 33 | |
| 34 | /** |
| 35 | * Return an unmodifiable view of the JSON backing this configuration. |
| 36 | * |
| 37 | * @return a JSON object. |
| 38 | */ |
| 39 | JsonObject json(); |
| 40 | |
| 41 | /** |
| 42 | * Returns the header type associated with the given numeric ID, null if there's no such an ID in the configuration. |
| 43 | * |
| 44 | * @param id integer value |
| 45 | * @return header type object or null |
| 46 | */ |
| 47 | Bmv2HeaderTypeModel headerType(int id); |
| 48 | |
| 49 | /** |
| 50 | * Returns the header type associated with the given name, null if there's no such a name in the configuration. |
| 51 | * |
| 52 | * @param name string value |
| 53 | * @return header type object or null |
| 54 | */ |
| 55 | Bmv2HeaderTypeModel headerType(String name); |
| 56 | |
| 57 | /** |
| 58 | * Returns the list of all the header types defined by in this configuration. Values returned are sorted in |
| 59 | * ascending order based on the numeric ID. |
| 60 | * |
| 61 | * @return list of header types |
| 62 | */ |
| 63 | List<Bmv2HeaderTypeModel> headerTypes(); |
| 64 | |
| 65 | /** |
| 66 | * Returns the header associated with the given numeric ID, null if there's no such an ID in the configuration. |
| 67 | * |
| 68 | * @param id integer value |
| 69 | * @return header object or null |
| 70 | */ |
| 71 | Bmv2HeaderModel header(int id); |
| 72 | |
| 73 | /** |
| 74 | * Returns the header associated with the given name, null if there's no such a name in the configuration. |
| 75 | * |
| 76 | * @param name string value |
| 77 | * @return header object or null |
| 78 | */ |
| 79 | Bmv2HeaderModel header(String name); |
| 80 | |
| 81 | /** |
| 82 | * Returns the list of all the header instances defined in this configuration. Values returned are sorted in |
| 83 | * ascending order based on the numeric ID. |
| 84 | * |
| 85 | * @return list of header types |
| 86 | */ |
| 87 | List<Bmv2HeaderModel> headers(); |
| 88 | |
| 89 | /** |
| 90 | * Returns the action associated with the given numeric ID, null if there's no such an ID in the configuration. |
| 91 | * |
| 92 | * @param id integer value |
| 93 | * @return action object or null |
| 94 | */ |
| 95 | Bmv2ActionModel action(int id); |
| 96 | |
| 97 | /** |
| 98 | * Returns the action associated with the given name, null if there's no such a name in the configuration. |
| 99 | * |
| 100 | * @param name string value |
| 101 | * @return action object or null |
| 102 | */ |
| 103 | Bmv2ActionModel action(String name); |
| 104 | |
| 105 | /** |
| 106 | * Returns the list of all the actions defined by in this configuration. Values returned are sorted in ascending |
| 107 | * order based on the numeric ID. |
| 108 | * |
| 109 | * @return list of actions |
| 110 | */ |
| 111 | List<Bmv2ActionModel> actions(); |
| 112 | |
| 113 | /** |
| 114 | * Returns the table associated with the given numeric ID, null if there's no such an ID in the configuration. |
| 115 | * |
| 116 | * @param id integer value |
| 117 | * @return table object or null |
| 118 | */ |
| 119 | Bmv2TableModel table(int id); |
| 120 | |
| 121 | /** |
| 122 | * Returns the table associated with the given name, null if there's no such a name in the configuration. |
| 123 | * |
| 124 | * @param name string value |
| 125 | * @return table object or null |
| 126 | */ |
| 127 | Bmv2TableModel table(String name); |
| 128 | |
| 129 | /** |
| 130 | * Returns the list of all the tables defined by in this configuration. Values returned are sorted in ascending |
| 131 | * order based on the numeric ID. |
| 132 | * |
| 133 | * @return list of actions |
| 134 | */ |
| 135 | List<Bmv2TableModel> tables(); |
| 136 | } |