RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> -Original Message- > From: Ruxandra Ioana Radulescu > Sent: Monday, November 28, 2016 12:10 PM > To: Stuart Yoder <stuart.yo...@nxp.com>; gre...@linuxfoundation.org > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; > ag...@suse.de; a...@arndb.de; Leo Li <leoyang...@nxp.com>; Roy Pledge > <roy.ple...@nxp.com>; Haiying Wang > <haiying.w...@nxp.com> > Subject: RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > -Original Message- > > From: Stuart Yoder [mailto:stuart.yo...@nxp.com] > > Sent: Friday, October 21, 2016 9:02 AM > > To: gre...@linuxfoundation.org > > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > > linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li > > <leoyang...@nxp.com>; Roy Pledge <roy.ple...@nxp.com>; Roy Pledge > > <roy.ple...@nxp.com>; Haiying Wang <haiying.w...@nxp.com>; Stuart > > Yoder <stuart.yo...@nxp.com> > > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > > From: Roy Pledge <roy.ple...@nxp.com> > > > > Add QBman APIs for frame queue and buffer pool operations. > > > > Signed-off-by: Roy Pledge <roy.ple...@nxp.com> > > Signed-off-by: Haiying Wang <haiying.w...@nxp.com> > > Signed-off-by: Stuart Yoder <stuart.yo...@nxp.com> > > --- > > drivers/bus/fsl-mc/dpio/Makefile |2 +- > > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ > > 3 files changed, 1474 insertions(+), 1 deletion(-) > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > > mc/dpio/Makefile > > index 128befc..6588498 100644 > > --- a/drivers/bus/fsl-mc/dpio/Makefile > > +++ b/drivers/bus/fsl-mc/dpio/Makefile > > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > > > -fsl-mc-dpio-objs := dpio.o > > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > > mc/dpio/qbman-portal.c > > new file mode 100644 > > index 000..1eb3dd9 > > --- /dev/null > > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c > > [...] > > > +/** > > + * qbman_swp_pull() - Issue the pull dequeue command > > + * @s: the software portal object > > + * @d: the software portal descriptor which has been configured with > > + * the set of qbman_pull_desc_set_*() calls > > + * > > + * Return 0 for success, and -EBUSY if the software portal is not ready > > + * to do pull dequeue. > > + */ > > +int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d) > > +{ > > + struct qbman_pull_desc *p; > > + > > + if (!atomic_dec_and_test(>vdq.available)) { > > + atomic_inc(>vdq.available); > > + return -EBUSY; > > + } > > + s->vdq.storage = (void *)d->rsp_addr_virt; > > + d->tok = 1; > > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_VDQCR); > > + *p = *d; > > + dma_wmb(); > > + > > + /* Set the verb byte, have to substitute in the valid-bit */ > > + p->verb |= s->vdq.valid_bit; > > + s->vdq.valid_bit ^= QB_VALID_BIT; > > + > > + return 0; > > +} > > + > [...] > > + > > +/** > > + * qbman_result_has_new_result() - Check and get the dequeue response > > from the > > + * dq storage memory set in pull dequeue > > command > > + * @s: the software portal object > > + * @dq: the dequeue result read from the memory > > + * > > + * Return 1 for getting a valid dequeue result, or 0 for not getting a > > valid > > + * dequeue result. > > + * > > + * Only used for user-provided storage of dequeue results, not DQRR. For > > + * efficiency purposes, the driver will perform any required endianness > > + * conversion to ensure that the user's dequeue result storage is in host- > > endian > > + * format. As such, once the user has called > > qbman_result_has_new_result() and > > + * been returned a valid dequeue result, they should not call it again on > > + * the same memory location (except of course if another dequeue > > command has > > + * be
RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> -Original Message- > From: Stuart Yoder [mailto:stuart.yo...@nxp.com] > Sent: Friday, October 21, 2016 9:02 AM > To: gre...@linuxfoundation.org > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li > <leoyang...@nxp.com>; Roy Pledge <roy.ple...@nxp.com>; Roy Pledge > <roy.ple...@nxp.com>; Haiying Wang <haiying.w...@nxp.com>; Stuart > Yoder <stuart.yo...@nxp.com> > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > From: Roy Pledge <roy.ple...@nxp.com> > > Add QBman APIs for frame queue and buffer pool operations. > > Signed-off-by: Roy Pledge <roy.ple...@nxp.com> > Signed-off-by: Haiying Wang <haiying.w...@nxp.com> > Signed-off-by: Stuart Yoder <stuart.yo...@nxp.com> > --- > drivers/bus/fsl-mc/dpio/Makefile |2 +- > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ > 3 files changed, 1474 insertions(+), 1 deletion(-) > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > mc/dpio/Makefile > index 128befc..6588498 100644 > --- a/drivers/bus/fsl-mc/dpio/Makefile > +++ b/drivers/bus/fsl-mc/dpio/Makefile > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > -fsl-mc-dpio-objs := dpio.o > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > mc/dpio/qbman-portal.c > new file mode 100644 > index 000..1eb3dd9 > --- /dev/null > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c [...] > +/** > + * qbman_swp_pull() - Issue the pull dequeue command > + * @s: the software portal object > + * @d: the software portal descriptor which has been configured with > + * the set of qbman_pull_desc_set_*() calls > + * > + * Return 0 for success, and -EBUSY if the software portal is not ready > + * to do pull dequeue. > + */ > +int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d) > +{ > + struct qbman_pull_desc *p; > + > + if (!atomic_dec_and_test(>vdq.available)) { > + atomic_inc(>vdq.available); > + return -EBUSY; > + } > + s->vdq.storage = (void *)d->rsp_addr_virt; > + d->tok = 1; > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_VDQCR); > + *p = *d; > + dma_wmb(); > + > + /* Set the verb byte, have to substitute in the valid-bit */ > + p->verb |= s->vdq.valid_bit; > + s->vdq.valid_bit ^= QB_VALID_BIT; > + > + return 0; > +} > + [...] > + > +/** > + * qbman_result_has_new_result() - Check and get the dequeue response > from the > + * dq storage memory set in pull dequeue > command > + * @s: the software portal object > + * @dq: the dequeue result read from the memory > + * > + * Return 1 for getting a valid dequeue result, or 0 for not getting a valid > + * dequeue result. > + * > + * Only used for user-provided storage of dequeue results, not DQRR. For > + * efficiency purposes, the driver will perform any required endianness > + * conversion to ensure that the user's dequeue result storage is in host- > endian > + * format. As such, once the user has called > qbman_result_has_new_result() and > + * been returned a valid dequeue result, they should not call it again on > + * the same memory location (except of course if another dequeue > command has > + * been executed to produce a new result to that location). > + */ > +int qbman_result_has_new_result(struct qbman_swp *s, const struct > dpaa2_dq *dq) > +{ > + if (!dq->dq.tok) > + return 0; While testing the Ethernet driver I discovered that sometimes the above check fails. When we check a store entry for the first time, if the hardware didn't manage to fill it with a valid respose yet, we may find a non-null value in the token field (because the stores have uninitialized memory). So by only checking that token is !=0, we risk processing an uninitialized memory area as a valid dequeue entry. We should always compare the token field against 1, the value that is given to the hardware on the dequeue command. It might also be a good idea to use a define here, to make it clear 1 is a magic value. And I think we should also zero the stores when they are first allocated, since even with the proposed fix there's still a (much smaller) risk of finding our exact token value in an uninitialized memory area. Thanks, Ioana ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> -Original Message- > From: Ruxandra Ioana Radulescu > Sent: Thursday, November 10, 2016 9:04 AM > To: Stuart Yoder <stuart.yo...@nxp.com>; gre...@linuxfoundation.org > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; > ag...@suse.de; a...@arndb.de; Leo Li <leoyang...@nxp.com>; Roy Pledge > <roy.ple...@nxp.com>; Haiying Wang > <haiying.w...@nxp.com>; Stuart Yoder <stuart.yo...@nxp.com> > Subject: RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > > -Original Message- > > From: Stuart Yoder [mailto:stuart.yo...@nxp.com] > > Sent: Friday, October 21, 2016 9:02 AM > > To: gre...@linuxfoundation.org > > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > > linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li > > <leoyang...@nxp.com>; Roy Pledge <roy.ple...@nxp.com>; Roy Pledge > > <roy.ple...@nxp.com>; Haiying Wang <haiying.w...@nxp.com>; Stuart > > Yoder <stuart.yo...@nxp.com> > > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > > From: Roy Pledge <roy.ple...@nxp.com> > > > > Add QBman APIs for frame queue and buffer pool operations. > > > > Signed-off-by: Roy Pledge <roy.ple...@nxp.com> > > Signed-off-by: Haiying Wang <haiying.w...@nxp.com> > > Signed-off-by: Stuart Yoder <stuart.yo...@nxp.com> > > --- > > drivers/bus/fsl-mc/dpio/Makefile |2 +- > > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ > > 3 files changed, 1474 insertions(+), 1 deletion(-) > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > > mc/dpio/Makefile > > index 128befc..6588498 100644 > > --- a/drivers/bus/fsl-mc/dpio/Makefile > > +++ b/drivers/bus/fsl-mc/dpio/Makefile > > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > > > -fsl-mc-dpio-objs := dpio.o > > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > > mc/dpio/qbman-portal.c > > new file mode 100644 > > index 000..1eb3dd9 > > --- /dev/null > > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c > > @@ -0,0 +1,1009 @@ > > [...] > > > +/** > > + * qbman_swp_release() - Issue a buffer release command > > + * @s: the software portal object > > + * @d: the release descriptor > > + * @buffers: a pointer pointing to the buffer address to be released > > + * @num_buffers: number of buffers to be released, must be less than 8 > > + * > > + * Return 0 for success, -EBUSY if the release command ring is not ready. > > + */ > > +int qbman_swp_release(struct qbman_swp *s, const struct > > qbman_release_desc *d, > > + const u64 *buffers, unsigned int num_buffers) > > +{ > > + int i; > > + struct qbman_release_desc *p; > > + u32 rar; > > + > > + if (!num_buffers || (num_buffers > 7)) > > + return -EINVAL; > > + > > + rar = qbman_read_register(s, QBMAN_CINH_SWP_RAR); > > + if (!RAR_SUCCESS(rar)) > > + return -EBUSY; > > + > > + /* Start the release command */ > > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_RCR(RAR_IDX(rar))); > > + /* Copy the caller's buffer pointers to the command */ > > + for (i = 0; i < num_buffers; i++) > > + p->buf[i] = cpu_to_le64(buffers[i]); > > + > > Hi Stuart, > We also need to set BPID field in the buffer release command, something like: > + p->bpid = d->bpid; > Without this all buffers will be released to buffer pool id 0, which is > incorrect. Will fix on next respin. > > + /* > > +* Set the verb byte, have to substitute in the valid-bit and the > > number > > +* of buffers. > > +*/ > > + dma_wmb(); > > + p->verb = d->verb | RAR_VB(rar) | num_buffers; > > + > > + return 0; > > +} > > + > > +struct qbman_acquire_desc { > > + u8 verb; > > + u8 reserved; > > + u16 bpid; > > + u8 num; > > + u8 reserved2[59]; > > +}; > > + > > +struct qbman_acquire_rslt { > > + u8 v
RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> -Original Message- > From: Stuart Yoder [mailto:stuart.yo...@nxp.com] > Sent: Friday, October 21, 2016 9:02 AM > To: gre...@linuxfoundation.org > Cc: German Rivera <german.riv...@nxp.com>; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li > <leoyang...@nxp.com>; Roy Pledge <roy.ple...@nxp.com>; Roy Pledge > <roy.ple...@nxp.com>; Haiying Wang <haiying.w...@nxp.com>; Stuart > Yoder <stuart.yo...@nxp.com> > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > From: Roy Pledge <roy.ple...@nxp.com> > > Add QBman APIs for frame queue and buffer pool operations. > > Signed-off-by: Roy Pledge <roy.ple...@nxp.com> > Signed-off-by: Haiying Wang <haiying.w...@nxp.com> > Signed-off-by: Stuart Yoder <stuart.yo...@nxp.com> > --- > drivers/bus/fsl-mc/dpio/Makefile |2 +- > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ > 3 files changed, 1474 insertions(+), 1 deletion(-) > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > mc/dpio/Makefile > index 128befc..6588498 100644 > --- a/drivers/bus/fsl-mc/dpio/Makefile > +++ b/drivers/bus/fsl-mc/dpio/Makefile > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > -fsl-mc-dpio-objs := dpio.o > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > mc/dpio/qbman-portal.c > new file mode 100644 > index 000..1eb3dd9 > --- /dev/null > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c > @@ -0,0 +1,1009 @@ [...] > +/** > + * qbman_swp_release() - Issue a buffer release command > + * @s: the software portal object > + * @d: the release descriptor > + * @buffers: a pointer pointing to the buffer address to be released > + * @num_buffers: number of buffers to be released, must be less than 8 > + * > + * Return 0 for success, -EBUSY if the release command ring is not ready. > + */ > +int qbman_swp_release(struct qbman_swp *s, const struct > qbman_release_desc *d, > + const u64 *buffers, unsigned int num_buffers) > +{ > + int i; > + struct qbman_release_desc *p; > + u32 rar; > + > + if (!num_buffers || (num_buffers > 7)) > + return -EINVAL; > + > + rar = qbman_read_register(s, QBMAN_CINH_SWP_RAR); > + if (!RAR_SUCCESS(rar)) > + return -EBUSY; > + > + /* Start the release command */ > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_RCR(RAR_IDX(rar))); > + /* Copy the caller's buffer pointers to the command */ > + for (i = 0; i < num_buffers; i++) > + p->buf[i] = cpu_to_le64(buffers[i]); > + Hi Stuart, We also need to set BPID field in the buffer release command, something like: + p->bpid = d->bpid; Without this all buffers will be released to buffer pool id 0, which is incorrect. > + /* > + * Set the verb byte, have to substitute in the valid-bit and the > number > + * of buffers. > + */ > + dma_wmb(); > + p->verb = d->verb | RAR_VB(rar) | num_buffers; > + > + return 0; > +} > + > +struct qbman_acquire_desc { > + u8 verb; > + u8 reserved; > + u16 bpid; > + u8 num; > + u8 reserved2[59]; > +}; > + > +struct qbman_acquire_rslt { > + u8 verb; > + u8 rslt; > + u16 reserved; > + u8 num; > + u8 reserved2[3]; > + u64 buf[7]; > +}; > + > +/** > + * qbman_swp_acquire() - Issue a buffer acquire command > + * @s: the software portal object > + * @bpid:the buffer pool index > + * @buffers: a pointer pointing to the acquired buffer addresses > + * @num_buffers: number of buffers to be acquired, must be less than 8 > + * > + * Return 0 for success, or negative error code if the acquire command > + * fails. > + */ > +int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers, > + unsigned int num_buffers) > +{ > + struct qbman_acquire_desc *p; > + struct qbman_acquire_rslt *r; > + int i; > + > + if (!num_buffers || (num_buffers > 7)) > + return -EINVAL; > + > + /* Start the management command */ > + p = qbman_swp_mc_start(s); qbman_swp_mc_start() returns a pointer to where the QBMan management command must be written, but doesn't clear any previ
[PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
From: Roy PledgeAdd QBman APIs for frame queue and buffer pool operations. Signed-off-by: Roy Pledge Signed-off-by: Haiying Wang Signed-off-by: Stuart Yoder --- drivers/bus/fsl-mc/dpio/Makefile |2 +- drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ 3 files changed, 1474 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile index 128befc..6588498 100644 --- a/drivers/bus/fsl-mc/dpio/Makefile +++ b/drivers/bus/fsl-mc/dpio/Makefile @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o -fsl-mc-dpio-objs := dpio.o +fsl-mc-dpio-objs := dpio.o qbman-portal.o diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl-mc/dpio/qbman-portal.c new file mode 100644 index 000..1eb3dd9 --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c @@ -0,0 +1,1009 @@ +/* + * Copyright (C) 2014 Freescale Semiconductor, Inc. + * + * 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 Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``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 Freescale Semiconductor 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 +#include +#include +#include + +#include "qbman-portal.h" + +#define QMAN_REV_4000 0x0400 +#define QMAN_REV_4100 0x0401 +#define QMAN_REV_4101 0x04010001 + +/* All QBMan command and result structures use this "valid bit" encoding */ +#define QB_VALID_BIT ((u32)0x80) + +/* QBMan portal management command codes */ +#define QBMAN_MC_ACQUIRE 0x30 +#define QBMAN_WQCHAN_CONFIGURE 0x46 + +/* CINH register offsets */ +#define QBMAN_CINH_SWP_EQAR0x8c0 +#define QBMAN_CINH_SWP_DQPI0xa00 +#define QBMAN_CINH_SWP_DCAP0xac0 +#define QBMAN_CINH_SWP_SDQCR 0xb00 +#define QBMAN_CINH_SWP_RAR 0xcc0 +#define QBMAN_CINH_SWP_ISR 0xe00 +#define QBMAN_CINH_SWP_IER 0xe40 +#define QBMAN_CINH_SWP_ISDR0xe80 +#define QBMAN_CINH_SWP_IIR 0xec0 + +/* CENA register offsets */ +#define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((u32)(n) << 6)) +#define QBMAN_CENA_SWP_DQRR(n) (0x200 + ((u32)(n) << 6)) +#define QBMAN_CENA_SWP_RCR(n) (0x400 + ((u32)(n) << 6)) +#define QBMAN_CENA_SWP_CR 0x600 +#define QBMAN_CENA_SWP_RR(vb) (0x700 + ((u32)(vb) >> 1)) +#define QBMAN_CENA_SWP_VDQCR 0x780 + +/* Reverse mapping of QBMAN_CENA_SWP_DQRR() */ +#define QBMAN_IDX_FROM_DQRR(p) (((unsigned long)p & 0x1ff) >> 6) + +/* SDQCR attribute codes */ +#define QB_SDQCR_FC_SHIFT 29 +#define QB_SDQCR_FC_MASK0x1 +#define QB_SDQCR_DCT_SHIFT 24 +#define QB_SDQCR_DCT_MASK 0x3 +#define QB_SDQCR_SRC_SHIFT 0 +#define QB_SDQCR_SRC_MASK 0xff + +enum qbman_sdqcr_dct { + qbman_sdqcr_dct_null = 0, + qbman_sdqcr_dct_prio_ics, + qbman_sdqcr_dct_active_ics, + qbman_sdqcr_dct_active +}; + +enum qbman_sdqcr_fc { + qbman_sdqcr_fc_one = 0, + qbman_sdqcr_fc_up_to_3 = 1 +}; + +/* Portal Access */ + +static inline u32 qbman_read_register(struct qbman_swp *p, u32 offset) +{ + return readl_relaxed(p->addr_cinh + offset); +} + +static inline void qbman_write_register(struct qbman_swp *p, u32 offset, +