[dpdk-dev,v4,1/5] eal: Fix coding style of eal_pci.c and eal_pci_uio.c

Message ID 1432014898-3543-2-git-send-email-mukawa@igel.co.jp (mailing list archive)
State Superseded, archived
Headers

Commit Message

Tetsuya Mukawa May 19, 2015, 5:54 a.m. UTC
  This patch fixes coding style of below files in linuxapp and bsdapp.
 - eal_pci.c
 - eal_pci_uio.c

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_eal/bsdapp/eal/eal_pci.c       | 24 +++++++++++++-----------
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 12 ++++++++----
 2 files changed, 21 insertions(+), 15 deletions(-)
  

Comments

Stephen Hemminger May 19, 2015, 2:51 p.m. UTC | #1
Acked-by: Stephen Hemminger <stephen@networkplumber.org>

On Mon, May 18, 2015 at 10:54 PM, Tetsuya Mukawa <mukawa@igel.co.jp> wrote:

> This patch fixes coding style of below files in linuxapp and bsdapp.
>  - eal_pci.c
>  - eal_pci_uio.c
>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> ---
>  lib/librte_eal/bsdapp/eal/eal_pci.c       | 24 +++++++++++++-----------
>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 12 ++++++++----
>  2 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c
> b/lib/librte_eal/bsdapp/eal/eal_pci.c
> index 61e8921..8e24fd1 100644
> --- a/lib/librte_eal/bsdapp/eal/eal_pci.c
> +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
> @@ -161,9 +161,10 @@ fail:
>  static int
>  pci_uio_map_secondary(struct rte_pci_device *dev)
>  {
> -        size_t i;
> -        struct uio_resource *uio_res;
> -       struct uio_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
> +       size_t i;
> +       struct uio_resource *uio_res;
> +       struct uio_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
>
>         TAILQ_FOREACH(uio_res, uio_res_list, next) {
>
> @@ -179,10 +180,10 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
>                             != uio_res->maps[i].addr) {
>                                 RTE_LOG(ERR, EAL,
>                                         "Cannot mmap device resource\n");
> -                               return (-1);
> +                               return -1;
>                         }
>                 }
> -               return (0);
> +               return 0;
>         }
>
>         RTE_LOG(ERR, EAL, "Cannot find resource for device\n");
> @@ -201,7 +202,8 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>         uint64_t pagesz;
>         struct rte_pci_addr *loc = &dev->addr;
>         struct uio_resource *uio_res;
> -       struct uio_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
> +       struct uio_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
>         struct uio_map *maps;
>
>         dev->intr_handle.fd = -1;
> @@ -209,7 +211,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>
>         /* secondary processes - use already recorded details */
>         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> -               return (pci_uio_map_secondary(dev));
> +               return pci_uio_map_secondary(dev);
>
>         snprintf(devname, sizeof(devname), "/dev/uio@pci:%u:%u:%u",
>                         dev->addr.bus, dev->addr.devid,
> dev->addr.function);
> @@ -233,7 +235,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>         if ((uio_res = rte_zmalloc("UIO_RES", sizeof (*uio_res), 0)) ==
> NULL) {
>                 RTE_LOG(ERR, EAL,
>                         "%s(): cannot store uio mmap details\n", __func__);
> -               return (-1);
> +               return -1;
>         }
>
>         snprintf(uio_res->path, sizeof(uio_res->path), "%s", devname);
> @@ -261,7 +263,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>                                                 (size_t)maps[j].size)
>                     ) == NULL) {
>                         rte_free(uio_res);
> -                       return (-1);
> +                       return -1;
>                 }
>
>                 maps[j].addr = mapaddr;
> @@ -271,7 +273,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>
>         TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);
>
> -       return (0);
> +       return 0;
>  }
>
>  /* Scan one pci sysfs entry, and fill the devices list from it. */
> @@ -311,7 +313,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
>         /* FreeBSD has no NUMA support (yet) */
>         dev->numa_node = 0;
>
> -/* parse resources */
> +       /* parse resources */
>         switch (conf->pc_hdr & PCIM_HDRTYPE) {
>         case PCIM_HDRTYPE_NORMAL:
>                 max = PCIR_MAX_BAR_0;
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> index b5116a7..5d3354d 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -92,7 +92,8 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
>  {
>         int fd, i;
>         struct mapped_pci_resource *uio_res;
> -       struct mapped_pci_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
> +       struct mapped_pci_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head,
> mapped_pci_res_list);
>
>         TAILQ_FOREACH(uio_res, uio_res_list, next) {
>
> @@ -272,7 +273,8 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>         uint64_t phaddr;
>         struct rte_pci_addr *loc = &dev->addr;
>         struct mapped_pci_resource *uio_res;
> -       struct mapped_pci_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
> +       struct mapped_pci_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head,
> mapped_pci_res_list);
>         struct pci_map *maps;
>
>         dev->intr_handle.fd = -1;
> @@ -417,7 +419,8 @@ static struct mapped_pci_resource *
>  pci_uio_find_resource(struct rte_pci_device *dev)
>  {
>         struct mapped_pci_resource *uio_res;
> -       struct mapped_pci_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
> +       struct mapped_pci_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head,
> mapped_pci_res_list);
>
>         if (dev == NULL)
>                 return NULL;
> @@ -436,7 +439,8 @@ void
>  pci_uio_unmap_resource(struct rte_pci_device *dev)
>  {
>         struct mapped_pci_resource *uio_res;
> -       struct mapped_pci_res_list *uio_res_list =
> RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
> +       struct mapped_pci_res_list *uio_res_list =
> +                       RTE_TAILQ_CAST(rte_uio_tailq.head,
> mapped_pci_res_list);
>
>         if (dev == NULL)
>                 return;
> --
> 2.1.4
>
>
  
Tetsuya Mukawa June 25, 2015, 3:19 a.m. UTC | #2
This patch set cleans up pci uio implementation. These clean up are
for consolidating pci uio implementation of linuxapp and bsdapp, and
moving consolidated functions in eal common.
Because of above, this patch set tries to implement linuxapp and bsdapp
almost same.
Actual consolidations will be done later patch set.

PATCH v5 changes:
 - Rebase to latest master branch.

PATCH v4 changes:
 - Rebase to latest master branch.
 - Fix bug in pci_uio_map_resource() of BSD code. 'maps[i].path' shouldn't be freed.
     Fixed in below patch:
     [PATCH 3/5] eal: Fix memory leaks and needless increment of pci_map_addr
 - 'path' member of 'struct mapped_pci_resource' should not be removed because it will be used in BSD code.
     Fixed in below patch:
     [PATCH 5/5] eal: Fix uio mapping differences between linuxapp and bsdapp

PATCH v3 changes:
 - Squash patches related with pci_map_resource().
 - Free maps[].path to easy to understand.
   (Thanks to Iremonger, Bernard)
 - Close fds opened in this function.
 - Remove unused path variable from mapped_pci_resource structure.

PATCH v2 changes:
 - Move 'if-condition' to later patch series.
 - Fix memory leaks of path.
 - Fix typos.
   (Thanks to David Marchand)
 - Fix commit title and body.
 - Fix pci_map_resource() to handle MAP_FAILED.
   (Thanks to Iremonger, Bernard)

Changes:
 - This patch set is derived from below.
   "[PATCH v2] eal: Port Hotplug support for BSD"
 - Set cfg_fd as -1, when cfg_fd is closed.
   (Thanks to Iremonger, Bernard)
 - Remove needless coding style fixings.
 - Fix coding style of if-else condition.
   (Thanks to Richardson, Bruce)



Tetsuya.Mukawa (5):
  eal: Fix coding style of eal_pci.c and eal_pci_uio.c
  eal: Close file descriptor of uio configuration
  eal: Fix memory leaks and needless increment of pci_map_addr
  eal/bsdapp: Change names of pci related data structure
  eal: Fix uio mapping differences between linuxapp and bsdapp

 lib/librte_eal/bsdapp/eal/eal_pci.c       | 156 ++++++++++++++++++------------
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c |  88 ++++++++++-------
 2 files changed, 149 insertions(+), 95 deletions(-)
  

Patch

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 61e8921..8e24fd1 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -161,9 +161,10 @@  fail:
 static int
 pci_uio_map_secondary(struct rte_pci_device *dev)
 {
-        size_t i;
-        struct uio_resource *uio_res;
-	struct uio_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
+	size_t i;
+	struct uio_resource *uio_res;
+	struct uio_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
 
 	TAILQ_FOREACH(uio_res, uio_res_list, next) {
 
@@ -179,10 +180,10 @@  pci_uio_map_secondary(struct rte_pci_device *dev)
 			    != uio_res->maps[i].addr) {
 				RTE_LOG(ERR, EAL,
 					"Cannot mmap device resource\n");
-				return (-1);
+				return -1;
 			}
 		}
-		return (0);
+		return 0;
 	}
 
 	RTE_LOG(ERR, EAL, "Cannot find resource for device\n");
@@ -201,7 +202,8 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 	uint64_t pagesz;
 	struct rte_pci_addr *loc = &dev->addr;
 	struct uio_resource *uio_res;
-	struct uio_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
+	struct uio_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, uio_res_list);
 	struct uio_map *maps;
 
 	dev->intr_handle.fd = -1;
