All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nipun Gupta <nipun.gupta@nxp.com>
To: thomas@monjalon.net, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com
Cc: dev@dpdk.org, Nipun Gupta <nipun.gupta@nxp.com>
Subject: [PATCH v2 7/9] raw/dpaa2_cmdif: support enqueue dequeue operations
Date: Sat,  7 Apr 2018 20:04:03 +0530	[thread overview]
Message-ID: <1523111645-8076-8-git-send-email-nipun.gupta@nxp.com> (raw)
In-Reply-To: <1523111645-8076-1-git-send-email-nipun.gupta@nxp.com>

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 doc/api/doxy-api-index.md                     |   1 +
 doc/api/doxy-api.conf                         |   1 +
 drivers/raw/dpaa2_cmdif/Makefile              |   2 +
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 136 ++++++++++++++++++++++++++
 drivers/raw/dpaa2_cmdif/rte_pmd_dpaa2_cmdif.h |  35 +++++++
 5 files changed, 175 insertions(+)
 create mode 100644 drivers/raw/dpaa2_cmdif/rte_pmd_dpaa2_cmdif.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 49fcec4..b9f28be 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -64,6 +64,7 @@ The public API headers are grouped by topics:
   [bnxt]               (@ref rte_pmd_bnxt.h),
   [dpaa]               (@ref rte_pmd_dpaa.h),
   [dpaa2]              (@ref rte_dpaa2_mempool.h),
+  [dpaa2_cmdif]        (@ref rte_pmd_dpaa2_cmdif.h),
   [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
 
 - **memory**:
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 59cb580..88088d6 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -38,6 +38,7 @@ INPUT                   = doc/api/doxy-api-index.md \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           drivers/net/softnic \
+                          drivers/raw/dpaa2_cmdif \
                           lib/librte_eal/common/include \
                           lib/librte_eal/common/include/generic \
                           lib/librte_acl \
diff --git a/drivers/raw/dpaa2_cmdif/Makefile b/drivers/raw/dpaa2_cmdif/Makefile
index 1d91d0c..c570827 100644
--- a/drivers/raw/dpaa2_cmdif/Makefile
+++ b/drivers/raw/dpaa2_cmdif/Makefile
@@ -30,4 +30,6 @@ LIBABIVER := 1
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF) += dpaa2_cmdif.c
 
+SYMLINK-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF)-include += rte_pmd_dpaa2_cmdif.h
+
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 9044489..c26fc30 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -53,8 +53,144 @@
 	return 0;
 }
 
