From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by dpdk.org (Postfix) with ESMTP id 21A01568B for ; Tue, 29 Sep 2015 02:44:47 +0200 (CEST) Received: by pacex6 with SMTP id ex6so188633656pac.0 for ; Mon, 28 Sep 2015 17:44:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bDE8atWYoMltShhVjmEuF5z9v8qp19JkIQrcFXOQ3Pw=; b=bFC3K5khfeut8h/HA2sTsVahSmTDBPTP+oZVb5ijqkUDmYpmXiHgZnD3AVOXGk81Cw kOKd3ZNyfhCiQioNGRhqQ9Euum376nI3cPoUwXxthsjOBmce8jAh71+b9sneslSYmViR Bla91mppfCEZfRe7bkRL69ZoLI0zXogWmbAFXCYC0/gc/9CJM+eC0zrteXeJw92JPeUd 5cL00XdHzrpa3kQrq+RGa12fsaUxdACGz8LWg0Cbnc6Zmn1H0ZEpXWVPvPpo0UMXNAwO clL/YxFNZN17lUVo7/TVzPU043cjsxCqTJ9+44xOtdHhb//rmv65z0Wo71wGzvvjtUCM y9rg== X-Gm-Message-State: ALoCoQkjIKRZp0c8RrSWVLMmZ2hpoG433Pjh34IXGigXyFx9J/d3LZwWYCzIPD78H+b69GJj+rXI X-Received: by 10.66.253.2 with SMTP id zw2mr30301600pac.104.1443487486350; Mon, 28 Sep 2015 17:44:46 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id sl7sm21702971pbc.54.2015.09.28.17.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Sep 2015 17:44:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Mon, 28 Sep 2015 17:44:43 -0700 Message-Id: <1443487487-31915-3-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443487487-31915-1-git-send-email-stephen@networkplumber.org> References: <1443487487-31915-1-git-send-email-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 2/6] ethdev: add common function for reserving DMA regions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2015 00:44:47 -0000 The code to create aligned DMA regions was copy-n-pasted throughout all the drivers. Since this code has to change now create a common function that just does the right thing for Xen at runtime. Signed-off-by: Stephen Hemminger --- lib/librte_ether/rte_ethdev.c | 24 ++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b309309..16db841 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3066,6 +3066,30 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) return 0; } + +const struct rte_memzone * +rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, + uint16_t queue_id, size_t size, unsigned align, + int socket_id) +{ + char z_name[RTE_MEMZONE_NAMESIZE]; + const struct rte_memzone *mz; + + snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", + dev->driver->pci_drv.name, ring_name, + dev->data->port_id, queue_id); + + mz = rte_memzone_lookup(z_name); + if (mz) + return mz; + + if (is_xen_dom0_supported()) + return rte_memzone_reserve_bounded(z_name, size, socket_id, + 0, align, RTE_PGSIZE_2M); + else + return rte_memzone_reserve_aligned(z_name, size, socket_id, + 0, align); +} int rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index fa06554..2955009 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -3978,6 +3978,29 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id, extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp); +/** + * Create memzone for HW rings. + * malloc can't be used as the physical address is needed. + * If the memzone is already created, then this function returns a ptr + * to the old one. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure + * @param name + * The name of the memory zone + * @param queue_id + * The index of the queue to add to name + * @param size + * The sizeof of the memory area + * @param align + * Alignment for resulting memzone. Must be a power of 2. + * @param socket_id + * The *socket_id* argument is the socket identifier in case of NUMA. + */ +const struct rte_memzone * +rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, + uint16_t queue_id, size_t size, + unsigned align, int socket_id); #ifdef __cplusplus } #endif -- 2.1.4