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