RE: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-28 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, September 28, 2017 4:18 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: Dan Carpenter <dan.carpen...@oracle.com>;
> de...@driverdev.osuosl.org; a...@arndb.de; stuyo...@gmail.com; Roy
> Pledge <roy.ple...@nxp.com>; linux-ker...@vger.kernel.org;
> ag...@suse.de; Bogdan Purcareata <bogdan.purcare...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> 
> On Thu, Sep 28, 2017 at 01:07:48PM +, Ruxandra Ioana Radulescu wrote:
> > > -Original Message-
> > > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > > Sent: Thursday, September 28, 2017 3:49 PM
> > > To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> > > Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org;
> > > a...@arndb.de; stuyo...@gmail.com; Roy Pledge
> <roy.ple...@nxp.com>;
> > > linux-ker...@vger.kernel.org; ag...@suse.de; Bogdan Purcareata
> > > <bogdan.purcare...@nxp.com>; Laurentiu Tudor
> > > <laurentiu.tu...@nxp.com>
> > > Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> > >
> > > On Wed, Sep 27, 2017 at 12:57:28PM -0500, Ioana Radulescu wrote:
> > > > diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > index f809682..26922fc 100644
> > > > --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > @@ -76,7 +76,7 @@ static inline struct dpaa2_io
> > > *service_select_by_cpu(struct dpaa2_io *d,
> > > > if (d)
> > > > return d;
> > > >
> > > > -   if (unlikely(cpu >= num_possible_cpus()))
> > > > +   if (unlikely(cpu >= (int)num_possible_cpus()))
> > >
> > >
> > > Drivers shouldn't use likely/unlikley.
> >
> > I was under the impression it's ok to use them on hotpath
> > (and while not entirely obvious, this function is called on
> > other drivers' hotpath).
> 
> Only use it if you can measure the difference.  If you can not, then do
> not use it as the compiler and the CPU will guess it better than you
> will.
> 
> This has been proven many times, something like 80% of our
> likely/unlikely usage in the kernel is wrong because of this, see the
> work from Andi Kleen many years ago in this area.
> 
> So please remove it.  Unless you can prove it matters, and if so,
> document that.
 
Greg, thanks for the explanation. Will remove it in v2.

Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-28 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Thursday, September 28, 2017 3:49 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org;
> a...@arndb.de; stuyo...@gmail.com; Roy Pledge <roy.ple...@nxp.com>;
> linux-ker...@vger.kernel.org; ag...@suse.de; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; Laurentiu Tudor
> <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> 
> On Wed, Sep 27, 2017 at 12:57:28PM -0500, Ioana Radulescu wrote:
> > diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > index f809682..26922fc 100644
> > --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > @@ -76,7 +76,7 @@ static inline struct dpaa2_io
> *service_select_by_cpu(struct dpaa2_io *d,
> > if (d)
> > return d;
> >
> > -   if (unlikely(cpu >= num_possible_cpus()))
> > +   if (unlikely(cpu >= (int)num_possible_cpus()))
> 
> 
> Drivers shouldn't use likely/unlikley.
 
I was under the impression it's ok to use them on hotpath
(and while not entirely obvious, this function is called on
other drivers' hotpath).

> Please write it more explicitly like this:
> 
>   if (cpu != -1 && cpu >= num_possible_cpus())
>   return NULL;
> 
> Same for the other one as well.

Will rewrite as you suggested in the second email and send a v2.

Thanks,
Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging: fsl-dpaa2/eth: fix a couple of implicit includes

2017-06-22 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
> Sent: Thursday, June 22, 2017 3:52 PM
> To: gre...@linuxfoundation.org; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; Bogdan
> Purcareata <bogdan.purcare...@nxp.com>; Leo Li <leoyang...@nxp.com>;
> stuyo...@gmail.com; Roy Pledge <roy.ple...@nxp.com>; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: [PATCH] staging: fsl-dpaa2/eth: fix a couple of implicit includes
> 
> From: Laurentiu Tudor <laurentiu.tu...@nxp.com>
> 
> dpni.c is using byte order macros and error codes but does
> not explicitly include the required kernel header, so add it.
> 
> Signed-off-by: Laurentiu Tudor <laurentiu.tu...@nxp.com>
 
Acked-by: Ioana Radulescu <ruxandra.radule...@nxp.com>

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 15/18] staging: fsl-dpaa2/eth: Reorder priv fields

2017-06-14 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, June 13, 2017 1:04 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; stuyo...@gmail.com; a...@arndb.de;
> linux-ker...@vger.kernel.org; ag...@suse.de; Bharat Bhushan
> <bharat.bhus...@nxp.com>; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; linux-arm-ker...@lists.infradead.org;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH 15/18] staging: fsl-dpaa2/eth: Reorder priv fields
> 
> On Tue, Jun 06, 2017 at 10:00:38AM -0500, Ioana Radulescu wrote:
> > Reorder fields in the device's private structure such that
> > the ones most used on the hotpath are at the beginning of
> > the structure.
> >
> > This brings a small performance improvement due to better
> > cache usage.
> 
> Really?  What kind of performance improvement?  Always be specific.

Fair point, thanks.

The test scenario was ipfwd with small frames and the improvement ~1%,
but I took this patch from an internal repo, so I need to redo the
measurements on the current tree before resending.

> 
> Please fix up and resend.

We're preparing a larger patchset with several optimizations, I'll
probably include the v2 there.

Thanks,
Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/2] staging: fsl-dpaa2/eth: Fix address translations

2017-05-25 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Laurentiu Tudor
> Sent: Wednesday, May 24, 2017 3:34 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>;
> gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> ag...@suse.de; a...@arndb.de; linux-arm-ker...@lists.infradead.org;
> io...@lists.linux-foundation.org; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; stuyo...@gmail.com; Nipun Gupta
> <nipun.gu...@nxp.com>
> Subject: Re: [PATCH 1/2] staging: fsl-dpaa2/eth: Fix address translations
> 
> Hi Ioana,
> 
> Debatable nit inline.
> 
> On 05/24/2017 03:13 PM, Ioana Radulescu wrote:
> > Use the correct mechanisms for translating a DMA-mapped IOVA
> > address into a virtual one. Without this fix, once SMMU is
> > enabled on Layerscape platforms, the Ethernet driver throws
> > IOMMU translation faults.
> >
> > Signed-off-by: Nipun Gupta <nipun.gu...@nxp.com>
> > Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
> > ---
> >   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 25
> +++--
> >   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  1 +
> >   2 files changed, 20 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > index 6f9eed66c64d..3fee0d6f17e0 100644
> > --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > @@ -37,6 +37,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >
> >   #include "../../fsl-mc/include/mc.h"
> >   #include "../../fsl-mc/include/mc-sys.h"
> > @@ -54,6 +55,16 @@ MODULE_DESCRIPTION("Freescale DPAA2 Ethernet
> Driver");
> >
> >   const char dpaa2_eth_drv_version[] = "0.1";
> >
> > +static void *dpaa2_iova_to_virt(struct iommu_domain *domain,
> 
> if you pass a "struct dpaa2_eth_priv *priv" instead of "iommu_domain"
> you can move the priv->iommu_domain reference in the function and
> slightly simplify the call sites.
 
Fair point, but I'd prefer keeping this function independent of the
Ethernet driver's private data structure. This way, if other (future)
DPAA2 drivers will need a similar function, we can just move it
to a common area instead of duplicating the code.

Thanks,
Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging: fsl-dpaa2/eth: add ETHERNET dependency

2017-05-17 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Arnd Bergmann [mailto:a...@arndb.de]
> Sent: Tuesday, May 16, 2017 2:30 PM
> To: Greg Kroah-Hartman <gre...@linuxfoundation.org>; Arnd Bergmann
> <a...@arndb.de>
> Cc: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>;
> de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org
> Subject: [PATCH] staging: fsl-dpaa2/eth: add ETHERNET dependency
> 
> The new driver cannot link correctly when the netdevice infrastructure
> is disabled:
> 
> ERROR: "netdev_info" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-eth.ko]
> undefined!
> ERROR: "skb_to_sgvec" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> ERROR: "napi_disable" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> ERROR: "napi_schedule_prep" [drivers/staging/fsl-dpaa2/ethernet/fsl-
> dpaa2-eth.ko] undefined!
> ERROR: "__napi_schedule_irqoff" [drivers/staging/fsl-dpaa2/ethernet/fsl-
> dpaa2-eth.ko] undefined!
> ERROR: "netif_carrier_on" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> 
> This adds a dependency on NETDEVICES and ETHERNET.
> 
> Fixes: 0352d1d85201 ("staging: fsl-dpaa2/eth: Add APIs for DPNI objects")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/staging/fsl-dpaa2/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-
> dpaa2/Kconfig
> index 2e325cb747ae..730fd6d4db33 100644
> --- a/drivers/staging/fsl-dpaa2/Kconfig
> +++ b/drivers/staging/fsl-dpaa2/Kconfig
> @@ -12,6 +12,7 @@ config FSL_DPAA2
>  config FSL_DPAA2_ETH
>   tristate "Freescale DPAA2 Ethernet"
>   depends on FSL_DPAA2 && FSL_MC_DPIO
> + depends on NETDEVICES && ETHERNET
>   ---help---
> Ethernet driver for Freescale DPAA2 SoCs, using the
> Freescale MC bus driver
> --
> 2.9.0

Thanks!
Acked-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 1/9] bus: fsl-mc: add DPCON object APIs

2017-04-28 Thread Ruxandra Ioana Radulescu


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Friday, April 28, 2017 3:24 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; stuyo...@gmail.com; a...@arndb.de;
> Haiying Wang <haiying.w...@nxp.com>; Roy Pledge
> <roy.ple...@nxp.com>; Alexandru Marginean
> <alexandru.margin...@nxp.com>; linux-ker...@vger.kernel.org;
> ag...@suse.de; Bogdan Hamciuc <bogdan.hamc...@nxp.com>; Bogdan
> Purcareata <bogdan.purcare...@nxp.com>; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH v3 1/9] bus: fsl-mc: add DPCON object APIs
> 
> On Fri, Apr 28, 2017 at 04:50:26AM -0500, Ioana Radulescu wrote:
> > From: Ioana Radulescu <ruxandra.radule...@freescale.com>
> >
> > This patch adds the command building/parsing wrapper functions
> > for the DPCON object. The binary interface version is v3.2.
> 
> The subject should have "staging: fsl-mc: bus: ..." to match the other
> ones (and to catch my filters properly...)

