alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
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; |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.TrafficTreatment; |
| 22 | |
| 23 | import 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 |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 28 | * the egress function. |
| 29 | * |
Sho SHIMIZU | fee286d | 2015-07-01 10:19:10 -0700 | [diff] [blame] | 30 | * A next objective is made up of a collection of traffic treatments |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 31 | * associated with a type. These types are: |
| 32 | * |
| 33 | * - Hashed |
| 34 | * - Broadcast |
| 35 | * - Failover |
| 36 | * - Simple |
| 37 | * |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 38 | * These types will indicate to the driver what the intended behavior is. |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 39 | * 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. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 43 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 44 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 45 | public 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 Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 88 | * Auxiliary optional information provided to the device driver. Typically |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 89 | * 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 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 98 | * A next step builder. |
| 99 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 100 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Specifies the id for this next objective. |
| 104 | * |
| 105 | * @param nextId an integer |
| 106 | * @return a next objective builder |
| 107 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 108 | Builder withId(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Sets the type of next step. |
| 112 | * |
| 113 | * @param type a type |
| 114 | * @return a next step builder |
| 115 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 116 | Builder withType(Type type); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Adds a treatment to this next step. |
| 120 | * |
| 121 | * @param treatment a traffic treatment |
| 122 | * @return a next step builder |
| 123 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 124 | Builder addTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 125 | |
Ray Milkey | 810d6e7 | 2015-08-14 10:35:06 -0700 | [diff] [blame] | 126 | /** |
| 127 | * Specifies the application which applied the filter. |
| 128 | * |
| 129 | * @param appId an application id |
| 130 | * @return an objective builder |
| 131 | */ |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 132 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 133 | Builder fromApp(ApplicationId appId); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 134 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 135 | /** |
Ray Milkey | 810d6e7 | 2015-08-14 10:35:06 -0700 | [diff] [blame] | 136 | * 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 Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 145 | * Set meta information related to this next objective. |
| 146 | * |
| 147 | * @param selector match conditions |
| 148 | * @return an objective builder |
| 149 | */ |
Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 150 | Builder withMeta(TrafficSelector selector); |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 151 | |
| 152 | /** |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 153 | * Builds the next objective that will be added. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 154 | * |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 155 | * @return a next objective |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 156 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 157 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 158 | NextObjective add(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * Builds the next objective that will be removed. |
| 162 | * |
| 163 | * @return a next objective. |
| 164 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 165 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 166 | NextObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 167 | |
| 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 Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 175 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 176 | NextObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 177 | |
| 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 Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 185 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 186 | NextObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 187 | |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 188 | /** |
| 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 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | } |