Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.provider.of.device.impl; |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 17 | |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 18 | import com.google.common.base.Strings; |
| 19 | import com.google.common.collect.Lists; |
| 20 | import com.google.common.collect.Maps; |
| 21 | import com.google.common.collect.Sets; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 22 | |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 26 | import org.apache.felix.scr.annotations.Modified; |
| 27 | import org.apache.felix.scr.annotations.Property; |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 28 | import org.apache.felix.scr.annotations.Reference; |
| 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 30 | import org.onlab.packet.ChassisId; |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 31 | import org.onlab.util.Frequency; |
| 32 | import org.onlab.util.Spectrum; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 33 | import org.onosproject.cfg.ComponentConfigService; |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 34 | import org.onosproject.net.AnnotationKeys; |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 35 | import org.onosproject.net.ChannelSpacing; |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 36 | import org.onosproject.net.CltSignalType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 37 | import org.onosproject.net.DefaultAnnotations; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 38 | import org.onosproject.net.Device; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 39 | import org.onosproject.net.DeviceId; |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 40 | import org.onosproject.net.GridType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 41 | import org.onosproject.net.MastershipRole; |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 42 | import org.onosproject.net.OchSignal; |
| 43 | import org.onosproject.net.OduSignalType; |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 44 | import org.onosproject.net.OtuSignalType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 45 | import org.onosproject.net.Port; |
| 46 | import org.onosproject.net.PortNumber; |
| 47 | import org.onosproject.net.SparseAnnotations; |
| 48 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 49 | import org.onosproject.net.device.DefaultPortDescription; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 50 | import org.onosproject.net.device.DefaultPortStatistics; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 51 | import org.onosproject.net.device.DeviceDescription; |
| 52 | import org.onosproject.net.device.DeviceProvider; |
| 53 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 54 | import org.onosproject.net.device.DeviceProviderService; |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 55 | import org.onosproject.net.device.OchPortDescription; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 56 | import org.onosproject.net.device.OduCltPortDescription; |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 57 | import org.onosproject.net.device.OmsPortDescription; |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 58 | import org.onosproject.net.device.OtuPortDescription; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 59 | import org.onosproject.net.device.PortDescription; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 60 | import org.onosproject.net.device.PortStatistics; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 61 | import org.onosproject.net.provider.AbstractProvider; |
| 62 | import org.onosproject.net.provider.ProviderId; |
| 63 | import org.onosproject.openflow.controller.Dpid; |
| 64 | import org.onosproject.openflow.controller.OpenFlowController; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 65 | import org.onosproject.openflow.controller.OpenFlowEventListener; |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 66 | import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 67 | import org.onosproject.openflow.controller.OpenFlowSwitch; |
| 68 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 69 | import org.onosproject.openflow.controller.PortDescPropertyType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 70 | import org.onosproject.openflow.controller.RoleState; |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 71 | import org.osgi.service.component.ComponentContext; |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 72 | import org.projectfloodlight.openflow.protocol.OFCalientPortDescProp; |
| 73 | import org.projectfloodlight.openflow.protocol.OFCalientPortDescPropOptical; |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 74 | import org.projectfloodlight.openflow.protocol.OFCalientPortDescStatsEntry; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 75 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
| 76 | import org.projectfloodlight.openflow.protocol.OFErrorType; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 77 | import org.projectfloodlight.openflow.protocol.OFExpPort; |
| 78 | import org.projectfloodlight.openflow.protocol.OFExpPortDescPropOpticalTransport; |
| 79 | import org.projectfloodlight.openflow.protocol.OFExpPortOpticalTransportLayerEntry; |
Ayaka Koshibe | e8708e3 | 2014-10-22 13:40:18 -0700 | [diff] [blame] | 80 | import org.projectfloodlight.openflow.protocol.OFFactory; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 81 | import org.projectfloodlight.openflow.protocol.OFMessage; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 82 | import org.projectfloodlight.openflow.protocol.OFObject; |
alshabib | 4680bb6 | 2014-09-04 17:15:08 -0700 | [diff] [blame] | 83 | import org.projectfloodlight.openflow.protocol.OFPortConfig; |
alshabib | 25c8eec | 2014-09-04 16:41:31 -0700 | [diff] [blame] | 84 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 85 | import org.projectfloodlight.openflow.protocol.OFPortDescPropOpticalTransport; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 86 | import org.projectfloodlight.openflow.protocol.OFPortFeatures; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 87 | import org.projectfloodlight.openflow.protocol.OFPortMod; |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 88 | import org.projectfloodlight.openflow.protocol.OFPortOptical; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 89 | import org.projectfloodlight.openflow.protocol.OFPortOpticalTransportLayerClass; |
| 90 | import org.projectfloodlight.openflow.protocol.OFPortOpticalTransportSignalType; |
alshabib | afc514a | 2014-12-01 14:44:05 -0800 | [diff] [blame] | 91 | import org.projectfloodlight.openflow.protocol.OFPortReason; |
alshabib | 4680bb6 | 2014-09-04 17:15:08 -0700 | [diff] [blame] | 92 | import org.projectfloodlight.openflow.protocol.OFPortState; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 93 | import org.projectfloodlight.openflow.protocol.OFPortStatsEntry; |
| 94 | import org.projectfloodlight.openflow.protocol.OFPortStatsReply; |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 95 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 96 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 97 | import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 98 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 99 | import org.projectfloodlight.openflow.protocol.OFVersion; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 100 | import org.projectfloodlight.openflow.types.OFPort; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 101 | import org.projectfloodlight.openflow.types.PortSpeed; |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 102 | import org.slf4j.Logger; |
tom | 5f38b3a | 2014-08-27 23:50:54 -0700 | [diff] [blame] | 103 | |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 104 | import java.util.ArrayList; |
| 105 | import java.util.Collection; |
| 106 | import java.util.Collections; |
| 107 | import java.util.Dictionary; |
| 108 | import java.util.HashMap; |
| 109 | import java.util.HashSet; |
| 110 | import java.util.List; |
| 111 | |
| 112 | import static com.google.common.base.Preconditions.checkArgument; |
| 113 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 114 | import static org.onlab.util.Tools.get; |
| 115 | import static org.onosproject.net.DeviceId.deviceId; |
| 116 | import static org.onosproject.net.Port.Type.COPPER; |
| 117 | import static org.onosproject.net.Port.Type.FIBER; |
| 118 | import static org.onosproject.openflow.controller.Dpid.dpid; |
| 119 | import static org.onosproject.openflow.controller.Dpid.uri; |
| 120 | import static org.slf4j.LoggerFactory.getLogger; |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 121 | |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 122 | /** |
tom | b1260e4 | 2014-08-26 18:39:57 -0700 | [diff] [blame] | 123 | * Provider which uses an OpenFlow controller to detect network |
tom | e06f855 | 2014-08-26 16:58:42 -0700 | [diff] [blame] | 124 | * infrastructure devices. |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 125 | */ |
tom | b1260e4 | 2014-08-26 18:39:57 -0700 | [diff] [blame] | 126 | @Component(immediate = true) |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 127 | public class OpenFlowDeviceProvider extends AbstractProvider implements DeviceProvider { |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 128 | |
alshabib | a89cc58 | 2014-09-09 16:43:00 -0700 | [diff] [blame] | 129 | private static final Logger LOG = getLogger(OpenFlowDeviceProvider.class); |
Thomas Vachuska | d07c092 | 2015-10-06 14:48:06 -0700 | [diff] [blame] | 130 | |
Charles Chan | 25b7732 | 2015-12-13 01:00:56 -0800 | [diff] [blame] | 131 | //TODO consider renaming KBPS and MBPS (as they are used to convert by division) |
| 132 | private static final long KBPS = 1_000; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 133 | private static final long MBPS = 1_000 * 1_000; |
Rimon Ashkenazy | e320103 | 2016-01-11 14:27:30 +0200 | [diff] [blame] | 134 | private static final Frequency FREQ50 = Frequency.ofGHz(50); |
| 135 | private static final Frequency FREQ191_7 = Frequency.ofGHz(191_700); |
Sho SHIMIZU | 00762ee | 2016-01-05 16:32:24 -0800 | [diff] [blame] | 136 | private static final Frequency FREQ4_4 = Frequency.ofGHz(4_400); |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 137 | |
| 138 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
tom | 96dfcab | 2014-08-28 09:26:03 -0700 | [diff] [blame] | 139 | protected DeviceProviderRegistry providerRegistry; |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 140 | |
tom | 5f38b3a | 2014-08-27 23:50:54 -0700 | [diff] [blame] | 141 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 142 | protected OpenFlowController controller; |
| 143 | |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 144 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 145 | protected ComponentConfigService cfgService; |
| 146 | |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 147 | private DeviceProviderService providerService; |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 148 | |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 149 | private final InternalDeviceProvider listener = new InternalDeviceProvider(); |
| 150 | |
| 151 | // TODO: We need to make the poll interval configurable. |
Srikanth Vavilapalli | 78baf58 | 2015-06-05 11:40:14 -0700 | [diff] [blame] | 152 | static final int POLL_INTERVAL = 5; |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 153 | @Property(name = "PortStatsPollFrequency", intValue = POLL_INTERVAL, |
| 154 | label = "Frequency (in seconds) for polling switch Port statistics") |
| 155 | private int portStatsPollFrequency = POLL_INTERVAL; |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 156 | |
| 157 | private HashMap<Dpid, PortStatsCollector> collectors = Maps.newHashMap(); |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 158 | |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 159 | /** |
| 160 | * Creates an OpenFlow device provider. |
| 161 | */ |
| 162 | public OpenFlowDeviceProvider() { |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 163 | super(new ProviderId("of", "org.onosproject.provider.openflow")); |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 164 | } |
| 165 | |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 166 | @Activate |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 167 | public void activate(ComponentContext context) { |
| 168 | cfgService.registerProperties(getClass()); |
tom | 96dfcab | 2014-08-28 09:26:03 -0700 | [diff] [blame] | 169 | providerService = providerRegistry.register(this); |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 170 | controller.addListener(listener); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 171 | controller.addEventListener(listener); |
Jian Li | 152b885 | 2015-12-07 14:47:25 -0800 | [diff] [blame] | 172 | |
Thomas Vachuska | d07c092 | 2015-10-06 14:48:06 -0700 | [diff] [blame] | 173 | connectInitialDevices(); |
alshabib | a89cc58 | 2014-09-09 16:43:00 -0700 | [diff] [blame] | 174 | LOG.info("Started"); |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | @Deactivate |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 178 | public void deactivate(ComponentContext context) { |
| 179 | cfgService.unregisterProperties(getClass(), false); |
tom | d40fc7a | 2014-09-04 16:41:10 -0700 | [diff] [blame] | 180 | controller.removeListener(listener); |
Thomas Vachuska | d07c092 | 2015-10-06 14:48:06 -0700 | [diff] [blame] | 181 | providerRegistry.unregister(this); |
Thomas Vachuska | 74bcd92 | 2015-06-02 13:08:57 -0700 | [diff] [blame] | 182 | collectors.values().forEach(PortStatsCollector::stop); |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 183 | providerService = null; |
alshabib | a89cc58 | 2014-09-09 16:43:00 -0700 | [diff] [blame] | 184 | LOG.info("Stopped"); |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Dusan Pajin | bab8a5e | 2015-07-24 17:37:19 +0200 | [diff] [blame] | 187 | @Modified |
| 188 | public void modified(ComponentContext context) { |
| 189 | Dictionary<?, ?> properties = context.getProperties(); |
| 190 | int newPortStatsPollFrequency; |
| 191 | try { |
| 192 | String s = get(properties, "PortStatsPollFrequency"); |
| 193 | newPortStatsPollFrequency = isNullOrEmpty(s) ? portStatsPollFrequency : Integer.parseInt(s.trim()); |
| 194 | |
| 195 | } catch (NumberFormatException | ClassCastException e) { |
| 196 | newPortStatsPollFrequency = portStatsPollFrequency; |
| 197 | } |
| 198 | |
| 199 | if (newPortStatsPollFrequency != portStatsPollFrequency) { |
| 200 | portStatsPollFrequency = newPortStatsPollFrequency; |
| 201 | collectors.values().forEach(psc -> psc.adjustPollInterval(portStatsPollFrequency)); |
| 202 | } |
| 203 | |
| 204 | LOG.info("Settings: portStatsPollFrequency={}", portStatsPollFrequency); |
| 205 | } |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 206 | |
Thomas Vachuska | d07c092 | 2015-10-06 14:48:06 -0700 | [diff] [blame] | 207 | private void connectInitialDevices() { |
| 208 | for (OpenFlowSwitch sw : controller.getSwitches()) { |
| 209 | try { |
| 210 | listener.switchAdded(new Dpid(sw.getId())); |
| 211 | } catch (Exception e) { |
| 212 | LOG.warn("Failed initially adding {} : {}", sw.getStringId(), e.getMessage()); |
| 213 | LOG.debug("Error details:", e); |
| 214 | // disconnect to trigger switch-add later |
| 215 | sw.disconnectSwitch(); |
| 216 | } |
| 217 | PortStatsCollector psc = new PortStatsCollector(sw, portStatsPollFrequency); |
| 218 | psc.start(); |
| 219 | collectors.put(new Dpid(sw.getId()), psc); |
| 220 | } |
| 221 | } |
| 222 | |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 223 | @Override |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 224 | public boolean isReachable(DeviceId deviceId) { |
| 225 | OpenFlowSwitch sw = controller.getSwitch(dpid(deviceId.uri())); |
Thomas Vachuska | d07c092 | 2015-10-06 14:48:06 -0700 | [diff] [blame] | 226 | return sw != null && sw.isConnected(); |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 227 | } |
| 228 | |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 229 | @Override |
Ayaka Koshibe | 78bcbc1 | 2014-11-19 14:28:58 -0800 | [diff] [blame] | 230 | public void triggerProbe(DeviceId deviceId) { |
Madan Jampani | c332876 | 2015-05-31 12:39:27 -0700 | [diff] [blame] | 231 | LOG.debug("Triggering probe on device {}", deviceId); |
Ayaka Koshibe | e8708e3 | 2014-10-22 13:40:18 -0700 | [diff] [blame] | 232 | |
Yuta HIGUCHI | 802d0e8 | 2014-10-31 16:07:37 -0700 | [diff] [blame] | 233 | final Dpid dpid = dpid(deviceId.uri()); |
| 234 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 235 | if (sw == null || !sw.isConnected()) { |
Ayaka Koshibe | 78bcbc1 | 2014-11-19 14:28:58 -0800 | [diff] [blame] | 236 | LOG.error("Failed to probe device {} on sw={}", deviceId, sw); |
Yuta HIGUCHI | 802d0e8 | 2014-10-31 16:07:37 -0700 | [diff] [blame] | 237 | providerService.deviceDisconnected(deviceId); |
Thomas Vachuska | 74bcd92 | 2015-06-02 13:08:57 -0700 | [diff] [blame] | 238 | return; |
Yuta HIGUCHI | 802d0e8 | 2014-10-31 16:07:37 -0700 | [diff] [blame] | 239 | } else { |
Ayaka Koshibe | 78bcbc1 | 2014-11-19 14:28:58 -0800 | [diff] [blame] | 240 | LOG.trace("Confirmed device {} connection", deviceId); |
Yuta HIGUCHI | 802d0e8 | 2014-10-31 16:07:37 -0700 | [diff] [blame] | 241 | } |
Ayaka Koshibe | e8708e3 | 2014-10-22 13:40:18 -0700 | [diff] [blame] | 242 | |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 243 | // Prompt an update of port information. We can use any XID for this. |
Ayaka Koshibe | e8708e3 | 2014-10-22 13:40:18 -0700 | [diff] [blame] | 244 | OFFactory fact = sw.factory(); |
| 245 | switch (fact.getVersion()) { |
| 246 | case OF_10: |
| 247 | sw.sendMsg(fact.buildFeaturesRequest().setXid(0).build()); |
| 248 | break; |
| 249 | case OF_13: |
| 250 | sw.sendMsg(fact.buildPortDescStatsRequest().setXid(0).build()); |
| 251 | break; |
| 252 | default: |
| 253 | LOG.warn("Unhandled protocol version"); |
| 254 | } |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | @Override |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 258 | public void roleChanged(DeviceId deviceId, MastershipRole newRole) { |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 259 | switch (newRole) { |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 260 | case MASTER: |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 261 | controller.setRole(dpid(deviceId.uri()), RoleState.MASTER); |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 262 | break; |
| 263 | case STANDBY: |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 264 | controller.setRole(dpid(deviceId.uri()), RoleState.EQUAL); |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 265 | break; |
| 266 | case NONE: |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 267 | controller.setRole(dpid(deviceId.uri()), RoleState.SLAVE); |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 268 | break; |
| 269 | default: |
| 270 | LOG.error("Unknown Mastership state : {}", newRole); |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 271 | |
| 272 | } |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 273 | LOG.debug("Accepting mastership role change to {} for device {}", newRole, deviceId); |
tom | ab21e7c | 2014-08-26 15:23:08 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 276 | @Override |
| 277 | public void changePortState(DeviceId deviceId, PortNumber portNumber, |
| 278 | boolean enable) { |
| 279 | final Dpid dpid = dpid(deviceId.uri()); |
| 280 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 281 | if (sw == null || !sw.isConnected()) { |
| 282 | LOG.error("Failed to change portState on device {}", deviceId); |
| 283 | return; |
| 284 | } |
| 285 | OFPortMod.Builder pmb = sw.factory().buildPortMod(); |
| 286 | OFPort port = OFPort.of((int) portNumber.toLong()); |
| 287 | pmb.setPortNo(port); |
| 288 | if (enable) { |
| 289 | pmb.setConfig(0x0); // port_down bit 0 |
| 290 | } else { |
| 291 | pmb.setConfig(0x1); // port_down bit 1 |
| 292 | } |
| 293 | pmb.setMask(0x1); |
| 294 | pmb.setAdvertise(0x0); |
| 295 | for (OFPortDesc pd : sw.getPorts()) { |
| 296 | if (pd.getPortNo().equals(port)) { |
| 297 | pmb.setHwAddr(pd.getHwAddr()); |
| 298 | break; |
| 299 | } |
| 300 | } |
| 301 | sw.sendMsg(Collections.singletonList(pmb.build())); |
| 302 | } |
| 303 | |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 304 | private void pushPortMetrics(Dpid dpid, List<OFPortStatsEntry> portStatsEntries) { |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 305 | DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid)); |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 306 | Collection<PortStatistics> stats = buildPortStatistics(deviceId, portStatsEntries); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 307 | providerService.updatePortStatistics(deviceId, stats); |
| 308 | } |
| 309 | |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 310 | private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId, |
| 311 | List<OFPortStatsEntry> entries) { |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 312 | HashSet<PortStatistics> stats = Sets.newHashSet(); |
| 313 | |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 314 | for (OFPortStatsEntry entry : entries) { |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 315 | try { |
Thomas Vachuska | 4e6025e | 2015-06-03 11:25:21 -0700 | [diff] [blame] | 316 | if (entry == null || entry.getPortNo() == null || entry.getPortNo().getPortNumber() < 0) { |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 317 | continue; |
| 318 | } |
| 319 | DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder(); |
| 320 | DefaultPortStatistics stat = builder.setDeviceId(deviceId) |
| 321 | .setPort(entry.getPortNo().getPortNumber()) |
| 322 | .setPacketsReceived(entry.getRxPackets().getValue()) |
| 323 | .setPacketsSent(entry.getTxPackets().getValue()) |
| 324 | .setBytesReceived(entry.getRxBytes().getValue()) |
| 325 | .setBytesSent(entry.getTxBytes().getValue()) |
| 326 | .setPacketsRxDropped(entry.getRxDropped().getValue()) |
| 327 | .setPacketsTxDropped(entry.getTxDropped().getValue()) |
| 328 | .setPacketsRxErrors(entry.getRxErrors().getValue()) |
| 329 | .setPacketsTxErrors(entry.getTxErrors().getValue()) |
| 330 | .setDurationSec(entry.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationSec()) |
| 331 | .setDurationNano(entry.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationNsec()) |
| 332 | .build(); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 333 | |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 334 | stats.add(stat); |
| 335 | } catch (Exception e) { |
| 336 | LOG.warn("Unable to process port stats", e); |
| 337 | } |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | return Collections.unmodifiableSet(stats); |
| 341 | |
| 342 | } |
| 343 | |
| 344 | private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener { |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 345 | |
Srikanth Vavilapalli | 78baf58 | 2015-06-05 11:40:14 -0700 | [diff] [blame] | 346 | private HashMap<Dpid, List<OFPortStatsEntry>> portStatsReplies = new HashMap<>(); |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 347 | |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 348 | @Override |
tom | d1900f3 | 2014-09-03 14:08:16 -0700 | [diff] [blame] | 349 | public void switchAdded(Dpid dpid) { |
alshabib | 6f5460b | 2014-09-03 14:46:17 -0700 | [diff] [blame] | 350 | if (providerService == null) { |
| 351 | return; |
| 352 | } |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 353 | DeviceId did = deviceId(uri(dpid)); |
alshabib | 6f5460b | 2014-09-03 14:46:17 -0700 | [diff] [blame] | 354 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
Lei Xu | dee1aff | 2015-10-16 00:45:10 -0500 | [diff] [blame] | 355 | if (sw == null) { |
| 356 | return; |
| 357 | } |
alshabib | 6f5460b | 2014-09-03 14:46:17 -0700 | [diff] [blame] | 358 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 359 | ChassisId cId = new ChassisId(dpid.value()); |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 360 | |
Thomas Vachuska | 82041f5 | 2014-11-30 22:14:02 -0800 | [diff] [blame] | 361 | SparseAnnotations annotations = DefaultAnnotations.builder() |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 362 | .set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString()) |
| 363 | .set(AnnotationKeys.CHANNEL_ID, sw.channelId()) |
| 364 | .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0]) |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 365 | .build(); |
| 366 | |
tom | d1900f3 | 2014-09-03 14:08:16 -0700 | [diff] [blame] | 367 | DeviceDescription description = |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 368 | new DefaultDeviceDescription(did.uri(), sw.deviceType(), |
Ray Milkey | d3edd03 | 2015-01-16 11:38:58 -0800 | [diff] [blame] | 369 | sw.manufacturerDescription(), |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 370 | sw.hardwareDescription(), |
| 371 | sw.softwareDescription(), |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 372 | sw.serialNumber(), |
Thomas Vachuska | 82041f5 | 2014-11-30 22:14:02 -0800 | [diff] [blame] | 373 | cId, annotations); |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 374 | providerService.deviceConnected(did, description); |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 375 | providerService.updatePorts(did, buildPortDescriptions(sw)); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 376 | |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 377 | PortStatsCollector psc = |
Lei Xu | dee1aff | 2015-10-16 00:45:10 -0500 | [diff] [blame] | 378 | new PortStatsCollector(sw, portStatsPollFrequency); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 379 | psc.start(); |
| 380 | collectors.put(dpid, psc); |
Lei Xu | dee1aff | 2015-10-16 00:45:10 -0500 | [diff] [blame] | 381 | |
| 382 | //figure out race condition for collectors.remove() and collectors.put() |
| 383 | if (controller.getSwitch(dpid) == null) { |
| 384 | switchRemoved(dpid); |
| 385 | } |
alshabib | 25c8eec | 2014-09-04 16:41:31 -0700 | [diff] [blame] | 386 | } |
| 387 | |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 388 | @Override |
| 389 | public void switchRemoved(Dpid dpid) { |
alshabib | 6f5460b | 2014-09-03 14:46:17 -0700 | [diff] [blame] | 390 | if (providerService == null) { |
| 391 | return; |
| 392 | } |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 393 | providerService.deviceDisconnected(deviceId(uri(dpid))); |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 394 | |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 395 | PortStatsCollector collector = collectors.remove(dpid); |
| 396 | if (collector != null) { |
| 397 | collector.stop(); |
| 398 | } |
| 399 | } |
Ayaka Koshibe | 38594c2 | 2014-10-22 13:36:12 -0700 | [diff] [blame] | 400 | |
| 401 | @Override |
| 402 | public void switchChanged(Dpid dpid) { |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 403 | LOG.debug("switchChanged({})", dpid); |
Ayaka Koshibe | 38594c2 | 2014-10-22 13:36:12 -0700 | [diff] [blame] | 404 | if (providerService == null) { |
| 405 | return; |
| 406 | } |
| 407 | DeviceId did = deviceId(uri(dpid)); |
| 408 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
Lei Xu | dee1aff | 2015-10-16 00:45:10 -0500 | [diff] [blame] | 409 | if (sw == null) { |
| 410 | return; |
| 411 | } |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 412 | final List<PortDescription> ports = buildPortDescriptions(sw); |
| 413 | LOG.debug("switchChanged({}) {}", did, ports); |
| 414 | providerService.updatePorts(did, ports); |
Ayaka Koshibe | 38594c2 | 2014-10-22 13:36:12 -0700 | [diff] [blame] | 415 | } |
| 416 | |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 417 | @Override |
| 418 | public void portChanged(Dpid dpid, OFPortStatus status) { |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 419 | LOG.debug("portChanged({},{})", dpid, status); |
alshabib | afc514a | 2014-12-01 14:44:05 -0800 | [diff] [blame] | 420 | PortDescription portDescription = buildPortDescription(status); |
tom | 782a7cf | 2014-09-11 23:58:38 -0700 | [diff] [blame] | 421 | providerService.portStatusChanged(deviceId(uri(dpid)), portDescription); |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 424 | @Override |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 425 | public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) { |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 426 | LOG.debug("receivedRoleReply({},{},{})", dpid, requested, response); |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 427 | MastershipRole request = roleOf(requested); |
| 428 | MastershipRole reply = roleOf(response); |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 429 | providerService.receivedRoleReply(deviceId(uri(dpid)), request, reply); |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Translates a RoleState to the corresponding MastershipRole. |
| 434 | * |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 435 | * @param response role state |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 436 | * @return a MastershipRole |
| 437 | */ |
| 438 | private MastershipRole roleOf(RoleState response) { |
| 439 | switch (response) { |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 440 | case MASTER: |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 441 | return MastershipRole.MASTER; |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 442 | case EQUAL: |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 443 | return MastershipRole.STANDBY; |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 444 | case SLAVE: |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 445 | return MastershipRole.NONE; |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 446 | default: |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 447 | LOG.warn("unknown role {}", response); |
| 448 | return null; |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 449 | } |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 450 | } |
| 451 | |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 452 | /** |
| 453 | * Builds a list of port descriptions for a given list of ports. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 454 | * |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 455 | * @return list of portdescriptions |
| 456 | */ |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 457 | private List<PortDescription> buildPortDescriptions(OpenFlowSwitch sw) { |
| 458 | final List<PortDescription> portDescs = new ArrayList<>(sw.getPorts().size()); |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 459 | if (!((Device.Type.ROADM.equals(sw.deviceType())) || |
| 460 | (Device.Type.OTN.equals(sw.deviceType())))) { |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 461 | sw.getPorts().forEach(port -> portDescs.add(buildPortDescription(port))); |
| 462 | } |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 463 | |
| 464 | OpenFlowOpticalSwitch opsw; |
| 465 | switch (sw.deviceType()) { |
| 466 | case ROADM: |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 467 | case OTN: |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 468 | opsw = (OpenFlowOpticalSwitch) sw; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 469 | List<OFPortDesc> ports = opsw.getPorts(); |
| 470 | LOG.debug("SW ID {} , ETH- ODU CLT Ports {}", opsw.getId(), ports); |
| 471 | // ODU client ports are reported as ETH |
| 472 | ports.forEach(port -> portDescs.add(buildOduCltPortDescription(port))); |
| 473 | |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 474 | opsw.getPortTypes().forEach(type -> { |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 475 | List<? extends OFObject> portsOf = opsw.getPortsOf(type); |
| 476 | LOG.debug("Ports Of{}", portsOf); |
| 477 | portsOf.forEach( |
| 478 | op -> { |
HIGUCHI Yuta | 1979f55 | 2015-12-28 21:24:26 -0800 | [diff] [blame] | 479 | portDescs.add(buildPortDescription(type, op)); |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 480 | } |
| 481 | ); |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 482 | }); |
| 483 | break; |
| 484 | case FIBER_SWITCH: |
| 485 | opsw = (OpenFlowOpticalSwitch) sw; |
| 486 | opsw.getPortTypes().forEach(type -> { |
| 487 | opsw.getPortsOf(type).forEach( |
| 488 | op -> { |
| 489 | portDescs.add(buildPortDescription((OFCalientPortDescStatsEntry) op)); |
| 490 | } |
| 491 | ); |
| 492 | }); |
| 493 | break; |
| 494 | default: |
| 495 | break; |
alshabib | 4680bb6 | 2014-09-04 17:15:08 -0700 | [diff] [blame] | 496 | } |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 497 | |
alshabib | 4680bb6 | 2014-09-04 17:15:08 -0700 | [diff] [blame] | 498 | return portDescs; |
| 499 | } |
| 500 | |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 501 | private PortDescription buildOduCltPortDescription(OFPortDesc port) { |
| 502 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 503 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) && |
| 504 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 505 | Long portSpeedInMbps = portSpeed(port); |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 506 | CltSignalType sigType = null; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 507 | |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 508 | switch (portSpeedInMbps.toString()) { |
| 509 | case "1000": |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 510 | sigType = CltSignalType.CLT_1GBE; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 511 | break; |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 512 | case "10000": |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 513 | sigType = CltSignalType.CLT_10GBE; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 514 | break; |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 515 | case "40000": |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 516 | sigType = CltSignalType.CLT_40GBE; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 517 | break; |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 518 | case "100000": |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 519 | sigType = CltSignalType.CLT_100GBE; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 520 | break; |
| 521 | default: |
Rimon Ashkenazy | d15ebf5 | 2016-01-06 14:36:13 +0200 | [diff] [blame] | 522 | throw new RuntimeException("Un recognize OduClt speed: " + portSpeedInMbps.toString()); |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | SparseAnnotations annotations = buildOduCltAnnotation(port); |
| 526 | return new OduCltPortDescription(portNo, enabled, sigType, annotations); |
| 527 | } |
| 528 | |
| 529 | private SparseAnnotations buildOduCltAnnotation(OFPortDesc port) { |
| 530 | SparseAnnotations annotations = null; |
| 531 | String portName = Strings.emptyToNull(port.getName()); |
| 532 | if (portName != null) { |
| 533 | annotations = DefaultAnnotations.builder() |
| 534 | .set(AnnotationKeys.PORT_NAME, portName) |
| 535 | .set(AnnotationKeys.STATIC_PORT, Boolean.TRUE.toString()).build(); |
| 536 | } |
| 537 | return annotations; |
| 538 | } |
| 539 | |
| 540 | private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port) { |
| 541 | if (port instanceof OFPortOptical) { |
| 542 | return buildPortDescription(ptype, (OFPortOptical) port); |
| 543 | } |
| 544 | return buildPortDescription(ptype, (OFExpPort) port); |
| 545 | } |
| 546 | |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 547 | private boolean matchingOtuPortSignalTypes(OFPortOpticalTransportSignalType sigType, |
| 548 | OduSignalType oduSignalType) { |
| 549 | switch (sigType) { |
| 550 | case OTU2: |
| 551 | if (oduSignalType == OduSignalType.ODU2) { |
| 552 | return true; |
| 553 | } |
| 554 | break; |
| 555 | case OTU4: |
| 556 | if (oduSignalType == OduSignalType.ODU4) { |
| 557 | return true; |
| 558 | } |
| 559 | break; |
| 560 | default: |
| 561 | break; |
| 562 | } |
| 563 | return false; |
| 564 | } |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 565 | /** |
| 566 | * Build a portDescription from a given a port description describing some |
| 567 | * Optical port. |
| 568 | * |
| 569 | * @param ptype description property type. |
| 570 | * @param port the port to build from. |
| 571 | * @return portDescription for the port. |
| 572 | */ |
| 573 | private PortDescription buildPortDescription(PortDescPropertyType ptype, OFExpPort port) { |
| 574 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 575 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) |
| 576 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 577 | SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 578 | |
| 579 | OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0); |
| 580 | OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType(); |
| 581 | |
| 582 | DefaultPortDescription portDes = null; |
| 583 | switch (sigType) { |
| 584 | case OMSN: |
Sho SHIMIZU | 70e76d8 | 2016-01-05 16:26:26 -0800 | [diff] [blame] | 585 | portDes = new OmsPortDescription(portNo, enabled, |
Rimon Ashkenazy | e320103 | 2016-01-11 14:27:30 +0200 | [diff] [blame] | 586 | FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations); |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 587 | break; |
| 588 | case OCH: |
| 589 | OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0); |
| 590 | OFPortOpticalTransportLayerClass layerClass = entry.getLayerClass(); |
| 591 | if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) { |
| 592 | LOG.error("Unsupported layer Class {} ", layerClass); |
| 593 | return null; |
| 594 | } |
| 595 | |
| 596 | // convert to ONOS OduSignalType |
| 597 | OduSignalType oduSignalType = OpenFlowDeviceValueMapper. |
| 598 | lookupOduSignalType((byte) entry.getSignalType()); |
| 599 | //OchSignal is needed for OchPortDescription constructor, |
| 600 | //yet not relevant for tunable OCH port, creating with default parameters |
| 601 | OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1); |
| 602 | |
| 603 | portDes = new OchPortDescription(portNo, enabled, |
| 604 | oduSignalType, true, signalId, annotations); |
| 605 | |
| 606 | break; |
| 607 | case OTU2: |
| 608 | case OTU4: |
Rimon Ashkenazy | 8ebfff0 | 2016-02-01 11:56:36 +0200 | [diff] [blame] | 609 | entry = firstProp.getFeatures().get(0).getValue().get(0); |
| 610 | layerClass = entry.getLayerClass(); |
| 611 | if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) { |
| 612 | LOG.error("Unsupported layer Class {} ", layerClass); |
| 613 | return null; |
| 614 | } |
| 615 | |
| 616 | // convert to ONOS OduSignalType |
| 617 | OduSignalType oduSignalTypeOtuPort = OpenFlowDeviceValueMapper. |
| 618 | lookupOduSignalType((byte) entry.getSignalType()); |
| 619 | if (!matchingOtuPortSignalTypes(sigType, oduSignalTypeOtuPort)) { |
| 620 | LOG.error("Wrong oduSignalType {} for OTU Port sigType {} ", oduSignalTypeOtuPort, sigType); |
| 621 | return null; |
| 622 | } |
| 623 | OtuSignalType otuSignalType = |
| 624 | ((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 : |
| 625 | OtuSignalType.OTU4); |
| 626 | portDes = new OtuPortDescription(portNo, enabled, otuSignalType, annotations); |
| 627 | break; |
Yafit Hadar | a9a73de | 2015-09-06 13:52:52 +0300 | [diff] [blame] | 628 | default: |
| 629 | break; |
| 630 | } |
| 631 | |
| 632 | return portDes; |
| 633 | } |
| 634 | |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 635 | /** |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 636 | * Creates an annotation for the port name if one is available. |
| 637 | * |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 638 | * @param portName the port name |
| 639 | * @param portMac the port mac |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 640 | * @return annotation containing the port name if one is found, |
| 641 | * null otherwise |
| 642 | */ |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 643 | private SparseAnnotations makePortAnnotation(String portName, String portMac) { |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 644 | SparseAnnotations annotations = null; |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 645 | String pName = Strings.emptyToNull(portName); |
| 646 | String pMac = Strings.emptyToNull(portMac); |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 647 | if (portName != null) { |
| 648 | annotations = DefaultAnnotations.builder() |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 649 | .set(AnnotationKeys.PORT_NAME, pName) |
| 650 | .set(AnnotationKeys.PORT_MAC, pMac).build(); |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 651 | } |
| 652 | return annotations; |
| 653 | } |
| 654 | |
| 655 | /** |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 656 | * Build a portDescription from a given Ethernet port description. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 657 | * |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 658 | * @param port the port to build from. |
| 659 | * @return portDescription for the port. |
| 660 | */ |
| 661 | private PortDescription buildPortDescription(OFPortDesc port) { |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 662 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 663 | boolean enabled = |
| 664 | !port.getState().contains(OFPortState.LINK_DOWN) && |
| 665 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
| 666 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 667 | SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 668 | return new DefaultPortDescription(portNo, enabled, type, |
| 669 | portSpeed(port), annotations); |
alshabib | a14f364 | 2014-09-05 09:31:31 -0700 | [diff] [blame] | 670 | } |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 671 | |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 672 | /** |
| 673 | * Build a portDescription from a given a port description describing some |
| 674 | * Optical port. |
| 675 | * |
| 676 | * @param port description property type. |
| 677 | * @param port the port to build from. |
| 678 | * @return portDescription for the port. |
| 679 | */ |
| 680 | private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) { |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 681 | checkArgument(port.getDesc().size() >= 1); |
| 682 | |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 683 | // Minimally functional fixture. This needs to be fixed as we add better support. |
| 684 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
Ayaka Koshibe | 74b5527 | 2015-05-28 15:16:04 -0700 | [diff] [blame] | 685 | |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 686 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) |
| 687 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 688 | SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 689 | |
| 690 | if (port.getVersion() == OFVersion.OF_13 |
| 691 | && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) { |
| 692 | // At this point, not much is carried in the optical port message. |
Ayaka Koshibe | ae54173 | 2015-05-19 13:37:27 -0700 | [diff] [blame] | 693 | LOG.debug("Optical transport port message {}", port.toString()); |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 694 | } else { |
| 695 | // removable once 1.4+ support complete. |
Ayaka Koshibe | ae54173 | 2015-05-19 13:37:27 -0700 | [diff] [blame] | 696 | LOG.debug("Unsupported optical port properties"); |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 697 | } |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 698 | |
| 699 | OFPortDescPropOpticalTransport desc = port.getDesc().get(0); |
| 700 | switch (desc.getPortSignalType()) { |
| 701 | // FIXME: use constants once loxi has full optical extensions |
| 702 | case 2: // OMS port |
| 703 | // Assume complete optical spectrum and 50 GHz grid |
| 704 | // LINC-OE is only supported optical OF device for now |
| 705 | return new OmsPortDescription(portNo, enabled, |
| 706 | Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); |
| 707 | case 5: // OCH port |
| 708 | OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); |
| 709 | return new OchPortDescription(portNo, enabled, OduSignalType.ODU4, |
| 710 | true, signal, annotations); |
| 711 | default: |
| 712 | break; |
| 713 | } |
| 714 | |
Ayaka Koshibe | 74b5527 | 2015-05-28 15:16:04 -0700 | [diff] [blame] | 715 | return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations); |
Ayaka Koshibe | 5460d62 | 2015-05-14 12:19:19 -0700 | [diff] [blame] | 716 | } |
| 717 | |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 718 | /** |
| 719 | * Build a portDescription from a given port description describing a fiber switch optical port. |
| 720 | * |
| 721 | * @param port description property type. |
| 722 | * @param port the port to build from. |
| 723 | * @return portDescription for the port. |
| 724 | */ |
| 725 | private PortDescription buildPortDescription(OFCalientPortDescStatsEntry port) { |
| 726 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 727 | |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 728 | // Use the alias name if it's available |
| 729 | String name = port.getName(); |
| 730 | List<OFCalientPortDescProp> props = port.getProperties(); |
| 731 | if (props != null && props.size() > 0) { |
| 732 | OFCalientPortDescPropOptical propOptical = (OFCalientPortDescPropOptical) props.get(0); |
| 733 | if (propOptical != null) { |
| 734 | name = propOptical.getInAlias(); |
| 735 | } |
| 736 | } |
| 737 | |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 738 | // FIXME when Calient OF agent reports port status |
| 739 | boolean enabled = true; |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 740 | SparseAnnotations annotations = makePortAnnotation(name, port.getHwAddr().toString()); |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 741 | |
Marc De Leenheer | fc913dd | 2015-07-30 16:04:55 -0700 | [diff] [blame] | 742 | // S160 data sheet |
| 743 | // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch |
| 744 | return new OmsPortDescription(portNo, enabled, |
| 745 | Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(100), annotations); |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 746 | } |
| 747 | |
alshabib | afc514a | 2014-12-01 14:44:05 -0800 | [diff] [blame] | 748 | private PortDescription buildPortDescription(OFPortStatus status) { |
| 749 | OFPortDesc port = status.getDesc(); |
| 750 | if (status.getReason() != OFPortReason.DELETE) { |
| 751 | return buildPortDescription(port); |
| 752 | } else { |
| 753 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 754 | Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 755 | SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()); |
Ray Milkey | e0fade7 | 2015-01-15 13:29:47 -0800 | [diff] [blame] | 756 | return new DefaultPortDescription(portNo, false, type, |
| 757 | portSpeed(port), annotations); |
alshabib | afc514a | 2014-12-01 14:44:05 -0800 | [diff] [blame] | 758 | } |
| 759 | } |
| 760 | |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 761 | private long portSpeed(OFPortDesc port) { |
| 762 | if (port.getVersion() == OFVersion.OF_13) { |
Charles Chan | 25b7732 | 2015-12-13 01:00:56 -0800 | [diff] [blame] | 763 | // Note: getCurrSpeed() returns a value in kbps (this also applies to OF_11 and OF_12) |
| 764 | return port.getCurrSpeed() / KBPS; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | PortSpeed portSpeed = PortSpeed.SPEED_NONE; |
| 768 | for (OFPortFeatures feat : port.getCurr()) { |
| 769 | portSpeed = PortSpeed.max(portSpeed, feat.getPortSpeed()); |
| 770 | } |
Thomas Vachuska | 98eda53 | 2014-10-29 17:31:02 -0700 | [diff] [blame] | 771 | return portSpeed.getSpeedBps() / MBPS; |
Thomas Vachuska | d16ce18 | 2014-10-29 17:25:29 -0700 | [diff] [blame] | 772 | } |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 773 | |
| 774 | @Override |
| 775 | public void handleMessage(Dpid dpid, OFMessage msg) { |
| 776 | switch (msg.getType()) { |
| 777 | case STATS_REPLY: |
| 778 | if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) { |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 779 | OFPortStatsReply portStatsReply = (OFPortStatsReply) msg; |
Srikanth Vavilapalli | 78baf58 | 2015-06-05 11:40:14 -0700 | [diff] [blame] | 780 | List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid); |
| 781 | if (portStatsReplyList == null) { |
| 782 | portStatsReplyList = Lists.newArrayList(); |
| 783 | } |
| 784 | portStatsReplyList.addAll(portStatsReply.getEntries()); |
| 785 | portStatsReplies.put(dpid, portStatsReplyList); |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 786 | if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { |
Srikanth Vavilapalli | 78baf58 | 2015-06-05 11:40:14 -0700 | [diff] [blame] | 787 | pushPortMetrics(dpid, portStatsReplies.get(dpid)); |
| 788 | portStatsReplies.get(dpid).clear(); |
Thomas Vachuska | 893bf4b | 2015-05-29 18:13:18 -0700 | [diff] [blame] | 789 | } |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 790 | } |
| 791 | break; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 792 | case ERROR: |
| 793 | if (((OFErrorMsg) msg).getErrType() == OFErrorType.PORT_MOD_FAILED) { |
| 794 | LOG.error("port mod failed"); |
| 795 | } |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 796 | default: |
| 797 | break; |
| 798 | } |
| 799 | } |
alshabib | f1216ed | 2014-09-03 11:53:54 -0700 | [diff] [blame] | 800 | } |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame^] | 801 | |
| 802 | |
tom | b5a46e6 | 2014-08-26 14:20:00 -0700 | [diff] [blame] | 803 | } |