Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [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 org.onosproject.net.pi.runtime.PiActionId; |
| 20 | import org.onosproject.net.pi.runtime.PiActionParamId; |
| 21 | import org.onosproject.net.pi.runtime.PiActionProfileId; |
| 22 | import org.onosproject.net.pi.runtime.PiCounterId; |
| 23 | import org.onosproject.net.pi.runtime.PiCounterType; |
| 24 | import org.onosproject.net.pi.runtime.PiHeaderFieldId; |
| 25 | import org.onosproject.net.pi.runtime.PiPacketMetadataId; |
| 26 | import org.onosproject.net.pi.runtime.PiTableId; |
| 27 | |
| 28 | /** |
| 29 | * Constants for the basic.p4 program. |
| 30 | */ |
| 31 | public final class BasicConstants { |
| 32 | |
| 33 | // TODO: constants could be auto-generated starting from the P4info. |
| 34 | |
| 35 | // Header field IDs |
| 36 | public static final String ETHERNET = "ethernet"; |
| 37 | public static final String LOCAL_METADATA = "local_metadata"; |
| 38 | public static final String STANDARD_METADATA = "standard_metadata"; |
| 39 | public static final PiHeaderFieldId HDR_IN_PORT_ID = PiHeaderFieldId.of(STANDARD_METADATA, "ingress_port"); |
| 40 | public static final PiHeaderFieldId HDR_ETH_DST_ID = PiHeaderFieldId.of(ETHERNET, "dst_addr"); |
| 41 | public static final PiHeaderFieldId HDR_ETH_SRC_ID = PiHeaderFieldId.of(ETHERNET, "src_addr"); |
| 42 | public static final PiHeaderFieldId HDR_ETH_TYPE_ID = PiHeaderFieldId.of(ETHERNET, "ether_type"); |
| 43 | public static final PiHeaderFieldId HDR_NEXT_HOP_ID = PiHeaderFieldId.of(LOCAL_METADATA, "next_hop_id"); |
| 44 | public static final PiHeaderFieldId HDR_SELECTOR_ID = PiHeaderFieldId.of(LOCAL_METADATA, "selector"); |
| 45 | // Table IDs |
| 46 | public static final PiTableId TBL_TABLE0_ID = PiTableId.of("table0_control.table0"); |
| 47 | public static final PiTableId TBL_WCMP_TABLE_ID = PiTableId.of("wcmp_control.wcmp_table"); |
| 48 | // Counter IDs |
| 49 | public static final PiCounterId CNT_TABLE0_ID = PiCounterId.of("table0_control.table0_counter", |
| 50 | PiCounterType.DIRECT); |
| 51 | public static final PiCounterId CNT_WCMP_TABLE_ID = PiCounterId.of("wcmp_control.wcmp_table_counter", |
| 52 | PiCounterType.DIRECT); |
| 53 | // Action IDs |
| 54 | public static final PiActionId ACT_NOACTION_ID = PiActionId.of("NoAction"); |
| 55 | public static final PiActionId ACT_DROP_ID = PiActionId.of("_drop"); |
| 56 | public static final PiActionId ACT_SET_EGRESS_PORT_ID = PiActionId.of("set_egress_port"); |
| 57 | public static final PiActionId ACT_SET_NEXT_HOP_ID = PiActionId.of("table0_control.set_next_hop_id"); |
| 58 | public static final PiActionId ACT_SEND_TO_CPU_ID = PiActionId.of("send_to_cpu"); |
| 59 | // Action Param IDs |
| 60 | public static final PiActionParamId ACT_PRM_PORT_ID = PiActionParamId.of("port"); |
| 61 | public static final PiActionParamId ACT_PRM_NEXT_HOP_ID = PiActionParamId.of("next_hop_id"); |
| 62 | // Action Profile IDs |
| 63 | public static final PiActionProfileId ACT_PRF_WCMP_SELECTOR_ID = PiActionProfileId.of("wcmp_selector"); |
| 64 | // Packet Metadata IDs |
| 65 | public static final PiPacketMetadataId PKT_META_EGRESS_PORT_ID = PiPacketMetadataId.of("egress_port"); |
| 66 | public static final PiPacketMetadataId PKT_META_INGRESS_PORT_ID = PiPacketMetadataId.of("ingress_port"); |
| 67 | // Bitwidths |
| 68 | public static final int PORT_BITWIDTH = 9; |
| 69 | |
| 70 | private BasicConstants() { |
| 71 | // Hides constructor. |
| 72 | } |
| 73 | } |