My bad, I must have missed this one when I changed the subject
lines for v2.
 
> I'll take this as-is for now.
 
Thanks a lot!
Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2 8/9] staging: fsl-dpaa2/eth: Add TODO file

2017-04-20 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Stuart Yoder [mailto:stuyo...@gmail.com]
> Sent: Wednesday, April 19, 2017 6:44 AM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; Alexander Graf <ag...@suse.de>; Arnd Bergmann
> <a...@arndb.de>; linux-arm-ker...@lists.infradead.org; Alexandru
> Marginean <alexandru.margin...@nxp.com>; Bogdan Hamciuc
> <bogdan.hamc...@nxp.com>; Laurentiu Tudor <laurentiu.tu...@nxp.com>;
> Roy Pledge <roy.ple...@nxp.com>; Haiying Wang
> <haiying.w...@nxp.com>
> Subject: Re: [PATCH v2 8/9] staging: fsl-dpaa2/eth: Add TODO file
> 
> On Wed, Apr 12, 2017 at 11:25 AM, Ioana Radulescu
> <ruxandra.radule...@nxp.com> wrote:
> > Add a list of TODO items for the Ethernet driver
> >
> > Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
> > ---
> > v2: Add note
> >
> >  drivers/staging/fsl-dpaa2/ethernet/TODO | 14 ++
> >  1 file changed, 14 insertions(+)
> >  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
> >
> > diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO b/drivers/staging/fsl-
> dpaa2/ethernet/TODO
> > new file mode 100644
> > index ..110e66d44b42
> > --- /dev/null
> > +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> > @@ -0,0 +1,14 @@
> > +* Add a DPAA2 MAC kernel driver in order to allow PHY management;
> currently
> > +  the DPMAC objects and their link to DPNIs are handled by MC internally
> > +  and all PHYs are seen as fixed-link
> > +* add more debug support: decide how to expose detailed debug
> statistics,
> > +  add ingress error queue support
> > +* MC firmware uprev; the DPAA2 objects used by the Ethernet driver
> need to
> > +  be kept in sync with binary interface changes in MC
> > +* refine README file
> > +* cleanup
> > +
> > +NOTE: None of the above is must-have before getting the DPAA2
> Ethernet driver
> > +out of staging. The main requirement for that is to have the drivers it
> > +depends on, fsl-mc bus and DPIO driver, moved to drivers/bus and
> drivers/soc
> > +respectively.
> 
> The TODO file should have contact info (I think)...look at other
> drivers/staging TODO
> for examples.

