net/i40e: warn when writing global registers
[dpdk.git] / drivers / net / nfp / nfp_nfpu.c
index 556ded3..f11afef 100644 (file)
@@ -8,7 +8,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 
-#include <rte_pci.h>
+#include <rte_bus_pci.h>
 #include <rte_malloc.h>
 
 #include "nfp_nfpu.h"
@@ -75,8 +75,13 @@ nfpu_open(struct rte_pci_device *pci_dev, nfpu_desc_t *desc, int nfp)
        /* barsz in log2 */
        while (barsz >>= 1)
                i++;
+
        barsz = i;
 
+       /* Sanity check: we can assume any bar size less than 1MB an error */
+       if (barsz < 20)
+               return -1;
+
        /* Getting address for NFP expansion BAR registers */
        cfg_base = pci_dev->mem_resource[0].addr;
        cfg_base = (uint8_t *)cfg_base + NFP_CFG_EXP_BAR_CFG_BASE;