Added dummy mellanox driver

Change-Id: I0dc9643709ca1b691f4ac153982be56359544807
diff --git a/drivers/mellanox-pro/BUCK b/drivers/mellanox-pro/BUCK
new file mode 100644
index 0000000..4b5f336
--- /dev/null
+++ b/drivers/mellanox-pro/BUCK
@@ -0,0 +1,25 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//drivers/p4runtime:onos-drivers-p4runtime',
+]
+
+BUNDLES = [
+    ':onos-drivers-mellanox-pro',
+]
+
+osgi_jar(
+    deps = COMPILE_DEPS,
+)
+
+onos_app(
+    app_name = 'org.onosproject.drivers.mellanox-pro',
+    title = 'Mellanox PRO Drivers',
+    category = 'Drivers',
+    url = 'http://onosproject.org',
+    description = 'Adds support for Mellanox Spectrum-based devices using P4Runtime',
+    included_bundles = BUNDLES,
+    required_apps = [
+        'org.onosproject.drivers.p4runtime',
+        'org.onosproject.pipelines.fabric',
+    ],
+)
diff --git a/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/MellanoxProDriversLoader.java b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/MellanoxProDriversLoader.java
new file mode 100644
index 0000000..31534ec
--- /dev/null
+++ b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/MellanoxProDriversLoader.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018-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.mellanox.pro;
+
+import org.apache.felix.scr.annotations.Component;
+import org.onosproject.net.driver.AbstractDriverLoader;
+
+/**
+ * Loader for the Mellanox PRO device drivers.
+ */
+@Component(immediate = true)
+public class MellanoxProDriversLoader extends AbstractDriverLoader {
+
+    public MellanoxProDriversLoader() {
+        super("/mellanox-pro-drivers.xml");
+    }
+}
diff --git a/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/SpectrumProPipelineProgrammable.java b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/SpectrumProPipelineProgrammable.java
new file mode 100644
index 0000000..01598b7
--- /dev/null
+++ b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/SpectrumProPipelineProgrammable.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2018-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.mellanox.pro;
+
+import org.onosproject.drivers.p4runtime.AbstractP4RuntimePipelineProgrammable;
+import org.onosproject.net.behaviour.PiPipelineProgrammable;
+import org.onosproject.net.pi.model.PiPipeconf;
+import org.onosproject.net.pi.model.PiPipeconfId;
+import org.onosproject.net.pi.service.PiPipeconfService;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.lang.String.format;
+
+/**
+ * Implementation of the PiPipelineProgrammable behaviour for a Spectrum-based
+ * switch.
+ */
+public class SpectrumProPipelineProgrammable
+        extends AbstractP4RuntimePipelineProgrammable
+        implements PiPipelineProgrammable {
+
+    private static final PiPipeconfId FABRIC_PIPECONF_ID =
+            new PiPipeconfId("org.onosproject.pipelines.fabric");
+
+    @Override
+    public ByteBuffer createDeviceDataBuffer(PiPipeconf pipeconf) {
+        checkArgument(pipeconf.id().equals(FABRIC_PIPECONF_ID),
+                      format("Cannot program Spectrum device with a pipeconf " +
+                                     "other than '%s' (found '%s')",
+                             FABRIC_PIPECONF_ID, pipeconf.id()));
+        // [MWC-2018] Dummy value. The chip is already configured with fabric.p4
+        return ByteBuffer.allocate(1).put((byte) 1);
+    }
+
+    @Override
+    public Optional<PiPipeconf> getDefaultPipeconf() {
+        return handler().get(PiPipeconfService.class)
+                .getPipeconf(FABRIC_PIPECONF_ID);
+    }
+}
diff --git a/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/package-info.java b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/package-info.java
new file mode 100644
index 0000000..5930379
--- /dev/null
+++ b/drivers/mellanox-pro/src/main/java/org/onosproject/drivers/mellanox/pro/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018-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 for Mellanox PRO device drivers.
+ */
+package org.onosproject.drivers.mellanox.pro;
diff --git a/drivers/mellanox-pro/src/main/resources/mellanox-pro-drivers.xml b/drivers/mellanox-pro/src/main/resources/mellanox-pro-drivers.xml
new file mode 100644
index 0000000..a3b8f0e
--- /dev/null
+++ b/drivers/mellanox-pro/src/main/resources/mellanox-pro-drivers.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2018-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.
+  -->
+<drivers>
+    <driver name="mellanox-pro" manufacturer="Mellanox" hwVersion="1.0" swVersion="1.0" extends="p4runtime">
+        <behaviour api="org.onosproject.net.behaviour.PiPipelineProgrammable"
+                   impl="org.onosproject.drivers.mellanox.pro.SpectrumProPipelineProgrammable"/>
+    </driver>
+</drivers>
+
diff --git a/mwc.defs b/mwc.defs
index a7312a7..461192e 100644
--- a/mwc.defs
+++ b/mwc.defs
@@ -4,6 +4,7 @@
     '//pipelines/fabric-pro:onos-pipelines-fabric-pro-oar',
     '//drivers/barefoot-pro:onos-drivers-barefoot-pro-oar',
     '//drivers/cavium-pro:onos-drivers-cavium-pro-oar',
+    '//drivers/mellanox-pro:onos-drivers-mellanox-pro-oar',
 ]
 
 APPS = APPS + MWC_APPS