Ben/Damjan,
Perhaps this will help answer my question. Pleas see C code I added to a repo: https://github.com/hesingh/misc/blob/master/p4tovpp/pool_cache.c See that I used aligned pool get. https://github.com/hesingh/misc/blob/master/p4tovpp/pool_cache.c#L17 Then, when the entry is looked up, this is where I use the right shift: https://github.com/hesingh/misc/blob/master/p4tovpp/pool_cache.c#L34 I think, since the value is already aligned due to use of pool_get_aligned(), I should not have to use the right shift on line 32, do I? If yes, I wonder where is the right shift used, if at all, for such code? Note, this is just a simple exact-match table entry. I have yet to try VPP classifier and using the opaque_index. Thanks, Hemant From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of hemant via lists.fd.io Sent: Sunday, February 14, 2021 9:23 PM To: dmar...@me.com Cc: bga...@cisco.com; ne...@graphiant.com; ayour...@gmail.com; vpp-dev@lists.fd.io Subject: Re: [vpp-dev] classifier howto? I got time to write this code now – sorry I was backed up writing the compiler. I used the suggestion by Ben to use the pool and I have setup table entries using pool_get_aligned(). I could make the code work and packet testing passed. But I am confused about “pointer to heap offset >> CLIB_LOG2_CACHE_LINE_BYTES.” Now all I have is a u32 index into the pool. So, I am not sure what is the pointer to the heap and the right shift? Thanks, Hemant From: Damjan Marion <dmar...@me.com <mailto:dmar...@me.com> > Sent: Wednesday, January 20, 2021 10:34 AM To: hem...@mnkcg.com <mailto:hem...@mnkcg.com> Cc: bga...@cisco.com <mailto:bga...@cisco.com> ; ne...@graphiant.com <mailto:ne...@graphiant.com> ; ayour...@gmail.com <mailto:ayour...@gmail.com> ; vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io> Subject: Re: [vpp-dev] classifier howto? Please note that we also have fixed pool implementation which may be used if you want to prevent pool resizing….. Another option is to make your entries cacheline aligned, and then convert pointer to heap offset shifted right for LOG2_CACHELINE_SIZE. That will give you working solution for HEAP sizes up to 256G. We do something similar in the buffer allocator. — Damjan On 20.01.2021., at 16:26, hemant via lists.fd.io <http://lists.fd.io> <hemant=mnkcg....@lists.fd.io <mailto:hemant=mnkcg....@lists.fd.io> > wrote: Hi Ben, Great, thanks for the pool info! I am all set. I will close the JIRA issue and also the code review. Best wishes, Hemant -----Original Message----- From: Benoit Ganne (bganne) < <mailto:bga...@cisco.com> bga...@cisco.com> Sent: Wednesday, January 20, 2021 9:47 AM To: <mailto:hem...@mnkcg.com> hem...@mnkcg.com; <mailto:ne...@graphiant.com> ne...@graphiant.com; <mailto:ayour...@gmail.com> ayour...@gmail.com Cc: <mailto:vpp-dev@lists.fd.io> vpp-dev@lists.fd.io Subject: RE: [vpp-dev] classifier howto? No, a u64 suffices. See how the u64 works with a bihash for any value, not just pkt_filter4_0_value, in the code example given below. Ok thanks. So you use the u64 to store a pointer to your structure allocated on the heap. The usual way to do this in VPP instead is to allocate your structure in a pool. You can then store the u32 index of your data in the bihash and use opaque_index directly. value = pool_get(pkt_filter4_pool); u32 index = value - pkt_filter4_pool; memcpy(value, &val, sizeof(val)); kv.value = index; clib_bihash_add_del_48_8 (&ump->hash_table_pkt_filter4_0, &kv, 1); Then you can retrieve value using this index (either coming from bihash lookup or from opaque_index): value = pool_elt_at_index(pkt_filter4_pool, index); I am not convinced adding metadata in opaque or opaque2 is really needed here. Best ben struct pkt_filter4_0_value val = {}, *value; val.action = permit4; val.u.permit4.abits = 130; val.u.permit4.ig_strip = 0; val.u.permit4.outer_desc = 1; val.u.permit4.teid = 5241; val.u.permit4.ip = 0x03030302; val.u.permit4.src_ip = 0x03030301; val.u.permit4.dstPort = 2152; val.u.permit4.filt_dir = 1; val.u.permit4.reflec_qos = 0; value = malloc(sizeof(val)); memcpy(value, &val, sizeof(val)); kv.value = (u64) value; clib_bihash_add_del_48_8 (&ump->hash_table_pkt_filter4_0, &kv, 1); Hemant -----Original Message----- From: Benoit Ganne (bganne) <bga...@cisco.com <mailto:bga...@cisco.com> > Sent: Wednesday, January 20, 2021 8:13 AM To: hem...@mnkcg.com; ne...@graphiant.com <mailto:ne...@graphiant.com> ; ayour...@gmail.com <mailto:ayour...@gmail.com> Cc: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io> Subject: RE: [vpp-dev] classifier howto? A github link is included in the JIRA issue to articulate the use case, https://jira.fd.io/browse/VPP-1967 <https://jira.fd.io/browse/VPP-1967> The github link has a value for a classifier entry shown: https://github.com/FDio/vpp/pull/33 <https://github.com/FDio/vpp/pull/33> The value is a value used in a 5G UPF. Is the 64-bits value you refer to the "struct pkt_filter4_0_value"? It looks much bigger than 64-bits to me... Best ben
smime.p7s
Description: S/MIME cryptographic signature
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#18751): https://lists.fd.io/g/vpp-dev/message/18751 Mute This Topic: https://lists.fd.io/mt/79925983/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-