blob: 0950166aee268245f292f6fc01e62f1dbcd26cb6 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.provider.of.device.impl;
tomb5a46e62014-08-26 14:20:00 -070017
Yafit Hadara9a73de2015-09-06 13:52:52 +030018import static com.google.common.base.Preconditions.checkArgument;
19import static com.google.common.base.Strings.isNullOrEmpty;
20import static org.onlab.util.Tools.get;
21import static org.onosproject.net.DeviceId.deviceId;
22import static org.onosproject.net.Port.Type.COPPER;
23import static org.onosproject.net.Port.Type.FIBER;
24import static org.onosproject.openflow.controller.Dpid.dpid;
25import static org.onosproject.openflow.controller.Dpid.uri;
26import static org.slf4j.LoggerFactory.getLogger;
27
28import java.util.ArrayList;
29import java.util.Collection;
30import java.util.Collections;
31import java.util.Dictionary;
32import java.util.HashMap;
33import java.util.HashSet;
34import java.util.List;
35
tomb5a46e62014-08-26 14:20:00 -070036import org.apache.felix.scr.annotations.Activate;
37import org.apache.felix.scr.annotations.Component;
38import org.apache.felix.scr.annotations.Deactivate;
Dusan Pajinbab8a5e2015-07-24 17:37:19 +020039import org.apache.felix.scr.annotations.Modified;
40import org.apache.felix.scr.annotations.Property;
tomb5a46e62014-08-26 14:20:00 -070041import org.apache.felix.scr.annotations.Reference;
42import org.apache.felix.scr.annotations.ReferenceCardinality;
Thomas Vachuskaf0397b52015-05-29 13:50:17 -070043import org.onlab.packet.ChassisId;
Marc De Leenheerb9311372015-07-09 11:36:49 -070044import org.onlab.util.Frequency;
45import org.onlab.util.Spectrum;
Yafit Hadara9a73de2015-09-06 13:52:52 +030046import org.onosproject.cfg.ComponentConfigService;
Thomas Vachuskab52a0142015-04-21 17:48:15 -070047import org.onosproject.net.AnnotationKeys;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070048import org.onosproject.net.ChannelSpacing;
Brian O'Connorabafb502014-12-02 22:26:20 -080049import org.onosproject.net.DefaultAnnotations;
Yafit Hadara9a73de2015-09-06 13:52:52 +030050import org.onosproject.net.Device;
Brian O'Connorabafb502014-12-02 22:26:20 -080051import org.onosproject.net.DeviceId;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070052import org.onosproject.net.GridType;
Brian O'Connorabafb502014-12-02 22:26:20 -080053import org.onosproject.net.MastershipRole;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070054import org.onosproject.net.OchSignal;
Yafit Hadara9a73de2015-09-06 13:52:52 +030055import org.onosproject.net.OduCltPort;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070056import org.onosproject.net.OduSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080057import org.onosproject.net.Port;
58import org.onosproject.net.PortNumber;
59import org.onosproject.net.SparseAnnotations;
60import org.onosproject.net.device.DefaultDeviceDescription;
61import org.onosproject.net.device.DefaultPortDescription;
sangho538108b2015-04-08 14:29:20 -070062import org.onosproject.net.device.DefaultPortStatistics;
Brian O'Connorabafb502014-12-02 22:26:20 -080063import org.onosproject.net.device.DeviceDescription;
64import org.onosproject.net.device.DeviceProvider;
65import org.onosproject.net.device.DeviceProviderRegistry;
66import org.onosproject.net.device.DeviceProviderService;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070067import org.onosproject.net.device.OchPortDescription;
Yafit Hadara9a73de2015-09-06 13:52:52 +030068import org.onosproject.net.device.OduCltPortDescription;
Marc De Leenheerb9311372015-07-09 11:36:49 -070069import org.onosproject.net.device.OmsPortDescription;
Brian O'Connorabafb502014-12-02 22:26:20 -080070import org.onosproject.net.device.PortDescription;
sangho538108b2015-04-08 14:29:20 -070071import org.onosproject.net.device.PortStatistics;
Brian O'Connorabafb502014-12-02 22:26:20 -080072import org.onosproject.net.provider.AbstractProvider;
73import org.onosproject.net.provider.ProviderId;
74import org.onosproject.openflow.controller.Dpid;
75import org.onosproject.openflow.controller.OpenFlowController;
sangho538108b2015-04-08 14:29:20 -070076import org.onosproject.openflow.controller.OpenFlowEventListener;
Ayaka Koshibe5460d622015-05-14 12:19:19 -070077import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
Brian O'Connorabafb502014-12-02 22:26:20 -080078import org.onosproject.openflow.controller.OpenFlowSwitch;
79import org.onosproject.openflow.controller.OpenFlowSwitchListener;
Ayaka Koshibe5460d622015-05-14 12:19:19 -070080import org.onosproject.openflow.controller.PortDescPropertyType;
Brian O'Connorabafb502014-12-02 22:26:20 -080081import org.onosproject.openflow.controller.RoleState;
Dusan Pajinbab8a5e2015-07-24 17:37:19 +020082import org.osgi.service.component.ComponentContext;
Marc De Leenheerb9311372015-07-09 11:36:49 -070083import org.projectfloodlight.openflow.protocol.OFCalientPortDescStatsEntry;
Yafit Hadara9a73de2015-09-06 13:52:52 +030084import org.projectfloodlight.openflow.protocol.OFExpPort;
85import org.projectfloodlight.openflow.protocol.OFExpPortDescPropOpticalTransport;
86import org.projectfloodlight.openflow.protocol.OFExpPortOpticalTransportLayerEntry;
Ayaka Koshibee8708e32014-10-22 13:40:18 -070087import org.projectfloodlight.openflow.protocol.OFFactory;
sangho538108b2015-04-08 14:29:20 -070088import org.projectfloodlight.openflow.protocol.OFMessage;
Yafit Hadara9a73de2015-09-06 13:52:52 +030089import org.projectfloodlight.openflow.protocol.OFObject;
alshabib4680bb62014-09-04 17:15:08 -070090import org.projectfloodlight.openflow.protocol.OFPortConfig;
alshabib25c8eec2014-09-04 16:41:31 -070091import org.projectfloodlight.openflow.protocol.OFPortDesc;
Marc De Leenheerfc913dd2015-07-30 16:04:55 -070092import org.projectfloodlight.openflow.protocol.OFPortDescPropOpticalTransport;
Thomas Vachuskad16ce182014-10-29 17:25:29 -070093import org.projectfloodlight.openflow.protocol.OFPortFeatures;
Ayaka Koshibe5460d622015-05-14 12:19:19 -070094import org.projectfloodlight.openflow.protocol.OFPortOptical;
Yafit Hadara9a73de2015-09-06 13:52:52 +030095import org.projectfloodlight.openflow.protocol.OFPortOpticalTransportLayerClass;
96import org.projectfloodlight.openflow.protocol.OFPortOpticalTransportSignalType;
alshabibafc514a2014-12-01 14:44:05 -080097import org.projectfloodlight.openflow.protocol.OFPortReason;
alshabib4680bb62014-09-04 17:15:08 -070098import org.projectfloodlight.openflow.protocol.OFPortState;
sangho538108b2015-04-08 14:29:20 -070099import org.projectfloodlight.openflow.protocol.OFPortStatsEntry;
100import org.projectfloodlight.openflow.protocol.OFPortStatsReply;
alshabiba14f3642014-09-05 09:31:31 -0700101import org.projectfloodlight.openflow.protocol.OFPortStatus;
sangho538108b2015-04-08 14:29:20 -0700102import org.projectfloodlight.openflow.protocol.OFStatsReply;
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700103import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
sangho538108b2015-04-08 14:29:20 -0700104import org.projectfloodlight.openflow.protocol.OFStatsType;
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700105import org.projectfloodlight.openflow.protocol.OFVersion;
106import org.projectfloodlight.openflow.types.PortSpeed;
tomb5a46e62014-08-26 14:20:00 -0700107import org.slf4j.Logger;
tom5f38b3a2014-08-27 23:50:54 -0700108
Yafit Hadara9a73de2015-09-06 13:52:52 +0300109import com.google.common.base.Strings;
110import com.google.common.collect.Lists;
111import com.google.common.collect.Maps;
112import com.google.common.collect.Sets;
tom782a7cf2014-09-11 23:58:38 -0700113
tomb5a46e62014-08-26 14:20:00 -0700114/**
tomb1260e42014-08-26 18:39:57 -0700115 * Provider which uses an OpenFlow controller to detect network
tome06f8552014-08-26 16:58:42 -0700116 * infrastructure devices.
tomb5a46e62014-08-26 14:20:00 -0700117 */
tomb1260e42014-08-26 18:39:57 -0700118@Component(immediate = true)
tomab21e7c2014-08-26 15:23:08 -0700119public class OpenFlowDeviceProvider extends AbstractProvider implements DeviceProvider {
tomb5a46e62014-08-26 14:20:00 -0700120
alshabiba89cc582014-09-09 16:43:00 -0700121 private static final Logger LOG = getLogger(OpenFlowDeviceProvider.class);
Thomas Vachuskad07c0922015-10-06 14:48:06 -0700122
Charles Chan25b77322015-12-13 01:00:56 -0800123 //TODO consider renaming KBPS and MBPS (as they are used to convert by division)
124 private static final long KBPS = 1_000;
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700125 private static final long MBPS = 1_000 * 1_000;
Yafit Hadara9a73de2015-09-06 13:52:52 +0300126 private static final Frequency FREQ100 = Frequency.ofGHz(100);
127 private static final Frequency FREQ193_1 = Frequency.ofTHz(193.1);
128 private static final Frequency FREQ4_4 = Frequency.ofTHz(4.4);
tomb5a46e62014-08-26 14:20:00 -0700129
130 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
tom96dfcab2014-08-28 09:26:03 -0700131 protected DeviceProviderRegistry providerRegistry;
tomab21e7c2014-08-26 15:23:08 -0700132
tom5f38b3a2014-08-27 23:50:54 -0700133 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
134 protected OpenFlowController controller;
135
Dusan Pajinbab8a5e2015-07-24 17:37:19 +0200136 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
137 protected ComponentConfigService cfgService;
138
tomab21e7c2014-08-26 15:23:08 -0700139 private DeviceProviderService providerService;
tomb5a46e62014-08-26 14:20:00 -0700140
sangho538108b2015-04-08 14:29:20 -0700141 private final InternalDeviceProvider listener = new InternalDeviceProvider();
142
Jian Li152b8852015-12-07 14:47:25 -0800143 private final IncomingMessageProvider inMsgListener = new IncomingMessageProvider();
144
145 private final OutgoingMessageProvider outMsgListener = new OutgoingMessageProvider();
146
147 private boolean isCtrlMsgMonitor;
148
sangho538108b2015-04-08 14:29:20 -0700149 // TODO: We need to make the poll interval configurable.
Srikanth Vavilapalli78baf582015-06-05 11:40:14 -0700150 static final int POLL_INTERVAL = 5;
Dusan Pajinbab8a5e2015-07-24 17:37:19 +0200151 @Property(name = "PortStatsPollFrequency", intValue = POLL_INTERVAL,
152 label = "Frequency (in seconds) for polling switch Port statistics")
153 private int portStatsPollFrequency = POLL_INTERVAL;
sangho538108b2015-04-08 14:29:20 -0700154
155 private HashMap<Dpid, PortStatsCollector> collectors = Maps.newHashMap();
tomd40fc7a2014-09-04 16:41:10 -0700156
tomab21e7c2014-08-26 15:23:08 -0700157 /**
158 * Creates an OpenFlow device provider.
159 */
160 public OpenFlowDeviceProvider() {
Brian O'Connorabafb502014-12-02 22:26:20 -0800161 super(new ProviderId("of", "org.onosproject.provider.openflow"));
tomab21e7c2014-08-26 15:23:08 -0700162 }
163
tomb5a46e62014-08-26 14:20:00 -0700164 @Activate
Dusan Pajinbab8a5e2015-07-24 17:37:19 +0200165 public void activate(ComponentContext context) {
166 cfgService.registerProperties(getClass());
tom96dfcab2014-08-28 09:26:03 -0700167 providerService = providerRegistry.register(this);
tomd40fc7a2014-09-04 16:41:10 -0700168 controller.addListener(listener);
sangho538108b2015-04-08 14:29:20 -0700169 controller.addEventListener(listener);
Jian Li152b8852015-12-07 14:47:25 -0800170
Thomas Vachuskad07c0922015-10-06 14:48:06 -0700171 connectInitialDevices();
alshabiba89cc582014-09-09 16:43:00 -0700172 LOG.info("Started");
tomb5a46e62014-08-26 14:20:00 -0700173 }
174
175 @Deactivate
Dusan Pajinbab8a5e2015-07-24 17:37:19 +0200176 public void deactivate(ComponentContext context) {
177 cfgService.unregisterProperties(getClass(), false);
tomd40fc7a2014-09-04 16:41:10 -0700178 controller.removeListener(listener);
Thomas Vachuskad07c0922015-10-06 14:48:06 -0700179 providerRegistry.unregister(this);
Thomas Vachuska74bcd922015-06-02 13:08:57 -0700180 collectors.values().forEach(PortStatsCollector::stop);
tomab21e7c2014-08-26 15:23:08 -0700181 providerService = null;
alshabiba89cc582014-09-09 16:43:00 -0700182 LOG.info("Stopped");
tomb5a46e62014-08-26 14:20:00 -0700183 }
184
Dusan Pajinbab8a5e2015-07-24 17:37:19 +0200185 @Modified
186 public void modified(ComponentContext context) {
187 Dictionary<?, ?> properties = context.getProperties();
188 int newPortStatsPollFrequency;
189 try {
190 String s = get(properties, "PortStatsPollFrequency");
191 newPortStatsPollFrequency = isNullOrEmpty(s) ? portStatsPollFrequency : Integer.parseInt(s.trim());
192
193 } catch (NumberFormatException | ClassCastException e) {
194 newPortStatsPollFrequency = portStatsPollFrequency;
195 }
196
197 if (newPortStatsPollFrequency != portStatsPollFrequency) {
198 portStatsPollFrequency = newPortStatsPollFrequency;
199 collectors.values().forEach(psc -> psc.adjustPollInterval(portStatsPollFrequency));
200 }
201
202 LOG.info("Settings: portStatsPollFrequency={}", portStatsPollFrequency);
203 }
Ayaka Koshibee60d4522014-10-28 15:07:00 -0700204
Thomas Vachuskad07c0922015-10-06 14:48:06 -0700205 private void connectInitialDevices() {
206 for (OpenFlowSwitch sw : controller.getSwitches()) {
207 try {
208 listener.switchAdded(new Dpid(sw.getId()));
209 } catch (Exception e) {
210 LOG.warn("Failed initially adding {} : {}", sw.getStringId(), e.getMessage());
211 LOG.debug("Error details:", e);
212 // disconnect to trigger switch-add later
213 sw.disconnectSwitch();
214 }
215 PortStatsCollector psc = new PortStatsCollector(sw, portStatsPollFrequency);
216 psc.start();
217 collectors.put(new Dpid(sw.getId()), psc);
218 }
219 }
220
Ayaka Koshibee60d4522014-10-28 15:07:00 -0700221 @Override
Yuta HIGUCHI54815322014-10-31 23:17:08 -0700222 public boolean isReachable(DeviceId deviceId) {
223 OpenFlowSwitch sw = controller.getSwitch(dpid(deviceId.uri()));
Thomas Vachuskad07c0922015-10-06 14:48:06 -0700224 return sw != null && sw.isConnected();
Ayaka Koshibee60d4522014-10-28 15:07:00 -0700225 }
226
tomab21e7c2014-08-26 15:23:08 -0700227 @Override
Ayaka Koshibe78bcbc12014-11-19 14:28:58 -0800228 public void triggerProbe(DeviceId deviceId) {
Madan Jampanic3328762015-05-31 12:39:27 -0700229 LOG.debug("Triggering probe on device {}", deviceId);
Ayaka Koshibee8708e32014-10-22 13:40:18 -0700230
Yuta HIGUCHI802d0e82014-10-31 16:07:37 -0700231 final Dpid dpid = dpid(deviceId.uri());
232 OpenFlowSwitch sw = controller.getSwitch(dpid);
233 if (sw == null || !sw.isConnected()) {
Ayaka Koshibe78bcbc12014-11-19 14:28:58 -0800234 LOG.error("Failed to probe device {} on sw={}", deviceId, sw);
Yuta HIGUCHI802d0e82014-10-31 16:07:37 -0700235 providerService.deviceDisconnected(deviceId);
Thomas Vachuska74bcd922015-06-02 13:08:57 -0700236 return;
Yuta HIGUCHI802d0e82014-10-31 16:07:37 -0700237 } else {
Ayaka Koshibe78bcbc12014-11-19 14:28:58 -0800238 LOG.trace("Confirmed device {} connection", deviceId);
Yuta HIGUCHI802d0e82014-10-31 16:07:37 -0700239 }
Ayaka Koshibee8708e32014-10-22 13:40:18 -0700240
Ayaka Koshibee60d4522014-10-28 15:07:00 -0700241 // Prompt an update of port information. We can use any XID for this.
Ayaka Koshibee8708e32014-10-22 13:40:18 -0700242 OFFactory fact = sw.factory();
243 switch (fact.getVersion()) {
244 case OF_10:
245 sw.sendMsg(fact.buildFeaturesRequest().setXid(0).build());
246 break;
247 case OF_13:
248 sw.sendMsg(fact.buildPortDescStatsRequest().setXid(0).build());
249 break;
250 default:
251 LOG.warn("Unhandled protocol version");
252 }
tomab21e7c2014-08-26 15:23:08 -0700253 }
254
255 @Override
Yuta HIGUCHI54815322014-10-31 23:17:08 -0700256 public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
alshabibf1216ed2014-09-03 11:53:54 -0700257 switch (newRole) {
tom782a7cf2014-09-11 23:58:38 -0700258 case MASTER:
Yuta HIGUCHI54815322014-10-31 23:17:08 -0700259 controller.setRole(dpid(deviceId.uri()), RoleState.MASTER);
tom782a7cf2014-09-11 23:58:38 -0700260 break;
261 case STANDBY:
Yuta HIGUCHI54815322014-10-31 23:17:08 -0700262 controller.setRole(dpid(deviceId.uri()), RoleState.EQUAL);
tom782a7cf2014-09-11 23:58:38 -0700263 break;
264 case NONE:
Yuta HIGUCHI54815322014-10-31 23:17:08 -0700265 controller.setRole(dpid(deviceId.uri()), RoleState.SLAVE);
tom782a7cf2014-09-11 23:58:38 -0700266 break;
267 default:
268 LOG.error("Unknown Mastership state : {}", newRole);
alshabibf1216ed2014-09-03 11:53:54 -0700269
270 }
Madan Jampanic3328762015-05-31 12:39:27 -0700271 LOG.debug("Accepting mastership role change for device {}", deviceId);
tomab21e7c2014-08-26 15:23:08 -0700272 }
273
Jian Li152b8852015-12-07 14:47:25 -0800274
275 /**
276 * Enable OpenFlow control message monitoring.
277 */
278 public void enableCtrlMsgMonitor() {
279 isCtrlMsgMonitor = true;
280 controller.addEventListener(inMsgListener);
281 for (OpenFlowSwitch sw : controller.getSwitches()) {
282 sw.addEventListener(outMsgListener);
283 }
284 LOG.info("Enable control message monitoring.");
285 }
286
287 /**
288 * Disable OpenFlow control message monitoring.
289 */
290 public void disableCtrlMsgMonitor() {
291 isCtrlMsgMonitor = false;
292 controller.removeEventListener(inMsgListener);
293 for (OpenFlowSwitch sw: controller.getSwitches()) {
294 sw.removeEventListener(outMsgListener);
295 }
296 LOG.info("Disable control message monitoring");
297 }
298
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700299 private void pushPortMetrics(Dpid dpid, List<OFPortStatsEntry> portStatsEntries) {
sangho538108b2015-04-08 14:29:20 -0700300 DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid));
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700301 Collection<PortStatistics> stats = buildPortStatistics(deviceId, portStatsEntries);
sangho538108b2015-04-08 14:29:20 -0700302 providerService.updatePortStatistics(deviceId, stats);
303 }
304
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700305 private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId,
306 List<OFPortStatsEntry> entries) {
sangho538108b2015-04-08 14:29:20 -0700307 HashSet<PortStatistics> stats = Sets.newHashSet();
308
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700309 for (OFPortStatsEntry entry : entries) {
Thomas Vachuskaf0397b52015-05-29 13:50:17 -0700310 try {
Thomas Vachuska4e6025e2015-06-03 11:25:21 -0700311 if (entry == null || entry.getPortNo() == null || entry.getPortNo().getPortNumber() < 0) {
Thomas Vachuskaf0397b52015-05-29 13:50:17 -0700312 continue;
313 }
314 DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
315 DefaultPortStatistics stat = builder.setDeviceId(deviceId)
316 .setPort(entry.getPortNo().getPortNumber())
317 .setPacketsReceived(entry.getRxPackets().getValue())
318 .setPacketsSent(entry.getTxPackets().getValue())
319 .setBytesReceived(entry.getRxBytes().getValue())
320 .setBytesSent(entry.getTxBytes().getValue())
321 .setPacketsRxDropped(entry.getRxDropped().getValue())
322 .setPacketsTxDropped(entry.getTxDropped().getValue())
323 .setPacketsRxErrors(entry.getRxErrors().getValue())
324 .setPacketsTxErrors(entry.getTxErrors().getValue())
325 .setDurationSec(entry.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationSec())
326 .setDurationNano(entry.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationNsec())
327 .build();
sangho538108b2015-04-08 14:29:20 -0700328
Thomas Vachuskaf0397b52015-05-29 13:50:17 -0700329 stats.add(stat);
330 } catch (Exception e) {
331 LOG.warn("Unable to process port stats", e);
332 }
sangho538108b2015-04-08 14:29:20 -0700333 }
334
335 return Collections.unmodifiableSet(stats);
336
337 }
338
Jian Li152b8852015-12-07 14:47:25 -0800339 /**
340 * A listener for incoming OpenFlow messages.
341 */
342 private class IncomingMessageProvider implements OpenFlowEventListener {
343
344 @Override
345 public void handleMessage(Dpid dpid, OFMessage msg) {
346 if (isCtrlMsgMonitor) {
347 // TODO: feed the control message stats via ControlMetricsServiceFactory
348 }
349 }
350 }
351
352 /**
353 * A listener for outgoing OpenFlow messages.
354 */
355 private class OutgoingMessageProvider implements OpenFlowEventListener {
356
357 @Override
358 public void handleMessage(Dpid dpid, OFMessage msg) {
359 if (isCtrlMsgMonitor) {
360 // TODO: feed the control message stats via ControlMetricsServiceFactory
361 }
362 }
363 }
364
sangho538108b2015-04-08 14:29:20 -0700365 private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener {
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700366
Srikanth Vavilapalli78baf582015-06-05 11:40:14 -0700367 private HashMap<Dpid, List<OFPortStatsEntry>> portStatsReplies = new HashMap<>();
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700368
alshabibf1216ed2014-09-03 11:53:54 -0700369 @Override
tomd1900f32014-09-03 14:08:16 -0700370 public void switchAdded(Dpid dpid) {
alshabib6f5460b2014-09-03 14:46:17 -0700371 if (providerService == null) {
372 return;
373 }
tom782a7cf2014-09-11 23:58:38 -0700374 DeviceId did = deviceId(uri(dpid));
alshabib6f5460b2014-09-03 14:46:17 -0700375 OpenFlowSwitch sw = controller.getSwitch(dpid);
Lei Xudee1aff2015-10-16 00:45:10 -0500376 if (sw == null) {
377 return;
378 }
alshabib6f5460b2014-09-03 14:46:17 -0700379
Jian Li152b8852015-12-07 14:47:25 -0800380 if (isCtrlMsgMonitor) {
381 // start to monitor the outgoing control messages
382 sw.addEventListener(outMsgListener);
383 }
384
alshabib7911a052014-10-16 17:49:37 -0700385 ChassisId cId = new ChassisId(dpid.value());
Ray Milkeye53f1712015-01-16 09:17:16 -0800386
Thomas Vachuska82041f52014-11-30 22:14:02 -0800387 SparseAnnotations annotations = DefaultAnnotations.builder()
andreafe3308f2015-10-06 15:51:25 -0700388 .set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString())
389 .set(AnnotationKeys.CHANNEL_ID, sw.channelId())
390 .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0])
Ray Milkeye53f1712015-01-16 09:17:16 -0800391 .build();
392
tomd1900f32014-09-03 14:08:16 -0700393 DeviceDescription description =
Marc De Leenheerb9311372015-07-09 11:36:49 -0700394 new DefaultDeviceDescription(did.uri(), sw.deviceType(),
Ray Milkeyd3edd032015-01-16 11:38:58 -0800395 sw.manufacturerDescription(),
tom782a7cf2014-09-11 23:58:38 -0700396 sw.hardwareDescription(),
397 sw.softwareDescription(),
alshabib7911a052014-10-16 17:49:37 -0700398 sw.serialNumber(),
Thomas Vachuska82041f52014-11-30 22:14:02 -0800399 cId, annotations);
tom782a7cf2014-09-11 23:58:38 -0700400 providerService.deviceConnected(did, description);
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700401 providerService.updatePorts(did, buildPortDescriptions(sw));
sangho538108b2015-04-08 14:29:20 -0700402
Thomas Vachuskafc52fec2015-05-18 19:13:56 -0700403 PortStatsCollector psc =
Lei Xudee1aff2015-10-16 00:45:10 -0500404 new PortStatsCollector(sw, portStatsPollFrequency);
sangho538108b2015-04-08 14:29:20 -0700405 psc.start();
406 collectors.put(dpid, psc);
Lei Xudee1aff2015-10-16 00:45:10 -0500407
408 //figure out race condition for collectors.remove() and collectors.put()
409 if (controller.getSwitch(dpid) == null) {
410 switchRemoved(dpid);
411 }
alshabib25c8eec2014-09-04 16:41:31 -0700412 }
413
alshabibf1216ed2014-09-03 11:53:54 -0700414 @Override
415 public void switchRemoved(Dpid dpid) {
alshabib6f5460b2014-09-03 14:46:17 -0700416 if (providerService == null) {
417 return;
418 }
tom782a7cf2014-09-11 23:58:38 -0700419 providerService.deviceDisconnected(deviceId(uri(dpid)));
alshabibf1216ed2014-09-03 11:53:54 -0700420
sangho538108b2015-04-08 14:29:20 -0700421 PortStatsCollector collector = collectors.remove(dpid);
422 if (collector != null) {
423 collector.stop();
424 }
Jian Li152b8852015-12-07 14:47:25 -0800425
426 OpenFlowSwitch sw = controller.getSwitch(dpid);
427 if (sw != null) {
428 if (isCtrlMsgMonitor) {
429 // stop monitoring the outgoing control messages
430 sw.removeEventListener(outMsgListener);
431 }
432 }
sangho538108b2015-04-08 14:29:20 -0700433 }
Ayaka Koshibe38594c22014-10-22 13:36:12 -0700434
435 @Override
436 public void switchChanged(Dpid dpid) {
437 if (providerService == null) {
438 return;
439 }
440 DeviceId did = deviceId(uri(dpid));
441 OpenFlowSwitch sw = controller.getSwitch(dpid);
Lei Xudee1aff2015-10-16 00:45:10 -0500442 if (sw == null) {
443 return;
444 }
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700445 providerService.updatePorts(did, buildPortDescriptions(sw));
Ayaka Koshibe38594c22014-10-22 13:36:12 -0700446 }
447
alshabiba14f3642014-09-05 09:31:31 -0700448 @Override
449 public void portChanged(Dpid dpid, OFPortStatus status) {
alshabibafc514a2014-12-01 14:44:05 -0800450 PortDescription portDescription = buildPortDescription(status);
tom782a7cf2014-09-11 23:58:38 -0700451 providerService.portStatusChanged(deviceId(uri(dpid)), portDescription);
alshabibf1216ed2014-09-03 11:53:54 -0700452 }
453
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700454 @Override
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700455 public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) {
456 MastershipRole request = roleOf(requested);
457 MastershipRole reply = roleOf(response);
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700458 providerService.receivedRoleReply(deviceId(uri(dpid)), request, reply);
459 }
460
461 /**
462 * Translates a RoleState to the corresponding MastershipRole.
463 *
Thomas Vachuskafc52fec2015-05-18 19:13:56 -0700464 * @param response role state
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700465 * @return a MastershipRole
466 */
467 private MastershipRole roleOf(RoleState response) {
468 switch (response) {
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700469 case MASTER:
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700470 return MastershipRole.MASTER;
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700471 case EQUAL:
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700472 return MastershipRole.STANDBY;
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700473 case SLAVE:
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700474 return MastershipRole.NONE;
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700475 default:
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700476 LOG.warn("unknown role {}", response);
477 return null;
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700478 }
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700479 }
480
alshabiba14f3642014-09-05 09:31:31 -0700481 /**
482 * Builds a list of port descriptions for a given list of ports.
tomff7eb7c2014-09-08 12:49:03 -0700483 *
alshabiba14f3642014-09-05 09:31:31 -0700484 * @return list of portdescriptions
485 */
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700486 private List<PortDescription> buildPortDescriptions(OpenFlowSwitch sw) {
487 final List<PortDescription> portDescs = new ArrayList<>(sw.getPorts().size());
Yafit Hadara9a73de2015-09-06 13:52:52 +0300488 if (!(Device.Type.ROADM.equals(sw.deviceType()))) {
489 sw.getPorts().forEach(port -> portDescs.add(buildPortDescription(port)));
490 }
Marc De Leenheerb9311372015-07-09 11:36:49 -0700491
492 OpenFlowOpticalSwitch opsw;
493 switch (sw.deviceType()) {
494 case ROADM:
495 opsw = (OpenFlowOpticalSwitch) sw;
Yafit Hadara9a73de2015-09-06 13:52:52 +0300496 List<OFPortDesc> ports = opsw.getPorts();
497 LOG.debug("SW ID {} , ETH- ODU CLT Ports {}", opsw.getId(), ports);
498 // ODU client ports are reported as ETH
499 ports.forEach(port -> portDescs.add(buildOduCltPortDescription(port)));
500
Marc De Leenheerb9311372015-07-09 11:36:49 -0700501 opsw.getPortTypes().forEach(type -> {
Yafit Hadara9a73de2015-09-06 13:52:52 +0300502 List<? extends OFObject> portsOf = opsw.getPortsOf(type);
503 LOG.debug("Ports Of{}", portsOf);
504 portsOf.forEach(
505 op -> {
506 portDescs.add(buildPortDescription(type, (OFObject) op));
507 }
508 );
Marc De Leenheerb9311372015-07-09 11:36:49 -0700509 });
510 break;
511 case FIBER_SWITCH:
512 opsw = (OpenFlowOpticalSwitch) sw;
513 opsw.getPortTypes().forEach(type -> {
514 opsw.getPortsOf(type).forEach(
515 op -> {
516 portDescs.add(buildPortDescription((OFCalientPortDescStatsEntry) op));
517 }
518 );
519 });
520 break;
521 default:
522 break;
alshabib4680bb62014-09-04 17:15:08 -0700523 }
Marc De Leenheerb9311372015-07-09 11:36:49 -0700524
alshabib4680bb62014-09-04 17:15:08 -0700525 return portDescs;
526 }
527
Yafit Hadara9a73de2015-09-06 13:52:52 +0300528 private PortDescription buildOduCltPortDescription(OFPortDesc port) {
529 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
530 boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
531 !port.getConfig().contains(OFPortConfig.PORT_DOWN);
532 Long portSpeed = portSpeed(port);
533 OduCltPort.SignalType sigType = null;
534
535 switch (portSpeed.toString()) {
536 case "1":
537 sigType = OduCltPort.SignalType.CLT_1GBE;
538 break;
539 case "10":
540 sigType = OduCltPort.SignalType.CLT_10GBE;
541 break;
542 case "40":
543 sigType = OduCltPort.SignalType.CLT_40GBE;
544 break;
545 case "100":
546 sigType = OduCltPort.SignalType.CLT_100GBE;
547 break;
548 default:
549 throw new RuntimeException("Un recognize OduClt speed: " + portSpeed.toString());
550 }
551
552 SparseAnnotations annotations = buildOduCltAnnotation(port);
553 return new OduCltPortDescription(portNo, enabled, sigType, annotations);
554 }
555
556 private SparseAnnotations buildOduCltAnnotation(OFPortDesc port) {
557 SparseAnnotations annotations = null;
558 String portName = Strings.emptyToNull(port.getName());
559 if (portName != null) {
560 annotations = DefaultAnnotations.builder()
561 .set(AnnotationKeys.PORT_NAME, portName)
562 .set(AnnotationKeys.STATIC_PORT, Boolean.TRUE.toString()).build();
563 }
564 return annotations;
565 }
566
567 private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port) {
568 if (port instanceof OFPortOptical) {
569 return buildPortDescription(ptype, (OFPortOptical) port);
570 }
571 return buildPortDescription(ptype, (OFExpPort) port);
572 }
573
574 /**
575 * Build a portDescription from a given a port description describing some
576 * Optical port.
577 *
578 * @param ptype description property type.
579 * @param port the port to build from.
580 * @return portDescription for the port.
581 */
582 private PortDescription buildPortDescription(PortDescPropertyType ptype, OFExpPort port) {
583 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
584 boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
585 && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
lishuai4ee42042015-11-30 17:19:21 +0800586 SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
Yafit Hadara9a73de2015-09-06 13:52:52 +0300587
588 OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0);
589 OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType();
590
591 DefaultPortDescription portDes = null;
592 switch (sigType) {
593 case OMSN:
594 portDes = new OmsPortDescription(portNo, enabled, FREQ193_1, FREQ193_1.add(FREQ4_4),
595 FREQ100, annotations);
596 break;
597 case OCH:
598 OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0);
599 OFPortOpticalTransportLayerClass layerClass = entry.getLayerClass();
600 if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) {
601 LOG.error("Unsupported layer Class {} ", layerClass);
602 return null;
603 }
604
605 // convert to ONOS OduSignalType
606 OduSignalType oduSignalType = OpenFlowDeviceValueMapper.
607 lookupOduSignalType((byte) entry.getSignalType());
608 //OchSignal is needed for OchPortDescription constructor,
609 //yet not relevant for tunable OCH port, creating with default parameters
610 OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1);
611
612 portDes = new OchPortDescription(portNo, enabled,
613 oduSignalType, true, signalId, annotations);
614
615 break;
616 case OTU2:
617 case OTU4:
618 LOG.error("Signal tpye OTU2/4 not supported yet ", port.toString());
619 break;
620 default:
621 break;
622 }
623
624 return portDes;
625 }
626
alshabiba14f3642014-09-05 09:31:31 -0700627 /**
Ray Milkeye0fade72015-01-15 13:29:47 -0800628 * Creates an annotation for the port name if one is available.
629 *
lishuai4ee42042015-11-30 17:19:21 +0800630 * @param portName the port name
631 * @param portMac the port mac
Ray Milkeye0fade72015-01-15 13:29:47 -0800632 * @return annotation containing the port name if one is found,
633 * null otherwise
634 */
lishuai4ee42042015-11-30 17:19:21 +0800635 private SparseAnnotations makePortAnnotation(String portName, String portMac) {
Ray Milkeye0fade72015-01-15 13:29:47 -0800636 SparseAnnotations annotations = null;
lishuai4ee42042015-11-30 17:19:21 +0800637 String pName = Strings.emptyToNull(portName);
638 String pMac = Strings.emptyToNull(portMac);
Ray Milkeye0fade72015-01-15 13:29:47 -0800639 if (portName != null) {
640 annotations = DefaultAnnotations.builder()
lishuai4ee42042015-11-30 17:19:21 +0800641 .set(AnnotationKeys.PORT_NAME, pName)
642 .set(AnnotationKeys.PORT_MAC, pMac).build();
Ray Milkeye0fade72015-01-15 13:29:47 -0800643 }
644 return annotations;
645 }
646
647 /**
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700648 * Build a portDescription from a given Ethernet port description.
tomff7eb7c2014-09-08 12:49:03 -0700649 *
alshabiba14f3642014-09-05 09:31:31 -0700650 * @param port the port to build from.
651 * @return portDescription for the port.
652 */
653 private PortDescription buildPortDescription(OFPortDesc port) {
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700654 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
655 boolean enabled =
656 !port.getState().contains(OFPortState.LINK_DOWN) &&
657 !port.getConfig().contains(OFPortConfig.PORT_DOWN);
658 Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
lishuai4ee42042015-11-30 17:19:21 +0800659 SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
Ray Milkeye0fade72015-01-15 13:29:47 -0800660 return new DefaultPortDescription(portNo, enabled, type,
661 portSpeed(port), annotations);
alshabiba14f3642014-09-05 09:31:31 -0700662 }
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700663
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700664 /**
665 * Build a portDescription from a given a port description describing some
666 * Optical port.
667 *
668 * @param port description property type.
669 * @param port the port to build from.
670 * @return portDescription for the port.
671 */
672 private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) {
Marc De Leenheerfc913dd2015-07-30 16:04:55 -0700673 checkArgument(port.getDesc().size() >= 1);
674
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700675 // Minimally functional fixture. This needs to be fixed as we add better support.
676 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
Ayaka Koshibe74b55272015-05-28 15:16:04 -0700677
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700678 boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
679 && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
lishuai4ee42042015-11-30 17:19:21 +0800680 SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700681
682 if (port.getVersion() == OFVersion.OF_13
683 && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
684 // At this point, not much is carried in the optical port message.
Ayaka Koshibeae541732015-05-19 13:37:27 -0700685 LOG.debug("Optical transport port message {}", port.toString());
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700686 } else {
687 // removable once 1.4+ support complete.
Ayaka Koshibeae541732015-05-19 13:37:27 -0700688 LOG.debug("Unsupported optical port properties");
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700689 }
Marc De Leenheerfc913dd2015-07-30 16:04:55 -0700690
691 OFPortDescPropOpticalTransport desc = port.getDesc().get(0);
692 switch (desc.getPortSignalType()) {
693 // FIXME: use constants once loxi has full optical extensions
694 case 2: // OMS port
695 // Assume complete optical spectrum and 50 GHz grid
696 // LINC-OE is only supported optical OF device for now
697 return new OmsPortDescription(portNo, enabled,
698 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
699 case 5: // OCH port
700 OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
701 return new OchPortDescription(portNo, enabled, OduSignalType.ODU4,
702 true, signal, annotations);
703 default:
704 break;
705 }
706
Ayaka Koshibe74b55272015-05-28 15:16:04 -0700707 return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations);
Ayaka Koshibe5460d622015-05-14 12:19:19 -0700708 }
709
Marc De Leenheerb9311372015-07-09 11:36:49 -0700710 /**
711 * Build a portDescription from a given port description describing a fiber switch optical port.
712 *
713 * @param port description property type.
714 * @param port the port to build from.
715 * @return portDescription for the port.
716 */
717 private PortDescription buildPortDescription(OFCalientPortDescStatsEntry port) {
718 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
719
720 // FIXME when Calient OF agent reports port status
721 boolean enabled = true;
lishuai4ee42042015-11-30 17:19:21 +0800722 SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
Marc De Leenheerb9311372015-07-09 11:36:49 -0700723
Marc De Leenheerfc913dd2015-07-30 16:04:55 -0700724 // S160 data sheet
725 // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch
726 return new OmsPortDescription(portNo, enabled,
727 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(100), annotations);
Marc De Leenheerb9311372015-07-09 11:36:49 -0700728 }
729
alshabibafc514a2014-12-01 14:44:05 -0800730 private PortDescription buildPortDescription(OFPortStatus status) {
731 OFPortDesc port = status.getDesc();
732 if (status.getReason() != OFPortReason.DELETE) {
733 return buildPortDescription(port);
734 } else {
735 PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
736 Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
lishuai4ee42042015-11-30 17:19:21 +0800737 SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
Ray Milkeye0fade72015-01-15 13:29:47 -0800738 return new DefaultPortDescription(portNo, false, type,
739 portSpeed(port), annotations);
alshabibafc514a2014-12-01 14:44:05 -0800740 }
741 }
742
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700743 private long portSpeed(OFPortDesc port) {
744 if (port.getVersion() == OFVersion.OF_13) {
Charles Chan25b77322015-12-13 01:00:56 -0800745 // Note: getCurrSpeed() returns a value in kbps (this also applies to OF_11 and OF_12)
746 return port.getCurrSpeed() / KBPS;
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700747 }
748
749 PortSpeed portSpeed = PortSpeed.SPEED_NONE;
750 for (OFPortFeatures feat : port.getCurr()) {
751 portSpeed = PortSpeed.max(portSpeed, feat.getPortSpeed());
752 }
Thomas Vachuska98eda532014-10-29 17:31:02 -0700753 return portSpeed.getSpeedBps() / MBPS;
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700754 }
sangho538108b2015-04-08 14:29:20 -0700755
756 @Override
757 public void handleMessage(Dpid dpid, OFMessage msg) {
758 switch (msg.getType()) {
759 case STATS_REPLY:
760 if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) {
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700761 OFPortStatsReply portStatsReply = (OFPortStatsReply) msg;
Srikanth Vavilapalli78baf582015-06-05 11:40:14 -0700762 List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid);
763 if (portStatsReplyList == null) {
764 portStatsReplyList = Lists.newArrayList();
765 }
766 portStatsReplyList.addAll(portStatsReply.getEntries());
767 portStatsReplies.put(dpid, portStatsReplyList);
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700768 if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
Srikanth Vavilapalli78baf582015-06-05 11:40:14 -0700769 pushPortMetrics(dpid, portStatsReplies.get(dpid));
770 portStatsReplies.get(dpid).clear();
Thomas Vachuska893bf4b2015-05-29 18:13:18 -0700771 }
sangho538108b2015-04-08 14:29:20 -0700772 }
773 break;
774 default:
775 break;
776 }
777 }
alshabibf1216ed2014-09-03 11:53:54 -0700778 }
tomb5a46e62014-08-26 14:20:00 -0700779}