DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] How to getting first objects from a rte_mempool buffer every time?
@ 2019-03-20 10:44 宋捷
  2019-03-20 11:57 ` Van Haaren, Harry
  0 siblings, 1 reply; 2+ messages in thread
From: 宋捷 @ 2019-03-20 10:44 UTC (permalink / raw)
  To: users

Hi all,

 

I have a pcap file that contained 100 IP packets. I can send them by DPDK by
below steps:

 

1.     I create a rte_mempool buffer by rte_pktmbuf_pool_create. load these
100 packets into this buffer. 

2.     call rte_mempool_get_bulk to getting packets form rte_mempool buffer
into rte_mbuf buffer,

3.     put rte_mbuf buffer into rte_eth_tx_burst for sending .

The pcap packets can be sent out from 1 to 100  Ok.

 

Now I want to send the only first 10 packets every time,

rte_mempool_get_bulk can get 1-10 objects, but next time it will get 11-20
objects.

I don’t know if there is easy way to getting first 10 objects from
rte_mempool buffer every time?

 

 

Thanks

 

Jie


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-users] How to getting first objects from a rte_mempool buffer every time?
  2019-03-20 10:44 [dpdk-users] How to getting first objects from a rte_mempool buffer every time? 宋捷
@ 2019-03-20 11:57 ` Van Haaren, Harry
  0 siblings, 0 replies; 2+ messages in thread
From: Van Haaren, Harry @ 2019-03-20 11:57 UTC (permalink / raw)
  To: songj, users

> -----Original Message-----
> From: users [mailto:users-bounces@dpdk.org] On Behalf Of ??
> Sent: Wednesday, March 20, 2019 10:45 AM
> To: users@dpdk.org
> Subject: [dpdk-users] How to getting first objects from a rte_mempool buffer
> every time?
> 
> Hi all,

Hi Jie,


> I have a pcap file that contained 100 IP packets. I can send them by DPDK by
> below steps:
> 
> 1.     I create a rte_mempool buffer by rte_pktmbuf_pool_create. load these
> 100 packets into this buffer.
> 
> 2.     call rte_mempool_get_bulk to getting packets form rte_mempool buffer
> into rte_mbuf buffer,
> 
> 3.     put rte_mbuf buffer into rte_eth_tx_burst for sending .
> 
> The pcap packets can be sent out from 1 to 100  Ok.
> 
> Now I want to send the only first 10 packets every time,
> 
> rte_mempool_get_bulk can get 1-10 objects, but next time it will get 11-20
> objects.
> 
> I don’t know if there is easy way to getting first 10 objects from
> rte_mempool buffer every time?

The mempool data-structure is not designed for this usage.

If you require the first 10 items, I recommend dequeueing them from the
mempool once (as you have described above), and then caching them in another
data-structure to "loop" over them.

Typically an rte_ring would work well here, with the 10 items being dequeued
and re-enqueued over-and-over again to loop.


Note; when sending an mbuf via Ethdev, the refcount will be decremented,
and possibly the mbuf will be free()-ed and returned to the mempool.

If you wish to "keep" the mbuf in the rte_ring cache, consider incrementing
the refcount of the mbuf every time before you TX it - the result will be that
the mbuf is not freed back to the mempool, and remain valid to TX again.


> Thanks
> Jie

Hope that helps! -Harry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-20 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 10:44 [dpdk-users] How to getting first objects from a rte_mempool buffer every time? 宋捷
2019-03-20 11:57 ` Van Haaren, Harry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).