Committed by
Gerrit Code Review
Handle ModOchSignalInstruction in FlowModBuidlerVer13
To support OCh (Optical Channel) according to ONF "Optical Transport Protocol Extension Version 1.0" Change-Id: I00d0d61a9c2a2808cf5a02df608a6f3a35afaf28
Showing
3 changed files
with
136 additions
and
3 deletions
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -18,6 +18,9 @@ package org.onosproject.provider.of.flow.impl; | ... | @@ -18,6 +18,9 @@ package org.onosproject.provider.of.flow.impl; |
18 | import com.google.common.collect.Lists; | 18 | import com.google.common.collect.Lists; |
19 | import org.onlab.packet.Ip4Address; | 19 | import org.onlab.packet.Ip4Address; |
20 | import org.onlab.packet.Ip6Address; | 20 | import org.onlab.packet.Ip6Address; |
21 | +import org.onosproject.net.ChannelSpacing; | ||
22 | +import org.onosproject.net.GridType; | ||
23 | +import org.onosproject.net.OchSignal; | ||
21 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
22 | import org.onosproject.net.flow.FlowRule; | 25 | import org.onosproject.net.flow.FlowRule; |
23 | import org.onosproject.net.flow.TrafficTreatment; | 26 | import org.onosproject.net.flow.TrafficTreatment; |
... | @@ -27,6 +30,7 @@ import org.onosproject.net.flow.instructions.Instructions.GroupInstruction; | ... | @@ -27,6 +30,7 @@ import org.onosproject.net.flow.instructions.Instructions.GroupInstruction; |
27 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; | 30 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
28 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; | 31 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; |
29 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; | 32 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; |
33 | +import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; | ||
30 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; | 34 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
31 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; | 35 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; |
32 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; | 36 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; |
... | @@ -246,9 +250,14 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -246,9 +250,14 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
246 | L0ModificationInstruction l0m = (L0ModificationInstruction) i; | 250 | L0ModificationInstruction l0m = (L0ModificationInstruction) i; |
247 | switch (l0m.subtype()) { | 251 | switch (l0m.subtype()) { |
248 | case LAMBDA: | 252 | case LAMBDA: |
249 | - ModLambdaInstruction ml = (ModLambdaInstruction) i; | 253 | + return buildModLambdaInstruction((ModLambdaInstruction) i); |
250 | - return factory().actions().circuit(factory().oxms().ochSigidBasic( | 254 | + case OCH: |
251 | - new CircuitSignalID((byte) 1, (byte) 2, ml.lambda(), (short) 1))); | 255 | + try { |
256 | + return buildModOchSignalInstruction((ModOchSignalInstruction) i); | ||
257 | + } catch (UnsupportedGridTypeException | UnsupportedChannelSpacingException e) { | ||
258 | + log.warn(e.getMessage()); | ||
259 | + break; | ||
260 | + } | ||
252 | default: | 261 | default: |
253 | log.warn("Unimplemented action type {}.", l0m.subtype()); | 262 | log.warn("Unimplemented action type {}.", l0m.subtype()); |
254 | break; | 263 | break; |
... | @@ -256,6 +265,64 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -256,6 +265,64 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
256 | return null; | 265 | return null; |
257 | } | 266 | } |
258 | 267 | ||
268 | + private OFAction buildModLambdaInstruction(ModLambdaInstruction instruction) { | ||
269 | + return factory().actions().circuit(factory().oxms().ochSigidBasic( | ||
270 | + new CircuitSignalID((byte) 1, (byte) 2, instruction.lambda(), (short) 1))); | ||
271 | + } | ||
272 | + | ||
273 | + private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) { | ||
274 | + OchSignal signal = instruction.lambda(); | ||
275 | + byte gridType = convertGridType(signal.gridType()); | ||
276 | + byte channelSpacing = convertChannelSpacing(signal.channelSpacing()); | ||
277 | + | ||
278 | + return factory().actions().circuit(factory().oxms().ochSigidBasic( | ||
279 | + new CircuitSignalID(gridType, channelSpacing, | ||
280 | + (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) | ||
281 | + )); | ||
282 | + } | ||
283 | + | ||
284 | + private byte convertGridType(GridType type) { | ||
285 | + // See ONF "Optical Transport Protocol Extensions Version 1.0" | ||
286 | + // for the following values | ||
287 | + switch (type) { | ||
288 | + case DWDM: | ||
289 | + // OFPGRIDT_DWDM of enum ofp_grid_type | ||
290 | + return 1; | ||
291 | + case CWDM: | ||
292 | + // OFPGRIDT_CWDM of enum ofp_grid_type | ||
293 | + return 2; | ||
294 | + case FLEX: | ||
295 | + // OFPGRIDT_FLEX of enum ofp_grid_type | ||
296 | + return 3; | ||
297 | + default: | ||
298 | + throw new UnsupportedGridTypeException(type); | ||
299 | + } | ||
300 | + } | ||
301 | + | ||
302 | + private byte convertChannelSpacing(ChannelSpacing spacing) { | ||
303 | + // See ONF "Optical Transport Protocol Extensions Version 1.0" | ||
304 | + // for the following values | ||
305 | + switch (spacing) { | ||
306 | + case CHL_100GHZ: | ||
307 | + // OFPCS_100GHZ of enum ofp_chl_spacing | ||
308 | + return 1; | ||
309 | + case CHL_50GHZ: | ||
310 | + // OFPCS_50GHZ of enum ofp_chl_spacing | ||
311 | + return 2; | ||
312 | + case CHL_25GHZ: | ||
313 | + // OFPCS_25GHZ of enum ofp_chl_spacing | ||
314 | + return 3; | ||
315 | + case CHL_12P5GHZ: | ||
316 | + // OFPCS_12P5GHZ of enum ofp_chl_spacing | ||
317 | + return 4; | ||
318 | + case CHL_6P25GHZ: | ||
319 | + // OFPCS_6P25GHZ of enum ofp_chl_spacing | ||
320 | + return 5; | ||
321 | + default: | ||
322 | + throw new UnsupportedChannelSpacingException(spacing); | ||
323 | + } | ||
324 | + } | ||
325 | + | ||
259 | private OFAction buildL2Modification(Instruction i) { | 326 | private OFAction buildL2Modification(Instruction i) { |
260 | L2ModificationInstruction l2m = (L2ModificationInstruction) i; | 327 | L2ModificationInstruction l2m = (L2ModificationInstruction) i; |
261 | ModEtherInstruction eth; | 328 | ModEtherInstruction eth; | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
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 | +package org.onosproject.provider.of.flow.impl; | ||
17 | + | ||
18 | +import org.onosproject.net.ChannelSpacing; | ||
19 | + | ||
20 | +/** | ||
21 | + * Thrown to indicate that unsupported channel spacing is referred. | ||
22 | + */ | ||
23 | +public class UnsupportedChannelSpacingException extends RuntimeException { | ||
24 | + | ||
25 | + /** | ||
26 | + * Creates an instance with the specified unsupported channel spacing. | ||
27 | + * | ||
28 | + * @param unsupported unsupported channel spacing | ||
29 | + */ | ||
30 | + public UnsupportedChannelSpacingException(ChannelSpacing unsupported) { | ||
31 | + super("ChannelSpacing " + unsupported + " is not supported"); | ||
32 | + } | ||
33 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
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 | +package org.onosproject.provider.of.flow.impl; | ||
17 | + | ||
18 | +import org.onosproject.net.GridType; | ||
19 | + | ||
20 | +/** | ||
21 | + * Thrown to indicate that unsupported gird type is referred. | ||
22 | + */ | ||
23 | +public class UnsupportedGridTypeException extends RuntimeException { | ||
24 | + | ||
25 | + /** | ||
26 | + * Creates an instance with the specified unsupported grid type. | ||
27 | + * | ||
28 | + * @param unsupported unsupported grid type | ||
29 | + */ | ||
30 | + public UnsupportedGridTypeException(GridType unsupported) { | ||
31 | + super("GridType " + unsupported + " is not supported"); | ||
32 | + } | ||
33 | +} |
-
Please register or login to post a comment