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 | /** |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 27 | * Configuration of a protocol-independent pipeline that includes a pipeline model, a collection of pipeline-specific |
| 28 | * behaviour implementations, and extensions. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 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 | /** |
ghj0504520 | ec1a420 | 2018-10-22 10:50:41 -0700 | [diff] [blame] | 48 | * Returns the fingerprint of pipeconf. |
| 49 | * |
| 50 | * @return a fingerprint |
| 51 | */ |
| 52 | long fingerprint(); |
| 53 | |
| 54 | /** |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 55 | * Returns all pipeline-specific behaviour interfaces defined by this configuration. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 56 | * |
| 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 Cascone | 31d3e44 | 2017-07-18 16:58:51 -0400 | [diff] [blame] | 78 | * 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 Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 81 | * |
| 82 | * @param type extension type |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 83 | * @return extension input stream |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 84 | */ |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 85 | Optional<InputStream> extension(ExtensionType type); |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Type of extension of a protocol-independent pipeline configuration. |
| 89 | */ |
| 90 | enum ExtensionType { |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 91 | |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 92 | /** |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 93 | * The P4Info as returned by the p4c compiler in text format. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 94 | */ |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 95 | P4_INFO_TEXT, |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * BMv2 JSON configuration. |
| 99 | */ |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 100 | BMV2_JSON, |
| 101 | |
| 102 | /** |
Alan Lo | 5e2b705 | 2018-10-18 14:24:24 +0300 | [diff] [blame] | 103 | * Mellanox Spectrum configuration binary. |
| 104 | */ |
| 105 | SPECTRUM_BIN, |
| 106 | |
| 107 | /** |
Carmelo Cascone | f7aa3f9 | 2017-07-06 23:56:50 -0400 | [diff] [blame] | 108 | * Barefoot's Tofino configuration binary. |
| 109 | */ |
Carmelo Cascone | d61fdb3 | 2017-10-30 10:09:57 -0700 | [diff] [blame] | 110 | TOFINO_BIN, |
| 111 | |
| 112 | /** |
| 113 | * Barefoot's Tofino context JSON. |
| 114 | */ |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 115 | TOFINO_CONTEXT_JSON, |
| 116 | |
| 117 | /** |
| 118 | * CPU port file in UTF 8 encoding. |
| 119 | */ |
| 120 | // TODO: consider a better way to get the CPU port in the interpreter |
| 121 | // (see FabricInterpreter.java mapLogicalPortNumber). Perhaps using |
| 122 | // pipeconf annotations? |
| 123 | CPU_PORT_TXT |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 124 | } |
| 125 | } |