alshabib | 77b8848 | 2015-04-07 15:47:50 -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 | 77b8848 | 2015-04-07 15:47:50 -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; |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 19 | |
| 20 | import java.util.List; |
| 21 | |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DeviceId; |
| 23 | |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 24 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 25 | * Service for programming data plane flow rules in manner independent of |
| 26 | * specific device table pipeline configuration. |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 27 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 28 | @Beta |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 29 | public interface FlowObjectiveService { |
| 30 | |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Installs the filtering rules onto the specified device. |
| 33 | * |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 34 | * @param deviceId device identifier |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 35 | * @param filteringObjective the filtering objective |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 36 | */ |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 37 | void filter(DeviceId deviceId, FilteringObjective filteringObjective); |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 38 | |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 39 | /** |
| 40 | * Installs the forwarding rules onto the specified device. |
| 41 | * |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 42 | * @param deviceId device identifier |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 43 | * @param forwardingObjective the forwarding objective |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 44 | */ |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 45 | void forward(DeviceId deviceId, ForwardingObjective forwardingObjective); |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 46 | |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Installs the next hop elements into the specified device. |
| 49 | * |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 50 | * @param deviceId device identifier |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 51 | * @param nextObjective a next objective |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 52 | */ |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 53 | void next(DeviceId deviceId, NextObjective nextObjective); |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 54 | |
alshabib | f6ea9e6 | 2015-04-21 17:08:26 -0700 | [diff] [blame] | 55 | /** |
| 56 | * Obtains a globally unique next objective. |
Sho SHIMIZU | 23aa2e7 | 2015-07-01 09:48:40 -0700 | [diff] [blame] | 57 | * |
alshabib | f6ea9e6 | 2015-04-21 17:08:26 -0700 | [diff] [blame] | 58 | * @return an integer |
| 59 | */ |
| 60 | int allocateNextId(); |
| 61 | |
Xin Jin | 313708b | 2015-07-09 13:43:04 -0700 | [diff] [blame] | 62 | /** |
Brian O'Connor | 3ac8526 | 2016-02-29 20:26:23 -0800 | [diff] [blame] | 63 | * Provides a composition policy expression. |
| 64 | * <p> |
| 65 | * WARNING: This method is a no-op in the default implementation. |
Xin Jin | 313708b | 2015-07-09 13:43:04 -0700 | [diff] [blame] | 66 | * |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 67 | * @param policy policy expression |
Xin Jin | 313708b | 2015-07-09 13:43:04 -0700 | [diff] [blame] | 68 | */ |
| 69 | void initPolicy(String policy); |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Installs the objective onto the specified device. |
| 73 | * |
| 74 | * @param deviceId device identifier |
| 75 | * @param objective the objective |
| 76 | */ |
| 77 | default void apply(DeviceId deviceId, Objective objective) { |
| 78 | if (ForwardingObjective.class.isAssignableFrom(objective.getClass())) { |
| 79 | forward(deviceId, (ForwardingObjective) objective); |
| 80 | } else if (FilteringObjective.class.isAssignableFrom(objective.getClass())) { |
| 81 | filter(deviceId, (FilteringObjective) objective); |
| 82 | } else if (NextObjective.class.isAssignableFrom(objective.getClass())) { |
| 83 | next(deviceId, (NextObjective) objective); |
| 84 | } else { |
| 85 | throw new UnsupportedOperationException("Unsupported objective of type " + objective.getClass()); |
| 86 | } |
| 87 | } |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Retrieve all nextObjective to group mappings known to this onos instance, |
| 91 | * in a format meant for display on the CLI, to help with debugging. Applications |
| 92 | * are only aware of next-Ids, while the group sub-system is only aware of group-ids. |
| 93 | * This method fills in the gap by providing information on the mapping |
| 94 | * between next-ids and group-ids done by device-drivers. |
| 95 | * |
| 96 | * @return a list of strings preformatted by the device-drivers to provide |
| 97 | * information on next-id to group-id mapping. Consumed by the |
Saurav Das | 42f6e6d | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 98 | * "obj-next-ids" command on the CLI. |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 99 | */ |
| 100 | List<String> getNextMappings(); |
Saurav Das | 42f6e6d | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Retrieve all nextObjectives that are waiting to hear back from device |
| 104 | * drivers, and the forwarding-objectives that are waiting on the |
| 105 | * successful completion of the next-objectives. Consumed by the |
| 106 | * "obj-pending-nexts" command on the CLI. |
| 107 | * |
| 108 | * @return a list of strings preformatted to provide information on the |
| 109 | * next-ids awaiting confirmation from the device-drivers. |
| 110 | */ |
| 111 | List<String> getPendingNexts(); |
alshabib | 77b8848 | 2015-04-07 15:47:50 -0700 | [diff] [blame] | 112 | } |