+static int
+dpaa2_cmdif_enqueue_bufs(struct rte_rawdev *dev,
+			 struct rte_rawdev_buf **buffers,
+			 unsigned int count,
+			 rte_rawdev_obj_t context)
+{
+	struct dpaa2_dpci_dev *cidev = dev->dev_private;
+	struct rte_dpaa2_cmdif_context *cmdif_send_cnxt;
+	struct dpaa2_queue *txq;
+	struct qbman_fd fd;
+	struct qbman_eq_desc eqdesc;
+	struct qbman_swp *swp;
+	int ret;
+
+	DPAA2_CMDIF_FUNC_TRACE();
+
+	RTE_SET_USED(count);
+
+	if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
+		ret = dpaa2_affine_qbman_swp();
+		if (ret) {
+			DPAA2_CMDIF_ERR("Failure in affining portal\n");
+			return 0;
+		}
+	}
+	swp = DPAA2_PER_LCORE_PORTAL;
+
+	cmdif_send_cnxt = (struct rte_dpaa2_cmdif_context *)(context);
+	txq = &(cidev->tx_queue[cmdif_send_cnxt->priority]);
+
+	/* Prepare enqueue descriptor */
+	qbman_eq_desc_clear(&eqdesc);
+	qbman_eq_desc_set_fq(&eqdesc, txq->fqid);
+	qbman_eq_desc_set_no_orp(&eqdesc, 0);
+	qbman_eq_desc_set_response(&eqdesc, 0, 0);
+
+	/* Set some of the FD parameters to i.
+	 * For performance reasons do not memset
+	 */
+	fd.simple.bpid_offset = 0;
+	fd.simple.ctrl = 0;
+
+	DPAA2_SET_FD_ADDR(&fd, DPAA2_VADDR_TO_IOVA(buffers[0]->buf_addr));
+	DPAA2_SET_FD_LEN(&fd, cmdif_send_cnxt->size);
+	DPAA2_SET_FD_FRC(&fd, cmdif_send_cnxt->frc);
+	DPAA2_SET_FD_FLC(&fd, cmdif_send_cnxt->flc);
+
+	/* Enqueue a packet to the QBMAN */
+	do {
+		ret = qbman_swp_enqueue_multiple(swp, &eqdesc, &fd, NULL, 1);
+		if (ret < 0 && ret != -EBUSY)
+			DPAA2_CMDIF_ERR("Transmit failure with err: %d\n", ret);
+	} while (ret == -EBUSY);
+
+	DPAA2_CMDIF_DEBUG("Successfully transmitted a packet\n");
+
+	return 0;
+}
+
+static int
+dpaa2_cmdif_dequeue_bufs(struct rte_rawdev *dev,
+			 struct rte_rawdev_buf **buffers,
+			 unsigned int count,
+			 rte_rawdev_obj_t context)
+{
+	struct dpaa2_dpci_dev *cidev = dev->dev_private;
+	struct rte_dpaa2_cmdif_context *cmdif_rcv_cnxt;
+	struct dpaa2_queue *rxq;
+	struct qbman_swp *swp;
+	struct qbman_result *dq_storage;
+	const struct qbman_fd *fd;
+	struct qbman_pull_desc pulldesc;
+	uint8_t status;
+	int ret;
+
+	DPAA2_CMDIF_FUNC_TRACE();
+
+	RTE_SET_USED(count);
+
+	if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
+		ret = dpaa2_affine_qbman_swp();
+		if (ret) {
+			DPAA2_CMDIF_ERR("Failure in affining portal\n");
+			return 0;
+		}
+	}
+	swp = DPAA2_PER_LCORE_PORTAL;
+
+	cmdif_rcv_cnxt = (struct rte_dpaa2_cmdif_context *)(context);
+	rxq = &(cidev->rx_queue[cmdif_rcv_cnxt->priority]);
+	dq_storage = rxq->q_storage->dq_storage[0];
+
+	qbman_pull_desc_clear(&pulldesc);
+	qbman_pull_desc_set_fq(&pulldesc, rxq->fqid);
+	qbman_pull_desc_set_numframes(&pulldesc, 1);
+	qbman_pull_desc_set_storage(&pulldesc, dq_storage,
+		(dma_addr_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
+
+	while (1) {
+		if (qbman_swp_pull(swp, &pulldesc)) {
+			DPAA2_CMDIF_ERR("VDQ cmd not issued. QBMAN is busy\n");
+			/* Portal was busy, try again */
+			continue;
+		}
+		break;
+	}
+
+	/* Check if previous issued command is completed. */
+	while (!qbman_check_command_complete(dq_storage))
+		;
+	/* Loop until the dq_storage is updated with new token by QBMAN */
+	while (!qbman_result_has_new_result(swp, dq_storage))
+		;
+
+	/* Check for valid frame. */
+	status = (uint8_t)qbman_result_DQ_flags(dq_storage);
+	if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) {
+		DPAA2_CMDIF_DEBUG("No frame is delivered\n");
+		return 0;
+	}
+
+	fd = qbman_result_DQ_fd(dq_storage);
+
+	buffers[0]->buf_addr = DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd) +
+			DPAA2_GET_FD_OFFSET(fd));
+	cmdif_rcv_cnxt->size = DPAA2_GET_FD_LEN(fd);
+	cmdif_rcv_cnxt->flc = DPAA2_GET_FD_FLC(fd);
+	cmdif_rcv_cnxt->frc = DPAA2_GET_FD_FRC(fd);
+
+	DPAA2_CMDIF_DEBUG("packet received\n");
+
+	return 1;
+}
+
 static const struct rte_rawdev_ops dpaa2_cmdif_ops = {
 	.attr_get = dpaa2_cmdif_get_attr,
+	.enqueue_bufs = dpaa2_cmdif_enqueue_bufs,
+	.dequeue_bufs = dpaa2_cmdif_dequeue_bufs,
 };
 
 static int
