What can I help you with?
DOCA Documentation v3.0.0

Hello Packet Example

This example demonstrates the most basic pipeline in the DOCA target architecture. It consists of:

  • Match on L2 source MAC address

  • Action to either forward to a P4 port ID, drop, or no action

The following #includes are required for every DPL program. They define the DOCA target architecture. In particular, they contain things like the default DOCA parser, default headers struct, etc. Note that the symbol names are prefixed with "nv_" and are reserved for NVIDIA DOCA TA usage.

Copy
Copied!
            

#include <doca_model.p4> #include <doca_headers.p4> #include <doca_externs.p4> #include <doca_parser.p4>

The DOCA TA features a single control, which requires a headers struct and standard metadata. User metadata and packet out metadata, defined by the user, are optional.

Copy
Copied!
            

control hello_packet(     inout nv_headers_t headers,     in nv_standard_metadata_t std_meta,     inout nv_empty_metadata_t user_meta,     inout nv_empty_metadata_t pkt_out_meta ) {     action drop() {         nv_drop();     }       action forward(bit<32> port) {         nv_send_to_port(port);     }       table forward_table {         key = {             headers.ethernet.dst_addr : exact;         }         actions = {             drop;             forward;             NoAction;         }         default_action = forward(3);         const entries = {             (48w0x001111111111) : forward(1);             (48w0x002222222222) : forward(2);             (48w0x00dddddddddd) : drop();             (48w0x00aaaaaaaaaa) : NoAction();             (48w0x00bbbbbbbbbb) : NoAction();         }     }     apply {         forward_table.apply();     } }

Finally, the main package must be instantiated:

Copy
Copied!
            

NvDocaPipeline(     nv_fixed_parser(),     hello_packet() ) main;

Info

For more information, refer to the full DPL example, hello_packet.p4.

© Copyright 2025, NVIDIA. Last updated on May 5, 2025.