blob: 33e781f219b24971c355329dee8d97bd150b07f6 [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;
alessioff124ad2018-11-13 13:25:51 +010022import org.onosproject.net.flow.TrafficSelector;
23import org.onosproject.net.flow.TrafficTreatment;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010024import org.onosproject.net.flow.FlowRule;
25import 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.flowobjective.FilteringObjective;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010036import org.onosproject.net.group.Group;
37
38import org.slf4j.Logger;
39
40import static org.slf4j.LoggerFactory.getLogger;
41
42/**
43 * Driver for HP hybrid switches employing V2 hardware module.
44 *
45 * - HP2920
46 * - HP3800, tested
47 * - HP5400, depends on switch configuration if "no-allow-v1-modules" it operates as V2
48 * - HP5400R, depends on switch configuration if "allow-v2-modules" it operates as V2
49 * - HP8200, depends on switch configuration if "no-allow-v1-modules" it operates as V2
50 *
51 * Refer to the device manual to check unsupported features and features supported in hardware
52 *
53 */
54
55public class HPPipelineV2 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 V2 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 V2 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 V2 Driver - Initializing hardware supported instructions");
131
132 hardwareInstructions.add(Instruction.Type.OUTPUT);
133
134 //Only modification of VLAN priority (VLAN_PCP) is supported in hardware
135 hardwareInstructions.add(Instruction.Type.L2MODIFICATION);
136
137 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.ETH_SRC);
138 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.ETH_DST);
139 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.VLAN_ID);
140 hardwareInstructionsL2mod.add(L2ModificationInstruction.L2SubType.VLAN_PCP);
141
142 //Only GROUP of type ALL is supported in hardware
143 //Moreover, for hardware support, each bucket must contain one and only one instruction of type OUTPUT
144 hardwareInstructions.add(Instruction.Type.GROUP);
145
146 hardwareGroups.add(Group.Type.ALL);
147
148 //TODO also L3MODIFICATION of IP_DSCP is supported in hardware
149 }
150
151 //Return TRUE if ForwardingObjective fwd includes UNSUPPORTED features
152 @Override
alessioff124ad2018-11-13 13:25:51 +0100153 protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100154 boolean unsupportedFeatures = false;
155
alessioff124ad2018-11-13 13:25:51 +0100156 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100157 if (this.unsupportedCriteria.contains(criterion.type())) {
158 log.warn("HP V2 Driver - unsupported criteria {}", criterion.type());
159
160 unsupportedFeatures = true;
161 }
162 }
163
alessioff124ad2018-11-13 13:25:51 +0100164 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100165 if (this.unsupportedInstructions.contains(instruction.type())) {
166 log.warn("HP V2 Driver - unsupported instruction {}", instruction.type());
167
168 unsupportedFeatures = true;
169 }
170
171 if (instruction.type() == Instruction.Type.L2MODIFICATION) {
172 if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
173 log.warn("HP V2 Driver - unsupported L2MODIFICATION instruction {}",
174 ((L2ModificationInstruction) instruction).subtype());
175
176 unsupportedFeatures = true;
177 }
178 }
179
180 if (instruction.type() == Instruction.Type.L3MODIFICATION) {
181 if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
182 log.warn("HP V2 Driver - unsupported L3MODIFICATION instruction {}",
183 ((L3ModificationInstruction) instruction).subtype());
184
185 unsupportedFeatures = true;
186 }
187 }
188 }
189
190 return unsupportedFeatures;
191 }
192
193 @Override
alessioff124ad2018-11-13 13:25:51 +0100194 protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100195 boolean hardwareProcess = true;
196
197 log.debug("HP V2 Driver - Evaluating the ForwardingObjective for proper TableID");
198
199 //Check criteria supported in hardware
alessioff124ad2018-11-13 13:25:51 +0100200 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100201
202 if (!this.hardwareCriteria.contains(criterion.type())) {
203 log.warn("HP V2 Driver - criterion {} only supported in SOFTWARE", criterion.type());
204
205 hardwareProcess = false;
206 break;
207 }
208
209 //V2 does not support hardware match on ETH_TYPE of value TYPE_VLAN (tested on HP3800 16.04)
210 if (criterion.type() == Criterion.Type.ETH_TYPE) {
211
212 if (((EthTypeCriterion) criterion).ethType().toShort() == Ethernet.TYPE_VLAN) {
213 log.warn("HP V2 Driver - ETH_TYPE == VLAN (0x8100) is only supported in software");
214
215 hardwareProcess = false;
216 break;
217 }
218 }
219
220 //HP2920 cannot match in hardware the ETH_DST in non-IP packets - TO BE REFINED AND TESTED
221 if (deviceHwVersion.contains("2920")) {
222
223 if (criterion.type() == Criterion.Type.ETH_DST) {
224 log.warn("HP V2 Driver (specific for HP2920) " +
225 "- criterion {} only supported in SOFTWARE", criterion.type());
226
227 hardwareProcess = false;
228 break;
229 }
230 }
231 }
232
233 //Check if a CLEAR action is included
alessioff124ad2018-11-13 13:25:51 +0100234 if (treatment.clearedDeferred()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100235 log.warn("HP V2 Driver - CLEAR action only supported in SOFTWARE");
236
237 hardwareProcess = false;
238 }
239
240 //If criteria can be processed in hardware, then check treatment
241 if (hardwareProcess) {
alessioff124ad2018-11-13 13:25:51 +0100242 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100243
244 //Check if the instruction type is contained in the hardware instruction
245 if (!this.hardwareInstructions.contains(instruction.type())) {
246 log.warn("HP V2 Driver - instruction {} only supported in SOFTWARE", instruction.type());
247
248 hardwareProcess = false;
249 break;
250 }
251
alessioff124ad2018-11-13 13:25:51 +0100252 /* If output is CONTROLLER_PORT the flow entry could be installed in hardware
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100253 * but is anyway processed in software because OPENFLOW header has to be added
254 */
255 if (instruction.type() == Instruction.Type.OUTPUT) {
256 if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
257 log.warn("HP V2 Driver - Forwarding to CONTROLLER only supported in software");
258
259 hardwareProcess = false;
260 break;
261 }
262 }
263
264 //Check if the specific L2MODIFICATION.subtype is supported in hardware
265 if (instruction.type() == Instruction.Type.L2MODIFICATION) {
266
267 if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
268 log.warn("HP V2 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE",
269 ((L2ModificationInstruction) instruction).subtype());
270
271 hardwareProcess = false;
272 break;
273 }
274 }
275
276 //Check if the specific GROUP addressed in the instruction is:
277 // --- installed in the device
278 // --- type ALL
279 // TODO --- check if all the buckets contains one and only one output action
280 if (instruction.type() == Instruction.Type.GROUP) {
281 boolean groupInstalled = false;
282
283 GroupId groupId = ((Instructions.GroupInstruction) instruction).groupId();
284
285 Iterable<Group> groupsOnDevice = groupService.getGroups(deviceId);
286
287 for (Group group : groupsOnDevice) {
288
289 if ((group.state() == Group.GroupState.ADDED) && (group.id().equals(groupId))) {
290 groupInstalled = true;
291
292 if (group.type() != Group.Type.ALL) {
293 log.warn("HP V2 Driver - group type {} only supported in SOFTWARE",
294 group.type().toString());
295 hardwareProcess = false;
296 }
297
298 break;
299 }
300 }
301
302 if (!groupInstalled) {
303 log.warn("HP V2 Driver - referenced group is not installed on the device.");
304 hardwareProcess = false;
305 }
306 }
307 }
308 }
309
310 if (hardwareProcess) {
311 log.warn("HP V2 Driver - This flow rule is supported in HARDWARE");
312 return HP_HARDWARE_TABLE;
313 } else {
314 //TODO: create a specific flow in table 100 to redirect selected traffic on table 200
315
316 log.warn("HP V2 Driver - This flow rule is only supported in SOFTWARE");
317 return HP_SOFTWARE_TABLE;
318 }
319 }
320
321 @Override
322 public void filter(FilteringObjective filter) {
323 log.error("Unsupported FilteringObjective: : filtering method send");
324 }
325
326 @Override
327 protected FlowRule.Builder processEthFilter(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
328 log.error("Unsupported FilteringObjective: processEthFilter invoked");
329 return null;
330 }
331
332 @Override
333 protected FlowRule.Builder processVlanFilter(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) {
334 log.error("Unsupported FilteringObjective: processVlanFilter invoked");
335 return null;
336 }
337
338 @Override
339 protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) {
340 log.error("Unsupported FilteringObjective: processIpFilter invoked");
341 return null;
342 }
343}