Thanks Stuart, I missed that. If I send a v3 of this patchset I'll include
this update, otherwise I'll send a separate patch for it.

Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file

2016-12-06 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, December 06, 2016 11:58 AM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> ag...@suse.de; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Bogdan Hamciuc
> <bogdan.hamc...@nxp.com>; Stuart Yoder <stuart.yo...@nxp.com>; Roy
> Pledge <roy.ple...@nxp.com>; Laurentiu Tudor
> <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> 
> On Tue, Dec 06, 2016 at 03:34:41AM -0600, Ioana Radulescu wrote:
> > Add a list of TODO items for the Ethernet driver
> >
> > Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
> > ---
> >  drivers/staging/fsl-dpaa2/ethernet/TODO |9 +
> >  1 files changed, 9 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
> >
> > diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO b/drivers/staging/fsl-
> dpaa2/ethernet/TODO
> > new file mode 100644
> > index 000..833265b
> > --- /dev/null
> > +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> > @@ -0,0 +1,9 @@
> > +* Add a DPAA2 MAC kernel driver in order to allow PHY management;
> currently
> > +  the DPMAC objects and their link to DPNIs are handled by MC internally
> > +  and all PHYs are seen as fixed-link
> > +* add more debug support: decide how to expose detailed debug
> statistics,
> > +  add ingress error queue support
> > +* MC firmware uprev; the DPAA2 objects used by the Ethernet driver
> need to
> > +  be kept in sync with binary interface changes in MC
> > +* refine README file
> > +* cleanup
> 
> These seem like very minor things, why not just spend a week and do this
> work and get it merged to the "correct" portion of the kernel tree?  Why
> does this have to go into staging?

