Wailok Shum | fb7e787 | 2021-06-18 17:30:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-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.fabric.impl.behaviour; |
| 18 | |
pierventre | 4d29d3c | 2021-08-27 17:20:00 +0200 | [diff] [blame^] | 19 | import com.google.common.collect.ImmutableMap; |
| 20 | |
| 21 | import java.util.Map; |
| 22 | |
Wailok Shum | fb7e787 | 2021-06-18 17:30:08 +0800 | [diff] [blame] | 23 | /** |
| 24 | * Constant values. |
| 25 | */ |
| 26 | public final class Constants { |
| 27 | |
| 28 | // Used with is_infra_port metadata |
| 29 | public static final byte[] ONE = new byte[]{1}; |
| 30 | public static final byte[] ZERO = new byte[]{0}; |
| 31 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame] | 32 | public static final byte FALSE = (byte) 0x00; |
| 33 | public static final byte TRUE = (byte) 0x01; |
| 34 | |
Wailok Shum | fb7e787 | 2021-06-18 17:30:08 +0800 | [diff] [blame] | 35 | public static final long PORT_TYPE_MASK = 0x3; |
| 36 | public static final byte PORT_TYPE_EDGE = 0x1; |
| 37 | public static final byte PORT_TYPE_INFRA = 0x2; |
| 38 | public static final byte PORT_TYPE_INTERNAL = 0x3; |
| 39 | |
| 40 | // Forwarding types from P4 program (not exposed in P4Info). |
| 41 | public static final byte FWD_MPLS = 1; |
| 42 | public static final byte FWD_IPV4_ROUTING = 2; |
| 43 | public static final byte FWD_IPV6_ROUTING = 4; |
| 44 | |
| 45 | public static final short ETH_TYPE_EXACT_MASK = (short) 0xFFFF; |
| 46 | |
| 47 | public static final int DEFAULT_VLAN = 4094; |
| 48 | public static final int DEFAULT_PW_TRANSPORT_VLAN = 4090; |
| 49 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame] | 50 | // Default Slice and Traffic Class IDs |
| 51 | public static final int DEFAULT_SLICE_ID = 0; |
| 52 | public static final int DEFAULT_TC = 0; |
| 53 | public static final byte DEFAULT_QFI = (byte) 0x00; |
| 54 | |
pierventre | 4d29d3c | 2021-08-27 17:20:00 +0200 | [diff] [blame^] | 55 | ////////////////////////////////////////////////////////////////////////////// |
| 56 | // 64 .... 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 // |
| 57 | // X X X X X X X X X X X X X X X X X X X X X 1 1 1 1 1 // |
| 58 | ////////////////////////////////////////////////////////////////////////////// |
| 59 | // Metadata instruction is used as 8 byte sequence to carry up to 64 metadata |
| 60 | |
| 61 | // FIXME We are assuming SR as the only app programming this meta. |
| 62 | // SDFAB-530 to get rid of this limitation |
| 63 | |
| 64 | /** |
| 65 | * SR is setting this metadata when a double tagged filtering objective is removed |
| 66 | * and no other hosts is sharing the same input port. Thus, termination mac entries |
| 67 | * can be removed together with the vlan table entries. |
| 68 | * |
| 69 | * See org.onosproject.segmentrouting.RoutingRulePopulator#buildDoubleTaggedFilteringObj() |
| 70 | * See org.onosproject.segmentrouting.RoutingRulePopulator#processDoubleTaggedFilter() |
| 71 | */ |
| 72 | public static final long CLEANUP_DOUBLE_TAGGED_HOST_ENTRIES = 1; |
| 73 | |
| 74 | /** |
| 75 | * SR is setting this metadata when an interface config update has been performed |
| 76 | * and thus termination mac entries should not be removed. |
| 77 | * |
| 78 | * See org.onosproject.segmentrouting.RoutingRulePopulator#processSinglePortFiltersInternal |
| 79 | */ |
| 80 | public static final long INTERFACE_CONFIG_UPDATE = 1L << 1; |
| 81 | |
| 82 | /** |
| 83 | * SR is setting this metadata to signal the driver when the config is for the pair port, |
| 84 | * i.e. ports connecting two leaves. |
| 85 | * |
| 86 | * See org.onosproject.segmentrouting.RoutingRulePopulator#portType |
| 87 | */ |
| 88 | public static final long PAIR_PORT = 1L << 2; |
| 89 | |
| 90 | /** |
| 91 | * SR is setting this metadata to signal the driver when the config is for an edge port, |
| 92 | * i.e. ports facing an host. |
| 93 | * |
| 94 | * See org.onosproject.segmentrouting.policy.impl.PolicyManager#trafficMatchFwdObjective |
| 95 | * See org.onosproject.segmentrouting.RoutingRulePopulator#portType |
| 96 | */ |
| 97 | public static final long EDGE_PORT = 1L << 3; |
| 98 | |
| 99 | /** |
| 100 | * SR is setting this metadata to signal the driver when the config is for an infra port, |
| 101 | * i.e. ports connecting a leaf with a spine. |
| 102 | */ |
| 103 | public static final long INFRA_PORT = 1L << 4; |
| 104 | |
| 105 | public static final long METADATA_MASK = 0x1FL; |
| 106 | |
| 107 | public static final Map<Long, Byte> METADATA_TO_PORT_TYPE = ImmutableMap.<Long, Byte>builder() |
| 108 | .put(PAIR_PORT, PORT_TYPE_INFRA) |
| 109 | .put(EDGE_PORT, PORT_TYPE_EDGE) |
| 110 | .put(INFRA_PORT, PORT_TYPE_INFRA) |
| 111 | .build(); |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame] | 112 | |
Wailok Shum | fb7e787 | 2021-06-18 17:30:08 +0800 | [diff] [blame] | 113 | // hide default constructor |
| 114 | private Constants() { |
| 115 | } |
| 116 | } |