[ONOS-7311] and [ONOS-7197] Update ONOS to support most recent version of BMv2 and PI

Change-Id: Ie69cfe1946f3c9241dc7f59a64bd40005a063931
This commit is contained in:
Andrea Campanella 2017-12-11 11:34:45 +01:00 committed by Carmelo Cascone
parent 61881df1ee
commit 8bcd5863ff
22 changed files with 21 additions and 140 deletions

View File

@ -1,5 +1,5 @@
GRPC_VER = '1.3.0'
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
COMPILE_DEPS = [
'//lib:CORE_DEPS',

View File

@ -25,7 +25,6 @@ import org.junit.Test;
import org.onlab.util.ImmutableByteSequence;
import org.onosproject.grpc.ctl.GrpcControllerImpl;
import org.onosproject.net.DeviceId;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiActionId;
import org.onosproject.net.pi.model.PiActionParamId;
import org.onosproject.net.pi.model.PiActionProfileId;
@ -64,7 +63,6 @@ import static org.onlab.util.ImmutableByteSequence.ofZeros;
import static org.onosproject.net.pi.model.PiPacketOperationType.PACKET_OUT;
import static org.onosproject.net.pi.model.PiPipeconf.ExtensionType.BMV2_JSON;
import static org.slf4j.LoggerFactory.getLogger;
import static p4.P4RuntimeOuterClass.ActionProfileGroup.Type.SELECT;
import static p4.P4RuntimeOuterClass.Update.Type.INSERT;
/**
@ -170,7 +168,6 @@ public class P4RuntimeTest {
P4RuntimeOuterClass.ActionProfileGroup groupMsg = P4RuntimeOuterClass.ActionProfileGroup.newBuilder()
.setActionProfileId(actionProfileId)
.setGroupId(1)
.setType(SELECT)
.addMembers(P4RuntimeOuterClass.ActionProfileGroup.Member.newBuilder()
.setMemberId(1)
.setWeight(1)
@ -269,7 +266,6 @@ public class P4RuntimeTest {
members.add(member);
}
PiActionGroup actionGroup = PiActionGroup.builder()
.withType(PiActionGroupType.SELECT)
.withActionProfileId(actionProfileId)
.withId(groupId)
.addMembers(members)

View File

@ -1,31 +0,0 @@
/*
* Copyright 2017-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.net.pi.model;
import com.google.common.annotations.Beta;
/**
* Type of action group in a protocol-independent pipeline.
*/
@Beta
public enum PiActionGroupType {
/**
* Performs load-balancing among different members of the group.
*/
SELECT
}

View File

@ -21,7 +21,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiActionProfileId;
import java.util.Collection;
@ -37,15 +36,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
public final class PiActionGroup implements PiEntity {
private final PiActionGroupId id;
private final PiActionGroupType type;
private final ImmutableSet<PiActionGroupMember> members;
private final PiActionProfileId piActionProfileId;
private PiActionGroup(PiActionGroupId id, PiActionGroupType type,
ImmutableSet<PiActionGroupMember> members,
private PiActionGroup(PiActionGroupId id, ImmutableSet<PiActionGroupMember> members,
PiActionProfileId piActionProfileId) {
this.id = id;
this.type = type;
this.members = members;
this.piActionProfileId = piActionProfileId;
}
@ -59,15 +55,6 @@ public final class PiActionGroup implements PiEntity {
return id;
}
/**
* Returns the type of this action group.
*
* @return action group type
*/
public PiActionGroupType type() {
return type;
}
/**
* Returns the members of this action group.
*
@ -96,21 +83,19 @@ public final class PiActionGroup implements PiEntity {
}
PiActionGroup that = (PiActionGroup) o;
return Objects.equal(id, that.id) &&
Objects.equal(type, that.type) &&
Objects.equal(members, that.members) &&
Objects.equal(piActionProfileId, that.piActionProfileId);
}
@Override
public int hashCode() {
return Objects.hashCode(id, type, members);
return Objects.hashCode(id, members);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("groupId", id)
.add("type", type)
.add("members", members)
.add("piActionProfileId", piActionProfileId)
.toString();
@ -136,7 +121,6 @@ public final class PiActionGroup implements PiEntity {
public static final class Builder {
private PiActionGroupId id;
private PiActionGroupType type;
private Map<PiActionGroupMemberId, PiActionGroupMember> members = Maps.newHashMap();
private PiActionProfileId piActionProfileId;
@ -155,17 +139,6 @@ public final class PiActionGroup implements PiEntity {
return this;
}
/**
* Sets the type of this action group.
*
* @param type action group type
* @return this
*/
public Builder withType(PiActionGroupType type) {
this.type = type;
return this;
}
/**
* Adds one member to this action group.
*
@ -206,11 +179,9 @@ public final class PiActionGroup implements PiEntity {
*/
public PiActionGroup build() {
checkNotNull(id);
checkNotNull(type);
checkArgument(!members.isEmpty(), "Members cannot be empty");
checkNotNull(piActionProfileId);
return new PiActionGroup(id, type,
ImmutableSet.copyOf(members.values()),
return new PiActionGroup(id, ImmutableSet.copyOf(members.values()),
piActionProfileId);
}
}

View File

@ -57,8 +57,7 @@ public final class PiActionGroupMember {
}
/**
* Returns the weight associated to this member. Meaningful if the action group of this member is of type {@link
* org.onosproject.net.pi.model.PiActionGroupType#SELECT}.
* Returns the weight associated to this member.
*
* @return weight
*/
@ -139,8 +138,7 @@ public final class PiActionGroupMember {
}
/**
* Sets the weight of this member. Meaningful only if the action group is of type {@link
* org.onosproject.net.pi.model.PiActionGroupType#SELECT}.
* Sets the weight of this member.
* <p>
* Default value is 0.
*

View File

@ -20,7 +20,6 @@ import com.google.common.collect.Lists;
import com.google.common.testing.EqualsTester;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Test;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiActionId;
import org.onosproject.net.pi.model.PiActionParamId;
@ -54,14 +53,12 @@ public class PiActionGroupTest {
private PiActionGroup piActionGroup1 = PiActionGroup.builder()
.addMember(piActionGroupMember)
.withId(piActionGroupId)
.withType(PiActionGroupType.SELECT)
.withActionProfileId(ACTION_PROF_ID)
.build();
private PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder()
.addMember(piActionGroupMember)
.withId(piActionGroupId)
.withType(PiActionGroupType.SELECT)
.withActionProfileId(ACTION_PROF_ID)
.build();
@ -69,7 +66,6 @@ public class PiActionGroupTest {
private PiActionGroup piActionGroup2 = PiActionGroup.builder()
.addMember(piActionGroupMember)
.withId(piActionGroupId2)
.withType(PiActionGroupType.SELECT)
.withActionProfileId(ACTION_PROF_ID)
.build();
@ -105,7 +101,6 @@ public class PiActionGroupTest {
piActionGroupMembers.add(piActionGroupMember);
assertThat(piActionGroup1, is(notNullValue()));
assertThat(piActionGroup1.id(), is(piActionGroupId));
assertThat(piActionGroup1.type(), is(PiActionGroupType.SELECT));
assertThat("Incorrect members value",
CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionGroupMembers));
}

View File

@ -19,7 +19,6 @@ package org.onosproject.net.pi.impl;
import org.onosproject.net.Device;
import org.onosproject.net.group.Group;
import org.onosproject.net.group.GroupBucket;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiPipeconf;
import org.onosproject.net.pi.model.PiPipelineInterpreter;
import org.onosproject.net.pi.runtime.PiAction;
@ -63,14 +62,6 @@ final class PiGroupTranslatorImpl {
final PiActionGroup.Builder piActionGroupBuilder = PiActionGroup.builder()
.withId(PiActionGroupId.of(group.id().id()));
switch (group.type()) {
case SELECT:
piActionGroupBuilder.withType(PiActionGroupType.SELECT);
break;
default:
throw new PiTranslationException(format("Group type %s not supported", group.type()));
}
if (!(group.appCookie() instanceof PiGroupKey)) {
throw new PiTranslationException("Group app cookie is not PI (class should be PiGroupKey)");
}

View File

@ -43,7 +43,6 @@ import org.onosproject.net.group.Group;
import org.onosproject.net.group.GroupBucket;
import org.onosproject.net.group.GroupBuckets;
import org.onosproject.net.group.GroupDescription;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiPipeconf;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionGroup;
@ -245,8 +244,6 @@ public class PiTranslatorServiceTest {
assertThat("Group ID must be equal",
piGroup1.id().id(), is(equalTo(GROUP_ID.id())));
assertThat("Group type must be SELECT",
piGroup1.type(), is(equalTo(PiActionGroupType.SELECT)));
assertThat("Action profile ID must be equal",
piGroup1.actionProfileId(), is(equalTo(ACT_PRF_WCMP_SELECTOR_ID)));

View File

@ -203,7 +203,6 @@ import org.onosproject.net.meter.MeterId;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.DefaultPacketRequest;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiActionId;
import org.onosproject.net.pi.model.PiActionParamId;
import org.onosproject.net.pi.model.PiActionProfileId;
@ -619,7 +618,6 @@ public final class KryoNamespaces {
.register(DomainConstraint.class)
.register(
// PI model
PiActionGroupType.class,
PiActionId.class,
PiActionParamId.class,
PiActionProfileId.class,

View File

@ -1,4 +1,4 @@
# ***** This file was auto-generated at Tue, 12 Dec 2017 18:49:34 GMT. Do not edit this file manually. *****
# ***** This file was auto-generated at Tue, 12 Dec 2017 22:03:12 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
pass_thru_pom(
@ -1400,15 +1400,6 @@ remote_jar (
visibility = [ 'PUBLIC' ],
)
remote_jar (
name = 'protobuf-java-3.0.2',
out = 'protobuf-java-3.0.2.jar',
url = 'mvn:com.google.protobuf:protobuf-java:jar:3.0.2',
sha1 = 'ee55e8e697d10b6643d77bb1f686bac3b9ba8579',
maven_coords = 'com.google.protobuf:protobuf-java:3.0.2',
visibility = [ 'PUBLIC' ],
)
remote_jar (
name = 'protobuf-java-3.2.0',
out = 'protobuf-java-3.2.0.jar',

View File

@ -255,7 +255,6 @@
"grpc-netty-1.3.0": "mvn:io.grpc:grpc-netty:1.3.0",
"grpc-auth-1.3.0": "mvn:io.grpc:grpc-auth:1.3.0",
"protobuf-java-3.3.0": "mvn:com.google.protobuf:protobuf-java:3.3.0",
"protobuf-java-3.0.2": "mvn:com.google.protobuf:protobuf-java:3.0.2",
"protobuf-java-3.2.0": "mvn:com.google.protobuf:protobuf-java:3.2.0",
"grpc-testing-1.3.0": "mvn:io.grpc:grpc-testing:1.3.0",
"grpc-testing-proto-1.3.0": "mvn:io.grpc:grpc-testing-proto:1.3.0",

View File

@ -1,4 +1,4 @@
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
GRPC_VER = '1.3.0'
BUNDLES = [
@ -13,7 +13,7 @@ BUNDLES = [
'//lib:grpc-netty-1.3.0',
'//lib:grpc-auth-1.3.0',
'//lib:google-instrumentation-0.3.0',
'//lib:protobuf-java-3.0.2',
'//lib:protobuf-java-3.2.0',
# Lazily adding all netty-related packages.
# Some of them might not be necessary.
'//lib:netty',

View File

@ -1,4 +1,4 @@
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
GRPC_VER = '1.3.0'
COMPILE_DEPS = [

View File

@ -2,7 +2,7 @@ include_defs(
'//bucklets/grpc.bucklet'
)
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
GRPC_VER = '1.3.0'
COMPILE_DEPS = [

View File

@ -1,5 +1,5 @@
GRPC_VER = '1.3.0'
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
COMPILE_DEPS = [
'//lib:CORE_DEPS',

View File

@ -17,7 +17,6 @@
package org.onosproject.p4runtime.ctl;
import com.google.common.collect.Maps;
import org.onosproject.net.pi.model.PiActionGroupType;
import org.onosproject.net.pi.model.PiActionProfileId;
import org.onosproject.net.pi.model.PiPipeconf;
import org.onosproject.net.pi.runtime.PiActionGroup;
@ -65,14 +64,6 @@ public final class ActionProfileGroupEncoder {
.setGroupId(piActionGroup.id().id())
.setActionProfileId(actionProfileId);
switch (piActionGroup.type()) {
case SELECT:
actionProfileGroupBuilder.setType(ActionProfileGroup.Type.SELECT);
break;
default:
throw new EncodeException(format("PI action group type %s not supported", piActionGroup.type()));
}
piActionGroup.members().forEach(m -> {
// TODO: currently we don't set "watch" field of member
Member member = Member.newBuilder()
@ -115,17 +106,6 @@ public final class ActionProfileGroupEncoder {
.withActionProfileId(piActionProfileId)
.withId(PiActionGroupId.of(actionProfileGroup.getGroupId()));
switch (actionProfileGroup.getType()) {
case UNSPECIFIED:
// FIXME: PI returns unspecified for select groups. Remove this case when PI bug will be fixed.
case SELECT:
piActionGroupBuilder.withType(PiActionGroupType.SELECT);
break;
default:
throw new EncodeException(format("Action profile type %s is not supported",
actionProfileGroup.getType()));
}
Map<Integer, Integer> memberWeights = Maps.newHashMap();
actionProfileGroup.getMembersList().forEach(member -> {
int weight = member.getWeight();

View File

@ -328,16 +328,16 @@ public final class P4RuntimeClientImpl implements P4RuntimeClient {
ForwardingPipelineConfig pipelineConfig = ForwardingPipelineConfig
.newBuilder()
.setDeviceId(p4DeviceId)
.setP4Info(p4Info)
.setP4DeviceConfig(p4DeviceConfigMsg.toByteString())
.build();
SetForwardingPipelineConfigRequest request = SetForwardingPipelineConfigRequest
.newBuilder()
.setDeviceId(p4DeviceId)
.setElectionId(p4RuntimeElectionId)
.setAction(VERIFY_AND_COMMIT)
.addConfigs(pipelineConfig)
.setConfig(pipelineConfig)
.build();
try {

View File

@ -64,7 +64,6 @@ import static org.easymock.EasyMock.niceMock;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.onosproject.net.pi.model.PiActionGroupType.SELECT;
import static org.onosproject.net.pi.model.PiPipeconf.ExtensionType.P4_INFO_TEXT;
import static org.onosproject.p4runtime.api.P4RuntimeClient.WriteOperationType.INSERT;
import static p4.P4RuntimeOuterClass.Action;
@ -95,7 +94,6 @@ public class P4RuntimeGroupTest {
.withId(GROUP_ID)
.addMembers(GROUP_MEMBERS)
.withActionProfileId(ACT_PROF_ID)
.withType(SELECT)
.build();
private static final DeviceId DEVICE_ID = DeviceId.deviceId("device:p4runtime:1");
private static final int P4_DEVICE_ID = 1;
@ -223,7 +221,6 @@ public class P4RuntimeGroupTest {
public void testReadGroups() throws Exception {
ActionProfileGroup.Builder group = ActionProfileGroup.newBuilder()
.setGroupId(GROUP_ID.id())
.setType(ActionProfileGroup.Type.SELECT)
.setActionProfileId(P4_INFO_ACT_PROF_ID);
List<ActionProfileMember> members = Lists.newArrayList();
@ -277,7 +274,6 @@ public class P4RuntimeGroupTest {
PiActionGroup piActionGroup = groups.iterator().next();
assertEquals(ACT_PROF_ID, piActionGroup.actionProfileId());
assertEquals(GROUP_ID, piActionGroup.id());
assertEquals(SELECT, piActionGroup.type());
assertEquals(3, piActionGroup.members().size());
assertTrue(GROUP_MEMBERS.containsAll(piActionGroup.members()));
assertTrue(piActionGroup.members().containsAll(GROUP_MEMBERS));

View File

@ -1,4 +1,4 @@
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
COMPILE_DEPS = [
'//lib:CORE_DEPS',

View File

@ -2,10 +2,10 @@ include_defs(
'//bucklets/grpc.bucklet'
)
PROTOBUF_VER = '3.0.2'
PROTOBUF_VER = '3.2.0'
GRPC_VER = '1.3.0'
PI_COMMIT = 'a8814a8ac40838a9df83fe47a17a025b69026fcf'
PI_COMMIT = '13d611a9c655938676ebcde2bd5653b461f46ca7'
PI_BASEURL = 'https://github.com/p4lang/PI.git'
# Wondering which .proto files to build? Check p4runtime's Makefile:

View File

@ -29,7 +29,7 @@
<description>ONOS P4Runtime Proto</description>
<properties>
<protobuf.version>3.0.2</protobuf.version>
<protobuf.version>3.2.0</protobuf.version>
<piCommit>a8814a8ac40838a9df83fe47a17a025b69026fcf</piCommit>
<piBaseUrl>https://github.com/p4lang/PI.git</piBaseUrl>
</properties>

View File

@ -15,10 +15,10 @@
set -e
BUILD_DIR=~/p4tools
BMV2_COMMIT="44ac9c21636b00fed660ae8590889d85b5d4df4c"
PI_COMMIT="a8814a8ac40838a9df83fe47a17a025b69026fcf"
BMV2_COMMIT="d930fa2818d8ed71f3bf36eaf3f3687d9b68184f"
PI_COMMIT="13d611a9c655938676ebcde2bd5653b461f46ca7"
P4C_COMMIT="040b931fbfcb7912e3a14cd05df950fbdd49b038"
PROTOBUF_COMMIT="tags/v3.0.2"
PROTOBUF_COMMIT="tags/v3.2.0"
GRPC_COMMIT="tags/v1.3.0"
NUM_CORES=`grep -c ^processor /proc/cpuinfo`