blob: 51ba53d3375d2816fe6382ff59e44214d1850433 [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;
20
21import java.util.Collection;
Carmelo Cascone00a59962017-06-16 17:51:49 +090022import java.util.Optional;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040023
24/**
25 * Model of a match+action table in a protocol-independent pipeline.
26 */
27@Beta
28public interface PiTableModel {
29
30 /**
Carmelo Cascone87892e22017-11-13 16:01:29 -080031 * Returns the ID of this table.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040032 *
33 * @return a string value
34 */
Carmelo Cascone87892e22017-11-13 16:01:29 -080035 PiTableId id();
36
37 /**
38 * Returns the type of this table.
39 *
40 * @return table type
41 */
42 PiTableType tableType();
43
44 /**
Carmelo Cascone50d195f2018-09-11 13:26:38 -070045 * Returns the model of the action profile that implements this table.
46 * Meaningful if this table is of type {@link PiTableType#INDIRECT},
47 * otherwise returns null.
Carmelo Cascone87892e22017-11-13 16:01:29 -080048 *
49 * @return action profile ID
50 */
51 PiActionProfileModel actionProfile();
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040052
53 /**
54 * Returns the maximum number of entries supported by this table.
55 *
56 * @return an integer value
57 */
Carmelo Cascone87892e22017-11-13 16:01:29 -080058 long maxSize();
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040059
60 /**
Carmelo Cascone87892e22017-11-13 16:01:29 -080061 * Returns a collection of direct counters associated to this table.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040062 *
Carmelo Cascone87892e22017-11-13 16:01:29 -080063 * @return collection of direct counters
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040064 */
Carmelo Cascone87892e22017-11-13 16:01:29 -080065 Collection<PiCounterModel> counters();
66
67 /**
68 * Returns a collection of direct meters associated to this table.
69 *
70 * @return collection of direct meters
71 */
72 Collection<PiMeterModel> meters();
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040073
74 /**
75 * Returns true if this table supports aging, false otherwise.
76 *
77 * @return a boolean value
78 */
79 boolean supportsAging();
80
81 /**
82 * Returns the collection of match fields supported by this table.
83 *
84 * @return a collection of match field models
85 */
Carmelo Cascone87892e22017-11-13 16:01:29 -080086 Collection<PiMatchFieldModel> matchFields();
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040087
88 /**
89 * Returns the actions supported by this table.
90 *
91 * @return a collection of action models
92 */
93 Collection<PiActionModel> actions();
Carmelo Cascone00a59962017-06-16 17:51:49 +090094
95 /**
Carmelo Cascone50d195f2018-09-11 13:26:38 -070096 * Returns the model of the constant default action associated with this
97 * table, if any.
Carmelo Cascone00a59962017-06-16 17:51:49 +090098 *
Carmelo Cascone87892e22017-11-13 16:01:29 -080099 * @return optional default action model
100 */
Carmelo Cascone50d195f2018-09-11 13:26:38 -0700101 Optional<PiActionModel> constDefaultAction();
Carmelo Cascone87892e22017-11-13 16:01:29 -0800102
103 /**
Carmelo Cascone33b27bc2018-09-09 22:56:14 -0700104 * Returns true if the table is populated with static entries that cannot be
105 * modified by the control plane at runtime.
106 *
107 * @return true if table is populated with static entries, false otherwise
108 */
109 boolean isConstantTable();
110
111 /**
Daniele Morod900fe42021-02-11 16:12:57 +0100112 * Returns true if the table supports one shot only when associated to an
113 * action profile.
114 *
115 * @return true if table support one shot only, false otherwise
116 */
117 boolean oneShotOnly();
118
119 /**
Carmelo Cascone50d195f2018-09-11 13:26:38 -0700120 * Returns the action model associated with the given ID, if present. If not
121 * present, it means that this table does not support such an action.
Carmelo Cascone87892e22017-11-13 16:01:29 -0800122 *
123 * @param actionId action ID
Carmelo Cascone00a59962017-06-16 17:51:49 +0900124 * @return optional action model
125 */
Carmelo Cascone87892e22017-11-13 16:01:29 -0800126 Optional<PiActionModel> action(PiActionId actionId);
127
128 /**
Carmelo Cascone50d195f2018-09-11 13:26:38 -0700129 * Returns the match field model associated with the given ID, if present.
130 * If not present, it means that this table does not support such a match
131 * field.
Carmelo Cascone87892e22017-11-13 16:01:29 -0800132 *
133 * @param matchFieldId match field ID
134 * @return optional match field model
135 */
136 Optional<PiMatchFieldModel> matchField(PiMatchFieldId matchFieldId);
Carmelo Cascone00a59962017-06-16 17:51:49 +0900137
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400138}