[dpdk-dev,1/5] ethdev: add new API to retrieve RX/TX queue information

Message ID 1434560084-21237-2-git-send-email-konstantin.ananyev@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Ananyev, Konstantin June 17, 2015, 4:54 p.m. UTC
  Add the ability for the upper layer to query RX/TX queue information.

Add new structures:
struct rte_eth_rx_qinfo
struct rte_eth_tx_qinfo

new functions:
rte_eth_rx_queue_info_get
rte_eth_tx_queue_info_get

into rte_etdev API.

Left extra free space in the qinfo structures,
so extra fields could be added later without ABI breakage.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 48 +++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 77 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 124 insertions(+), 1 deletion(-)
  

Comments

Ananyev, Konstantin June 18, 2015, 1:18 p.m. UTC | #1
Add the ability for the upper layer to query RX/TX queue information.
Right now supported for:
ixgbe, i40e, e1000 PMDs.

Konstantin Ananyev (5):
  ethdev: add new API to retrieve RX/TX queue information
  i40e: add support for eth_(rxq|txq)_info_get
  ixgbe: add support for eth_(rxq|txq)_info_get
  e1000: add support for eth_(rxq|txq)_info_get
  testpmd: add new command to display RX/TX queue information

 app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
 app/test-pmd/config.c            | 67 ++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h           |  2 ++
 drivers/net/e1000/e1000_ethdev.h | 12 +++++++
 drivers/net/e1000/em_ethdev.c    |  2 ++
 drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
 drivers/net/e1000/igb_ethdev.c   |  4 +++
 drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c   |  2 ++
 drivers/net/i40e/i40e_ethdev.h   |  5 +++
 drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
 drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
 drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h    | 77 +++++++++++++++++++++++++++++++++++++++-
 16 files changed, 440 insertions(+), 1 deletion(-)
  
miroslaw.walukiewicz@intel.com June 18, 2015, 1:30 p.m. UTC | #2
Konstantin, 

Is there a possibility to read information about available space in NIC queue for TX.

It is quite easy to compute (or even available directly)  and very useful especially for application sending multi-descriptor packets like TCP TSO. 

Now there is no access to such information and the transmit packet function must be called to 
be sure that there is available space.

Mirek

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> Sent: Thursday, June 18, 2015 3:19 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> queue information
> 
> Add the ability for the upper layer to query RX/TX queue information.
> Right now supported for:
> ixgbe, i40e, e1000 PMDs.
> 
> Konstantin Ananyev (5):
>   ethdev: add new API to retrieve RX/TX queue information
>   i40e: add support for eth_(rxq|txq)_info_get
>   ixgbe: add support for eth_(rxq|txq)_info_get
>   e1000: add support for eth_(rxq|txq)_info_get
>   testpmd: add new command to display RX/TX queue information
> 
>  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
>  app/test-pmd/config.c            | 67
> ++++++++++++++++++++++++++++++++++
>  app/test-pmd/testpmd.h           |  2 ++
>  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
>  drivers/net/e1000/em_ethdev.c    |  2 ++
>  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
>  drivers/net/e1000/igb_ethdev.c   |  4 +++
>  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.c   |  2 ++
>  drivers/net/i40e/i40e_ethdev.h   |  5 +++
>  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
>  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
>  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
>  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.h    | 77
> +++++++++++++++++++++++++++++++++++++++-
>  16 files changed, 440 insertions(+), 1 deletion(-)
> 
> --
> 1.8.5.3
  
Bruce Richardson June 18, 2015, 1:39 p.m. UTC | #3
On Thu, Jun 18, 2015 at 01:30:33PM +0000, Walukiewicz, Miroslaw wrote:
> Konstantin, 
> 
> Is there a possibility to read information about available space in NIC queue for TX.
> 
> It is quite easy to compute (or even available directly)  and very useful especially for application sending multi-descriptor packets like TCP TSO. 
> 
> Now there is no access to such information and the transmit packet function must be called to 
> be sure that there is available space.
> 
> Mirek
> 

Hi Mirek,

I'm not sure this function is the right place for such a query. It seems that
a function like you require needs to be used on the datapath, while this API
is not planned to be high-performance. I think that it might be better to
add an equivalent function to the existing RX descriptor querying function.

/Bruce

> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> > Sent: Thursday, June 18, 2015 3:19 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > queue information
> > 
> > Add the ability for the upper layer to query RX/TX queue information.
> > Right now supported for:
> > ixgbe, i40e, e1000 PMDs.
> > 
> > Konstantin Ananyev (5):
> >   ethdev: add new API to retrieve RX/TX queue information
> >   i40e: add support for eth_(rxq|txq)_info_get
> >   ixgbe: add support for eth_(rxq|txq)_info_get
> >   e1000: add support for eth_(rxq|txq)_info_get
> >   testpmd: add new command to display RX/TX queue information
> > 
> >  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
> >  app/test-pmd/config.c            | 67
> > ++++++++++++++++++++++++++++++++++
> >  app/test-pmd/testpmd.h           |  2 ++
> >  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
> >  drivers/net/e1000/em_ethdev.c    |  2 ++
> >  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
> >  drivers/net/e1000/igb_ethdev.c   |  4 +++
> >  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
> >  drivers/net/i40e/i40e_ethdev.c   |  2 ++
> >  drivers/net/i40e/i40e_ethdev.h   |  5 +++
> >  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
> >  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> >  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
> >  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
> >  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
> >  lib/librte_ether/rte_ethdev.h    | 77
> > +++++++++++++++++++++++++++++++++++++++-
> >  16 files changed, 440 insertions(+), 1 deletion(-)
> > 
> > --
> > 1.8.5.3
>
  
miroslaw.walukiewicz@intel.com June 18, 2015, 1:56 p.m. UTC | #4
Yes, really I need a high performance function - it is especially useful on TX path.

Which queue query function are you talking here to be enhanced?

Mirek

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Thursday, June 18, 2015 3:39 PM
> To: Walukiewicz, Miroslaw
> Cc: Ananyev, Konstantin; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> queue information
> 
> On Thu, Jun 18, 2015 at 01:30:33PM +0000, Walukiewicz, Miroslaw wrote:
> > Konstantin,
> >
> > Is there a possibility to read information about available space in NIC queue
> for TX.
> >
> > It is quite easy to compute (or even available directly)  and very useful
> especially for application sending multi-descriptor packets like TCP TSO.
> >
> > Now there is no access to such information and the transmit packet function
> must be called to
> > be sure that there is available space.
> >
> > Mirek
> >
> 
> Hi Mirek,
> 
> I'm not sure this function is the right place for such a query. It seems that
> a function like you require needs to be used on the datapath, while this API
> is not planned to be high-performance. I think that it might be better to
> add an equivalent function to the existing RX descriptor querying function.
> 
> /Bruce
> 
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin
> Ananyev
> > > Sent: Thursday, June 18, 2015 3:19 PM
> > > To: dev@dpdk.org
> > > Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > > queue information
> > >
> > > Add the ability for the upper layer to query RX/TX queue information.
> > > Right now supported for:
> > > ixgbe, i40e, e1000 PMDs.
> > >
> > > Konstantin Ananyev (5):
> > >   ethdev: add new API to retrieve RX/TX queue information
> > >   i40e: add support for eth_(rxq|txq)_info_get
> > >   ixgbe: add support for eth_(rxq|txq)_info_get
> > >   e1000: add support for eth_(rxq|txq)_info_get
> > >   testpmd: add new command to display RX/TX queue information
> > >
> > >  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
> > >  app/test-pmd/config.c            | 67
> > > ++++++++++++++++++++++++++++++++++
> > >  app/test-pmd/testpmd.h           |  2 ++
> > >  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
> > >  drivers/net/e1000/em_ethdev.c    |  2 ++
> > >  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
> > >  drivers/net/e1000/igb_ethdev.c   |  4 +++
> > >  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
> > >  drivers/net/i40e/i40e_ethdev.c   |  2 ++
> > >  drivers/net/i40e/i40e_ethdev.h   |  5 +++
> > >  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
> > >  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> > >  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
> > >  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
> > >  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
> > >  lib/librte_ether/rte_ethdev.h    | 77
> > > +++++++++++++++++++++++++++++++++++++++-
> > >  16 files changed, 440 insertions(+), 1 deletion(-)
> > >
> > > --
> > > 1.8.5.3
> >
  
