[dpdk-dev] [PATCH 2/3] ethdev: Add in data rxtx callback support
Neil Horman
nhorman at tuxdriver.com
Thu Feb 12 22:12:15 CET 2015
On Thu, Feb 12, 2015 at 07:57:56PM +0000, John McNamara wrote:
> From: Richardson, Bruce <bruce.richardson at intel.com>
>
> Add in support for inline processing of packets inside the RX or
> TX call. For an RX callback, what happens is that we get a set of
> packets from the NIC and then pass them to a callback function, if
> configured, to allow additional processing to be done on them, e.g.
> filling in more mbuf fields, before passing back to the application.
> On TX, the packets are similarly post-processed before being handed
> to the NIC for transmission.
>
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
> lib/librte_ether/rte_ethdev.c | 165 +++++++++++++++++++++++++++++++++++++-
> lib/librte_ether/rte_ethdev.h | 175 ++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 334 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e4b3315..944737e 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -337,6 +337,15 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
> dev->data->nb_rx_queues = 0;
> return -(ENOMEM);
> }
> + dev->rx_cbs = rte_zmalloc("ethdev->rx_cbs",
> + sizeof(*dev->rx_cbs) * nb_queues,
> + RTE_CACHE_LINE_SIZE);
> + if (dev->rx_cbs == NULL) {
> + rte_free(dev->data->rx_queues);
> + dev->data->rx_queues = NULL;
> + dev->data->nb_rx_queues = 0;
> + return -(ENOMEM);
> + }
> } else { /* re-configure */
> FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
>
> @@ -348,10 +357,18 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
> RTE_CACHE_LINE_SIZE);
> if (rxq == NULL)
> return -(ENOMEM);
> + dev->rx_cbs = rte_realloc(dev->rx_cbs, sizeof(*dev->rx_cbs) *
> + nb_queues, RTE_CACHE_LINE_SIZE);
> + if (dev->rx_cbs == NULL)
> + return -(ENOMEM);
>
> - if (nb_queues > old_nb_queues)
> + if (nb_queues > old_nb_queues) {
> + uint16_t new_qs = nb_queues - old_nb_queues;
> memset(rxq + old_nb_queues, 0,
> - sizeof(rxq[0]) * (nb_queues - old_nb_queues));
> + sizeof(rxq[0]) * new_qs);
> + memset(dev->rx_cbs + old_nb_queues, 0,
> + sizeof(dev->rx_cbs[0]) * new_qs);
> + }
>
> dev->data->rx_queues = rxq;
>
> @@ -479,6 +496,15 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
> dev->data->nb_tx_queues = 0;
> return -(ENOMEM);
> }
> + dev->tx_cbs = rte_zmalloc("ethdev->tx_cbs",
> + sizeof(*dev->tx_cbs) * nb_queues,
> + RTE_CACHE_LINE_SIZE);
> + if (dev->tx_cbs == NULL) {
> + rte_free(dev->data->tx_queues);
> + dev->data->tx_queues = NULL;
> + dev->data->nb_tx_queues = 0;
> + return -(ENOMEM);
> + }
> } else { /* re-configure */
> FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
>
> @@ -490,10 +516,19 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
> RTE_CACHE_LINE_SIZE);
> if (txq == NULL)
> return -(ENOMEM);
> + dev->tx_cbs = rte_realloc(dev->tx_cbs, sizeof(*dev->tx_cbs) *
> + nb_queues, RTE_CACHE_LINE_SIZE);
> + if (dev->tx_cbs == NULL)
> + return -(ENOMEM);
> +
>
> - if (nb_queues > old_nb_queues)
> + if (nb_queues > old_nb_queues) {
> + uint16_t new_qs = nb_queues - old_nb_queues;
> memset(txq + old_nb_queues, 0,
> - sizeof(txq[0]) * (nb_queues - old_nb_queues));
> + sizeof(txq[0]) * new_qs);
> + memset(dev->tx_cbs + old_nb_queues, 0,
> + sizeof(dev->tx_cbs[0]) * new_qs);
> + }
>
> dev->data->tx_queues = txq;
>
> @@ -3253,3 +3288,125 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
> FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
> return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
> }
> +
> +void *
> +rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> + rte_rxtx_callback_fn fn, void *user_param)
> +{
These, and its companion manipulator functions need to be added to the ABI
versioning scripts. As it currently stands this won't be exposed in a shared
build, and so the examples won't build.
Neil
More information about the dev
mailing list