blob: a1012a16082de5a8b88b80e0ecd006c67572fb5f [file] [log] [blame]
Alessio Giorgettic1518bb2017-11-17 17:01:26 +01001/*
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
17package org.onosproject.drivers.hp;
18
19import org.onlab.packet.Ethernet;
20import org.onosproject.core.GroupId;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.flow.FlowRule;
alessioff124ad2018-11-13 13:25:51 +010023import org.onosproject.net.flow.TrafficSelector;
24import org.onosproject.net.flow.TrafficTreatment;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010025import org.onosproject.net.flow.criteria.Criterion;
26import org.onosproject.net.flow.criteria.EthCriterion;
27import org.onosproject.net.flow.criteria.EthTypeCriterion;
28import org.onosproject.net.flow.criteria.IPCriterion;
29import org.onosproject.net.flow.criteria.PortCriterion;
30import org.onosproject.net.flow.criteria.VlanIdCriterion;
31import org.onosproject.net.flow.instructions.Instruction;
32import org.onosproject.net.flow.instructions.Instructions;
33import org.onosproject.net.flow.instructions.L2ModificationInstruction;
34import org.onosproject.net.flow.instructions.L3ModificationInstruction;
35import org.onosproject.net.flow.instructions.L4ModificationInstruction;
36import org.onosproject.net.flowobjective.FilteringObjective;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010037import org.onosproject.net.group.Group;
38
39import org.slf4j.Logger;
40
41import static org.slf4j.LoggerFactory.getLogger;
42
43/**
44 * Driver for HP hybrid switches employing V3 hardware module.
45 * NOT TESTED ON V3 HARDWARE DEVICES
46 *
47 * - HP2930
48 * - HP3810
49 * - HP5400R, depends on switch configuration if "no-allow-v2-modules" it operates as V3
50 *
51 * Refer to the device manual to check unsupported features and features supported in hardware
52 *
53 */
54
55public class HPPipelineV3 extends AbstractHPPipeline {
56
57 private final Logger log = getLogger(getClass());
58
59 @Override
60 protected FlowRule.Builder setDefaultTableIdForFlowObjective(FlowRule.Builder ruleBuilder) {
61 log.debug("HP V3 Driver - Setting default table id to hardware table {}", HP_HARDWARE_TABLE);
62 return ruleBuilder.forTable(HP_HARDWARE_TABLE);
63 }
64
65 @Override
66 protected void initUnSupportedFeatures() {
67 //Initialize unsupported criteria
68 unsupportedCriteria.add(Criterion.Type.METADATA);
69 unsupportedCriteria.add(Criterion.Type.IP_ECN);
70 unsupportedCriteria.add(Criterion.Type.SCTP_SRC);
71 unsupportedCriteria.add(Criterion.Type.SCTP_SRC_MASKED);
72 unsupportedCriteria.add(Criterion.Type.SCTP_DST);
73 unsupportedCriteria.add(Criterion.Type.SCTP_DST_MASKED);
74 unsupportedCriteria.add(Criterion.Type.IPV6_ND_SLL);
75 unsupportedCriteria.add(Criterion.Type.IPV6_ND_TLL);
76 unsupportedCriteria.add(Criterion.Type.MPLS_LABEL);
77 unsupportedCriteria.add(Criterion.Type.MPLS_TC);
78 unsupportedCriteria.add(Criterion.Type.MPLS_BOS);
79 unsupportedCriteria.add(Criterion.Type.PBB_ISID);
80 unsupportedCriteria.add(Criterion.Type.TUNNEL_ID);
81 unsupportedCriteria.add(Criterion.Type.IPV6_EXTHDR);
82
83 //Initialize unsupported instructions
84 unsupportedInstructions.add(Instruction.Type.QUEUE);
85 unsupportedInstructions.add(Instruction.Type.METADATA);
86 unsupportedInstructions.add(Instruction.Type.L0MODIFICATION);
87 unsupportedInstructions.add(Instruction.Type.L1MODIFICATION);
88 unsupportedInstructions.add(Instruction.Type.PROTOCOL_INDEPENDENT);
89 unsupportedInstructions.add(Instruction.Type.EXTENSION);
90 unsupportedInstructions.add(Instruction.Type.STAT_TRIGGER);
91
92 //Initialize unsupportet L2MODIFICATION actions
93 unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_PUSH);
94 unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_POP);
95 unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_LABEL);
96 unsupportedL2mod.add(L2ModificationInstruction.L2SubType.MPLS_BOS);
97 unsupportedL2mod.add(L2ModificationInstruction.L2SubType.DEC_MPLS_TTL);
98
99 //Initialize unsupported L3MODIFICATION actions
100 unsupportedL3mod.add(L3ModificationInstruction.L3SubType.TTL_IN);
101 unsupportedL3mod.add(L3ModificationInstruction.L3SubType.TTL_OUT);
102 unsupportedL3mod.add(L3ModificationInstruction.L3SubType.DEC_TTL);
103
104 //All L4MODIFICATION actions are supported
105 }
106
107 @Override
108 protected void initHardwareCriteria() {
109 log.debug("HP V3 Driver - Initializing hardware supported criteria");
110
111 hardwareCriteria.add(Criterion.Type.IN_PORT);
112 hardwareCriteria.add(Criterion.Type.VLAN_VID);
113 hardwareCriteria.add(Criterion.Type.VLAN_PCP);
114
115 //Match in hardware is not supported ETH_TYPE == VLAN (0x8100)
116 hardwareCriteria.add(Criterion.Type.ETH_TYPE);
117
118 hardwareCriteria.add(Criterion.Type.ETH_SRC);
119 hardwareCriteria.add(Criterion.Type.ETH_DST);
120 hardwareCriteria.add(Criterion.Type.IPV4_SRC);
121 hardwareCriteria.add(Criterion.Type.IPV4_DST);
122 hardwareCriteria.add(Criterion.Type.IP_PROTO);
123 hardwareCriteria.add(Criterion.Type.IP_DSCP);
124 hardwareCriteria.add(Criterion.Type.TCP_SRC);
125 hardwareCriteria.add(Criterion.Type.TCP_DST);
126 }
127
128 @Override
129 protected void initHardwareInstructions() {
130 log.debug("HP V3 Driver - Initializing hardware supported instructions");
131
132 hardwareInstructions.add(Instruction.Type.OUTPUT);
133
134 hardwareInstructions.add(Instruction.Type.L2MODIFICATION);
135 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.ETH_SRC);
136 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.ETH_DST);
137 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.VLAN_ID);
138 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.VLAN_PCP);
139
140 hardwareInstructions.add(Instruction.Type.L3MODIFICATION);
141 hardwareInstructionsL3mod.add(L3ModificationInstruction.L3SubType.IPV4_SRC);
142 hardwareInstructionsL3mod.add(L3ModificationInstruction.L3SubType.IPV4_DST);
143
144 hardwareInstructions.add(Instruction.Type.L4MODIFICATION);
145 hardwareInstructionsL4mod.add(L4ModificationInstruction.L4SubType.TCP_DST);
146 hardwareInstructionsL4mod.add(L4ModificationInstruction.L4SubType.UDP_DST);
147 hardwareInstructionsL4mod.add(L4ModificationInstruction.L4SubType.TCP_SRC);
148 hardwareInstructionsL4mod.add(L4ModificationInstruction.L4SubType.UDP_SRC);
149
150 /** Only GROUP of type ALL is supported in hardware.
151 *
152 * Moreover, each bucket must contain one and only one instruction of type OUTPUT
153 */
154 hardwareInstructions.add(Instruction.Type.GROUP);
155 hardwareGroups.add(Group.Type.ALL);
156
157 //TODO also L3MODIFICATION of IP_DSCP is supported in hardware
158 }
159
160 //Return TRUE if ForwardingObjective fwd includes UNSUPPORTED features
161 @Override
alessioff124ad2018-11-13 13:25:51 +0100162 protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100163 boolean unsupportedFeatures = false;
164
alessioff124ad2018-11-13 13:25:51 +0100165 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100166 if (this.unsupportedCriteria.contains(criterion.type())) {
167 log.warn("HP V3 Driver - unsupported criteria {}", criterion.type());
168
169 unsupportedFeatures = true;
170 }
171 }
172
alessioff124ad2018-11-13 13:25:51 +0100173 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100174 if (this.unsupportedInstructions.contains(instruction.type())) {
175 log.warn("HP V3 Driver - unsupported instruction {}", instruction.type());
176
177 unsupportedFeatures = true;
178 }
179
180 if (instruction.type() == Instruction.Type.L2MODIFICATION) {
181 if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
182 log.warn("HP V3 Driver - unsupported L2MODIFICATION instruction {}",
183 ((L2ModificationInstruction) instruction).subtype());
184
185 unsupportedFeatures = true;
186 }
187 }
188
189 if (instruction.type() == Instruction.Type.L3MODIFICATION) {
190 if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
191 log.warn("HP V3 Driver - unsupported L3MODIFICATION instruction {}",
192 ((L3ModificationInstruction) instruction).subtype());
193
194 unsupportedFeatures = true;
195 }
196 }
197 }
198
199 return unsupportedFeatures;
200 }
201
202 @Override
alessioff124ad2018-11-13 13:25:51 +0100203 protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100204 boolean hardwareProcess = true;
205
206 log.debug("HP V3 Driver - Evaluating the ForwardingObjective for proper TableID");
207
208 //Check criteria supported in hardware
alessioff124ad2018-11-13 13:25:51 +0100209 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100210
211 if (!this.hardwareCriteria.contains(criterion.type())) {
212 log.warn("HP V3 Driver - criterion {} only supported in SOFTWARE", criterion.type());
213
214 hardwareProcess = false;
215 break;
216 }
217
218 //HP3800 does not support hardware match on ETH_TYPE of value TYPE_VLAN
219 if (criterion.type() == Criterion.Type.ETH_TYPE) {
220
221 if (((EthTypeCriterion) criterion).ethType().toShort() == Ethernet.TYPE_VLAN) {
222 log.warn("HP V3 Driver - ETH_TYPE == VLAN (0x8100) is only supported in software");
223
224 hardwareProcess = false;
225 break;
226 }
227 }
228
229 }
230
231 //TODO: CLEAR ations should be supported by V3 hardware modules - To be TESTED
232 //This commented code is required if CLEAR action is not supported in hardware
233 /*if (fwd.treatment().clearedDeferred()) {
234 log.warn("HP V3 Driver - CLEAR action only supported in SOFTWARE");
235
236 hardwareProcess = false;
237 }*/
238
239 //If criteria can be processed in hardware, then check treatment
240 if (hardwareProcess) {
alessioff124ad2018-11-13 13:25:51 +0100241 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100242
243 //Check if the instruction type is contained in the hardware instruction
244 if (!this.hardwareInstructions.contains(instruction.type())) {
245 log.warn("HP V3 Driver - instruction {} only supported in SOFTWARE", instruction.type());
246
247 hardwareProcess = false;
248 break;
249 }
250
251 /** If output is CONTROLLER_PORT the flow entry could be installed in hardware
252 * but is anyway processed in software because OPENFLOW header has to be added
253 */
254 if (instruction.type() == Instruction.Type.OUTPUT) {
255 if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
256 log.warn("HP V3 Driver - Forwarding to CONTROLLER only supported in software");
257
258 hardwareProcess = false;
259 break;
260 }
261 }
262
263 //Check if the specific L2MODIFICATION.subtype is supported in hardware
264 if (instruction.type() == Instruction.Type.L2MODIFICATION) {
265
266 if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
267 log.warn("HP V3 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE",
268 ((L2ModificationInstruction) instruction).subtype());
269
270 hardwareProcess = false;
271 break;
272 }
273 }
274
275 //Check if the specific L3MODIFICATION.subtype is supported in hardware
276 if (instruction.type() == Instruction.Type.L3MODIFICATION) {
277
278 if (!this.hardwareInstructionsL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
279 log.warn("HP V3 Driver - L3MODIFICATION.subtype {} only supported in SOFTWARE",
280 ((L3ModificationInstruction) instruction).subtype());
281
282 hardwareProcess = false;
283 break;
284 }
285 }
286
287 //Check if the specific L4MODIFICATION.subtype is supported in hardware
288 if (instruction.type() == Instruction.Type.L4MODIFICATION) {
289
290 if (!this.hardwareInstructionsL4mod.contains(((L4ModificationInstruction) instruction).subtype())) {
291 log.warn("HP V3 Driver - L4MODIFICATION.subtype {} only supported in SOFTWARE",
292 ((L4ModificationInstruction) instruction).subtype());
293
294 hardwareProcess = false;
295 break;
296 }
297 }
298
299 //Check if the specific GROUP addressed in the instruction is:
300 // --- installed in the device
301 // --- type ALL
302 // TODO --- check if all the buckets contains one and only one output action
303 if (instruction.type() == Instruction.Type.GROUP) {
304 boolean groupInstalled = false;
305
306 GroupId groupId = ((Instructions.GroupInstruction) instruction).groupId();
307
308 Iterable<Group> groupsOnDevice = groupService.getGroups(deviceId);
309
310 for (Group group : groupsOnDevice) {
311
312 if ((group.state() == Group.GroupState.ADDED) && (group.id().equals(groupId))) {
313 groupInstalled = true;
314
315 if (group.type() != Group.Type.ALL) {
316 log.warn("HP V3 Driver - group type {} only supported in SOFTWARE",
317 group.type().toString());
318 hardwareProcess = false;
319 }
320
321 break;
322 }
323 }
324
325 if (!groupInstalled) {
326 log.warn("HP V3 Driver - referenced group is not installed on the device.");
327 hardwareProcess = false;
328 }
329 }
330 }
331 }
332
333 if (hardwareProcess) {
334 log.warn("HP V3 Driver - This flow rule is supported in HARDWARE");
335 return HP_HARDWARE_TABLE;
336 } else {
337 //TODO: create a specific flow in table 100 to redirect selected traffic on table 200
338
339 log.warn("HP V3 Driver - This flow rule is only supported in SOFTWARE");
340 return HP_SOFTWARE_TABLE;
341 }
342 }
343
344 @Override
345 public void filter(FilteringObjective filter) {
346 log.error("Unsupported FilteringObjective: : filtering method send");
347 }
348
349 @Override
350 protected FlowRule.Builder processEthFilter(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
351 log.error("Unsupported FilteringObjective: processEthFilter invoked");
352 return null;
353 }
354
355 @Override
356 protected FlowRule.Builder processVlanFilter(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) {
357 log.error("Unsupported FilteringObjective: processVlanFilter invoked");
358 return null;
359 }
360
361 @Override
362 protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) {
363 log.error("Unsupported FilteringObjective: processIpFilter invoked");
364 return null;
365 }
366}