From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C6EF459BA; Tue, 17 Sep 2024 09:11:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7E4D140659; Tue, 17 Sep 2024 09:11:23 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 44B3B40652 for ; Tue, 17 Sep 2024 09:11:22 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48H29qro009218; Tue, 17 Sep 2024 00:11:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=m BBVhdXAHBm/BHCaPUu5H/xEuMULprMD6cOs8gDWLEg=; b=Wsa3ilWi1c2R1CFsX PV9q6VV4qrXgwAAIRd+agEn13RnKmKA5S4Un/+4RrcaBGeljBNMyI+1qYAY2Nhxa F/FEOltKKrEFcwFrU9RExtRMRu4pl2LguS+PWlhBVQF5tK7f3KzjH+eR0gH41Kw4 FvjiqGBkS56LAl9jqNjroWyzr8A1Hy8qhVTm6eWTIPTDCPR0f8QniGdZPatA7m6E gQip01Wp/kudBlru1B8/Ibx9zccx4gQ+1z61TH93OMBjNQjeSdlbUV9ac1/GYs8f q43BcS/cDNqEqcl7zEvS8aACgAeGHsqCwBB7b9gmSBH1TOo/PzpA/zTfK9iSqAfS DNPCA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41na0g16m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Sep 2024 00:11:21 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 17 Sep 2024 00:11:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 17 Sep 2024 00:11:20 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.21.130]) by maili.marvell.com (Postfix) with ESMTP id 831195B6950; Tue, 17 Sep 2024 00:11:16 -0700 (PDT) From: To: , , , , , , , , CC: , Pavan Nikhilesh Subject: [PATCH v2 2/3] eventdev: add event port pre-schedule modify Date: Tue, 17 Sep 2024 12:41:05 +0530 Message-ID: <20240917071106.8815-3-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240917071106.8815-1-pbhagavatula@marvell.com> References: <20240910083117.4281-1-pbhagavatula@marvell.com> <20240917071106.8815-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: RC-D_DXIgCzNlt4M4tf2KahRTfKk-w6F X-Proofpoint-GUID: RC-D_DXIgCzNlt4M4tf2KahRTfKk-w6F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Pavan Nikhilesh Some event devices allow pre-schedule types to be modified at runtime on an event port. Add `RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PRESCHEDULE` capability to indicate that the event device supports this feature. Add `rte_event_port_preschedule_modify()` API to modify the pre-schedule type at runtime. Signed-off-by: Pavan Nikhilesh --- app/test/test_eventdev.c | 61 +++++++++++++++++++-- doc/guides/prog_guide/eventdev/eventdev.rst | 12 ++++ lib/eventdev/eventdev_pmd.h | 2 + lib/eventdev/eventdev_private.c | 10 ++++ lib/eventdev/eventdev_trace_points.c | 3 + lib/eventdev/rte_eventdev.h | 55 +++++++++++++++++++ lib/eventdev/rte_eventdev_core.h | 6 ++ lib/eventdev/rte_eventdev_trace_fp.h | 11 +++- lib/eventdev/version.map | 4 ++ 9 files changed, 158 insertions(+), 6 deletions(-) diff --git a/app/test/test_eventdev.c b/app/test/test_eventdev.c index cf496ee88d..6c799e3d11 100644 --- a/app/test/test_eventdev.c +++ b/app/test/test_eventdev.c @@ -1251,7 +1251,8 @@ test_eventdev_profile_switch(void) } static int -preschedule_test(rte_event_dev_preschedule_type_t preschedule_type, const char *preschedule_name) +preschedule_test(rte_event_dev_preschedule_type_t preschedule_type, const char *preschedule_name, + uint8_t modify) { #define NB_EVENTS 1024 uint64_t start, total; @@ -1269,7 +1270,11 @@ preschedule_test(rte_event_dev_preschedule_type_t preschedule_type, const char * TEST_ASSERT(rc == 1, "Failed to enqueue event"); } - RTE_SET_USED(preschedule_type); + if (modify) { + rc = rte_event_port_preschedule_modify(TEST_DEV_ID, 0, preschedule_type); + TEST_ASSERT_SUCCESS(rc, "Failed to modify preschedule type"); + } + total = 0; while (cnt) { start = rte_rdtsc_precise(); @@ -1302,11 +1307,55 @@ test_eventdev_preschedule_configure(void) rc = rte_event_dev_configure(TEST_DEV_ID, &dev_conf); TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); - rc = preschedule_test(RTE_EVENT_DEV_PRESCHEDULE_NONE, "RTE_EVENT_DEV_PRESCHEDULE_NONE"); - rc |= preschedule_test(RTE_EVENT_DEV_PRESCHEDULE, "RTE_EVENT_DEV_PRESCHEDULE"); + rc = preschedule_test(RTE_EVENT_DEV_PRESCHEDULE_NONE, "RTE_EVENT_DEV_PRESCHEDULE_NONE", 0); + rc |= preschedule_test(RTE_EVENT_DEV_PRESCHEDULE, "RTE_EVENT_DEV_PRESCHEDULE", 0); if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE) rc |= preschedule_test(RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE, - "RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE"); + "RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE", 0); + + return rc; +} + +static int +test_eventdev_preschedule_modify(void) +{ + struct rte_event_dev_config dev_conf; + struct rte_event_queue_conf qcfg; + struct rte_event_port_conf pcfg; + struct rte_event_dev_info info; + int rc; + + rte_event_dev_info_get(TEST_DEV_ID, &info); + if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PRESCHEDULE) == 0) + return TEST_SKIPPED; + + devconf_set_default_sane_values(&dev_conf, &info); + dev_conf.preschedule_type = RTE_EVENT_DEV_PRESCHEDULE_NONE; + rc = rte_event_dev_configure(TEST_DEV_ID, &dev_conf); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + + rc = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to get port0 default config"); + rc = rte_event_port_setup(TEST_DEV_ID, 0, &pcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to setup port0"); + + rc = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to get queue0 default config"); + rc = rte_event_queue_setup(TEST_DEV_ID, 0, &qcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to setup queue0"); + + rc = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); + TEST_ASSERT(rc == (int)dev_conf.nb_event_queues, "Failed to link port, device %d", + TEST_DEV_ID); + + rc = rte_event_dev_start(TEST_DEV_ID); + TEST_ASSERT_SUCCESS(rc, "Failed to start event device"); + + rc = preschedule_test(RTE_EVENT_DEV_PRESCHEDULE_NONE, "RTE_EVENT_DEV_PRESCHEDULE_NONE", 1); + rc |= preschedule_test(RTE_EVENT_DEV_PRESCHEDULE, "RTE_EVENT_DEV_PRESCHEDULE", 1); + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE) + rc |= preschedule_test(RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE, + "RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE", 1); return rc; } @@ -1373,6 +1422,8 @@ static struct unit_test_suite eventdev_common_testsuite = { test_eventdev_profile_switch), TEST_CASE_ST(eventdev_configure_setup, NULL, test_eventdev_preschedule_configure), + TEST_CASE_ST(eventdev_configure_setup, eventdev_stop_device, + test_eventdev_preschedule_modify), TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device, test_eventdev_link), TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device, diff --git a/doc/guides/prog_guide/eventdev/eventdev.rst b/doc/guides/prog_guide/eventdev/eventdev.rst index 341b9bb2c6..2deab0333e 100644 --- a/doc/guides/prog_guide/eventdev/eventdev.rst +++ b/doc/guides/prog_guide/eventdev/eventdev.rst @@ -379,6 +379,18 @@ Currently, the following pre-schedule types are supported: * ``RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE`` - Issue pre-schedule when dequeue is issued and there are no forward progress constraints. +To enable or disable event pre-scheduling at a given event port, the application can use +``rte_event_port_preschedule_modify()`` API. + +.. code-block:: c + + rte_event_port_preschedule_modify(dev_id, port_id, RTE_EVENT_DEV_PRESCHEDULE); + // Dequeue events from the event port with normal dequeue() function. + rte_event_port_preschedule_modify(dev_id, port_id, RTE_EVENT_DEV_PRESCHEDULE_NONE); + // Disable pre-scheduling if thread is about to be scheduled out and issue dequeue() to drain + // pending events. + + Starting the EventDev ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index 7a5699f14b..9ea23aa6cd 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -184,6 +184,8 @@ struct __rte_cache_aligned rte_eventdev { /**< Pointer to PMD DMA adapter enqueue function. */ event_profile_switch_t profile_switch; /**< Pointer to PMD Event switch profile function. */ + event_preschedule_modify_t preschedule_modify; + /**< Pointer to PMD Event port pre-schedule type modify function. */ uint64_t reserved_64s[3]; /**< Reserved for future fields */ void *reserved_ptrs[3]; /**< Reserved for future fields */ diff --git a/lib/eventdev/eventdev_private.c b/lib/eventdev/eventdev_private.c index 017f97ccab..f0aae766ea 100644 --- a/lib/eventdev/eventdev_private.c +++ b/lib/eventdev/eventdev_private.c @@ -96,6 +96,14 @@ dummy_event_port_profile_switch(__rte_unused void *port, __rte_unused uint8_t pr return -EINVAL; } +static int +dummy_event_port_preschedule_modify(__rte_unused void *port, + __rte_unused rte_event_dev_preschedule_type_t preschedule) +{ + RTE_EDEV_LOG_ERR("modify pre-schedule requested for unconfigured event device"); + return -EINVAL; +} + void event_dev_fp_ops_reset(struct rte_event_fp_ops *fp_op) { @@ -114,6 +122,7 @@ event_dev_fp_ops_reset(struct rte_event_fp_ops *fp_op) .ca_enqueue = dummy_event_crypto_adapter_enqueue, .dma_enqueue = dummy_event_dma_adapter_enqueue, .profile_switch = dummy_event_port_profile_switch, + .preschedule_modify = dummy_event_port_preschedule_modify, .data = dummy_data, }; @@ -136,5 +145,6 @@ event_dev_fp_ops_set(struct rte_event_fp_ops *fp_op, fp_op->ca_enqueue = dev->ca_enqueue; fp_op->dma_enqueue = dev->dma_enqueue; fp_op->profile_switch = dev->profile_switch; + fp_op->preschedule_modify = dev->preschedule_modify; fp_op->data = dev->data->ports; } diff --git a/lib/eventdev/eventdev_trace_points.c b/lib/eventdev/eventdev_trace_points.c index 8024e07531..e41674123c 100644 --- a/lib/eventdev/eventdev_trace_points.c +++ b/lib/eventdev/eventdev_trace_points.c @@ -49,6 +49,9 @@ RTE_TRACE_POINT_REGISTER(rte_eventdev_trace_maintain, RTE_TRACE_POINT_REGISTER(rte_eventdev_trace_port_profile_switch, lib.eventdev.port.profile.switch) +RTE_TRACE_POINT_REGISTER(rte_eventdev_trace_port_preschedule_modify, + lib.eventdev.port.preschedule.modify) + /* Eventdev Rx adapter trace points */ RTE_TRACE_POINT_REGISTER(rte_eventdev_trace_eth_rx_adapter_create, lib.eventdev.rx.adapter.create) diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h index 5ea7f5a07b..0add0093ac 100644 --- a/lib/eventdev/rte_eventdev.h +++ b/lib/eventdev/rte_eventdev.h @@ -470,6 +470,16 @@ struct rte_event; * @see rte_event_dev_configure() */ +#define RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PRESCHEDULE (1ULL << 18) +/**< Event device supports event pre-scheduling per event port. + * + * When this flag is set, the event device allows controlling the event + * pre-scheduling at a event port granularity. + * + * @see rte_event_dev_configure() + * @see rte_event_port_preschedule_modify() + */ + /* Event device priority levels */ #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0 /**< Highest priority level for events and queues. @@ -708,18 +718,23 @@ typedef enum { RTE_EVENT_DEV_PRESCHEDULE_NONE = 0, /* Disable pre-schedule across the event device or on a given event port. * @ref rte_event_dev_config.preschedule_type + * @ref rte_event_port_preschedule_modify() */ RTE_EVENT_DEV_PRESCHEDULE, /* Enable pre-schedule always across the event device or a given event port. * @ref rte_event_dev_config.preschedule_type + * @ref rte_event_port_preschedule_modify() * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE + * @see RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PRESCHEDULE */ RTE_EVENT_DEV_PRESCHEDULE_ADAPTIVE, /* Enable adaptive pre-schedule across the event device or a given event port. * Delay issuing pre-schedule until there are no forward progress constraints with * the held flow contexts. * @ref rte_event_dev_config.preschedule_type + * @ref rte_event_port_preschedule_modify() * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE + * @see RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PRESCHEDULE */ } rte_event_dev_preschedule_type_t; @@ -2922,6 +2937,46 @@ rte_event_port_profile_switch(uint8_t dev_id, uint8_t port_id, uint8_t profile_i return fp_ops->profile_switch(port, profile_id); } +/** + * Change the pre-schedule type to use on an event port. + * + * This function is used to change the current pre-schedule type configured + * on an event port, the pre-schedule type can be set to none to disable pre-scheduling. + * This effects the subsequent ``rte_event_dequeue_burst`` call. + * The event device should support RTE_EVENT_DEV_CAP_PER_PORT_PRESCHEDULE capability. + * + * @param dev_id + * The identifier of the device. + * @param port_id + * The identifier of the event port. + * @param type + * The preschedule type to use on the event port. + * @return + * - 0 on success. + * - -EINVAL if *dev_id*, *port_id*, or *type* is invalid. + */ +static inline int +rte_event_port_preschedule_modify(uint8_t dev_id, uint8_t port_id, + rte_event_dev_preschedule_type_t type) +{ + const struct rte_event_fp_ops *fp_ops; + void *port; + + fp_ops = &rte_event_fp_ops[dev_id]; + port = fp_ops->data[port_id]; + +#ifdef RTE_LIBRTE_EVENTDEV_DEBUG + if (dev_id >= RTE_EVENT_MAX_DEVS || port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) + return -EINVAL; + + if (port == NULL) + return -EINVAL; +#endif + rte_eventdev_trace_port_preschedule_modify(dev_id, port_id, type); + + return fp_ops->preschedule_modify(port, type); +} + #ifdef __cplusplus } #endif diff --git a/lib/eventdev/rte_eventdev_core.h b/lib/eventdev/rte_eventdev_core.h index fc8e1556ab..2275888a6b 100644 --- a/lib/eventdev/rte_eventdev_core.h +++ b/lib/eventdev/rte_eventdev_core.h @@ -49,6 +49,10 @@ typedef uint16_t (*event_dma_adapter_enqueue_t)(void *port, struct rte_event ev[ typedef int (*event_profile_switch_t)(void *port, uint8_t profile); /**< @internal Switch active link profile on the event port. */ +typedef int (*event_preschedule_modify_t)(void *port, + rte_event_dev_preschedule_type_t preschedule_type); +/**< @internal Modify pre-schedule type on the event port. */ + struct __rte_cache_aligned rte_event_fp_ops { void **data; /**< points to array of internal port data pointers */ @@ -76,6 +80,8 @@ struct __rte_cache_aligned rte_event_fp_ops { /**< PMD DMA adapter enqueue function. */ event_profile_switch_t profile_switch; /**< PMD Event switch profile function. */ + event_preschedule_modify_t preschedule_modify; + /**< PMD Event port pre-schedule switch. */ uintptr_t reserved[4]; }; diff --git a/lib/eventdev/rte_eventdev_trace_fp.h b/lib/eventdev/rte_eventdev_trace_fp.h index 04d510ad00..78baed94de 100644 --- a/lib/eventdev/rte_eventdev_trace_fp.h +++ b/lib/eventdev/rte_eventdev_trace_fp.h @@ -8,7 +8,7 @@ /** * @file * - * API for ethdev trace support + * API for eventdev trace support */ #ifdef __cplusplus @@ -54,6 +54,15 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_u8(profile); ) +RTE_TRACE_POINT_FP( + rte_eventdev_trace_port_preschedule_modify, + RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint8_t port_id, + int type), + rte_trace_point_emit_u8(dev_id); + rte_trace_point_emit_u8(port_id); + rte_trace_point_emit_int(type); +) + RTE_TRACE_POINT_FP( rte_eventdev_trace_eth_tx_adapter_enqueue, RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint8_t port_id, void *ev_table, diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index 4947bb4ec6..b6d63ba576 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -147,6 +147,10 @@ EXPERIMENTAL { rte_event_port_profile_unlink; rte_event_port_profile_links_get; __rte_eventdev_trace_port_profile_switch; + + # added in 24.11 + rte_event_port_preschedule_modify; + __rte_eventdev_trace_port_preschedule_modify; }; INTERNAL { -- 2.25.1