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 { ...@@ -260,6 +260,8 @@ public class BgpRouter {
260 .withFlag(ForwardingObjective.Flag.SPECIFIC); 260 .withFlag(ForwardingObjective.Flag.SPECIFIC);
261 261
262 if (nextId == null) { 262 if (nextId == null) {
263 + // Route withdraws are not specified with next hops. Generating
264 + // dummy treatment as there is no equivalent nextId info.
263 fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build()); 265 fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build());
264 } else { 266 } else {
265 fwdBuilder.nextStep(nextId); 267 fwdBuilder.nextStep(nextId);
......
...@@ -21,11 +21,11 @@ package org.onosproject.core; ...@@ -21,11 +21,11 @@ package org.onosproject.core;
21 public interface GroupId { 21 public interface GroupId {
22 22
23 /** 23 /**
24 - * Returns a group ID as short value. 24 + * Returns a group ID as an integer value.
25 * The method is not intended for use by application developers. 25 * The method is not intended for use by application developers.
26 * Return data type may change in the future release. 26 * Return data type may change in the future release.
27 * 27 *
28 - * @return a group ID as short value 28 + * @return a group ID as integer value
29 */ 29 */
30 int id(); 30 int id();
31 } 31 }
......
...@@ -36,7 +36,7 @@ public enum ObjectiveError { ...@@ -36,7 +36,7 @@ public enum ObjectiveError {
36 GROUPINSTALLATIONFAILED, 36 GROUPINSTALLATIONFAILED,
37 37
38 /** 38 /**
39 - * The group was reported as installed but is not missing. 39 + * The group was reported as installed but is missing.
40 */ 40 */
41 GROUPMISSING, 41 GROUPMISSING,
42 42
...@@ -46,6 +46,11 @@ public enum ObjectiveError { ...@@ -46,6 +46,11 @@ public enum ObjectiveError {
46 DEVICEMISSING, 46 DEVICEMISSING,
47 47
48 /** 48 /**
49 + * Incorrect Objective parameters passed in by the caller.
50 + */
51 + BADPARAMS,
52 +
53 + /**
49 * An unknown error occurred. 54 * An unknown error occurred.
50 */ 55 */
51 UNKNOWN 56 UNKNOWN
......
...@@ -32,11 +32,17 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -32,11 +32,17 @@ public class DefaultGroupDescription implements GroupDescription {
32 private final GroupKey appCookie; 32 private final GroupKey appCookie;
33 private final ApplicationId appId; 33 private final ApplicationId appId;
34 private final DeviceId deviceId; 34 private final DeviceId deviceId;
35 + private final Integer givenGroupId;
35 36
36 /** 37 /**
37 * Constructor to be used by north bound applications. 38 * Constructor to be used by north bound applications.
38 * NOTE: The caller of this subsystem MUST ensure the appCookie 39 * NOTE: The caller of this subsystem MUST ensure the appCookie
39 - * provided in this API is immutable 40 + * provided in this API is immutable.
41 + * NOTE: The caller may choose to pass in 'null' for the groupId. This is
42 + * the typical case, where the caller allows the group subsystem to choose
43 + * the groupId in a globally unique way. If the caller passes in the groupId,
44 + * the caller MUST ensure that the id is globally unique (not just unique
45 + * per device).
40 * 46 *
41 * @param deviceId device identifier 47 * @param deviceId device identifier
42 * @param type type of the group 48 * @param type type of the group
...@@ -49,11 +55,13 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -49,11 +55,13 @@ public class DefaultGroupDescription implements GroupDescription {
49 GroupDescription.Type type, 55 GroupDescription.Type type,
50 GroupBuckets buckets, 56 GroupBuckets buckets,
51 GroupKey appCookie, 57 GroupKey appCookie,
58 + Integer groupId,
52 ApplicationId appId) { 59 ApplicationId appId) {
53 this.type = checkNotNull(type); 60 this.type = checkNotNull(type);
54 this.deviceId = checkNotNull(deviceId); 61 this.deviceId = checkNotNull(deviceId);
55 this.buckets = checkNotNull(buckets); 62 this.buckets = checkNotNull(buckets);
56 this.appCookie = appCookie; 63 this.appCookie = appCookie;
64 + this.givenGroupId = groupId;
57 this.appId = appId; 65 this.appId = appId;
58 } 66 }
59 67
...@@ -70,6 +78,7 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -70,6 +78,7 @@ public class DefaultGroupDescription implements GroupDescription {
70 this.buckets = groupDesc.buckets(); 78 this.buckets = groupDesc.buckets();
71 this.appCookie = groupDesc.appCookie(); 79 this.appCookie = groupDesc.appCookie();
72 this.appId = groupDesc.appId(); 80 this.appId = groupDesc.appId();
81 + this.givenGroupId = groupDesc.givenGroupId();
73 } 82 }
74 83
75 /** 84 /**
...@@ -85,7 +94,7 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -85,7 +94,7 @@ public class DefaultGroupDescription implements GroupDescription {
85 public DefaultGroupDescription(DeviceId deviceId, 94 public DefaultGroupDescription(DeviceId deviceId,
86 GroupDescription.Type type, 95 GroupDescription.Type type,
87 GroupBuckets buckets) { 96 GroupBuckets buckets) {
88 - this(deviceId, type, buckets, null, null); 97 + this(deviceId, type, buckets, null, null, null);
89 } 98 }
90 99
91 /** 100 /**
...@@ -138,6 +147,17 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -138,6 +147,17 @@ public class DefaultGroupDescription implements GroupDescription {
138 return this.buckets; 147 return this.buckets;
139 } 148 }
140 149
150 + /**
151 + * Returns groupId passed in by application.
152 + *
153 + * @return Integer group Id passed in by caller. May be null if caller passed
154 + * in null during GroupDescription creation.
155 + */
156 + @Override
157 + public Integer givenGroupId() {
158 + return this.givenGroupId;
159 + }
160 +
141 @Override 161 @Override
142 /* 162 /*
143 * The deviceId, type and buckets are used for hash. 163 * The deviceId, type and buckets are used for hash.
...@@ -177,6 +197,7 @@ public class DefaultGroupDescription implements GroupDescription { ...@@ -177,6 +197,7 @@ public class DefaultGroupDescription implements GroupDescription {
177 .add("type", type) 197 .add("type", type)
178 .add("buckets", buckets) 198 .add("buckets", buckets)
179 .add("appId", appId) 199 .add("appId", appId)
200 + .add("givenGroupId", givenGroupId)
180 .toString(); 201 .toString();
181 } 202 }
182 } 203 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -75,6 +75,14 @@ public interface GroupDescription { ...@@ -75,6 +75,14 @@ public interface GroupDescription {
75 public GroupKey appCookie(); 75 public GroupKey appCookie();
76 76
77 /** 77 /**
78 + * Returns groupId passed in by caller.
79 + *
80 + * @return Integer group id passed in by caller. May be null if caller
81 + * passed in null to let groupService determin the group id.
82 + */
83 + public Integer givenGroupId();
84 +
85 + /**
78 * Returns group buckets of a group. 86 * Returns group buckets of a group.
79 * 87 *
80 * @return GroupBuckets immutable list of group bucket 88 * @return GroupBuckets immutable list of group bucket
......
...@@ -177,6 +177,7 @@ public class GroupManagerTest { ...@@ -177,6 +177,7 @@ public class GroupManagerTest {
177 Group.Type.SELECT, 177 Group.Type.SELECT,
178 groupBuckets, 178 groupBuckets,
179 key, 179 key,
180 + null,
180 appId); 181 appId);
181 groupService.addGroup(newGroupDesc); 182 groupService.addGroup(newGroupDesc);
182 internalProvider.validate(DID, null); 183 internalProvider.validate(DID, null);
...@@ -397,6 +398,7 @@ public class GroupManagerTest { ...@@ -397,6 +398,7 @@ public class GroupManagerTest {
397 Group.Type.SELECT, 398 Group.Type.SELECT,
398 groupBuckets, 399 groupBuckets,
399 key, 400 key,
401 + null,
400 appId); 402 appId);
401 groupService.addGroup(newGroupDesc); 403 groupService.addGroup(newGroupDesc);
402 404
......
...@@ -430,8 +430,13 @@ public class DistributedGroupStore ...@@ -430,8 +430,13 @@ public class DistributedGroupStore
430 return; 430 return;
431 } 431 }
432 432
433 + GroupId id = null;
434 + if (groupDesc.givenGroupId() == null) {
433 // Get a new group identifier 435 // Get a new group identifier
434 - GroupId id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId())); 436 + id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
437 + } else {
438 + id = new DefaultGroupId(groupDesc.givenGroupId());
439 + }
435 // Create a group entry object 440 // Create a group entry object
436 StoredGroupEntry group = new DefaultGroup(id, groupDesc); 441 StoredGroupEntry group = new DefaultGroup(id, groupDesc);
437 // Insert the newly created group entry into key and id maps 442 // Insert the newly created group entry into key and id maps
...@@ -513,6 +518,7 @@ public class DistributedGroupStore ...@@ -513,6 +518,7 @@ public class DistributedGroupStore
513 oldGroup.type(), 518 oldGroup.type(),
514 updatedBuckets, 519 updatedBuckets,
515 newCookie, 520 newCookie,
521 + oldGroup.givenGroupId(),
516 oldGroup.appId()); 522 oldGroup.appId());
517 StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(), 523 StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(),
518 updatedGroupDesc); 524 updatedGroupDesc);
...@@ -718,6 +724,7 @@ public class DistributedGroupStore ...@@ -718,6 +724,7 @@ public class DistributedGroupStore
718 group.type(), 724 group.type(),
719 group.buckets(), 725 group.buckets(),
720 group.appCookie(), 726 group.appCookie(),
727 + group.givenGroupId(),
721 group.appId()); 728 group.appId());
722 storeGroupDescriptionInternal(tmp); 729 storeGroupDescriptionInternal(tmp);
723 getPendingGroupKeyTable(). 730 getPendingGroupKeyTable().
......
...@@ -275,8 +275,13 @@ public class SimpleGroupStore ...@@ -275,8 +275,13 @@ public class SimpleGroupStore
275 return; 275 return;
276 } 276 }
277 277
278 + GroupId id = null;
279 + if (groupDesc.givenGroupId() == null) {
278 // Get a new group identifier 280 // Get a new group identifier
279 - GroupId id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId())); 281 + id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
282 + } else {
283 + id = new DefaultGroupId(groupDesc.givenGroupId());
284 + }
280 // Create a group entry object 285 // Create a group entry object
281 StoredGroupEntry group = new DefaultGroup(id, groupDesc); 286 StoredGroupEntry group = new DefaultGroup(id, groupDesc);
282 // Insert the newly created group entry into concurrent key and id maps 287 // Insert the newly created group entry into concurrent key and id maps
...@@ -324,6 +329,7 @@ public class SimpleGroupStore ...@@ -324,6 +329,7 @@ public class SimpleGroupStore
324 oldGroup.type(), 329 oldGroup.type(),
325 updatedBuckets, 330 updatedBuckets,
326 newCookie, 331 newCookie,
332 + oldGroup.givenGroupId(),
327 oldGroup.appId()); 333 oldGroup.appId());
328 StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(), 334 StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(),
329 updatedGroupDesc); 335 updatedGroupDesc);
...@@ -494,6 +500,7 @@ public class SimpleGroupStore ...@@ -494,6 +500,7 @@ public class SimpleGroupStore
494 group.type(), 500 group.type(),
495 group.buckets(), 501 group.buckets(),
496 group.appCookie(), 502 group.appCookie(),
503 + group.givenGroupId(),
497 group.appId()); 504 group.appId());
498 storeGroupDescriptionInternal(tmp); 505 storeGroupDescriptionInternal(tmp);
499 } 506 }
......
...@@ -224,6 +224,7 @@ public class SimpleGroupStoreTest { ...@@ -224,6 +224,7 @@ public class SimpleGroupStoreTest {
224 Group.Type.SELECT, 224 Group.Type.SELECT,
225 groupBuckets, 225 groupBuckets,
226 key, 226 key,
227 + null,
227 appId); 228 appId);
228 InternalGroupStoreDelegate checkStoreGroupDelegate = 229 InternalGroupStoreDelegate checkStoreGroupDelegate =
229 new InternalGroupStoreDelegate(key, 230 new InternalGroupStoreDelegate(key,
...@@ -424,6 +425,7 @@ public class SimpleGroupStoreTest { ...@@ -424,6 +425,7 @@ public class SimpleGroupStoreTest {
424 Group.Type.SELECT, 425 Group.Type.SELECT,
425 groupBuckets, 426 groupBuckets,
426 key, 427 key,
428 + null,
427 appId); 429 appId);
428 InternalGroupStoreDelegate checkStoreGroupDelegate = 430 InternalGroupStoreDelegate checkStoreGroupDelegate =
429 new InternalGroupStoreDelegate(key, 431 new InternalGroupStoreDelegate(key,
......
...@@ -85,8 +85,6 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -85,8 +85,6 @@ import static org.slf4j.LoggerFactory.getLogger;
85 */ 85 */
86 public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeliner { 86 public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeliner {
87 87
88 -
89 -
90 protected static final int MAC_TABLE = 0; 88 protected static final int MAC_TABLE = 0;
91 protected static final int VLAN_MPLS_TABLE = 1; 89 protected static final int VLAN_MPLS_TABLE = 1;
92 protected static final int VLAN_TABLE = 2; 90 protected static final int VLAN_TABLE = 2;
...@@ -149,7 +147,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -149,7 +147,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
149 appId = coreService.registerApplication( 147 appId = coreService.registerApplication(
150 "org.onosproject.driver.OVSCorsaPipeline"); 148 "org.onosproject.driver.OVSCorsaPipeline");
151 149
152 - pushDefaultRules(); 150 + initializePipeline();
153 } 151 }
154 152
155 @Override 153 @Override
...@@ -216,6 +214,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -216,6 +214,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
216 new GroupBuckets(Collections 214 new GroupBuckets(Collections
217 .singletonList(bucket)), 215 .singletonList(bucket)),
218 key, 216 key,
217 + null, // let group service determine group id
219 nextObjective.appId()); 218 nextObjective.appId());
220 groupService.addGroup(groupDescription); 219 groupService.addGroup(groupDescription);
221 pendingGroups.put(key, nextObjective); 220 pendingGroups.put(key, nextObjective);
...@@ -454,7 +453,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -454,7 +453,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
454 } 453 }
455 } 454 }
456 455
457 - private void pushDefaultRules() { 456 + private void initializePipeline() {
458 processMacTable(true); 457 processMacTable(true);
459 processVlanMplsTable(true); 458 processVlanMplsTable(true);
460 processVlanTable(true); 459 processVlanTable(true);
......
...@@ -252,6 +252,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -252,6 +252,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
252 new GroupBuckets( 252 new GroupBuckets(
253 Collections.singletonList(bucket)), 253 Collections.singletonList(bucket)),
254 key, 254 key,
255 + null,
255 nextObjective.appId()); 256 nextObjective.appId());
256 groupService.addGroup(groupDescription); 257 groupService.addGroup(groupDescription);
257 pendingGroups.put(key, nextObjective); 258 pendingGroups.put(key, nextObjective);
...@@ -274,6 +275,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -274,6 +275,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
274 GroupDescription.Type.SELECT, 275 GroupDescription.Type.SELECT,
275 new GroupBuckets(buckets), 276 new GroupBuckets(buckets),
276 key, 277 key,
278 + null,
277 nextObjective.appId()); 279 nextObjective.appId());
278 groupService.addGroup(groupDescription); 280 groupService.addGroup(groupDescription);
279 pendingGroups.put(key, nextObjective); 281 pendingGroups.put(key, nextObjective);
......
...@@ -55,5 +55,9 @@ ...@@ -55,5 +55,9 @@
55 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" 55 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
56 impl="org.onosproject.driver.handshaker.OFCorsaSwitchDriver"/> 56 impl="org.onosproject.driver.handshaker.OFCorsaSwitchDriver"/>
57 </driver> 57 </driver>
58 + <driver name="ofdpa" manufacturer="Broadcom Corp." hwVersion="OF-DPA 1.0" swVersion="OF-DPA 1.0">
59 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
60 + impl="org.onosproject.driver.pipeline.OFDPA1Pipeline"/>
61 + </driver>
58 </drivers> 62 </drivers>
59 63
......
...@@ -213,6 +213,7 @@ public class Controller { ...@@ -213,6 +213,7 @@ public class Controller {
213 ofSwitchDriver.init(new Dpid(dpid), desc, ofv); 213 ofSwitchDriver.init(new Dpid(dpid), desc, ofv);
214 ofSwitchDriver.setAgent(agent); 214 ofSwitchDriver.setAgent(agent);
215 ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver)); 215 ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
216 + log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
216 return ofSwitchDriver; 217 return ofSwitchDriver;
217 } 218 }
218 log.error("No OpenFlow driver for {} : {}", dpid, desc); 219 log.error("No OpenFlow driver for {} : {}", dpid, desc);
......
...@@ -35,6 +35,7 @@ import org.projectfloodlight.openflow.protocol.OFGroupDelete; ...@@ -35,6 +35,7 @@ import org.projectfloodlight.openflow.protocol.OFGroupDelete;
35 import org.projectfloodlight.openflow.protocol.OFGroupMod; 35 import org.projectfloodlight.openflow.protocol.OFGroupMod;
36 import org.projectfloodlight.openflow.protocol.OFGroupType; 36 import org.projectfloodlight.openflow.protocol.OFGroupType;
37 import org.projectfloodlight.openflow.protocol.action.OFAction; 37 import org.projectfloodlight.openflow.protocol.action.OFAction;
38 +import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
38 import org.projectfloodlight.openflow.protocol.action.OFActionOutput; 39 import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
39 import org.projectfloodlight.openflow.protocol.oxm.OFOxm; 40 import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
40 import org.projectfloodlight.openflow.types.CircuitSignalID; 41 import org.projectfloodlight.openflow.types.CircuitSignalID;
...@@ -210,6 +211,12 @@ public final class GroupModBuilder { ...@@ -210,6 +211,12 @@ public final class GroupModBuilder {
210 actions.add(action.build()); 211 actions.add(action.build());
211 break; 212 break;
212 case GROUP: 213 case GROUP:
214 + Instructions.GroupInstruction grp =
215 + (Instructions.GroupInstruction) i;
216 + OFActionGroup.Builder actgrp = factory.actions().buildGroup()
217 + .setGroup(OFGroup.of(grp.groupId().id()));
218 + actions.add(actgrp.build());
219 + break;
213 default: 220 default:
214 log.warn("Instruction type {} not yet implemented.", i.type()); 221 log.warn("Instruction type {} not yet implemented.", i.type());
215 } 222 }
......