Search in sources :

Example 1 with P4RuntimeDefaultEntryMirror

use of org.onosproject.drivers.p4runtime.mirror.P4RuntimeDefaultEntryMirror 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

ByteBuffer (java.nio.ByteBuffer)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 DEFAULT_SUPPORT_DEFAULT_TABLE_ENTRY (org.onosproject.drivers.p4runtime.P4RuntimeDriverProperties.DEFAULT_SUPPORT_DEFAULT_TABLE_ENTRY)1 SUPPORT_DEFAULT_TABLE_ENTRY (org.onosproject.drivers.p4runtime.P4RuntimeDriverProperties.SUPPORT_DEFAULT_TABLE_ENTRY)1 P4RuntimeDefaultEntryMirror (org.onosproject.drivers.p4runtime.mirror.P4RuntimeDefaultEntryMirror)1 PiPipelineProgrammable (org.onosproject.net.behaviour.PiPipelineProgrammable)1 PiPipeconf (org.onosproject.net.pi.model.PiPipeconf)1 PiPipelineModel (org.onosproject.net.pi.model.PiPipelineModel)1 PiTableEntry (org.onosproject.net.pi.runtime.PiTableEntry)1 P4RuntimeReadClient (org.onosproject.p4runtime.api.P4RuntimeReadClient)1 Logger (org.slf4j.Logger)1 LoggerFactory.getLogger (org.slf4j.LoggerFactory.getLogger)1