blob: 994335279bccf0c4672c6b00079c2ae16b2706f7 [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04003 *
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 Cascone39c28ca2017-11-15 13:03:57 -080017package org.onosproject.net.pi.service;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040018
19import com.google.common.annotations.Beta;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.pi.model.PiPipeconf;
22import org.onosproject.net.pi.model.PiPipeconfId;
23
24import java.util.Optional;
25
26/**
27 * A service to manage the configurations of protocol-independent pipelines.
28 */
29@Beta
30public 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 Cascone158b8c42018-07-04 19:42:37 +020038 * @throws IllegalStateException if the same pipeconf identifier is already
39 * registered.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040040 */
41 void register(PiPipeconf pipeconf) throws IllegalStateException;
42
43 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +020044 * 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 Campanellaa9b3c9b2017-07-21 14:03:15 +020049 *
50 * @param pipeconfId a pipeconfId
Carmelo Cascone158b8c42018-07-04 19:42:37 +020051 * @throws IllegalStateException if the same pipeconf identifier is already
52 * registered.
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020053 */
54 void remove(PiPipeconfId pipeconfId) throws IllegalStateException;
55
56 /**
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040057 * Returns all pipeconfs registered.
58 *
59 * @return a collection of pipeconfs
60 */
61 Iterable<PiPipeconf> getPipeconfs();
62
63 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +020064 * 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 Cascone1022a4e2017-05-25 00:16:18 -040067 *
68 * @param id a pipeconf identifier
69 * @return an optional pipeconf
70 */
71 Optional<PiPipeconf> getPipeconf(PiPipeconfId id);
72
73 /**
Carmelo Cascone4c289b72019-01-22 15:30:45 -080074 * Returns the pipeconf instance associated with the given device, if
75 * present. If not present, it means no pipeconf has been associated with
76 * that device so far.
77 *
78 * @param deviceId a device identifier
79 * @return an optional pipeconf
80 */
81 Optional<PiPipeconf> getPipeconf(DeviceId deviceId);
82
83 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +020084 * Signals that the given pipeconf is associated to the given infrastructure
85 * device. As a result of this method, the pipeconf for the given device can
86 * be later retrieved using {@link #ofDevice(DeviceId)}
87 *
88 * @param pipeconfId a pipeconf identifier
89 * @param deviceId a device identifier
90 */
91 void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId);
92
93 /**
94 * Returns the name of a driver that is equivalent to the base driver of the
95 * given device plus all the pipeline-specific behaviors exposed by the
96 * given pipeconf (previously registered using {@link
97 * #register(PiPipeconf)}). If such driver does not exist, this method
98 * creates one and registers is with all necessary ONOS subsystems, such
99 * that the returned name can be used to retrieve the driver instance using
100 * {@link org.onosproject.net.driver.DriverService#getDriver(String)}.
101 * <p>
102 * This method needs to be called on all nodes of the cluster that wants to
103 * use such merged driver.
104 * <p>
105 * Returns null if such merged driver cannot be created.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400106 *
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +0200107 * @param deviceId a device identifier
Andrea Campanellabc112a92017-06-26 19:06:43 +0200108 * @param pipeconfId a pipeconf identifier
Carmelo Cascone158b8c42018-07-04 19:42:37 +0200109 * @return driver name or null.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400110 */
Carmelo Cascone0761cd32018-08-29 19:22:50 -0700111 String getMergedDriver(DeviceId deviceId, PiPipeconfId pipeconfId);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400112
113 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +0200114 * Returns the pipeconf identifier currently associated with the given
115 * device identifier, if present. If not present, it means no pipeconf has
116 * been associated with that device so far.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400117 *
118 * @param deviceId device identifier
119 * @return an optional pipeconf identifier
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800120 * @deprecated in ONOS 2.1 use {@link #getPipeconf(DeviceId)} instead
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400121 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800122 @Deprecated
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400123 Optional<PiPipeconfId> ofDevice(DeviceId deviceId);
Andrea Campanellaf9c409a2017-07-13 14:14:41 +0200124
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400125}