org.onosproject.net.pi.model.DefaultPiPipeconf Java Examples

The following examples show how to use org.onosproject.net.pi.model.DefaultPiPipeconf. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FabricPipeconfLoader.java    From onos with Apache License 2.0 6 votes vote down vote up
private PiPipeconf bmv2Pipeconf(String profile, String platform)
        throws FileNotFoundException {
    final URL bmv2JsonUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + BMV2_JSON, profile, BMV2, platform));
    final URL p4InfoUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + P4INFO_TXT, profile, BMV2, platform));
    final URL cpuPortUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + CPU_PORT_TXT, profile, BMV2, platform));

    checkFileExists(bmv2JsonUrl, BMV2_JSON);
    checkFileExists(p4InfoUrl, P4INFO_TXT);
    checkFileExists(cpuPortUrl, CPU_PORT_TXT);

    final DefaultPiPipeconf.Builder builder = DefaultPiPipeconf.builder()
            .withId(makePipeconfId(platform, profile))
            .addBehaviour(PortStatisticsDiscovery.class,
                          FabricPortStatisticsDiscovery.class)
            .addExtension(PiPipeconf.ExtensionType.BMV2_JSON, bmv2JsonUrl);

    return build(builder, profile, p4InfoUrl, cpuPortUrl);
}
 
Example #2
Source File: FabricPipeconfLoader.java    From onos with Apache License 2.0 6 votes vote down vote up
private PiPipeconf spectrumPipeconf(String profile, String platform)
        throws FileNotFoundException {

    final URL spectrumBinUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + SPECTRUM_BIN, profile, SPECTRUM, platform));
    final URL p4InfoUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + P4INFO_TXT, profile, SPECTRUM, platform));
    final URL cpuPortUrl = this.getClass().getResource(format(
            P4C_RES_BASE_PATH + CPU_PORT_TXT, profile, SPECTRUM, platform));

    checkFileExists(spectrumBinUrl, SPECTRUM_BIN);
    checkFileExists(p4InfoUrl, P4INFO_TXT);
    checkFileExists(cpuPortUrl, CPU_PORT_TXT);

    final DefaultPiPipeconf.Builder builder = DefaultPiPipeconf.builder()
            .withId(makePipeconfId(platform, profile))
            .addExtension(PiPipeconf.ExtensionType.SPECTRUM_BIN, spectrumBinUrl);

    return build(builder, profile, p4InfoUrl, cpuPortUrl);
}
 
Example #3
Source File: PipeconfLoader.java    From onos with Apache License 2.0 6 votes vote down vote up
private static PiPipeconf buildBasicPipeconf() {
    final URL jsonUrl = PipeconfLoader.class.getResource(BASIC_JSON_PATH);
    final URL p4InfoUrl = PipeconfLoader.class.getResource(BASIC_P4INFO);

    return DefaultPiPipeconf.builder()
            .withId(BASIC_PIPECONF_ID)
            .withPipelineModel(parseP4Info(p4InfoUrl))
            .addBehaviour(PiPipelineInterpreter.class, BasicInterpreterImpl.class)
            .addBehaviour(Pipeliner.class, BasicPipelinerImpl.class)
            .addBehaviour(PortStatisticsDiscovery.class, PortStatisticsDiscoveryImpl.class)
            .addExtension(P4_INFO_TEXT, p4InfoUrl)
            .addExtension(BMV2_JSON, jsonUrl)
            // Put here other target-specific extensions,
            // e.g. Tofino's bin and context.json.
            .build();
}
 
