blob: 99754a8b616094f876fbe6539833fae30d1fcc50 [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
2 * Copyright 2017-present Open Networking Laboratory
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
17package org.onosproject.net.pi.model;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.driver.Behaviour;
21
22import java.nio.ByteBuffer;
23import java.util.Collection;
24import java.util.Optional;
25
26/**
27 * Configuration of a protocol-independent pipeline that includes a pipeline model, a collection of
28 * pipeline-specific behaviours implementation, and extensions.
29 */
30@Beta
31public interface PiPipeconf {
32
33 /**
34 * Returns the identifier of this pipeline configuration.
35 *
36 * @return a identifier
37 */
38 PiPipeconfId id();
39
40 /**
41 * Returns the pipeline model.
42 *
43 * @return a pipeline model
44 */
45 PiPipelineModel pipelineModel();
46
47 /**
Andrea Campanellabc112a92017-06-26 19:06:43 +020048 * Returns all pipeline-specific behaviour interfaces defined by this configuration.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040049 *
50 * @return a collection of behaviours
51 */
52 Collection<Class<? extends Behaviour>> behaviours();
53
54 /**
55 * Returns the implementation class for the given behaviour, if present.
56 *
57 * @param behaviour behaviour interface
58 * @return implementation class
59 */
60 Optional<Class<? extends Behaviour>> implementation(Class<? extends Behaviour> behaviour);
61
62 /**
63 * Indicates whether or not the pipeconf supports the specified class of behaviour.
64 *
65 * @param behaviourClass behaviour class
66 * @return true if behaviour is supported
67 */
68 boolean hasBehaviour(Class<? extends Behaviour> behaviourClass);
69
70 /**
71 * Returns, if present, an arbitrary sequence of bytes representing a device-specific or control
72 * protocol-specific extension of this configuration. For example, if requesting a
73 * target-specific P4 binary, this will return the same bytes produced by the P4 compiler.
74 *
75 * @param type extension type
76 * @return extension bytes
77 */
78 // FIXME: this is a sloppy way of handling extensions.
79 Optional<ByteBuffer> extension(ExtensionType type);
80
81 /**
82 * Type of extension of a protocol-independent pipeline configuration.
83 */
84 enum ExtensionType {
85 /**
86 * The P4Info as returned by the p4c compiler (in binary format).
87 */
88 P4_INFO_BINARY,
89
90 /**
91 * BMv2 JSON configuration.
92 */
93 BMV2_JSON
94 }
95}