Saurav Das | 86d13e8 | 2017-04-28 17:03:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.driver.pipeline; |
| 18 | |
| 19 | import static org.slf4j.LoggerFactory.getLogger; |
| 20 | |
| 21 | import java.util.Collection; |
| 22 | import org.onlab.packet.Ethernet; |
| 23 | import org.onosproject.net.flow.FlowRule; |
| 24 | import org.onosproject.net.flow.TrafficSelector; |
| 25 | import org.onosproject.net.flow.criteria.Criterion; |
| 26 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 27 | import org.onosproject.net.flow.criteria.IPCriterion; |
| 28 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 29 | import org.onosproject.net.flowobjective.ObjectiveError; |
| 30 | import org.slf4j.Logger; |
| 31 | |
| 32 | import com.google.common.collect.ImmutableSet; |
| 33 | |
| 34 | /** |
| 35 | * Pipeliner for Broadcom OF-DPA 3.0 TTP, specifically for Qumran based switches. |
| 36 | */ |
| 37 | public class Ofdpa3QmxPipeline extends Ofdpa3Pipeline { |
| 38 | private final Logger log = getLogger(getClass()); |
| 39 | |
| 40 | @Override |
| 41 | protected void initDriverId() { |
| 42 | driverId = coreService.registerApplication( |
| 43 | "org.onosproject.driver.Ofdpa3QmxPipeline"); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | protected boolean matchInPortTmacTable() { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | protected Collection<FlowRule> processEthTypeSpecific(ForwardingObjective fwd) { |
| 53 | TrafficSelector selector = fwd.selector(); |
| 54 | EthTypeCriterion ethType = |
| 55 | (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); |
| 56 | //XXX remove when support is added to Qumran based OF-DPA |
| 57 | if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4 || |
| 58 | ethType.ethType().toShort() == Ethernet.TYPE_IPV6) { |
| 59 | log.warn("Routing table is currently unsupported in dev:{}", deviceId); |
| 60 | return ImmutableSet.of(); |
| 61 | } |
| 62 | |
| 63 | return super.processEthTypeSpecific(fwd); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) { |
| 68 | EthTypeCriterion ethType = |
| 69 | (EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE); |
| 70 | if (ethType == null) { |
| 71 | log.error("Versatile forwarding objective:{} must include ethType", |
| 72 | fwd.id()); |
| 73 | fail(fwd, ObjectiveError.BADPARAMS); |
| 74 | return ImmutableSet.of(); |
| 75 | } |
| 76 | //XXX remove when support is added to Qumran based OF-DPA |
| 77 | if (ethType.ethType().toShort() == Ethernet.TYPE_IPV6) { |
| 78 | log.warn("ACL table for IPv6 is currently unsupported in dev:{}", deviceId); |
| 79 | return ImmutableSet.of(); |
| 80 | } |
| 81 | |
| 82 | if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) { |
| 83 | for (Criterion c : fwd.selector().criteria()) { |
| 84 | if (c instanceof IPCriterion) { |
| 85 | if (((IPCriterion) c).type() == Criterion.Type.IPV4_DST) { |
| 86 | log.warn("ACL table for Dst IPv4 is currently " |
| 87 | + "unsupported in dev:{}", deviceId); |
| 88 | return ImmutableSet.of(); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | return super.processVersatile(fwd); |
| 95 | } |
| 96 | } |