From 388022d5d09416f1bef27e1704a59c8047a1f5a6 Mon Sep 17 00:00:00 2001 From: Alejandro Lucero Date: Fri, 5 Oct 2018 13:45:26 +0100 Subject: [PATCH] net/nfp: check hugepage IOVA based on DMA mask NFP devices can not handle DMA addresses requiring more than 40 bits. This patch uses rte_dev_check_dma_mask with 40 bits and avoids device initialization if memory out of NFP range. Signed-off-by: Alejandro Lucero --- drivers/net/nfp/Makefile | 1 + drivers/net/nfp/meson.build | 2 ++ drivers/net/nfp/nfp_net.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/drivers/net/nfp/Makefile b/drivers/net/nfp/Makefile index ab4e0a7d95..d3fa5699b9 100644 --- a/drivers/net/nfp/Makefile +++ b/drivers/net/nfp/Makefile @@ -10,6 +10,7 @@ LIB = librte_pmd_nfp.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lm LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index a8f29f9864..ba6a22e8b9 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -17,3 +17,5 @@ sources = files('nfpcore/nfp_cpp_pcie_ops.c', 'nfpcore/nfp_nsp_eth.c', 'nfpcore/nfp_hwinfo.c', 'nfp_net.c') + +allow_experimental_apis = true diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 4d6a797b01..b5b98d6501 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -2702,6 +2702,14 @@ nfp_net_init(struct rte_eth_dev *eth_dev) pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + /* NFP can not handle DMA addresses requiring more than 40 bits */ + if (rte_eal_check_dma_mask(40)) { + RTE_LOG(ERR, PMD, "device %s can not be used:", + pci_dev->device.name); + RTE_LOG(ERR, PMD, "\trestricted dma mask to 40 bits!\n"); + return -ENODEV; + }; + if ((pci_dev->id.device_id == PCI_DEVICE_ID_NFP4000_PF_NIC) || (pci_dev->id.device_id == PCI_DEVICE_ID_NFP6000_PF_NIC)) { port = get_pf_port_number(eth_dev->data->name); -- 2.20.1