X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_pci.c;h=f8095745b2e6402a21e64673f71ca6c4c97382e6;hb=3031749c2df04a63cdcef186dcce3781e61436e8;hp=ac2c1fe2eafdaf3db332e04ce92da0762431ccb2;hpb=d10296d7ea9c7e4f0da51ff2fb9c89b838e06940;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index ac2c1fe2ea..f8095745b2 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -1,13 +1,13 @@ /*- * BSD LICENSE - * + * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * + * * 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 @@ -17,7 +17,7 @@ * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * 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 @@ -195,14 +195,14 @@ pci_uio_get_mappings(const char *devname, struct uio_map maps[], size_t nb_maps) uint64_t offset, size; for (i = 0; i != nb_maps; i++) { - + /* check if map directory exists */ - rte_snprintf(dirname, sizeof(dirname), + rte_snprintf(dirname, sizeof(dirname), "%s/maps/map%u", devname, i); - + if (access(dirname, F_OK) != 0) break; - + /* get mapping offset */ rte_snprintf(filename, sizeof(filename), "%s/offset", dirname); @@ -212,7 +212,7 @@ pci_uio_get_mappings(const char *devname, struct uio_map maps[], size_t nb_maps) __func__, dirname); return (-1); } - + /* get mapping size */ rte_snprintf(filename, sizeof(filename), "%s/size", dirname); @@ -222,7 +222,7 @@ pci_uio_get_mappings(const char *devname, struct uio_map maps[], size_t nb_maps) __func__, dirname); return (-1); } - + /* get mapping physical address */ rte_snprintf(filename, sizeof(filename), "%s/addr", dirname); @@ -236,7 +236,7 @@ pci_uio_get_mappings(const char *devname, struct uio_map maps[], size_t nb_maps) if ((offset > OFF_MAX) || (size > SIZE_MAX)) { RTE_LOG(ERR, EAL, "%s(): offset/size exceed system max value\n", - __func__); + __func__); return (-1); } @@ -358,7 +358,7 @@ static int pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf, /* format could be uio%d ...*/ int shortprefix_len = sizeof("uio") - 1; /* ... or uio:uio%d */ - int longprefix_len = sizeof("uio:uio") - 1; + int longprefix_len = sizeof("uio:uio") - 1; char *endptr; if (strncmp(e->d_name, "uio", 3) != 0) @@ -521,13 +521,13 @@ pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev) for (i = 0; imem_resource[i].phys_addr = phys_addr; dev->mem_resource[i].len = end_addr - phys_addr + 1; /* not mapped for now */ - dev->mem_resource[i].addr = NULL; + dev->mem_resource[i].addr = NULL; } } fclose(f); @@ -556,24 +556,24 @@ error: return -1; } -/* - * parse a sysfs file containing one integer value +/* + * parse a sysfs file containing one integer value * different to the eal version, as it needs to work with 64-bit values - */ -static int -pci_parse_sysfs_value(const char *filename, uint64_t *val) + */ +static int +pci_parse_sysfs_value(const char *filename, uint64_t *val) { FILE *f; char buf[BUFSIZ]; char *end = NULL; - + f = fopen(filename, "r"); if (f == NULL) { RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", __func__, filename); return -1; } - + if (fgets(buf, sizeof(buf), f) == NULL) { RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", __func__, filename); @@ -662,7 +662,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, /* get max_vfs */ dev->max_vfs = 0; rte_snprintf(filename, sizeof(filename), "%s/max_vfs", dirname); - if (!access(filename, F_OK) && + if (!access(filename, F_OK) && eal_parse_sysfs_value(filename, &tmp) == 0) { dev->max_vfs = (uint16_t)tmp; } @@ -692,7 +692,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, /* device is valid, add in list (sorted) */ if (TAILQ_EMPTY(&pci_device_list)) { TAILQ_INSERT_TAIL(&pci_device_list, dev, next); - } + } else { struct rte_pci_device *dev2 = NULL; @@ -706,7 +706,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } TAILQ_INSERT_TAIL(&pci_device_list, dev, next); } - + return 0; }