blob: 9ebd70f24c49989dca5c8e6b6c419c042567704f [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 /**
ghj0504520ec1a4202018-10-22 10:50:41 -070048 * Returns the fingerprint of pipeconf.
49 *
50 * @return a fingerprint
51 */
52 long fingerprint();
53
54 /**
Andrea Campanellabc112a92017-06-26 19:06:43 +020055 * Returns all pipeline-specific behaviour interfaces defined by this configuration.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040056 *
57 * @return a collection of behaviours
58 */
59 Collection<Class<? extends Behaviour>> behaviours();
60
61 /**
62 * Returns the implementation class for the given behaviour, if present.
63 *
64 * @param behaviour behaviour interface
65 * @return implementation class
66 */
67 Optional<Class<? extends Behaviour>> implementation(Class<? extends Behaviour> behaviour);
68
69 /**
70 * Indicates whether or not the pipeconf supports the specified class of behaviour.
71 *
72 * @param behaviourClass behaviour class
73 * @return true if behaviour is supported
74 */
75 boolean hasBehaviour(Class<? extends Behaviour> behaviourClass);
76
77 /**
Carmelo Cascone31d3e442017-07-18 16:58:51 -040078 * Returns, if present, an input stream pointing at the beginning of a file representing a device-specific or
79 * control protocol-specific extension of this configuration. For example, if requesting a target-specific P4
80 * binary, this will return the same bytes produced by the P4 compiler.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040081 *
82 * @param type extension type
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040083 * @return extension input stream
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040084 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040085 Optional<InputStream> extension(ExtensionType type);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040086
87 /**
88 * Type of extension of a protocol-independent pipeline configuration.
89 */
90 enum ExtensionType {
Carmelo Cascone87892e22017-11-13 16:01:29 -080091
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040092 /**
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040093 * The P4Info as returned by the p4c compiler in text format.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040094 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -040095 P4_INFO_TEXT,
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040096
97 /**
98 * BMv2 JSON configuration.
99 */
Carmelo Casconef7aa3f92017-07-06 23:56:50 -0400100 BMV2_JSON,
101
102 /**
Alan Lo5e2b7052018-10-18 14:24:24 +0300103 * Mellanox Spectrum configuration binary.
104 */
105 SPECTRUM_BIN,
106
107 /**
Carmelo Casconef7aa3f92017-07-06 23:56:50 -0400108 * Barefoot's Tofino configuration binary.
109 */
Carmelo Casconed61fdb32017-10-30 10:09:57 -0700110 TOFINO_BIN,
111
112 /**
113 * Barefoot's Tofino context JSON.
114 */
Carmelo Cascone6880ba62018-09-06 00:04:34 -0700115 TOFINO_CONTEXT_JSON,
116
117 /**
Carmelo Cascone37f31ad2019-07-14 19:12:24 -0700118 * Stratum Fixed Pipeline Model (FPM) pipeline configuration binary.
119 */
120 STRATUM_FPM_BIN,
121
122 /**
Carmelo Cascone6880ba62018-09-06 00:04:34 -0700123 * CPU port file in UTF 8 encoding.
124 */
125 // TODO: consider a better way to get the CPU port in the interpreter
126 // (see FabricInterpreter.java mapLogicalPortNumber). Perhaps using
127 // pipeconf annotations?
Yi Tseng40e0a0c2020-06-08 17:10:56 +0800128 CPU_PORT_TXT,
129
130 /**
131 * Raw device config.
132 */
133 RAW_DEVICE_CONFIG
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400134 }
135}