blob: 722b881f952c158360bb296cc6dbffe6bdbb2b9e [file] [log] [blame]
alshabib77b88482015-04-07 15:47:50 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
alshabib77b88482015-04-07 15:47:50 -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;
Saurav Das24431192016-03-07 19:13:00 -080019
20import java.util.List;
21
alshabib77b88482015-04-07 15:47:50 -070022import org.onosproject.net.DeviceId;
23
alshabib77b88482015-04-07 15:47:50 -070024/**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070025 * Service for programming data plane flow rules in manner independent of
26 * specific device table pipeline configuration.
alshabib77b88482015-04-07 15:47:50 -070027 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070028@Beta
alshabib77b88482015-04-07 15:47:50 -070029public interface FlowObjectiveService {
30
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070031 /**
32 * Installs the filtering rules onto the specified device.
33 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080034 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070035 * @param filteringObjective the filtering objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070036 */
alshabib2a441c62015-04-13 18:39:38 -070037 void filter(DeviceId deviceId, FilteringObjective filteringObjective);
alshabib77b88482015-04-07 15:47:50 -070038
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070039 /**
40 * Installs the forwarding rules onto the specified device.
41 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080042 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070043 * @param forwardingObjective the forwarding objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070044 */
alshabib2a441c62015-04-13 18:39:38 -070045 void forward(DeviceId deviceId, ForwardingObjective forwardingObjective);
alshabib77b88482015-04-07 15:47:50 -070046
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070047 /**
48 * Installs the next hop elements into the specified device.
49 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080050 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070051 * @param nextObjective a next objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070052 */
alshabib2a441c62015-04-13 18:39:38 -070053 void next(DeviceId deviceId, NextObjective nextObjective);
alshabib77b88482015-04-07 15:47:50 -070054
alshabibf6ea9e62015-04-21 17:08:26 -070055 /**
56 * Obtains a globally unique next objective.
Sho SHIMIZU23aa2e72015-07-01 09:48:40 -070057 *
alshabibf6ea9e62015-04-21 17:08:26 -070058 * @return an integer
59 */
60 int allocateNextId();
61
Xin Jin313708b2015-07-09 13:43:04 -070062 /**
Brian O'Connor3ac85262016-02-29 20:26:23 -080063 * Provides a composition policy expression.
64 * <p>
65 * WARNING: This method is a no-op in the default implementation.
Xin Jin313708b2015-07-09 13:43:04 -070066 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080067 * @param policy policy expression
Xin Jin313708b2015-07-09 13:43:04 -070068 */
69 void initPolicy(String policy);
Thomas Vachuska00f48162016-02-29 17:07:23 -080070
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 Das24431192016-03-07 19:13:00 -080088
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 Dasb5c236e2016-06-07 10:08:06 -070098 * "obj-next-ids" command on the CLI.
Saurav Das24431192016-03-07 19:13:00 -080099 */
100 List<String> getNextMappings();
Saurav Dasb5c236e2016-06-07 10:08:06 -0700101
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();
alshabib77b88482015-04-07 15:47:50 -0700112}