From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id E9A5C5398 for ; Fri, 14 Dec 2018 02:17:00 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2018 17:16:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,351,1539673200"; d="scan'208";a="107324760" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga007.fm.intel.com with ESMTP; 13 Dec 2018 17:16:58 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 13 Dec 2018 17:16:58 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 13 Dec 2018 17:16:58 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.203]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.201]) with mapi id 14.03.0415.000; Fri, 14 Dec 2018 09:16:54 +0800 From: "Xu, Rosen" To: "Iremonger, Bernard" , "dev@dpdk.org" CC: "Lu, Wenzhuo" , "Wu, Jingjing" , "Yigit, Ferruh" Thread-Topic: [PATCH] app/test-pmd: add IFPGA AFU register read/write access for testpmd Thread-Index: AQHUjV2vOdPOsnIHekinm9VcA5kxyaVyjVSAgArtCHA= Date: Fri, 14 Dec 2018 01:16:53 +0000 Message-ID: <0E78D399C70DA940A335608C6ED296D73A4376D6@SHSMSX104.ccr.corp.intel.com> References: <1544098591-157631-1-git-send-email-rosen.xu@intel.com> <8CEF83825BEC744B83065625E567D7C260D37D6D@IRSMSX108.ger.corp.intel.com> In-Reply-To: <8CEF83825BEC744B83065625E567D7C260D37D6D@IRSMSX108.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2EwM2Y2NzYtYjJlMi00ZWQ5LWFjZmQtNzMzZTg4ZjhmOGEzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibHFCQjA5bnhrZldpZllFK1B0UW5pQVJIbjNUaTg2cTlRUnJJbW11ZnF6V3hzYWpmU2pqbWRtdWdrYnJxRHJVcSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] app/test-pmd: add IFPGA AFU register read/write access for testpmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2018 01:17:01 -0000 Hi Iremonger, All the warnings have been fixed. Thanks a lot. > -----Original Message----- > From: Iremonger, Bernard > Sent: Friday, December 07, 2018 18:25 > To: Xu, Rosen ; dev@dpdk.org > Cc: Lu, Wenzhuo ; Wu, Jingjing > ; Yigit, Ferruh > Subject: RE: [PATCH] app/test-pmd: add IFPGA AFU register read/write acce= ss > for testpmd >=20 > Hi Rosen >=20 > > -----Original Message----- > > From: Xu, Rosen > > Sent: Thursday, December 6, 2018 12:17 PM > > To: dev@dpdk.org > > Cc: Lu, Wenzhuo ; Wu, Jingjing > > ; Iremonger, Bernard > > ; Xu, Rosen ; Yigit, > > Ferruh > > Subject: [PATCH] app/test-pmd: add IFPGA AFU register read/write > > access for testpmd > > > > 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 > > --- > > app/test-pmd/config.c | 112 > > ++++++++++++++++++++++++++++++++++++++++- > > -------- > > app/test-pmd/testpmd.h | 60 ++++++++++++++++++++++++++ > > 2 files changed, 152 insertions(+), 20 deletions(-) > > > > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index > > b9e5dd9..d401bf4 100644 > > --- a/app/test-pmd/config.c > > +++ b/app/test-pmd/config.c > > @@ -872,7 +872,8 @@ void print_valid_ports(void) { > > const struct rte_pci_device *pci_dev; > > const struct rte_bus *bus; > > - uint64_t pci_len; > > + 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 " > > @@ -889,16 +890,19 @@ void print_valid_ports(void) > > bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > if (bus && !strcmp(bus->name, "pci")) { > > pci_dev =3D RTE_DEV_TO_PCI(ports[port_id].dev_info.device); > > + len =3D pci_dev->mem_resource[0].len; > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + afu_dev =3D RTE_DEV_TO_AFU(ports[port_id].dev_info.device); > > + len =3D afu_dev->mem_resource[0].len; > > } else { > > - printf("Not a PCI device\n"); > > + printf("Not a PCI or AFU device\n"); > > return 1; > > } > > > > - pci_len =3D pci_dev->mem_resource[0].len; > > - if (reg_off >=3D pci_len) { > > + if (reg_off >=3D len) { > > printf("Port %d: register offset %u (0x%X) out of port PCI " > > "resource (length=3D%"PRIu64")\n", > > - port_id, (unsigned)reg_off, (unsigned)reg_off, pci_len); > > + port_id, (unsigned)reg_off, (unsigned)reg_off, len); > > return 1; > > } > > return 0; > > @@ -927,7 +931,7 @@ void print_valid_ports(void) > > port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_x)= { > > uint32_t reg_v; > > - > > + const struct rte_bus *bus; > > > > if (port_id_is_invalid(port_id, ENABLED_WARN)) > > return; > > @@ -935,7 +939,16 @@ void print_valid_ports(void) > > return; > > if (reg_bit_pos_is_invalid(bit_x)) > > return; > > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + > > + bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > + if (bus && !strcmp(bus->name, "pci")) { > > + reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + reg_v =3D port_id_afu_reg_read(port_id, reg_off); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > display_port_and_reg_off(port_id, (unsigned)reg_off); > > printf("bit %d=3D%d\n", bit_x, (int) ((reg_v & (1 << bit_x)) >> > > bit_x)); } @@ > > -947,6 +960,7 @@ void print_valid_ports(void) > > uint32_t reg_v; > > uint8_t l_bit; > > uint8_t h_bit; > > + const struct rte_bus *bus; > > > > if (port_id_is_invalid(port_id, ENABLED_WARN)) > > return; > > @@ -961,7 +975,15 @@ void print_valid_ports(void) > > else > > l_bit =3D bit1_pos, h_bit =3D bit2_pos; > > > > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > + if (bus && !strcmp(bus->name, "pci")) { > > + reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + reg_v =3D port_id_afu_reg_read(port_id, reg_off); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > reg_v >>=3D l_bit; > > if (h_bit < 31) > > reg_v &=3D ((1 << (h_bit - l_bit + 1)) - 1); @@ -974,12 +996,22 > @@ > > void print_valid_ports(void) port_reg_display(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; > > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + > > + bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > + if (bus && !strcmp(bus->name, "pci")) { > > + reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + reg_v =3D port_id_afu_reg_read(port_id, reg_off); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > display_port_reg_value(port_id, reg_off, reg_v); } > > > > @@ -988,6 +1020,7 @@ void print_valid_ports(void) > > uint8_t bit_v) > > { > > uint32_t reg_v; > > + const struct rte_bus *bus; > > > > if (port_id_is_invalid(port_id, ENABLED_WARN)) > > return; > > @@ -999,12 +1032,26 @@ void print_valid_ports(void) > > printf("Invalid bit value %d (must be 0 or 1)\n", (int) bit_v); > > return; > > } > > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > - if (bit_v =3D=3D 0) > > - reg_v &=3D ~(1 << bit_pos); > > - else > > - reg_v |=3D (1 << bit_pos); > > - port_id_pci_reg_write(port_id, reg_off, reg_v); > > + > > + bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > + if (bus && !strcmp(bus->name, "pci")) { > > + reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + if (bit_v =3D=3D 0) > > + reg_v &=3D ~(1 << bit_pos); > > + else > > + reg_v |=3D (1 << bit_pos); > > + port_id_pci_reg_write(port_id, reg_off, reg_v); > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + reg_v =3D port_id_afu_reg_read(port_id, reg_off); > > + if (bit_v =3D=3D 0) > > + reg_v &=3D ~(1 << bit_pos); > > + else > > + reg_v |=3D (1 << bit_pos); > > + port_id_afu_reg_write(port_id, reg_off, reg_v); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > display_port_reg_value(port_id, reg_off, reg_v); } > > > > @@ -1016,6 +1063,7 @@ void print_valid_ports(void) > > uint32_t reg_v; > > uint8_t l_bit; > > uint8_t h_bit; > > + const struct rte_bus *bus; > > > > if (port_id_is_invalid(port_id, ENABLED_WARN)) > > return; > > @@ -1041,21 +1089,45 @@ void print_valid_ports(void) > > (unsigned)max_v, (unsigned)max_v); > > return; > > } > > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > - reg_v &=3D ~(max_v << l_bit); /* Keep unchanged bits */ > > - reg_v |=3D (value << l_bit); /* Set changed bits */ > > - port_id_pci_reg_write(port_id, reg_off, reg_v); > > + > > + bus =3D rte_bus_find_by_device(ports[port_id].dev_info.device); > > + if (bus && !strcmp(bus->name, "pci")) { > > + reg_v =3D port_id_pci_reg_read(port_id, reg_off); > > + reg_v &=3D ~(max_v << l_bit); /* Keep unchanged bits */ > > + reg_v |=3D (value << l_bit); /* Set changed bits */ > > + port_id_pci_reg_write(port_id, reg_off, reg_v); > > + } else if (bus && !strcmp(bus->name, "ifpga")) { > > + reg_v =3D port_id_afu_reg_read(port_id, reg_off); > > + reg_v &=3D ~(max_v << l_bit); /* Keep unchanged bits */ > > + reg_v |=3D (value << l_bit); /* Set changed bits */ > > + port_id_afu_reg_write(port_id, reg_off, reg_v); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > display_port_reg_value(port_id, reg_off, reg_v); } > > > > 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; > > - port_id_pci_reg_write(port_id, reg_off, reg_v); > > + > > + bus =3D 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); > > + } else { > > + printf("Not a PCI or AFU device\n"); > > + return; > > + } > > + > > display_port_reg_value(port_id, reg_off, reg_v); } > > > > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index > > 3ff11e6..0f51df4 100644 > > --- a/app/test-pmd/testpmd.h > > +++ b/app/test-pmd/testpmd.h > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > > > #define RTE_PORT_ALL (~(portid_t)0x0) > > > > @@ -671,6 +672,65 @@ struct mplsoudp_decap_conf { #define > > port_id_pci_reg_write(pt_id, reg_off, reg_value) \ > > port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value)) > > > > +/** > > + * Read/Write operations on an AFU register of a port. > > + */ > > +static inline uint32_t > > +port_afu_reg_read(struct rte_port *port, uint32_t reg_off) { > > + const struct rte_afu_device *afu_dev; > > + const struct rte_bus *bus; > > + void *reg_addr; > > + uint32_t reg_v; > > + > > + if (!port->dev_info.device) { > > + printf("Invalid device\n"); > > + return 0; > > + } > > + > > + bus =3D rte_bus_find_by_device(port->dev_info.device); > > + if (bus && !strcmp(bus->name, "ifpga")) { > > + afu_dev =3D RTE_DEV_TO_AFU(port->dev_info.device); > > + } else { > > + printf("Not an IFPGA AFU device\n"); > > + return 0; > > + } > > + > > + reg_addr =3D ((char *)afu_dev->mem_resource[0].addr + reg_off); > > + reg_v =3D *((volatile uint32_t *)reg_addr); > > + return rte_le_to_cpu_32(reg_v); > > +} > > + > > +#define port_id_afu_reg_read(pt_id, reg_off) \ > > + port_afu_reg_read(&ports[(pt_id)], (reg_off)) > > + > > +static inline void > > +port_afu_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t > > +reg_v) { > > + const struct rte_afu_device *afu_dev; > > + const struct rte_bus *bus; > > + void *reg_addr; > > + > > + if (!port->dev_info.device) { > > + printf("Invalid device\n"); > > + return; > > + } > > + > > + bus =3D rte_bus_find_by_device(port->dev_info.device); > > + if (bus && !strcmp(bus->name, "ifpga")) { > > + afu_dev =3D RTE_DEV_TO_AFU(port->dev_info.device); > > + } else { > > + printf("Not an IFPGA AFU device\n"); > > + return; > > + } > > + > > + reg_addr =3D ((char *)afu_dev->mem_resource[0].addr + reg_off); > > + *((volatile uint32_t *)reg_addr) =3D rte_cpu_to_le_32(reg_v); } > > + > > +#define port_id_afu_reg_write(pt_id, reg_off, reg_value) \ > > + port_afu_reg_write(&ports[(pt_id)], (reg_off), (reg_value)) > > + > > /* Prototypes */ > > unsigned int parse_item_list(char* str, const char* item_name, > > unsigned int max_items, > > -- > > 1.8.3.1 >=20 > The following check-git-log.sh and checkpatches.sh warnings should be fix= ed. >=20 > ./devtools/check-git-log.sh -1 > Wrong headline label: > app/test-pmd: add IFPGA AFU register read/write access for testpm= d > Headline too long: > app/test-pmd: add IFPGA AFU register read/write access for testpm= d >=20 > ./devtools/checkpatches.sh app-test-pmd-add-IFPGA-AFU-register-read- > write-access-for-testpmd.patch >=20 > ### app/test-pmd: add IFPGA AFU register read/write access for testpmd > WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' > #61: FILE: app/test-pmd/config.c:905: > + port_id, (unsigned)reg_off, (unsigned)reg_off, > + len); >=20 > WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' > #61: FILE: app/test-pmd/config.c:905: > + port_id, (unsigned)reg_off, (unsigned)reg_off, > + len); >=20 > total: 0 errors, 2 warnings, 271 lines checked >=20 > Regards, >=20 > Bernard. >=20 >=20 >=20