blob: 1c5ca95f1730fafc581449c11afa870a25bb97c9 [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
76 */
77 Collection<TrafficTreatment> next();
78
79 /**
80 * The type of operation that will be applied to the traffic using the collection
81 * of treatments.
82 *
83 * @return a type
84 */
85 Type type();
86
87 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -070088 * Auxiliary optional information provided to the device driver. Typically
Saurav Das8a0732e2015-11-20 15:27:53 -080089 * conveys information about selectors (matches) that are intended to
90 * use this Next Objective.
91 *
92 * @return a selector intended to pass meta information to the device driver.
93 * Value may be null if no meta information is provided.
94 */
95 TrafficSelector meta();
96
97 /**
alshabibfaa1e362015-04-02 15:01:54 -070098 * A next step builder.
99 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700100 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700101
102 /**
103 * Specifies the id for this next objective.
104 *
105 * @param nextId an integer
106 * @return a next objective builder
107 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700108 Builder withId(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Sets the type of next step.
112 *
113 * @param type a type
114 * @return a next step builder
115 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700116 Builder withType(Type type);
alshabibfaa1e362015-04-02 15:01:54 -0700117
118 /**
119 * Adds a treatment to this next step.
120 *
121 * @param treatment a traffic treatment
122 * @return a next step builder
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Builder addTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700125
Ray Milkey810d6e72015-08-14 10:35:06 -0700126 /**
127 * Specifies the application which applied the filter.
128 *
129 * @param appId an application id
130 * @return an objective builder
131 */
alshabib2a441c62015-04-13 18:39:38 -0700132 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700133 Builder fromApp(ApplicationId appId);
alshabib2a441c62015-04-13 18:39:38 -0700134
alshabibfaa1e362015-04-02 15:01:54 -0700135 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700136 * Sets the priority for this objective.
137 *
138 * @param priority an integer
139 * @return an objective builder
140 */
141 @Override
142 Builder withPriority(int priority);
143
144 /**
Saurav Das8a0732e2015-11-20 15:27:53 -0800145 * Set meta information related to this next objective.
146 *
147 * @param selector match conditions
148 * @return an objective builder
149 */
Saurav Das4ce45962015-11-24 23:21:05 -0800150 Builder withMeta(TrafficSelector selector);
Saurav Das8a0732e2015-11-20 15:27:53 -0800151
152 /**
alshabib2a441c62015-04-13 18:39:38 -0700153 * Builds the next objective that will be added.
alshabibfaa1e362015-04-02 15:01:54 -0700154 *
alshabib2a441c62015-04-13 18:39:38 -0700155 * @return a next objective
alshabibfaa1e362015-04-02 15:01:54 -0700156 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800157 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700158 NextObjective add();
alshabib2a441c62015-04-13 18:39:38 -0700159
160 /**
161 * Builds the next objective that will be removed.
162 *
163 * @return a next objective.
164 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800165 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700166 NextObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700167
168 /**
169 * Builds the next objective that will be added.
170 * The context will be used to notify the calling application.
171 *
172 * @param context an objective context
173 * @return a next objective
174 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800175 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700176 NextObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700177
178 /**
179 * Builds the next objective that will be removed.
180 * The context will be used to notify the calling application.
181 *
182 * @param context an objective context
183 * @return a next objective
184 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800185 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700186 NextObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700187
Saurav Das8a0732e2015-11-20 15:27:53 -0800188 /**
189 * Build the next objective that will be added, with {@link Operation}
190 * ADD_TO_EXISTING.
191 *
192 * @return a next objective
193 */
194 NextObjective addToExisting();
195
196 /**
197 * Build the next objective that will be removed, with {@link Operation}
198 * REMOVE_FROM_EXISTING.
199 *
200 * @return a next objective
201 */
202 NextObjective removeFromExisting();
203
204 /**
205 * Builds the next objective that will be added, with {@link Operation}
206 * ADD_TO_EXISTING. The context will be used to notify the calling application.
207 *
208 * @param context an objective context
209 * @return a next objective
210 */
211 NextObjective addToExisting(ObjectiveContext context);
212
213 /**
214 * Builds the next objective that will be removed, with {@link Operation}
215 * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
216 *
217 * @param context an objective context
218 * @return a next objective
219 */
220 NextObjective removeFromExisting(ObjectiveContext context);
221
alshabibfaa1e362015-04-02 15:01:54 -0700222 }
223
224}