Actually the first bullet is not minor at all and requires some design
choices that we aren't yet completely clear with, and which in turn may
affect parts of the Ethernet driver. We figured it would be best to try
adding this in staging first (and also provide this way an example of using
the fsl-mc bus and dpio driver) than wait until all MAC development
questions are ironed-out.
I can remove the other bullets from the TODO list if you think they're
not worth mentioning.

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

2016-11-28 Thread Ruxandra Ioana Radulescu
> -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 ; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li
> ; Roy Pledge ; Roy Pledge
> ; Haiying Wang ; Stuart
> Yoder 
> Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> 
> From: Roy Pledge 
> 
> Add 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

[...]

> +/**
> + * 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

2016-11-10 Thread Ruxandra Ioana Radulescu
 
> -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 ; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li
> ; Roy Pledge ; Roy Pledge
> ; Haiying Wang ; Stuart
> Yoder 
> Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> 
> From: Roy Pledge 
> 
> Add 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 @@

[...] 

> +/**
> + * 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
previous values found there.
We should memset the area to zero before using it.
Same comment applies to other places where this function is used.

> +
> + if (!p)
> + return -EBUSY;
> +
> + /* Encode the caller-provided attributes */
> + p->bpid = cpu_to_le16(bpid);
> + p->num = num_buffers;
> +
> + /* Complete the management command */
> + r = qbman_swp_mc_complete(s, p, p->verb |
> QBMAN_MC_ACQUIRE);


RE: [PATCH 8/9] bus: fsl-mc: dpio: add the DPAA2 DPIO object driver

