DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2 1/2] pmd: Modified dev_info structure to include default RX/TX configuration
Date: Wed, 1 Oct 2014 09:42:56 +0100	[thread overview]
Message-ID: <20141001084255.GB1204@BRICHA3-MOBL> (raw)
In-Reply-To: <1412150458-26213-2-git-send-email-pablo.de.lara.guarch@intel.com>

On Wed, Oct 01, 2014 at 09:00:57AM +0100, Pablo de Lara wrote:
> Many sample apps use duplicated code to set rte_eth_txconf and rte_eth_rxconf
> structures. This patch allows the user to get a default optimal RX/TX configuration
> through rte_eth_dev_info get, and still any parameters may be tweaked as wished,
> before setting up queues.
> 
> Besides, if a NULL pointer is passed to rte_eth_rx_queue_setup or
> rte_eth_tx_queue_setup, these functions get internally the default RX/TX
> configuration for the user.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c       |   28 +++++++++++++++++++++-----
>  lib/librte_ether/rte_ethdev.h       |    2 +
>  lib/librte_pmd_e1000/igb_ethdev.c   |   32 ++++++++++++++++++++++++++++++-
>  lib/librte_pmd_i40e/i40e_ethdev.c   |   33 ++++++++++++++++++++++++++++++++
>  lib/librte_pmd_ixgbe/ixgbe_ethdev.c |   36 +++++++++++++++++++++++++++++++++++
>  5 files changed, 124 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index fd1010a..2f9eea2 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -928,6 +928,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
>  	struct rte_eth_dev *dev;
>  	struct rte_pktmbuf_pool_private *mbp_priv;
>  	struct rte_eth_dev_info dev_info;
> +	const struct rte_eth_rxconf *conf;
>  
>  	/* This function is only safe when called from the primary process
>  	 * in a multi-process setup*/
> @@ -937,6 +938,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
>  		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>  		return (-EINVAL);
>  	}
> +
>  	dev = &rte_eth_devices[port_id];
>  	if (rx_queue_id >= dev->data->nb_rx_queues) {
>  		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
> @@ -980,8 +982,12 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
>  		return (-EINVAL);
>  	}
>  
> +	conf = rx_conf;
> +	if (conf == NULL)
> +		conf = &dev_info.default_rxconf;
> +
>  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
> -					      socket_id, rx_conf, mp);
> +					      socket_id, conf, mp);
>  	if (!ret) {
>  		if (!dev->data->min_rx_buf_size ||
>  		    dev->data->min_rx_buf_size > mbp_buf_size)
> @@ -997,6 +1003,8 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
>  		       const struct rte_eth_txconf *tx_conf)
>  {
>  	struct rte_eth_dev *dev;
> +	struct rte_eth_dev_info dev_info;
> +	const struct rte_eth_txconf *conf;
>  
>  	/* This function is only safe when called from the primary process
>  	 * in a multi-process setup*/
> @@ -1006,6 +1014,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
>  		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>  		return (-EINVAL);
>  	}
> +
>  	dev = &rte_eth_devices[port_id];
>  	if (tx_queue_id >= dev->data->nb_tx_queues) {
>  		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
> @@ -1018,9 +1027,17 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
>  		return -EBUSY;
>  	}
>  
> +	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
>  	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
> +
> +	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
> +
> +	conf = tx_conf;
> +	if (conf == NULL)
> +		conf = &dev_info.default_txconf;
> +
>  	return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc,
> -					       socket_id, tx_conf);
> +					       socket_id, conf);
>  }
>  
>  void
> @@ -1249,10 +1266,9 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
>  	}
>  	dev = &rte_eth_devices[port_id];
>  
> -	/* Default device offload capabilities to zero */
> -	dev_info->rx_offload_capa = 0;
> -	dev_info->tx_offload_capa = 0;
> -	dev_info->if_index = 0;
> +	/* Reset dev info structure */
> +	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
> +
>  	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
>  	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
>  	dev_info->pci_dev = dev->pci_dev;
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 50df654..f63d38a 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -906,6 +906,8 @@ struct rte_eth_dev_info {
>  	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
>  	uint32_t rx_offload_capa; /**< Device RX offload capabilities. */
>  	uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
> +	struct rte_eth_rxconf default_rxconf; /**< Default RX configuration */
> +	struct rte_eth_txconf default_txconf; /**< Default TX configuration */
>  };
>  
>  struct rte_eth_dev;

In this file (rte_ethdev.h), you also need to update the API documentation 
for the rte_eth_rx_queue_setup and rte_eth_tx_queue_setup functions to state 
that passing in a NULL value for the conf parameter is allowed, and that it 
just means to use the defaults.

/Bruce

  parent reply	other threads:[~2014-10-01  8:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 14:19 [dpdk-dev] [PATCH 0/2] Added functions to get RX/TX default configuration Pablo de Lara
2014-09-26 14:19 ` [dpdk-dev] [PATCH 1/2] pmd: Added rte_eth_rxconf_defaults and rte_eth_txconf defaults functions Pablo de Lara
2014-09-26 14:19 ` [dpdk-dev] [PATCH 2/2] app: Used rte_eth_rxconf_defaults and rte_eth_txconf_defaults in apps Pablo de Lara
2014-09-27 18:45 ` [dpdk-dev] [PATCH 0/2] Added functions to get RX/TX default configuration David Marchand
     [not found]   ` <E115CCD9D858EF4F90C690B0DCB4D89722628264@IRSMSX108.ger.corp.intel.com>
2014-09-29 14:02     ` De Lara Guarch, Pablo
2014-09-29 14:40       ` David Marchand
2014-10-01  8:00 ` [dpdk-dev] [PATCH v2 0/2] Get default RX/TX configuration Pablo de Lara
2014-10-01  8:00   ` [dpdk-dev] [PATCH v2 1/2] pmd: Modified dev_info structure to include " Pablo de Lara
2014-10-01  8:38     ` Bruce Richardson
2014-10-01  8:42     ` Bruce Richardson [this message]
2014-10-01  8:45     ` David Marchand
2014-10-01  8:00   ` [dpdk-dev] [PATCH v2 2/2] app: Used default RX/TX configuration got from dev info in apps Pablo de Lara
2014-10-01  9:49   ` [dpdk-dev] [PATCH v3 0/3] Get default RX/TX configuration Pablo de Lara
2014-10-01  9:49     ` [dpdk-dev] [PATCH v3 1/3] ether: Reset whole dev info structure Pablo de Lara
2014-10-10 11:08       ` Thomas Monjalon
2014-10-01  9:49     ` [dpdk-dev] [PATCH v3 2/3] pmd: Modified dev_info structure to include default RX/TX configuration Pablo de Lara
2014-10-10 11:14       ` Thomas Monjalon
2014-10-10 12:05         ` De Lara Guarch, Pablo
2014-10-01  9:49     ` [dpdk-dev] [PATCH v3 3/3] app: Used default RX/TX configuration got from dev info in apps Pablo de Lara
2014-10-10 11:20       ` Thomas Monjalon
2014-10-10 12:07         ` De Lara Guarch, Pablo
2014-10-01  9:54     ` [dpdk-dev] [PATCH v3 0/3] Get default RX/TX configuration De Lara Guarch, Pablo
2014-10-02 10:18       ` David Marchand
2014-10-10 12:48         ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141001084255.GB1204@BRICHA3-MOBL \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).