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