From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by dpdk.org (Postfix) with ESMTP id 31D0FC460 for ; Fri, 23 Oct 2015 08:34:46 +0200 (CEST) Received: by pasz6 with SMTP id z6so109392689pas.2 for ; Thu, 22 Oct 2015 23:34:45 -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=y0Y5RG71Hl1BCQSWZ20JuXZYSBtuHkvR7VlYObFuQEM=; b=MOjJTwgX4xn0zMPY1kQ1C+HosvWmZVwyI1ft4bqEewqX0Eje6f8pzSt4DVS0Zm595G Sx+msnRLUcdKGEIjqYQcDX47djlN1Ph9nCuQrI4uTB3EsUHJvVCgUZtMWjukVF6WrQUA lcJZv+kjxiiQgZUoN052NvOEUMUSxf+5hZ6ZS66MATCeczTRtPG3tsheTSPViajxVMBX UsYb3yxEbrHcNsHuzzS0bjfnNIYY6uu1yVN4kXTIDJsoMQkdeEM7uOkREJtBheEEum7/ CH+NwmVa17iErx0ONHJ8ILEWjQCxaGq9jsHVa7crDALlk16n/xQWMvRpposAO+yzHn21 dYJQ== X-Gm-Message-State: ALoCoQlVaEAX/iwpytb31xdp1UoyniF0sgzPYCJet4MfXNEpKTG3RPOcQPepa3XFtIT99Raqt3It X-Received: by 10.66.142.106 with SMTP id rv10mr20681531pab.29.1445582085595; Thu, 22 Oct 2015 23:34:45 -0700 (PDT) Received: from xeon-e3.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ot8sm17078910pbb.26.2015.10.22.23.34.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Oct 2015 23:34:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Thu, 22 Oct 2015 23:34:46 -0700 Message-Id: <1445582090-5927-3-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445582090-5927-1-git-send-email-stephen@networkplumber.org> References: <1445582090-5927-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: Fri, 23 Oct 2015 06:34:46 -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 f593f6e..6c520a3 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2838,6 +2838,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 8a8c82b..8d2098d 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -3598,6 +3598,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