#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
#include <errno.h>
#include <stdint.h>
#include <inttypes.h>
-#include <sys/types.h>
-#include <sys/queue.h>
#include <rte_string_fns.h>
-#include <rte_byteorder.h>
#include <rte_log.h>
-#include <rte_debug.h>
#include <rte_dev.h>
-#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_memzone.h>
#include <rte_eal.h>
-#include <rte_per_lcore.h>
-#include <rte_lcore.h>
-#include <rte_atomic.h>
-#include <rte_branch_prediction.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_errno.h>
#include "rte_eventdev.h"
#include "eventdev_pmd.h"
-#include "rte_eventdev_trace.h"
+#include "eventdev_trace.h"
static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
.nb_devs = 0
};
+/* Public fastpath APIs. */
+struct rte_event_fp_ops rte_event_fp_ops[RTE_EVENT_MAX_DEVS];
+
/* Event dev north bound API implementation */
uint8_t
rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps)
{
struct rte_eventdev *dev;
- const struct rte_event_timer_adapter_ops *ops;
+ const struct event_timer_adapter_ops *ops;
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
if (caps == NULL)
return -EINVAL;
- *caps = 0;
+
+ if (dev->dev_ops->crypto_adapter_caps_get == NULL)
+ *caps = RTE_EVENT_CRYPTO_ADAPTER_SW_CAP;
+ else
+ *caps = 0;
return dev->dev_ops->crypto_adapter_caps_get ?
(*dev->dev_ops->crypto_adapter_caps_get)
- (dev, cdev, caps) : -ENOTSUP;
+ (dev, cdev, caps) : 0;
}
int
}
static inline int
-rte_event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
+event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
{
uint8_t old_nb_queues = dev->data->nb_queues;
struct rte_event_queue_conf *queues_cfg;
RTE_EDEV_LOG_DEBUG("Setup %d queues on device %u", nb_queues,
dev->data->dev_id);
- /* First time configuration */
- if (dev->data->queues_cfg == NULL && nb_queues != 0) {
- /* Allocate memory to store queue configuration */
- dev->data->queues_cfg = rte_zmalloc_socket(
- "eventdev->data->queues_cfg",
- sizeof(dev->data->queues_cfg[0]) * nb_queues,
- RTE_CACHE_LINE_SIZE, dev->data->socket_id);
- if (dev->data->queues_cfg == NULL) {
- dev->data->nb_queues = 0;
- RTE_EDEV_LOG_ERR("failed to get mem for queue cfg,"
- "nb_queues %u", nb_queues);
- return -(ENOMEM);
- }
- /* Re-configure */
- } else if (dev->data->queues_cfg != NULL && nb_queues != 0) {
+ if (nb_queues != 0) {
+ queues_cfg = dev->data->queues_cfg;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP);
for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->queue_release)(dev, i);
- /* Re allocate memory to store queue configuration */
- queues_cfg = dev->data->queues_cfg;
- queues_cfg = rte_realloc(queues_cfg,
- sizeof(queues_cfg[0]) * nb_queues,
- RTE_CACHE_LINE_SIZE);
- if (queues_cfg == NULL) {
- RTE_EDEV_LOG_ERR("failed to realloc queue cfg memory,"
- " nb_queues %u", nb_queues);
- return -(ENOMEM);
- }
- dev->data->queues_cfg = queues_cfg;
if (nb_queues > old_nb_queues) {
uint8_t new_qs = nb_queues - old_nb_queues;
memset(queues_cfg + old_nb_queues, 0,
sizeof(queues_cfg[0]) * new_qs);
}
- } else if (dev->data->queues_cfg != NULL && nb_queues == 0) {
+ } else {
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP);
for (i = nb_queues; i < old_nb_queues; i++)
#define EVENT_QUEUE_SERVICE_PRIORITY_INVALID (0xdead)
static inline int
-rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)
+event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)
{
uint8_t old_nb_ports = dev->data->nb_ports;
void **ports;
RTE_EDEV_LOG_DEBUG("Setup %d ports on device %u", nb_ports,
dev->data->dev_id);
- /* First time configuration */
- if (dev->data->ports == NULL && nb_ports != 0) {
- dev->data->ports = rte_zmalloc_socket("eventdev->data->ports",
- sizeof(dev->data->ports[0]) * nb_ports,
- RTE_CACHE_LINE_SIZE, dev->data->socket_id);
- if (dev->data->ports == NULL) {
- dev->data->nb_ports = 0;
- RTE_EDEV_LOG_ERR("failed to get mem for port meta data,"
- "nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
-
- /* Allocate memory to store port configurations */
- dev->data->ports_cfg =
- rte_zmalloc_socket("eventdev->ports_cfg",
- sizeof(dev->data->ports_cfg[0]) * nb_ports,
- RTE_CACHE_LINE_SIZE, dev->data->socket_id);
- if (dev->data->ports_cfg == NULL) {
- dev->data->nb_ports = 0;
- RTE_EDEV_LOG_ERR("failed to get mem for port cfg,"
- "nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
-
- /* Allocate memory to store queue to port link connection */
- dev->data->links_map =
- rte_zmalloc_socket("eventdev->links_map",
- sizeof(dev->data->links_map[0]) * nb_ports *
- RTE_EVENT_MAX_QUEUES_PER_DEV,
- RTE_CACHE_LINE_SIZE, dev->data->socket_id);
- if (dev->data->links_map == NULL) {
- dev->data->nb_ports = 0;
- RTE_EDEV_LOG_ERR("failed to get mem for port_map area,"
- "nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
- for (i = 0; i < nb_ports * RTE_EVENT_MAX_QUEUES_PER_DEV; i++)
- dev->data->links_map[i] =
- EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
- } else if (dev->data->ports != NULL && nb_ports != 0) {/* re-config */
+ if (nb_ports != 0) { /* re-config */
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_release, -ENOTSUP);
ports = dev->data->ports;
for (i = nb_ports; i < old_nb_ports; i++)
(*dev->dev_ops->port_release)(ports[i]);
- /* Realloc memory for ports */
- ports = rte_realloc(ports, sizeof(ports[0]) * nb_ports,
- RTE_CACHE_LINE_SIZE);
- if (ports == NULL) {
- RTE_EDEV_LOG_ERR("failed to realloc port meta data,"
- " nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
-
- /* Realloc memory for ports_cfg */
- ports_cfg = rte_realloc(ports_cfg,
- sizeof(ports_cfg[0]) * nb_ports,
- RTE_CACHE_LINE_SIZE);
- if (ports_cfg == NULL) {
- RTE_EDEV_LOG_ERR("failed to realloc port cfg mem,"
- " nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
-
- /* Realloc memory to store queue to port link connection */
- links_map = rte_realloc(links_map,
- sizeof(dev->data->links_map[0]) * nb_ports *
- RTE_EVENT_MAX_QUEUES_PER_DEV,
- RTE_CACHE_LINE_SIZE);
- if (links_map == NULL) {
- dev->data->nb_ports = 0;
- RTE_EDEV_LOG_ERR("failed to realloc mem for port_map,"
- "nb_ports %u", nb_ports);
- return -(ENOMEM);
- }
-
if (nb_ports > old_nb_ports) {
uint8_t new_ps = nb_ports - old_nb_ports;
unsigned int old_links_map_end =
links_map[i] =
EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
}
-
- dev->data->ports = ports;
- dev->data->ports_cfg = ports_cfg;
- dev->data->links_map = links_map;
- } else if (dev->data->ports != NULL && nb_ports == 0) {
+ } else {
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_release, -ENOTSUP);
ports = dev->data->ports;
- for (i = nb_ports; i < old_nb_ports; i++)
+ for (i = nb_ports; i < old_nb_ports; i++) {
(*dev->dev_ops->port_release)(ports[i]);
+ ports[i] = NULL;
+ }
}
dev->data->nb_ports = nb_ports;
rte_event_dev_configure(uint8_t dev_id,
const struct rte_event_dev_config *dev_conf)
{
- struct rte_eventdev *dev;
struct rte_event_dev_info info;
+ struct rte_eventdev *dev;
int diag;
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
/* Setup new number of queues and reconfigure device. */
- diag = rte_event_dev_queue_config(dev, dev_conf->nb_event_queues);
+ diag = event_dev_queue_config(dev, dev_conf->nb_event_queues);
if (diag != 0) {
- RTE_EDEV_LOG_ERR("dev%d rte_event_dev_queue_config = %d",
- dev_id, diag);
+ RTE_EDEV_LOG_ERR("dev%d event_dev_queue_config = %d", dev_id,
+ diag);
return diag;
}
/* Setup new number of ports and reconfigure device. */
- diag = rte_event_dev_port_config(dev, dev_conf->nb_event_ports);
+ diag = event_dev_port_config(dev, dev_conf->nb_event_ports);
if (diag != 0) {
- rte_event_dev_queue_config(dev, 0);
- RTE_EDEV_LOG_ERR("dev%d rte_event_dev_port_config = %d",
- dev_id, diag);
+ event_dev_queue_config(dev, 0);
+ RTE_EDEV_LOG_ERR("dev%d event_dev_port_config = %d", dev_id,
+ diag);
return diag;
}
+ event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
+
/* Configure the device */
diag = (*dev->dev_ops->dev_configure)(dev);
if (diag != 0) {
RTE_EDEV_LOG_ERR("dev%d dev_configure = %d", dev_id, diag);
- rte_event_dev_queue_config(dev, 0);
- rte_event_dev_port_config(dev, 0);
+ event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
+ event_dev_queue_config(dev, 0);
+ event_dev_port_config(dev, 0);
}
dev->data->event_dev_cap = info.event_dev_cap;
return 0;
}
+void
+rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id,
+ rte_eventdev_port_flush_t release_cb, void *args)
+{
+ struct rte_eventdev *dev;
+
+ RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id);
+ dev = &rte_eventdevs[dev_id];
+
+ if (!is_valid_port(dev, port_id)) {
+ RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
+ return;
+ }
+
+ if (dev->dev_ops->port_quiesce)
+ (*dev->dev_ops->port_quiesce)(dev, dev->data->ports[port_id],
+ release_cb, args);
+}
+
int
rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
uint32_t *attr_value)
*attr_value = conf->schedule_type;
break;
+ case RTE_EVENT_QUEUE_ATTR_WEIGHT:
+ *attr_value = RTE_EVENT_QUEUE_WEIGHT_LOWEST;
+ if (dev->dev_ops->queue_attr_get)
+ return (*dev->dev_ops->queue_attr_get)(
+ dev, queue_id, attr_id, attr_value);
+ break;
+ case RTE_EVENT_QUEUE_ATTR_AFFINITY:
+ *attr_value = RTE_EVENT_QUEUE_AFFINITY_LOWEST;
+ if (dev->dev_ops->queue_attr_get)
+ return (*dev->dev_ops->queue_attr_get)(
+ dev, queue_id, attr_id, attr_value);
+ break;
default:
return -EINVAL;
};
return 0;
}
+int
+rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
+ uint64_t attr_value)
+{
+ struct rte_eventdev *dev;
+
+ RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+ dev = &rte_eventdevs[dev_id];
+ if (!is_valid_queue(dev, queue_id)) {
+ RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
+ return -EINVAL;
+ }
+
+ if (!(dev->data->event_dev_cap &
+ RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
+ RTE_EDEV_LOG_ERR(
+ "Device %" PRIu8 "does not support changing queue attributes at runtime",
+ dev_id);
+ return -ENOTSUP;
+ }
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -ENOTSUP);
+ return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
+ attr_value);
+}
+
int
rte_event_port_link(uint8_t dev_id, uint8_t port_id,
const uint8_t queues[], const uint8_t priorities[],
else
return diag;
+ event_dev_fp_ops_set(rte_event_fp_ops + dev_id, dev);
+
return 0;
}
dev->data->dev_started = 0;
(*dev->dev_ops->dev_stop)(dev);
rte_eventdev_trace_stop(dev_id);
+ event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
}
int
return -EBUSY;
}
+ event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
rte_eventdev_trace_close(dev_id);
return (*dev->dev_ops->dev_close)(dev);
}
static inline int
-rte_eventdev_data_alloc(uint8_t dev_id, struct rte_eventdev_data **data,
- int socket_id)
+eventdev_data_alloc(uint8_t dev_id, struct rte_eventdev_data **data,
+ int socket_id)
{
char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
const struct rte_memzone *mz;
return -ENOMEM;
*data = mz->addr;
- if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
memset(*data, 0, sizeof(struct rte_eventdev_data));
+ for (n = 0; n < RTE_EVENT_MAX_PORTS_PER_DEV *
+ RTE_EVENT_MAX_QUEUES_PER_DEV;
+ n++)
+ (*data)->links_map[n] =
+ EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
+ }
return 0;
}
static inline uint8_t
-rte_eventdev_find_free_device_index(void)
+eventdev_find_free_device_index(void)
{
uint8_t dev_id;
return RTE_EVENT_MAX_DEVS;
}
-static uint16_t
-rte_event_tx_adapter_enqueue(__rte_unused void *port,
- __rte_unused struct rte_event ev[],
- __rte_unused uint16_t nb_events)
-{
- rte_errno = ENOTSUP;
- return 0;
-}
-
-static uint16_t
-rte_event_crypto_adapter_enqueue(__rte_unused void *port,
- __rte_unused struct rte_event ev[],
- __rte_unused uint16_t nb_events)
-{
- rte_errno = ENOTSUP;
- return 0;
-}
-
struct rte_eventdev *
rte_event_pmd_allocate(const char *name, int socket_id)
{
return NULL;
}
- dev_id = rte_eventdev_find_free_device_index();
+ dev_id = eventdev_find_free_device_index();
if (dev_id == RTE_EVENT_MAX_DEVS) {
RTE_EDEV_LOG_ERR("Reached maximum number of event devices");
return NULL;
eventdev = &rte_eventdevs[dev_id];
- eventdev->txa_enqueue = rte_event_tx_adapter_enqueue;
- eventdev->txa_enqueue_same_dest = rte_event_tx_adapter_enqueue;
- eventdev->ca_enqueue = rte_event_crypto_adapter_enqueue;
-
if (eventdev->data == NULL) {
struct rte_eventdev_data *eventdev_data = NULL;
- int retval = rte_eventdev_data_alloc(dev_id, &eventdev_data,
- socket_id);
+ int retval =
+ eventdev_data_alloc(dev_id, &eventdev_data, socket_id);
if (retval < 0 || eventdev_data == NULL)
return NULL;
if (eventdev == NULL)
return -EINVAL;
+ event_dev_fp_ops_reset(rte_event_fp_ops + eventdev->data->dev_id);
eventdev->attached = RTE_EVENTDEV_DETACHED;
eventdev_globals.nb_devs--;
return 0;
}
+void
+event_dev_probing_finish(struct rte_eventdev *eventdev)
+{
+ if (eventdev == NULL)
+ return;
+
+ event_dev_fp_ops_set(rte_event_fp_ops + eventdev->data->dev_id,
+ eventdev);
+}
static int
handle_dev_list(const char *cmd __rte_unused,