2016-11-04 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Stuart Yoder
> Sent: Thursday, November 03, 2016 4:38 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Subject: FW: [PATCH 8/9] bus: fsl-mc: dpio: add the DPAA2 DPIO object
> driver
> 
> 
> 
> -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>; Haiying Wang
> <haiying.w...@nxp.com>; Stuart Yoder <stuart.yo...@nxp.com>
> Subject: [PATCH 8/9] bus: fsl-mc: dpio: add the DPAA2 DPIO object driver
> 
> From: Roy Pledge <roy.ple...@nxp.com>
> 
> The DPIO driver registers with the fsl-mc bus to handle bus-related
> events for DPIO objects.  Key responsibility is mapping I/O
> regions, setting up interrupt handlers, and calling the DPIO
> service initialization during probe.
> 
> 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/dpio-driver.c | 289
> ++
>  2 files changed, 290 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/bus/fsl-mc/dpio/dpio-driver.c
> 
> diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-
> mc/dpio/Makefile
> index 0778da7..837d330 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 qbman-portal.o dpio-service.o
> +fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o dpio-driver.o
> diff --git a/drivers/bus/fsl-mc/dpio/dpio-driver.c b/drivers/bus/fsl-
> mc/dpio/dpio-driver.c
> new file mode 100644
> index 000..ad04a2c
> --- /dev/null
> +++ b/drivers/bus/fsl-mc/dpio/dpio-driver.c
> @@ -0,0 +1,289 @@
> +/*
> + * Copyright 2014-2016 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 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#include "qbman-portal.h"
> +#include "dpio.h"
> +#include "dpio-cmd.h"
> +
> +MODULE_LICENSE("Dual BSD/GPL");
> +MODULE_AUTHOR("Freescale Semiconductor, Inc");
> +MODULE_DESCRIPTION("DPIO Driver");
> +
> +struct dpio_priv {
> + struct dpaa2_io *io;
> +};
> +
> +static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
> +{
> +

RE: [PATCH 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-11-04 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Stuart Yoder
> Sent: Friday, November 04, 2016 4:32 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@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>
> Subject: RE: [PATCH 4/9] bus: fsl-mc: dpio: add frame descriptor and
> scatter/gather APIs
> 
>  > +/**
> > > + * dpaa2_fd_set_bpid() - Set the bpid field of frame descriptor
> > > + * @fd: the given frame descriptor
> > > + * @bpid: buffer pool id to be set
> > > + */
> > > +static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
> > > +{
> > > + fd->simple.bpid = bpid;
> > > +}
> >
> > The setter/getter functions for fd.ctrl are missing.
> 
> Ok, will add those.  Does the ethernet driver use that field?
 
Yes.

> 
> > > +
> > > +/**
> > > + * struct dpaa2_sg_entry - the scatter-gathering structure
> > > + * @addr: address of the sg entry
> > > + * @len: length in this sg entry
> > > + * @bpid: buffer pool id
> > > + * @format_offset: offset in the MS 16 bits, BPID in the LS 16 bits
> >
> > Description of the format_offset field is incorrect, it shouldn't
> > contain the reference to BPID.
> 
> Thanks, will fix.
> 
> > > +/**
> > > + * dpaa2_sg_get_len() - Get the length in SG entry
> > > + * @sg: the given scatter-gathering object
> > > + *
> > > + * Return the length.
> > > + */
> > > +static inline u32 dpaa2_sg_get_len(const struct dpaa2_sg_entry *sg)
> > > +{
> > > + if (dpaa2_sg_short_len(sg))
> > > + return le32_to_cpu(sg->len) & SG_SHORT_LEN_MASK;
> > > +
> > > + return le32_to_cpu(sg->len);
> > > +}
> >
> > We should do this in dpaa2_fd_get_len() as well. Hardware is capable of
> > generating FDs with SL bit set for single frame format too, although in
> > practice I've never actually seen it.
> 
> Any suggestion on how to test this case?

Actually, I stand corrected. Apparently WRIOP _always_ generates short
len frames, it just happens that, for the current default settings, the rest
of the bits in the 32bit word that contains the short length field are always
zero.
For FDs generated on the core both formats are accepted, and we use
long length format for the Ethernet driver TX frames.

Thanks,
Ioana
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 7/9] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface

2016-11-04 Thread Ruxandra Ioana Radulescu

