# Range Matching TNA

**URL:** <https://forum.p4.org/t/range-matching-tna/1254>\
**Category:** Uncategorized\
**Created:** [February 10, 2025, 10:11am UTC](https://forum.p4.org/t/range-matching-tna/1254 "2025-02-10T10:11:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![layal](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@layal](https://forum.p4.org/u/layal)\
**Post date:** [February 10, 2025, 10:11am UTC](https://forum.p4.org/t/range-matching-tna/1254/1 "2025-02-10T10:11:19Z")

</div>

Hello,  
I am trying to compile a program that includes range match key, and I encountered the following error:

"error: Currently in p4c, the table forward\_l2\_0 cannot perform a range match on key ingress::meta.current as the key does not fit in under 5 PHV nibbles.

Are there constraints on the key size for range matches? Also, is the range matching algorithm in tofino now open source?

---

<div class="post-metadata">

**Author:** ![p4prof](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/p4prof/32/251_2.png) [@p4prof](https://forum.p4.org/u/p4prof)\
**Post date:** [February 12, 2025, 4:11am UTC](https://forum.p4.org/t/range-matching-tna/1254/2 "2025-02-12T04:11:08Z")

</div>

@layal ,

According to the message, you defined a table that uses `range` match kind on a key field that is longer than 20 bits (5 nibbles) and that is not supported by the compiler.

Unfortunately, I am not allowed to answer the rest of the questions in a public forum, since I am not aware of Intel ever publishing the range matching algorithm details. If you have access to ICRP Forum, please ask the question there so that I can provide more information.

It is my hope that sooner or later Intel will lift a lot of these restrictions, but currently this is not the case and your question clearly demonstrates the importance of doing that even (or especially) in light of open-sourcing the SDE.

---

<div class="post-metadata">

**Author:** ![layal](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@layal](https://forum.p4.org/u/layal)\
**Post date:** [February 12, 2025, 8:12am UTC](https://forum.p4.org/t/range-matching-tna/1254/3 "2025-02-12T08:12:13Z")

</div>

Thank you very much for your response.

---

<div class="post-metadata">

**Author:** ![fruffy](https://avatars.discourse-cdn.com/v4/letter/f/a8b319/32.png) [@fruffy](https://forum.p4.org/u/fruffy)\
**Post date:** [February 12, 2025, 1:54pm UTC](https://forum.p4.org/t/range-matching-tna/1254/4 "2025-02-12T13:54:27Z")

</div>

> Unfortunately, I am not allowed to answer the rest of the questions in a public forum, since I am not aware of Intel ever publishing the range matching algorithm details.

Considering much of the Tofino code is now open-source, we can probably use whatever exists in the code as our guideline 🙂

> <https://github.com/p4lang/p4c/blob/c67d1fd01f598ccf9ee9ec115d5901ac799f97be/backends/tofino/bf-p4c/mau/resource_estimate.cpp#L1601>