Bruce Richardson June 18, 2015, 1:58 p.m. UTC | #5
On Thu, Jun 18, 2015 at 02:18:43PM +0100, Konstantin Ananyev wrote:
> Add the ability for the upper layer to query RX/TX queue information.
> Right now supported for:
> ixgbe, i40e, e1000 PMDs.
> 
> Konstantin Ananyev (5):
>   ethdev: add new API to retrieve RX/TX queue information
>   i40e: add support for eth_(rxq|txq)_info_get
>   ixgbe: add support for eth_(rxq|txq)_info_get
>   e1000: add support for eth_(rxq|txq)_info_get
>   testpmd: add new command to display RX/TX queue information
> 
>  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
>  app/test-pmd/config.c            | 67 ++++++++++++++++++++++++++++++++++
>  app/test-pmd/testpmd.h           |  2 ++
>  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
>  drivers/net/e1000/em_ethdev.c    |  2 ++
>  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
>  drivers/net/e1000/igb_ethdev.c   |  4 +++
>  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.c   |  2 ++
>  drivers/net/i40e/i40e_ethdev.h   |  5 +++
>  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
>  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
>  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
>  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.h    | 77 +++++++++++++++++++++++++++++++++++++++-
>  16 files changed, 440 insertions(+), 1 deletion(-)
> 
> -- 
> 1.8.5.3
> 
Series Acked-by: Bruce Richardson <bruce.richardson@intel.com>

BTW: I'm sure there are plenty of possible suggestions for extensions to these 
functions, but rather than constantly doing new versions to keep adding things
in, can we get the base functionality applied and add in the new info later -
as separate patches? There is space in the structs for more info without 
affecting the ABI.

Regards,
/Bruce
  
Bruce Richardson June 18, 2015, 2:13 p.m. UTC | #6
On Thu, Jun 18, 2015 at 02:56:52PM +0100, Walukiewicz, Miroslaw wrote:
> Yes, really I need a high performance function - it is especially useful on TX path.
> 
> Which queue query function are you talking here to be enhanced?
> 

There are already functions for querying the RX queue - so as to enable power
management/frequency scaling.

rte_eth_rx_queue_count()
rte_eth_rX_descriptor_done()

You could write equivalents for the TX side that only do the minimum needed.
Descriptor-done is probably the simplest and most useful for you, as in you can
query if you have enough space for a single operation, rather than having the
code scan arbitrarily far ahead.

/Bruce

> Mirek
> 
> > -----Original Message-----
> > From: Richardson, Bruce
> > Sent: Thursday, June 18, 2015 3:39 PM
> > To: Walukiewicz, Miroslaw
> > Cc: Ananyev, Konstantin; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > queue information
> > 
> > On Thu, Jun 18, 2015 at 01:30:33PM +0000, Walukiewicz, Miroslaw wrote:
> > > Konstantin,
> > >
> > > Is there a possibility to read information about available space in NIC queue
> > for TX.
> > >
> > > It is quite easy to compute (or even available directly)  and very useful
> > especially for application sending multi-descriptor packets like TCP TSO.
> > >
> > > Now there is no access to such information and the transmit packet function
> > must be called to
> > > be sure that there is available space.
> > >
> > > Mirek
> > >
> > 
> > Hi Mirek,
> > 
> > I'm not sure this function is the right place for such a query. It seems that
> > a function like you require needs to be used on the datapath, while this API
> > is not planned to be high-performance. I think that it might be better to
> > add an equivalent function to the existing RX descriptor querying function.
> > 
> > /Bruce
> > 
> > > > -----Original Message-----
> > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin
> > Ananyev
> > > > Sent: Thursday, June 18, 2015 3:19 PM
> > > > To: dev@dpdk.org
> > > > Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > > > queue information
> > > >
> > > > Add the ability for the upper layer to query RX/TX queue information.
> > > > Right now supported for:
> > > > ixgbe, i40e, e1000 PMDs.
> > > >
> > > > Konstantin Ananyev (5):
> > > >   ethdev: add new API to retrieve RX/TX queue information
> > > >   i40e: add support for eth_(rxq|txq)_info_get
> > > >   ixgbe: add support for eth_(rxq|txq)_info_get
> > > >   e1000: add support for eth_(rxq|txq)_info_get
> > > >   testpmd: add new command to display RX/TX queue information
> > > >
> > > >  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
> > > >  app/test-pmd/config.c            | 67
> > > > ++++++++++++++++++++++++++++++++++
> > > >  app/test-pmd/testpmd.h           |  2 ++
> > > >  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
> > > >  drivers/net/e1000/em_ethdev.c    |  2 ++
> > > >  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
> > > >  drivers/net/e1000/igb_ethdev.c   |  4 +++
> > > >  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
> > > >  drivers/net/i40e/i40e_ethdev.c   |  2 ++
> > > >  drivers/net/i40e/i40e_ethdev.h   |  5 +++
> > > >  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
> > > >  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> > > >  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
> > > >  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
> > > >  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
> > > >  lib/librte_ether/rte_ethdev.h    | 77
> > > > +++++++++++++++++++++++++++++++++++++++-
> > > >  16 files changed, 440 insertions(+), 1 deletion(-)
> > > >
> > > > --
> > > > 1.8.5.3
> > >
  
