Skip to content

Wrong bitwise alignment expected for LPM keys when they are not multiples of 8 bits in size #625

Description

@jafingerhut

The PI library (and behavioral-model repo, which has its own separate issue to track this) expect LPM keys to always be "left aligned" in an integer number of 8-bit bytes.

This matches what the P4Runtime API specification says, when the LPM key fields are a multiple of 8 bits wide.

However, when an LPM key field has a bit width W that is not a multiple of 8 bits wide, the P4Runtime specification requires that the W bits are in the least significant W bits of the minimum number of bytes required to hold W bits.

To have a more visual example:

# What the PI library expects today for an LPM key field with width W=20 bits, where 0
# bits represent bit positions that are outside of the LPM key value, and 1 bits represent
# bit positions that are part of the LPM key value.
1111_1111 1111_1111 1111_0000
^^^^^^^^^ most significant byte
                    ^^^^^^^^^ least significant byte

# What the P4Runtime specification says about where the bits should be for such a field:
0000_1111 1111_1111 1111_1111

Correcting this is a small change to the PI library code, but is likely to be a bit more changes within the behavioral-model repository code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions