Saurav Das
Committed by Gerrit Code Review

First shot at Broadcom OFDPA 1.0 pipeline

Requires changes to the group description to accept groupId from callers.

Change-Id: Ic21dfe8ae7c246b7d3a6b00e8e5c986e1dc21fa0
......@@ -260,6 +260,8 @@ public class BgpRouter {
.withFlag(ForwardingObjective.Flag.SPECIFIC);
if (nextId == null) {
// Route withdraws are not specified with next hops. Generating
// dummy treatment as there is no equivalent nextId info.
fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build());
} else {
fwdBuilder.nextStep(nextId);
......
......@@ -21,11 +21,11 @@ package org.onosproject.core;
public interface GroupId {
/**
* Returns a group ID as short value.
* Returns a group ID as an integer value.
* The method is not intended for use by application developers.
* Return data type may change in the future release.
*
* @return a group ID as short value
* @return a group ID as integer value
*/
int id();
}
......
......@@ -36,7 +36,7 @@ public enum ObjectiveError {
GROUPINSTALLATIONFAILED,
/**
* The group was reported as installed but is not missing.
* The group was reported as installed but is missing.
*/
GROUPMISSING,
......@@ -46,6 +46,11 @@ public enum ObjectiveError {
DEVICEMISSING,
/**
* Incorrect Objective parameters passed in by the caller.
*/
BADPARAMS,
/**
* An unknown error occurred.
*/
UNKNOWN
......
......@@ -32,11 +32,17 @@ public class DefaultGroupDescription implements GroupDescription {
private final GroupKey appCookie;
private final ApplicationId appId;
private final DeviceId deviceId;
private final Integer givenGroupId;
/**
* Constructor to be used by north bound applications.
* NOTE: The caller of this subsystem MUST ensure the appCookie
* provided in this API is immutable
* provided in this API is immutable.
* NOTE: The caller may choose to pass in 'null' for the groupId. This is
* the typical case, where the caller allows the group subsystem to choose
* the groupId in a globally unique way. If the caller passes in the groupId,
* the caller MUST ensure that the id is globally unique (not just unique
* per device).
*
* @param deviceId device identifier
* @param type type of the group
......@@ -49,11 +55,13 @@ public class DefaultGroupDescription implements GroupDescription {
GroupDescription.Type type,
GroupBuckets buckets,
GroupKey appCookie,
Integer groupId,
ApplicationId appId) {
this.type = checkNotNull(type);
this.deviceId = checkNotNull(deviceId);
this.buckets = checkNotNull(buckets);
this.appCookie = appCookie;
this.givenGroupId = groupId;
this.appId = appId;
}
......@@ -70,6 +78,7 @@ public class DefaultGroupDescription implements GroupDescription {
this.buckets = groupDesc.buckets();
this.appCookie = groupDesc.appCookie();
this.appId = groupDesc.appId();
this.givenGroupId = groupDesc.givenGroupId();
}
/**
......@@ -85,7 +94,7 @@ public class DefaultGroupDescription implements GroupDescription {
public DefaultGroupDescription(DeviceId deviceId,
GroupDescription.Type type,
GroupBuckets buckets) {
this(deviceId, type, buckets, null, null);
this(deviceId, type, buckets, null, null, null);
}
/**
......@@ -138,6 +147,17 @@ public class DefaultGroupDescription implements GroupDescription {
return this.buckets;
}
/**
* Returns groupId passed in by application.
*
* @return Integer group Id passed in by caller. May be null if caller passed
* in null during GroupDescription creation.
*/
@Override
public Integer givenGroupId() {
return this.givenGroupId;
}
@Override
/*
* The deviceId, type and buckets are used for hash.
......@@ -177,6 +197,7 @@ public class DefaultGroupDescription implements GroupDescription {
.add("type", type)
.add("buckets", buckets)
.add("appId", appId)
.add("givenGroupId", givenGroupId)
.toString();
}
}
\ No newline at end of file
......
......@@ -75,6 +75,14 @@ public interface GroupDescription {
public GroupKey appCookie();
/**
* Returns groupId passed in by caller.
*
* @return Integer group id passed in by caller. May be null if caller
* passed in null to let groupService determin the group id.
*/
public Integer givenGroupId();
/**
* Returns group buckets of a group.
*
* @return GroupBuckets immutable list of group bucket
......
......@@ -177,6 +177,7 @@ public class GroupManagerTest {
Group.Type.SELECT,
groupBuckets,
key,
null,
appId);
groupService.addGroup(newGroupDesc);
internalProvider.validate(DID, null);
......@@ -397,6 +398,7 @@ public class GroupManagerTest {
Group.Type.SELECT,
groupBuckets,
key,
null,
appId);
groupService.addGroup(newGroupDesc);
......
......@@ -430,8 +430,13 @@ public class DistributedGroupStore
return;
}
GroupId id = null;
if (groupDesc.givenGroupId() == null) {
// Get a new group identifier
GroupId id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
} else {
id = new DefaultGroupId(groupDesc.givenGroupId());
}
// Create a group entry object
StoredGroupEntry group = new DefaultGroup(id, groupDesc);
// Insert the newly created group entry into key and id maps
......@@ -513,6 +518,7 @@ public class DistributedGroupStore
oldGroup.type(),
updatedBuckets,
newCookie,
oldGroup.givenGroupId(),
oldGroup.appId());
StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(),
updatedGroupDesc);
......@@ -718,6 +724,7 @@ public class DistributedGroupStore
group.type(),
group.buckets(),
group.appCookie(),
group.givenGroupId(),
group.appId());
storeGroupDescriptionInternal(tmp);
getPendingGroupKeyTable().
......
......@@ -275,8 +275,13 @@ public class SimpleGroupStore
return;
}
GroupId id = null;
if (groupDesc.givenGroupId() == null) {
// Get a new group identifier
GroupId id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
} else {
id = new DefaultGroupId(groupDesc.givenGroupId());
}
// Create a group entry object
StoredGroupEntry group = new DefaultGroup(id, groupDesc);
// Insert the newly created group entry into concurrent key and id maps
......@@ -324,6 +329,7 @@ public class SimpleGroupStore
oldGroup.type(),
updatedBuckets,
newCookie,
oldGroup.givenGroupId(),
oldGroup.appId());
StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(),
updatedGroupDesc);
......@@ -494,6 +500,7 @@ public class SimpleGroupStore
group.type(),
group.buckets(),
group.appCookie(),
group.givenGroupId(),
group.appId());
storeGroupDescriptionInternal(tmp);
}
......
......@@ -224,6 +224,7 @@ public class SimpleGroupStoreTest {
Group.Type.SELECT,
groupBuckets,
key,
null,
appId);
InternalGroupStoreDelegate checkStoreGroupDelegate =
new InternalGroupStoreDelegate(key,
......@@ -424,6 +425,7 @@ public class SimpleGroupStoreTest {
Group.Type.SELECT,
groupBuckets,
key,
null,
appId);
InternalGroupStoreDelegate checkStoreGroupDelegate =
new InternalGroupStoreDelegate(key,
......
......@@ -85,8 +85,6 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeliner {
protected static final int MAC_TABLE = 0;
protected static final int VLAN_MPLS_TABLE = 1;
protected static final int VLAN_TABLE = 2;
......@@ -149,7 +147,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
appId = coreService.registerApplication(
"org.onosproject.driver.OVSCorsaPipeline");
pushDefaultRules();
initializePipeline();
}
@Override
......@@ -216,6 +214,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
new GroupBuckets(Collections
.singletonList(bucket)),
key,
null, // let group service determine group id
nextObjective.appId());
groupService.addGroup(groupDescription);
pendingGroups.put(key, nextObjective);
......@@ -454,7 +453,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
}
}
private void pushDefaultRules() {
private void initializePipeline() {
processMacTable(true);
processVlanMplsTable(true);
processVlanTable(true);
......
......@@ -252,6 +252,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
new GroupBuckets(
Collections.singletonList(bucket)),
key,
null,
nextObjective.appId());
groupService.addGroup(groupDescription);
pendingGroups.put(key, nextObjective);
......@@ -274,6 +275,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
GroupDescription.Type.SELECT,
new GroupBuckets(buckets),
key,
null,
nextObjective.appId());
groupService.addGroup(groupDescription);
pendingGroups.put(key, nextObjective);
......
......@@ -55,5 +55,9 @@
<behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
impl="org.onosproject.driver.handshaker.OFCorsaSwitchDriver"/>
</driver>
<driver name="ofdpa" manufacturer="Broadcom Corp." hwVersion="OF-DPA 1.0" swVersion="OF-DPA 1.0">
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.OFDPA1Pipeline"/>
</driver>
</drivers>
......
......@@ -213,6 +213,7 @@ public class Controller {
ofSwitchDriver.init(new Dpid(dpid), desc, ofv);
ofSwitchDriver.setAgent(agent);
ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
return ofSwitchDriver;
}
log.error("No OpenFlow driver for {} : {}", dpid, desc);
......
......@@ -35,6 +35,7 @@ import org.projectfloodlight.openflow.protocol.OFGroupDelete;
import org.projectfloodlight.openflow.protocol.OFGroupMod;
import org.projectfloodlight.openflow.protocol.OFGroupType;
import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
import org.projectfloodlight.openflow.types.CircuitSignalID;
......@@ -210,6 +211,12 @@ public final class GroupModBuilder {
actions.add(action.build());
break;
case GROUP:
Instructions.GroupInstruction grp =
(Instructions.GroupInstruction) i;
OFActionGroup.Builder actgrp = factory.actions().buildGroup()
.setGroup(OFGroup.of(grp.groupId().id()));
actions.add(actgrp.build());
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
......