Ananyev, Konstantin June 18, 2015, 2:17 p.m. UTC | #7
Hi Mirek,

> -----Original Message-----
> From: Walukiewicz, Miroslaw
> Sent: Thursday, June 18, 2015 2:31 PM
> To: Ananyev, Konstantin; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX queue information
> 
> Konstantin,
> 
> Is there a possibility to read information about available space in NIC queue for TX.

I suppose it is possible as some future addition.
As I said in the commit message, I left some reserved space, so extra fields could be added to the structure without ABI breakage.
For now, I just added some static/config information for the queue, but I think it is possible and plausible to have some runtime information too.

> 
> It is quite easy to compute (or even available directly)  and very useful especially for application sending multi-descriptor packets like
> TCP TSO.
> 
> Now there is no access to such information and the transmit packet function must be called to
> be sure that there is available space.

Hmm, as I said I was thinking about adding some RT information in future:
number of free descriptors (from SW point of view), index of next descriptor to process by SW, etc.
But my thought it would be use by some watchdog thread to collect statistics/detect stall, etc.
I didn't intend it to be used by IO thread. 

I am not sure why do you need to call such function at RT?
PMD wouldn't TX a packet, if there is not enough free TXDs for the whole packet.
From other side upper layer, can't always calculate correctly how many TXD it would really need
(context descriptors might be needed, etc).
 Plus, even if nb_tx_free==X, in reality it could be there much more free TXDs, and SW just need