diff --git a/drivers/raw/dpaa2_cmdif/rte_pmd_dpaa2_cmdif.h b/drivers/raw/dpaa2_cmdif/rte_pmd_dpaa2_cmdif.h
new file mode 100644
index 0000000..483b66e
--- /dev/null
+++ b/drivers/raw/dpaa2_cmdif/rte_pmd_dpaa2_cmdif.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef __RTE_PMD_DPAA2_CMDIF_H__
+#define __RTE_PMD_DPAA2_CMDIF_H__
+
+/**
+ * @file
+ *
+ * NXP dpaa2 AIOP CMDIF PMD specific structures.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** The context required in the I/O path for DPAA2 AIOP Command Interface */
+struct rte_dpaa2_cmdif_context {
+	/** Size to populate in QBMAN FD */
+	uint32_t size;
+	/** FRC to populate in QBMAN FD */
+	uint32_t frc;
+	/** FLC to populate in QBMAN FD */
+	uint64_t flc;
+	/** Priority of the command. This priority determines DPCI Queue*/
+	uint8_t priority;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __RTE_PMD_DPAA2_CMDIF_H__ */
-- 
1.9.1

  parent reply	other threads:[~2018-04-07 14:35 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22  9:34 [PATCH 0/9] Introduce DPAA2 Command Interface raw driver Nipun Gupta
2018-02-22  9:34 ` [PATCH 1/9] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-02-22  9:34 ` [PATCH 2/9] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-02-22  9:34 ` [PATCH 3/9] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-02-22  9:34 ` [PATCH 4/9] bus/fslmc: add preprocessors to get flc and frc from fd Nipun Gupta
2018-02-22  9:34 ` [PATCH 5/9] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-02-22 13:12   ` Shreyansh Jain
2018-02-23  6:35     ` Nipun Gupta
2018-02-22 14:31   ` Jerin Jacob
2018-02-23  6:35     ` Nipun Gupta
2018-02-22  9:34 ` [PATCH 6/9] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-02-22  9:34 ` [PATCH 7/9] raw/dpaa2_cmdif: support enqueue dequeue operations Nipun Gupta
2018-02-22  9:34 ` [PATCH 8/9] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-02-22  9:34 ` [PATCH 9/9] doc: add dpaa2 command interface rawdev to release notes Nipun Gupta
2018-04-07 14:33 ` [PATCH v2 0/9] Introduce DPAA2 Command Interface raw driver Nipun Gupta
2018-04-07 14:33   ` [PATCH v2 1/9] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-04-07 14:33   ` [PATCH v2 2/9] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-04-07 14:33   ` [PATCH v2 3/9] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-04-25  1:47     ` Shreyansh Jain
2018-04-25  3:53     ` Shreyansh Jain
2018-04-07 14:34   ` [PATCH v2 4/9] bus/fslmc: add preprocessors to get flc and frc from fd Nipun Gupta
2018-04-07 14:34   ` [PATCH v2 5/9] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-04-25  4:18     ` Shreyansh Jain
2018-04-07 14:34   ` [PATCH v2 6/9] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-04-07 14:34   ` Nipun Gupta [this message]
2018-04-07 14:34   ` [PATCH v2 8/9] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-04-16 12:40     ` Hemant Agrawal
2018-04-07 14:34   ` [PATCH v2 9/9] doc: add dpaa2 command interface rawdev to release notes Nipun Gupta
2018-04-23 12:23     ` Kovacevic, Marko
2018-04-25  1:50     ` Shreyansh Jain
2018-04-07 14:43   ` [PATCH v2 0/9] Introduce DPAA2 Command Interface raw driver Nipun Gupta
2018-04-26 10:14   ` [PATCH 0/7 v3] " Nipun Gupta
2018-04-26 10:14     ` [PATCH 1/7 v3] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-04-26 10:14     ` [PATCH 2/7 v3] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-05-01  9:45       ` Shreyansh Jain
2018-04-26 10:14     ` [PATCH 3/7 v3] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-04-26 10:14     ` [PATCH 4/7 v3] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-04-26 10:14     ` [PATCH 5/7 v3] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-04-26 10:14     ` [PATCH 6/7 v3] raw/dpaa2_cmdif: support enqueue dequeue operations Nipun Gupta
2018-04-26 10:14     ` [PATCH 7/7 v3] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-05-01  9:45     ` [PATCH 0/7 v3] Introduce DPAA2 Command Interface raw driver Shreyansh Jain
2018-05-02 17:15     ` [PATCH v4 0/7] " Nipun Gupta
2018-05-02 17:15       ` [PATCH v4 1/7] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-05-03 13:49         ` Shreyansh Jain
2018-05-02 17:15       ` [PATCH v4 2/7] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-05-02 17:15       ` [PATCH v4 3/7] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-05-02 17:15       ` [PATCH v4 4/7] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-05-03 14:10         ` Shreyansh Jain
2018-05-02 17:15       ` [PATCH v4 5/7] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-05-02 17:15       ` [PATCH v4 6/7] raw/dpaa2_cmdif: support enqueue dequeue operations Nipun Gupta
2018-05-02 17:15       ` [PATCH v4 7/7] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-05-03 16:33       ` [PATCH v5 0/7] Introduce DPAA2 Command Interface raw driver Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 1/7] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 2/7] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 3/7] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 4/7] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 5/7] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 6/7] raw/dpaa2_cmdif: support enqueue dequeue operations Nipun Gupta
2018-05-03 16:33         ` [PATCH v5 7/7] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-05-04  7:15         ` [PATCH v5 0/7] Introduce DPAA2 Command Interface raw driver Nipun Gupta
2018-05-04 10:11         ` [PATCH v6 " Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 1/7] mempool/dpaa2: add functions exposed to DPDK applications Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 2/7] bus/fslmc: expose API to free dpci device Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 3/7] bus/fslmc: keep Tx queues information for DPCI devices too Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 4/7] raw/dpaa2_cmdif: introduce DPAA2 command interface driver Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 5/7] raw/dpaa2_cmdif: add attribute get functionality Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 6/7] raw/dpaa2_cmdif: support enqueue dequeue operations Nipun Gupta
2018-05-04 10:11           ` [PATCH v6 7/7] doc: add DPAA2 CMDIF rawdev guide Nipun Gupta
2018-05-08 12:08             ` Thomas Monjalon
2018-05-05 18:44           ` [PATCH v6 0/7] Introduce DPAA2 Command Interface raw driver Shreyansh Jain
2018-05-08 12:27             ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1523111645-8076-8-git-send-email-nipun.gupta@nxp.com \
    --to=nipun.gupta@nxp.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=shreyansh.jain@nxp.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.