use of org.onosproject.driver.extensions.Ofdpa3SetQosIndex in project onos by opennetworkinglab.
the class Ofdpa3Pipeline method processInitPwVersatile.
/**
* Helper method to process the pw forwarding objectives.
*
* @param forwardingObjective the fw objective to process
* @return a singleton list of flow rule
*/
private Collection<FlowRule> processInitPwVersatile(ForwardingObjective forwardingObjective) {
// We retrieve the matching criteria for mpls l2 port.
TunnelIdCriterion tunnelIdCriterion = (TunnelIdCriterion) forwardingObjective.selector().getCriterion(TUNNEL_ID);
PortCriterion portCriterion = (PortCriterion) forwardingObjective.selector().getCriterion(IN_PORT);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
int mplsLogicalPort;
long tunnelId;
// Mpls tunnel ids according to the OFDPA manual have to be
// in the range [2^17-1, 2^16].
tunnelId = MPLS_TUNNEL_ID_BASE | tunnelIdCriterion.tunnelId();
if (tunnelId > MPLS_TUNNEL_ID_MAX) {
log.error("Pw Versatile Forwarding Objective must include tunnel id < {}", MPLS_TUNNEL_ID_MAX);
fail(forwardingObjective, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
// Port has not been null.
if (portCriterion == null) {
log.error("Pw Versatile Forwarding Objective must include port");
fail(forwardingObjective, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
// 0x0000XXXX is UNI interface.
if (portCriterion.port().toLong() > MPLS_UNI_PORT_MAX) {
log.error("Pw Versatile Forwarding Objective invalid logical port {}", portCriterion.port().toLong());
fail(forwardingObjective, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
mplsLogicalPort = ((int) portCriterion.port().toLong());
if (forwardingObjective.nextId() == null) {
log.error("Pw Versatile Forwarding Objective must contain nextId ", forwardingObjective.nextId());
fail(forwardingObjective, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
// We don't expect a treatment.
if (forwardingObjective.treatment() != null && !forwardingObjective.treatment().equals(DefaultTrafficTreatment.emptyTreatment())) {
log.error("Pw Versatile Forwarding Objective cannot contain a treatment ", forwardingObjective.nextId());
fail(forwardingObjective, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
// We retrieve the l2 vpn group and point the mpls
// l2 port to this.
NextGroup next = getGroupForNextObjective(forwardingObjective.nextId());
if (next == null) {
log.warn("next-id:{} not found in dev:{}", forwardingObjective.nextId(), deviceId);
fail(forwardingObjective, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
if (group == null) {
log.warn("Group with key:{} for next-id:{} not found in dev:{}", gkeys.get(0).peekFirst(), forwardingObjective.nextId(), deviceId);
fail(forwardingObjective, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
// We prepare the flow rule for the mpls l2 port table.
selector.matchTunnelId(tunnelId);
selector.extension(new Ofdpa3MatchMplsL2Port(mplsLogicalPort), deviceId);
// This should not be necessary but without we receive an error
treatment.extension(new Ofdpa3SetQosIndex(0), deviceId);
treatment.transition(MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE);
treatment.deferred().group(group.id());
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(forwardingObjective.appId()).withPriority(MPLS_L2_PORT_PRIORITY).forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).makePermanent().forTable(MPLS_L2_PORT_FLOW_TABLE);
return Collections.singletonList(ruleBuilder.build());
}
Aggregations