hash: fallback to software CRC32 implementation
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci.c
index ddb0535..63bcbce 100644 (file)
@@ -97,6 +97,25 @@ error:
        return -1;
 }
 
+void *
+pci_find_max_end_va(void)
+{
+       const struct rte_memseg *seg = rte_eal_get_physmem_layout();
+       const struct rte_memseg *last = seg;
+       unsigned i = 0;
+
+       for (i = 0; i < RTE_MAX_MEMSEG; i++, seg++) {
+               if (seg->addr == NULL)
+                       break;
+
+               if (seg->addr > last->addr)
+                       last = seg;
+
+       }
+       return RTE_PTR_ADD(last->addr, last->len);
+}
+
+
 /* map a particular resource from a file */
 void *
 pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size)
@@ -106,26 +125,19 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size)
        /* Map the PCI memory resource of device */
        mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
                        MAP_SHARED, fd, offset);
-       if (mapaddr == MAP_FAILED ||
-                       (requested_addr != NULL && mapaddr != requested_addr)) {
+       if (mapaddr == MAP_FAILED) {
                RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n",
                        __func__, fd, requested_addr,
                        (unsigned long)size, (unsigned long)offset,
                        strerror(errno), mapaddr);
-               goto fail;
+       } else {
+               RTE_LOG(DEBUG, EAL, "  PCI memory mapped at %p\n", mapaddr);
        }
 
-       RTE_LOG(DEBUG, EAL, "  PCI memory mapped at %p\n", mapaddr);
-
        return mapaddr;
-
-fail:
-       return NULL;
 }
 
 /* parse the "resource" sysfs file */
-#define IORESOURCE_MEM  0x00000200
-
 static int
 pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
 {
@@ -258,8 +270,15 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
        dev->max_vfs = 0;
        snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
        if (!access(filename, F_OK) &&
-           eal_parse_sysfs_value(filename, &tmp) == 0) {
+           eal_parse_sysfs_value(filename, &tmp) == 0)
                dev->max_vfs = (uint16_t)tmp;
+       else {
+               /* for non igb_uio driver, need kernel version >= 3.8 */
+               snprintf(filename, sizeof(filename),
+                        "%s/sriov_numvfs", dirname);
+               if (!access(filename, F_OK) &&
+                   eal_parse_sysfs_value(filename, &tmp) == 0)
+                       dev->max_vfs = (uint16_t)tmp;
        }
 
        /* get numa node */
@@ -498,7 +517,7 @@ pci_map_device(struct rte_pci_device *dev)
                        return ret;
        }
 #endif
-       /* map resources for devices that use igb_uio */
+       /* map resources for devices that use uio_pci_generic or igb_uio */
        if (!mapped) {
                ret = pci_uio_map_resource(dev);
                if (ret != 0)