X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fevent%2Fopdl%2Fopdl_evdev.c;h=d2d2be44b5180338a406f21f95df35e87b9e5e2c;hb=6a1bc531ac6b8fcd101ea42d4a419f92655f7087;hp=11ac8fc0a0ffeb85a490e51f39cd8a531132d564;hpb=8ca8e3b48eff93325341d11f0fcbf561da81ffaa;p=dpdk.git diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c index 11ac8fc0a0..d2d2be44b5 100644 --- a/drivers/event/opdl/opdl_evdev.c +++ b/drivers/event/opdl/opdl_evdev.c @@ -1,6 +1,5 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Intel Corporation */ #include @@ -26,6 +25,211 @@ static void opdl_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info); +uint16_t +opdl_event_enqueue_burst(void *port, + const struct rte_event ev[], + uint16_t num) +{ + struct opdl_port *p = port; + + if (unlikely(!p->opdl->data->dev_started)) + return 0; + + + /* either rx_enqueue or disclaim*/ + return p->enq(p, ev, num); +} + +uint16_t +opdl_event_enqueue(void *port, const struct rte_event *ev) +{ + struct opdl_port *p = port; + + if (unlikely(!p->opdl->data->dev_started)) + return 0; + + + return p->enq(p, ev, 1); +} + +uint16_t +opdl_event_dequeue_burst(void *port, + struct rte_event *ev, + uint16_t num, + uint64_t wait) +{ + struct opdl_port *p = (void *)port; + + RTE_SET_USED(wait); + + if (unlikely(!p->opdl->data->dev_started)) + return 0; + + /* This function pointer can point to tx_dequeue or claim*/ + return p->deq(p, ev, num); +} + +uint16_t +opdl_event_dequeue(void *port, + struct rte_event *ev, + uint64_t wait) +{ + struct opdl_port *p = (void *)port; + + if (unlikely(!p->opdl->data->dev_started)) + return 0; + + RTE_SET_USED(wait); + + return p->deq(p, ev, 1); +} + +static int +opdl_port_link(struct rte_eventdev *dev, + void *port, + const uint8_t queues[], + const uint8_t priorities[], + uint16_t num) +{ + struct opdl_port *p = port; + + RTE_SET_USED(priorities); + RTE_SET_USED(dev); + + if (unlikely(dev->data->dev_started)) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "Attempt to link queue (%u) to port %d while device started\n", + dev->data->dev_id, + queues[0], + p->id); + rte_errno = -EINVAL; + return 0; + } + + /* Max of 1 queue per port */ + if (num > 1) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "Attempt to link more than one queue (%u) to port %d requested\n", + dev->data->dev_id, + num, + p->id); + rte_errno = -EDQUOT; + return 0; + } + + if (!p->configured) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "port %d not configured, cannot link to %u\n", + dev->data->dev_id, + p->id, + queues[0]); + rte_errno = -EINVAL; + return 0; + } + + if (p->external_qid != OPDL_INVALID_QID) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "port %d already linked to queue %u, cannot link to %u\n", + dev->data->dev_id, + p->id, + p->external_qid, + queues[0]); + rte_errno = -EINVAL; + return 0; + } + + p->external_qid = queues[0]; + + return 1; +} + +static int +opdl_port_unlink(struct rte_eventdev *dev, + void *port, + uint8_t queues[], + uint16_t nb_unlinks) +{ + struct opdl_port *p = port; + + RTE_SET_USED(queues); + RTE_SET_USED(nb_unlinks); + + if (unlikely(dev->data->dev_started)) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "Attempt to unlink queue (%u) to port %d while device started\n", + dev->data->dev_id, + queues[0], + p->id); + rte_errno = -EINVAL; + return 0; + } + RTE_SET_USED(nb_unlinks); + + /* Port Stuff */ + p->queue_id = OPDL_INVALID_QID; + p->p_type = OPDL_INVALID_PORT; + p->external_qid = OPDL_INVALID_QID; + + /* always unlink 0 queue due to statice pipeline */ + return 0; +} + +static int +opdl_port_setup(struct rte_eventdev *dev, + uint8_t port_id, + const struct rte_event_port_conf *conf) +{ + struct opdl_evdev *device = opdl_pmd_priv(dev); + struct opdl_port *p = &device->ports[port_id]; + + RTE_SET_USED(conf); + + /* Check if port already configured */ + if (p->configured) { + PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " + "Attempt to setup port %d which is already setup\n", + dev->data->dev_id, + p->id); + return -EDQUOT; + } + + *p = (struct opdl_port){0}; /* zero entire structure */ + p->id = port_id; + p->opdl = device; + p->queue_id = OPDL_INVALID_QID; + p->external_qid = OPDL_INVALID_QID; + dev->data->ports[port_id] = p; + rte_smp_wmb(); + p->configured = 1; + device->nb_ports++; + return 0; +} + +static void +opdl_port_release(void *port) +{ + struct opdl_port *p = (void *)port; + + if (p == NULL || + p->opdl->data->dev_started) { + return; + } + + p->configured = 0; + p->initialized = 0; +} + +static void +opdl_port_def_conf(struct rte_eventdev *dev, uint8_t port_id, + struct rte_event_port_conf *port_conf) +{ + RTE_SET_USED(dev); + RTE_SET_USED(port_id); + + port_conf->new_event_threshold = MAX_OPDL_CONS_Q_DEPTH; + port_conf->dequeue_depth = MAX_OPDL_CONS_Q_DEPTH; + port_conf->enqueue_depth = MAX_OPDL_CONS_Q_DEPTH; +} static int opdl_queue_setup(struct rte_eventdev *dev, @@ -83,7 +287,8 @@ opdl_queue_setup(struct rte_eventdev *dev, } } /* Check if queue id has been setup already */ - for (uint32_t i = 0; i < device->nb_q_md; i++) { + uint32_t i; + for (i = 0; i < device->nb_q_md; i++) { if (device->q_md[i].ext_id == queue_id) { PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : " "queue id %u already setup\n", @@ -185,8 +390,8 @@ opdl_dump(struct rte_eventdev *dev, FILE *f) fprintf(f, "\n\n -- RING STATISTICS --\n"); - - for (uint32_t i = 0; i < device->nb_opdls; i++) + uint32_t i; + for (i = 0; i < device->nb_opdls; i++) opdl_ring_dump(device->opdl[i], f); fprintf(f, @@ -195,7 +400,7 @@ opdl_dump(struct rte_eventdev *dev, FILE *f) "Av. Grant Size Av. Cycles PP" " Empty DEQs Non Empty DEQs Pkts Processed\n"); - for (uint32_t i = 0; i < device->max_port_nb; i++) { + for (i = 0; i < device->max_port_nb; i++) { char queue_id[64]; char total_cyc[64]; const char *p_type; @@ -217,16 +422,17 @@ opdl_dump(struct rte_eventdev *dev, FILE *f) else p_type = "????"; - sprintf(queue_id, "%02u", port->external_qid); + snprintf(queue_id, sizeof(queue_id), "%02u", + port->external_qid); if (port->p_type == OPDL_REGULAR_PORT || port->p_type == OPDL_ASYNC_PORT) - sprintf(total_cyc, + snprintf(total_cyc, sizeof(total_cyc), " %'16"PRIu64"", (cpg != 0 ? port->port_stat[total_cycles] / cpg : 0)); else - sprintf(total_cyc, + snprintf(total_cyc, sizeof(total_cyc), " ----"); fprintf(f, "%4s %10u %8u %9s %'16"PRIu64" %'16"PRIu64" %s " @@ -402,7 +608,7 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque) static int opdl_probe(struct rte_vdev_device *vdev) { - static const struct rte_eventdev_ops evdev_opdl_ops = { + static struct rte_eventdev_ops evdev_opdl_ops = { .dev_configure = opdl_dev_configure, .dev_infos_get = opdl_info_get, .dev_close = opdl_close, @@ -413,6 +619,12 @@ opdl_probe(struct rte_vdev_device *vdev) .queue_def_conf = opdl_queue_def_conf, .queue_setup = opdl_queue_setup, .queue_release = opdl_queue_release, + .port_def_conf = opdl_port_def_conf, + .port_setup = opdl_port_setup, + .port_release = opdl_port_release, + .port_link = opdl_port_link, + .port_unlink = opdl_port_unlink, + .xstats_get = opdl_xstats_get, .xstats_get_names = opdl_xstats_get_names, @@ -499,6 +711,13 @@ opdl_probe(struct rte_vdev_device *vdev) dev->dev_ops = &evdev_opdl_ops; + dev->enqueue = opdl_event_enqueue; + dev->enqueue_burst = opdl_event_enqueue_burst; + dev->enqueue_new_burst = opdl_event_enqueue_burst; + dev->enqueue_forward_burst = opdl_event_enqueue_burst; + dev->dequeue = opdl_event_dequeue; + dev->dequeue_burst = opdl_event_dequeue_burst; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; @@ -510,6 +729,9 @@ opdl_probe(struct rte_vdev_device *vdev) str_len = strlen(name); memcpy(opdl->service_name, name, str_len); + if (do_test == 1) + test_result = opdl_selftest(); + return test_result; } @@ -532,12 +754,9 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = { .remove = opdl_remove }; -RTE_INIT(opdl_init_log); - -static void -opdl_init_log(void) +RTE_INIT(opdl_init_log) { - opdl_logtype_driver = rte_log_register("eventdev.opdl.driver"); + opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver"); if (opdl_logtype_driver >= 0) rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO); }