From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8AAC7A0487 for ; Mon, 29 Jul 2019 14:25:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D2D351BEB8; Mon, 29 Jul 2019 14:25:11 +0200 (CEST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id DDE691BE70 for ; Mon, 29 Jul 2019 14:25:10 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id n9so36539138wrr.4 for ; Mon, 29 Jul 2019 05:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cgzrSrTP9wOQul6kkAZrYgC7A06R8tncrAUVUyEa40k=; b=PAP6EMfAjxa1lTP85PaeYwG5QQ63WWMVPNZ89kAa33xx1SZ1bYnbUdZ8VPMsClqaVb PJ6s7/fOSJR6FYXncFXazIDbqamCq0KwMKoiq2L9wUplZrLSeMFz6YdomB4ypwmeTJR2 EKb2DIfnd+bCWSrL8uowwvhIdCr/f9Sm31JC4GYIOxABlJfSgkL5dsaKJo7KhDsqZ+hm XTLLo024wvtetsPrZdU6Ubr32QRoedU51Nr+oxPRT++qZzjRl7kodPuli7LZvb+l2TOK FpcwCPep2Iat9MjhSUtk9GikfJ+iew5ZC/mlIdhs0ZrPyhC66fzZFah6l7FAJDyYDiCg Nq3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cgzrSrTP9wOQul6kkAZrYgC7A06R8tncrAUVUyEa40k=; b=Wu0+KFYPTqGFa+mrX9AOOOHYMB7IbHmUEVRKWWruNVmGk+0SQxEKgEXMx5wjSRMW7Z YrpZpKMUWJVuZQ0ld9yzXL3xjbjzLnux0K7uy4vE2jvtovg/j8yejvpEOVp5O5ie4p4W fSbeUwrd4XK+y7CqHb9wqDl+i9/3ExhB2tPx37kanWF10jwNzlCREeGvdwAjru7vUW3Z 83+La+F2wmQ0xF+KQgUShZP4CjsLCvPwHYNMAN0R3i7Upw827xurhJwyLel6xop4doxv 4lDH8b40g006hydPAQmUdGN9KWWIb0TleH5114podMn3ZFB8hUJJ0uPjrrh9DKw0EY+5 Cudw== X-Gm-Message-State: APjAAAXy3WNYDST79MZdLastLUykSD01uPnZu6g5KPHnmYteB3fYg1DJ yINPUmRtyqBYDLKZiXu4eXDqvsRSQNpl89cnR4vqjw== X-Google-Smtp-Source: APXvYqwfIxSAScf+Uf8h0toMRiAgTVP1ZRqT+yKk2pkLNEM1XciIG0l0p3ob/k3w8axOXfKSvXsrmE+Cr6Crq/U56rM= X-Received: by 2002:a5d:6a90:: with SMTP id s16mr66054848wru.288.1564403110503; Mon, 29 Jul 2019 05:25:10 -0700 (PDT) MIME-Version: 1.0 References: <20190723053821.30227-1-vattunuru@marvell.com> <20190729121313.30639-1-vattunuru@marvell.com> <20190729121313.30639-3-vattunuru@marvell.com> In-Reply-To: <20190729121313.30639-3-vattunuru@marvell.com> From: Igor Ryzhov Date: Mon, 29 Jul 2019 15:24:59 +0300 Message-ID: To: vattunuru@marvell.com Cc: dev@dpdk.org, Thomas Monjalon , jerinj@marvell.com, Olivier Matz , Ferruh Yigit , anatoly.burakov@intel.com, Andrew Rybchenko , kirankumark@marvell.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v9 2/5] kni: add IOVA=VA support in KNI lib 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" Hi, I believe iova_mode check should not be automatic and should be a part of rte_kni_conf. What if I want to use KNI just as a pure virtual device without any connection to a real PCI device in an application that works in VA mode? Best regards, Igor On Mon, Jul 29, 2019 at 3:14 PM wrote: > > From: Vamsi Attunuru > > Current KNI implementation only operates in IOVA=PA mode, patch adds > required functionality in KNI lib to support IOVA=VA mode. > > KNI kernel module requires device info to get iommu domain related > information for IOVA addr related translations. Patch defines device > related info in rte_kni_device_info structure and passes device info > to the kernel KNI module when IOVA=VA mode is enabled. > > Signed-off-by: Vamsi Attunuru > Signed-off-by: Kiran Kumar K > --- > lib/librte_eal/linux/eal/include/rte_kni_common.h | 8 ++++++ > lib/librte_kni/Makefile | 1 + > lib/librte_kni/meson.build | 1 + > lib/librte_kni/rte_kni.c | 30 +++++++++++++++++++++++ > 4 files changed, 40 insertions(+) > > diff --git a/lib/librte_eal/linux/eal/include/rte_kni_common.h b/lib/librte_eal/linux/eal/include/rte_kni_common.h > index 37d9ee8..4fd8a90 100644 > --- a/lib/librte_eal/linux/eal/include/rte_kni_common.h > +++ b/lib/librte_eal/linux/eal/include/rte_kni_common.h > @@ -111,6 +111,13 @@ struct rte_kni_device_info { > void * mbuf_va; > phys_addr_t mbuf_phys; > > + /* PCI info */ > + uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */ > + uint16_t device_id; /**< Device ID or PCI_ANY_ID. */ > + uint8_t bus; /**< Device bus */ > + uint8_t devid; /**< Device ID */ > + uint8_t function; /**< Device function. */ > + > uint16_t group_id; /**< Group ID */ > uint32_t core_id; /**< core ID to bind for kernel thread */ > > @@ -121,6 +128,7 @@ struct rte_kni_device_info { > unsigned mbuf_size; > unsigned int mtu; > uint8_t mac_addr[6]; > + uint8_t iova_mode; > }; > > #define KNI_DEVICE "kni" > diff --git a/lib/librte_kni/Makefile b/lib/librte_kni/Makefile > index cbd6599..ab15d10 100644 > --- a/lib/librte_kni/Makefile > +++ b/lib/librte_kni/Makefile > @@ -7,6 +7,7 @@ include $(RTE_SDK)/mk/rte.vars.mk > LIB = librte_kni.a > > CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -fno-strict-aliasing > +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci > LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_ethdev > > EXPORT_MAP := rte_kni_version.map > diff --git a/lib/librte_kni/meson.build b/lib/librte_kni/meson.build > index 41fa2e3..fd46f87 100644 > --- a/lib/librte_kni/meson.build > +++ b/lib/librte_kni/meson.build > @@ -9,3 +9,4 @@ version = 2 > sources = files('rte_kni.c') > headers = files('rte_kni.h') > deps += ['ethdev', 'pci'] > +includes += include_directories('../../drivers/bus/pci') > diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c > index 4b51fb4..2aaaeaa 100644 > --- a/lib/librte_kni/rte_kni.c > +++ b/lib/librte_kni/rte_kni.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -199,6 +200,27 @@ kni_release_mz(struct rte_kni *kni) > rte_memzone_free(kni->m_sync_addr); > } > > +static void > +kni_dev_pci_addr_get(uint16_t port_id, struct rte_kni_device_info *kni_dev_info) > +{ > + const struct rte_pci_device *pci_dev; > + struct rte_eth_dev_info dev_info; > + const struct rte_bus *bus = NULL; > + > + rte_eth_dev_info_get(port_id, &dev_info); > + > + if (dev_info.device) > + bus = rte_bus_find_by_device(dev_info.device); > + if (bus && !strcmp(bus->name, "pci")) { > + pci_dev = RTE_DEV_TO_PCI(dev_info.device); > + kni_dev_info->bus = pci_dev->addr.bus; > + kni_dev_info->devid = pci_dev->addr.devid; > + kni_dev_info->function = pci_dev->addr.function; > + kni_dev_info->vendor_id = pci_dev->id.vendor_id; > + kni_dev_info->device_id = pci_dev->id.device_id; > + } > +} > + > struct rte_kni * > rte_kni_alloc(struct rte_mempool *pktmbuf_pool, > const struct rte_kni_conf *conf, > @@ -247,6 +269,12 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, > kni->ops.port_id = UINT16_MAX; > > memset(&dev_info, 0, sizeof(dev_info)); > + > + if (rte_eal_iova_mode() == RTE_IOVA_VA) { > + uint16_t port_id = conf->group_id; > + > + kni_dev_pci_addr_get(port_id, &dev_info); > + } > dev_info.core_id = conf->core_id; > dev_info.force_bind = conf->force_bind; > dev_info.group_id = conf->group_id; > @@ -300,6 +328,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, > kni->group_id = conf->group_id; > kni->mbuf_size = conf->mbuf_size; > > + dev_info.iova_mode = (rte_eal_iova_mode() == RTE_IOVA_VA) ? 1 : 0; > + > ret = ioctl(kni_fd, RTE_KNI_IOCTL_CREATE, &dev_info); > if (ret < 0) > goto ioctl_fail; > -- > 2.8.4 >