use of org.onosproject.net.pi.model.PiPipeconf in project onos by opennetworkinglab.
the class PiPipeconfManager method unregister.
@Override
public void unregister(PiPipeconfId pipeconfId) throws IllegalStateException {
checkNotNull(pipeconfId);
// TODO add mechanism to remove from device.
if (!pipeconfs.containsKey(pipeconfId)) {
throw new IllegalStateException(format("Pipeconf %s is not registered", pipeconfId));
}
// TODO remove the binding from the distributed Store when the lifecycle of a pipeconf is defined.
// pipeconfMappingStore.removeBindings(pipeconfId);
final PiPipeconf pipeconf = pipeconfs.remove(pipeconfId);
log.info("Unregistered pipeconf: {} (fingerprint={})", pipeconfId, HexString.toHexString(pipeconf.fingerprint()));
post(new PiPipeconfEvent(PiPipeconfEvent.Type.UNREGISTERED, pipeconfId));
}
use of org.onosproject.net.pi.model.PiPipeconf in project onos by opennetworkinglab.
the class PiPipeconfWatchdogManager method probeTask.
private void probeTask(Device device) {
if (!isLocalMaster(device)) {
return;
}
final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(device.id());
if (pipeconfId == null || !device.is(PiPipelineProgrammable.class)) {
return;
}
if (pipeconfService.getPipeconf(pipeconfId).isEmpty()) {
log.warn("Pipeconf {} is not registered, skipping probe for {}", pipeconfId, device.id());
return;
}
final PiPipeconf pipeconf = pipeconfService.getPipeconf(pipeconfId).get();
if (!device.is(DeviceHandshaker.class)) {
log.error("Missing DeviceHandshaker behavior for {}", device.id());
return;
}
final boolean success = doSetPipeconfIfRequired(device, pipeconf);
// the mastership after pipeline probe returns.
if (isLocalMaster(device)) {
// (next reconcile interval)
if (success) {
signalStatusReady(device.id());
signalStatusConfigured(device.id());
} else {
// When a network partition occurs watchdog is stuck for LONG_TIMEOUT
// before returning and will mark the device offline. However, in the
// meanwhile the mastership has been passed to another instance which is
// already connected and has already marked the device online.
signalStatusUnknown(device.id());
}
} else {
log.warn("No longer the master for {} aborting probe task", device.id());
}
}
use of org.onosproject.net.pi.model.PiPipeconf in project onos by opennetworkinglab.
the class FabricPipeconfLoader method buildPipeconfFromPath.
private PiPipeconf buildPipeconfFromPath(String path) {
String[] pieces = path.split(SEP);
// p4c-out/<profile>/<target>/<platform>
if (pieces.length != 4) {
return null;
}
String profile = pieces[1];
String target = pieces[2];
String platform = pieces[3];
final PiPipeconf pipeconf;
try {
switch(target) {
case BMV2:
pipeconf = bmv2Pipeconf(profile, platform);
break;
case SPECTRUM:
pipeconf = spectrumPipeconf(profile, platform);
break;
default:
log.warn("Unknown target '{}', skipping pipeconf build...", target);
return null;
}
} catch (FileNotFoundException e) {
log.warn("Unable to build pipeconf at {} because file is missing: {}", path, e.getMessage());
return null;
}
return pipeconf;
}
use of org.onosproject.net.pi.model.PiPipeconf in project onos by opennetworkinglab.
the class StreamClientImpl method handlePacketIn.
private void handlePacketIn(P4RuntimeOuterClass.PacketIn packetInMsg) {
if (log.isTraceEnabled()) {
log.trace("Received packet-in from {}: {}", deviceId, packetInMsg);
}
if (!pipeconfService.getPipeconf(deviceId).isPresent()) {
log.warn("Unable to handle packet-in from {}, missing pipeconf: {}", deviceId, TextFormat.shortDebugString(packetInMsg));
return;
}
// Decode packet message and post event.
// TODO: consider implementing a cache to speed up
// encoding/deconding of packet-in/out (e.g. LLDP, ARP)
final PiPipeconf pipeconf = pipeconfService.getPipeconf(deviceId).get();
final PiPacketOperation pktOperation;
try {
pktOperation = CODECS.packetIn().decode(packetInMsg, null, pipeconf);
} catch (CodecException e) {
log.warn("Unable to process packet-int: {}", e.getMessage());
return;
}
controller.postEvent(new P4RuntimeEvent(P4RuntimeEvent.Type.PACKET_IN, new PacketInEvent(deviceId, pktOperation)));
}
use of org.onosproject.net.pi.model.PiPipeconf in project onos by opennetworkinglab.
the class AbstractP4RuntimePipelineProgrammable method getDefaultEntries.
/**
* Once the pipeconf is set successfully, we should store all the default entries
* before notify other service to prevent overwriting the default entries.
* Default entries may be used in P4RuntimeFlowRuleProgrammable.
* <p>
* This method returns a completable future with the result of the pipeconf set
* operation (which might not be true).
*
* @param pipeconfSet completable future for setting pipeconf
* @param pipeconf pipeconf
* @return completable future eventually true if the pipeconf set successfully
*/
private CompletableFuture<Boolean> getDefaultEntries(CompletableFuture<Boolean> pipeconfSet, PiPipeconf pipeconf) {
if (!driverBoolProperty(SUPPORT_DEFAULT_TABLE_ENTRY, DEFAULT_SUPPORT_DEFAULT_TABLE_ENTRY)) {
return pipeconfSet;
}
return pipeconfSet.thenApply(setSuccess -> {
if (!setSuccess) {
return setSuccess;
}
final P4RuntimeDefaultEntryMirror mirror = handler().get(P4RuntimeDefaultEntryMirror.class);
final PiPipelineModel pipelineModel = pipeconf.pipelineModel();
final P4RuntimeReadClient.ReadRequest request = client.read(p4DeviceId, pipeconf);
// Read default entries from all non-constant tables.
// Ignore constant default entries.
pipelineModel.tables().stream().filter(t -> !t.isConstantTable()).forEach(t -> {
if (!t.constDefaultAction().isPresent()) {
request.defaultTableEntry(t.id());
}
});
final P4RuntimeReadClient.ReadResponse response = request.submitSync();
mirror.sync(deviceId, response.all(PiTableEntry.class));
return true;
});
}
Aggregations