blob: 19585f7e29dae873ba1b43d92d8fa261425b0074 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibfaa1e362015-04-02 15:01:54 -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 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabib2a441c62015-04-13 18:39:38 -070019import org.onosproject.core.ApplicationId;
Saurav Das8a0732e2015-11-20 15:27:53 -080020import org.onosproject.net.flow.TrafficSelector;
alshabibfaa1e362015-04-02 15:01:54 -070021import org.onosproject.net.flow.TrafficTreatment;
22
23import java.util.Collection;
24
25/**
26 * Represents a nexthop which will be translated by a driver
27 * into the appropriate group or actions needed to implement
alshabib9d9e3a32015-06-25 18:33:50 -070028 * the egress function.
29 *
Sho SHIMIZUfee286d2015-07-01 10:19:10 -070030 * A next objective is made up of a collection of traffic treatments
alshabib9d9e3a32015-06-25 18:33:50 -070031 * associated with a type. These types are:
32 *
33 * - Hashed
34 * - Broadcast
35 * - Failover
36 * - Simple
37 *
Saurav Das8a0732e2015-11-20 15:27:53 -080038 * These types will indicate to the driver what the intended behavior is.
alshabib9d9e3a32015-06-25 18:33:50 -070039 * For example, a broadcast next objective with a collection of output
40 * treatments will indicate to a driver that all output actions are expected
41 * to be executed simultaneously. The driver is then free to implement this
42 * as a group or a simple action list.
alshabibfaa1e362015-04-02 15:01:54 -070043 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070044@Beta
alshabibfaa1e362015-04-02 15:01:54 -070045public interface NextObjective extends Objective {
46
47 /**
48 * Represents the type of next phase to build.
49 */
50 enum Type {
51 /**
52 * A hashed packet processing.
53 */
54 HASHED,
55
56 /**
57 * Broadcast packet process.
58 */
59 BROADCAST,
60
61 /**
62 * Failover handling.
63 */
64 FAILOVER,
65
66 /**
67 * Simple processing. Could be a group or a treatment.
68 */
69 SIMPLE
70 }
71
72 /**
73 * The collection of treatments that need to be applied to a set of traffic.
74 *
75 * @return a collection of traffic treatments
Charles Chanb87d9f12018-10-31 21:00:06 -070076 * @deprecated in 1.14.2, replaced by {@link #nextTreatments}
alshabibfaa1e362015-04-02 15:01:54 -070077 */
Charles Chanb87d9f12018-10-31 21:00:06 -070078 @Deprecated
alshabibfaa1e362015-04-02 15:01:54 -070079 Collection<TrafficTreatment> next();
80
81 /**
Charles Chanb87d9f12018-10-31 21:00:06 -070082 * The collection of next treatments that need to be applied to a set of traffic.
83 *
84 * @return a collection of next treatments
85 */
86 Collection<NextTreatment> nextTreatments();
87
88 /**
alshabibfaa1e362015-04-02 15:01:54 -070089 * The type of operation that will be applied to the traffic using the collection
90 * of treatments.
91 *
92 * @return a type
93 */
94 Type type();
95
96 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -070097 * Auxiliary optional information provided to the device driver. Typically
Saurav Das8a0732e2015-11-20 15:27:53 -080098 * conveys information about selectors (matches) that are intended to
99 * use this Next Objective.
100 *
101 * @return a selector intended to pass meta information to the device driver.
102 * Value may be null if no meta information is provided.
103 */
104 TrafficSelector meta();
105
106 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800107 * Returns a new builder set to create a copy of this objective.
108 *
109 * @return new builder
110 */
111 @Override
112 Builder copy();
113
114 /**
alshabibfaa1e362015-04-02 15:01:54 -0700115 * A next step builder.
116 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700117 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700118
119 /**
120 * Specifies the id for this next objective.
121 *
122 * @param nextId an integer
123 * @return a next objective builder
124 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700125 Builder withId(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700126
127 /**
128 * Sets the type of next step.
129 *
130 * @param type a type
131 * @return a next step builder
132 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700133 Builder withType(Type type);
alshabibfaa1e362015-04-02 15:01:54 -0700134
135 /**
136 * Adds a treatment to this next step.
137 *
138 * @param treatment a traffic treatment
139 * @return a next step builder
Charles Chanb87d9f12018-10-31 21:00:06 -0700140 * @deprecated in 1.14.2, replaced by {@link #addTreatment(NextTreatment)}
alshabibfaa1e362015-04-02 15:01:54 -0700141 */
Charles Chanb87d9f12018-10-31 21:00:06 -0700142 @Deprecated
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700143 Builder addTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700144
Ray Milkey810d6e72015-08-14 10:35:06 -0700145 /**
Charles Chanb87d9f12018-10-31 21:00:06 -0700146 * Adds a next treatment to this next step.
147 *
148 * @param nextTreatment a next treatment
149 * @return a next step builder
150 */
151 Builder addTreatment(NextTreatment nextTreatment);
152
153 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700154 * Specifies the application which applied the filter.
155 *
156 * @param appId an application id
157 * @return an objective builder
158 */
alshabib2a441c62015-04-13 18:39:38 -0700159 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700160 Builder fromApp(ApplicationId appId);
alshabib2a441c62015-04-13 18:39:38 -0700161
alshabibfaa1e362015-04-02 15:01:54 -0700162 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700163 * Sets the priority for this objective.
164 *
165 * @param priority an integer
166 * @return an objective builder
167 */
168 @Override
169 Builder withPriority(int priority);
170
171 /**
Saurav Das8a0732e2015-11-20 15:27:53 -0800172 * Set meta information related to this next objective.
173 *
174 * @param selector match conditions
175 * @return an objective builder
176 */
Saurav Das4ce45962015-11-24 23:21:05 -0800177 Builder withMeta(TrafficSelector selector);
Saurav Das8a0732e2015-11-20 15:27:53 -0800178
179 /**
alshabib2a441c62015-04-13 18:39:38 -0700180 * Builds the next objective that will be added.
alshabibfaa1e362015-04-02 15:01:54 -0700181 *
alshabib2a441c62015-04-13 18:39:38 -0700182 * @return a next objective
alshabibfaa1e362015-04-02 15:01:54 -0700183 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800184 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700185 NextObjective add();
alshabib2a441c62015-04-13 18:39:38 -0700186
187 /**
188 * Builds the next objective that will be removed.
189 *
190 * @return a next objective.
191 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800192 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700193 NextObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700194
195 /**
196 * Builds the next objective that will be added.
197 * The context will be used to notify the calling application.
198 *
199 * @param context an objective context
200 * @return a next objective
201 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800202 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700203 NextObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700204
205 /**
206 * Builds the next objective that will be removed.
207 * The context will be used to notify the calling application.
208 *
209 * @param context an objective context
210 * @return a next objective
211 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800212 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700213 NextObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700214
Saurav Das8a0732e2015-11-20 15:27:53 -0800215 /**
216 * Build the next objective that will be added, with {@link Operation}
217 * ADD_TO_EXISTING.
218 *
219 * @return a next objective
220 */
221 NextObjective addToExisting();
222
223 /**
224 * Build the next objective that will be removed, with {@link Operation}
225 * REMOVE_FROM_EXISTING.
226 *
227 * @return a next objective
228 */
229 NextObjective removeFromExisting();
230
231 /**
232 * Builds the next objective that will be added, with {@link Operation}
233 * ADD_TO_EXISTING. The context will be used to notify the calling application.
234 *
235 * @param context an objective context
236 * @return a next objective
237 */
238 NextObjective addToExisting(ObjectiveContext context);
239
240 /**
241 * Builds the next objective that will be removed, with {@link Operation}
242 * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
243 *
244 * @param context an objective context
245 * @return a next objective
246 */
247 NextObjective removeFromExisting(ObjectiveContext context);
248
Saurav Dasceccf242017-08-03 18:30:35 -0700249 /**
Jonghwan Hyunf810a7a2018-02-12 16:43:45 +0900250 * Build the next objective that will be modified with {@link Operation}
251 * MODIFY.
252 *
253 * @return a next objective
254 */
255
256 NextObjective modify();
257 /**
258 * Build the next objective that will be modified, with {@link Operation}
259 * MODIFY. The context will be used to notify the calling application.
260 *
261 * @param context an objective context
262 * @return a next objective
263 */
264 NextObjective modify(ObjectiveContext context);
265
266 /**
Saurav Dasceccf242017-08-03 18:30:35 -0700267 * Builds the next objective that needs to be verified.
268 *
269 * @return a next objective with {@link Operation} VERIFY
270 */
271 NextObjective verify();
272
273 /**
274 * Builds the next objective that needs to be verified. The context will
275 * be used to notify the calling application.
276 *
277 * @param context an objective context
278 * @return a next objective with {@link Operation} VERIFY
279 */
280 NextObjective verify(ObjectiveContext context);
281
alshabibfaa1e362015-04-02 15:01:54 -0700282 }
283
284}