> -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 ; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li
> ; Roy Pledge ; Roy Pledge
> ; Haiying Wang ; Stuart
> Yoder 
> Subject: [PATCH 7/9] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface
> 
> From: Roy Pledge 
> 
> The DPIO service interface handles initialization of DPIO objects
> and exports APIs to be used by other DPAA2 object drivers to perform
> queuing and buffer management related operations.  The service allows
> registration of callbacks when frames or notifications are received.
> 
> 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/dpio-service.c | 614
> +
>  include/linux/fsl/dpaa2-io.h   | 138 
>  3 files changed, 753 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/bus/fsl-mc/dpio/dpio-service.c
>  create mode 100644 include/linux/fsl/dpaa2-io.h
> 
> diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-
> mc/dpio/Makefile
> index 6588498..0778da7 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 qbman-portal.o
> +fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
> diff --git a/drivers/bus/fsl-mc/dpio/dpio-service.c b/drivers/bus/fsl-
> mc/dpio/dpio-service.c
> new file mode 100644
> index 000..7a455a7
> --- /dev/null
> +++ b/drivers/bus/fsl-mc/dpio/dpio-service.c
> @@ -0,0 +1,614 @@
> +/*
> + * Copyright 2014-2016 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 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "dpio.h"
> +#include "qbman-portal.h"
> +
> +struct dpaa2_io {
> + atomic_t refs;
> + struct dpaa2_io_desc dpio_desc;
> + struct qbman_swp_desc swp_desc;
> + struct qbman_swp *swp;
> + struct list_head node;
> + spinlock_t lock_mgmt_cmd;
> + spinlock_t lock_notifications;
> + struct list_head notifications;
> +};
> +
> +struct dpaa2_io_store {
> + unsigned int max;
> + dma_addr_t paddr;
> + struct dpaa2_dq *vaddr;
> + void *alloced_addr;/* unaligned value from kmalloc() */
> + unsigned int idx;  /* position of the next-to-be-returned entry */
> + struct qbman_swp *swp; /* portal used to issue VDQCR */
> + struct device *dev;/* device used for DMA mapping */
> +};
> +
> +/* keep a per cpu array of DPIOs for fast access */
> +static struct dpaa2_io *dpio_by_cpu[NR_CPUS];
> +static struct list_head dpio_list = LIST_HEAD_INIT(dpio_list);
> +static 

