X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fevent%2Fdpaa2%2Fdpaa2_eventdev.c;h=ba7e5145ec50005e39dbcfc56107b298c3338e54;hb=d1eded3a8e6fa28087eef3062081a8b0f2dca222;hp=633e2a0fadbe9eda677c713d6e35e29cac5ae99f;hpb=65293784977f47ccdf5d8813a3e599068d8dae52;p=dpdk.git diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c index 633e2a0fad..ba7e5145ec 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.c +++ b/drivers/event/dpaa2/dpaa2_eventdev.c @@ -1,33 +1,7 @@ -/*- - * BSD LICENSE +/* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017 NXP. + * Copyright 2017 NXP * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of NXP nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include @@ -36,7 +10,6 @@ #include #include #include -#include #include #include @@ -51,14 +24,16 @@ #include #include #include -#include #include -#include +#include +#include +#include #include #include #include #include +#include #include "dpaa2_eventdev.h" #include #include @@ -93,7 +68,7 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); if (ret) { - PMD_DRV_LOG(ERR, PMD, "Failure in affining portal\n"); + PMD_DRV_LOG(ERR, "Failure in affining portal\n"); return 0; } } @@ -138,14 +113,23 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[], */ struct rte_event *ev_temp = rte_malloc(NULL, sizeof(struct rte_event), 0); + + if (!ev_temp) { + if (!loop) + return num_tx; + frames_to_send = loop; + PMD_DRV_LOG(ERR, "Unable to allocate memory"); + goto send_partial; + } rte_memcpy(ev_temp, event, sizeof(struct rte_event)); DPAA2_SET_FD_ADDR((&fd_arr[loop]), ev_temp); DPAA2_SET_FD_LEN((&fd_arr[loop]), sizeof(struct rte_event)); } +send_partial: loop = 0; while (loop < frames_to_send) { - loop += qbman_swp_enqueue_multiple_eqdesc(swp, + loop += qbman_swp_enqueue_multiple_desc(swp, &eqdesc[loop], &fd_arr[loop], frames_to_send - loop); } @@ -179,10 +163,9 @@ RETRY: * case to avoid the problem. */ if (errno == EINTR) { - PMD_DRV_LOG(DEBUG, PMD, "epoll_wait fails\n"); + PMD_DRV_LOG(DEBUG, "epoll_wait fails\n"); if (i++ > 10) - PMD_DRV_LOG(DEBUG, PMD, - "Dequeue burst Failed\n"); + PMD_DRV_LOG(DEBUG, "Dequeue burst Failed\n"); goto RETRY; } } @@ -191,10 +174,14 @@ RETRY: static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp, const struct qbman_fd *fd, const struct qbman_result *dq, + struct dpaa2_queue *rxq, struct rte_event *ev) { struct rte_event *ev_temp = (struct rte_event *)DPAA2_GET_FD_ADDR(fd); + + RTE_SET_USED(rxq); + rte_memcpy(ev, ev_temp, sizeof(struct rte_event)); rte_free(ev_temp); @@ -204,6 +191,7 @@ static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp, static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp, const struct qbman_fd *fd, const struct qbman_result *dq, + struct dpaa2_queue *rxq, struct rte_event *ev) { struct rte_event *ev_temp = @@ -211,6 +199,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp, uint8_t dqrr_index = qbman_get_dqrr_idx(dq); RTE_SET_USED(swp); + RTE_SET_USED(rxq); rte_memcpy(ev, ev_temp, sizeof(struct rte_event)); rte_free(ev_temp); @@ -234,7 +223,7 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], if (unlikely(!DPAA2_PER_LCORE_DPIO)) { ret = dpaa2_affine_qbman_swp(); if (ret) { - PMD_DRV_LOG(ERR, PMD, "Failure in affining portal\n"); + PMD_DRV_LOG(ERR, "Failure in affining portal\n"); return 0; } } @@ -267,10 +256,10 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], rxq = (struct dpaa2_queue *)qbman_result_DQ_fqd_ctx(dq); if (rxq) { - rxq->cb(swp, fd, dq, &ev[num_pkts]); + rxq->cb(swp, fd, dq, rxq, &ev[num_pkts]); } else { qbman_swp_dqrr_consume(swp, dq); - PMD_DRV_LOG(ERR, PMD, "Null Return VQ received\n"); + PMD_DRV_LOG(ERR, "Null Return VQ received\n"); return 0; } @@ -317,7 +306,8 @@ dpaa2_eventdev_info_get(struct rte_eventdev *dev, dev_info->max_event_port_enqueue_depth = DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH; dev_info->max_num_events = DPAA2_EVENT_MAX_NUM_EVENTS; - dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED; + dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED | + RTE_EVENT_DEV_CAP_BURST_MODE; } static int @@ -379,8 +369,8 @@ dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id, RTE_SET_USED(queue_conf); queue_conf->nb_atomic_flows = DPAA2_EVENT_QUEUE_ATOMIC_FLOWS; - queue_conf->event_queue_cfg = RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY | - RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY; + queue_conf->schedule_type = RTE_SCHED_TYPE_ATOMIC | + RTE_SCHED_TYPE_PARALLEL; queue_conf->priority = RTE_EVENT_DEV_PRIORITY_NORMAL; } @@ -552,6 +542,147 @@ dpaa2_eventdev_dump(struct rte_eventdev *dev, FILE *f) RTE_SET_USED(f); } +static int +dpaa2_eventdev_eth_caps_get(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev, + uint32_t *caps) +{ + const char *ethdev_driver = eth_dev->device->driver->name; + + PMD_DRV_FUNC_TRACE(); + + RTE_SET_USED(dev); + + if (!strcmp(ethdev_driver, "net_dpaa2")) + *caps = RTE_EVENT_ETH_RX_ADAPTER_DPAA2_CAP; + else + *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP; + + return 0; +} + +static int +dpaa2_eventdev_eth_queue_add_all(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev, + const struct rte_event_eth_rx_adapter_queue_conf *queue_conf) +{ + struct dpaa2_eventdev *priv = dev->data->dev_private; + uint8_t ev_qid = queue_conf->ev.queue_id; + uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id; + int i, ret; + + PMD_DRV_FUNC_TRACE(); + + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { + ret = dpaa2_eth_eventq_attach(eth_dev, i, + dpcon_id, queue_conf); + if (ret) { + PMD_DRV_ERR("dpaa2_eth_eventq_attach failed: ret %d\n", + ret); + goto fail; + } + } + return 0; +fail: + for (i = (i - 1); i >= 0 ; i--) + dpaa2_eth_eventq_detach(eth_dev, i); + + return ret; +} + +static int +dpaa2_eventdev_eth_queue_add(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev, + int32_t rx_queue_id, + const struct rte_event_eth_rx_adapter_queue_conf *queue_conf) +{ + struct dpaa2_eventdev *priv = dev->data->dev_private; + uint8_t ev_qid = queue_conf->ev.queue_id; + uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id; + int ret; + + PMD_DRV_FUNC_TRACE(); + + if (rx_queue_id == -1) + return dpaa2_eventdev_eth_queue_add_all(dev, + eth_dev, queue_conf); + + ret = dpaa2_eth_eventq_attach(eth_dev, rx_queue_id, + dpcon_id, queue_conf); + if (ret) { + PMD_DRV_ERR("dpaa2_eth_eventq_attach failed: ret: %d\n", ret); + return ret; + } + return 0; +} + +static int +dpaa2_eventdev_eth_queue_del_all(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev) +{ + int i, ret; + + PMD_DRV_FUNC_TRACE(); + + RTE_SET_USED(dev); + + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { + ret = dpaa2_eth_eventq_detach(eth_dev, i); + if (ret) { + PMD_DRV_ERR("dpaa2_eth_eventq_detach failed: ret %d\n", + ret); + return ret; + } + } + + return 0; +} + +static int +dpaa2_eventdev_eth_queue_del(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev, + int32_t rx_queue_id) +{ + int ret; + + PMD_DRV_FUNC_TRACE(); + + if (rx_queue_id == -1) + return dpaa2_eventdev_eth_queue_del_all(dev, eth_dev); + + ret = dpaa2_eth_eventq_detach(eth_dev, rx_queue_id); + if (ret) { + PMD_DRV_ERR("dpaa2_eth_eventq_detach failed: ret: %d\n", ret); + return ret; + } + + return 0; +} + +static int +dpaa2_eventdev_eth_start(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev) +{ + PMD_DRV_FUNC_TRACE(); + + RTE_SET_USED(dev); + RTE_SET_USED(eth_dev); + + return 0; +} + +static int +dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev, + const struct rte_eth_dev *eth_dev) +{ + PMD_DRV_FUNC_TRACE(); + + RTE_SET_USED(dev); + RTE_SET_USED(eth_dev); + + return 0; +} + static const struct rte_eventdev_ops dpaa2_eventdev_ops = { .dev_infos_get = dpaa2_eventdev_info_get, .dev_configure = dpaa2_eventdev_configure, @@ -567,7 +698,12 @@ static const struct rte_eventdev_ops dpaa2_eventdev_ops = { .port_link = dpaa2_eventdev_port_link, .port_unlink = dpaa2_eventdev_port_unlink, .timeout_ticks = dpaa2_eventdev_timeout_ticks, - .dump = dpaa2_eventdev_dump + .dump = dpaa2_eventdev_dump, + .eth_rx_adapter_caps_get = dpaa2_eventdev_eth_caps_get, + .eth_rx_adapter_queue_add = dpaa2_eventdev_eth_queue_add, + .eth_rx_adapter_queue_del = dpaa2_eventdev_eth_queue_del, + .eth_rx_adapter_start = dpaa2_eventdev_eth_start, + .eth_rx_adapter_stop = dpaa2_eventdev_eth_stop, }; static int @@ -596,7 +732,7 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev, dpci_dev->token, i, &rx_queue_cfg); if (ret) { - PMD_DRV_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "set_rx_q failed with err code: %d", ret); return ret; } @@ -622,10 +758,10 @@ dpaa2_eventdev_create(const char *name) } eventdev->dev_ops = &dpaa2_eventdev_ops; - eventdev->schedule = NULL; eventdev->enqueue = dpaa2_eventdev_enqueue; eventdev->enqueue_burst = dpaa2_eventdev_enqueue_burst; eventdev->enqueue_new_burst = dpaa2_eventdev_enqueue_burst; + eventdev->enqueue_forward_burst = dpaa2_eventdev_enqueue_burst; eventdev->dequeue = dpaa2_eventdev_dequeue; eventdev->dequeue_burst = dpaa2_eventdev_dequeue_burst; @@ -651,7 +787,7 @@ dpaa2_eventdev_create(const char *name) ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev); if (ret) { - PMD_DRV_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "dpci setup failed with err code: %d", ret); return ret; } @@ -669,7 +805,7 @@ dpaa2_eventdev_probe(struct rte_vdev_device *vdev) const char *name; name = rte_vdev_device_name(vdev); - PMD_DRV_LOG(INFO, PMD, "Initializing %s\n", name); + PMD_DRV_LOG(INFO, "Initializing %s", name); return dpaa2_eventdev_create(name); }