Example #4
Source File: PipeconfLoader.java    From onos with Apache License 2.0 6 votes vote down vote up
private static PiPipeconf buildIntPipeconf() {
    final URL jsonUrl = PipeconfLoader.class.getResource(INT_JSON_PATH);
    final URL p4InfoUrl = PipeconfLoader.class.getResource(INT_P4INFO);

    // INT behavior is controlled using pipeline-specific flow rule,
    // not using flow objectives, so we just borrow pipeliner to basic pipeconf.
    return DefaultPiPipeconf.builder()
            .withId(INT_PIPECONF_ID)
            .withPipelineModel(parseP4Info(p4InfoUrl))
            .addBehaviour(PiPipelineInterpreter.class, BasicInterpreterImpl.class)
            .addBehaviour(Pipeliner.class, BasicPipelinerImpl.class)
            .addBehaviour(PortStatisticsDiscovery.class, PortStatisticsDiscoveryImpl.class)
            .addBehaviour(IntProgrammable.class, IntProgrammableImpl.class)
            .addExtension(P4_INFO_TEXT, p4InfoUrl)
            .addExtension(BMV2_JSON, jsonUrl)
            .build();
}
 
Example #5
Source File: PipeconfLoader.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
private PiPipeconf buildPipeconf() throws P4InfoParserException {

        final URL p4InfoUrl = PipeconfLoader.class.getResource(P4INFO_PATH);
        final URL bmv2JsonUrlUrl = PipeconfLoader.class.getResource(BMV2_JSON_PATH);
        final PiPipelineModel pipelineModel = P4InfoParser.parse(p4InfoUrl);

        return DefaultPiPipeconf.builder()
                .withId(PIPECONF_ID)
                .withPipelineModel(pipelineModel)
                .addBehaviour(PiPipelineInterpreter.class, InterpreterImpl.class)
                .addBehaviour(Pipeliner.class, PipelinerImpl.class)
                .addExtension(P4_INFO_TEXT, p4InfoUrl)
                .addExtension(BMV2_JSON, bmv2JsonUrlUrl)
                .build();
    }
 
Example #6
Source File: PipeconfLoader.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
private PiPipeconf buildPipeconf() throws P4InfoParserException {

        final URL p4InfoUrl = PipeconfLoader.class.getResource(P4INFO_PATH);
        final URL bmv2JsonUrlUrl = PipeconfLoader.class.getResource(BMV2_JSON_PATH);
        final PiPipelineModel pipelineModel = P4InfoParser.parse(p4InfoUrl);

        return DefaultPiPipeconf.builder()
                .withId(PIPECONF_ID)
                .withPipelineModel(pipelineModel)
                .addBehaviour(PiPipelineInterpreter.class, InterpreterImpl.class)
                .addBehaviour(Pipeliner.class, PipelinerImpl.class)
                .addExtension(P4_INFO_TEXT, p4InfoUrl)
                .addExtension(BMV2_JSON, bmv2JsonUrlUrl)
                .build();
    }
 
Example #7
Source File: PipeconfLoader.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
private PiPipeconf buildPipeconf() throws P4InfoParserException {

        final URL p4InfoUrl = PipeconfLoader.class.getResource(P4INFO_PATH);
        final URL bmv2JsonUrlUrl = PipeconfLoader.class.getResource(BMV2_JSON_PATH);
        final PiPipelineModel pipelineModel = P4InfoParser.parse(p4InfoUrl);

        return DefaultPiPipeconf.builder()
                .withId(PIPECONF_ID)
                .withPipelineModel(pipelineModel)
                .addBehaviour(PiPipelineInterpreter.class, InterpreterImpl.class)
                .addBehaviour(Pipeliner.class, PipelinerImpl.class)
                .addExtension(P4_INFO_TEXT, p4InfoUrl)
                .addExtension(BMV2_JSON, bmv2JsonUrlUrl)
                .build();
    }
 
Example #8
Source File: P4RuntimeGroupTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private static PiPipeconf buildPipeconf() {
    final URL p4InfoUrl = P4RuntimeGroupTest.class.getResource(P4INFO_PATH);
    return DefaultPiPipeconf.builder()
            .withId(new PiPipeconfId(PIPECONF_ID))
            .withPipelineModel(EasyMock.niceMock(PiPipelineModel.class))
            .addExtension(P4_INFO_TEXT, p4InfoUrl)
            .build();
}
 
