blob: ea3c2a7bf04c604ddd93e133ff72a1a7409d4f4c [file] [log] [blame]
Jonghwan Hyunb9358822017-12-06 17:55:27 -08001/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.pipelines.basic;
18
19import com.google.common.collect.ImmutableBiMap;
20import org.onosproject.net.pi.model.PiCounterId;
21import org.onosproject.net.pi.model.PiTableId;
22
23import java.util.Optional;
24
25import static org.onosproject.pipelines.basic.BasicConstants.CNT_TABLE0_ID;
26import static org.onosproject.pipelines.basic.BasicConstants.TBL_TABLE0_ID;
27import static org.onosproject.pipelines.basic.IntConstants.*;
28
29/**
30 * Interpreter implementation for INT pipeline.
31 */
32public class IntInterpreterImpl extends BasicInterpreterImpl {
33
34 private static final ImmutableBiMap<PiTableId, PiCounterId> TABLE_COUNTER_MAP =
35 new ImmutableBiMap.Builder<PiTableId, PiCounterId>()
36 .put(TBL_TABLE0_ID, CNT_TABLE0_ID)
37 .put(TBL_SET_SOURCE_SINK_ID, CNT_SET_SOURCE_SINK_ID)
38 .put(TBL_INT_SOURCE_ID, CNT_INT_SOURCE_ID)
39 .put(TBL_INT_INSERT_ID, CNT_INT_INSERT_ID)
40 .put(TBL_INT_INST_0003_ID, CNT_INT_INST_0003_ID)
41 .put(TBL_INT_INST_0407_ID, CNT_INT_INST_0407_ID)
42 .build();
43
44 @Override
45 public Optional<PiCounterId> mapTableCounter(PiTableId piTableId) {
46 return Optional.ofNullable(TABLE_COUNTER_MAP.get(piTableId));
47 }
48}