to process them (and would do that at next  tx_burst() call.
So, why just not:
...
n = tx_burst(..., nb_tx);
if (n < nb_tx) {requeue unsent of packets;}
?

Konstantin

> 
> Mirek
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> > Sent: Thursday, June 18, 2015 3:19 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > queue information
> >
> > Add the ability for the upper layer to query RX/TX queue information.
> > Right now supported for:
> > ixgbe, i40e, e1000 PMDs.
> >
> > Konstantin Ananyev (5):
> >   ethdev: add new API to retrieve RX/TX queue information
> >   i40e: add support for eth_(rxq|txq)_info_get
> >   ixgbe: add support for eth_(rxq|txq)_info_get
> >   e1000: add support for eth_(rxq|txq)_info_get
> >   testpmd: add new command to display RX/TX queue information
> >
> >  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
> >  app/test-pmd/config.c            | 67
> > ++++++++++++++++++++++++++++++++++
> >  app/test-pmd/testpmd.h           |  2 ++
> >  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
> >  drivers/net/e1000/em_ethdev.c    |  2 ++
> >  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
> >  drivers/net/e1000/igb_ethdev.c   |  4 +++
> >  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
> >  drivers/net/i40e/i40e_ethdev.c   |  2 ++
> >  drivers/net/i40e/i40e_ethdev.h   |  5 +++
> >  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
> >  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> >  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
> >  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
> >  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
> >  lib/librte_ether/rte_ethdev.h    | 77
> > +++++++++++++++++++++++++++++++++++++++-
> >  16 files changed, 440 insertions(+), 1 deletion(-)
> >
> > --
> > 1.8.5.3
  
miroslaw.walukiewicz@intel.com June 18, 2015, 2:37 p.m. UTC | #8
> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Thursday, June 18, 2015 4:17 PM
> To: Walukiewicz, Miroslaw; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> queue information
> 
> Hi Mirek,
> 
> > -----Original Message-----
> > From: Walukiewicz, Miroslaw
> > Sent: Thursday, June 18, 2015 2:31 PM
> > To: Ananyev, Konstantin; dev@dpdk.org
> > Subject: RE: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve
> RX/TX queue information
> >
> > Konstantin,
> >
> > Is there a possibility to read information about available space in NIC queue
> for TX.
> 
> I suppose it is possible as some future addition.
> As I said in the commit message, I left some reserved space, so extra fields
> could be added to the structure without ABI breakage.
> For now, I just added some static/config information for the queue, but I think
> it is possible and plausible to have some runtime information too.
> 
> >
> > It is quite easy to compute (or even available directly)  and very useful
> especially for application sending multi-descriptor packets like
> > TCP TSO.
> >
> > Now there is no access to such information and the transmit packet function
> must be called to
> > be sure that there is available space.
> 
> Hmm, as I said I was thinking about adding some RT information in future:
> number of free descriptors (from SW point of view), index of next descriptor
> to process by SW, etc.
> But my thought it would be use by some watchdog thread to collect
> statistics/detect stall, etc.
> I didn't intend it to be used by IO thread.
> 
> I am not sure why do you need to call such function at RT?
> PMD wouldn't TX a packet, if there is not enough free TXDs for the whole
> packet.
> From other side upper layer, can't always calculate correctly how many TXD it
> would really need
> (context descriptors might be needed, etc).
>  Plus, even if nb_tx_free==X, in reality it could be there much more free
> TXDs, and SW just need
> to process them (and would do that at next  tx_burst() call.
> So, why just not:
> ...
> n = tx_burst(..., nb_tx);
> if (n < nb_tx) {requeue unsent of packets;}
> ?
> 
The case is TCP TSO operation as I said.

I really use the that method proposed by you but it very expensive way.

The TX path in TCP is very complex and expensive. 
It is desirable to create the TCP TSO segments that fits the space in queue to avoid re-queue  of packets 
making the TX path much more complex. 
For ixgbe the TSO segments are up to 40 descriptors (max 64K of data) and making the TX queue full is just simple.

Having the possibility for reading number of descriptors available to send can improve TCP TX process in the way 
that when there is no space in TX queue we can just not enter the complex TX path and spent time making more 
useful job than re-queue.
Also It is easy to fit the TSO segment to available space in TX queue instead of sending always a large 64K TCP segments 
and count on the result of tx_burst and re-queue in case of lack of space.

Mirek

> Konstantin
> 
> >
> > Mirek
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin
> Ananyev
> > > Sent: Thursday, June 18, 2015 3:19 PM
> > > To: dev@dpdk.org
> > > Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> > > queue information
> > >
> > > Add the ability for the upper layer to query RX/TX queue information.
> > > Right now supported for:
> > > ixgbe, i40e, e1000 PMDs.
> > >
> > > Konstantin Ananyev (5):
> > >   ethdev: add new API to retrieve RX/TX queue information
> > >   i40e: add support for eth_(rxq|txq)_info_get
> > >   ixgbe: add support for eth_(rxq|txq)_info_get
> > >   e1000: add support for eth_(rxq|txq)_info_get
> > >   testpmd: add new command to display RX/TX queue information
> > >
> > >  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
> > >  app/test-pmd/config.c            | 67
> > > ++++++++++++++++++++++++++++++++++
> > >  app/test-pmd/testpmd.h           |  2 ++
> > >  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
> > >  drivers/net/e1000/em_ethdev.c    |  2 ++
> > >  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
> > >  drivers/net/e1000/igb_ethdev.c   |  4 +++
> > >  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
> > >  drivers/net/i40e/i40e_ethdev.c   |  2 ++
> > >  drivers/net/i40e/i40e_ethdev.h   |  5 +++
> > >  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
> > >  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> > >  drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
> > >  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
> > >  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
> > >  lib/librte_ether/rte_ethdev.h    | 77
> > > +++++++++++++++++++++++++++++++++++++++-
> > >  16 files changed, 440 insertions(+), 1 deletion(-)
> > >
> > > --
> > > 1.8.5.3
  
Zhang, Helin June 19, 2015, 3:18 a.m. UTC | #9
Acked-by: Helin Zhang <helin.zhang@intel.com>

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> Sent: Thursday, June 18, 2015 9:19 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX queue
> information
> 
> Add the ability for the upper layer to query RX/TX queue information.
> Right now supported for:
> ixgbe, i40e, e1000 PMDs.
> 
> Konstantin Ananyev (5):
>   ethdev: add new API to retrieve RX/TX queue information
>   i40e: add support for eth_(rxq|txq)_info_get
>   ixgbe: add support for eth_(rxq|txq)_info_get
>   e1000: add support for eth_(rxq|txq)_info_get
>   testpmd: add new command to display RX/TX queue information
> 
>  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
>  app/test-pmd/config.c            | 67
> ++++++++++++++++++++++++++++++++++
>  app/test-pmd/testpmd.h           |  2 ++
>  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
>  drivers/net/e1000/em_ethdev.c    |  2 ++
>  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
>  drivers/net/e1000/igb_ethdev.c   |  4 +++
>  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.c   |  2 ++
>  drivers/net/i40e/i40e_ethdev.h   |  5 +++
>  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
>  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
>  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.h    | 77
> +++++++++++++++++++++++++++++++++++++++-
>  16 files changed, 440 insertions(+), 1 deletion(-)
> 
> --
> 1.8.5.3
  
David Harton June 23, 2015, 12:35 p.m. UTC | #10
Acked-by: David Harton <dharton@cisco.com>


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> Sent: Thursday, June 18, 2015 9:19 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCHv2 0/5] ethdev: add new API to retrieve RX/TX
> queue information
> 
> Add the ability for the upper layer to query RX/TX queue information.
> Right now supported for:
> ixgbe, i40e, e1000 PMDs.
> 
> Konstantin Ananyev (5):
>   ethdev: add new API to retrieve RX/TX queue information
>   i40e: add support for eth_(rxq|txq)_info_get
>   ixgbe: add support for eth_(rxq|txq)_info_get
>   e1000: add support for eth_(rxq|txq)_info_get
>   testpmd: add new command to display RX/TX queue information
> 
>  app/test-pmd/cmdline.c           | 48 +++++++++++++++++++++++++
>  app/test-pmd/config.c            | 67 ++++++++++++++++++++++++++++++++++
>  app/test-pmd/testpmd.h           |  2 ++
>  drivers/net/e1000/e1000_ethdev.h | 12 +++++++
>  drivers/net/e1000/em_ethdev.c    |  2 ++
>  drivers/net/e1000/em_rxtx.c      | 38 ++++++++++++++++++++
>  drivers/net/e1000/igb_ethdev.c   |  4 +++
>  drivers/net/e1000/igb_rxtx.c     | 36 +++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.c   |  2 ++
>  drivers/net/i40e/i40e_ethdev.h   |  5 +++
>  drivers/net/i40e/i40e_rxtx.c     | 42 ++++++++++++++++++++++
>  drivers/net/ixgbe/ixgbe_ethdev.c |  4 +++
> drivers/net/ixgbe/ixgbe_ethdev.h |  6 ++++
>  drivers/net/ixgbe/ixgbe_rxtx.c   | 42 ++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.c    | 54 ++++++++++++++++++++++++++++
>  lib/librte_ether/rte_ethdev.h    | 77
> +++++++++++++++++++++++++++++++++++++++-
>  16 files changed, 440 insertions(+), 1 deletion(-)
> 
> --
> 1.8.5.3
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e13fde5..6b9a7ef 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3629,6 +3629,54 @@  rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
 }
 
 int
+rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+	struct rte_eth_rx_qinfo *qinfo)
+{
+	struct rte_eth_dev *dev;
+
+	memset(qinfo, 0, sizeof(*qinfo));
+
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_rx_queues) {
+		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return -EINVAL;
+	}
+
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_qinfo_get, -ENOTSUP);
+	dev->dev_ops->rx_qinfo_get(dev, queue_id, qinfo);
+	return 0;
+}
+
+int
+rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+	struct rte_eth_tx_qinfo *qinfo)
+{
+	struct rte_eth_dev *dev;
+
+	memset(qinfo, 0, sizeof(*qinfo));
+
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_tx_queues) {
+		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return -EINVAL;
+	}
+
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_qinfo_get, -ENOTSUP);
+	dev->dev_ops->tx_qinfo_get(dev, queue_id, qinfo);
+	return 0;
+}
+
+int
 rte_eth_dev_set_mc_addr_list(uint8_t port_id,
 			     struct ether_addr *mc_addr_set,
 			     uint32_t nb_mc_addr)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 04c192d..45afdd3 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -942,6 +942,30 @@  struct rte_eth_xstats {
 	uint64_t value;
 };
 
+/**
+ * Ethernet device RX queue information strcuture.
+ * Used to retieve information about configured queue.
+ */
+struct rte_eth_rx_qinfo {
+	struct rte_mempool *mp;     /**< mempool used by that queue. */
+	struct rte_eth_rxconf conf; /**< queue config parameters. */
+	uint8_t scattered_rx;       /**< scattered packets RX supported. */
+	uint16_t nb_desc;           /**< configured number of RXDs. */
+	uint16_t max_desc;          /**< max allowed number of RXDs. */
+	uint16_t min_desc;          /**< min allowed number of RXDs. */
+} __rte_cache_aligned;
+
+/**
+ * Ethernet device TX queue information strcuture.
+ * Used to retieve information about configured queue.
+ */
+struct rte_eth_tx_qinfo {
+	struct rte_eth_txconf conf; /**< queue config parameters. */
+	uint16_t nb_desc;           /**< configured number of TXDs. */
+	uint16_t max_desc;          /**< max allowed number of TXDs. */
+	uint16_t min_desc;          /**< min allowed number of TXDs. */
+} __rte_cache_aligned;
+
 struct rte_eth_dev;
 
 struct rte_eth_dev_callback;