@@ -209,7 +211,7 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 
 	/* secondary processes - use already recorded details */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-		return (pci_uio_map_secondary(dev));
+		return pci_uio_map_secondary(dev);
 
 	snprintf(devname, sizeof(devname), "/dev/uio@pci:%u:%u:%u",
 			dev->addr.bus, dev->addr.devid, dev->addr.function);
@@ -233,7 +235,7 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 	if ((uio_res = rte_zmalloc("UIO_RES", sizeof (*uio_res), 0)) == NULL) {
 		RTE_LOG(ERR, EAL,
 			"%s(): cannot store uio mmap details\n", __func__);
-		return (-1);
+		return -1;
 	}
 
 	snprintf(uio_res->path, sizeof(uio_res->path), "%s", devname);
@@ -261,7 +263,7 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 						(size_t)maps[j].size)
 		    ) == NULL) {
 			rte_free(uio_res);
-			return (-1);
+			return -1;
 		}
 
 		maps[j].addr = mapaddr;
@@ -271,7 +273,7 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 
 	TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);
 
-	return (0);
+	return 0;
 }
 
 /* Scan one pci sysfs entry, and fill the devices list from it. */
@@ -311,7 +313,7 @@  pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 	/* FreeBSD has no NUMA support (yet) */
 	dev->numa_node = 0;
 
