From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0076.outbound.protection.outlook.com [104.47.2.76]) by dpdk.org (Postfix) with ESMTP id B7A4556A3 for ; Thu, 30 Aug 2018 08:06:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z0Ryc0zbUMiPPpZfMQbOy6vVmXdfkN291Vhw/UzQgE4=; b=qHwmUCRbM00+BUMHAkkUVTsScQXVhwp/6qC8VMf5uJLnRawMEkUFtsBvfKIE+pzbgEWPSv7+H40uVBpnWAVKYNDS5HouVRpYoGKFHgCDuX/thOmkfVlYokejlh5S3qcCWUx+0gnlK4lorjrhDtcFxfEe2tL78+I1DIGEh0AuEcg= Received: from bf-netperf1.ap.freescale.net (14.143.30.134) by DB6PR0401MB2533.eurprd04.prod.outlook.com (2603:10a6:4:36::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Thu, 30 Aug 2018 06:06:05 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, nipun.gupta@nxp.com, Sunil Kumar Kori Date: Thu, 30 Aug 2018 11:33:59 +0530 Message-Id: <1535609039-10869-5-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535609039-10869-1-git-send-email-hemant.agrawal@nxp.com> References: <1535609039-10869-1-git-send-email-hemant.agrawal@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.143.30.134] X-ClientProxiedBy: BM1PR0101CA0004.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::14) To DB6PR0401MB2533.eurprd04.prod.outlook.com (2603:10a6:4:36::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e81fca0c-e4c2-4b4e-327b-08d60e3eacca X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0401MB2533; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0401MB2533; 3:n1lnTeWJ4sb5UTSs33GLvK84naLMg40fWDZgQvqBJGHzuCAqf1RBs1aAoIB3uGydaI/siJTX3s2M8RbfmMouovSd1uYUfZHpFj+ggpso5ORp2tZzAZcNn1dS5p4I0r91TS15TLwGxx5UPuvrfOrZC66jYf0ZxCkqF6YTONagIeupxdzTvp4dQmdNYcG01ivSurXwHJHkgL2WdpH0N0Iv5z2hBr5r+BpexV+RNBv6OkQufhSGn/EnywIPwrpBsjgW; 25:9Tvm6TfwhoFTWRj+A5CAS4goUOo3gntnqb+RceNYZzXkOkrxamWalEX75c0YHvfTgp4q6IZtaxpmm/h3+HrgC0+aqh4Y2pabMDoC8vPBZPILopiZVQMR2tBYe4bd2dyww1JTlqCk8mJODOvfzMOfSHB7TRrqMrliysBKp90xx0pJRUDLwv/tnjUeFAW+XysFPestvCqi2CPkFWYHCf9k6p0ZKHNCbPxGQmDeF1Mph5DQbxfufquHMpfZrnr7iywVyhdsRj+1eDjLesfuRN2ppuODqfJcaLjna10eH2UdE7PofJGDxeHS/ImZfraM7COak4tMgeHi1VLUX9FhwODESg==; 31:UWI3Xlymkzb29Q66okLzzK2nEa8aiuzu2qXaxk4Eilk9jHer1cFZCeozYkjovRtNc/7L4fHBzF3bcGF4JigeizxzNw2Orxfq19Es0s+vnqms67HYlDJhEDAAGSi+245e2yckQZW/a5SnaWFMfll6mGJng0IwD9i9LWX4fSfM3411c/HbXZkRX6zoGUFQNeqdS9dVaceHigwhQhAgfL3OS7J0Kt6i85tEosJcoQvbvU4= X-MS-TrafficTypeDiagnostic: DB6PR0401MB2533: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0401MB2533; 20:np3Elj97g8LFni1EG9x1M6++aRN3N5cDBsxCymQVusVXxd/yhShyuajIZCIRsXI3jcQKT0nqCXGb4QH4vwMwZ6udWAD5zo7VRQl8Ohr8q/DRym6xGrpw6fX+IQ5oEnRtiE05dRemamhvksGQWiuQJkNiGMpUHd16aiXAg5uvOItxiQgcPY7AuiXKOUjgA5njJnVHq6Wur0RYO7JwHaEJzPfGUQzLNQyiJAx48OEl4uJjQ6Ihqfp11td+cPCKiI2888DwI3NBXFRg7pHpunakpK1VoGIr2n5VPU6oqR6yWDmxLGKdNGQJCuiJFU3uKdq5QP/4Ir6szmz/ARgCD66B8hyaDb/GyDGDcq3FCXqPpgudkTGup1jTyNLLjP1pCYfEy73pumUQKoXXHsC4Y84A58jK4x5w5HxygHO1DFCO5GcfmXFvjvhGaaASdmmDu4jlLbje0W8rfIrEdNJuYuGrWGLYU78KAodbTsE06nAwowq+pTSAKh+xtOK3NiG0AfNH; 4:2lxK+3IrCPzQ8rP6nAmLqqqwOe3Ot0LoNC9ORcsRk2r13lTvWPlQcdDwzQpitdxihooRMyCFsZGOlvn5KwmLgdfqz92zgQJueTvs2iZUU4+4Yq4yLi7xw0CMk9waaiaIzYg4hmoLu31MqtryS/S0cVUK6gPRA8wiKteVAeZExgXM1DSOtDuuAmdLb7PbXTOKMQ8BTdz74ExJPsudBmWQb/xtnPqSFYOzMEhk3/XqKB3z+qWinkA8tEbsGuZM9teYsrB/ttGjQkr3E43INXt3vRxBN3Aj66hQoYZiTHHEr/BaXC2ZLWGx7d0LxJWPDExnF14d5KmNSgjAkOFx/9Lm6yBPi73o17ijKtWxMZcVFfw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:DB6PR0401MB2533; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0401MB2533; X-Forefront-PRVS: 07807C55DC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(366004)(39860400002)(346002)(376002)(189003)(199004)(16586007)(105586002)(106356001)(6512007)(386003)(26005)(6506007)(47776003)(478600001)(66066001)(48376002)(50466002)(97736004)(6346003)(186003)(16526019)(316002)(55236004)(53936002)(2361001)(6486002)(446003)(2616005)(4326008)(305945005)(25786009)(476003)(486006)(956004)(7736002)(11346002)(5024004)(2351001)(68736007)(44832011)(14444005)(81166006)(5660300001)(2906002)(81156014)(36756003)(50226002)(8936002)(575784001)(86362001)(6666003)(6116002)(5009440100003)(52116002)(3846002)(6916009)(8676002)(76176011)(51416003)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0401MB2533; H:bf-netperf1.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0401MB2533; 23:4yEe9txERWUqDF9Ts2ytuQt+yGPSz3yGeSx87iO?= =?us-ascii?Q?uF0ONrDo3E9RWyOxRjvS+VyNgwxS/mCElOY2WIU+bF9UsXz1TiOvCiY/PnCO?= =?us-ascii?Q?hDwC41UjcWdpIdokzOM8dn4TdMfKjD0U/42iNLrvSvDIOOjVLSnKHj8LWmhR?= =?us-ascii?Q?41vN2eqCj578ION1YaeOysxN5FnHkepx6ew7qdCyJt9LrV8CBU6p9/y6Z4ie?= =?us-ascii?Q?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tDst9I42wllrgIOT38GTuIKNOunccpFkxeCq8ag5FwO5VH5FKRQLnYUyh7Dr2SMHZMl5FaGaMjPON8BZWVFzF3JCkkuHvmYMfYttg8OPsoT877K5v+pce90mSWQVATHJB89JoKkajP/Xo2fbn4b5M95qOT8NryF/fLL8xDxesHclcF1WZDIg==; 5:wMo7O4a5E9KQ8HVW3XPfHQAcg7faxezHy7s5O1tMiETr/L5mElQH1vvFp4n9U/Oi1FK6uUt2ZJ8ePguYcNFJaCiX8DLjn8eVYG+YSJJHdFyovs+PnG1f70aPmm99peWsYpvRycNx30XADnrrz9Yg70R5m0ed0KhDB3Fw16hrozM=; 7:zFFYjGS4hpehSoiw8wEY7UupQVl/rrpKmR7Br0MPp/f99VWQC28bYCo5U5w9e/sMVqvMQwDAE/GLHdpbjPicaDQdBsqZUxGftfOcT7Q7R2/N8Q9SNTF6EWE1EGjYctsrDGCZcNXVIsG3J/3pMThFLAzGsFsjR9hyMTjIp0gm7SxF7eqWEtXE4zlDabS2WD4e3nBFZY/DdJlz2iDbgV43l0oaB+wu2FXRfwP2GmSuz/t48N94sIKn/mrZBIBmR+uW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2018 06:06:05.9569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e81fca0c-e4c2-4b4e-327b-08d60e3eacca X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2533 Subject: [dpdk-dev] [PATCH 5/5] event/dpaa2: affining portal at runtime during I/O 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: Thu, 30 Aug 2018 06:06:08 -0000 This patch restructure the code to have the QBMAN portal affliated at run time. The device cleanup is also improved. Signed-off-by: Sunil Kumar Kori Signed-off-by: Hemant Agrawal --- drivers/event/dpaa2/dpaa2_eventdev.c | 277 ++++++++++++++++++++++++----------- drivers/event/dpaa2/dpaa2_eventdev.h | 9 ++ 2 files changed, 198 insertions(+), 88 deletions(-) diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c index 456b446..b4e0885 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.c +++ b/drivers/event/dpaa2/dpaa2_eventdev.c @@ -54,31 +54,60 @@ static uint16_t dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], uint16_t nb_events) { - struct rte_eventdev *ev_dev = - ((struct dpaa2_io_portal_t *)port)->eventdev; - struct dpaa2_eventdev *priv = ev_dev->data->dev_private; + + struct dpaa2_port *dpaa2_portal = port; + struct dpaa2_dpio_dev *dpio_dev; uint32_t queue_id = ev[0].queue_id; - struct dpaa2_eventq *evq_info = &priv->evq_info[queue_id]; + struct dpaa2_eventq *evq_info; uint32_t fqid; struct qbman_swp *swp; struct qbman_fd fd_arr[MAX_TX_RING_SLOTS]; uint32_t loop, frames_to_send; struct qbman_eq_desc eqdesc[MAX_TX_RING_SLOTS]; uint16_t num_tx = 0; - int ret; - - RTE_SET_USED(port); + int i, ret; + uint8_t channel_index; if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + /* Affine current thread context to a qman portal */ ret = dpaa2_affine_qbman_swp(); - if (ret) { + if (ret < 0) { DPAA2_EVENTDEV_ERR("Failure in affining portal"); return 0; } } - + /* todo - dpaa2_portal shall have dpio_dev - no per thread variable */ + dpio_dev = DPAA2_PER_LCORE_DPIO; swp = DPAA2_PER_LCORE_PORTAL; + if (likely(dpaa2_portal->is_port_linked)) + goto skip_linking; + + /* Create mapping between portal and channel to receive packets */ + for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) { + evq_info = &dpaa2_portal->evq_info[i]; + if (!evq_info->event_port) + continue; + + ret = dpio_add_static_dequeue_channel(dpio_dev->dpio, + CMD_PRI_LOW, + dpio_dev->token, + evq_info->dpcon->dpcon_id, + &channel_index); + if (ret < 0) { + DPAA2_EVENTDEV_ERR( + "Static dequeue config failed: err(%d)", ret); + goto err; + } + + qbman_swp_push_set(swp, channel_index, 1); + evq_info->dpcon->channel_index = channel_index; + } + dpaa2_portal->is_port_linked = true; + +skip_linking: + evq_info = &dpaa2_portal->evq_info[queue_id]; + while (nb_events) { frames_to_send = (nb_events >> 3) ? MAX_TX_RING_SLOTS : nb_events; @@ -99,14 +128,14 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], qbman_eq_desc_set_no_orp(&eqdesc[loop], 0); qbman_eq_desc_set_response(&eqdesc[loop], 0, 0); - if (event->mbuf->seqn) { + if (event->sched_type == RTE_SCHED_TYPE_ATOMIC + && event->mbuf->seqn) { uint8_t dqrr_index = event->mbuf->seqn - 1; qbman_eq_desc_set_dca(&eqdesc[loop], 1, dqrr_index, 0); DPAA2_PER_LCORE_DQRR_SIZE--; - DPAA2_PER_LCORE_DQRR_HELD &= - ~(1 << dqrr_index); + DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); } memset(&fd_arr[loop], 0, sizeof(struct qbman_fd)); @@ -116,7 +145,7 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], * to avoid copy */ struct rte_event *ev_temp = rte_malloc(NULL, - sizeof(struct rte_event), 0); + sizeof(struct rte_event), 0); if (!ev_temp) { if (!loop) @@ -143,6 +172,18 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], } return num_tx; +err: + for (int n = 0; n < i; n++) { + evq_info = &dpaa2_portal->evq_info[n]; + if (!evq_info->event_port) + continue; + qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0); + dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0, + dpio_dev->token, + evq_info->dpcon->dpcon_id); + } + return 0; + } static uint16_t @@ -205,22 +246,53 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks) { const struct qbman_result *dq; + struct dpaa2_dpio_dev *dpio_dev = NULL; + struct dpaa2_port *dpaa2_portal = port; + struct dpaa2_eventq *evq_info; struct qbman_swp *swp; const struct qbman_fd *fd; struct dpaa2_queue *rxq; - int num_pkts = 0, ret, i = 0; - - RTE_SET_USED(port); + int num_pkts = 0, ret, i = 0, n; + uint8_t channel_index; if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + /* Affine current thread context to a qman portal */ ret = dpaa2_affine_qbman_swp(); - if (ret) { + if (ret < 0) { DPAA2_EVENTDEV_ERR("Failure in affining portal"); return 0; } } + + dpio_dev = DPAA2_PER_LCORE_DPIO; swp = DPAA2_PER_LCORE_PORTAL; + if (likely(dpaa2_portal->is_port_linked)) + goto skip_linking; + + /* Create mapping between portal and channel to receive packets */ + for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) { + evq_info = &dpaa2_portal->evq_info[i]; + if (!evq_info->event_port) + continue; + + ret = dpio_add_static_dequeue_channel(dpio_dev->dpio, + CMD_PRI_LOW, + dpio_dev->token, + evq_info->dpcon->dpcon_id, + &channel_index); + if (ret < 0) { + DPAA2_EVENTDEV_ERR( + "Static dequeue config failed: err(%d)", ret); + goto err; + } + + qbman_swp_push_set(swp, channel_index, 1); + evq_info->dpcon->channel_index = channel_index; + } + dpaa2_portal->is_port_linked = true; + +skip_linking: /* Check if there are atomic contexts to be released */ while (DPAA2_PER_LCORE_DQRR_SIZE) { if (DPAA2_PER_LCORE_DQRR_HELD & (1 << i)) { @@ -259,6 +331,18 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], } while (num_pkts < nb_events); return num_pkts; +err: + for (n = 0; n < i; n++) { + evq_info = &dpaa2_portal->evq_info[n]; + if (!evq_info->event_port) + continue; + + qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0); + dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0, + dpio_dev->token, + evq_info->dpcon->dpcon_id); + } + return 0; } static uint16_t @@ -387,31 +471,39 @@ dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id, queue_conf->priority = RTE_EVENT_DEV_PRIORITY_NORMAL; } -static void -dpaa2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t queue_id) -{ - EVENTDEV_INIT_FUNC_TRACE(); - - RTE_SET_USED(dev); - RTE_SET_USED(queue_id); -} - static int dpaa2_eventdev_queue_setup(struct rte_eventdev *dev, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf) { struct dpaa2_eventdev *priv = dev->data->dev_private; - struct dpaa2_eventq *evq_info = - &priv->evq_info[queue_id]; + struct dpaa2_eventq *evq_info = &priv->evq_info[queue_id]; EVENTDEV_INIT_FUNC_TRACE(); + switch (queue_conf->schedule_type) { + case RTE_SCHED_TYPE_PARALLEL: + case RTE_SCHED_TYPE_ATOMIC: + break; + case RTE_SCHED_TYPE_ORDERED: + DPAA2_EVENTDEV_ERR("Schedule type is not supported."); + return -1; + } evq_info->event_queue_cfg = queue_conf->event_queue_cfg; + evq_info->event_queue_id = queue_id; return 0; } static void +dpaa2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t queue_id) +{ + EVENTDEV_INIT_FUNC_TRACE(); + + RTE_SET_USED(dev); + RTE_SET_USED(queue_id); +} + +static void dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id, struct rte_event_port_conf *port_conf) { @@ -419,7 +511,6 @@ dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id, RTE_SET_USED(dev); RTE_SET_USED(port_id); - RTE_SET_USED(port_conf); port_conf->new_event_threshold = DPAA2_EVENT_MAX_NUM_EVENTS; @@ -430,56 +521,44 @@ dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id, port_conf->disable_implicit_release = 0; } -static void -dpaa2_eventdev_port_release(void *port) -{ - EVENTDEV_INIT_FUNC_TRACE(); - - RTE_SET_USED(port); -} - static int dpaa2_eventdev_port_setup(struct rte_eventdev *dev, uint8_t port_id, const struct rte_event_port_conf *port_conf) { + char event_port_name[32]; + struct dpaa2_port *portal; + EVENTDEV_INIT_FUNC_TRACE(); RTE_SET_USED(port_conf); - if (!dpaa2_io_portal[port_id].dpio_dev) { - dpaa2_io_portal[port_id].dpio_dev = - dpaa2_get_qbman_swp(port_id); - rte_atomic16_inc(&dpaa2_io_portal[port_id].dpio_dev->ref_count); - if (!dpaa2_io_portal[port_id].dpio_dev) - return -1; + sprintf(event_port_name, "event-port-%d", port_id); + portal = rte_malloc(event_port_name, sizeof(struct dpaa2_port), 0); + if (!portal) { + DPAA2_EVENTDEV_ERR("Memory allocation failure"); + return -ENOMEM; } - dpaa2_io_portal[port_id].eventdev = dev; - dev->data->ports[port_id] = &dpaa2_io_portal[port_id]; + memset(portal, 0, sizeof(struct dpaa2_port)); + dev->data->ports[port_id] = portal; return 0; } -static int -dpaa2_eventdev_port_unlink(struct rte_eventdev *dev, void *port, - uint8_t queues[], uint16_t nb_unlinks) +static void +dpaa2_eventdev_port_release(void *port) { - struct dpaa2_eventdev *priv = dev->data->dev_private; - struct dpaa2_io_portal_t *dpaa2_portal = port; - struct dpaa2_eventq *evq_info; - int i; + struct dpaa2_port *portal = port; EVENTDEV_INIT_FUNC_TRACE(); - for (i = 0; i < nb_unlinks; i++) { - evq_info = &priv->evq_info[queues[i]]; - qbman_swp_push_set(dpaa2_portal->dpio_dev->sw_portal, - evq_info->dpcon->channel_index, 0); - dpio_remove_static_dequeue_channel(dpaa2_portal->dpio_dev->dpio, - 0, dpaa2_portal->dpio_dev->token, - evq_info->dpcon->dpcon_id); - } + /* TODO: Cleanup is required when ports are in linked state. */ + if (portal->is_port_linked) + DPAA2_EVENTDEV_WARN("Event port must be unlinked before release"); - return (int)nb_unlinks; + if (portal) + rte_free(portal); + + portal = NULL; } static int @@ -488,46 +567,66 @@ dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port, uint16_t nb_links) { struct dpaa2_eventdev *priv = dev->data->dev_private; - struct dpaa2_io_portal_t *dpaa2_portal = port; + struct dpaa2_port *dpaa2_portal = port; struct dpaa2_eventq *evq_info; - uint8_t channel_index; - int ret, i, n; + uint16_t i; EVENTDEV_INIT_FUNC_TRACE(); + RTE_SET_USED(priorities); + for (i = 0; i < nb_links; i++) { evq_info = &priv->evq_info[queues[i]]; + memcpy(&dpaa2_portal->evq_info[queues[i]], evq_info, + sizeof(struct dpaa2_eventq)); + dpaa2_portal->evq_info[queues[i]].event_port = port; + dpaa2_portal->num_linked_evq++; + } - ret = dpio_add_static_dequeue_channel( - dpaa2_portal->dpio_dev->dpio, - CMD_PRI_LOW, dpaa2_portal->dpio_dev->token, - evq_info->dpcon->dpcon_id, &channel_index); - if (ret < 0) { - DPAA2_EVENTDEV_ERR( - "Static dequeue config failed: err(%d)", ret); - goto err; - } + return (int)nb_links; +} - qbman_swp_push_set(dpaa2_portal->dpio_dev->sw_portal, - channel_index, 1); - evq_info->dpcon->channel_index = channel_index; - } +static int +dpaa2_eventdev_port_unlink(struct rte_eventdev *dev, void *port, + uint8_t queues[], uint16_t nb_unlinks) +{ + struct dpaa2_port *dpaa2_portal = port; + int i; + struct dpaa2_dpio_dev *dpio_dev = NULL; + struct dpaa2_eventq *evq_info; + struct qbman_swp *swp; - RTE_SET_USED(priorities); + EVENTDEV_INIT_FUNC_TRACE(); - return (int)nb_links; -err: - for (n = 0; n < i; n++) { - evq_info = &priv->evq_info[queues[n]]; - qbman_swp_push_set(dpaa2_portal->dpio_dev->sw_portal, - evq_info->dpcon->channel_index, 0); - dpio_remove_static_dequeue_channel(dpaa2_portal->dpio_dev->dpio, - 0, dpaa2_portal->dpio_dev->token, - evq_info->dpcon->dpcon_id); + RTE_SET_USED(dev); + RTE_SET_USED(queues); + + for (i = 0; i < nb_unlinks; i++) { + evq_info = &dpaa2_portal->evq_info[queues[i]]; + + if (DPAA2_PER_LCORE_DPIO && evq_info->dpcon) { + /* todo dpaa2_portal shall have dpio_dev-no per lcore*/ + dpio_dev = DPAA2_PER_LCORE_DPIO; + swp = DPAA2_PER_LCORE_PORTAL; + + qbman_swp_push_set(swp, + evq_info->dpcon->channel_index, 0); + dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0, + dpio_dev->token, + evq_info->dpcon->dpcon_id); + } + memset(evq_info, 0, sizeof(struct dpaa2_eventq)); + if (dpaa2_portal->num_linked_evq) + dpaa2_portal->num_linked_evq--; } - return ret; + + if (!dpaa2_portal->num_linked_evq) + dpaa2_portal->is_port_linked = false; + + return (int)nb_unlinks; } + static int dpaa2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns, uint64_t *timeout_ticks) @@ -806,6 +905,8 @@ dpaa2_eventdev_create(const char *name) priv->max_event_queues++; } while (dpcon_dev && dpci_dev); + RTE_LOG(INFO, PMD, "%s eventdev created\n", name); + return 0; fail: return -EFAULT; diff --git a/drivers/event/dpaa2/dpaa2_eventdev.h b/drivers/event/dpaa2/dpaa2_eventdev.h index 8898024..720e0c6 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.h +++ b/drivers/event/dpaa2/dpaa2_eventdev.h @@ -62,11 +62,20 @@ struct dpaa2_eventq { struct dpaa2_dpcon_dev *dpcon; /* Attached DPCI device */ struct dpaa2_dpci_dev *dpci; + /* Mapped event port */ + struct dpaa2_io_portal_t *event_port; /* Configuration provided by the user */ uint32_t event_queue_cfg; uint32_t event_queue_id; }; +struct dpaa2_port { + struct dpaa2_eventq evq_info[DPAA2_EVENT_MAX_QUEUES]; + uint8_t num_linked_evq; + uint8_t is_port_linked; + uint64_t timeout_us; +}; + struct dpaa2_eventdev { struct dpaa2_eventq evq_info[DPAA2_EVENT_MAX_QUEUES]; uint32_t dequeue_timeout_ns; -- 2.7.4