@@ -1045,6 +1069,12 @@  typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @Check DD bit of specific RX descriptor */
 
+typedef void (*eth_rx_qinfo_get_t)(struct rte_eth_dev *dev,
+	uint16_t rx_queue_id, struct rte_eth_rx_qinfo *qinfo);
+
+typedef void (*eth_tx_qinfo_get_t)(struct rte_eth_dev *dev,
+	uint16_t tx_queue_id, struct rte_eth_tx_qinfo *qinfo);
+
 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
 /**< @internal Set MTU. */
 
@@ -1389,8 +1419,13 @@  struct eth_dev_ops {
 	rss_hash_update_t rss_hash_update;
 	/** Get current RSS hash configuration. */
 	rss_hash_conf_get_t rss_hash_conf_get;
-	eth_filter_ctrl_t              filter_ctrl;          /**< common filter control*/
+	eth_filter_ctrl_t              filter_ctrl;
+	/**< common filter control. */
 	eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs */
+	eth_rx_qinfo_get_t rx_qinfo_get;
+	/**< retrieve RX queue information. */
+	eth_tx_qinfo_get_t tx_qinfo_get;
+	/**< retrieve TX queue information. */
 };
 
 /**
@@ -3616,6 +3651,46 @@  int rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,
 int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
 		struct rte_eth_rxtx_callback *user_cb);
 
+/**
+ * Retrieve information about given port's RX queue.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param queue_id
+ *   The RX queue on the Ethernet device for which information
+ *   will be retrieved.
+ * @param qinfo
+ *   A pointer to a structure of type *rte_eth_rx_qinfo_info* to be filled with
+ *   the information of the Ethernet device.
+ *
+ * @return
+ *   - 0: Success
+ *   - -ENOTSUP: routine is not supported by the device PMD.
+ *   - -EINVAL:  The port_id or the queue_id is out of range.
+ */
+int rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+	struct rte_eth_rx_qinfo *qinfo);
+
+/**
+ * Retrieve information about given port's TX queue.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param queue_id
+ *   The TX queue on the Ethernet device for which information
+ *   will be retrieved.
+ * @param qinfo
+ *   A pointer to a structure of type *rte_eth_tx_qinfo_info* to be filled with
+ *   the information of the Ethernet device.
+ *
+ * @return
+ *   - 0: Success
+ *   - -ENOTSUP: routine is not supported by the device PMD.
+ *   - -EINVAL:  The port_id or the queue_id is out of range.
+ */
+int rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+	struct rte_eth_tx_qinfo *qinfo);
+
 #ifdef __cplusplus
 }
 #endif