From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7C93A052B; Thu, 30 Jul 2020 21:57:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 847391C1CB; Thu, 30 Jul 2020 21:54:03 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 379181C0CD for ; Thu, 30 Jul 2020 21:53:23 +0200 (CEST) IronPort-SDR: oTxS8j2AujjfQue6doTe737KLxWY2GsfpjlxfDIoUFq0R7KCE/C7Bj+I2CPRtfzl2vsdzyTBpq QsIspigYuGvw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="139672349" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="139672349" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 12:53:22 -0700 IronPort-SDR: PqPCivNfeGLjfmzvrQ+JxkzTWz+E7NHxzO1SJgjXKQtxa597jjX3kJh0uLMVhKCpMFFNnI8uGP T0ataMc3mwbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="465378156" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by orsmga005.jf.intel.com with ESMTP; 30 Jul 2020 12:53:22 -0700 From: "McDaniel, Timothy" To: jerinj@marvell.com Cc: mattias.ronnblom@ericsson.com, dev@dpdk.org, gage.eads@intel.com, harry.van.haaren@intel.com, "McDaniel, Timothy" Date: Thu, 30 Jul 2020 14:50:10 -0500 Message-Id: <1596138614-17409-24-git-send-email-timothy.mcdaniel@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1596138614-17409-1-git-send-email-timothy.mcdaniel@intel.com> References: <1593232671-5690-0-git-send-email-timothy.mcdaniel@intel.com> <1596138614-17409-1-git-send-email-timothy.mcdaniel@intel.com> Subject: [dpdk-dev] [PATCH 23/27] event/dlb: add eventdev_start 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "McDaniel, Timothy" Change-Id: I9dcf8cf95c1001e09ab3e44e3fbd2ccbf0ddec72 Signed-off-by: McDaniel, Timothy --- drivers/event/dlb/dlb.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/drivers/event/dlb/dlb.c b/drivers/event/dlb/dlb.c index ed681a3..7a78d59 100644 --- a/drivers/event/dlb/dlb.c +++ b/drivers/event/dlb/dlb.c @@ -1163,6 +1163,72 @@ int dlb_string_to_int(int *result, const char *str) *dev_info = evdev_dlb_default_info; } +static int +dlb_eventdev_reapply_configuration(struct rte_eventdev *dev); + +static int +dlb_eventdev_apply_port_links(struct rte_eventdev *dev); + +static int +dlb_eventdev_start(struct rte_eventdev *dev) +{ + struct dlb_eventdev *dlb = dlb_pmd_priv(dev); + struct dlb_hw_dev *handle = &dlb->qm_instance; + struct dlb_start_domain_args cfg; + struct dlb_cmd_response response; + int ret, i; + + rte_spinlock_lock(&dlb->qm_instance.resource_lock); + if (dlb->run_state != DLB_RUN_STATE_STOPPED) { + DLB_LOG_ERR("bad state %d for dev_start\n", + (int)dlb->run_state); + rte_spinlock_unlock(&dlb->qm_instance.resource_lock); + return -EINVAL; + } + dlb->run_state = DLB_RUN_STATE_STARTING; + rte_spinlock_unlock(&dlb->qm_instance.resource_lock); + + /* If the device was configured more than once, some event ports and/or + * queues may need to be reconfigured. + */ + ret = dlb_eventdev_reapply_configuration(dev); + if (ret) + return ret; + + /* The DLB PMD delays port links until the device is started. */ + ret = dlb_eventdev_apply_port_links(dev); + if (ret) + return ret; + + cfg.response = (uintptr_t)&response; + + for (i = 0; i < dlb->num_ports; i++) { + if (!dlb->ev_ports[i].setup_done) { + DLB_LOG_ERR("dlb: port %d not setup", i); + return -ESTALE; + } + } + + for (i = 0; i < dlb->num_queues; i++) { + if (dlb->ev_queues[i].num_links == 0) { + DLB_LOG_ERR("dlb: queue %d is not linked", i); + return -ENOLINK; + } + } + + ret = dlb_iface_sched_domain_start(handle, &cfg); + if (ret < 0) { + DLB_LOG_ERR("dlb: sched_domain_start ret=%d (driver status: %s)\n", + ret, dlb_error_strings[response.status]); + return ret; + } + + dlb->run_state = DLB_RUN_STATE_STARTED; + DLB_LOG_DBG("dlb: sched_domain_start completed OK\n"); + + return 0; +} + static inline int dlb_check_enqueue_sw_credits(struct dlb_eventdev *dlb, struct dlb_eventdev_port *ev_port) @@ -2057,6 +2123,40 @@ int dlb_string_to_int(int *result, const char *str) } static int +dlb_eventdev_apply_port_links(struct rte_eventdev *dev) +{ + struct dlb_eventdev *dlb = dlb_pmd_priv(dev); + int i; + + /* Perform requested port->queue links */ + for (i = 0; i < dlb->num_ports; i++) { + struct dlb_eventdev_port *ev_port = &dlb->ev_ports[i]; + int j; + + for (j = 0; j < DLB_MAX_NUM_QIDS_PER_LDB_CQ; j++) { + struct dlb_eventdev_queue *ev_queue; + uint8_t prio, queue_id; + + if (!ev_port->link[j].valid) + continue; + + prio = ev_port->link[j].priority; + queue_id = ev_port->link[j].queue_id; + + if (dlb_validate_port_link(ev_port, queue_id, true, j)) + return -EINVAL; + + ev_queue = &dlb->ev_queues[queue_id]; + + if (dlb_do_port_link(dev, ev_queue, ev_port, prio)) + return -EINVAL; + } + } + + return 0; +} + +static int dlb_eventdev_port_link(struct rte_eventdev *dev, void *event_port, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links) @@ -2537,6 +2637,47 @@ static int dlb_num_dir_queues_setup(struct dlb_eventdev *dlb) } static int +dlb_eventdev_reapply_configuration(struct rte_eventdev *dev) +{ + struct dlb_eventdev *dlb = dlb_pmd_priv(dev); + int ret, i; + + /* If an event queue or port was previously configured, but hasn't been + * reconfigured, reapply its original configuration. + */ + for (i = 0; i < dlb->num_queues; i++) { + struct dlb_eventdev_queue *ev_queue; + + ev_queue = &dlb->ev_queues[i]; + + if (ev_queue->qm_queue.config_state != DLB_PREV_CONFIGURED) + continue; + + ret = dlb_eventdev_queue_setup(dev, i, &ev_queue->conf); + if (ret < 0) { + DLB_LOG_ERR("dlb: failed to reconfigure queue %d", i); + return ret; + } + } + + for (i = 0; i < dlb->num_ports; i++) { + struct dlb_eventdev_port *ev_port = &dlb->ev_ports[i]; + + if (ev_port->qm_port.config_state != DLB_PREV_CONFIGURED) + continue; + + ret = dlb_eventdev_port_setup(dev, i, &ev_port->conf); + if (ret < 0) { + DLB_LOG_ERR("dlb: failed to reconfigure ev_port %d", + i); + return ret; + } + } + + return 0; +} + +static int dlb_eventdev_port_unlink(struct rte_eventdev *dev, void *event_port, uint8_t queues[], uint16_t nb_unlinks) { @@ -2738,6 +2879,7 @@ static int dlb_num_dir_queues_setup(struct dlb_eventdev *dlb) static struct rte_eventdev_ops dlb_eventdev_entry_ops = { .dev_infos_get = dlb_eventdev_info_get, .dev_configure = dlb_eventdev_configure, + .dev_start = dlb_eventdev_start, .queue_def_conf = dlb_eventdev_queue_default_conf_get, .queue_setup = dlb_eventdev_queue_setup, .queue_release = dlb_eventdev_queue_release, -- 1.7.10