[ONOS-6519] Supporting OVS DPDK, and PICA8 OVS interface creation & MTU setting

Change-Id: Icee3f9c6cf430d952acc7bfebd82cfa6d94b0e63
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
index df3461d..ebbdd76 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
@@ -16,10 +16,12 @@
 package org.onosproject.ovsdb.controller;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.ovsdb.controller.OvsdbConstant.*;
 
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 
 import com.google.common.collect.Maps;
 import org.onosproject.net.DefaultAnnotations;
@@ -56,20 +58,26 @@
         /**
          * A pair of virtual devices that act as a patch cable.
          */
-        PATCH
+        PATCH,
+        /**
+         * A DPDK net device.
+         */
+        DPDK
     }
 
     private final String name;
     private final Type type;
+    private final Optional<Long> mtu;
 
     /* Adds more configs */
 
     /* Fields start with "options:" prefix defined in the OVSDB */
     private final Map<String, String> options;
 
-    private OvsdbInterface(String name, Type type, Map<String, String> options) {
+    private OvsdbInterface(String name, Type type, Optional<Long> mtu, Map<String, String> options) {
         this.name = name;
-        this.type = type;
+        this.type = checkNotNull(type, "the type of interface can not be null");
+        this.mtu = mtu;
         this.options = Maps.newHashMap(options);
     }
 
@@ -101,6 +109,15 @@
     }
 
     /**
+     * Returns mtu of the interface.
+     *
+     * @return interface mtu
+     */
+    public Optional<Long> mtu() {
+        return mtu;
+    }
+
+    /**
      * Returns optional configs of the interface.
      *
      * @return interface options
@@ -131,6 +148,7 @@
         return toStringHelper(this)
                 .add("name", name)
                 .add("type", type)
+                .add("mtu", mtu)
                 .add("options", options)
                 .toString();
     }
@@ -170,6 +188,7 @@
     public static final class Builder {
         private String name;
         private Type type;
+        private Optional<Long> mtu = Optional.empty();
         private Map<String, String> options = Maps.newHashMap();
 
         private Builder() {
@@ -220,7 +239,7 @@
          * @return ovsdb interface
          */
         public OvsdbInterface build() {
-            return new OvsdbInterface(name, type, options);
+            return new OvsdbInterface(name, type, mtu, options);
         }
 
         /**
@@ -246,6 +265,17 @@
         }
 
         /**
+         * Returns OVSDB interface builder with a given interface mtu.
+         *
+         * @param mtu mtu of the interface
+         * @return ovsdb interface builder
+         */
+        public Builder mtu(Long mtu) {
+            this.mtu = Optional.ofNullable(mtu);
+            return this;
+        }
+
+        /**
          * Returns OVSDB interface builder with given options.
          *
          * @param options map of options
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 2ed28f7..0ed4663 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -1025,7 +1025,16 @@
         // insert an interface
         Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
         intf.setName(ovsdbIface.name());
+
         intf.setType(ovsdbIface.typeToString());
+
+        if (ovsdbIface.mtu().isPresent()) {
+            Set<Long> mtuSet = Sets.newConcurrentHashSet();
+            mtuSet.add(ovsdbIface.mtu().get());
+            intf.setMtu(mtuSet);
+            intf.setMtuRequest(mtuSet);
+        }
+
         intf.setOptions(ovsdbIface.options());
         Insert intfInsert = new Insert(dbSchema.getTableSchema(INTERFACE), INTERFACE, intf.getRow());
         operations.add(intfInsert);
diff --git a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java
index 4e9c656..b8aaa6a 100644
--- a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java
+++ b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java
@@ -46,7 +46,7 @@
         LACPCURRENT("lacp_current"), OTHERCONFIG("other_config"),
         STATISTICS("statistics"), STATUS("status"), ADMINSTATE("admin_state"),
         LINKSTATE("link_state"), LINKRESETS("link_resets"),
-        LINKSPEED("link_speed"), DUPLEX("duplex"), MTU("mtu"), ERROR("error");
+        LINKSPEED("link_speed"), DUPLEX("duplex"), MTU("mtu"), MTU_REQUEST("mtu_request"), ERROR("error");
 
         private final String columnName;
 
@@ -980,6 +980,20 @@
     }
 
     /**
+     * Get the Column entity which column name is "mtuRequest" from the Row entity of
+     * attributes.
+     * @return the Column entity which column name is "mtuRequest"
+     */
+    public Column getMtuRequestColumn() {
+        ColumnDescription columndesc = new ColumnDescription(
+                                                             InterfaceColumn.MTU_REQUEST
+                                                             .columnName(),
+                                                            "getMtuRequestColumn",
+                                                             VersionNum.VERSION7140);
+        return (Column) super.getColumnHandler(columndesc);
+    }
+
+    /**
      * Add a Column entity which column name is "mtu" to the Row entity of
      * attributes.
      * @param mtu the column data which column name is "mtu"
@@ -994,6 +1008,20 @@
     }
 
     /**
+     * Add a Column entity which column name is "mtuRequest" to the Row entity of
+     * attributes.
+     * @param mtuRequest the column data which column name is "mtuRequest"
+     */
+    public void setMtuRequest(Set<Long> mtuRequest) {
+        ColumnDescription columndesc = new ColumnDescription(
+                                                             InterfaceColumn.MTU_REQUEST
+                                                                     .columnName(),
+                                                             "setMtuRequest",
+                                                             VersionNum.VERSION7140);
+        super.setDataHandler(columndesc, mtuRequest);
+    }
+
+    /**
      * Get the Column entity which column name is "error" from the Row entity of
      * attributes.
      * @return the Column entity which column name is "error"
diff --git a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java
index ad2c77e..00aa763 100644
--- a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java
+++ b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java
@@ -29,7 +29,10 @@
     VERSION670("6.7.0"), VERSION680("6.8.0"), VERSION690("6.9.0"),
     VERSION6100("6.10.0"), VERSION6111("6.11.1"), VERSION710("7.1.0"),
     VERSION720("7.2.0"), VERSION721("7.2.1"), VERSION730("7.3.0"),
-    VERSION740("7.4.0"), VERSION750("7.5.0"), VERSION770("7.7.0");
+    VERSION740("7.4.0"), VERSION750("7.5.0"), VERSION760("7.6.0"),
+    VERSION770("7.7.0"), VERSION780("7.8.0"), VERSION790("7.9.0"),
+    VERSION7100("7.10.0"), VERSION7110("7.11.0"), VERSION7120("7.12.0"),
+    VERSION7130("7.13.0"), VERSION7140("7.14.0");
 
     private final String versionNum;