From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DA6512BB3 for ; Tue, 6 Dec 2016 18:17:28 +0100 (CET) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP; 06 Dec 2016 09:17:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="39568721" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.64]) by fmsmga005.fm.intel.com with SMTP; 06 Dec 2016 09:17:13 -0800 Received: by (sSMTP sendmail emulation); Tue, 06 Dec 2016 17:17:12 +0000 Date: Tue, 6 Dec 2016 17:17:12 +0000 From: Bruce Richardson To: Jerin Jacob Cc: dev@dpdk.org, thomas.monjalon@6wind.com, hemant.agrawal@nxp.com, gage.eads@intel.com, harry.van.haaren@intel.com Message-ID: <20161206171712.GC22224@bricha3-MOBL3.ger.corp.intel.com> References: <1479447902-3700-2-git-send-email-jerin.jacob@caviumnetworks.com> <1480996340-29871-1-git-send-email-jerin.jacob@caviumnetworks.com> <1480996340-29871-4-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480996340-29871-4-git-send-email-jerin.jacob@caviumnetworks.com> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.7.1 (2016-10-04) Subject: Re: [dpdk-dev] [PATCH v2 3/6] eventdev: implement the northbound APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 17:17:30 -0000 On Tue, Dec 06, 2016 at 09:22:17AM +0530, Jerin Jacob wrote: > This patch implements northbound eventdev API interface using > southbond driver interface > > Signed-off-by: Jerin Jacob > --- > config/common_base | 6 + > lib/Makefile | 1 + > lib/librte_eal/common/include/rte_log.h | 1 + > lib/librte_eventdev/Makefile | 57 ++ > lib/librte_eventdev/rte_eventdev.c | 1001 ++++++++++++++++++++++++++ > lib/librte_eventdev/rte_eventdev.h | 108 ++- > lib/librte_eventdev/rte_eventdev_pmd.h | 109 +++ > lib/librte_eventdev/rte_eventdev_version.map | 33 + > mk/rte.app.mk | 1 + > 9 files changed, 1311 insertions(+), 6 deletions(-) > create mode 100644 lib/librte_eventdev/Makefile > create mode 100644 lib/librte_eventdev/rte_eventdev.c > create mode 100644 lib/librte_eventdev/rte_eventdev_version.map > > + > +static inline int > +rte_event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues) > +{ > + uint8_t old_nb_queues = dev->data->nb_queues; > + void **queues; > + uint8_t *queues_prio; > + unsigned int i; > + > + RTE_EDEV_LOG_DEBUG("Setup %d queues on device %u", nb_queues, > + dev->data->dev_id); > + > + /* First time configuration */ > + if (dev->data->queues == NULL && nb_queues != 0) { > + dev->data->queues = rte_zmalloc_socket("eventdev->data->queues", > + sizeof(dev->data->queues[0]) * nb_queues, > + RTE_CACHE_LINE_SIZE, dev->data->socket_id); > + if (dev->data->queues == NULL) { > + dev->data->nb_queues = 0; > + RTE_EDEV_LOG_ERR("failed to get memory for queue meta," > + "nb_queues %u", nb_queues); > + return -(ENOMEM); > + } > + /* Allocate memory to store queue priority */ > + dev->data->queues_prio = rte_zmalloc_socket( > + "eventdev->data->queues_prio", > + sizeof(dev->data->queues_prio[0]) * nb_queues, > + RTE_CACHE_LINE_SIZE, dev->data->socket_id); > + if (dev->data->queues_prio == NULL) { > + dev->data->nb_queues = 0; > + RTE_EDEV_LOG_ERR("failed to get mem for queue priority," > + "nb_queues %u", nb_queues); > + return -(ENOMEM); > + } > + > + } else if (dev->data->queues != NULL && nb_queues != 0) {/* re-config */ > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP); > + > + queues = dev->data->queues; > + for (i = nb_queues; i < old_nb_queues; i++) > + (*dev->dev_ops->queue_release)(queues[i]); > + > + queues = rte_realloc(queues, sizeof(queues[0]) * nb_queues, > + RTE_CACHE_LINE_SIZE); > + if (queues == NULL) { > + RTE_EDEV_LOG_ERR("failed to realloc queue meta data," > + " nb_queues %u", nb_queues); > + return -(ENOMEM); > + } > + dev->data->queues = queues; > + > + /* Re allocate memory to store queue priority */ > + queues_prio = dev->data->queues_prio; > + queues_prio = rte_realloc(queues_prio, > + sizeof(queues_prio[0]) * nb_queues, > + RTE_CACHE_LINE_SIZE); > + if (queues_prio == NULL) { > + RTE_EDEV_LOG_ERR("failed to realloc queue priority," > + " nb_queues %u", nb_queues); > + return -(ENOMEM); > + } > + dev->data->queues_prio = queues_prio; > + > + if (nb_queues > old_nb_queues) { > + uint8_t new_qs = nb_queues - old_nb_queues; > + > + memset(queues + old_nb_queues, 0, > + sizeof(queues[0]) * new_qs); > + memset(queues_prio + old_nb_queues, 0, > + sizeof(queues_prio[0]) * new_qs); > + } > + } else if (dev->data->queues != NULL && nb_queues == 0) { > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP); > + > + queues = dev->data->queues; > + for (i = nb_queues; i < old_nb_queues; i++) > + (*dev->dev_ops->queue_release)(queues[i]); > + } > + > + dev->data->nb_queues = nb_queues; > + return 0; > +} > + While the ports array makes sense to have available at the top level of the API and allocated from rte_eventdev.c, I'm not seeing what the value of having the queues allocated at that level is. The only time the queue array is indexed by eventdev layer is when releasing a queue. Therefore, I suggest just saving the number of queues for sanity checking and let the queue array allocation and freeing be handled entirely in the drivers themselves. /Bruce