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