[dpdk-dev] How to know corresponding device from port number

Tetsuya.Mukawa mukawa at igel.co.jp
Fri Dec 6 07:22:06 CET 2013


(2013/11/28 19:46), Richardson, Bruce wrote:
>> If someone wants to implement forwarding application that receives
>> packets from ETH_A and send those to ETH_B.
>> Also above application is split to 3 processes like following.
>> [ETH_A]-->Process_A --> [Ring_A] --> Process_B --> [Ring_B] --> Process_C --
>>> [ETH_B] (All 3 processes are implemented using PMD)
>> At present, to implement Process_B might be difficult or tricky because ring
>> can't be distinguished.
>>
>> I guess all virtual eth device like ring and pcap should have MAC address.
>> And It should be possible to specify MAC address from command line.
>> If so, DPDK application can distinguish all ports using MAC address even if
>> port corresponds virtual eth device.
> [BR] Actually, the way the ring pmd is implemented is designed to take account of this multi-process scenario in a slightly different way. 
>
> Firstly, the ethernet device numbers used are always per-process, which is why in the multiprocess case, we still do a load of the ethernet drivers and a pci probe on initialization of secondary processes. Any ring PMDs created by passing EAL parameters to a process are therefore local to that process alone. To use the ring-based PMD to exchange packets between two processes, the APIs of the ring PMD should be used directly by the app, instead of via the EAL commandline. The rings should be directly created in the app, e.g. in process A, using rte_ring_create(), and then, if you need a PMD interface to the ring, you call the rte_eth_from_rings() API. Then in process B, you use rte_ring_lookup() to get the pointer to the ring(s) you wish to use, and again call rte_eth_from_ring() to similarly wrap that into an eth_dev structure.
>
> (Now, it's also worth noting that you may pay a very small performance penalty for not using the ring APIs directly, since the ring enqueue and dequeue functions are direct function calls that often can be inlined by the compiler. Using the rings through an eth_dev API gives you API consistency, but it means that the ring enqueue and dequeue is done via function pointers, which means the calls cannot be inlined directly.)

Thanks  Richardson,
I understand how to use the RIng PMD in above case.

Tetsuya Mukawa


More information about the dev mailing list