-/* parse resources */
+	/* parse resources */
 	switch (conf->pc_hdr & PCIM_HDRTYPE) {
 	case PCIM_HDRTYPE_NORMAL:
 		max = PCIR_MAX_BAR_0;
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index b5116a7..5d3354d 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -92,7 +92,8 @@  pci_uio_map_secondary(struct rte_pci_device *dev)
 {
 	int fd, i;
 	struct mapped_pci_resource *uio_res;
-	struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
+	struct mapped_pci_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
 	TAILQ_FOREACH(uio_res, uio_res_list, next) {
 
@@ -272,7 +273,8 @@  pci_uio_map_resource(struct rte_pci_device *dev)
 	uint64_t phaddr;
 	struct rte_pci_addr *loc = &dev->addr;
 	struct mapped_pci_resource *uio_res;
-	struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
+	struct mapped_pci_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 	struct pci_map *maps;
 
 	dev->intr_handle.fd = -1;
@@ -417,7 +419,8 @@  static struct mapped_pci_resource *
 pci_uio_find_resource(struct rte_pci_device *dev)
 {
 	struct mapped_pci_resource *uio_res;
-	struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
+	struct mapped_pci_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
 	if (dev == NULL)
 		return NULL;
@@ -436,7 +439,8 @@  void
 pci_uio_unmap_resource(struct rte_pci_device *dev)
 {
 	struct mapped_pci_resource *uio_res;
-	struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
+	struct mapped_pci_res_list *uio_res_list =
+			RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
 	if (dev == NULL)
 		return;