Jonghwan Hyun | b935882 | 2017-12-06 17:55:27 -0800 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.pipelines.basic; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableBiMap; |
| 20 | import org.onosproject.net.pi.model.PiCounterId; |
| 21 | import org.onosproject.net.pi.model.PiTableId; |
| 22 | |
| 23 | import java.util.Optional; |
| 24 | |
| 25 | import static org.onosproject.pipelines.basic.BasicConstants.CNT_TABLE0_ID; |
| 26 | import static org.onosproject.pipelines.basic.BasicConstants.TBL_TABLE0_ID; |
| 27 | import static org.onosproject.pipelines.basic.IntConstants.*; |
| 28 | |
| 29 | /** |
| 30 | * Interpreter implementation for INT pipeline. |
| 31 | */ |
| 32 | public 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 | } |