From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <hemant.agrawal@nxp.com>
Subject: [dpdk-dev] [RFC Patch 15/39] bus/dpaa: add support for FMAN frame queue lookup
Date: Sat, 27 May 2017 15:55:11 +0530 [thread overview]
Message-ID: <1495880735-1651-16-git-send-email-shreyansh.jain@nxp.com> (raw)
In-Reply-To: <1495880735-1651-1-git-send-email-shreyansh.jain@nxp.com>
Signed-off-by: Geoff Thorpe <geoff.thorpe@freescale.com>
Signed-off-by: Roy Pledge <roy.pledge@freescale.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
drivers/bus/dpaa/base/qbman/qman.c | 99 ++++++++++++++++++++++++++++++-
drivers/bus/dpaa/base/qbman/qman_driver.c | 7 ++-
drivers/bus/dpaa/base/qbman/qman_priv.h | 11 ++++
drivers/bus/dpaa/include/fsl_qman.h | 12 ++++
4 files changed, 126 insertions(+), 3 deletions(-)
diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index 8da7acb..2a1882a 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -176,6 +176,65 @@ static inline struct qman_fq *table_find_fq(struct qman_portal *p, u32 fqid)
return fqtree_find(&p->retire_table, fqid);
}
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+static void **qman_fq_lookup_table;
+static size_t qman_fq_lookup_table_size;
+
+int qman_setup_fq_lookup_table(size_t num_entries)
+{
+ num_entries++;
+ /* Allocate 1 more entry since the first entry is not used */
+ qman_fq_lookup_table = vmalloc((num_entries * sizeof(void *)));
+ if (!qman_fq_lookup_table) {
+ pr_err("QMan: Could not allocate fq lookup table\n");
+ return -ENOMEM;
+ }
+ memset(qman_fq_lookup_table, 0, num_entries * sizeof(void *));
+ qman_fq_lookup_table_size = num_entries;
+ pr_info("QMan: Allocated lookup table at %p, entry count %lu\n",
+ qman_fq_lookup_table,
+ (unsigned long)qman_fq_lookup_table_size);
+ return 0;
+}
+
+/* global structure that maintains fq object mapping */
+static DEFINE_SPINLOCK(fq_hash_table_lock);
+
+static int find_empty_fq_table_entry(u32 *entry, struct qman_fq *fq)
+{
+ u32 i;
+
+ spin_lock(&fq_hash_table_lock);
+ /* Can't use index zero because this has special meaning
+ * in context_b field.
+ */
+ for (i = 1; i < qman_fq_lookup_table_size; i++) {
+ if (qman_fq_lookup_table[i] == NULL) {
+ *entry = i;
+ qman_fq_lookup_table[i] = fq;
+ spin_unlock(&fq_hash_table_lock);
+ return 0;
+ }
+ }
+ spin_unlock(&fq_hash_table_lock);
+ return -ENOMEM;
+}
+
+static void clear_fq_table_entry(u32 entry)
+{
+ spin_lock(&fq_hash_table_lock);
+ BUG_ON(entry >= qman_fq_lookup_table_size);
+ qman_fq_lookup_table[entry] = NULL;
+ spin_unlock(&fq_hash_table_lock);
+}
+
+static inline struct qman_fq *get_fq_table_entry(u32 entry)
+{
+ BUG_ON(entry >= qman_fq_lookup_table_size);
+ return qman_fq_lookup_table[entry];
+}
+#endif
+
static inline void cpu_to_hw_fqd(struct qm_fqd *fqd)
{
/* Byteswap the FQD to HW format */
@@ -766,8 +825,13 @@ static u32 __poll_portal_slow(struct qman_portal *p, u32 is)
break;
case QM_MR_VERB_FQPN:
/* Parked */
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ fq = get_fq_table_entry(
+ be32_to_cpu(msg->fq.contextB));
+#else
fq = (void *)(uintptr_t)
be32_to_cpu(msg->fq.contextB);
+#endif
fq_state_change(p, fq, msg, verb);
if (fq->cb.fqs)
fq->cb.fqs(p, fq, &swapped_msg);
@@ -792,7 +856,11 @@ static u32 __poll_portal_slow(struct qman_portal *p, u32 is)
}
} else {
/* Its a software ERN */
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ fq = get_fq_table_entry(be32_to_cpu(msg->ern.tag));
+#else
fq = (void *)(uintptr_t)be32_to_cpu(msg->ern.tag);
+#endif
fq->cb.ern(p, fq, &swapped_msg);
}
num++;
@@ -907,7 +975,11 @@ static inline unsigned int __poll_portal_fast(struct qman_portal *p,
clear_vdqcr(p, fq);
} else {
/* SDQCR: context_b points to the FQ */
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ fq = get_fq_table_entry(dq->contextB);
+#else
fq = (void *)(uintptr_t)dq->contextB;
+#endif
/* Now let the callback do its stuff */
res = fq->cb.dqrr(p, fq, dq);
/*
@@ -1119,7 +1191,12 @@ int qman_create_fq(u32 fqid, u32 flags, struct qman_fq *fq)
fq->flags = flags;
fq->state = qman_fq_state_oos;
fq->cgr_groupid = 0;
-
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ if (unlikely(find_empty_fq_table_entry(&fq->key, fq))) {
+ pr_info("Find empty table entry failed\n");
+ return -ENOMEM;
+ }
+#endif
if (!(flags & QMAN_FQ_FLAG_AS_IS) || (flags & QMAN_FQ_FLAG_NO_MODIFY))
return 0;
/* Everything else is AS_IS support */
@@ -1193,7 +1270,9 @@ void qman_destroy_fq(struct qman_fq *fq, u32 flags __maybe_unused)
case qman_fq_state_oos:
if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID))
qman_release_fqid(fq->fqid);
-
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ clear_fq_table_entry(fq->key);
+#endif
return;
default:
break;
@@ -1258,7 +1337,11 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts)
dma_addr_t phys_fq;
mcc->initfq.we_mask |= QM_INITFQ_WE_CONTEXTB;
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ mcc->initfq.fqd.context_b = fq->key;
+#else
mcc->initfq.fqd.context_b = (u32)(uintptr_t)fq;
+#endif
/*
* and the physical address - NB, if the user wasn't trying to
* set CONTEXTA, clear the stashing settings.
@@ -1419,7 +1502,11 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
msg.verb = QM_MR_VERB_FQRNI;
msg.fq.fqs = mcr->alterfq.fqs;
msg.fq.fqid = fq->fqid;
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ msg.fq.contextB = fq->key;
+#else
msg.fq.contextB = (u32)(uintptr_t)fq;
+#endif
fq->cb.fqs(p, fq, &msg);
}
} else if (res == QM_MCR_RESULT_PENDING) {
@@ -1861,7 +1948,11 @@ static inline struct qm_eqcr_entry *try_p_eq_start(struct qman_portal *p,
QM_EQCR_DCA_PARK : 0) |
((flags >> 8) & QM_EQCR_DCA_IDXMASK);
eq->fqid = cpu_to_be32(fq->fqid);
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ eq->tag = cpu_to_be32(fq->key);
+#else
eq->tag = cpu_to_be32((u32)(uintptr_t)fq);
+#endif
eq->fd = *fd;
cpu_to_hw_fd(&eq->fd);
return eq;
@@ -1907,7 +1998,11 @@ int qman_enqueue_multi(struct qman_fq *fq,
/* try to send as many frames as possible */
while (eqcr->available && frames_to_send--) {
eq->fqid = cpu_to_be32(fq->fqid);
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ eq->tag = cpu_to_be32(fq->key);
+#else
eq->tag = cpu_to_be32((u32)(uintptr_t)fq);
+#endif
eq->fd.opaque_addr = fd->opaque_addr;
eq->fd.addr = cpu_to_be40(fd->addr);
eq->fd.status = cpu_to_be32(fd->status);
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index a7faf17..5c535dd 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -279,5 +279,10 @@ int qman_global_init(void)
else
qman_clk = be32_to_cpu(*clk);
- return ret;
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ ret = qman_setup_fq_lookup_table(CONFIG_FSL_QMAN_FQ_LOOKUP_MAX);
+ if (ret)
+ return ret;
+#endif
+ return 0;
}
diff --git a/drivers/bus/dpaa/base/qbman/qman_priv.h b/drivers/bus/dpaa/base/qbman/qman_priv.h
index 4ae2ea5..e9826c2 100644
--- a/drivers/bus/dpaa/base/qbman/qman_priv.h
+++ b/drivers/bus/dpaa/base/qbman/qman_priv.h
@@ -44,6 +44,10 @@
#include "dpaa_sys.h"
#include <fsl_qman.h>
+#if !defined(CONFIG_FSL_QMAN_FQ_LOOKUP) && defined(RTE_ARCH_ARM64)
+#error "_ARM64 requires _FSL_QMAN_FQ_LOOKUP"
+#endif
+
/* Congestion Groups */
/*
* This wrapper represents a bit-array for the state of the 256 QMan congestion
@@ -197,6 +201,13 @@ void qm_set_liodns(struct qm_portal_config *pcfg);
int qman_testwrite_cgr(struct qman_cgr *cgr, u64 i_bcnt,
struct qm_mcr_cgrtestwrite *result);
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+/* If the fq object pointer is greater than the size of context_b field,
+ * than a lookup table is required.
+ */
+int qman_setup_fq_lookup_table(size_t num_entries);
+#endif
+
/* QMan s/w corenet portal, low-level i/face */
/*
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index 7d9ad00..1867a66 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -46,6 +46,15 @@ extern "C" {
#include <dpaa_rbtree.h>
+/* FQ lookups (turn this on for 64bit user-space) */
+#if (__WORDSIZE == 64)
+#define CONFIG_FSL_QMAN_FQ_LOOKUP
+/* if FQ lookups are supported, this controls the number of initialised,
+ * s/w-consumed FQs that can be supported at any one time.
+ */
+#define CONFIG_FSL_QMAN_FQ_LOOKUP_MAX (32 * 1024)
+#endif
+
/* Last updated for v00.800 of the BG */
/* Hardware constants */
@@ -1245,6 +1254,9 @@ struct qman_fq {
enum qman_fq_state state;
int cgr_groupid;
struct rb_node node;
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ u32 key;
+#endif
};
/*
--
2.7.4
next prev parent reply other threads:[~2017-05-27 10:18 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-27 10:24 [dpdk-dev] [RFC Patch 00/39] Introduce NXP DPAA Bus, Mempool and PMD Shreyansh Jain
2017-05-27 10:24 ` [dpdk-dev] [RFC Patch 01/39] eal: add Bus log type Shreyansh Jain
2017-05-27 10:28 ` Shreyansh Jain
2017-05-27 10:24 ` [dpdk-dev] [RFC Patch 02/39] eal: add support for 24 40 and 48 bit operations Shreyansh Jain
2017-05-27 10:24 ` [dpdk-dev] [RFC Patch 03/39] config: add NXP DPAA SoC build configuration Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 04/39] bus/dpaa: introduce NXP DPAA Bus driver skeleton Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 05/39] bus/dpaa: add compatibility and helper macros Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 06/39] bus/dpaa: add OF parser for device scanning Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 07/39] bus/dpaa: introducing FMan configurations Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 08/39] bus/dpaa: add FMan hardware operations Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 09/39] bus/dpaa: enable DPAA IOCTL portal driver Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 10/39] bus/dpaa: add layer for interrupt emulation using pthread Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 11/39] bus/dpaa: add routines for managing a RB tree Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 12/39] bus/dpaa: add QMAN interface driver Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 13/39] bus/dpaa: add QMan driver core routines Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 14/39] bus/dpaa: add BMAN driver core Shreyansh Jain
2017-05-27 10:25 ` Shreyansh Jain [this message]
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 16/39] bus/dpaa: add BMan hardware interfaces Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 17/39] bus/dpaa: add fman flow control threshold setting Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 18/39] bus/dpaa: integrate DPAA Bus with hardware blocks Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 19/39] doc: add NXP DPAA PMD documentation Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 20/39] mempool/dpaa: add support for NXP DPAA Mempool Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 21/39] drivers: enable compilation of DPAA Mempool driver Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 22/39] maintainers: claim ownership " Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 23/39] net/dpaa: add NXP DPAA PMD driver skeleton Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 24/39] config: enable NXP DPAA PMD compilation Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 25/39] net/dpaa: add support for Tx and Rx queue setup Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 26/39] net/dpaa: add support for MTU update Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 27/39] net/dpaa: add support for link status update Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 28/39] net/dpaa: add support for jumbo frames Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 29/39] net/dpaa: add support for promiscuous toggle Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 30/39] net/dpaa: add support for multicast toggle Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 31/39] net/dpaa: add support for basic stats Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 32/39] net/dpaa: add support for device info Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 33/39] net/dpaa: support for checksum offload Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 34/39] net/dpaa: add support for hashed RSS Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 35/39] net/dpaa: add support for MAC address update Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 36/39] net/dpaa: add support for packet type parsing Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 37/39] net/dpaa: add support for Scattered Rx Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 38/39] net/dpaa: add support for flow control Shreyansh Jain
2017-05-27 10:25 ` [dpdk-dev] [RFC Patch 39/39] net/dpaa: add packet dump for debugging Shreyansh Jain
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=1495880735-1651-16-git-send-email-shreyansh.jain@nxp.com \
--to=shreyansh.jain@nxp.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=hemant.agrawal@nxp.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).