Rimon Ashkenazy
Committed by Gerrit Code Review

Add new OFOpticalSwitch13 LambdaQuery, and corrections to OMS port Desc:

 - fix OmsPort totalChannels(),
 - fix creating OMS PortDescription with correct parameters of min/max frequencies.

Change-Id: I9adbbb4e1e9ebe20ba4b3c2ae23b7a0651af5d66
...@@ -62,7 +62,7 @@ public class OmsPort extends DefaultPort { ...@@ -62,7 +62,7 @@ public class OmsPort extends DefaultPort {
62 */ 62 */
63 public short totalChannels() { 63 public short totalChannels() {
64 Frequency diff = maxFrequency.subtract(minFrequency); 64 Frequency diff = maxFrequency.subtract(minFrequency);
65 - return (short) (diff.asHz() / (grid.asHz() + 1)); 65 + return (short) (diff.asHz() / grid.asHz());
66 } 66 }
67 67
68 /** 68 /**
......
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.query;
17 +
18 +import org.onosproject.net.ChannelSpacing;
19 +import org.onosproject.net.OchSignal;
20 +import org.onosproject.net.OmsPort;
21 +import org.onosproject.net.Port;
22 +import org.onosproject.net.PortNumber;
23 +import org.onosproject.net.behaviour.LambdaQuery;
24 +import org.onosproject.net.device.DeviceService;
25 +import org.onosproject.net.driver.AbstractHandlerBehaviour;
26 +
27 +import java.util.Collections;
28 +import java.util.Set;
29 +import java.util.stream.Collectors;
30 +import java.util.stream.IntStream;
31 +
32 +/**
33 + * Lambda query implementation for OFOpticalSwitch13.
34 + *
35 + * Note: Standard (ONF TS-022, March 15, 2015) does not support negative values for spacingMultiplier in exp_OCH_sigid.
36 + * Thus, Lambda values cannot be calculated using center and spacingMultiplier of +/- values.
37 + * Therefore, Lambda values are calculated with positive values only: starting from min-frequency of 191.7 THz.
38 + *
39 + * TODO: When standard is fixed - modify queryLambdas accordingly.
40 + *
41 + * OFOpticalSwitch13 exposes OchSignal resources: 'lambdaCount' lambdas with 50GHz width (fixed grid)
42 + * starting from min-frequency of 191.7 THz.
43 + */
44 +
45 +public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
46 +
47 + @Override
48 + public Set<OchSignal> queryLambdas(PortNumber port) {
49 + DeviceService deviceService = this.handler().get(DeviceService.class);
50 + Port p = deviceService.getPort(this.data().deviceId(), port);
51 +
52 + // Only OMS ports expose lambda resources
53 + if (!p.type().equals(Port.Type.OMS)) {
54 + return Collections.emptySet();
55 + }
56 +
57 + short lambdaCount = ((OmsPort) p).totalChannels();
58 + // OMS ports expose 'lambdaCount' fixed grid lambdas of 50GHz width, starting from min-frequency 191.7 THz.
59 + return IntStream.rangeClosed(1, lambdaCount)
60 + .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x))
61 + .collect(Collectors.toSet());
62 + }
63 +}
...@@ -175,6 +175,8 @@ ...@@ -175,6 +175,8 @@
175 impl="org.onosproject.driver.handshaker.OFOpticalSwitch13"/> 175 impl="org.onosproject.driver.handshaker.OFOpticalSwitch13"/>
176 <behaviour api="org.onosproject.net.behaviour.TributarySlotQuery" 176 <behaviour api="org.onosproject.net.behaviour.TributarySlotQuery"
177 impl="org.onosproject.driver.query.DefaultTributarySlotQuery" /> 177 impl="org.onosproject.driver.query.DefaultTributarySlotQuery" />
178 + <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
179 + impl="org.onosproject.driver.query.OFOpticalSwitch13LambdaQuery"/>
178 </driver> 180 </driver>
179 <driver name="aos" extends="ofdpa" 181 <driver name="aos" extends="ofdpa"
180 manufacturer="Accton" hwVersion=".*" swVersion="1.*"> 182 manufacturer="Accton" hwVersion=".*" swVersion="1.*">
......
...@@ -123,7 +123,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -123,7 +123,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
123 //TODO consider renaming KBPS and MBPS (as they are used to convert by division) 123 //TODO consider renaming KBPS and MBPS (as they are used to convert by division)
124 private static final long KBPS = 1_000; 124 private static final long KBPS = 1_000;
125 private static final long MBPS = 1_000 * 1_000; 125 private static final long MBPS = 1_000 * 1_000;
126 - private static final Frequency FREQ100 = Frequency.ofGHz(100); 126 + private static final Frequency FREQ50 = Frequency.ofGHz(50);
127 + private static final Frequency FREQ191_7 = Frequency.ofGHz(191_700);
127 private static final Frequency FREQ4_4 = Frequency.ofGHz(4_400); 128 private static final Frequency FREQ4_4 = Frequency.ofGHz(4_400);
128 129
129 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 130 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
...@@ -598,7 +599,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -598,7 +599,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
598 switch (sigType) { 599 switch (sigType) {
599 case OMSN: 600 case OMSN:
600 portDes = new OmsPortDescription(portNo, enabled, 601 portDes = new OmsPortDescription(portNo, enabled,
601 - Spectrum.CENTER_FREQUENCY, Spectrum.CENTER_FREQUENCY.add(FREQ4_4), FREQ100, annotations); 602 + FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations);
602 break; 603 break;
603 case OCH: 604 case OCH:
604 OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0); 605 OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0);
......