From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ie0-f179.google.com (mail-ie0-f179.google.com [209.85.223.179]) by dpdk.org (Postfix) with ESMTP id BB722B568 for ; Sun, 15 Feb 2015 16:25:00 +0100 (CET) Received: by iecat20 with SMTP id at20so29221120iec.12 for ; Sun, 15 Feb 2015 07:25:00 -0800 (PST) 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=118ipMRlpPKKYG21uvwalJWZEaq+S6pHiUzYgALpjO0=; b=RC2U/P8op5pQGcHFxG0oHMm8ecctEWkfnUAQUvQBRZm/eHQK6HcUP5qFrxYubN4Zj/ 8WZYUdZBGEcDmDPr4kF9c0zCy0hXMYPaMLAZSSecKOX3jdtxXHNuBR5u3o2+i5gsGkma LUOvRit5Azli3cOhezDmEj+m6SLO+9tWwDZXymJ5VbTPNb7dOHin1kLm2FOEISVIJ6I3 1D+UiGq111fDRRoWqvuv9ZRBdCTicI+DKII4aNy9RcgJ4x1gp9v/q+h2U7opeRxeTo1l r4Ni/yk3AS+0cXu5FcLl6Pw9aQQH+40xJNuhV2s0ResBkX3yT28clqdwas8YQpW3c9zz GD9g== X-Gm-Message-State: ALoCoQlftuI0kNe6oQEBEkQ3ug4pDRru15ovh/mKRFumfRFRgHaKHLfcoAeGKR2a3SWtzoPWFFux X-Received: by 10.107.25.135 with SMTP id 129mr25494600ioz.44.1424013900227; Sun, 15 Feb 2015 07:25:00 -0800 (PST) Received: from uryu.home.lan ([67.210.173.2]) by mx.google.com with ESMTPSA id i2sm7949373ioi.41.2015.02.15.07.24.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Feb 2015 07:24:59 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Date: Sun, 15 Feb 2015 10:24:46 -0500 Message-Id: <1424013889-2226-2-git-send-email-shemming@brocade.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424013889-2226-1-git-send-email-shemming@brocade.com> References: <1424013889-2226-1-git-send-email-shemming@brocade.com> Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 2/5] enic: fix device to work with Xen DOM0 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: Sun, 15 Feb 2015 15:25:01 -0000 It is possible to passthrough a PCI device when running in Xen Paravirt mode. The device driver has to accomodate by using memory zones differently. This patch models the memory allocation for ENIC device based on changes already done for ixgbe and igb. Build tested only; has not been tested on ENIC hardware. --- v2 -- this patch is added lib/librte_pmd_enic/enic_main.c | 19 ++++++++++++++++--- lib/librte_pmd_enic/vnic/vnic_dev.c | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/librte_pmd_enic/enic_main.c b/lib/librte_pmd_enic/enic_main.c index 48fdca2..0be5172 100644 --- a/lib/librte_pmd_enic/enic_main.c +++ b/lib/librte_pmd_enic/enic_main.c @@ -537,8 +537,14 @@ enic_alloc_consistent(__rte_unused void *priv, size_t size, const struct rte_memzone *rz; *dma_handle = 0; - rz = rte_memzone_reserve_aligned((const char *)name, - size, 0, 0, ENIC_ALIGN); +#ifdef RTE_LIBRTE_XEN_DOM0 + if (is_xen_dom0_supported()) + rz = rte_memzone_reserve_bounded((char *)name, size, + 0, 0, ENIC_ALIGN, RTE_PGSIZE_2M); + else +#endif + rz = rte_memzone_reserve_aligned((char *)name, size, + 0, 0, ENIC_ALIGN); if (!rz) { pr_err("%s : Failed to allocate memory requested for %s", __func__, name); @@ -546,7 +552,14 @@ enic_alloc_consistent(__rte_unused void *priv, size_t size, } vaddr = rz->addr; - *dma_handle = (dma_addr_t)rz->phys_addr; + +#ifdef RTE_LIBRTE_XEN_DOM0 + if (is_xen_dom0_supported()) + *dma_handle = rte_mem_phy2mch(rz->memseg_id, + rz->phys_addr); + else +#endif + *dma_handle = (dma_addr_t)rz->phys_addr; return vaddr; } diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c b/lib/librte_pmd_enic/vnic/vnic_dev.c index 6407994..e660aaf 100644 --- a/lib/librte_pmd_enic/vnic/vnic_dev.c +++ b/lib/librte_pmd_enic/vnic/vnic_dev.c @@ -276,9 +276,14 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev, vnic_dev_desc_ring_size(ring, desc_count, desc_size); - rz = rte_memzone_reserve_aligned(z_name, - ring->size_unaligned, socket_id, - 0, ENIC_ALIGN); +#ifdef RTE_LIBRTE_XEN_DOM0 + if (is_xen_dom0_supported()) + rz = rte_memzone_reserve_bounded(z_name, ring->size_unaligned, + socket_id, 0, ENIC_ALIGN, RTE_PGSIZE_2M); + else +#endif + rz = rte_memzone_reserve_aligned(z_name, ring->size_unaligned, + socket_id, 0, ENIC_ALIGN); if (!rz) { pr_err("Failed to allocate ring (size=%d), aborting\n", (int)ring->size); @@ -292,7 +297,13 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev, return -ENOMEM; } - ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr; +#ifdef RTE_LIBRTE_XEN_DOM0 + if (is_xen_dom0_supported()) + ring->base_addr_unaligned = rte_mem_phy2mch(rz->memseg_id, + rz->phys_addr); + else +#endif + ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr; ring->base_addr = ALIGN(ring->base_addr_unaligned, ring->base_align); -- 2.1.4