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 E53BDA0521; Sat, 27 Jun 2020 06:44:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 416E21C032; Sat, 27 Jun 2020 06:40:33 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id EA77E1BF7E for ; Sat, 27 Jun 2020 06:40:11 +0200 (CEST) IronPort-SDR: t+uZz5ZouhMpRXrsUCOS8VWpA7M0aa6J3OgcZIlkrhynIdJSYzxoKo3aOD3njABR+U0sCEUdz2 maYuc8aqFUCA== X-IronPort-AV: E=McAfee;i="6000,8403,9664"; a="125753110" X-IronPort-AV: E=Sophos;i="5.75,286,1589266800"; d="scan'208";a="125753110" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 21:40:11 -0700 IronPort-SDR: H7wK3TFCMNUhe7rfUNZz2sRu4/dxCEONSZKUdue1z+aVrjPINA0KU6T079gNX8TTNsXKVXb+oX /CsL35/U/AkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,286,1589266800"; d="scan'208";a="480023021" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by fmsmga006.fm.intel.com with ESMTP; 26 Jun 2020 21:40:10 -0700 From: Tim McDaniel To: jerinj@marvell.com Cc: mattias.ronnblom@ericsson.com, dev@dpdk.org, gage.eads@intel.com, harry.van.haaren@intel.com, "McDaniel, Timothy" Date: Fri, 26 Jun 2020 23:37:47 -0500 Message-Id: <1593232671-5690-24-git-send-email-timothy.mcdaniel@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1593232671-5690-1-git-send-email-timothy.mcdaniel@intel.com> References: <1593232671-5690-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" 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 ac97f4d..d93b159 100644 --- a/drivers/event/dlb/dlb.c +++ b/drivers/event/dlb/dlb.c @@ -1155,6 +1155,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) @@ -2051,6 +2117,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) @@ -2531,6 +2631,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) { @@ -2732,6 +2873,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