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