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

Add a metadata collection mode to the STF back end. #3933

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

fruffy-bfn
Copy link
Contributor

@fruffy-bfn fruffy-bfn commented Mar 20, 2023

This pull request adds a new test back end that only serializes user metadata from the appropriate target. For v1model, this is the meta variable. We can refine this output as needed.

For example, for pins_middleblock.p4 which has the local metadata

struct local_metadata_t {
    bool                admit_to_l3;
    vrf_id_t            vrf_id;
    packet_rewrites_t   packet_rewrites;
    bit<16>             l4_src_port;
    bit<16>             l4_dst_port;
    bit<16>             wcmp_selector_input;
    bool                apply_tunnel_encap_at_egress;
    ipv6_addr_t         tunnel_encap_src_ipv6;
    ipv6_addr_t         tunnel_encap_dst_ipv6;
    bool                mirror_session_id_valid;
    mirror_session_id_t mirror_session_id_value;
    @field_list(PreservedFieldList.CLONE_I2E)
    ipv4_addr_t         mirroring_src_ip;
    @field_list(PreservedFieldList.CLONE_I2E)
    ipv4_addr_t         mirroring_dst_ip;
    @field_list(PreservedFieldList.CLONE_I2E)
    ethernet_addr_t     mirroring_src_mac;
    @field_list(PreservedFieldList.CLONE_I2E)
    ethernet_addr_t     mirroring_dst_mac;
    @field_list(PreservedFieldList.CLONE_I2E)
    bit<8>              mirroring_ttl;
    @field_list(PreservedFieldList.CLONE_I2E)
    bit<8>              mirroring_tos;
    MeterColor_t        color;
    port_id_t           ingress_port;
    route_metadata_t    route_metadata;
}

the output will be:

# A P4TestGen-generated test case for pins_middleblock.p4
# p4testgen seed: 8
# Date generated: 2023-03-21-09:13:49.993
# Current statement coverage: 0.57

input_packet: 0x02EB6C1F2EBF3B941568
input_port: 440

output_packet: "0x00000000000000000000000008004500002200004000002F7AAE0000000000000000000088BE02EB6C1F2EBF3B941568"
output_port: 0
output_packet_mask: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"


Metadata: *meta.admit_to_l3:0x0
Metadata: *meta.apply_tunnel_encap_at_egress:0x0
Metadata: *meta.color:0x0
Metadata: *meta.ingress_port:0x1B8
Metadata: *meta.l4_dst_port:0x0000
Metadata: *meta.l4_src_port:0x0000
Metadata: *meta.mirror_session_id_valid:0x0
Metadata: *meta.mirror_session_id_value:0x000
Metadata: *meta.mirroring_dst_ip:0x00000000
Metadata: *meta.mirroring_dst_mac:0x000000000000
Metadata: *meta.mirroring_src_ip:0x00000000
Metadata: *meta.mirroring_src_mac:0x000000000000
Metadata: *meta.mirroring_tos:0x00
Metadata: *meta.mirroring_ttl:0x00
Metadata: *meta.packet_rewrites.dst_mac:0x000000000000
Metadata: *meta.packet_rewrites.src_mac:0x000000000000
Metadata: *meta.route_metadata:0x00
Metadata: *meta.tunnel_encap_dst_ipv6:0x00000000000000000000000000000000
Metadata: *meta.tunnel_encap_src_ipv6:0x00000000000000000000000000000000
Metadata: *meta.vrf_id:0x000
Metadata: *meta.wcmp_selector_input:0x0000

This PR also cleans up the P4Tests.cmake files for the BMv2 and eBPF back end and adds options to disable/enable specific test back ends. In this case, we disable the protobuf in favor of the "dummy" metadata back end.

@fruffy-bfn fruffy-bfn force-pushed the metadata_collection branch 5 times, most recently from fb5947d to fe73c52 Compare March 20, 2023 20:34
@fruffy-bfn fruffy-bfn force-pushed the metadata_collection branch from fe73c52 to a833e93 Compare March 21, 2023 13:13
@fruffy fruffy marked this pull request as ready for review March 21, 2023 16:20
Copy link
Contributor

@jnfoster jnfoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!!

@fruffy fruffy merged commit 9aaeb3b into p4lang:main Mar 24, 2023
@fruffy-bfn fruffy-bfn deleted the metadata_collection branch March 31, 2023 13:36
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

Successfully merging this pull request may close these issues.

3 participants