HeaderStackTest()
    : testHeaderType("test_t", 0) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    phv_factory.push_back_header("test_0", testHeader_0, testHeaderType);
    phv_factory.push_back_header("test_1", testHeader_1, testHeaderType);
    phv_factory.push_back_header("test_2", testHeader_2, testHeaderType);

    const std::vector<header_id_t> headers =
      {testHeader_0, testHeader_1, testHeader_2};
    phv_factory.push_back_header_stack("test_stack", testHeaderStack,
				       testHeaderType, headers);
  }
  TableIndirectWS() 
    : testHeaderType("test_t", 0), action_fn("actionA", 0) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);

    key_builder.push_back_field(testHeader1, 0, 16);

    // with counters, without ageing
    table = MatchTableIndirectWS::create("exact", "test_table", 0,
					 table_size, key_builder,
					 true, false);
    table->set_next_node(0, nullptr);

    BufBuilder builder;
    
    builder.push_back_field(testHeader1, 1, 48); // h1.f48
    builder.push_back_field(testHeader2, 0, 16); // h2.f16
    builder.push_back_field(testHeader2, 1, 48); // h2.f48

    std::unique_ptr<Calculation<hash_t> > calc(new Calculation<hash_t>(builder));
    calc->set_compute_fn(hash::xxh64<hash_t>);

    table->set_hash(std::move(calc));
  }
  TableSizeTwo()
    : testHeaderType("test_t", 0), action_fn("actionA", 0) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);

    key_builder.push_back_field(testHeader1, 0, 16);

    key_builder_w_valid.push_back_field(testHeader1, 0, 16);
    key_builder_w_valid.push_back_valid_header(testHeader2);

    std::unique_ptr<MUType> match_unit;

    // true enables counters
    match_unit = std::unique_ptr<MUType>(new MUType(2, key_builder));
    table = std::unique_ptr<MatchTable>(
      new MatchTable("test_table", 0, std::move(match_unit), true)
    );
    table->set_next_node(0, nullptr);

    match_unit = std::unique_ptr<MUType>(new MUType(2, key_builder_w_valid));
    table_w_valid = std::unique_ptr<MatchTable>(
      new MatchTable("test_table", 0, std::move(match_unit))
    );
    table_w_valid->set_next_node(0, nullptr);
  }
 PHVTest()
   : testHeaderType("test_t", 0) {
   testHeaderType.push_back_field("f16", 16);
   testHeaderType.push_back_field("f48", 48);
   phv_factory.push_back_header("test1", testHeader1, testHeaderType);
   phv_factory.push_back_header("test2", testHeader2, testHeaderType);
 }
  AgeingTest()
      : testHeaderType("test_t", 0),
        action_fn("actionA", 0),
        ageing_writer(new MemoryAccessor(4096)),
        phv_source(PHVSourceIface::make_phv_source()) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);

    key_builder.push_back_field(testHeader1, 0, 16, MatchKeyParam::Type::EXACT);

    typedef MatchTableAbstract::ActionEntry ActionEntry;
    typedef MatchUnitExact<ActionEntry> MUExact;

    LookupStructureFactory factory;

    std::unique_ptr<MUExact> match_unit(new MUExact(1, key_builder, &factory));

    // counters disabled, ageing enabled
    table = std::unique_ptr<MatchTable>(
      new MatchTable("test_table", 0, std::move(match_unit), false, true)
    );
    table->set_next_node(0, nullptr);
  }
 LearningTest()
   : testHeaderType("test_t", 0),
     learn_writer(new MemoryAccessor(4096)) {
   testHeaderType.push_back_field("f16", 16);
   testHeaderType.push_back_field("f48", 48);
   phv_factory.push_back_header("test1", testHeader1, testHeaderType);
   phv_factory.push_back_header("test2", testHeader2, testHeaderType);
 }
 ConditionalsTest()
   : testHeaderType("test_t", 0) {
   testHeaderType.push_back_field("f32", 32);
   testHeaderType.push_back_field("f48", 48);
   testHeaderType.push_back_field("f8", 8);
   testHeaderType.push_back_field("f16", 16);
   testHeaderType.push_back_field("f128", 128);
   phv_factory.push_back_header("test1", testHeader1, testHeaderType);
   phv_factory.push_back_header("test2", testHeader2, testHeaderType);
 }
  ActionsTest()
      : testHeaderType("test_t", 0),
        testActionFn("test_action", 0),
        testActionFnEntry(&testActionFn),
        phv_source(PHVSourceIface::make_phv_source()) {
    testHeaderType.push_back_field("f32", 32);
    testHeaderType.push_back_field("f48", 48);
    testHeaderType.push_back_field("f8", 8);
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f128", 128);

    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);

    phv_factory.push_back_header("testS0", testHeaderS0, testHeaderType);
    phv_factory.push_back_header("testS1", testHeaderS1, testHeaderType);
    phv_factory.push_back_header_stack("test_stack", testHeaderStack,
				       testHeaderType,
				       {testHeaderS0, testHeaderS1});
  }
  TableIndirect() 
    : testHeaderType("test_t", 0), action_fn("actionA", 0) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);

    key_builder.push_back_field(testHeader1, 0, 16);

    // with counters, without ageing
    table = MatchTableIndirect::create("exact", "test_table", 0,
				       table_size, key_builder,
				       true, false);
    table->set_next_node(0, nullptr);
  }
  CalculationTest()
      : testHeaderType("test_t", 0),
        oneParseState("parse_state", 0),
        parser("test_parser", 0),
        phv_source(PHVSourceIface::make_phv_source()) {
    testHeaderType.push_back_field("f16", 16);
    testHeaderType.push_back_field("f48", 48);
    testHeaderType.push_back_field("f32_1", 32);
    testHeaderType.push_back_field("f32_2", 32);
    testHeaderType.push_back_field("f5", 5);
    testHeaderType.push_back_field("f19", 19);

    phv_factory.push_back_header("test1", testHeader1, testHeaderType);
    phv_factory.push_back_header("test2", testHeader2, testHeaderType);
  }
示例#11
0
 virtual void SetUp() {
   phv = phv_factory.create();
 }
示例#12
0
Packet::PHVPool::PHVPool(const PHVFactory &phv_factory)
  : phv_factory(phv_factory) {
  phvs.push_back(std::move(phv_factory.create()));
}