DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] How to know corresponding device from port number
@ 2013-11-26 10:15 Tetsuya.Mukawa
  2013-11-26 10:38 ` Richardson, Bruce
  0 siblings, 1 reply; 5+ messages in thread
From: Tetsuya.Mukawa @ 2013-11-26 10:15 UTC (permalink / raw)
  To: dev

Hi,

I have a question about how to know corresponding device from port number.
For example, if I have 4 Ethernet devices and 2 Ring PMDs, I will get 6
ports during initialization.
In the case, how can I know which port corresponds last Ring PMD?

Regards,
Tetsuya Mukawa

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

* Re: [dpdk-dev] How to know corresponding device from port number
  2013-11-26 10:15 [dpdk-dev] How to know corresponding device from port number Tetsuya.Mukawa
@ 2013-11-26 10:38 ` Richardson, Bruce
  2013-11-27  1:47   ` Tetsuya.Mukawa
  0 siblings, 1 reply; 5+ messages in thread
From: Richardson, Bruce @ 2013-11-26 10:38 UTC (permalink / raw)
  To: Tetsuya.Mukawa, dev

> 
> Hi,
> 
> I have a question about how to know corresponding device from port
> number.
> For example, if I have 4 Ethernet devices and 2 Ring PMDs, I will get 6 ports
> during initialization.
> In the case, how can I know which port corresponds last Ring PMD?

[BR] Firstly, to identify the ring PMD's vs the ethernet device PMDs you can use the information in the rte_eth_dev structure. For each device x, (0 <= x <=5), if you check rte_eth_devices[x], the ring pmd's will have a NULL driver pointer and the pci address given in the pci_dev structure will be all-zeros.
As for distinguishing two different ring ethdevs from each other, I'm not aware of any way to do this, they will just have different eth_dev indexes.

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

* Re: [dpdk-dev] How to know corresponding device from port number
  2013-11-26 10:38 ` Richardson, Bruce
@ 2013-11-27  1:47   ` Tetsuya.Mukawa
  2013-11-28 10:46     ` Richardson, Bruce
  0 siblings, 1 reply; 5+ messages in thread
From: Tetsuya.Mukawa @ 2013-11-27  1:47 UTC (permalink / raw)
  To: Richardson, Bruce, dev

> [BR] Firstly, to identify the ring PMD's vs the ethernet device PMDs you can use the information in the rte_eth_dev structure. For each device x, (0 <= x <=5), if you check rte_eth_devices[x], the ring pmd's will have a NULL driver pointer and the pci address given in the pci_dev structure will be all-zeros.
> As for distinguishing two different ring ethdevs from each other, I'm not aware of any way to do this, they will just have different eth_dev indexes.

Thanks, I understand there is no way to distinguish rings.
It will be a problem in following case.

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.

Thanks,
Tetsuya Mukawa

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

* Re: [dpdk-dev] How to know corresponding device from port number
  2013-11-27  1:47   ` Tetsuya.Mukawa
@ 2013-11-28 10:46     ` Richardson, Bruce
  2013-12-06  6:22       ` Tetsuya.Mukawa
  0 siblings, 1 reply; 5+ messages in thread
From: Richardson, Bruce @ 2013-11-28 10:46 UTC (permalink / raw)
  To: Tetsuya.Mukawa, dev

> 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.)

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

* Re: [dpdk-dev] How to know corresponding device from port number
  2013-11-28 10:46     ` Richardson, Bruce
@ 2013-12-06  6:22       ` Tetsuya.Mukawa
  0 siblings, 0 replies; 5+ messages in thread
From: Tetsuya.Mukawa @ 2013-12-06  6:22 UTC (permalink / raw)
  To: Richardson, Bruce, dev

(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

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

end of thread, other threads:[~2013-12-06  6:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26 10:15 [dpdk-dev] How to know corresponding device from port number Tetsuya.Mukawa
2013-11-26 10:38 ` Richardson, Bruce
2013-11-27  1:47   ` Tetsuya.Mukawa
2013-11-28 10:46     ` Richardson, Bruce
2013-12-06  6:22       ` Tetsuya.Mukawa

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).