Example #9
Source File: FabricPipeconfManager.java    From onos with Apache License 2.0 5 votes vote down vote up
static PiPipeconf build(
        DefaultPiPipeconf.Builder pipeconfBuilder,
        String profileName, URL p4InfoUrl, URL cpuPortUrl) {
    checkNotNull(pipeconfBuilder,
                 "pipeconfBuilder cannot be null");
    checkArgument(profileName != null && !profileName.isEmpty(),
                  "profileName cannot be null or empty");
    checkNotNull(p4InfoUrl,
                 "p4InfoUrl cannot be null (check if file exists)");
    checkNotNull(cpuPortUrl,
                 "cpuPortUrl cannot be null (check if file exists)");

    pipeconfBuilder
            .withPipelineModel(parseP4Info(p4InfoUrl))
            .addBehaviour(PiPipelineInterpreter.class, FabricInterpreter.class)
            .addBehaviour(Pipeliner.class, FabricPipeliner.class)
            .addExtension(PiPipeconf.ExtensionType.P4_INFO_TEXT, p4InfoUrl)
            .addExtension(PiPipeconf.ExtensionType.CPU_PORT_TXT, cpuPortUrl);

    // Add IntProgrammable behaviour for INT-enabled profiles.
    if (profileName.endsWith(INT_PROFILE_SUFFIX) ||
            profileName.endsWith(FULL_PROFILE_SUFFIX)) {
        pipeconfBuilder.addBehaviour(IntProgrammable.class, FabricIntProgrammable.class);
    }
    // Add BngProgrammable behavior for BNG-enabled pipelines.
    if (profileName.endsWith(BNG_PROFILE_SUFFIX)) {
        pipeconfBuilder.addBehaviour(BngProgrammable.class, FabricBngProgrammable.class);
    }
    return pipeconfBuilder.build();
}
 
Example #10
Source File: PipeconfFactory.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPipeconf buildPipeconf() throws P4InfoParserException {

        final PiPipelineModel pipelineModel = P4InfoParser.parse(P4INFO_URL);

        return DefaultPiPipeconf.builder()
                .withId(PIPECONF_ID)
                .withPipelineModel(pipelineModel)
                .addBehaviour(PiPipelineInterpreter.class, PipelineInterpreterImpl.class)
                .addBehaviour(PortStatisticsDiscovery.class, PortStatisticsDiscoveryImpl.class)
                // Since mytunnel.p4 defines only 1 table, we re-use the existing single-table pipeliner.
                .addBehaviour(Pipeliner.class, DefaultSingleTablePipeline.class)
                .addExtension(P4_INFO_TEXT, P4INFO_URL)
                .addExtension(BMV2_JSON, BMV2_JSON_URL)
                .build();
    }
 
Example #11
Source File: FabricPipeconfManager.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public PiPipeconf buildFabricPipeconf(
        DefaultPiPipeconf.Builder builder, String profile, URL p4InfoUrl, URL cpuPortUrl) {
    return build(builder, profile, p4InfoUrl, cpuPortUrl);
}
 
Example #12
Source File: FabricPipeconfService.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Builds a pipeconf for fabric.p4.
 * <p>
 * This method expects as input a pipeconf builder already populated with
 * the pipeconf ID (i.e., {@link DefaultPiPipeconf.Builder#withId}) and
 * target-specific extensions (i.e., {@link DefaultPiPipeconf.Builder#addExtension}.
 * The implementation takes care of adding all the necessary behavior
 * implementations specific to fabric.p4, depending on the profile name,
 * e.g., adding INT-related behaviors for fabric-int profile).
 * <p>
 * Finally, the implementation takes care of parsing the given P4Info file
 * (in text format) as pipeconf pipeline model, and setting the pipeconf CPU
 * port to the one contained in the given file URL.
 *
 * @param builder    pipeconf builder already populated with ID and
 *                   target-specific extensions
 * @param profile    fabric.p4 profile name
 * @param p4InfoUrl  URL to P4Info file in text format
 * @param cpuPortUrl URL to txt file containing the CPU port
 * @return pipeconf instance
 */
PiPipeconf buildFabricPipeconf(DefaultPiPipeconf.Builder builder, String profile,
                               URL p4InfoUrl, URL cpuPortUrl);