From: Pablo de Lara Date: Wed, 1 Oct 2014 09:49:04 +0000 (+0100) Subject: ethdev: get default Rx/Tx configuration from dev info X-Git-Tag: spdx-start~10313 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fbde27f19ab8;p=dpdk.git ethdev: get default Rx/Tx configuration from dev info 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 Reviewed-by: Bruce Richardson Acked-by: David Marchand [Thomas: split patch] --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 6c657cf116..1659340943 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1022,6 +1022,9 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, return (-EINVAL); } + if (rx_conf == NULL) + rx_conf = &dev_info.default_rxconf; + ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, socket_id, rx_conf, mp); if (!ret) { @@ -1039,6 +1042,7 @@ 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; /* This function is only safe when called from the primary process * in a multi-process setup*/ @@ -1060,7 +1064,14 @@ 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); + + if (tx_conf == NULL) + tx_conf = &dev_info.default_txconf; + return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc, socket_id, tx_conf); } diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 3f79cc36ba..13be711d5c 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 */ }; /** Maximum name length for extended statistics counters */ @@ -1717,6 +1719,8 @@ extern int rte_eth_dev_configure(uint8_t port_id, * the DMA memory allocated for the receive descriptors of the ring. * @param rx_conf * The pointer to the configuration data to be used for the receive queue. + * NULL value is allowed, in which case default RX configuration + * will be used. * The *rx_conf* structure contains an *rx_thresh* structure with the values * of the Prefetch, Host, and Write-Back threshold registers of the receive * ring. @@ -1754,6 +1758,8 @@ extern int rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, * the DMA memory allocated for the transmit descriptors of the ring. * @param tx_conf * The pointer to the configuration data to be used for the transmit queue. + * NULL value is allowed, in which case default RX configuration + * will be used. * The *tx_conf* structure contains the following data: * - The *tx_thresh* structure with the values of the Prefetch, Host, and * Write-Back threshold registers of the transmit ring.