Alessio Giorgetti | c1518bb | 2017-11-17 17:01:26 +0100 | [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.drivers.hp; |
| 18 | |
| 19 | import org.onlab.packet.Ethernet; |
| 20 | import org.onosproject.net.PortNumber; |
| 21 | import org.onosproject.net.flow.FlowRule; |
| 22 | import org.onosproject.net.flow.criteria.Criterion; |
| 23 | import org.onosproject.net.flow.criteria.EthCriterion; |
| 24 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 25 | import org.onosproject.net.flow.criteria.IPCriterion; |
| 26 | import org.onosproject.net.flow.criteria.PortCriterion; |
| 27 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 28 | import org.onosproject.net.flow.instructions.Instruction; |
| 29 | import org.onosproject.net.flow.instructions.Instructions; |
| 30 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
| 31 | import org.onosproject.net.flow.instructions.L3ModificationInstruction; |
| 32 | import org.onosproject.net.flowobjective.FilteringObjective; |
| 33 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 34 | import org.slf4j.Logger; |
| 35 | |
| 36 | import static org.slf4j.LoggerFactory.getLogger; |
| 37 | |
| 38 | /** |
| 39 | * Driver for HP3500 hybrid switches employing V1 hardware module. |
| 40 | * |
| 41 | * Refer to the device manual to check unsupported features and features supported in hardware |
| 42 | * |
| 43 | */ |
| 44 | |
| 45 | public class HPPipelineV3500 extends AbstractHPPipeline { |
| 46 | |
| 47 | private Logger log = getLogger(getClass()); |
| 48 | |
| 49 | @Override |
| 50 | protected FlowRule.Builder setDefaultTableIdForFlowObjective(FlowRule.Builder ruleBuilder) { |
| 51 | log.debug("HP V3500 Driver - Setting default table id to software table {}", HP_SOFTWARE_TABLE); |
| 52 | |
| 53 | return ruleBuilder.forTable(HP_SOFTWARE_TABLE); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected void initUnSupportedFeatures() { |
| 58 | //Initialize unsupported criteria |
| 59 | unsupportedCriteria.add(Criterion.Type.METADATA); |
| 60 | unsupportedCriteria.add(Criterion.Type.IP_ECN); |
| 61 | unsupportedCriteria.add(Criterion.Type.SCTP_SRC); |
| 62 | unsupportedCriteria.add(Criterion.Type.SCTP_SRC_MASKED); |
| 63 | unsupportedCriteria.add(Criterion.Type.SCTP_DST); |
| 64 | unsupportedCriteria.add(Criterion.Type.SCTP_DST_MASKED); |
| 65 | unsupportedCriteria.add(Criterion.Type.IPV6_ND_SLL); |
| 66 | unsupportedCriteria.add(Criterion.Type.IPV6_ND_TLL); |
| 67 | unsupportedCriteria.add(Criterion.Type.MPLS_LABEL); |
| 68 | unsupportedCriteria.add(Criterion.Type.MPLS_TC); |
| 69 | unsupportedCriteria.add(Criterion.Type.MPLS_BOS); |
| 70 | unsupportedCriteria.add(Criterion.Type.PBB_ISID); |
| 71 | unsupportedCriteria.add(Criterion.Type.TUNNEL_ID); |
| 72 | unsupportedCriteria.add(Criterion.Type.IPV6_EXTHDR); |
| 73 | |
| 74 | //Initialize unsupported instructions |
| 75 | unsupportedInstructions.add(Instruction.Type.QUEUE); |
| 76 | unsupportedInstructions.add(Instruction.Type.METADATA); |
| 77 | unsupportedInstructions.add(Instruction.Type.L0MODIFICATION); |
| 78 | unsupportedInstructions.add(Instruction.Type.L1MODIFICATION); |
| 79 | unsupportedInstructions.add(Instruction.Type.PROTOCOL_INDEPENDENT); |
| 80 | unsupportedInstructions.add(Instruction.Type.EXTENSION); |
| 81 | unsupportedInstructions.add(Instruction.Type.STAT_TRIGGER); |
| 82 | |
| 83 | //Initialize unsupported L2MODIFICATION actions |
| 84 | unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_PUSH); |
| 85 | unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_POP); |
| 86 | unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_LABEL); |
| 87 | unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_BOS); |
| 88 | unsupportedL2mod.add(L2ModificationInstruction.L2SubType.DEC_MPLS_TTL); |
| 89 | |
| 90 | //Initialize unsupported L3MODIFICATION actions |
| 91 | unsupportedL3mod.add(L3ModificationInstruction.L3SubType.TTL_IN); |
| 92 | unsupportedL3mod.add(L3ModificationInstruction.L3SubType.TTL_OUT); |
| 93 | unsupportedL3mod.add(L3ModificationInstruction.L3SubType.DEC_TTL); |
| 94 | |
| 95 | //All L4MODIFICATION actions are supported |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | protected void initHardwareCriteria() { |
| 100 | log.debug("HP V3500 Driver - Initializing hardware supported criteria"); |
| 101 | |
| 102 | hardwareCriteria.add(Criterion.Type.IN_PORT); |
| 103 | hardwareCriteria.add(Criterion.Type.VLAN_VID); |
| 104 | |
| 105 | //Match in hardware is supported only for ETH_TYPE == IPv4 (0x0800) |
| 106 | hardwareCriteria.add(Criterion.Type.ETH_TYPE); |
| 107 | |
| 108 | hardwareCriteria.add(Criterion.Type.IPV4_SRC); |
| 109 | hardwareCriteria.add(Criterion.Type.IPV4_DST); |
| 110 | hardwareCriteria.add(Criterion.Type.IP_PROTO); |
| 111 | hardwareCriteria.add(Criterion.Type.IP_DSCP); |
| 112 | hardwareCriteria.add(Criterion.Type.TCP_SRC); |
| 113 | hardwareCriteria.add(Criterion.Type.TCP_DST); |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | protected void initHardwareInstructions() { |
| 118 | log.debug("HP V3500 Driver - Initializing hardware supported instructions"); |
| 119 | |
| 120 | //If the output is on CONTROLLER PORT the rule is processed in software |
| 121 | hardwareInstructions.add(Instruction.Type.OUTPUT); |
| 122 | |
| 123 | //Only modification of VLAN priority (VLAN_PCP) is supported in hardware |
| 124 | hardwareInstructions.add(Instruction.Type.L2MODIFICATION); |
| 125 | hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.VLAN_PCP); |
| 126 | |
| 127 | //TODO also L3MODIFICATION of IP_DSCP is supported in hardware |
| 128 | } |
| 129 | |
| 130 | //Return TRUE if ForwardingObjective fwd includes unsupported features |
| 131 | @Override |
| 132 | protected boolean checkUnSupportedFeatures(ForwardingObjective fwd) { |
| 133 | boolean unsupportedFeatures = false; |
| 134 | |
| 135 | for (Criterion criterion : fwd.selector().criteria()) { |
| 136 | if (this.unsupportedCriteria.contains(criterion.type())) { |
| 137 | log.warn("HP V3500 Driver - unsupported criteria {}", criterion.type()); |
| 138 | |
| 139 | unsupportedFeatures = true; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | for (Instruction instruction : fwd.treatment().allInstructions()) { |
| 144 | if (this.unsupportedInstructions.contains(instruction.type())) { |
| 145 | log.warn("HP V3500 Driver - unsupported instruction {}", instruction.type()); |
| 146 | |
| 147 | unsupportedFeatures = true; |
| 148 | } |
| 149 | |
| 150 | if (instruction.type() == Instruction.Type.L2MODIFICATION) { |
| 151 | if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) { |
| 152 | log.warn("HP V3500 Driver - unsupported L2MODIFICATION instruction {}", |
| 153 | ((L2ModificationInstruction) instruction).subtype()); |
| 154 | |
| 155 | unsupportedFeatures = true; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if (instruction.type() == Instruction.Type.L3MODIFICATION) { |
| 160 | if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) { |
| 161 | log.warn("HP V3500 Driver - unsupported L3MODIFICATION instruction {}", |
| 162 | ((L3ModificationInstruction) instruction).subtype()); |
| 163 | |
| 164 | unsupportedFeatures = true; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return unsupportedFeatures; |
| 170 | } |
| 171 | |
| 172 | @Override |
| 173 | protected int tableIdForForwardingObjective(ForwardingObjective fwd) { |
| 174 | boolean hardwareProcess = true; |
| 175 | |
| 176 | log.debug("HP V3500 Driver - Evaluating the ForwardingObjective for proper TableID"); |
| 177 | |
| 178 | //Check criteria supported in hardware |
| 179 | for (Criterion criterion : fwd.selector().criteria()) { |
| 180 | |
| 181 | if (!this.hardwareCriteria.contains(criterion.type())) { |
| 182 | log.warn("HP V3500 Driver - criterion {} only supported in SOFTWARE", criterion.type()); |
| 183 | |
| 184 | hardwareProcess = false; |
| 185 | break; |
| 186 | } |
| 187 | |
| 188 | //HP3500 supports hardware match on ETH_TYPE only with value TYPE_IPV4 |
| 189 | if (criterion.type() == Criterion.Type.ETH_TYPE) { |
| 190 | |
| 191 | if (((EthTypeCriterion) criterion).ethType().toShort() != Ethernet.TYPE_IPV4) { |
| 192 | log.warn("HP V3500 Driver - only ETH_TYPE == IPv4 (0x0800) is supported in hardware"); |
| 193 | |
| 194 | hardwareProcess = false; |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | //HP3500 supports IN_PORT criterion in hardware only if associated with ETH_TYPE criterion |
| 200 | if (criterion.type() == Criterion.Type.IN_PORT) { |
| 201 | hardwareProcess = false; |
| 202 | |
| 203 | for (Criterion requiredCriterion : fwd.selector().criteria()) { |
| 204 | if (requiredCriterion.type() == Criterion.Type.ETH_TYPE) { |
| 205 | hardwareProcess = true; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | if (!hardwareProcess) { |
| 210 | log.warn("HP V3500 Driver - IN_PORT criterion without ETH_TYPE is not supported in hardware"); |
| 211 | |
| 212 | break; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | } |
| 217 | |
| 218 | //Check if a CLEAR action is included |
| 219 | if (fwd.treatment().clearedDeferred()) { |
| 220 | log.warn("HP V3500 Driver - CLEAR action only supported in SOFTWARE"); |
| 221 | |
| 222 | hardwareProcess = false; |
| 223 | } |
| 224 | |
| 225 | //If criteria can be processed in hardware, then check treatment |
| 226 | if (hardwareProcess) { |
| 227 | |
| 228 | for (Instruction instruction : fwd.treatment().allInstructions()) { |
| 229 | |
| 230 | //Check if the instruction type is contained in the hardware instruction |
| 231 | if (!this.hardwareInstructions.contains(instruction.type())) { |
| 232 | log.warn("HP V3500 Driver - instruction {} only supported in SOFTWARE", instruction.type()); |
| 233 | |
| 234 | hardwareProcess = false; |
| 235 | break; |
| 236 | } |
| 237 | |
| 238 | /** If output is CONTROLLER_PORT the flow entry could be installed in hardware |
| 239 | * but is anyway processed in software because openflow header has to be added |
| 240 | */ |
| 241 | if (instruction.type() == Instruction.Type.OUTPUT) { |
| 242 | if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) { |
| 243 | log.warn("HP V3500 Driver - Forwarding to CONTROLLER only supported in software"); |
| 244 | |
| 245 | hardwareProcess = false; |
| 246 | break; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /** Only L2MODIFICATION supported in hardware is MODIFY VLAN_PRIORITY. |
| 251 | * Check if the specific L2MODIFICATION.subtype is supported in hardware |
| 252 | * */ |
| 253 | if (instruction.type() == Instruction.Type.L2MODIFICATION) { |
| 254 | |
Yuta HIGUCHI | fbd9ae9 | 2018-01-24 23:39:06 -0800 | [diff] [blame^] | 255 | if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) { |
Alessio Giorgetti | c1518bb | 2017-11-17 17:01:26 +0100 | [diff] [blame] | 256 | log.warn("HP V3500 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", |
| 257 | ((L2ModificationInstruction) instruction).subtype()); |
| 258 | |
| 259 | hardwareProcess = false; |
| 260 | break; |
| 261 | } |
| 262 | |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if (hardwareProcess) { |
| 268 | log.warn("HP V3500 Driver - This flow rule is supported in HARDWARE"); |
| 269 | return HP_HARDWARE_TABLE; |
| 270 | } else { |
| 271 | //TODO: create a specific flow in table 100 to redirect selected traffic on table 200 |
| 272 | |
| 273 | log.warn("HP V3500 Driver - This flow rule is only supported in SOFTWARE"); |
| 274 | return HP_SOFTWARE_TABLE; |
| 275 | } |
| 276 | |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public void filter(FilteringObjective filter) { |
| 281 | log.error("HP V3500 Driver - Unsupported FilteringObjective: filtering method send"); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | protected FlowRule.Builder processEthFilter(FilteringObjective filt, EthCriterion eth, PortCriterion port) { |
| 286 | log.error("HP V3500 Driver - Unsupported FilteringObjective: processEthFilter invoked"); |
| 287 | return null; |
| 288 | } |
| 289 | |
| 290 | @Override |
| 291 | protected FlowRule.Builder processVlanFilter(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) { |
| 292 | log.error("HP V3500 Driver - Unsupported FilteringObjective: processVlanFilter invoked"); |
| 293 | return null; |
| 294 | } |
| 295 | |
| 296 | @Override |
| 297 | protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) { |
| 298 | log.error("HP V3500 Driver - Unsupported FilteringObjective: processIpFilter invoked"); |
| 299 | return null; |
| 300 | } |
| 301 | } |
| 302 | |