[dpdk-dev] [PATCH v2 1/2] pmd: Modified dev_info structure to include default RX/TX configuration

Bruce Richardson bruce.richardson at intel.com
Wed Oct 1 10:38:53 CEST 2014


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

One very minor nit -  I don't think you need the new local variable conf.  
You can just check "if (rx_conf == NULL) rx_conf = &dev...". The same for 
the tx_conf too.

/Bruce

 


More information about the dev mailing list