From patchwork Wed Jul 6 07:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Kumar X-Patchwork-Id: 113728 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 077D1A0540; Wed, 6 Jul 2022 09:57:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73C3542B7D; Wed, 6 Jul 2022 09:56:38 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 3013142847 for ; Wed, 6 Jul 2022 09:56:37 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id p9so2863417plr.11 for ; Wed, 06 Jul 2022 00:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vvdntech-in.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xkCQppoRn6XXp9EYxbVqDV/o+ddHJQiEiBSrKEcDVkk=; b=hdv5ktiRRHDR6cyq15BX2Rv0lv/YLeL8zV2u6tBgWfzfbD2DYf+ve16SfYZCPwRRgR 7rM/LH3tlhQKf8CQsTz6EAwICj6I72zxKHnEINwjmmd2GGQTiSI+PomaCJDa9J7WwHeZ 2mCwvJ+5KHV3EApuFL3UB7y0SlcJr+PE6UYMwYFWe22zNiWMdSCSZ+zMfq/qrwShiiXe B4CR2EfNAC04Iqxgc3M8LDM2dbSPHdPt3TIgmZYVHm1uUIAZMMCFHIKItHtZ+T1zsiE2 EE4tIiX7w07mTrOAClWMK6fSh31sFTfELLn7Ragr2jLPRnzE5cDbmBlP4bQoOc4dKthq d7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xkCQppoRn6XXp9EYxbVqDV/o+ddHJQiEiBSrKEcDVkk=; b=QM9kuA1+KDJyCzvDnP13ZFD3zqb/l1pBd9PvzWXlF9End5Y4Zc4xCHZg/N/4CiC7ij wQB9ht9sG2wxyheNlwOqvsWMsZgu+H7AKA8DTxo1wUGXHiziZWESCUEgl5fv9qIG/uzC 4Lh3qsWN6Rs0ErI4xMGc1Pl7ItX11Pg+mZ+mVKvHerJeHq2JKxD9Jgvb7YdgTVFGIjyx 337tfAU4326yK4K15DCV0IOklXjaJGPCHyOhvsMpOPbFyr8JJNB52gWvfP+xCWCvEPvp x4gE7sR6ePUMqx6MITa519lu219MuIZ4HiK1hbNoyDZ2+9+xadbgmix42kdYpqVygiLc 7/fw== X-Gm-Message-State: AJIora9g5dmKygC6X2Q3PLrVDvtQtB+WOjDClmhANBYyn2L6Sj9GdNIo BupCh57KkwNYiBhK+41B7NoGHGEUYjCqfuUN X-Google-Smtp-Source: AGRyM1vVn0h7EvWKe6uRrSowpEgxtwlXRTwGmbuDlxom77X0LYPJvMcKv6DeGTU8KA9gfYmmzfRVgQ== X-Received: by 2002:a17:902:934c:b0:167:80c6:aedd with SMTP id g12-20020a170902934c00b0016780c6aeddmr47282775plp.97.1657094195725; Wed, 06 Jul 2022 00:56:35 -0700 (PDT) Received: from 470--5GDC--BLR.blore.vvdntech.com ([106.51.39.131]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001ef81574355sm7378805pjg.12.2022.07.06.00.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 00:56:35 -0700 (PDT) From: Aman Kumar To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, david.marchand@redhat.com, aman.kumar@vvdntech.in Subject: [RFC PATCH 10/29] net/qdma: add net PMD ops template Date: Wed, 6 Jul 2022 13:22:00 +0530 Message-Id: <20220706075219.517046-11-aman.kumar@vvdntech.in> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706075219.517046-1-aman.kumar@vvdntech.in> References: <20220706075219.517046-1-aman.kumar@vvdntech.in> MIME-Version: 1.0 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 define dpdk pmd ops function for the device. routines are added as dummy calls. Signed-off-by: Aman Kumar --- drivers/net/qdma/meson.build | 5 +- drivers/net/qdma/qdma.h | 1 + drivers/net/qdma/qdma_devops.c | 464 ++++++++++++++++++++++++++++++ drivers/net/qdma/qdma_devops.h | 486 ++++++++++++++++++++++++++++++++ drivers/net/qdma/qdma_ethdev.c | 11 +- drivers/net/qdma/rte_pmd_qdma.h | 8 +- 6 files changed, 970 insertions(+), 5 deletions(-) create mode 100644 drivers/net/qdma/qdma_devops.c create mode 100644 drivers/net/qdma/qdma_devops.h diff --git a/drivers/net/qdma/meson.build b/drivers/net/qdma/meson.build index 99076e1ebf..858d981002 100644 --- a/drivers/net/qdma/meson.build +++ b/drivers/net/qdma/meson.build @@ -17,9 +17,12 @@ includes += include_directories('qdma_access/qdma_soft_access') includes += include_directories('qdma_access/eqdma_soft_access') includes += include_directories('qdma_access/qdma_s80_hard_access') +headers += files('rte_pmd_qdma.h') + sources = files( - 'qdma_ethdev.c', 'qdma_common.c', + 'qdma_devops.c', + 'qdma_ethdev.c', 'qdma_access/eqdma_soft_access/eqdma_soft_access.c', 'qdma_access/eqdma_soft_access/eqdma_soft_reg_dump.c', 'qdma_access/qdma_s80_hard_access/qdma_s80_hard_access.c', diff --git a/drivers/net/qdma/qdma.h b/drivers/net/qdma/qdma.h index 7c2d3b34e0..f4155380f9 100644 --- a/drivers/net/qdma/qdma.h +++ b/drivers/net/qdma/qdma.h @@ -248,6 +248,7 @@ struct qdma_pci_dev { int16_t rx_qid_statid_map[RTE_ETHDEV_QUEUE_STAT_CNTRS]; }; +void qdma_dev_ops_init(struct rte_eth_dev *dev); int qdma_identify_bars(struct rte_eth_dev *dev); int qdma_get_hw_version(struct rte_eth_dev *dev); diff --git a/drivers/net/qdma/qdma_devops.c b/drivers/net/qdma/qdma_devops.c new file mode 100644 index 0000000000..cf3ef6de34 --- /dev/null +++ b/drivers/net/qdma/qdma_devops.c @@ -0,0 +1,464 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017-2022 Xilinx, Inc. All rights reserved. + * Copyright(c) 2022 VVDN Technologies Private Limited. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qdma.h" +#include "qdma_access_common.h" +#include "qdma_reg_dump.h" +#include "qdma_platform.h" +#include "qdma_devops.h" + +/** + * DPDK callback to configure a RX queue. + * + * @param dev + * Pointer to Ethernet device structure. + * @param rx_queue_id + * RX queue index. + * @param nb_rx_desc + * Number of descriptors to configure in queue. + * @param socket_id + * NUMA socket on which memory must be allocated. + * @param[in] rx_conf + * Thresholds parameters. + * @param mp_pool + * Memory pool for buffer allocations. + * + * @return + * 0 on success, + * -ENOMEM when memory allocation fails + * -ENOTSUP when HW doesn't support the required configuration + * -EINVAL on other failure. + */ +int qdma_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mb_pool) +{ + (void)dev; + (void)rx_queue_id; + (void)nb_rx_desc; + (void)socket_id; + (void)rx_conf; + (void)mb_pool; + + return 0; +} + +/** + * DPDK callback to configure a TX queue. + * + * @param dev + * Pointer to Ethernet device structure. + * @param tx_queue_id + * TX queue index. + * @param nb_tx_desc + * Number of descriptors to configure in queue. + * @param socket_id + * NUMA socket on which memory must be allocated. + * @param[in] tx_conf + * Thresholds parameters. + * + * @return + * 0 on success + * -ENOMEM when memory allocation fails + * -EINVAL on other failure. + */ +int qdma_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, + uint16_t nb_tx_desc, unsigned int socket_id, + const struct rte_eth_txconf *tx_conf) +{ + (void)dev; + (void)tx_queue_id; + (void)nb_tx_desc; + (void)socket_id; + (void)tx_conf; + + return 0; +} + +void qdma_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_id) +{ + (void)dev; + (void)q_id; +} + +void qdma_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t q_id) +{ + (void)dev; + (void)q_id; +} + +/** + * DPDK callback to start the device. + * + * Start the device by configuring the Rx/Tx descriptor and device registers. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, negative errno value on failure. + */ +int qdma_dev_start(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +/** + * DPDK callback to retrieve the physical link information. + * + * @param dev + * Pointer to Ethernet device structure. + * @param wait_to_complete + * wait_to_complete field is ignored. + */ +int qdma_dev_link_update(struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +{ + dev->data->dev_link.link_status = RTE_ETH_LINK_UP; + dev->data->dev_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; + dev->data->dev_link.link_speed = RTE_ETH_SPEED_NUM_25G; + PMD_DRV_LOG(INFO, "Link update done\n"); + return 0; +} + +/** + * DPDK callback to get information about the device. + * + * @param dev + * Pointer to Ethernet device structure. + * @param[out] dev_info + * Device information structure output buffer. + */ +int qdma_dev_infos_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info) +{ + struct qdma_pci_dev *qdma_dev = dev->data->dev_private; + + dev_info->max_rx_queues = qdma_dev->dev_cap.num_qs; + dev_info->max_tx_queues = qdma_dev->dev_cap.num_qs; + + dev_info->min_rx_bufsize = 256; + dev_info->max_rx_pktlen = DMA_BRAM_SIZE; + dev_info->max_mac_addrs = 1; + + return 0; +} + +/** + * DPDK callback to stop the device. + * + * Stop the device by clearing all configured Rx/Tx queue + * descriptors and registers. + * + * @param dev + * Pointer to Ethernet device structure. + */ +int qdma_dev_stop(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +/** + * DPDK callback to close the device. + * + * Destroy all queues and objects, free memory. + * + * @param dev + * Pointer to Ethernet device structure. + */ +int qdma_dev_close(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +/** + * DPDK callback to reset the device. + * + * Uninitialze PF device after waiting for all its VFs to shutdown. + * Initialize back PF device and then send Reset done mailbox + * message to all its VFs to come online again. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, negative errno value on failure. + */ +int qdma_dev_reset(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +/** + * DPDK callback for Ethernet device configuration. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, negative errno value on failure. + */ +int qdma_dev_configure(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +int qdma_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qid) +{ + (void)dev; + (void)qid; + + return 0; +} + + +int qdma_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t qid) +{ + (void)dev; + (void)qid; + + return 0; +} + +int qdma_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qid) +{ + (void)dev; + (void)qid; + + return 0; +} + +int qdma_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qid) +{ + (void)dev; + (void)qid; + + return 0; +} + +/** + * DPDK callback to retrieve device registers and + * register attributes (number of registers and register size) + * + * @param dev + * Pointer to Ethernet device structure. + * @param regs + * Pointer to rte_dev_reg_info structure to fill in. If regs->data is + * NULL the function fills in the width and length fields. If non-NULL + * the registers are put into the buffer pointed at by the data field. + * + * @return + * 0 on success, -ENOTSUP on failure. + */ +int +qdma_dev_get_regs(struct rte_eth_dev *dev, + struct rte_dev_reg_info *regs) +{ + (void)dev; + (void)regs; + + return -ENOTSUP; +} + +/** + * DPDK callback to set a queue statistics mapping for + * a tx/rx queue of an Ethernet device. + * + * @param dev + * Pointer to Ethernet device structure. + * @param queue_id + * Index of the queue for which a queue stats mapping is required. + * @param stat_idx + * The per-queue packet statistics functionality number that + * the queue_id is to be assigned. + * @param is_rx + * Whether queue is a Rx or a Tx queue. + * + * @return + * 0 on success, -EINVAL on failure. + */ +int qdma_dev_queue_stats_mapping(struct rte_eth_dev *dev, + uint16_t queue_id, + uint8_t stat_idx, + uint8_t is_rx) +{ + (void)dev; + (void)queue_id; + (void)stat_idx; + (void)is_rx; + + return 0; +} + +/** + * DPDK callback for retrieving Port statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * @param eth_stats + * Pointer to structure containing statistics. + * + * @return + * Returns 0 i.e. success + */ +int qdma_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *eth_stats) +{ + (void)dev; + (void)eth_stats; + + return 0; +} + +/** + * DPDK callback to reset Port statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * + */ +int qdma_dev_stats_reset(struct rte_eth_dev *dev) +{ + (void)dev; + + return 0; +} + +/** + * DPDK callback to get Rx Queue info of an Ethernet device. + * + * @param dev + * Pointer to Ethernet device structure. + * @param rx_queue_id + * The RX queue on the Ethernet device for which information will be + * retrieved + * @param qinfo + * A pointer to a structure of type rte_eth_rxq_info_info to be filled with + * the information of given Rx queue. + */ +void +qdma_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, + struct rte_eth_rxq_info *qinfo) +{ + (void)dev; + (void)rx_queue_id; + (void)qinfo; +} + +/** + * DPDK callback to get Tx Queue info of an Ethernet device. + * + * @param dev + * Pointer to Ethernet device structure. + * @param tx_queue_id + * The TX queue on the Ethernet device for which information will be + * retrieved + * @param qinfo + * A pointer to a structure of type rte_eth_txq_info_info to be filled with + * the information of given Tx queue. + */ +void +qdma_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id, + struct rte_eth_txq_info *qinfo) +{ + struct qdma_tx_queue *txq = NULL; + + if (!qinfo) + return; + + txq = dev->data->tx_queues[tx_queue_id]; + qinfo->conf.offloads = txq->offloads; + qinfo->conf.tx_deferred_start = txq->tx_deferred_start; + qinfo->conf.tx_rs_thresh = 0; + qinfo->nb_desc = txq->nb_tx_desc - 1; +} + +int qdma_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) +{ + (void)tx_queue; + (void)free_cnt; + + return 0; +} + +static struct eth_dev_ops qdma_eth_dev_ops = { + .dev_configure = qdma_dev_configure, + .dev_infos_get = qdma_dev_infos_get, + .dev_start = qdma_dev_start, + .dev_stop = qdma_dev_stop, + .dev_close = qdma_dev_close, + .dev_reset = qdma_dev_reset, + .link_update = qdma_dev_link_update, + .rx_queue_setup = qdma_dev_rx_queue_setup, + .tx_queue_setup = qdma_dev_tx_queue_setup, + .rx_queue_release = qdma_dev_rx_queue_release, + .tx_queue_release = qdma_dev_tx_queue_release, + .rx_queue_start = qdma_dev_rx_queue_start, + .rx_queue_stop = qdma_dev_rx_queue_stop, + .tx_queue_start = qdma_dev_tx_queue_start, + .tx_queue_stop = qdma_dev_tx_queue_stop, + .tx_done_cleanup = qdma_dev_tx_done_cleanup, + .queue_stats_mapping_set = qdma_dev_queue_stats_mapping, + .get_reg = qdma_dev_get_regs, + .stats_get = qdma_dev_stats_get, + .stats_reset = qdma_dev_stats_reset, + .rxq_info_get = qdma_dev_rxq_info_get, + .txq_info_get = qdma_dev_txq_info_get, +}; + +uint16_t qdma_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + (void)rx_queue; + (void)rx_pkts; + (void)nb_pkts; + + return 0; +} + +uint16_t qdma_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + (void)tx_queue; + (void)tx_pkts; + (void)nb_pkts; + + return 0; +} + +void qdma_dev_ops_init(struct rte_eth_dev *dev) +{ + dev->dev_ops = &qdma_eth_dev_ops; + dev->rx_pkt_burst = &qdma_recv_pkts; + dev->tx_pkt_burst = &qdma_xmit_pkts; +} diff --git a/drivers/net/qdma/qdma_devops.h b/drivers/net/qdma/qdma_devops.h new file mode 100644 index 0000000000..240fa6b60c --- /dev/null +++ b/drivers/net/qdma/qdma_devops.h @@ -0,0 +1,486 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017-2022 Xilinx, Inc. All rights reserved. + * Copyright(c) 2022 VVDN Technologies Private Limited. All rights reserved. + */ + +#ifndef __QDMA_DEVOPS_H__ +#define __QDMA_DEVOPS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup dpdk_devops_func Functions + */ + +/** + * DPDK callback for Ethernet device configuration. + * + * This API requests the queue base from Queue Resource Manager and programs + * the queue base and queue count in function map (FMAP) + * + * @param dev Pointer to Ethernet device structure + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_configure(struct rte_eth_dev *dev); + +/** + * DPDK callback to get information about the device + * + * @param dev Pointer to Ethernet device structure + * @param dev_info: Pointer to Device information structure + * + * @ingroup dpdk_devops_func + */ +int qdma_dev_infos_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info); + +/** + * DPDK callback to retrieve the physical link information + * + * @param dev + * Pointer to Ethernet device structure + * @param wait_to_complete + * wait_to_complete field is ignored + * + * @ingroup dpdk_devops_func + */ +int qdma_dev_link_update(struct rte_eth_dev *dev, + __rte_unused int wait_to_complete); + +/** + * DPDK callback to configure a RX queue. + * + * This API validates queue parameters and allocates C2H ring and + * Streaming CMPT ring from the DPDK reserved hugepage memory zones + * + * @param dev Pointer to Ethernet device structure. + * @param rx_queue_id RX queue index relative to the PCIe function + * pointed by dev + * @param nb_rx_desc Number of C2H descriptors to configure for this queue + * @param socket_id NUMA socket on which memory must be allocated + * @param rx_conf Rx queue configuration parameters + * @param mb_pool Memory pool to use for buffer allocations on this queue + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mb_pool); + +/** + * DPDK callback to configure a TX queue. + * + * This API validates queue parameters and allocates H2C ring from the + * DPDK reserved hugepage memory zone + * + * @param dev Pointer to Ethernet device structure + * @param tx_queue_id TX queue index + * @param nb_tx_desc Number of descriptors to configure in queue + * @param socket_id NUMA socket on which memory must be allocated + * @param tx_conf Tx queue configuration parameters + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, + uint16_t nb_tx_desc, unsigned int socket_id, + const struct rte_eth_txconf *tx_conf); + +/** + * DPDK callback to get Rx queue info of an Ethernet device + * + * @param dev + * Pointer to Ethernet device structure + * @param rx_queue_id + * The RX queue on the Ethernet device for which information will be + * retrieved + * @param qinfo + * A pointer to a structure of type rte_eth_rxq_info_info to be filled with + * the information of given Rx queue + * + * @ingroup dpdk_devops_func + */ +void +qdma_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, + struct rte_eth_rxq_info *qinfo); + +/** + * DPDK callback to get Tx queue info of an Ethernet device + * + * @param dev + * Pointer to Ethernet device structure + * @param tx_queue_id + * The TX queue on the Ethernet device for which information will be + * retrieved + * @param qinfo + * A pointer to a structure of type rte_eth_txq_info_info to be filled with + * the information of given Tx queue + * + * @ingroup dpdk_devops_func + */ +void +qdma_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id, + struct rte_eth_txq_info *qinfo); + +/** + * DPDK callback to start the device. + * + * This API starts the Ethernet device by initializing Rx, Tx descriptors + * and device registers. For the Port queues whose start is not deferred, + * it calls qdma_dev_tx_queue_start and qdma_dev_rx_queue_start to start + * the queues for packet processing. + * + * @param dev Pointer to Ethernet device structure + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_start(struct rte_eth_dev *dev); + +/** + * DPDK callback to start a C2H queue which has been deferred start. + * + * This API clears and then programs the Software, Prefetch and + * Completion context of the C2H queue + * + * @param dev Pointer to Ethernet device structure + * @param qid Rx queue index + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t qid); + +/** + * DPDK callback to start a H2C queue which has been deferred start. + * + * This API clears and then programs the Software context of the H2C queue + * + * @param dev Pointer to Ethernet device structure + * @param qid Tx queue index + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qid); + +/** + * DPDK callback for receiving packets in burst. + * + * This API does following operations: + * - Process the Completion ring to determine and store packet information + * - Update CMPT CIDX + * - Process C2H ring to retrieve rte_mbuf pointers corresponding to + * received packets and store in rx_pkts array. + * - Populate C2H ring with new pointers for packet buffers + * - Update C2H ring PIDX + * + * @param rx_queue Generic pointer to Rx queue structure + * @param rx_pkts The address of an array of pointers to rte_mbuf structures + * that must be large enough to store nb_pkts pointers in it + * @param nb_pkts Maximum number of packets to retrieve + * + * @return Number of packets successfully received (<= nb_pkts) + * @ingroup dpdk_devops_func + * + */ +uint16_t qdma_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); + +/** + * DPDK callback for transmitting packets in burst. + * + * This API does following operations: + * - Free rte_mbuf pointers to previous transmitted packets, + * back to the memory pool + * - Retrieve packet buffer pointer from tx_pkts and populate H2C ring + * with pointers to new packet buffers. + * - Update H2C ring PIDX + * + * @param tx_queue Generic pointer to Tx queue structure + * @param tx_pkts The address of an array of nb_pkts pointers to + * rte_mbuf structures which contain the output packets + * @param nb_pkts The maximum number of packets to transmit + * + * @return Number of packets successfully transmitted (<= nb_pkts) + * @ingroup dpdk_devops_func + * + */ +uint16_t qdma_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); + +/** + * DPDK callback for retrieving Port statistics. + * + * This API updates Port statistics in rte_eth_stats structure parameters + * + * @param dev Pointer to Ethernet device structure + * @param eth_stats Pointer to structure containing statistics + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *eth_stats); + +/** + * DPDK callback to reset Port statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @ingroup dpdk_devops_func + */ +int qdma_dev_stats_reset(struct rte_eth_dev *dev); + +/** + * DPDK callback to set a queue statistics mapping for + * a tx/rx queue of an Ethernet device. + * + * @param dev + * Pointer to Ethernet device structure + * @param queue_id + * Index of the queue for which a queue stats mapping is required + * @param stat_idx + * The per-queue packet statistics functionality number that + * the queue_id is to be assigned + * @param is_rx + * Whether queue is a Rx or a Tx queue + * + * @return + * 0 on success, -EINVAL on failure + * @ingroup dpdk_devops_func + */ +int qdma_dev_queue_stats_mapping(struct rte_eth_dev *dev, + uint16_t queue_id, + uint8_t stat_idx, + uint8_t is_rx); + +/** + * DPDK callback to get the number of used descriptors of a rx queue + * + * @param dev + * Pointer to Ethernet device structure + * @param rx_queue_id + * The RX queue on the Ethernet device for which information will be + * retrieved + * + * @return + * The number of used descriptors in the specific queue + * @ingroup dpdk_devops_func + */ +uint32_t +qdma_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id); + +/** + * DPDK callback to check the status of a Rx descriptor in the queue + * + * @param rx_queue + * Pointer to Rx queue specific data structure + * @param offset + * The offset of the descriptor starting from tail (0 is the next + * packet to be received by the driver) + * + * @return + * - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to + * receive a packet. + * - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but + * not yet processed by the driver (i.e. in the receive queue). + * - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by + * the driver and not yet returned to hw, or reserved by the hw. + * - (-EINVAL) bad descriptor offset. + * @ingroup dpdk_devops_func + */ +int +qdma_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); + +/** + * DPDK callback to check the status of a Tx descriptor in the queue + * + * @param tx_queue + * Pointer to Tx queue specific data structure + * @param offset + * The offset of the descriptor starting from tail (0 is the place where + * the next packet will be send) + * + * @return + * - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e. + * in the transmit queue. + * - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can + * be reused by the driver. + * - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the + * driver or the hardware. + * - (-EINVAL) bad descriptor offset. + * @ingroup dpdk_devops_func + */ +int +qdma_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); + +/** + * DPDK callback to request the driver to free mbufs + * currently cached by the driver + * + * @param tx_queue + * Pointer to Tx queue specific data structure + * @param free_cnt + * Maximum number of packets to free. Use 0 to indicate all possible packets + * should be freed. Note that a packet may be using multiple mbufs. + * + * @return + * - Failure: < 0 + * - Success: >= 0 + * 0-n: Number of packets freed. More packets may still remain in ring that + * are in use. + * @ingroup dpdk_devops_func + */ +int +qdma_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt); + +/** + * DPDK callback to retrieve device registers and + * register attributes (number of registers and register size) + * + * @param dev + * Pointer to Ethernet device structure + * @param regs + * Pointer to rte_dev_reg_info structure to fill in. If regs->data is + * NULL the function fills in the width and length fields. If non-NULL + * the registers are put into the buffer pointed at by the data field. + * + * @return + * 0 on success, -ENOTSUP on failure + * @ingroup dpdk_devops_func + */ +int +qdma_dev_get_regs(struct rte_eth_dev *dev, + struct rte_dev_reg_info *regs); + +/** + * DPDK callback to stop a C2H queue + * + * This API invalidates Hardware, Software, Prefetch and completion contexts + * of C2H queue. It also free the rte_mbuf pointers assigned to descriptors + * prepared for packet reception. + * + * @param dev Pointer to Ethernet device structure + * @param qid Rx queue index + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qid); + +/** + * qdma_dev_tx_queue_stop() - DPDK callback to stop a queue in H2C direction + * + * This API invalidates Hardware, Software contexts of H2C queue. It also free + * the rte_mbuf pointers assigned to descriptors that are pending transmission. + * + * @param dev Pointer to Ethernet device structure + * @param qid TX queue index + * + * @return 0 on success, < 0 on failure + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qid); + + +/** + * DPDK callback to stop the device. + * + * This API stops the device by invalidating all the contexts of all the queues + * belonging to the port by calling qdma_dev_tx_queue_stop() and + * qdma_dev_rx_queue_stop() for all the queues of the port. + * + * @param dev Pointer to Ethernet device structure + * + * @ingroup dpdk_devops_func + * + */ +int qdma_dev_stop(struct rte_eth_dev *dev); + +/** + * DPDK callback to release a Rx queue. + * + * This API releases the descriptor rings and any additional memory allocated + * for given C2H queue + * + * @param dev Pointer to Ethernet device structure + * @param q_id: Rx queue id + * + * @ingroup dpdk_devops_func + */ +void qdma_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t q_id); + +/** + * DPDK callback to release a Tx queue. + * + * This API releases the descriptor rings and any additional memory allocated + * for given H2C queue + * + * @param dev Pointer to Ethernet device structure + * @param q_id: Tx queue id + * + * @ingroup dpdk_devops_func + */ +void qdma_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_id); + +/** + * DPDK callback to close the device. + * + * This API frees the descriptor rings and objects beonging to all the queues + * of the given port. It also clears the FMAP. + * + * @param dev Pointer to Ethernet device structure + * + * @ingroup dpdk_devops_func + */ +int qdma_dev_close(struct rte_eth_dev *dev); + +/** + * DPDK callback to close the VF device. + * + * This API frees the descriptor rings and objects beonging to all the queues + * of the given port. It also clears the FMAP. + * + * @param dev Pointer to Ethernet device structure + * + * @ingroup dpdk_devops_func + */ +int qdma_vf_dev_close(struct rte_eth_dev *dev); + +/** + * DPDK callback to reset the device. + * + * This callback is invoked when applcation calls rte_eth_dev_reset() API + * to reset a device. This callback uninitialzes PF device after waiting for + * all its VFs to shutdown. It initialize back PF device and then send + * Reset done mailbox message to all its VFs to come online again. + * + * @param dev + * Pointer to Ethernet device structure + * + * @return + * 0 on success, negative errno value on failure + * @ingroup dpdk_devops_func + */ +int qdma_dev_reset(struct rte_eth_dev *dev); + +#ifdef __cplusplus +} +#endif +#endif /* ifndef __QDMA_DEVOPS_H__ */ diff --git a/drivers/net/qdma/qdma_ethdev.c b/drivers/net/qdma/qdma_ethdev.c index 54776c637d..79aac4aa60 100644 --- a/drivers/net/qdma/qdma_ethdev.c +++ b/drivers/net/qdma/qdma_ethdev.c @@ -25,6 +25,7 @@ #include "qdma_version.h" #include "qdma_access_common.h" #include "qdma_access_export.h" +#include "qdma_devops.h" /* Poll for QDMA errors every 1 second */ #define QDMA_ERROR_POLL_FRQ (1000000) @@ -356,8 +357,10 @@ static int qdma_eth_dev_init(struct rte_eth_dev *dev) /* for secondary processes, we don't initialise any further as primary * has already done this work. */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + qdma_dev_ops_init(dev); return 0; + } /* allocate space for a single Ethernet MAC address */ dev->data->mac_addrs = rte_zmalloc("qdma", RTE_ETHER_ADDR_LEN * 1, 0); @@ -436,6 +439,8 @@ static int qdma_eth_dev_init(struct rte_eth_dev *dev) PMD_DRV_LOG(INFO, "QDMA device driver probe:"); + qdma_dev_ops_init(dev); + /* Getting the device attributes from the Hardware */ qdma_device_attributes_get(dev); @@ -580,6 +585,10 @@ static int qdma_eth_dev_uninit(struct rte_eth_dev *dev) /* only uninitialize in the primary process */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -EPERM; + + if (qdma_dev->dev_configured) + qdma_dev_close(dev); + /* cancel pending polls */ if (qdma_dev->is_master) rte_eal_alarm_cancel(qdma_check_errors, (void *)dev); diff --git a/drivers/net/qdma/rte_pmd_qdma.h b/drivers/net/qdma/rte_pmd_qdma.h index f5e3def613..d09ec4a715 100644 --- a/drivers/net/qdma/rte_pmd_qdma.h +++ b/drivers/net/qdma/rte_pmd_qdma.h @@ -2,8 +2,8 @@ * Copyright(c) 2017-2022 Xilinx, Inc. All rights reserved. */ -#ifndef __RTE_PMD_QDMA_EXPORT_H__ -#define __RTE_PMD_QDMA_EXPORT_H__ +#ifndef __RTE_PMD_QDMA_H__ +#define __RTE_PMD_QDMA_H__ #include #include @@ -256,7 +256,9 @@ struct rte_pmd_qdma_dev_attributes { enum rte_pmd_qdma_ip_type ip_type; }; +#define DMA_BRAM_SIZE 524288 + #ifdef __cplusplus } #endif -#endif /* ifndef __RTE_PMD_QDMA_EXPORT_H__ */ +#endif /* ifndef __RTE_PMD_QDMA_H__ */