Fix: do not handle non-smart NIC capable port at direct port provider

Change-Id: Ife763092da8d4ad8f361dbb7cfe5532c54c24ebe
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
index db7af99..a73946f 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
@@ -58,6 +58,7 @@
 import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.hasIntfAleadyInDevice;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.isSmartNicCapable;
 import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
 import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER;
 
@@ -148,6 +149,10 @@
                 return;
             }
 
+            if (!isSmartNicCapable(event.port())) {
+                return;
+            }
+
             if (event.port().getState() == State.DOWN) {
                 removePort(event.port());
             } else {
@@ -160,6 +165,10 @@
                 return;
             }
 
+            if (!isSmartNicCapable(event.port())) {
+                return;
+            }
+
             removePort(event.port());
         }
 
@@ -307,6 +316,7 @@
                     .filter(port -> port.getvNicType().equals(DIRECT))
                     .filter(port -> !port.getVifType().equals(UNBOUND))
                     .filter(port -> port.getHostId().equals(node.hostname()))
+                    .filter(OpenstackNetworkingUtil::isSmartNicCapable)
                     .collect(Collectors.toList());
 
             ports.forEach(port -> addIntfToDevice(node, port));
@@ -318,7 +328,7 @@
                 log.error("Failed to retrieve interface name from a port {}", port.getId());
             } else if (intfName.equals(UNSUPPORTED_VENDOR)) {
                 log.warn("Failed to retrieve interface name from a port {} " +
-                                "because of unsupported ovs-based sr-iov");
+                                "because of unsupported ovs-based sr-iov", port.getId());
                 return;
             }
 
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
index 615de0e..16dcc21 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
@@ -137,6 +137,7 @@
 import static org.onlab.packet.Ip4Address.valueOf;
 import static org.onosproject.net.AnnotationKeys.PORT_NAME;
 import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
+import static org.onosproject.openstacknetworking.api.Constants.DIRECT;
 import static org.onosproject.openstacknetworking.api.Constants.FLOATING_IP_FORMAT;
 import static org.onosproject.openstacknetworking.api.Constants.NETWORK_FORMAT;
 import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_REST_PATH;
@@ -399,6 +400,24 @@
     }
 
     /**
+     * Checks whether the given openstack port is smart NIC capable.
+     *
+     * @param port openstack port
+     * @return true if the given port is smart NIC capable, false otherwise
+     */
+    public static boolean isSmartNicCapable(Port port) {
+        if (port.getProfile() != null && port.getvNicType().equals(DIRECT)) {
+            String vendorInfo = String.valueOf(port.getProfile().get(PCI_VENDOR_INFO));
+            if (portNamePrefixMap().containsKey(vendorInfo)) {
+                log.debug("Port {} is a Smart NIC capable port.", port.getId());
+                return true;
+            }
+            return false;
+        }
+        return false;
+    }
+
+    /**
      * Extract the interface name with the supplied port.
      *
      * @param port port