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 | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 34 | public static final String DOT = "."; |
| 35 | private static final String INGRESS = "ingress"; |
| 36 | private static final String EGRESS = "egress"; |
| 37 | private static final String TABLE0_CTRL = INGRESS + DOT + "table0_control"; |
| 38 | private static final String WCMP_CTRL = INGRESS + DOT + "wcmp_control"; |
| 39 | private static final String PORT_COUNT_INGRESS_CTRL = INGRESS + DOT + "port_counters_ingress"; |
| 40 | private static final String PORT_COUNT_EGRESS_CTRL = EGRESS + DOT + "port_counters_egress"; |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 41 | public static final String HDR = "hdr"; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 42 | public static final String ETHERNET = "ethernet"; |
Carmelo Cascone | 5167f32 | 2017-11-21 21:58:50 -0800 | [diff] [blame] | 43 | public static final String IPV4 = "ipv4"; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 44 | public static final String LOCAL_METADATA = "local_metadata"; |
| 45 | public static final String STANDARD_METADATA = "standard_metadata"; |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 46 | |
| 47 | // Header field IDs |
| 48 | |
| 49 | public static final PiMatchFieldId HDR_IN_PORT_ID = |
| 50 | PiMatchFieldId.of(STANDARD_METADATA + DOT + "ingress_port"); |
| 51 | public static final PiMatchFieldId HDR_ETH_DST_ID = |
| 52 | PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "dst_addr"); |
| 53 | public static final PiMatchFieldId HDR_ETH_SRC_ID = |
| 54 | PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "src_addr"); |
| 55 | public static final PiMatchFieldId HDR_ETH_TYPE_ID = |
| 56 | PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + "ether_type"); |
| 57 | public static final PiMatchFieldId HDR_IPV4_DST_ID = |
| 58 | PiMatchFieldId.of(HDR + DOT + IPV4 + DOT + "dst_addr"); |
| 59 | public static final PiMatchFieldId HDR_IPV4_SRC_ID = |
| 60 | PiMatchFieldId.of(HDR + DOT + IPV4 + DOT + "src_addr"); |
| 61 | public static final PiMatchFieldId HDR_NEXT_HOP_ID = |
| 62 | PiMatchFieldId.of(LOCAL_METADATA + DOT + "next_hop_id"); |
| 63 | public static final PiMatchFieldId HDR_SELECTOR_ID = |
| 64 | PiMatchFieldId.of(LOCAL_METADATA + DOT + "selector"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 65 | // Table IDs |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 66 | public static final PiTableId TBL_TABLE0_ID = |
| 67 | PiTableId.of(TABLE0_CTRL + DOT + "table0"); |
| 68 | public static final PiTableId TBL_WCMP_TABLE_ID = |
| 69 | PiTableId.of(WCMP_CTRL + DOT + "wcmp_table"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 70 | // Counter IDs |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 71 | public static final PiCounterId CNT_EGRESS_PORT_COUNTER_ID = |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 72 | PiCounterId.of(PORT_COUNT_EGRESS_CTRL + DOT + "egress_port_counter"); |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 73 | public static final PiCounterId CNT_INGRESS_PORT_COUNTER_ID = |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 74 | PiCounterId.of(PORT_COUNT_INGRESS_CTRL + DOT + "ingress_port_counter"); |
| 75 | public static final PiCounterId CNT_TABLE0_ID = |
| 76 | PiCounterId.of(TABLE0_CTRL + DOT + "table0_counter"); |
| 77 | public static final PiCounterId CNT_WCMP_TABLE_ID = |
| 78 | PiCounterId.of(WCMP_CTRL + DOT + "wcmp_table_counter"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 79 | // Action IDs |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 80 | public static final PiActionId ACT_NOACTION_ID = |
| 81 | PiActionId.of("NoAction"); |
| 82 | public static final PiActionId ACT_DROP_ID = |
| 83 | PiActionId.of("_drop"); |
| 84 | public static final PiActionId ACT_SET_EGRESS_PORT_ID = |
| 85 | PiActionId.of("set_egress_port"); |
| 86 | public static final PiActionId ACT_SET_NEXT_HOP_ID = |
| 87 | PiActionId.of(TABLE0_CTRL + DOT + "set_next_hop_id"); |
| 88 | public static final PiActionId ACT_SEND_TO_CPU_ID = |
| 89 | PiActionId.of("send_to_cpu"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 90 | // Action Param IDs |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 91 | public static final PiActionParamId ACT_PRM_PORT_ID = |
| 92 | PiActionParamId.of("port"); |
| 93 | public static final PiActionParamId ACT_PRM_NEXT_HOP_ID = |
| 94 | PiActionParamId.of("next_hop_id"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 95 | // Action Profile IDs |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 96 | public static final PiActionProfileId ACT_PRF_WCMP_SELECTOR_ID = |
| 97 | PiActionProfileId.of(WCMP_CTRL + DOT + "wcmp_selector"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 98 | // Packet Metadata IDs |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame^] | 99 | public static final PiControlMetadataId PKT_META_EGRESS_PORT_ID = |
| 100 | PiControlMetadataId.of("egress_port"); |
| 101 | public static final PiControlMetadataId PKT_META_INGRESS_PORT_ID = |
| 102 | PiControlMetadataId.of("ingress_port"); |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 103 | // Bitwidths |
| 104 | public static final int PORT_BITWIDTH = 9; |
| 105 | |
| 106 | private BasicConstants() { |
| 107 | // Hides constructor. |
| 108 | } |
| 109 | } |