[P4-dev] Custom Hash Functions

Antonin Bas antonin at barefootnetworks.com
Fri Jun 17 23:37:06 EDT 2016


Hi Vibhaa,

The link you included in your email refers to the original version of the
P4 software switch (p4c-behavioral). We are deprecating this code and most
of the community is now using the new version, known as bmv2:
https://github.com/p4lang/behavioral-model
It is very easy to add a new hash function in bmv2. Once you get familiar
with bmv2 (the README is a good place to start), you can edit this file to
include your hash functions:
https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch/simple_switch.cpp#L62.
This file defines 2 example hash functions (called hash_ex and bmv2_hash),
from which you can take inspiration. Note that the "standard" hash
functions (e.g. crc16) are still available, but they are defined in a
different place, which you need not worry about.
I once wrote a long email to the mailing list about writing your own hash
functions. Unfortunately it cannot be found in the p4-dev archives any more
(we had a technical issue a few months ago and the archives were lost). I
will find it in my inbox and forward it to the list so that you can read it.

Best,

Antonin

On Fri, Jun 17, 2016 at 1:18 PM, Vibhaalakshmi Sivaraman <
vibhaa at princeton.edu> wrote:

> How can we add our own custom hash functions to the existing set of field
> list calculations? Flow Radar
> <https://github.com/USC-NSL/p4c-behavioral/blob/9a4c17c42a0de05f14aa9a0b9d0abf19b5d6129b/p4c_bm/templates/src/checksums_algos.h> seems
> to have done this, but I am not sure what the procedure for compiling it,
> which is the right place to make the addition or if there are any
> restrictions on the format. Any help on this would be great!
>
> Thanks,
> Vibhaa
>
> --
> Vibhaalakshmi Sivaraman
> Computer Science
> Princeton University '17
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160617/53ad4d84/attachment-0002.html>


More information about the P4-dev mailing list