[dpdk-dev] [PATCH v2 1/6] mbuf: add buffer offset field for flexible indirection
Olivier Matz
olivier.matz at 6wind.com
Tue Apr 3 10:26:15 CEST 2018
Hi,
On Mon, Apr 02, 2018 at 11:50:03AM -0700, Yongseok Koh wrote:
> When attaching a mbuf, indirect mbuf has to point to start of buffer of
> direct mbuf. By adding buf_off field to rte_mbuf, this becomes more
> flexible. Indirect mbuf can point to any part of direct mbuf by calling
> rte_pktmbuf_attach_at().
>
> Possible use-cases could be:
> - If a packet has multiple layers of encapsulation, multiple indirect
> buffers can reference different layers of the encapsulated packet.
> - A large direct mbuf can even contain multiple packets in series and
> each packet can be referenced by multiple mbuf indirections.
>
> Signed-off-by: Yongseok Koh <yskoh at mellanox.com>
I think the current API is already able to do what you want.
1/ Here is a mbuf m with its data
off
<-->
len
+----+ <---------->
| |
+-|----v----------------------+
| | -----------------------|
m | buf | XXXXXXXXXXX ||
| -----------------------|
+-----------------------------+
2/ clone m:
c = rte_pktmbuf_alloc(pool);
rte_pktmbuf_attach(c, m);
Note that c has its own offset and length fields.
off
<-->
len
+----+ <---------->
| |
+-|----v----------------------+
| | -----------------------|
m | buf | XXXXXXXXXXX ||
| -----------------------|
+------^----------------------+
|
+----+
indirect |
+-|---------------------------+
| | -----------------------|
c | buf | ||
| -----------------------|
+-----------------------------+
off len
<--><---------->
3/ remove some data from c without changing m
rte_pktmbuf_adj(c, 10) // at head
rte_pktmbuf_trim(c, 10) // at tail
Please let me know if it fits your needs.
Regards,
Olivier
More information about the dev
mailing list