[P4-dev] reading egress port from register
antonin at barefootnetworks.com
Tue Aug 1 14:47:07 EDT 2017
It is pretty simple IMO:
1) compute a random index for your register lookup. You can either use
modify_field_with_hash_based_offset if the "randomness" comes from
computing a hash over a list of fields (header fields or metadata fields),
or modify_field_rng_uniform if you want a truly random number. Both of
these primitives will let you get a value in the range of your choice, i.e.
2) use register_read to read the value stored at the index computed in 1)
in the register array. When calling register_read, you can either copy the
value directly into standard_metadata.egress_spec or into one of your
user-defined metadata field (and copy this value to
standard_metadata.egress_spec later in the pipeline).
I am not sure what you mean by "How can I match this metadata value using a
table?". There is no real difference between matching on a header field or
a metadata field (except for validity considerations).
On Tue, Aug 1, 2017 at 4:05 AM, Roshan Se <roshan.sedar at student.uclouvain.be
> I am trying to pick the outgoing (a random fashion) from a register, where
> I have stored all the available outgoing ports in the register in advance.
> What I tried to do so far is that reading the register value into a
> metadata field and copy (modify_field) to egress_spec. I am not sure
> whether this is the right way to do.
> How can I match this metadata value using a table? how can I do mod
> operation on the register value set?
> any help would be great. thanks in advance,
> P4-dev mailing list
> P4-dev at lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the P4-dev