Hi,
I have a question about the actual input format used by the Tofino hash function when multiple fields are provided as hash inputs.
As an example, during packet parsing, I place parsed header contents into the following fields:
struct ig_packet_parsed_header_t {
bit<8> field_1_1;
bit<16> field_1_2;
bit<32> field_1_3;
bit<64> field_1_4;
bit<8> field_2_1;
bit<16> field_2_2;
bit<32> field_2_3;
bit<8> field_3_1;
bit<16> field_3_2;
bit<32> field_3_3;
}
For different packets, some of these fields may not be populated by the parser, while others always contain valid values.
I then use these fields as inputs to a hash function, as shown below:
CRCPolynomial<bit<16>>( 0x8005, true, false, false, 16w0x0000, 16w0xFFFF) crc16_usb;
Hash<bit<16>>(HashAlgorithm_t.CUSTOM, crc16_usb) hash_16;
bit<16> value_1 = hash_16.get({field_1_1, field_1_2, field_1_3, field_1_4,
field_2_1, field_2_2, field_2_3,
field_3_1, field_3_2, field_3_3});
Assume that for a given packet, the parser does not populate field_1_4, field_2_3, field_3_1, and field_3_3 (i.e., these fields contain no valid parsed data). The other fields have the following values:
bit<8> field_1_1 = 0x01
bit<16> field_1_2 = 0x0203
bit<32> field_1_3 = 0x04050607
bit<64> field_1_4 // not populated
bit<8> field_2_1 = 0x08
bit<16> field_2_2 = 0x090A
bit<32> field_2_3 // not populated
bit<8> field_3_1 // not populated
bit<16> field_3_2 = 0x0B0C
bit<32> field_3_3 // not populated
My questions are:
- What is the actual byte sequence fed into the hash function?
- Is it a compact concatenation of only the populated fields, for example:
01 02 03 04 05 06 07 08 09 0A 0B 0C
- Or a reversed byte order (little-endian / network-order transformation), such as:
0C 0B 0A 09 08 07 06 05 04 03 02 01
- Or are the unused fields padded with zeros according to their declared bit widths, for example:
01 02 03 04 05 06 07 00 00 00 00 00 00 00 00
08 09 0A 00 00 00 00
00 0B 0C 00 00 00 00
- I have tried to verify the result using an online CRC calculator (Sunshine's Homepage - Online CRC Calculator Javascript), but I cannot obtain results consistent with the P4 hash output. This might be due to incorrect CRC settings. Could someone clarify how the six parameters of CRCPolynomial correspond to the configuration options in the online CRC calculator?
Any clarification or references would be greatly appreciated.
Thanks!