RE: [PATCH 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-11-04 Thread Ruxandra Ioana Radulescu
> -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 ; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li
> ; Roy Pledge ; Stuart Yoder
> 
> Subject: [PATCH 4/9] bus: fsl-mc: dpio: add frame descriptor and
> scatter/gather APIs
> 
> From: Roy Pledge 
> 
> Add global definitions for DPAA2 frame descriptors and scatter
> gather entries.
> 
> Signed-off-by: Roy Pledge 
> Signed-off-by: Stuart Yoder 
> ---
>  include/linux/fsl/dpaa2-fd.h | 415
> +++
>  1 file changed, 415 insertions(+)
>  create mode 100644 include/linux/fsl/dpaa2-fd.h
> 
> diff --git a/include/linux/fsl/dpaa2-fd.h b/include/linux/fsl/dpaa2-fd.h
> new file mode 100644
> index 000..b3fa9ff
> --- /dev/null
> +++ b/include/linux/fsl/dpaa2-fd.h
> @@ -0,0 +1,415 @@
> +/*
> + * Copyright 2014-2016 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.
> + */
> +#ifndef __FSL_DPAA2_FD_H
> +#define __FSL_DPAA2_FD_H
> +
> +#include 
> +
> +/**
> + * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
> + *
> + * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
> + * Frames can be enqueued and dequeued to Frame Queues (FQs) which
> are consumed
> + * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
> + *
> + * There are three types of frames: single, scatter gather, and frame lists.
> + *
> + * The set of APIs in this file must be used to create, manipulate and
> + * query Frame Descriptors.
> + */
> +
> +/**
> + * struct dpaa2_fd - Struct describing FDs
> + * @words: for easier/faster copying the whole FD structure
> + * @addr:  address in the FD
> + * @len:   length in the FD
> + * @bpid:  buffer pool ID
> + * @format_offset: format and offset fields
> + * @frc:   frame context
> + * @ctrl:  control bits...including dd, sc, va, err, etc
> + * @flc:   flow context address
> + *
> + * This structure represents the basic Frame Descriptor used in the system.
> + */
> +struct dpaa2_fd {
> + union {
> + u32 words[8];
> + struct dpaa2_fd_simple {
> + __le64 addr;
> + __le32 len;
> + __le16 bpid;
> + __le16 format_offset;
> + __le32 frc;
> + __le32 ctrl;
> + __le64 flc;
> + } simple;
> + };
> +};
> +
> +#define FD_OFFSET_MASK 0x0FFF
> +#define FD_FORMAT_MASK 0x3
> +#define FD_FORMAT_SHIFT 12
> +#define SG_SHORT_LEN_FLAG_MASK 0x1
> +#define SG_SHORT_LEN_FLAG_SHIFT 14
> +#define SG_SHORT_LEN_MASK 0x1
> +#define SG_OFFSET_MASK 0x0FFF
> +#define SG_FORMAT_MASK 0x3
> +#define SG_FORMAT_SHIFT 12
> +#define SG_BPID_MASK 0x3FFF
> +#define SG_FINAL_FLAG_MASK 0x1
> +#define SG_FINAL_FLAG_SHIFT 15
> +
> +enum dpaa2_fd_format {
> + dpaa2_fd_single = 0,
> + 

RE: [PATCH 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects

2016-11-02 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Stuart Yoder [mailto:stuart.yo...@nxp.com]
> Sent: Friday, October 21, 2016 5:02 PM
> 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>; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>; Roy Pledge <roy.ple...@nxp.com>; Stuart
> Yoder <stuart.yo...@nxp.com>
> Subject: [PATCH 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects
> 
> From: Ioana Radulescu <ruxandra.radule...@nxp.com>
> 
> Add the command build/parse APIs for operating on DPIO objects through
> the DPAA2 Management Complex.
> 
> Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
> Signed-off-by: Roy Pledge <roy.ple...@nxp.com>
> Signed-off-by: Stuart Yoder <stuart.yo...@nxp.com>
> ---
>  drivers/bus/fsl-mc/Kconfig |  10 ++
>  drivers/bus/fsl-mc/Makefile|   3 +
>  drivers/bus/fsl-mc/dpio/Makefile   |   9 ++
>  drivers/bus/fsl-mc/dpio/dpio-cmd.h | 198
> 
>  drivers/bus/fsl-mc/dpio/dpio.c | 229
> +
>  drivers/bus/fsl-mc/dpio/dpio.h | 108 +
>  6 files changed, 557 insertions(+)
>  create mode 100644 drivers/bus/fsl-mc/dpio/Makefile
>  create mode 100644 drivers/bus/fsl-mc/dpio/dpio-cmd.h
>  create mode 100644 drivers/bus/fsl-mc/dpio/dpio.c
>  create mode 100644 drivers/bus/fsl-mc/dpio/dpio.h
> 
> diff --git a/drivers/bus/fsl-mc/Kconfig b/drivers/bus/fsl-mc/Kconfig
> index 5c009ab..a10aaf0 100644
> --- a/drivers/bus/fsl-mc/Kconfig
> +++ b/drivers/bus/fsl-mc/Kconfig
> @@ -15,3 +15,13 @@ config FSL_MC_BUS
> architecture.  The fsl-mc bus driver handles discovery of
> DPAA2 objects (which are represented as Linux devices) and
> binding objects to drivers.
> +
> +config FSL_MC_DPIO
> +tristate "QorIQ DPAA2 DPIO driver"
> +depends on FSL_MC_BUS
> +help
> +   Driver for the DPAA2 DPIO object.  A DPIO provides queue and
> +   buffer management facilities for software to interact with
> +   other DPAA2 objects. This driver does not expose the DPIO
> +   objects individually, but groups them under a service layer
> +   API.
> diff --git a/drivers/bus/fsl-mc/Makefile b/drivers/bus/fsl-mc/Makefile
> index d56afee..d18df72 100644
> --- a/drivers/bus/fsl-mc/Makefile
> +++ b/drivers/bus/fsl-mc/Makefile
> @@ -17,3 +17,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \
> fsl-mc-msi.o \
> dpmcp.o \
> dpbp.o
> +
> +# MC DPIO driver
> +obj-$(CONFIG_FSL_MC_DPIO) += dpio/
> diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-
> mc/dpio/Makefile
> new file mode 100644
> index 000..128befc
> --- /dev/null
> +++ b/drivers/bus/fsl-mc/dpio/Makefile
> @@ -0,0 +1,9 @@
> +#
> +# QorIQ DPAA2 DPIO driver
> +#
> +
> +subdir-ccflags-y := -Werror
> +
> +obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
> +
> +fsl-mc-dpio-objs := dpio.o
> diff --git a/drivers/bus/fsl-mc/dpio/dpio-cmd.h b/drivers/bus/fsl-
> mc/dpio/dpio-cmd.h
> new file mode 100644
> index 000..b25a4cc
> --- /dev/null
> +++ b/drivers/bus/fsl-mc/dpio/dpio-cmd.h
> @@ -0,0 +1,198 @@
> +/*
> + * Copyright 2013-2016 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 the above-listed copyright holders nor the
> + * names of any 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 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