blob: 15776f5607301d307f3c2dcb08437aacdb5ecb8b [file] [log] [blame]
Jovana Vuleta1de61262017-06-14 11:10:29 +02001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jovana Vuleta1de61262017-06-14 11:10:29 +02003 *
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
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010019import org.onlab.packet.Ethernet;
20import org.onosproject.core.GroupId;
Jovana Vuleta1de61262017-06-14 11:10:29 +020021import org.onosproject.net.PortNumber;
Jovana Vuleta1de61262017-06-14 11:10:29 +020022import 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;
Jovana Vuleta1de61262017-06-14 11:10:29 +020026import org.onosproject.net.flow.criteria.EthCriterion;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010027import org.onosproject.net.flow.criteria.EthTypeCriterion;
Jovana Vuleta1de61262017-06-14 11:10:29 +020028import org.onosproject.net.flow.criteria.IPCriterion;
29import org.onosproject.net.flow.criteria.PortCriterion;
30import org.onosproject.net.flow.criteria.VlanIdCriterion;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010031import 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;
Jovana Vuleta1de61262017-06-14 11:10:29 +020035import org.onosproject.net.flowobjective.FilteringObjective;
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010036import org.onosproject.net.group.Group;
37
Jovana Vuleta1de61262017-06-14 11:10:29 +020038import org.slf4j.Logger;
39
40import static org.slf4j.LoggerFactory.getLogger;
41
42/**
43 * Driver for HP3800 hybrid switches.
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010044 *
45 * Refer to the device manual to check unsupported features and features supported in hardware
46 *
Jovana Vuleta1de61262017-06-14 11:10:29 +020047 */
Jovana Vuleta1de61262017-06-14 11:10:29 +020048
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010049public class HPPipelineV3800 extends AbstractHPPipeline {
Jovana Vuleta1de61262017-06-14 11:10:29 +020050
51 private final Logger log = getLogger(getClass());
52
Jovana Vuleta1de61262017-06-14 11:10:29 +020053 @Override
54 protected FlowRule.Builder setDefaultTableIdForFlowObjective(FlowRule.Builder ruleBuilder) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010055 log.debug("HP V3800 Driver - Setting default table id to hardware table {}", HP_HARDWARE_TABLE);
Jovana Vuleta1de61262017-06-14 11:10:29 +020056 return ruleBuilder.forTable(HP_HARDWARE_TABLE);
57 }
58
59 @Override
Alessio Giorgettic1518bb2017-11-17 17:01:26 +010060 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
alessioff124ad2018-11-13 13:25:51 +0100147 protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100148 boolean unsupportedFeatures = false;
149
alessioff124ad2018-11-13 13:25:51 +0100150 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100151 if (this.unsupportedCriteria.contains(criterion.type())) {
152 log.warn("HP V3800 Driver - unsupported criteria {}", criterion.type());
153
154 unsupportedFeatures = true;
155 }
156 }
157
alessioff124ad2018-11-13 13:25:51 +0100158 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100159 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
alessioff124ad2018-11-13 13:25:51 +0100188 protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100189 boolean hardwareProcess = true;
190
191 log.debug("HP V3800 Driver - Evaluating the ForwardingObjective for proper TableID");
192
193 //Check criteria supported in hardware
alessioff124ad2018-11-13 13:25:51 +0100194 for (Criterion criterion : selector.criteria()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100195
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
alessioff124ad2018-11-13 13:25:51 +0100217 if (treatment.clearedDeferred()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100218 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) {
alessioff124ad2018-11-13 13:25:51 +0100225 for (Instruction instruction : treatment.allInstructions()) {
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100226
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 Vuleta1de61262017-06-14 11:10:29 +0200302 }
303
304 @Override
305 public void filter(FilteringObjective filter) {
306 log.error("Unsupported FilteringObjective: : filtering method send");
307 }
308
309 @Override
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100310 protected FlowRule.Builder processEthFilter(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
Jovana Vuleta1de61262017-06-14 11:10:29 +0200311 log.error("Unsupported FilteringObjective: processEthFilter invoked");
312 return null;
313 }
314
315 @Override
Alessio Giorgettic1518bb2017-11-17 17:01:26 +0100316 protected FlowRule.Builder processVlanFilter(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) {
Jovana Vuleta1de61262017-06-14 11:10:29 +0200317 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 Vuleta1de61262017-06-14 11:10:29 +0200326}