@@ -1251,7 +1251,8 @@ test_eventdev_profile_switch(void)
}
static int
-prefetch_test(rte_event_dev_prefetch_type_t prefetch_type, const char *prefetch_name)
+prefetch_test(rte_event_dev_prefetch_type_t prefetch_type, const char *prefetch_name,
+ uint8_t modify)
{
#define NB_EVENTS 1024
uint64_t start, total;
@@ -1269,7 +1270,11 @@ prefetch_test(rte_event_dev_prefetch_type_t prefetch_type, const char *prefetch_
TEST_ASSERT(rc == 1, "Failed to enqueue event");
}
- RTE_SET_USED(prefetch_type);
+ if (modify) {
+ rc = rte_event_port_prefetch_modify(TEST_DEV_ID, 0, prefetch_type);
+ TEST_ASSERT_SUCCESS(rc, "Failed to modify prefetch type");
+ }
+
total = 0;
while (cnt) {
start = rte_rdtsc_precise();
@@ -1301,11 +1306,55 @@ test_eventdev_prefetch_configure(void)
rc = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev");
- rc = prefetch_test(RTE_EVENT_DEV_PREFETCH_NONE, "RTE_EVENT_DEV_PREFETCH_NONE");
- rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH, "RTE_EVENT_DEV_PREFETCH");
+ rc = prefetch_test(RTE_EVENT_DEV_PREFETCH_NONE, "RTE_EVENT_DEV_PREFETCH_NONE", 0);
+ rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH, "RTE_EVENT_DEV_PREFETCH", 0);
if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH)
rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH_INTELLIGENT,
- "RTE_EVENT_DEV_PREFETCH_INTELLIGENT");
+ "RTE_EVENT_DEV_PREFETCH_INTELLIGENT", 0);
+
+ return rc;
+}
+
+static int
+test_eventdev_prefetch_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_PREFETCH) == 0)
+ return TEST_SKIPPED;
+
+ devconf_set_default_sane_values(&dev_conf, &info);
+ dev_conf.prefetch_type = RTE_EVENT_DEV_PREFETCH_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 = prefetch_test(RTE_EVENT_DEV_PREFETCH_NONE, "RTE_EVENT_DEV_PREFETCH_NONE", 1);
+ rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH, "RTE_EVENT_DEV_PREFETCH", 1);
+ if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH)
+ rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH_INTELLIGENT,
+ "RTE_EVENT_DEV_PREFETCH_INTELLIGENT", 1);
return rc;
}
@@ -1372,6 +1421,8 @@ static struct unit_test_suite eventdev_common_testsuite = {
test_eventdev_profile_switch),
TEST_CASE_ST(eventdev_configure_setup, NULL,
test_eventdev_prefetch_configure),
+ TEST_CASE_ST(eventdev_configure_setup, eventdev_stop_device,
+ test_eventdev_prefetch_modify),
TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
test_eventdev_link),
TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
@@ -379,6 +379,18 @@ Currently, the following prefetch types are supported:
* ``RTE_EVENT_DEV_PREFETCH_INTELLIGENT`` - Issue prefetch when dequeue is issued and there are
no forward progress constraints.
+To enable or disable event prefetching at a given event port, the application can use
+``rte_event_port_prefetch_modify()`` API.
+
+.. code-block:: c
+
+ rte_event_port_prefetch_modify(dev_id, port_id, RTE_EVENT_DEV_PREFETCH);
+ // Dequeue events from the event port with normal dequeue() function.
+ rte_event_port_prefetch_modify(dev_id, port_id, RTE_EVENT_DEV_PREFETCH_NONE);
+ // Disable prefetching if thread is about to be scheduled out and issue dequeue() to drain
+ // pending events.
+
+
Starting the EventDev
~~~~~~~~~~~~~~~~~~~~~
@@ -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_prefetch_modify_t prefetch_modify;
+ /**< Pointer to PMD Event port prefetch modify function. */
uint64_t reserved_64s[3]; /**< Reserved for future fields */
void *reserved_ptrs[3]; /**< Reserved for future fields */
@@ -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_prefetch_modify(__rte_unused void *port,
+ __rte_unused rte_event_dev_prefetch_type_t prefetch)
+{
+ RTE_EDEV_LOG_ERR("modify prefetch 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,
+ .prefetch_modify = dummy_event_port_prefetch_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->prefetch_modify = dev->prefetch_modify;
fp_op->data = dev->data->ports;
}
@@ -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_prefetch_modify,
+ lib.eventdev.port.prefetch.modify)
+
/* Eventdev Rx adapter trace points */
RTE_TRACE_POINT_REGISTER(rte_eventdev_trace_eth_rx_adapter_create,
lib.eventdev.rx.adapter.create)
@@ -470,6 +470,16 @@ struct rte_event;
* @see rte_event_dev_configure()
*/
+#define RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PREFETCH (1ULL << 18)
+/**< Event device supports event prefetching per event port.
+ *
+ * When this flag is set, the event device allows controlling the event
+ * prefetching/pre-scheduling at a event port granularity.
+ *
+ * @see rte_event_dev_configure()
+ * @see rte_event_port_prefetch_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_PREFETCH_NONE = 0,
/* Disable prefetch across the event device or on a given event port.
* @ref rte_event_dev_config.prefetch_type
+ * @ref rte_event_port_prefetch_modify()
*/
RTE_EVENT_DEV_PREFETCH,
/* Enable prefetch always across the event device or a given event port.
* @ref rte_event_dev_config.prefetch_type
+ * @ref rte_event_port_prefetch_modify()
* @see RTE_EVENT_DEV_CAP_EVENT_PREFETCH
+ * @see RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PREFETCH
*/
RTE_EVENT_DEV_PREFETCH_INTELLIGENT,
/* Enable intelligent prefetch across the event device or a given event port.
* Delay issuing prefetch until there are no forward progress constraints with
* the held flow contexts.
* @ref rte_event_dev_config.prefetch_type
+ * @ref rte_event_port_prefetch_modify()
* @see RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH
+ * @see RTE_EVENT_DEV_CAP_EVENT_PER_PORT_PREFETCH
*/
} rte_event_dev_prefetch_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 prefetch type to use on an event port.
+ *
+ * This function is used to change the current prefetch type configured
+ * on an event port, the prefetch type can be set to none to disable prefetching.
+ * This effects the subsequent ``rte_event_dequeue_burst`` call.
+ * The event device should support RTE_EVENT_DEV_CAP_PER_PORT_PREFETCH capability.
+ *
+ * @param dev_id
+ * The identifier of the device.
+ * @param port_id
+ * The identifier of the event port.
+ * @param type
+ * The prefetch type to use on the event port.
+ * @return
+ * - 0 on success.
+ * - -EINVAL if *dev_id*, *port_id*, or *type* is invalid.
+ * - -ENOTSUP if the device doesn't support prefetch or per port prefetch.
+ */
+static inline int
+rte_event_port_prefetch_modify(uint8_t dev_id, uint8_t port_id, rte_event_dev_prefetch_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_prefetch_modify(dev_id, port_id, type);
+
+ return fp_ops->prefetch_modify(port, type);
+}
+
#ifdef __cplusplus
}
#endif
@@ -49,6 +49,9 @@ 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_prefetch_modify_t)(void *port, rte_event_dev_prefetch_type_t prefetch_type);
+/**< @internal Modify prefetch 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 +79,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_prefetch_modify_t prefetch_modify;
+ /**< PMD Event port prefetch switch. */
uintptr_t reserved[4];
};
@@ -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_prefetch_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,
@@ -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_prefetch_modify;
+ __rte_eventdev_trace_port_prefetch_modify;
};
INTERNAL {