HI Francois
What you said is correct and in such case API should only have odp_packet_t as
an its type signature and access memory as per implementation policy.
I am talking about use case where an API can input data both as a plain buffer
(which is a contiguous memory) *OR* as a packet (which is variable,
scattered/non-scattered segmented memory). So when API sees that input data is
from buffer pool, can simply use address returned by odp_buf_addr as memory
pointer and do direct read/write (as its not segmented and contiguous memory)
and when it sees chunk is from packet pool , then access data according to its
base hw implementation.
I am taking here a simple memcpy() pseudo example to explain case . Say, if I
want to enable memcpy from both packet and buffer memory, then there are 2 ways
of doing it:
1. Add two separate APIs , say memcpy_from_buffer(odp_buffer_t buf,size_t
len, void *dst) and memcpy_from_packet(odp_packet_t packet, size_t len, void *)
OR
2. Or, make one API say memcpy(odp_handle_t handle, odp_pool_t pool,
size_t len, void *dst)
{
if (pool type== odp_buffer_t ) then
addr=odp_buffer_addr((odp_buffer_t)handle);
else
addr=odp_packet_data((odp_packet_t)handle);
memcpy(dst,addr,len);
}
Hope this could explain intended use case to an extent.
Thanks
Shally
From: Francois Ozog [mailto:[email protected]]
Sent: 01 March 2017 13:28
To: Verma, Shally <[email protected]>
Cc: [email protected]
Subject: Re: [lng-odp] Generic handle in ODP
Hi Shally,
I am unsure this leads to a safe direction and here is why.
Depending on the hardware, software provides either
1) a bunch of buffers where the HW will place packets (1 buffer will receive
one packet)
or 2) a large memory zone in which the hardware will place the packets
according to a silicon specific policy.
In the case of 2, I am not sure a packet has to be contained in a odp_buffer_t.
And even so, freeing such an odp_buffer_t will not result in freeing the
underlying memory because allocation unit is memory region not odp_buffer_t.
Could you elaborate on the use case you have in mind?
Cordially,
FF
On 1 March 2017 at 07:41, Verma, Shally
<[email protected]<mailto:[email protected]>> wrote:
I wanted to check if we could introduce a generic handle concept in ODP
(something like odp_handle_t carrying purpose similar to void * ) which can be
used for API that need to handle multiple types in one call. Ex. an API that
works on both Packet and Buffer Type .Such use cases can take generic handle in
input and map it to either per requirement.
If agreed, following defines the purpose..
odp_handle_t is a generic handle type which implementation should implement in
such a way that it could be map to represent any other type.
It is to aid an API which handle multiple types. Example , odp_handle_t can
represent as odp_buffer_t or odp_packet_t
Thanks
Shally
--
[Linaro]<http://www.linaro.org/>
François-Frédéric Ozog | Director Linaro Networking Group
T: +33.67221.6485<tel:%2B33.67221.6485>
[email protected]<mailto:[email protected]> | Skype: ffozog