cli_commands.txt File Contents - 2022.2 English

Vitis Networking P4 User Guide (UG1308)

Document ID
2022.2 English

In addition to input packet data (and optional input meta data), all of the example designs have an input cli_commands.txt file. This file must, at a minimum, contain the run_traffic command. For example, run_traffic <packetname>. (Refer to the previous section, p4bm-vitisnet-cli application, for more information on the run_traffic command).

It is also recommended that the command exit be included at the end of every cli_commands.txt file, although this is not mandatory.

The cli_commands.txt file can contain the following commands:

Add an entry to the specified table
Modify an existing entry on the specified table
Delete an entry from the specified table
Delete all entries from the specified table
Delete all entries from all tables
Read a counter value from a specified counter extern
Update a counter value of a specified counter extern
Reset all counter values of a specified counter extern
Load traffic and metadata for the example

The format of each of the commands is as follows:

  • table_add <table name> <action name> <match fields> => <action parameters> [priority]
  • table_modify <table name> <entry handle> [action parameters]
  • table_delete <table name> <entry handle>
  • table_clear <table name>
  • reset_state
  • counter_read <counter name> <counter index>
  • counter_write <counter name> <counter index> <byte count> <packet count>
  • counter_reset <counter name>
  • run_traffic <filename>
    For the run_traffic command, the filename parameter specifies the input stimulus packet data and optional metadata files, where packet data is stored in the <filename>_in.pcap|user text file and metadata is stored in the <filename>_in.meta file. The command parameters are defined as follows:
    The name given to the table in the P4 program. It is case sensitive.
    The value given to reference an entry when it is added to the table
    The name given to the action in the P4 program. It is case-sensitive.
    A space-separated list that appears in the same order as the table search key fields as specified in the P4 program. The format of the individual field depends on the match kind used for the field:
    • ternary fields are specified as a hexadecimal value followed by '&&&' followed by a hexadecimal mask (no white space between the numbers and the &&&). Bit positions of the mask equal to 1 are exact match bit positions and bit positions of the mask equal to 0 are wildcard bit positions.
    • field_mask fields are specified in a similar way as ternary fields, but with the restriction that the only mask values permitted are all bits set to 0 or all bits set to 1.
    • lpm fields are specified by a hexadecimal value followed by a '/' character followed by the prefix length (0x0a010203/24 for example). The prefix length must always be in decimal (hexadecimal is not supported). A prefix length of 0 may be used, and such an entry matches any value of that search key field.
    • range fields are specified as a minimum hexadecimal value followed by '->' followed by a maximum hexadecimal value (with no white spaces), for example: 0->0xffffffff for a 32-bit field.
    • exact fields are specified using a hexadecimal value.
    • unused fields are specified using a hexadecimal value.
    action parameters
    A space-separated list of values that provides the parameters for the specified action. They must appear in the same order as they appear in the P4 program.
    In CAMs where multiple entries can match, the lowest priority value of the entry determines the winning response. It must only be specified when the table mode/type is STCAM or TCAM, otherwise it is omitted.

An example of a table_add for the following table with exact, lpm, and field_mask match_fields is as follows:

table test_table {
  key = {meta.port : exact;
  hdr.eth.dmac : lpm;
  hdr.eth.smac : field_mask;
table_add test_table update_flow 0x5 0x296f5d24202a/48 0xeebb6da832d8&&&0xffffffffffff... 

Other examples of cli_commands.txt file entries are further explained in the following sections describing the individual example designs.