blob: d4e9c06fa27cb9ef03c17b0b7cf2903fd32f6127 [file] [log] [blame]
Diego Garciaaab99472019-01-10 13:53:31 +01001/*
2 * Copyright 2018-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 * This work was partially supported by EC H2020 project METRO-HAUL (761727).
17 */
18package org.onosproject.drivers.odtn.tapi;
19
20import org.onosproject.net.ChannelSpacing;
21
22/**
23 * Tapi 2.1 OLS device related helpers.
24 */
25public final class TapiDeviceHelper {
26
27 public static final String SERVICE_INTERFACE_POINT = "service-interface-point";
28 public static final String UUID = "uuid";
29 public static final String MEDIA_CHANNEL_SERVICE_INTERFACE_POINT_SPEC =
30 "media-channel-service-interface-point-spec";
31 public static final String MC_POOL = "mc-pool";
32 public static final String LAYER_PROTOCOL_NAME = "layer-protocol-name";
33 public static final String PHOTONIC_MEDIA = "PHOTONIC_MEDIA";
34 public static final String SUPPORTED_LAYER_PROTOCOL_QUALIFIER = "supported-layer-protocol-qualifier";
35 public static final String PHOTONIC_LAYER_QUALIFIER_NMC = "PHOTONIC_LAYER_QUALIFIER_NMC";
36 public static final String FREQUENCY_CONSTRAINT = "frequency-constraint";
37 public static final String GRID_TYPE = "grid-type";
38 public static final String ADJUSTMENT_GRANULARITY = "adjustment-granularity";
39 public static final String UPPER_FREQUENCY = "upper-frequency";
40 public static final String LOWER_FREQUENCY = "lower-frequency";
41 public static final String AVAILABLE_SPECTRUM = "available-spectrum";
42 public static final long BASE_FREQUENCY = 193100000; //Working in Mhz
Andrea Campanella2bdf2042019-01-28 13:47:11 +010043 public static final String TAPI_CONNECTIVITY_CONNECTIVITY_SERVICE = "tapi-connectivity:connectivity-service";
44 public static final String END_POINT = "end-point";
45 public static final String SERVICE_LAYER = "service-layer";
46 public static final String SERVICE_TYPE = "service-type";
47 public static final String POINT_TO_POINT_CONNECTIVITY = "POINT_TO_POINT_CONNECTIVITY";
48 public static final String LOCAL_ID = "local-id";
49 public static final String LAYER_PROTOCOL_QUALIFIER = "layer-protocol-qualifier";
50 public static final String TAPI_PHOTONIC_MEDIA_PHOTONIC_LAYER_QUALIFIER_NMC =
51 "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_NMC";
52 public static final String SERVICE_INTERFACE_POINT_UUID = "service-interface-point-uuid";
Diego Garciaaab99472019-01-10 13:53:31 +010053
54 private TapiDeviceHelper(){}
55
56 /**
57 * Returns the slot granularity corresponding to a channelSpacing.
58 *
59 * @param chSpacing OchSingal channel spacing {@link ChannelSpacing}
60 * @return OchSignal slot width granularity
61 */
62 public static int getSlotGranularity(ChannelSpacing chSpacing) {
63 if (chSpacing.equals(ChannelSpacing.CHL_100GHZ)) {
64 return 8;
65 } else if (chSpacing.equals(ChannelSpacing.CHL_50GHZ)) {
66 return 4;
67 } else if (chSpacing.equals(ChannelSpacing.CHL_25GHZ)) {
68 return 2;
69 } else if (chSpacing.equals(ChannelSpacing.CHL_12P5GHZ)) {
70 return 1;
71 } else {
72 return 0;
73 }
74 }
75
76 /**
77 * Returns the ChannelSpacing corresponding to an adjustmentGranularity.
78 *
79 * @param adjustmentGranularity {@link String}
80 * @return OchSingnal ChannelSpacing {@link ChannelSpacing}
81 */
82 public static ChannelSpacing getChannelSpacing(String adjustmentGranularity) {
83 switch (adjustmentGranularity) {
84 case "G_100GHZ ":
85 return ChannelSpacing.CHL_100GHZ;
86 case "G_50GHZ":
87 return ChannelSpacing.CHL_50GHZ;
88 case "G_25GHZ":
89 return ChannelSpacing.CHL_25GHZ;
90 case "G_12_5GHZ ":
91 return ChannelSpacing.CHL_12P5GHZ;
92 case "G_6_25GHZ ":
93 return ChannelSpacing.CHL_6P25GHZ;
94 default:
95 return ChannelSpacing.CHL_0GHZ;
96 }
97 }
98
99 /**
100 * To Mbps conversion from Hz.
101 *
102 * @param speed the speed in Hz
103 * @return the speed in Mbps
104 */
105 public static long toMbpsFromHz(long speed) {
106 return speed / 1000000;
107 }
108}