Committed by
Gerrit Code Review
Use LambdaQuery in OpenFlowDeviceProvider to get details for optical ports and f…
…ix OmsPort totalChannels() Change-Id: I09bee1ad1cbf4b8d7185c2b022ffed4d8b2ef2e7
Showing
6 changed files
with
94 additions
and
10 deletions
... | @@ -37,7 +37,7 @@ public interface OmsPort extends Port { | ... | @@ -37,7 +37,7 @@ public interface OmsPort extends Port { |
37 | */ | 37 | */ |
38 | default short totalChannels() { | 38 | default short totalChannels() { |
39 | Frequency diff = maxFrequency().subtract(minFrequency()); | 39 | Frequency diff = maxFrequency().subtract(minFrequency()); |
40 | - return (short) (diff.asHz() / grid().asHz()); | 40 | + return (short) (diff.asHz() / grid().asHz() + 1); |
41 | } | 41 | } |
42 | 42 | ||
43 | /** | 43 | /** | ... | ... |
... | @@ -91,7 +91,7 @@ public class OmsPortHelperTest { | ... | @@ -91,7 +91,7 @@ public class OmsPortHelperTest { |
91 | assertThat(oms.maxFrequency(), is(maxF)); | 91 | assertThat(oms.maxFrequency(), is(maxF)); |
92 | assertThat(oms.minFrequency(), is(minF)); | 92 | assertThat(oms.minFrequency(), is(minF)); |
93 | assertThat(oms.grid(), is(grid)); | 93 | assertThat(oms.grid(), is(grid)); |
94 | - assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15)); | 94 | + assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16)); |
95 | } | 95 | } |
96 | 96 | ||
97 | } | 97 | } | ... | ... |
... | @@ -115,7 +115,7 @@ public class DefaultOmsPortTest { | ... | @@ -115,7 +115,7 @@ public class DefaultOmsPortTest { |
115 | assertThat(oms.maxFrequency(), is(maxFrequency)); | 115 | assertThat(oms.maxFrequency(), is(maxFrequency)); |
116 | assertThat(oms.minFrequency(), is(minFrequency)); | 116 | assertThat(oms.minFrequency(), is(minFrequency)); |
117 | assertThat(oms.grid(), is(grid)); | 117 | assertThat(oms.grid(), is(grid)); |
118 | - assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15)); | 118 | + assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16)); |
119 | } | 119 | } |
120 | 120 | ||
121 | } | 121 | } | ... | ... |
drivers/optical/src/main/java/org/onosproject/driver/optical/query/OplinkRoadmLambdaQuery.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 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.driver.optical.query; | ||
17 | + | ||
18 | +import java.util.Set; | ||
19 | +import java.util.stream.Collectors; | ||
20 | +import java.util.stream.IntStream; | ||
21 | + | ||
22 | +import org.onosproject.net.ChannelSpacing; | ||
23 | +import org.onosproject.net.OchSignal; | ||
24 | +import org.onosproject.net.PortNumber; | ||
25 | +import org.onosproject.net.behaviour.LambdaQuery; | ||
26 | +import org.onosproject.net.driver.AbstractHandlerBehaviour; | ||
27 | + | ||
28 | +/** | ||
29 | + * Lambda query implementation for Oplink ROADM. | ||
30 | + * | ||
31 | + * An Oplink ROADM port exposes OMSn resources: 88 lambdas with 50GHz width (fixed grid). | ||
32 | + * | ||
33 | + * Channel id: Nominal central frequency = 193.1 THz + spacingMultiplier * channelSpacing). | ||
34 | + * Channel (-28 to 59): starting from 191.7 THz to 196.05 THz, Increment by 50GHz. | ||
35 | + */ | ||
36 | + | ||
37 | +public class OplinkRoadmLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { | ||
38 | + | ||
39 | + private static final int LAMBDA_COUNT = 88; | ||
40 | + private static final int CENTER_OFFSET = 29; | ||
41 | + | ||
42 | + @Override | ||
43 | + public Set<OchSignal> queryLambdas(PortNumber port) { | ||
44 | + return IntStream.rangeClosed(1, LAMBDA_COUNT) | ||
45 | + .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x - CENTER_OFFSET)) | ||
46 | + .collect(Collectors.toSet()); | ||
47 | + } | ||
48 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | <drivers> | 17 | <drivers> |
18 | <driver name="linc-oe" extends="default" | 18 | <driver name="linc-oe" extends="default" |
19 | manufacturer="FlowForwarding.org" hwVersion="Unknown" | 19 | manufacturer="FlowForwarding.org" hwVersion="Unknown" |
20 | - swVersion="LINC-OE OpenFlow Software Switch 1.1"> | 20 | + swVersion="LINC(-OE)? OpenFlow Software Switch 1.1"> |
21 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" | 21 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" |
22 | impl="org.onosproject.driver.optical.handshaker.OfOpticalSwitchImplLinc13"/> | 22 | impl="org.onosproject.driver.optical.handshaker.OfOpticalSwitchImplLinc13"/> |
23 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" | 23 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" |
... | @@ -52,6 +52,8 @@ | ... | @@ -52,6 +52,8 @@ |
52 | swVersion="of-agent"> | 52 | swVersion="of-agent"> |
53 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" | 53 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" |
54 | impl="org.onosproject.driver.optical.handshaker.OplinkRoadmHandshaker"/> | 54 | impl="org.onosproject.driver.optical.handshaker.OplinkRoadmHandshaker"/> |
55 | + <behaviour api="org.onosproject.net.behaviour.LambdaQuery" | ||
56 | + impl="org.onosproject.driver.optical.query.OplinkRoadmLambdaQuery"/> | ||
55 | <behaviour api="org.onosproject.net.optical.OpticalDevice" | 57 | <behaviour api="org.onosproject.net.optical.OpticalDevice" |
56 | impl="org.onosproject.net.optical.DefaultOpticalDevice"/> | 58 | impl="org.onosproject.net.optical.DefaultOpticalDevice"/> |
57 | </driver> | 59 | </driver> | ... | ... |
... | @@ -32,10 +32,12 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -32,10 +32,12 @@ import static org.slf4j.LoggerFactory.getLogger; |
32 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
33 | import java.util.Collection; | 33 | import java.util.Collection; |
34 | import java.util.Collections; | 34 | import java.util.Collections; |
35 | +import java.util.Comparator; | ||
35 | import java.util.Dictionary; | 36 | import java.util.Dictionary; |
36 | import java.util.HashMap; | 37 | import java.util.HashMap; |
37 | import java.util.HashSet; | 38 | import java.util.HashSet; |
38 | import java.util.List; | 39 | import java.util.List; |
40 | +import java.util.Set; | ||
39 | 41 | ||
40 | import org.apache.felix.scr.annotations.Activate; | 42 | import org.apache.felix.scr.annotations.Activate; |
41 | import org.apache.felix.scr.annotations.Component; | 43 | import org.apache.felix.scr.annotations.Component; |
... | @@ -62,6 +64,7 @@ import org.onosproject.net.OtuSignalType; | ... | @@ -62,6 +64,7 @@ import org.onosproject.net.OtuSignalType; |
62 | import org.onosproject.net.Port; | 64 | import org.onosproject.net.Port; |
63 | import org.onosproject.net.PortNumber; | 65 | import org.onosproject.net.PortNumber; |
64 | import org.onosproject.net.SparseAnnotations; | 66 | import org.onosproject.net.SparseAnnotations; |
67 | +import org.onosproject.net.behaviour.LambdaQuery; | ||
65 | import org.onosproject.net.device.DefaultDeviceDescription; | 68 | import org.onosproject.net.device.DefaultDeviceDescription; |
66 | import org.onosproject.net.device.DefaultPortDescription; | 69 | import org.onosproject.net.device.DefaultPortDescription; |
67 | import org.onosproject.net.device.DefaultPortStatistics; | 70 | import org.onosproject.net.device.DefaultPortStatistics; |
... | @@ -71,6 +74,8 @@ import org.onosproject.net.device.DeviceProviderRegistry; | ... | @@ -71,6 +74,8 @@ import org.onosproject.net.device.DeviceProviderRegistry; |
71 | import org.onosproject.net.device.DeviceProviderService; | 74 | import org.onosproject.net.device.DeviceProviderService; |
72 | import org.onosproject.net.device.PortDescription; | 75 | import org.onosproject.net.device.PortDescription; |
73 | import org.onosproject.net.device.PortStatistics; | 76 | import org.onosproject.net.device.PortStatistics; |
77 | +import org.onosproject.net.driver.DriverHandler; | ||
78 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
74 | import org.onosproject.net.provider.AbstractProvider; | 79 | import org.onosproject.net.provider.AbstractProvider; |
75 | import org.onosproject.net.provider.ProviderId; | 80 | import org.onosproject.net.provider.ProviderId; |
76 | import org.onosproject.openflow.controller.Dpid; | 81 | import org.onosproject.openflow.controller.Dpid; |
... | @@ -479,7 +484,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -479,7 +484,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
479 | LOG.debug("Ports Of{}", portsOf); | 484 | LOG.debug("Ports Of{}", portsOf); |
480 | portsOf.forEach( | 485 | portsOf.forEach( |
481 | op -> { | 486 | op -> { |
482 | - portDescs.add(buildPortDescription(type, op)); | 487 | + portDescs.add(buildPortDescription(type, op, opsw)); |
483 | } | 488 | } |
484 | ); | 489 | ); |
485 | }); | 490 | }); |
... | @@ -540,9 +545,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -540,9 +545,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
540 | return annotations; | 545 | return annotations; |
541 | } | 546 | } |
542 | 547 | ||
543 | - private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port) { | 548 | + private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port, |
549 | + OpenFlowOpticalSwitch opsw) { | ||
544 | if (port instanceof OFPortOptical) { | 550 | if (port instanceof OFPortOptical) { |
545 | - return buildPortDescription(ptype, (OFPortOptical) port); | 551 | + return buildPortDescription(ptype, (OFPortOptical) port, opsw); |
546 | } | 552 | } |
547 | return buildPortDescription(ptype, (OFExpPort) port); | 553 | return buildPortDescription(ptype, (OFExpPort) port); |
548 | } | 554 | } |
... | @@ -681,7 +687,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -681,7 +687,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
681 | * @param port the port to build from. | 687 | * @param port the port to build from. |
682 | * @return portDescription for the port. | 688 | * @return portDescription for the port. |
683 | */ | 689 | */ |
684 | - private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) { | 690 | + private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port, |
691 | + OpenFlowOpticalSwitch opsw) { | ||
685 | checkArgument(port.getDesc().size() >= 1); | 692 | checkArgument(port.getDesc().size() >= 1); |
686 | 693 | ||
687 | // Minimally functional fixture. This needs to be fixed as we add better support. | 694 | // Minimally functional fixture. This needs to be fixed as we add better support. |
... | @@ -706,8 +713,35 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -706,8 +713,35 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
706 | case 2: // OMS port | 713 | case 2: // OMS port |
707 | // Assume complete optical spectrum and 50 GHz grid | 714 | // Assume complete optical spectrum and 50 GHz grid |
708 | // LINC-OE is only supported optical OF device for now | 715 | // LINC-OE is only supported optical OF device for now |
709 | - return omsPortDescription(portNo, enabled, | 716 | + Set<OchSignal> signals = null; |
710 | - Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); | 717 | + if (opsw instanceof HandlerBehaviour) { |
718 | + DriverHandler driverHandler = ((HandlerBehaviour) opsw).handler(); | ||
719 | + if (driverHandler != null && driverHandler.hasBehaviour(LambdaQuery.class)) { | ||
720 | + try { | ||
721 | + signals = driverHandler.behaviour(LambdaQuery.class).queryLambdas(portNo); | ||
722 | + } catch (NullPointerException e) { | ||
723 | + signals = null; | ||
724 | + } | ||
725 | + } | ||
726 | + } | ||
727 | + Frequency minFreq; | ||
728 | + Frequency maxFreq; | ||
729 | + Frequency channelSpacing; | ||
730 | + if (signals == null || signals.isEmpty()) { | ||
731 | + minFreq = Spectrum.U_BAND_MIN; | ||
732 | + maxFreq = Spectrum.O_BAND_MAX; | ||
733 | + channelSpacing = Frequency.ofGHz(50); | ||
734 | + } else { | ||
735 | + Comparator<OchSignal> compare = | ||
736 | + (OchSignal a, OchSignal b) -> a.spacingMultiplier() - b.spacingMultiplier(); | ||
737 | + OchSignal minOch = Collections.min(signals, compare); | ||
738 | + OchSignal maxOch = Collections.max(signals, compare); | ||
739 | + minFreq = minOch.centralFrequency(); | ||
740 | + maxFreq = maxOch.centralFrequency(); | ||
741 | + channelSpacing = minOch.channelSpacing().frequency(); | ||
742 | + } | ||
743 | + return omsPortDescription(portNo, enabled, minFreq, | ||
744 | + maxFreq, channelSpacing, annotations); | ||
711 | case 5: // OCH port | 745 | case 5: // OCH port |
712 | OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); | 746 | OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); |
713 | return ochPortDescription(portNo, enabled, OduSignalType.ODU4, | 747 | return ochPortDescription(portNo, enabled, OduSignalType.ODU4, | ... | ... |
-
Please register or login to post a comment