All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Rosen Xu <rosen.xu@intel.com>, dev@dpdk.org
Cc: wenzhuo.lu@intel.com, jingjing.wu@intel.com, bernard.iremonger@intel.com
Subject: Re: [PATCH v6] app/testpmd: add IFPGA AFU register access function
Date: Tue, 8 Jan 2019 15:28:01 +0000	[thread overview]
Message-ID: <a3b4dbd0-fb37-9db1-27e6-c3934f504a8b@intel.com> (raw)
In-Reply-To: <1546409941-135237-1-git-send-email-rosen.xu@intel.com>

On 1/2/2019 6:19 AM, Rosen Xu wrote:
> Currently register read/write of testpmd is only for PCI device,
> but more and more IFPGA based AFU devices need this feature to
> access registers, this patch will add support for it.
> 
> Signed-off-by: Rosen Xu <rosen.xu@intel.com>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 
> v5 updates:
> ===========
>  - Added Macro to fix compile dependency of ifpga for testpmd
> ---
>  app/test-pmd/config.c  | 253 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  app/test-pmd/testpmd.h |  64 +++++++++++++
>  2 files changed, 315 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index b9e5dd9..5600ef5 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -866,7 +866,50 @@ void print_valid_ports(void)
>  	printf("Invalid vlan_id %d (must be < 4096)\n", vlan_id);
>  	return 1;
>  }
> +#ifdef RTE_LIBRTE_IFPGA_BUS
> +static int
> +port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off)
> +{
> +	const struct rte_pci_device *pci_dev;
> +	const struct rte_bus *bus;
> +	uint64_t len;
> +	const struct rte_afu_device *afu_dev;
>  
> +	if (reg_off & 0x3) {
> +		printf("Port register offset 0x%X not aligned on a 4-byte "
> +		       "boundary\n",
> +		       (unsigned int)reg_off);
> +		return 1;
> +	}
> +
> +	if (!ports[port_id].dev_info.device) {
> +		printf("Invalid device\n");
> +		return 0;
> +	}
> +
> +	bus = rte_bus_find_by_device(ports[port_id].dev_info.device);
> +	if (bus && !strcmp(bus->name, "pci")) {
> +		pci_dev = RTE_DEV_TO_PCI(ports[port_id].dev_info.device);
> +		len = pci_dev->mem_resource[0].len;
> +	} else if (bus && !strcmp(bus->name, "ifpga")) {
> +		afu_dev = RTE_DEV_TO_AFU(ports[port_id].dev_info.device);
> +		len = afu_dev->mem_resource[0].len;
> +	} else {
> +		printf("Not a PCI or AFU device\n");
> +		return 1;
> +	}
> +
> +	if (reg_off >= len) {
> +		printf("Port %d: register offset %u (0x%X) out of port "
> +		       "PCI or AFU device "
> +		       "resource (length=%"PRIu64")\n",
> +		       port_id, (unsigned int)reg_off,
> +			(unsigned int)reg_off, len);
> +		return 1;
> +	}
> +	return 0;
> +}

Do we need to duplicate all function? I think wrapping only following part with
'#ifdef RTE_LIBRTE_IFPGA_BUS' can work:

  	} else if (bus && !strcmp(bus->name, "ifpga")) {
  		afu_dev = RTE_DEV_TO_AFU(ports[port_id].dev_info.device);


<...>

> +void
> +port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
> +{
> +	const struct rte_bus *bus;
> +
> +	if (port_id_is_invalid(port_id, ENABLED_WARN))
> +		return;
> +	if (port_reg_off_is_invalid(port_id, reg_off))
> +		return;
> +
> +	bus = rte_bus_find_by_device(ports[port_id].dev_info.device);
> +	if (bus && !strcmp(bus->name, "pci")) {
> +		port_id_pci_reg_write(port_id, reg_off, reg_v);
> +	} else if (bus && !strcmp(bus->name, "ifpga")) {
> +		port_id_afu_reg_write(port_id, reg_off, reg_v);

Same thing for all above functions, instead of duplication all function with
#ifdef, only wrapping "ifpga" related lines should work.

<...>

> @@ -11,6 +11,9 @@
>  #include <rte_bus_pci.h>
>  #include <rte_gro.h>
>  #include <rte_gso.h>
> +#ifdef RTE_LIBRTE_IFPGA_BUS
> +#include <rte_bus_ifpga.h>
> +#endif

This is causing build error with meson, because 'bus_ifpga' is not added as a
dependency to testpmd. Can you please fix it?

      reply	other threads:[~2019-01-08 15:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 12:16 [PATCH] app/test-pmd: add IFPGA AFU register read/write access for testpmd Rosen Xu
2018-12-07 10:24 ` Iremonger, Bernard
2018-12-14  1:16   ` Xu, Rosen
2018-12-14  1:14 ` [PATCH v2] " Rosen Xu
2018-12-14 10:18   ` Iremonger, Bernard
2018-12-17 12:17     ` Xu, Rosen
2018-12-14 17:37   ` Pattan, Reshma
2018-12-17 12:16     ` Xu, Rosen
2018-12-17 12:29 ` [PATCH v3] app/test-pmd: add IFPGA AFU register access fuction " Rosen Xu
2018-12-17 12:56 ` [PATCH v4] app/test-pmd: add IFPGA AFU register access function " Rosen Xu
2018-12-18 10:21   ` Iremonger, Bernard
2018-12-18 11:32     ` Xu, Rosen
2018-12-18 11:30 ` [PATCH v5] app/testpmd: add IFPGA AFU register access function Rosen Xu
2018-12-18 18:12   ` Iremonger, Bernard
2018-12-20  8:58     ` Ferruh Yigit
2018-12-20 10:48       ` Xu, Rosen
2018-12-20 14:22         ` Ferruh Yigit
2019-01-02  6:20           ` Xu, Rosen
2018-12-20 12:57   ` Ferruh Yigit
2019-01-02  6:19 ` [PATCH v6] " Rosen Xu
2019-01-08 15:28   ` Ferruh Yigit [this message]

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=a3b4dbd0-fb37-9db1-27e6-c3934f504a8b@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=rosen.xu@intel.com \
    --cc=wenzhuo.lu@intel.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 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.