Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [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 | |
Carmelo Cascone | 39c28ca | 2017-11-15 13:03:57 -0800 | [diff] [blame] | 17 | package org.onosproject.net.pi.service; |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.pi.model.PiPipeconf; |
| 22 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 23 | |
| 24 | import java.util.Optional; |
| 25 | |
| 26 | /** |
| 27 | * A service to manage the configurations of protocol-independent pipelines. |
| 28 | */ |
| 29 | @Beta |
| 30 | public interface PiPipeconfService { |
| 31 | |
| 32 | // TODO: we might want to extend ListenerService to support the broadcasting of PipeconfEvent. |
| 33 | |
| 34 | /** |
| 35 | * Registers the given pipeconf. |
| 36 | * |
| 37 | * @param pipeconf a pipeconf |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 38 | * @throws IllegalStateException if the same pipeconf identifier is already |
| 39 | * registered. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 40 | */ |
| 41 | void register(PiPipeconf pipeconf) throws IllegalStateException; |
| 42 | |
| 43 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 44 | * Unregisters the Pipeconf identified by the given PiPipeconfId. |
| 45 | * Unregistering a Pipeconf removes it from the ONOS controller, thus making |
| 46 | * it un-capable of controlling (e.g installing flow rules) the devices that |
| 47 | * have the pipeconf's P4 program deployed. For now this method DOES NOT |
| 48 | * remove the P4 program from the devices. |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 49 | * |
| 50 | * @param pipeconfId a pipeconfId |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 51 | * @throws IllegalStateException if the same pipeconf identifier is already |
| 52 | * registered. |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 53 | */ |
| 54 | void remove(PiPipeconfId pipeconfId) throws IllegalStateException; |
| 55 | |
| 56 | /** |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 57 | * Returns all pipeconfs registered. |
| 58 | * |
| 59 | * @return a collection of pipeconfs |
| 60 | */ |
| 61 | Iterable<PiPipeconf> getPipeconfs(); |
| 62 | |
| 63 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 64 | * Returns the pipeconf instance associated with the given identifier, if |
| 65 | * present. If not present, it means that no pipeconf with such identifier |
| 66 | * has been registered so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 67 | * |
| 68 | * @param id a pipeconf identifier |
| 69 | * @return an optional pipeconf |
| 70 | */ |
| 71 | Optional<PiPipeconf> getPipeconf(PiPipeconfId id); |
| 72 | |
| 73 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 74 | * Signals that the given pipeconf is associated to the given infrastructure |
| 75 | * device. As a result of this method, the pipeconf for the given device can |
| 76 | * be later retrieved using {@link #ofDevice(DeviceId)} |
| 77 | * |
| 78 | * @param pipeconfId a pipeconf identifier |
| 79 | * @param deviceId a device identifier |
| 80 | */ |
| 81 | void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId); |
| 82 | |
| 83 | /** |
| 84 | * Returns the name of a driver that is equivalent to the base driver of the |
| 85 | * given device plus all the pipeline-specific behaviors exposed by the |
| 86 | * given pipeconf (previously registered using {@link |
| 87 | * #register(PiPipeconf)}). If such driver does not exist, this method |
| 88 | * creates one and registers is with all necessary ONOS subsystems, such |
| 89 | * that the returned name can be used to retrieve the driver instance using |
| 90 | * {@link org.onosproject.net.driver.DriverService#getDriver(String)}. |
| 91 | * <p> |
| 92 | * This method needs to be called on all nodes of the cluster that wants to |
| 93 | * use such merged driver. |
| 94 | * <p> |
| 95 | * Returns null if such merged driver cannot be created. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 96 | * |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 97 | * @param deviceId a device identifier |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 98 | * @param pipeconfId a pipeconf identifier |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 99 | * @return driver name or null. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 100 | */ |
Carmelo Cascone | 20f8789 | 2018-08-29 19:22:50 -0700 | [diff] [blame] | 101 | String getMergedDriver(DeviceId deviceId, PiPipeconfId pipeconfId); |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 102 | |
| 103 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 104 | * Returns the pipeconf identifier currently associated with the given |
| 105 | * device identifier, if present. If not present, it means no pipeconf has |
| 106 | * been associated with that device so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 107 | * |
| 108 | * @param deviceId device identifier |
| 109 | * @return an optional pipeconf identifier |
| 110 | */ |
| 111 | Optional<PiPipeconfId> ofDevice(DeviceId deviceId); |
Andrea Campanella | f9c409a | 2017-07-13 14:14:41 +0200 | [diff] [blame] | 112 | |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 113 | } |