Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDPF dependencies in TdiTableManager #290

Open
ffoulkes opened this issue Oct 22, 2024 · 0 comments
Open

IDPF dependencies in TdiTableManager #290

ffoulkes opened this issue Oct 22, 2024 · 0 comments
Assignees

Comments

@ffoulkes
Copy link
Collaborator

ffoulkes commented Oct 22, 2024

Synopsis

TdiTableManager supports the PacketModMeter and DirectPacketModMeter P4Externs, which are ES2K-specific. To support them, TableManager #includes idpf/p4info.pb.h, which is only available in the ipdk-io/p4runtime-dev repository.

This is undesirable, since it couples the DPDK and Tofino platforms to a version of P4Runtime that has been customized for ES2K.

Expected behavior

TdiTableManager should provide for target-specific handling of P4 resources, incorporated as part of the build.

Proposed solution

This is somewhat kludgy, but it changes less code and is easier to review than the more general solution, which is described in issue #304.

  1. Define a generic base class (TdiTableAnnex) and a subclass for each target that requires one (Es2kTableAnnex).
  2. Modify each site in TdiTableManager that performs target-specific processing to support a P4Extern, and add a method to the TableAnnex classes.
  3. Move the ES2K-specific code from TdiTableManager to the corresponding method in Es2kTableAnnex, and replace the original with a call to the method.
  4. Add a method toTdiTargetFactory that creates a TableAnnex class of the correct type.
  5. This will allow us to isolate the ES2K-specific code and prevent it from being included by the other targets.

Sample code

With this approach, the following code fragment:

if (resource_type == "DirectPacketModMeter" &&
    table_entry.has_meter_config()) {
  bool units_in_packets;  // or bytes
  ASSIGN_OR_RETURN(
      auto meter,
      tdi_extern_manager_->FindDirectPktModMeterByID(resource_id));
  RETURN_IF_ERROR(GetMeterUnitsInPackets(meter, units_in_packets));

  TdiPktModMeterConfig config;
  config.SetTableEntry(table_entry);
  config.isPktModMeter = units_in_packets;

  RETURN_IF_ERROR(table_data->SetPktModMeterConfig(config));
}

becomes this:

if (resource_type == "DirectPacketModMeter") {
  RETURN_IF_ERROR(tdi_table_annex_->BuildDirPktModTableData(
      table_entry, table_data, resource_id));
}

Class model

tdi_table_annex

@ffoulkes ffoulkes added bug Something isn't working and removed bug Something isn't working labels Oct 22, 2024
@ffoulkes ffoulkes self-assigned this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant