Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -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 | |
Carmelo Cascone | 356ab8b | 2019-09-25 01:02:53 -0700 | [diff] [blame] | 17 | package org.onosproject.pipelines.fabric.impl.behaviour; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 18 | |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableList; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableMap; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableSet; |
| 22 | import org.onlab.packet.DeserializationException; |
| 23 | import org.onlab.packet.Ethernet; |
| 24 | import org.onlab.util.ImmutableByteSequence; |
| 25 | import org.onosproject.net.ConnectPoint; |
| 26 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.Port; |
| 28 | import org.onosproject.net.PortNumber; |
| 29 | import org.onosproject.net.device.DeviceService; |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 30 | import org.onosproject.net.driver.DriverHandler; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 31 | import org.onosproject.net.flow.TrafficTreatment; |
| 32 | import org.onosproject.net.flow.criteria.Criterion; |
| 33 | import org.onosproject.net.flow.instructions.Instructions; |
| 34 | import org.onosproject.net.packet.DefaultInboundPacket; |
| 35 | import org.onosproject.net.packet.InboundPacket; |
| 36 | import org.onosproject.net.packet.OutboundPacket; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 37 | import org.onosproject.net.pi.model.PiMatchFieldId; |
| 38 | import org.onosproject.net.pi.model.PiPipelineInterpreter; |
| 39 | import org.onosproject.net.pi.model.PiTableId; |
| 40 | import org.onosproject.net.pi.runtime.PiAction; |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 41 | import org.onosproject.net.pi.runtime.PiPacketMetadata; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 42 | import org.onosproject.net.pi.runtime.PiPacketOperation; |
Carmelo Cascone | 2102bfb | 2020-12-04 16:54:24 -0800 | [diff] [blame] | 43 | import org.onosproject.pipelines.fabric.FabricConstants; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 44 | |
| 45 | import java.nio.ByteBuffer; |
| 46 | import java.util.Collection; |
| 47 | import java.util.List; |
| 48 | import java.util.Optional; |
| 49 | import java.util.Set; |
| 50 | |
| 51 | import static java.lang.String.format; |
| 52 | import static java.util.stream.Collectors.toList; |
| 53 | import static org.onlab.util.ImmutableByteSequence.copyFrom; |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 54 | import static org.onosproject.net.PortNumber.CONTROLLER; |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 55 | import static org.onosproject.net.PortNumber.FLOOD; |
| 56 | import static org.onosproject.net.flow.instructions.Instruction.Type.OUTPUT; |
| 57 | import static org.onosproject.net.pi.model.PiPacketOperationType.PACKET_OUT; |
| 58 | |
| 59 | /** |
| 60 | * Interpreter for fabric pipeline. |
| 61 | */ |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 62 | public class FabricInterpreter extends AbstractFabricHandlerBehavior |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 63 | implements PiPipelineInterpreter { |
Carmelo Cascone | 1e8843f | 2018-07-19 19:01:12 +0200 | [diff] [blame] | 64 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 65 | private static final int PORT_BITWIDTH = 9; |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 66 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 67 | // Group tables by control block. |
| 68 | private static final Set<PiTableId> FILTERING_CTRL_TBLS = ImmutableSet.of( |
| 69 | FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, |
| 70 | FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER); |
| 71 | private static final Set<PiTableId> FORWARDING_CTRL_TBLS = ImmutableSet.of( |
| 72 | FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS, |
| 73 | FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, |
| 74 | FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V6, |
| 75 | FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING); |
| 76 | private static final Set<PiTableId> ACL_CTRL_TBLS = ImmutableSet.of( |
| 77 | FabricConstants.FABRIC_INGRESS_ACL_ACL); |
| 78 | private static final Set<PiTableId> NEXT_CTRL_TBLS = ImmutableSet.of( |
| 79 | FabricConstants.FABRIC_INGRESS_NEXT_NEXT_VLAN, |
| 80 | FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE, |
Carmelo Cascone | 45cc086 | 2018-11-26 11:50:41 -0800 | [diff] [blame] | 81 | FabricConstants.FABRIC_INGRESS_NEXT_HASHED, |
| 82 | FabricConstants.FABRIC_INGRESS_NEXT_XCONNECT); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 83 | private static final Set<PiTableId> E_NEXT_CTRL_TBLS = ImmutableSet.of( |
| 84 | FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 85 | |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 86 | private static final ImmutableMap<Criterion.Type, PiMatchFieldId> CRITERION_MAP = |
| 87 | ImmutableMap.<Criterion.Type, PiMatchFieldId>builder() |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 88 | .put(Criterion.Type.IN_PORT, FabricConstants.HDR_IG_PORT) |
| 89 | .put(Criterion.Type.ETH_DST, FabricConstants.HDR_ETH_DST) |
| 90 | .put(Criterion.Type.ETH_SRC, FabricConstants.HDR_ETH_SRC) |
| 91 | .put(Criterion.Type.ETH_DST_MASKED, FabricConstants.HDR_ETH_DST) |
| 92 | .put(Criterion.Type.ETH_SRC_MASKED, FabricConstants.HDR_ETH_SRC) |
| 93 | .put(Criterion.Type.ETH_TYPE, FabricConstants.HDR_ETH_TYPE) |
Yi Tseng | 43ee7e8 | 2018-04-12 16:37:34 +0800 | [diff] [blame] | 94 | .put(Criterion.Type.MPLS_LABEL, FabricConstants.HDR_MPLS_LABEL) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 95 | .put(Criterion.Type.VLAN_VID, FabricConstants.HDR_VLAN_ID) |
Daniele Moro | 7c3a002 | 2019-07-12 13:38:34 -0700 | [diff] [blame] | 96 | .put(Criterion.Type.INNER_VLAN_VID, FabricConstants.HDR_INNER_VLAN_ID) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 97 | .put(Criterion.Type.IPV4_DST, FabricConstants.HDR_IPV4_DST) |
| 98 | .put(Criterion.Type.IPV4_SRC, FabricConstants.HDR_IPV4_SRC) |
| 99 | .put(Criterion.Type.IPV6_DST, FabricConstants.HDR_IPV6_DST) |
| 100 | .put(Criterion.Type.IP_PROTO, FabricConstants.HDR_IP_PROTO) |
| 101 | .put(Criterion.Type.ICMPV6_TYPE, FabricConstants.HDR_ICMP_TYPE) |
| 102 | .put(Criterion.Type.ICMPV6_CODE, FabricConstants.HDR_ICMP_CODE) |
Daniele Moro | 59020df | 2019-08-05 15:37:45 -0700 | [diff] [blame] | 103 | .put(Criterion.Type.UDP_DST, FabricConstants.HDR_L4_DPORT) |
| 104 | .put(Criterion.Type.UDP_SRC, FabricConstants.HDR_L4_SPORT) |
| 105 | .put(Criterion.Type.UDP_DST_MASKED, FabricConstants.HDR_L4_DPORT) |
| 106 | .put(Criterion.Type.UDP_SRC_MASKED, FabricConstants.HDR_L4_SPORT) |
| 107 | .put(Criterion.Type.TCP_DST, FabricConstants.HDR_L4_DPORT) |
| 108 | .put(Criterion.Type.TCP_SRC, FabricConstants.HDR_L4_SPORT) |
| 109 | .put(Criterion.Type.TCP_DST_MASKED, FabricConstants.HDR_L4_DPORT) |
| 110 | .put(Criterion.Type.TCP_SRC_MASKED, FabricConstants.HDR_L4_SPORT) |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 111 | .build(); |
| 112 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 113 | private static final PiAction NOP = PiAction.builder() |
| 114 | .withId(FabricConstants.NOP).build(); |
Carmelo Cascone | 50d195f | 2018-09-11 13:26:38 -0700 | [diff] [blame] | 115 | |
| 116 | private static final ImmutableMap<PiTableId, PiAction> DEFAULT_ACTIONS = |
| 117 | ImmutableMap.<PiTableId, PiAction>builder() |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 118 | .put(FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, NOP) |
Carmelo Cascone | 50d195f | 2018-09-11 13:26:38 -0700 | [diff] [blame] | 119 | .build(); |
| 120 | |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 121 | private FabricTreatmentInterpreter treatmentInterpreter; |
| 122 | |
| 123 | /** |
| 124 | * Creates a new instance of this behavior with the given capabilities. |
| 125 | * |
| 126 | * @param capabilities capabilities |
| 127 | */ |
| 128 | public FabricInterpreter(FabricCapabilities capabilities) { |
| 129 | super(capabilities); |
| 130 | instantiateTreatmentInterpreter(); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Create a new instance of this behaviour. Used by the abstract projectable |
| 135 | * model (i.e., {@link org.onosproject.net.Device#as(Class)}. |
| 136 | */ |
| 137 | public FabricInterpreter() { |
| 138 | super(); |
| 139 | } |
| 140 | |
| 141 | private void instantiateTreatmentInterpreter() { |
| 142 | this.treatmentInterpreter = new FabricTreatmentInterpreter(this.capabilities); |
| 143 | } |
| 144 | |
| 145 | @Override |
| 146 | public void setHandler(DriverHandler handler) { |
| 147 | super.setHandler(handler); |
| 148 | instantiateTreatmentInterpreter(); |
| 149 | } |
| 150 | |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 151 | @Override |
| 152 | public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) { |
| 153 | return Optional.ofNullable(CRITERION_MAP.get(type)); |
| 154 | } |
| 155 | |
| 156 | @Override |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 157 | public Optional<PiTableId> mapFlowRuleTableId(int flowRuleTableId) { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 158 | // The only use case for Index ID->PiTableId is when using the single |
| 159 | // table pipeliner. fabric.p4 is never used with such pipeliner. |
| 160 | return Optional.empty(); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | @Override |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 164 | public PiAction mapTreatment(TrafficTreatment treatment, PiTableId piTableId) |
| 165 | throws PiInterpreterException { |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 166 | if (FILTERING_CTRL_TBLS.contains(piTableId)) { |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 167 | return treatmentInterpreter.mapFilteringTreatment(treatment, piTableId); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 168 | } else if (FORWARDING_CTRL_TBLS.contains(piTableId)) { |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 169 | return treatmentInterpreter.mapForwardingTreatment(treatment, piTableId); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 170 | } else if (ACL_CTRL_TBLS.contains(piTableId)) { |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 171 | return treatmentInterpreter.mapAclTreatment(treatment, piTableId); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 172 | } else if (NEXT_CTRL_TBLS.contains(piTableId)) { |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 173 | return treatmentInterpreter.mapNextTreatment(treatment, piTableId); |
Yi Tseng | 20f9e7b | 2018-05-24 23:27:39 +0800 | [diff] [blame] | 174 | } else if (E_NEXT_CTRL_TBLS.contains(piTableId)) { |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 175 | return treatmentInterpreter.mapEgressNextTreatment(treatment, piTableId); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 176 | } else { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 177 | throw new PiInterpreterException(format( |
| 178 | "Treatment mapping not supported for table '%s'", piTableId)); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 182 | private PiPacketOperation createPiPacketOperation( |
| 183 | DeviceId deviceId, ByteBuffer data, long portNumber) |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 184 | throws PiInterpreterException { |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 185 | PiPacketMetadata metadata = createPacketMetadata(portNumber); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 186 | return PiPacketOperation.builder() |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 187 | .withType(PACKET_OUT) |
| 188 | .withData(copyFrom(data)) |
| 189 | .withMetadatas(ImmutableList.of(metadata)) |
| 190 | .build(); |
| 191 | } |
| 192 | |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 193 | private PiPacketMetadata createPacketMetadata(long portNumber) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 194 | throws PiInterpreterException { |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 195 | try { |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 196 | return PiPacketMetadata.builder() |
Yi Tseng | 43ee7e8 | 2018-04-12 16:37:34 +0800 | [diff] [blame] | 197 | .withId(FabricConstants.EGRESS_PORT) |
Carmelo Cascone | 1e8843f | 2018-07-19 19:01:12 +0200 | [diff] [blame] | 198 | .withValue(copyFrom(portNumber).fit(PORT_BITWIDTH)) |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 199 | .build(); |
| 200 | } catch (ImmutableByteSequence.ByteSequenceTrimException e) { |
| 201 | throw new PiInterpreterException(format( |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 202 | "Port number '%d' too big, %s", portNumber, e.getMessage())); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet) |
| 208 | throws PiInterpreterException { |
| 209 | DeviceId deviceId = packet.sendThrough(); |
| 210 | TrafficTreatment treatment = packet.treatment(); |
| 211 | |
| 212 | // fabric.p4 supports only OUTPUT instructions. |
| 213 | List<Instructions.OutputInstruction> outInstructions = treatment |
| 214 | .allInstructions() |
| 215 | .stream() |
| 216 | .filter(i -> i.type().equals(OUTPUT)) |
| 217 | .map(i -> (Instructions.OutputInstruction) i) |
| 218 | .collect(toList()); |
| 219 | |
| 220 | if (treatment.allInstructions().size() != outInstructions.size()) { |
| 221 | // There are other instructions that are not of type OUTPUT. |
| 222 | throw new PiInterpreterException("Treatment not supported: " + treatment); |
| 223 | } |
| 224 | |
| 225 | ImmutableList.Builder<PiPacketOperation> builder = ImmutableList.builder(); |
| 226 | for (Instructions.OutputInstruction outInst : outInstructions) { |
| 227 | if (outInst.port().isLogical() && !outInst.port().equals(FLOOD)) { |
| 228 | throw new PiInterpreterException(format( |
| 229 | "Output on logical port '%s' not supported", outInst.port())); |
| 230 | } else if (outInst.port().equals(FLOOD)) { |
| 231 | // Since fabric.p4 does not support flooding, we create a packet |
| 232 | // operation for each switch port. |
| 233 | final DeviceService deviceService = handler().get(DeviceService.class); |
| 234 | for (Port port : deviceService.getPorts(packet.sendThrough())) { |
| 235 | builder.add(createPiPacketOperation(deviceId, packet.data(), port.number().toLong())); |
| 236 | } |
| 237 | } else { |
| 238 | builder.add(createPiPacketOperation(deviceId, packet.data(), outInst.port().toLong())); |
| 239 | } |
| 240 | } |
| 241 | return builder.build(); |
| 242 | } |
| 243 | |
| 244 | @Override |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 245 | public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId) throws PiInterpreterException { |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 246 | // Assuming that the packet is ethernet, which is fine since fabric.p4 |
| 247 | // can deparse only ethernet packets. |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 248 | Ethernet ethPkt; |
| 249 | try { |
| 250 | ethPkt = Ethernet.deserializer().deserialize(packetIn.data().asArray(), 0, |
| 251 | packetIn.data().size()); |
| 252 | } catch (DeserializationException dex) { |
| 253 | throw new PiInterpreterException(dex.getMessage()); |
| 254 | } |
| 255 | |
| 256 | // Returns the ingress port packet metadata. |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 257 | Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas() |
Yi Tseng | 43ee7e8 | 2018-04-12 16:37:34 +0800 | [diff] [blame] | 258 | .stream().filter(m -> m.id().equals(FabricConstants.INGRESS_PORT)) |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 259 | .findFirst(); |
| 260 | |
| 261 | if (packetMetadata.isPresent()) { |
| 262 | ImmutableByteSequence portByteSequence = packetMetadata.get().value(); |
| 263 | short s = portByteSequence.asReadOnlyBuffer().getShort(); |
| 264 | ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s)); |
| 265 | ByteBuffer rawData = ByteBuffer.wrap(packetIn.data().asArray()); |
| 266 | return new DefaultInboundPacket(receivedFrom, ethPkt, rawData); |
| 267 | } else { |
| 268 | throw new PiInterpreterException(format( |
| 269 | "Missing metadata '%s' in packet-in received from '%s': %s", |
Yi Tseng | 43ee7e8 | 2018-04-12 16:37:34 +0800 | [diff] [blame] | 270 | FabricConstants.INGRESS_PORT, deviceId, packetIn)); |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 271 | } |
| 272 | } |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 273 | |
| 274 | @Override |
Carmelo Cascone | 50d195f | 2018-09-11 13:26:38 -0700 | [diff] [blame] | 275 | public Optional<PiAction> getOriginalDefaultAction(PiTableId tableId) { |
| 276 | return Optional.ofNullable(DEFAULT_ACTIONS.get(tableId)); |
| 277 | } |
| 278 | |
| 279 | @Override |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 280 | public Optional<Integer> mapLogicalPortNumber(PortNumber port) { |
| 281 | if (!port.equals(CONTROLLER)) { |
| 282 | return Optional.empty(); |
| 283 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 284 | return capabilities.cpuPort(); |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 285 | } |
Yi Tseng | fa4a1c7 | 2017-11-03 10:22:38 -0700 | [diff] [blame] | 286 | } |