summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--it/jvpp-benchmark/asciidoc/Readme.adoc8
-rw-r--r--it/jvpp-benchmark/pom.xml5
-rw-r--r--it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java2
-rw-r--r--it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java78
4 files changed, 82 insertions, 11 deletions
diff --git a/it/jvpp-benchmark/asciidoc/Readme.adoc b/it/jvpp-benchmark/asciidoc/Readme.adoc
index 604abf9b3..8c787d4ac 100644
--- a/it/jvpp-benchmark/asciidoc/Readme.adoc
+++ b/it/jvpp-benchmark/asciidoc/Readme.adoc
@@ -5,7 +5,7 @@ Provides JMH based benchmarks JVpp (Java API for VPP).
== AclUpdateBenchmark
Creates ACL of size aclSize using acl_add_replace,
-then assigns it to local0 using acl_interface_set_acl_list.
+then assigns it to loopback interface using acl_interface_set_acl_list.
Then ACL is updated synchronously using acl_add_replace.
By default 20x2s warmup and 100x2s measurment iterations
@@ -42,6 +42,12 @@ To specify aclSetSize (default=100), use:
sudo java -jar ./target/jvpp-benchmark-exec.jar -p aclSetSize=1000
---
+To test interface in bridged (L2) / routed (L3) mode (default=L3), use:
+[source,shell]
+---
+sudo java -jar ./target/jvpp-benchmark-exec.jar -p mode=L2
+---
+
To see more options, use
[source,shell]
---
diff --git a/it/jvpp-benchmark/pom.xml b/it/jvpp-benchmark/pom.xml
index 4c1920a10..ea1886ba6 100644
--- a/it/jvpp-benchmark/pom.xml
+++ b/it/jvpp-benchmark/pom.xml
@@ -65,6 +65,11 @@
</dependency>
<dependency>
<groupId>io.fd.vpp</groupId>
+ <artifactId>jvpp-core</artifactId>
+ <version>${jvpp.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.fd.vpp</groupId>
<artifactId>jvpp-acl</artifactId>
<version>${jvpp.version}</version>
</dependency>
diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
index fea9055ea..98894fe1d 100644
--- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
+++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
@@ -88,7 +88,7 @@ class AclProviderImpl implements AclProvider {
}
private static final class IpProvider {
- private long ip = 0x01000000; // 1.0.0.0
+ private long ip = 0x01000001; // 1.0.0.1
private static byte[] getIp(final int i) {
int b1 = (i >> 24) & 0xff;
diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
index ef314b8e5..3ec7be953 100644
--- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
+++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
@@ -16,15 +16,28 @@
package io.fd.hc2vpp.it.jvpp.benchmark;
+import static io.fd.hc2vpp.it.jvpp.benchmark.AclUpdateBenchmark.InterfaceMode.L2;
+import static io.fd.hc2vpp.it.jvpp.benchmark.AclUpdateBenchmark.InterfaceMode.L3;
+
import com.google.common.io.CharStreams;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.acl.JVppAclImpl;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclList;
import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
+import io.fd.vpp.jvpp.core.JVppCoreImpl;
+import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDel;
+import io.fd.vpp.jvpp.core.dto.CreateLoopback;
+import io.fd.vpp.jvpp.core.dto.CreateLoopbackReply;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge;
+import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import io.fd.vpp.jvpp.dto.JVppReply;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
@@ -63,13 +76,17 @@ public class AclUpdateBenchmark {
@Param( {"100"})
private int aclSetSize;
+ @Param( {"L3"})
+ private InterfaceMode mode;
+
private AclProvider aclProvider;
private JVppRegistryImpl registry;
- private FutureJVppAclFacade jvpp;
+ private FutureJVppAclFacade jvppAcl;
+ private FutureJVppCoreFacade jvppCore;
@Benchmark
public void testMethod() throws Exception {
- jvpp.aclAddReplace(aclProvider.next()).toCompletableFuture().get();
+ jvppAcl.aclAddReplace(aclProvider.next()).toCompletableFuture().get();
}
@Setup(Level.Iteration)
@@ -122,34 +139,77 @@ public class AclUpdateBenchmark {
private void connect() throws IOException {
LOG.info("Connecting to JVPP ...");
registry = new JVppRegistryImpl("ACLUpdateBenchmark");
- jvpp = new FutureJVppAclFacade(registry, new JVppAclImpl());
+ jvppCore = new FutureJVppCoreFacade(registry, new JVppCoreImpl());
+ jvppAcl = new FutureJVppAclFacade(registry, new JVppAclImpl());
LOG.info("Successfully connected to JVPP");
}
private void disconnect() throws Exception {
LOG.info("Disconnecting ...");
- jvpp.close();
+ jvppAcl.close();
+ jvppCore.close();
registry.close();
LOG.info("Successfully disconnected ...");
}
/**
- * Creates ACL and assigns it to local0 interface.
+ * Initializes loopback interface, creates ACL and assigns it to loop0.
*/
private void initAcl()
throws ExecutionException, InterruptedException {
+ // Create loopback interface
+ final CreateLoopbackReply loop0 = invoke(jvppCore.createLoopback(new CreateLoopback()));
+
+ // Enable loop0
+ final SwInterfaceSetFlags flags = new SwInterfaceSetFlags();
+ flags.adminUpDown = 1;
+ flags.swIfIndex = loop0.swIfIndex;
+ invoke(jvppCore.swInterfaceSetFlags(flags));
+
+ if (L3.equals(mode)) {
+ // Assign IP to loop0
+ final SwInterfaceAddDelAddress address = new SwInterfaceAddDelAddress();
+ address.address = new byte[]{1,0,0,0};
+ address.addressLength = 8;
+ address.isAdd = 1;
+ address.swIfIndex = loop0.swIfIndex;
+ invoke(jvppCore.swInterfaceAddDelAddress(address));
+ } else if (L2.equals(mode)) {
+ // Create bridge domain 1
+ final BridgeDomainAddDel bd = new BridgeDomainAddDel();
+ bd.bdId = 1;
+ bd.isAdd = 1;
+ invoke(jvppCore.bridgeDomainAddDel(bd));
+
+ // Assign loop0 to BD1:
+ final SwInterfaceSetL2Bridge loop0Bridge = new SwInterfaceSetL2Bridge();
+ loop0Bridge.bdId = bd.bdId;
+ loop0Bridge.rxSwIfIndex = loop0.swIfIndex;
+ loop0Bridge.enable = 1; // set L2 mode
+ invoke(jvppCore.swInterfaceSetL2Bridge(loop0Bridge));
+ }
+
// Create ACL
- final int aclId = jvpp.aclAddReplace(aclProvider.next()).toCompletableFuture().get().aclIndex;
+ final int aclId = invoke(jvppAcl.aclAddReplace(aclProvider.next())).aclIndex;
- // Assign the ACL to local0 interface
+ // Assign the ACL to loop0 interface
final AclInterfaceSetAclList aclList = new AclInterfaceSetAclList();
- aclList.swIfIndex = 0;
+ aclList.swIfIndex = loop0.swIfIndex;
aclList.count = 1;
aclList.nInput = 1;
aclList.acls = new int[] {aclId};
- jvpp.aclInterfaceSetAclList(aclList).toCompletableFuture().get();
+ invoke(jvppAcl.aclInterfaceSetAclList(aclList));
// Use ACL index in subsequent executions of aclProvider.next() method
aclProvider.setAclIndex(aclId);
}
+
+ public enum InterfaceMode {
+ L2, L3
+ }
+
+ private static <R extends JVppReply<?>> R invoke(final CompletionStage<R> completionStage)
+ throws ExecutionException, InterruptedException {
+ return completionStage.toCompletableFuture().get();
+ }
}