Use static link config instead of LLDP
To work, the LinkDiscovery provider should be active:
org.onosproject.linkdiscovery
Change-Id: I7ae3ff95150c1ef4d6ebba64a32c39a6fe22863d
diff --git a/drivers/barefoot/src/main/java/org/onosproject/drivers/barefoot/TofinoDefaultPipeconfFactory.java b/drivers/barefoot/src/main/java/org/onosproject/drivers/barefoot/TofinoDefaultPipeconfFactory.java
index f383448..f3c61d0 100644
--- a/drivers/barefoot/src/main/java/org/onosproject/drivers/barefoot/TofinoDefaultPipeconfFactory.java
+++ b/drivers/barefoot/src/main/java/org/onosproject/drivers/barefoot/TofinoDefaultPipeconfFactory.java
@@ -20,6 +20,8 @@
import org.onosproject.driver.pipeline.DefaultSingleTablePipeline;
import org.onosproject.drivers.p4runtime.DefaultP4Interpreter;
import org.onosproject.drivers.p4runtime.DefaultP4PortStatisticsDiscovery;
+import org.onosproject.drivers.p4runtime.NetcfgLinkDiscovery;
+import org.onosproject.net.behaviour.LinkDiscovery;
import org.onosproject.net.behaviour.Pipeliner;
import org.onosproject.net.device.PortStatisticsDiscovery;
import org.onosproject.net.pi.model.DefaultPiPipeconf;
@@ -68,6 +70,8 @@
.addBehaviour(PiPipelineInterpreter.class, DefaultP4Interpreter.class)
.addBehaviour(Pipeliner.class, DefaultSingleTablePipeline.class)
.addBehaviour(PortStatisticsDiscovery.class, DefaultP4PortStatisticsDiscovery.class)
+ // FIXME: remove as soon as we get Packet I/O working
+ .addBehaviour(LinkDiscovery.class, NetcfgLinkDiscovery.class)
.addExtension(P4_INFO_TEXT, p4InfoUrl)
.addExtension(BMV2_JSON, jsonUrl)
.addExtension(TOFINO_BIN, tofinoUrl)
diff --git a/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/Bmv2DefaultPipeconfFactory.java b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/Bmv2DefaultPipeconfFactory.java
index 41fe160..9a12170 100644
--- a/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/Bmv2DefaultPipeconfFactory.java
+++ b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/Bmv2DefaultPipeconfFactory.java
@@ -20,6 +20,8 @@
import org.onosproject.driver.pipeline.DefaultSingleTablePipeline;
import org.onosproject.drivers.p4runtime.DefaultP4Interpreter;
import org.onosproject.drivers.p4runtime.DefaultP4PortStatisticsDiscovery;
+import org.onosproject.drivers.p4runtime.NetcfgLinkDiscovery;
+import org.onosproject.net.behaviour.LinkDiscovery;
import org.onosproject.net.behaviour.Pipeliner;
import org.onosproject.net.device.PortStatisticsDiscovery;
import org.onosproject.net.pi.model.DefaultPiPipeconf;
@@ -62,6 +64,8 @@
.addBehaviour(PiPipelineInterpreter.class, DefaultP4Interpreter.class)
.addBehaviour(Pipeliner.class, DefaultSingleTablePipeline.class)
.addBehaviour(PortStatisticsDiscovery.class, DefaultP4PortStatisticsDiscovery.class)
+ // FIXME: remove as soon as we get Packet I/O working
+ .addBehaviour(LinkDiscovery.class, NetcfgLinkDiscovery.class)
.addExtension(P4_INFO_TEXT, p4InfoUrl)
.addExtension(BMV2_JSON, jsonUrl)
.build();
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/NetcfgLinkDiscovery.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/NetcfgLinkDiscovery.java
new file mode 100644
index 0000000..0b30930
--- /dev/null
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/NetcfgLinkDiscovery.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.drivers.p4runtime;
+
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.LinkKey;
+import org.onosproject.net.behaviour.LinkDiscovery;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.basics.BasicLinkConfig;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.link.DefaultLinkDescription;
+import org.onosproject.net.link.LinkDescription;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Implementation of the LinkDiscovery behaviour that returns all link available in the network configuration
+ * subsystem, where this device is the source connect point.
+ */
+// TODO: remove this behavior as soon we get working Packet I/O on Tofino.
+public class NetcfgLinkDiscovery extends AbstractHandlerBehaviour implements LinkDiscovery {
+
+ @Override
+ public Set<LinkDescription> getLinks() {
+ final NetworkConfigService configService = this.handler().get(NetworkConfigService.class);
+ return configService.getSubjects(LinkKey.class)
+ .stream()
+ .filter(linkKey -> linkKey.src().deviceId().equals(data().deviceId()))
+ .map(linkKey -> {
+ BasicLinkConfig linkConfig = configService.getConfig(linkKey, BasicLinkConfig.class);
+ return new DefaultLinkDescription(linkKey.src(), linkKey.dst(),
+ linkConfig.type(),
+ DefaultLinkDescription.EXPECTED,
+ DefaultAnnotations.EMPTY);
+ })
+ .collect(Collectors.toSet());
+ }
+}
diff --git a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
index 410ce4d..9c49727 100644
--- a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
+++ b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
@@ -268,7 +268,7 @@
executor.execute(() -> event.subject().as(LinkDiscovery.class).getLinks()
.forEach(linkDesc -> {
providerService.linkDetected(new DefaultLinkDescription(
- linkDesc.src(), linkDesc.dst(), linkDesc.type(), false,
+ linkDesc.src(), linkDesc.dst(), linkDesc.type(), linkDesc.isExpected(),
DefaultAnnotations.builder()
.putAll(linkDesc.annotations())
.set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase())
diff --git a/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java b/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
index 998e269..c0884f7 100644
--- a/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
+++ b/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
@@ -156,7 +156,7 @@
.as(PiPipelineInterpreter.class)
.mapInboundPacket(eventSubject.deviceId(), operation);
if (inPkt == null) {
- log.warn("Received null inbound packet. Ignoring.");
+ log.debug("Received null inbound packet. Ignoring.");
return;
}
//Creating the corresponding outbound Packet