blob: e9539a59c32ecc880b9f6a905db38a7716246767 [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 Cascone158b8c42018-07-04 19:42:37 +020074 * 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 Cascone1022a4e2017-05-25 00:16:18 -040096 *
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020097 * @param deviceId a device identifier
Andrea Campanellabc112a92017-06-26 19:06:43 +020098 * @param pipeconfId a pipeconf identifier
Carmelo Cascone158b8c42018-07-04 19:42:37 +020099 * @return driver name or null.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400100 */
Carmelo Cascone0761cd32018-08-29 19:22:50 -0700101 String getMergedDriver(DeviceId deviceId, PiPipeconfId pipeconfId);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400102
103 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +0200104 * 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 Cascone1022a4e2017-05-25 00:16:18 -0400107 *
108 * @param deviceId device identifier
109 * @return an optional pipeconf identifier
110 */
111 Optional<PiPipeconfId> ofDevice(DeviceId deviceId);
Andrea Campanellaf9c409a2017-07-13 14:14:41 +0200112
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400113}