From patchwork Tue Jun 26 17:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41608 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C7C851BE40; Tue, 26 Jun 2018 19:38:06 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 78AE21BE3C; Tue, 26 Jun 2018 19:38:04 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbb0r028350; Tue, 26 Jun 2018 18:37:37 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbbkk028349; Tue, 26 Jun 2018 18:37:37 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:28 +0100 Message-Id: <1530034653-28299-2-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 1/6] eal: add internal dma mask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Devices can have addressing limitations and an internal dma mask will track the more restrictive dma mask set by a device. Signed-off-by: Alejandro Lucero --- lib/librte_eal/common/eal_common_options.c | 1 + lib/librte_eal/common/eal_internal_cfg.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 996a034..2d7c839 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -205,6 +205,7 @@ struct device_option { for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) internal_cfg->hugepage_info[i].lock_descriptor = -1; internal_cfg->base_virtaddr = 0; + internal_cfg->dma_mask = 0; internal_cfg->syslog_facility = LOG_DAEMON; diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index fa6ccbe..e1e2944 100644 --- a/lib/librte_eal/common/eal_internal_cfg.h +++ b/lib/librte_eal/common/eal_internal_cfg.h @@ -84,6 +84,7 @@ struct internal_config { const char *mbuf_pool_ops_name; /**< mbuf pool ops name */ unsigned num_hugepage_sizes; /**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES]; + uint64_t dma_mask; }; extern struct internal_config internal_config; /**< Global EAL configuration. */ From patchwork Tue Jun 26 17:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41610 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 121201BE5A; Tue, 26 Jun 2018 19:38:14 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id A3CDB1BE3E; Tue, 26 Jun 2018 19:38:04 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbbv9028354; Tue, 26 Jun 2018 18:37:37 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbbk8028353; Tue, 26 Jun 2018 18:37:37 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:29 +0100 Message-Id: <1530034653-28299-3-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 2/6] mem: add hugepages check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Devices can have addressing limitations and a driver can set a dma mask. This patch adds a function for checking hugepages iovas are within the range supported by the dma mask. Signed-off-by: Alejandro Lucero --- lib/librte_eal/linuxapp/eal/eal_memory.c | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 17c20d4..4c196a6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1334,6 +1334,42 @@ void numa_error(char *where) return -1; } +int +rte_eal_memory_dma_mask_check(void) +{ + struct rte_mem_config *mcfg; + int i; + int total_segs_checked = 0; + uint64_t mask; + + if (!internal_config.dma_mask) + return 0; + + mask = 1ULL << internal_config.dma_mask; + mask -= 1; + + /* get pointer to global configuration */ + mcfg = rte_eal_get_configuration()->mem_config; + + for (i = 0; i < RTE_MAX_MEMSEG; i++) { + RTE_LOG(DEBUG, EAL, "Memseg %d with iova %"PRIx64" and mask %"PRIx64"\n", i, + mcfg->memseg[i].iova, mask); + + if (!mcfg->memseg[i].iova) + break; + + if (mcfg->memseg[i].iova & ~mask) { + return -1; + } + total_segs_checked++; + } + + RTE_LOG(DEBUG, EAL, "ALEJ: %d segments successfully checked with dma mask\n", + total_segs_checked); + + return 0; +} + /* * uses fstat to report the size of a file on disk */ From patchwork Tue Jun 26 17:37:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41609 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 080371BE56; Tue, 26 Jun 2018 19:38:12 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id D613B1BE3F; Tue, 26 Jun 2018 19:38:04 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbbMF028358; Tue, 26 Jun 2018 18:37:37 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbbuM028357; Tue, 26 Jun 2018 18:37:37 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:30 +0100 Message-Id: <1530034653-28299-4-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 3/6] eal: check hugepages within dma mask range X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hugepages get an iova address which could be out of range for devices with addressing limitations. This patch checks hugepages are withint the range if dma mask is set by a device. Signed-off-by: Alejandro Lucero --- lib/librte_eal/common/eal_private.h | 3 +++ lib/librte_eal/linuxapp/eal/eal.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 462226f..05db535 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -224,4 +224,7 @@ */ struct rte_bus *rte_bus_find_by_device_name(const char *str); +/* if dma mask set by a device, check hugepages are not out of range */ +int rte_eal_memory_dma_mask_check(void); + #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 229eec9..eaa9325 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -960,6 +960,10 @@ static void rte_eal_init_alert(const char *msg) return -1; } + /* If dma mask set, check hugepages iovas are within the range */ + if (rte_eal_memory_dma_mask_check() < 0) + rte_panic("iovas out of range\n"); + /* initialize default service/lcore mappings and start running. Ignore * -ENOTSUP, as it indicates no service coremask passed to EAL. */ From patchwork Tue Jun 26 17:37:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41611 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 413C21BE68; Tue, 26 Jun 2018 19:38:16 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 0F2AC1BE3C; Tue, 26 Jun 2018 19:38:05 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbbZO028362; Tue, 26 Jun 2018 18:37:37 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbbBM028361; Tue, 26 Jun 2018 18:37:37 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:31 +0100 Message-Id: <1530034653-28299-5-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 4/6] mem: add function for setting internal dma mask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" A device with addressing limitations will invoke this function for setting a dma mask. It has no effect if there is another dma mask already set and more restrictive than this one. Signed-off-by: Alejandro Lucero --- lib/librte_eal/common/eal_common_memory.c | 15 +++++++++++++++ lib/librte_eal/common/include/rte_memory.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index fc6c44d..39bf98c 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -109,6 +109,21 @@ } } +/* set global dma mask based on device dma mask */ +void +rte_eal_set_dma_mask(uint8_t maskbits) { + + /* If no dma mask yet this is the new one */ + if (!internal_config.dma_mask) { + internal_config.dma_mask = maskbits; + return; + } + + /* Set dma mask just if more restrictive than current one */ + if (internal_config.dma_mask > maskbits) + internal_config.dma_mask = maskbits; +} + /* return the number of memory channels */ unsigned rte_memory_get_nchannel(void) { diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h index 80a8fc0..a078c31 100644 --- a/lib/librte_eal/common/include/rte_memory.h +++ b/lib/librte_eal/common/include/rte_memory.h @@ -209,6 +209,9 @@ struct rte_memseg { */ unsigned rte_memory_get_nrank(void); +/* set global dma mask based on a specific device dma mask */ +void rte_eal_set_dma_mask(uint8_t maskbits); + /** * Drivers based on uio will not load unless physical * addresses are obtainable. It is only possible to get From patchwork Tue Jun 26 17:37:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41612 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D8371BE6F; Tue, 26 Jun 2018 19:38:18 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 5884F1BE3D; Tue, 26 Jun 2018 19:38:05 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbcpu028366; Tue, 26 Jun 2018 18:37:38 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbcpG028365; Tue, 26 Jun 2018 18:37:38 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:32 +0100 Message-Id: <1530034653-28299-6-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 5/6] ethdev: add function for dma mask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This function calls a generic one for ethernet devices. Signed-off-by: Alejandro Lucero --- lib/librte_ether/rte_ethdev.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index eba11ca..e3979e4 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2799,6 +2799,18 @@ int rte_eth_dev_set_vlan_ether_type(uint16_t port_id, int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on); /** + * Set global dma mask by a device + * + * @param maskbits + * mask length in bits + * + */ +static inline void +rte_eth_dev_set_dma_mask(uint8_t maskbits) { + rte_eal_set_dma_mask(maskbits); +} + +/** * * Retrieve a burst of input packets from a receive queue of an Ethernet * device. The retrieved packets are stored in *rte_mbuf* structures whose From patchwork Tue Jun 26 17:37:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 41613 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B15921BE78; Tue, 26 Jun 2018 19:38:19 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 806D81BE3C; Tue, 26 Jun 2018 19:38:05 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbctu028370; Tue, 26 Jun 2018 18:37:38 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbc7p028369; Tue, 26 Jun 2018 18:37:38 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:33 +0100 Message-Id: <1530034653-28299-7-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 6/6] net/nfp: set dma mask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" NFP 4000/6000 devices can not use iova addresses requiring more than 40 bits. This patch sets a dma mask for avoiding hugepages with iova requiring more than those 40 bits. Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index d9cd047..7ac03f0 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -2915,6 +2915,8 @@ uint32_t nfp_net_txq_full(struct nfp_net_txq *txq) rte_free(port_name); + rte_eth_dev_set_dma_mask(40); + return ret; }