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 | |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 19 | import org.onosproject.net.pi.model.PiActionId; |
| 20 | import org.onosproject.net.pi.model.PiActionParamId; |
| 21 | import org.onosproject.net.pi.model.PiActionProfileId; |
| 22 | import org.onosproject.net.pi.model.PiControlMetadataId; |
| 23 | import org.onosproject.net.pi.model.PiCounterId; |
| 24 | import org.onosproject.net.pi.model.PiMatchFieldId; |
| 25 | import org.onosproject.net.pi.model.PiTableId; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Constants for the basic.p4 program. |
| 29 | */ |
| 30 | public final class BasicConstants { |
| 31 | |
| 32 | // TODO: constants could be auto-generated starting from the P4info. |
| 33 | |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 34 | private static final String TABLE0_CONTROL = "table0_control"; |
| 35 | private static final String WCMP_CONTROL = "wcmp_control"; |
| 36 | |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 37 | // Header field IDs |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 38 | public static final String DOT = "."; |
| 39 | public static final String HDR = "hdr"; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 40 | public static final String ETHERNET = "ethernet"; |
Carmelo Cascone | 5167f32 | 2017-11-21 21:58:50 -0800 | [diff] [blame] | 41 | public static final String IPV4 = "ipv4"; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 42 | public static final String LOCAL_METADATA = "local_metadata"; |
| 43 | public static final String STANDARD_METADATA = "standard_metadata"; |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 44 | public static final PiMatchFieldId HDR_IN_PORT_ID = PiMatchFieldId.of(STANDARD_METADATA + DOT + "ingress_port"); |
| 45 | public static final PiMatchFieldId HDR_ETH_DST_ID = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "dst_addr"); |
| 46 | public static final PiMatchFieldId HDR_ETH_SRC_ID = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "src_addr"); |
| 47 | public static final PiMatchFieldId HDR_ETH_TYPE_ID = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "ether_type"); |
Carmelo Cascone | 5167f32 | 2017-11-21 21:58:50 -0800 | [diff] [blame] | 48 | public static final PiMatchFieldId HDR_IPV4_DST_ID = PiMatchFieldId.of(HDR + DOT + IPV4 + DOT + "dst_addr"); |
| 49 | public static final PiMatchFieldId HDR_IPV4_SRC_ID = PiMatchFieldId.of(HDR + DOT + IPV4 + DOT + "src_addr"); |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 50 | public static final PiMatchFieldId HDR_NEXT_HOP_ID = PiMatchFieldId.of(LOCAL_METADATA + DOT + "next_hop_id"); |
| 51 | public static final PiMatchFieldId HDR_SELECTOR_ID = PiMatchFieldId.of(LOCAL_METADATA + DOT + "selector"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 52 | // Table IDs |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 53 | public static final PiTableId TBL_TABLE0_ID = PiTableId.of(TABLE0_CONTROL + DOT + "table0"); |
| 54 | public static final PiTableId TBL_WCMP_TABLE_ID = PiTableId.of(WCMP_CONTROL + DOT + "wcmp_table"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 55 | // Counter IDs |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 56 | public static final PiCounterId CNT_EGRESS_PORT_COUNTER_ID = |
| 57 | PiCounterId.of("port_counters_egress.egress_port_counter"); |
| 58 | public static final PiCounterId CNT_INGRESS_PORT_COUNTER_ID = |
| 59 | PiCounterId.of("port_counters_ingress.ingress_port_counter"); |
| 60 | public static final PiCounterId CNT_TABLE0_ID = PiCounterId.of(TABLE0_CONTROL + DOT + "table0_counter"); |
| 61 | public static final PiCounterId CNT_WCMP_TABLE_ID = PiCounterId.of(WCMP_CONTROL + DOT + "wcmp_table_counter"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 62 | // Action IDs |
| 63 | public static final PiActionId ACT_NOACTION_ID = PiActionId.of("NoAction"); |
| 64 | public static final PiActionId ACT_DROP_ID = PiActionId.of("_drop"); |
| 65 | public static final PiActionId ACT_SET_EGRESS_PORT_ID = PiActionId.of("set_egress_port"); |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 66 | public static final PiActionId ACT_SET_NEXT_HOP_ID = PiActionId.of(TABLE0_CONTROL + DOT + "set_next_hop_id"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 67 | public static final PiActionId ACT_SEND_TO_CPU_ID = PiActionId.of("send_to_cpu"); |
| 68 | // Action Param IDs |
| 69 | public static final PiActionParamId ACT_PRM_PORT_ID = PiActionParamId.of("port"); |
| 70 | public static final PiActionParamId ACT_PRM_NEXT_HOP_ID = PiActionParamId.of("next_hop_id"); |
| 71 | // Action Profile IDs |
Carmelo Cascone | 5167f32 | 2017-11-21 21:58:50 -0800 | [diff] [blame] | 72 | public static final PiActionProfileId ACT_PRF_WCMP_SELECTOR_ID = PiActionProfileId.of("wcmp_control.wcmp_selector"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 73 | // Packet Metadata IDs |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 74 | public static final PiControlMetadataId PKT_META_EGRESS_PORT_ID = PiControlMetadataId.of("egress_port"); |
| 75 | public static final PiControlMetadataId PKT_META_INGRESS_PORT_ID = PiControlMetadataId.of("ingress_port"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 76 | // Bitwidths |
| 77 | public static final int PORT_BITWIDTH = 9; |
| 78 | |
| 79 | private BasicConstants() { |
| 80 | // Hides constructor. |
| 81 | } |
| 82 | } |