Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDFAB-844 - Part 2] Add SlicingConfig class #454

Merged
merged 38 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cc1ac61
Add SlicingProviderService interface
ccascone Jan 12, 2022
b3a48b2
Remove slice/tc initialization from FabricUpfProgrammable
ccascone Jan 12, 2022
e159959
Remove slice/tc initialization from FabricUpfProgrammable
ccascone Jan 12, 2022
71482ae
Remove REST API for adding/removing slice/tcs
ccascone Jan 12, 2022
22385a1
Remove unused CLI commands
ccascone Jan 12, 2022
a13fa6e
Revisit TrafficClass and remove hardcoded initialization
ccascone Jan 12, 2022
c45c3e1
Introduce TrafficClassConfig class
ccascone Jan 13, 2022
7bbf074
Remove queue allocation logic
ccascone Jan 13, 2022
4060841
Comments and renaming on SlicingManager
ccascone Jan 13, 2022
e0a8ead
Fix meter color int value
ccascone Jan 13, 2022
2adadd3
Less ambiguous handling of BE
ccascone Jan 13, 2022
025409e
Fix tests
ccascone Jan 13, 2022
b5a2d1d
Remove leftover QueueStoreValue
ccascone Jan 13, 2022
e3be92f
Javadoc
ccascone Jan 13, 2022
0952439
Wordsmithing
ccascone Jan 13, 2022
50639d7
Merge branch 'main' into qos-refactoring-pr1
ccascone Jan 13, 2022
9bb7335
Improvements to TrafficClassConfig
ccascone Jan 14, 2022
1f0bc37
Rename config class to description to disambiguate from netcfg
ccascone Jan 14, 2022
24a62d8
First stab at config class
ccascone Jan 14, 2022
804cc1a
First stab at tests for SlicingTests
ccascone Jan 14, 2022
0bfa478
Forgot to check in the test JSON
ccascone Jan 14, 2022
9f8d376
Consistently call it tcDescription instead of tcConfig
ccascone Jan 18, 2022
2072395
Remove ability to configure best effort queue ID
ccascone Jan 20, 2022
f9869bd
Use default for mobile slice
ccascone Jan 20, 2022
b7843c4
clean up rest API docs
ccascone Jan 20, 2022
c436d0d
address review comments
ccascone Jan 20, 2022
dd216f4
Fix test and checkstyles
ccascone Jan 20, 2022
7397b13
Merge branch 'qos-refactoring-pr1' into qos-refactoring-pr2
ccascone Jan 20, 2022
e156a87
Move distributed store destroy to preDeactivate hook
ccascone Jan 21, 2022
52e0d25
Update default tc javadoc
ccascone Jan 21, 2022
bf31d8d
Merge branch 'qos-refactoring-pr1' into qos-refactoring-pr2
ccascone Jan 21, 2022
42fc8ec
javadoc
ccascone Jan 21, 2022
00f6468
review comments
ccascone Jan 21, 2022
c5c58e0
tests
ccascone Jan 21, 2022
3309d3d
Fix tests
ccascone Jan 21, 2022
fc3c9e0
Merge branch 'qos-refactoring-pr1' into qos-refactoring-pr2
ccascone Jan 21, 2022
3f0c995
Restore double quotes in json example
ccascone Jan 21, 2022
20d4524
Merge remote-tracking branch 'origin/qos-refactoring' into qos-refact…
ccascone Jan 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,8 @@ public final class Constants {
public static final int PKT_IN_MIRROR_SESSION_ID = 0x1FF;

// Static Queue IDs (should match those in gen-stratum-qos-config.py)
public static final int QUEUE_ID_BEST_EFFORT = 0;
// FIXME: remove hardcoded queue ID, should be derived from netcfg
public static final int QUEUE_ID_SYSTEM = 1;
charlesmcchan marked this conversation as resolved.
Show resolved Hide resolved
public static final int QUEUE_ID_CONTROL = 2;
public static final int QUEUE_ID_FIRST_REAL_TIME = 3; // This will always be 3
// FIXME: ELASTIC_ID can change and it should be configurable at runtime (i.e., via netcfg?)
public static final int QUEUE_ID_FIRST_ELASTIC = 6; // TODO: this can change

// Traffic Classes
public static final int TC_BEST_EFFORT = 0; // Also the default TC
public static final int TC_CONTROL = 1;
public static final int TC_REAL_TIME = 2;
public static final int TC_ELASTIC = 3;

public static final int DEFAULT_SLICE_ID = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import org.onosproject.net.pi.model.PiPipeconf;
import org.slf4j.Logger;
import org.stratumproject.fabric.tna.slicing.api.Color;
import org.stratumproject.fabric.tna.slicing.api.MeterColor;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -70,11 +70,11 @@ public boolean isArchTna() {
.orElse(false);
}

public int getMeterColor(Color color) {
if (isArchV1model() && color == Color.RED) {
public int getMeterColor(MeterColor color) {
if (isArchV1model() && color == MeterColor.RED) {
return BMV2_COLOR_RED;
} else {
return color.ordinal();
return color.toInt();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.criteria.PiCriterion;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.OutboundPacket;
Expand All @@ -36,23 +35,16 @@
import org.onosproject.net.pi.model.PiCounterModel;
import org.onosproject.net.pi.model.PiTableId;
import org.onosproject.net.pi.model.PiTableModel;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionParam;
import org.onosproject.net.pi.runtime.PiCounterCell;
import org.onosproject.net.pi.runtime.PiCounterCellHandle;
import org.onosproject.net.pi.runtime.PiCounterCellId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.stratumproject.fabric.tna.PipeconfLoader;
import org.stratumproject.fabric.tna.behaviour.FabricCapabilities;
import org.stratumproject.fabric.tna.slicing.api.SliceId;
import org.stratumproject.fabric.tna.slicing.api.SlicingException;
import org.stratumproject.fabric.tna.slicing.api.SlicingService;
import org.stratumproject.fabric.tna.slicing.api.TrafficClass;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand All @@ -61,12 +53,9 @@

import static java.lang.String.format;
import static org.onosproject.net.pi.model.PiCounterType.INDIRECT;
import static org.stratumproject.fabric.tna.behaviour.FabricUtils.sliceTcConcat;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_EGRESS_SPGW_EG_TUNNEL_PEERS;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_EGRESS_SPGW_GTPU_ENCAP;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_EGRESS_SPGW_TERMINATIONS_COUNTER;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_QOS_QUEUES;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_QOS_SET_QUEUE;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_SPGW_DOWNLINK_SESSIONS;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_SPGW_DOWNLINK_TERMINATIONS;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_SPGW_IG_TUNNEL_PEERS;
Expand All @@ -76,13 +65,11 @@
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.FABRIC_INGRESS_SPGW_UPLINK_TERMINATIONS;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_GTPU_IS_VALID;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_IPV4_DST_ADDR;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_SLICE_TC;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_TEID;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_TUNNEL_IPV4_DST;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_TUN_PEER_ID;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_UE_ADDR;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.HDR_UE_SESSION_ID;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.QID;

/**
* Implementation of a UPF programmable device behavior.
Expand All @@ -94,10 +81,7 @@ public class FabricUpfProgrammable extends AbstractP4RuntimeHandlerBehaviour
private static final int DEFAULT_PRIORITY = 128;
private static final long DEFAULT_P4_DEVICE_ID = 1;

private static final int PRIORITY_LOW = 10;

protected FlowRuleService flowRuleService;
protected SlicingService slicingService;
protected PacketService packetService;
protected FabricUpfTranslator upfTranslator;

Expand All @@ -111,8 +95,6 @@ public class FabricUpfProgrammable extends AbstractP4RuntimeHandlerBehaviour

private ApplicationId appId;

static final SliceId SLICE_MOBILE = SliceId.of(SliceId.MAX);

@Override
protected boolean setupBehaviour(String opName) {
// Already initialized.
Expand All @@ -130,7 +112,6 @@ protected boolean setupBehaviour(String opName) {
}

flowRuleService = handler().get(FlowRuleService.class);
slicingService = handler().get(SlicingService.class);
packetService = handler().get(PacketService.class);
upfTranslator = new FabricUpfTranslator();
final CoreService coreService = handler().get(CoreService.class);
Expand All @@ -154,47 +135,11 @@ protected boolean setupBehaviour(String opName) {
public boolean init() {
if (setupBehaviour("init()")) {
log.info("UpfProgrammable initialized for appId {} and deviceId {}", appId, deviceId);
try {
/* Add MOBILE slice and BEST_EFFORT tc if needed
and initialize the remaining traffic classes */
Set<TrafficClass> tcs = slicingService.getTrafficClasses(SLICE_MOBILE);
if (tcs.isEmpty()) {
slicingService.addSlice(SLICE_MOBILE);
}
Arrays.stream(TrafficClass.values()).forEach(tc -> {
if (tcs.contains(tc) || tc.equals(TrafficClass.BEST_EFFORT) ||
tc.equals(TrafficClass.SYSTEM)) {
return;
}
slicingService.addTrafficClass(SLICE_MOBILE, tc);
});
} catch (SlicingException e) {
log.error("Exception while configuring traffic class for Mobile Slice: {}", e.getMessage());
return false;
}
return true;
}
return false;
}

private FlowRule setQueueFlowRule(int sliceId, int tc, int queueId) {
TrafficSelector trafficSelector = DefaultTrafficSelector.builder()
.matchPi(PiCriterion.builder().matchExact(HDR_SLICE_TC, sliceTcConcat(sliceId, tc)).build())
.build();
PiAction action = PiAction.builder()
.withId(FABRIC_INGRESS_QOS_SET_QUEUE)
.withParameter(new PiActionParam(QID, queueId))
.build();

return DefaultFlowRule.builder()
.forDevice(deviceId).fromApp(appId).makePermanent()
.forTable(FABRIC_INGRESS_QOS_QUEUES)
.withSelector(trafficSelector)
.withTreatment(DefaultTrafficTreatment.builder().piTableAction(action).build())
.withPriority(PRIORITY_LOW)
.build();
}

@Override
public boolean fromThisUpf(FlowRule flowRule) {
return flowRule.deviceId().equals(this.deviceId) &&
Expand Down Expand Up @@ -327,11 +272,6 @@ public void cleanUp() {
return;
}
log.info("Clearing all UPF-related table entries.");
// Remove static Queue Configuration
slicingService.removeTrafficClass(SLICE_MOBILE, TrafficClass.ELASTIC);
slicingService.removeTrafficClass(SLICE_MOBILE, TrafficClass.REAL_TIME);
slicingService.removeTrafficClass(SLICE_MOBILE, TrafficClass.CONTROL);
slicingService.removeSlice(SLICE_MOBILE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionParam;
import org.onosproject.net.pi.runtime.PiTableAction;
import org.stratumproject.fabric.tna.slicing.api.SliceId;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -75,7 +76,6 @@
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.TUNNEL_SRC_PORT;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.TUN_DST_ADDR;
import static org.stratumproject.fabric.tna.behaviour.P4InfoConstants.TUN_PEER_ID;
import static org.stratumproject.fabric.tna.behaviour.upf.FabricUpfProgrammable.SLICE_MOBILE;

/**
* Provides logic to translate UPF entities into pipeline-specific ones and vice-versa.
Expand Down Expand Up @@ -600,7 +600,9 @@ public FlowRule interfaceToFabricEntry(UpfInterface upfInterface, DeviceId devic
.build();
PiAction action = PiAction.builder()
.withId(actionId)
.withParameter(new PiActionParam(SLICE_ID, SLICE_MOBILE.id()))
// FIXME: Use a different slice id, provided by UP4
// This will likely require updating UpfInterface.
.withParameter(new PiActionParam(SLICE_ID, SliceId.DEFAULT.id()))
.build();
return DefaultFlowRule.builder()
.forDevice(deviceId).fromApp(appId).makePermanent()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.stratumproject.fabric.tna.slicing;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.stratumproject.fabric.tna.slicing.api.SlicingProviderService;

@Component(immediate = true, service = {
NetcfgSlicingProvider.class,
})
public class NetcfgSlicingProvider {

@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected SlicingProviderService slicingProviderService;

// TODO: listen for netcfg, register slices/tcs with slicingProviderService

}

This file was deleted.

Loading