Supports dpdk config in OpenstackNode.
Change-Id: I332d7643acb56c5fa7460edb6e4c90a2d862706f
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
index c10820e..b7ca1f5 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
@@ -24,6 +24,7 @@
}
public static final String INTEGRATION_BRIDGE = "br-int";
+ public static final String TUNNEL_BRIDGE = "br-tun";
public static final String ROUTER_BRIDGE = "br-router";
public static final String DEFAULT_TUNNEL = "vxlan";
public static final String PATCH_INTG_BRIDGE = "patch-intg";
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
index 220f7fc..94afc4e 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
@@ -25,6 +25,7 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.device.DeviceService;
+import org.onosproject.openstacknode.api.DpdkConfig.DatapathType;
import java.util.ArrayList;
import java.util.Collection;
@@ -55,8 +56,7 @@
private final OpenstackAuth auth;
private final String endpoint;
private final OpenstackSshAuth sshAuth;
- private final DatapathType datapathType;
- private final String socketDir;
+ private final DpdkConfig dpdkConfig;
private static final String NOT_NULL_MSG = "Node % cannot be null";
@@ -78,8 +78,7 @@
* @param auth keystone authentication info
* @param endpoint openstack endpoint URL
* @param sshAuth ssh authentication info
- * @param datapathType data path type
- * @param socketDir socket directory
+ * @param dpdkConfig dpdk config
*/
protected DefaultOpenstackNode(String hostname, NodeType type,
DeviceId intgBridge,
@@ -93,8 +92,7 @@
OpenstackAuth auth,
String endpoint,
OpenstackSshAuth sshAuth,
- DatapathType datapathType,
- String socketDir) {
+ DpdkConfig dpdkConfig) {
this.hostname = hostname;
this.type = type;
this.intgBridge = intgBridge;
@@ -108,8 +106,7 @@
this.auth = auth;
this.endpoint = endpoint;
this.sshAuth = sshAuth;
- this.datapathType = datapathType;
- this.socketDir = socketDir;
+ this.dpdkConfig = dpdkConfig;
}
@Override
@@ -154,12 +151,18 @@
@Override
public DatapathType datapathType() {
- return datapathType;
+ if (dpdkConfig == null) {
+ return DatapathType.NORMAL;
+ }
+ return dpdkConfig.datapathType();
}
@Override
public String socketDir() {
- return socketDir;
+ if (dpdkConfig == null) {
+ return null;
+ }
+ return dpdkConfig.socketDir();
}
@Override
@@ -253,8 +256,7 @@
Objects.equals(auth, that.auth) &&
Objects.equals(endpoint, that.endpoint) &&
Objects.equals(sshAuth, that.sshAuth) &&
- Objects.equals(datapathType, that.datapathType) &&
- Objects.equals(socketDir, that.socketDir);
+ Objects.equals(dpdkConfig, that.dpdkConfig);
}
return false;
}
@@ -273,8 +275,7 @@
auth,
endpoint,
sshAuth,
- datapathType,
- socketDir);
+ dpdkConfig);
}
@Override
@@ -293,8 +294,7 @@
.add("auth", auth)
.add("endpoint", endpoint)
.add("sshAuth", sshAuth)
- .add("datapathType", datapathType)
- .add("socketDir", socketDir)
+ .add("datapathType", dpdkConfig)
.toString();
}
@@ -314,7 +314,7 @@
.authentication(auth)
.endpoint(endpoint)
.sshAuthInfo(sshAuth)
- .datapathType(datapathType)
+ .dpdkConfig(dpdkConfig)
.build();
}
@@ -334,8 +334,7 @@
.authentication(auth)
.endpoint(endpoint)
.sshAuthInfo(sshAuth)
- .datapathType(datapathType)
- .socketDir(socketDir)
+ .dpdkConfig(dpdkConfig)
.build();
}
@@ -364,6 +363,11 @@
}
@Override
+ public DpdkConfig dpdkConfig() {
+ return dpdkConfig;
+ }
+
+ @Override
public PortNumber phyIntfPortNum(String providerPhysnet) {
Optional<OpenstackPhyInterface> openstackPhyInterface =
phyIntfs.stream().filter(p -> p.network().equals(providerPhysnet)).findAny();
@@ -422,8 +426,7 @@
.authentication(osNode.authentication())
.endpoint(osNode.endpoint())
.sshAuthInfo(osNode.sshAuthInfo())
- .datapathType(osNode.datapathType())
- .socketDir(osNode.socketDir());
+ .dpdkConfig(osNode.dpdkConfig());
}
/**
@@ -444,8 +447,7 @@
private OpenstackAuth auth;
private String endpoint;
private OpenstackSshAuth sshAuth;
- private DatapathType datapathType = DatapathType.NORMAL;
- private String socketDir;
+ private DpdkConfig dpdkConfig;
// private constructor not intended to use from external
private Builder() {
@@ -483,8 +485,7 @@
auth,
endpoint,
sshAuth,
- datapathType,
- socketDir);
+ dpdkConfig);
}
@Override
@@ -568,14 +569,8 @@
}
@Override
- public Builder datapathType(DatapathType datapathType) {
- this.datapathType = datapathType;
- return this;
- }
-
- @Override
- public Builder socketDir(String socketDir) {
- this.socketDir = socketDir;
+ public Builder dpdkConfig(DpdkConfig dpdkConfig) {
+ this.dpdkConfig = dpdkConfig;
return this;
}
}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkConfig.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkConfig.java
new file mode 100644
index 0000000..92cc5d1
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkConfig.java
@@ -0,0 +1,86 @@
+/*
+ * 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.openstacknode.api;
+
+import java.util.Collection;
+
+/**
+ * Representation of dpdk config information.
+ */
+public interface DpdkConfig {
+
+ /**
+ * List of valid data path types.
+ */
+ enum DatapathType {
+ NORMAL,
+ NETDEV
+ }
+
+ /**
+ * Returns the data path type.
+ *
+ * @return data path type; normal or netdev
+ */
+ DatapathType datapathType();
+
+ /**
+ * Returns socket directory which dpdk port bound to.
+ *
+ * @return socket directory
+ */
+ String socketDir();
+
+ /**
+ * Returns a collection of dpdk interfaces.
+ *
+ * @return dpdk interfaces
+ */
+ Collection<DpdkInterface> dpdkIntfs();
+
+ interface Builder {
+ /**
+ * Returns new dpdk config.
+ *
+ * @return dpdk config
+ */
+ DpdkConfig build();
+
+ /**
+ * Returns dpdk config builder with supplied datapath type.
+ *
+ * @param datapathType datapath type
+ * @return dpdk config builder
+ */
+ Builder datapathType(DatapathType datapathType);
+
+ /**
+ * Returns dpdk config builder with supplied socket directory.
+ *
+ * @param socketDir socket directory
+ * @return dpdk config builder
+ */
+ Builder socketDir(String socketDir);
+
+ /**
+ * Returns dpdk config builder with supplied dpdk interfaces.
+ *
+ * @param dpdkIntfs a collection of dpdk interfaces
+ * @return dpdk config builder
+ */
+ Builder dpdkIntfs(Collection<DpdkInterface> dpdkIntfs);
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkInterface.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkInterface.java
new file mode 100644
index 0000000..d10348e
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DpdkInterface.java
@@ -0,0 +1,130 @@
+/*
+ * 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.openstacknode.api;
+
+/**
+ * Representation of dpdk interface information.
+ */
+public interface DpdkInterface {
+ Long DEFAULT_MTU_SIZE = 1500L;
+
+ /**
+ * Dpdk interface type.
+ */
+ enum Type {
+ /**
+ * A DPDK net device.
+ */
+ DPDK,
+ /**
+ * A DPDK_VHOST_USER net device.
+ */
+ DPDK_VHOST_USER,
+ /**
+ * A DPDK_VHOST_USER_CLIENT net device.
+ */
+ DPDK_VHOST_USER_CLIENT
+ }
+
+
+ /**
+ * Returns the name of the device where the dpdk interface is.
+ *
+ * @return device name
+ */
+ String deviceName();
+
+ /**
+ * Returns the name of the dpdk interface.
+ *
+ * @return dpdk interface name
+ */
+ String intf();
+
+ /**
+ * Returns the dpdk device arguments of this dpdk port.
+ * ex) "0000:85:00.1"
+ *
+ * @return pci address
+ */
+ String pciAddress();
+
+ /**
+ * Returns the dpdk interface type.
+ *
+ * @return type
+ */
+ Type type();
+
+ /**
+ * Returns the mtu size.
+ *
+ * @return mtu
+ */
+ Long mtu();
+
+ /**
+ * Builder of dpdk interface description entities.
+ */
+ interface Builder {
+ /**
+ * Returns new dpdk interface.
+ *
+ * @return dpdk interface description
+ */
+ DpdkInterface build();
+
+ /**
+ * Returns dpdk interface builder with supplied device name.
+ *
+ * @param deviceName device name
+ * @return dpdk interface
+ */
+ Builder deviceName(String deviceName);
+
+ /**
+ * Returns dpdk interface builder with supplied interface name.
+ *
+ * @param name interface name
+ * @return dpdk interface
+ */
+ Builder intf(String name);
+
+ /**
+ * Returns dpdk interface builder with supplied pci address.
+ *
+ * @param pciAddress pci address
+ * @return dpdk interface
+ */
+ Builder pciAddress(String pciAddress);
+
+ /**
+ * Returns dpdk interface builder with supplied type.
+ *
+ * @param type type
+ * @return dpdk interface
+ */
+ Builder type(Type type);
+
+ /**
+ * Returns dpdk interface builder with supplied mtu size.
+ *
+ * @param mtu mtu
+ * @return dpdk interface
+ */
+ Builder mtu(Long mtu);
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
index a935e08..3ffdda9 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
@@ -20,6 +20,7 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.openstacknode.api.DpdkConfig.DatapathType;
import java.util.Collection;
@@ -48,14 +49,6 @@
}
/**
- * List of valid data path types.
- */
- enum DatapathType {
- NORMAL,
- NETDEV
- }
-
- /**
* Returns hostname of the node.
*
* @return hostname
@@ -227,6 +220,13 @@
OpenstackSshAuth sshAuthInfo();
/**
+ * Returns the dpdk config info.
+ *
+ * @return dpdk config
+ */
+ DpdkConfig dpdkConfig();
+
+ /**
* Builder of new node entities.
*/
interface Builder {
@@ -343,20 +343,12 @@
Builder sshAuthInfo(OpenstackSshAuth sshAuth);
/**
- * Returns openstack node builder with supplied data path type.
+ * Returns openstack node builder with supplied dpdk config info.
*
- * @param datapathType data path type
+ * @param dpdkConfig dpdk config
* @return openstack node builder
*/
- Builder datapathType(DatapathType datapathType);
-
- /**
- * Returns openstack node builder with supplied socket directory.
- *
- * @param socketDir socket directory
- * @return openstack node builder
- */
- Builder socketDir(String socketDir);
+ Builder dpdkConfig(DpdkConfig dpdkConfig);
}
}