blob: 9b353c89e8229d8ae41b36e56e9e5f317b0198ea [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
17package org.onosproject.net.pi.model;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.driver.Behaviour;
21
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040022import java.io.InputStream;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040023import java.util.Collection;
24import java.util.Optional;
25
26/**
Carmelo Cascone87892e22017-11-13 16:01:29 -080027 * Configuration of a protocol-independent pipeline that includes a pipeline model, a collection of pipeline-specific
28 * behaviour implementations, and extensions.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040029 */
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 /**
Carmelo Cascone31d3e442017-07-18 16:58:51 -040071 * Returns, if present, an input stream pointing at the beginning of a file representing a device-specific or
72 * control protocol-specific extension of this configuration. For example, if requesting a target-specific P4
73 * binary, this will return the same bytes produced by the P4 compiler.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040074 *
75 * @param type extension type
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040076 * @return extension input stream
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040077 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040078 Optional<InputStream> extension(ExtensionType type);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040079
80 /**
81 * Type of extension of a protocol-independent pipeline configuration.
82 */
83 enum ExtensionType {
Carmelo Cascone87892e22017-11-13 16:01:29 -080084
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040085 /**
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040086 * The P4Info as returned by the p4c compiler in text format.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040087 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040088 P4_INFO_TEXT,
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040089
90 /**
91 * BMv2 JSON configuration.
92 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040093 BMV2_JSON,
94
95 /**
96 * Barefoot's Tofino configuration binary.
97 */
Carmelo Casconed61fdb32017-10-30 10:09:57 -070098 TOFINO_BIN,
99
100 /**
101 * Barefoot's Tofino context JSON.
102 */
103 TOFINO_CONTEXT_JSON
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400104 }
105}