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