Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.pi.model; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import org.onosproject.net.driver.Behaviour; |
| 21 | |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 22 | import java.io.InputStream; |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 23 | import java.util.Collection; |
| 24 | import 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 |
| 31 | public 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 Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 48 | * Returns all pipeline-specific behaviour interfaces defined by this configuration. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 49 | * |
| 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 Cascone | 31d3e44 | 2017-07-18 16:58:51 -0400 | [diff] [blame] | 71 | * 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 Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 74 | * |
| 75 | * @param type extension type |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 76 | * @return extension input stream |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 77 | */ |
| 78 | // FIXME: this is a sloppy way of handling extensions. |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 79 | Optional<InputStream> extension(ExtensionType type); |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Type of extension of a protocol-independent pipeline configuration. |
| 83 | */ |
| 84 | enum ExtensionType { |
| 85 | /** |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 86 | * The P4Info as returned by the p4c compiler in text format. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 87 | */ |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 88 | P4_INFO_TEXT, |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * BMv2 JSON configuration. |
| 92 | */ |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 93 | BMV2_JSON, |
| 94 | |
| 95 | /** |
| 96 | * Barefoot's Tofino configuration binary. |
| 97 | */ |
| 98 | TOFINO_BIN |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 99 | } |
| 100 | } |