Search in sources :

Example 6 with PiPipeconf

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));
}
Also used : PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPipeconfEvent(org.onosproject.net.pi.service.PiPipeconfEvent)

Example 7 with PiPipeconf

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());
    }
}
Also used : DeviceHandshaker(org.onosproject.net.device.DeviceHandshaker) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId)

Example 8 with PiPipeconf

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;
}
Also used : PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) DefaultPiPipeconf(org.onosproject.net.pi.model.DefaultPiPipeconf) FileNotFoundException(java.io.FileNotFoundException)

Example 9 with PiPipeconf

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)));
}
Also used : PacketInEvent(org.onosproject.p4runtime.ctl.controller.PacketInEvent) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) CodecException(org.onosproject.p4runtime.ctl.codec.CodecException) P4RuntimeEvent(org.onosproject.p4runtime.api.P4RuntimeEvent)

Example 10 with PiPipeconf

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;
    });
}
Also used : P4RuntimeReadClient(org.onosproject.p4runtime.api.P4RuntimeReadClient) DEFAULT_SUPPORT_DEFAULT_TABLE_ENTRY(org.onosproject.drivers.p4runtime.P4RuntimeDriverProperties.DEFAULT_SUPPORT_DEFAULT_TABLE_ENTRY) Logger(org.slf4j.Logger) PiPipelineProgrammable(org.onosproject.net.behaviour.PiPipelineProgrammable) P4RuntimeReadClient(org.onosproject.p4runtime.api.P4RuntimeReadClient) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) CompletableFuture(java.util.concurrent.CompletableFuture) SUPPORT_DEFAULT_TABLE_ENTRY(org.onosproject.drivers.p4runtime.P4RuntimeDriverProperties.SUPPORT_DEFAULT_TABLE_ENTRY) PiPipelineModel(org.onosproject.net.pi.model.PiPipelineModel) ByteBuffer(java.nio.ByteBuffer) PiTableEntry(org.onosproject.net.pi.runtime.PiTableEntry) P4RuntimeDefaultEntryMirror(org.onosproject.drivers.p4runtime.mirror.P4RuntimeDefaultEntryMirror) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) P4RuntimeDefaultEntryMirror(org.onosproject.drivers.p4runtime.mirror.P4RuntimeDefaultEntryMirror) PiTableEntry(org.onosproject.net.pi.runtime.PiTableEntry) PiPipelineModel(org.onosproject.net.pi.model.PiPipelineModel)

Aggregations

PiPipeconf (org.onosproject.net.pi.model.PiPipeconf)13 Sets (com.google.common.collect.Sets)4 Set (java.util.Set)4 PiPipeconfService (org.onosproject.net.pi.service.PiPipeconfService)4 Logger (org.slf4j.Logger)4 Maps (com.google.common.collect.Maps)3 Collection (java.util.Collection)3 Map (java.util.Map)3 DeviceService (org.onosproject.net.device.DeviceService)3 PortStatisticsDiscovery (org.onosproject.net.device.PortStatisticsDiscovery)3 String.format (java.lang.String.format)2 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 Device (org.onosproject.net.Device)2 DeviceId (org.onosproject.net.DeviceId)2 DefaultPortStatistics (org.onosproject.net.device.DefaultPortStatistics)2 PortStatistics (org.onosproject.net.device.PortStatistics)2 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)2 PiUtils.getInterpreterOrNull (org.onosproject.net.pi.impl.PiUtils.getInterpreterOrNull)2 PiPipeconfId (org.onosproject.net.pi.model.PiPipeconfId)2