From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id D3BAA9AC7 for ; Thu, 12 Feb 2015 22:12:29 +0100 (CET) Received: from [67.210.173.2] (helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1YM13f-0003nJ-Re; Thu, 12 Feb 2015 16:12:26 -0500 Date: Thu, 12 Feb 2015 16:12:15 -0500 From: Neil Horman To: John McNamara Message-ID: <20150212211215.GA5920@neilslaptop.think-freely.org> References: <1419266844-4848-1-git-send-email-bruce.richardson@intel.com> <1423771077-13665-1-git-send-email-john.mcnamara@intel.com> <1423771077-13665-3-git-send-email-john.mcnamara@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1423771077-13665-3-git-send-email-john.mcnamara@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 2/3] ethdev: Add in data rxtx callback support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2015 21:12:30 -0000 On Thu, Feb 12, 2015 at 07:57:56PM +0000, John McNamara wrote: > From: Richardson, Bruce > > 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 > --- > 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