alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | faa1e36 | 2015-04-02 15:01:54 -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 | package org.onosproject.net.flowobjective; |
| 17 | |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
| 21 | import org.onosproject.net.flow.TrafficTreatment; |
| 22 | |
| 23 | /** |
| 24 | * Represents a description of which types of traffic need to |
| 25 | * be forwarded through the device. A forwarding objective may |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 26 | * result in multiple rules at the device. There are two main types |
| 27 | * of forwarding objectives: |
| 28 | * |
| 29 | * - Versatile |
| 30 | * - Specific |
| 31 | * |
| 32 | * A versatile forwarding objective represents a composite rule that matches |
| 33 | * two or more header fields. The use of versatile usually indicates that this |
| 34 | * rule should be inserted in its entirety into the ACL table. Although, |
| 35 | * drivers for some devices are free to implement this differently. |
| 36 | * |
| 37 | * A specific forwarding objective represents a specific rule matching one or |
| 38 | * more header fields. The installation of this rule may result in several rules |
| 39 | * at the device. For example, one per table type. |
Jonghwan Hyun | 800d9d0 | 2018-04-09 09:40:50 -0700 | [diff] [blame] | 40 | * |
| 41 | * There is one additional type of forwarding objective: |
| 42 | * |
| 43 | * - Egress |
| 44 | * |
| 45 | * An egress forwarding objecrive represents a flow rule that is inserted into |
| 46 | * egress tables, only if they exist in the device. |
| 47 | * |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 48 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 49 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 50 | public interface ForwardingObjective extends Objective { |
| 51 | |
| 52 | /** |
| 53 | * Represents whether this objective is monolithic or |
| 54 | * may be broken down into parts. |
| 55 | */ |
| 56 | enum Flag { |
| 57 | /** |
| 58 | * A decomposable objective. |
| 59 | */ |
| 60 | SPECIFIC, |
| 61 | |
| 62 | /** |
| 63 | * A monolithic objective. |
| 64 | */ |
Jonghwan Hyun | 800d9d0 | 2018-04-09 09:40:50 -0700 | [diff] [blame] | 65 | VERSATILE, |
| 66 | |
| 67 | /** |
| 68 | * An objective to program egress pipeline. |
| 69 | */ |
| 70 | EGRESS |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Obtain the selector for this objective. |
| 75 | * |
| 76 | * @return a traffic selector |
| 77 | */ |
| 78 | TrafficSelector selector(); |
| 79 | |
| 80 | /** |
| 81 | * Obtain the traffic treatment for this objective. Mutually exclusive with |
| 82 | * 'treatment'. |
| 83 | * |
| 84 | * @return an integer |
| 85 | */ |
| 86 | Integer nextId(); |
| 87 | |
| 88 | /** |
| 89 | * A traffic treatment for this forwarding objective. Mutually exclusive |
| 90 | * with a nextId. |
| 91 | * |
| 92 | * @return a traffic treatment |
| 93 | */ |
| 94 | TrafficTreatment treatment(); |
| 95 | |
| 96 | /** |
| 97 | * Obtain the type of this objective. |
| 98 | * |
| 99 | * @return a flag type |
| 100 | */ |
| 101 | Flag flag(); |
| 102 | |
| 103 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 104 | * Auxiliary optional information provided to the device driver. Typically |
| 105 | * conveys information about selectors (matches) that are intended to |
| 106 | * use this Forwarding Objective. |
| 107 | * |
| 108 | * @return a selector intended to pass meta information to the device driver. |
| 109 | * Value may be null if no meta information is provided. |
| 110 | */ |
| 111 | TrafficSelector meta(); |
| 112 | |
| 113 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 114 | * Returns a new builder set to create a copy of this objective. |
| 115 | * |
| 116 | * @return new builder |
| 117 | */ |
| 118 | @Override |
| 119 | Builder copy(); |
| 120 | |
| 121 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 122 | * A forwarding objective builder. |
| 123 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 124 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Assigns a selector to the forwarding objective. |
| 128 | * |
| 129 | * @param selector a traffic selector |
| 130 | * @return a forwarding objective builder |
| 131 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 132 | Builder withSelector(TrafficSelector selector); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Assigns a next step to the forwarding objective. |
| 136 | * |
| 137 | * @param nextId a next objective id. |
| 138 | * @return a forwarding objective builder |
| 139 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 140 | Builder nextStep(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * Assigns the treatment for this forwarding objective. |
| 144 | * |
| 145 | * @param treatment a traffic treatment |
| 146 | * @return a forwarding objective |
| 147 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 148 | Builder withTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Assigns the flag to the forwarding objective. |
| 152 | * |
| 153 | * @param flag a flag |
| 154 | * @return a forwarding objective builder |
| 155 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 156 | Builder withFlag(Flag flag); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 157 | |
| 158 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 159 | * Set meta information related to this forwarding objective. |
| 160 | * |
| 161 | * @param selector match conditions |
| 162 | * @return an objective builder |
| 163 | */ |
| 164 | Builder withMeta(TrafficSelector selector); |
| 165 | |
| 166 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 167 | * Assigns an application id. |
| 168 | * |
| 169 | * @param appId an application id |
| 170 | * @return a filtering builder |
| 171 | */ |
| 172 | @Override |
| 173 | Builder fromApp(ApplicationId appId); |
| 174 | |
| 175 | /** |
| 176 | * Sets the priority for this objective. |
| 177 | * |
| 178 | * @param priority an integer |
| 179 | * @return an objective builder |
| 180 | */ |
| 181 | @Override |
| 182 | Builder withPriority(int priority); |
| 183 | |
| 184 | /** |
| 185 | * Makes the filtering objective permanent. |
| 186 | * |
| 187 | * @return an objective builder |
| 188 | */ |
| 189 | @Override |
| 190 | Builder makePermanent(); |
| 191 | |
| 192 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 193 | * Builds the forwarding objective that will be added. |
| 194 | * |
| 195 | * @return a forwarding objective |
| 196 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 197 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 198 | ForwardingObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Builds the forwarding objective that will be removed. |
| 202 | * |
| 203 | * @return a forwarding objective. |
| 204 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 205 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 206 | ForwardingObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 207 | |
| 208 | /** |
| 209 | * Builds the forwarding objective that will be added. |
| 210 | * The context will be used to notify the calling application. |
| 211 | * |
| 212 | * @param context an objective context |
| 213 | * @return a forwarding objective |
| 214 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 215 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 216 | ForwardingObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * Builds the forwarding objective that will be removed. |
| 220 | * The context will be used to notify the calling application. |
| 221 | * |
| 222 | * @param context an objective context |
| 223 | * @return a forwarding objective |
| 224 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 225 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 226 | ForwardingObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 227 | } |
| 228 | } |