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 0F459A046B for ; Tue, 23 Jul 2019 12:54:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA4ED1BFDE; Tue, 23 Jul 2019 12:54:19 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 19A381BFDB for ; Tue, 23 Jul 2019 12:54:19 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 07563B00055; Tue, 23 Jul 2019 10:54:18 +0000 (UTC) Received: from [192.168.1.11] (85.187.13.152) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 23 Jul 2019 11:54:09 +0100 To: , CC: , , , , , , Bruce Richardson References: <20190717090408.13717-1-vattunuru@marvell.com> <20190723053821.30227-1-vattunuru@marvell.com> <20190723053821.30227-3-vattunuru@marvell.com> From: Andrew Rybchenko Message-ID: <1fa119a4-e93d-30c3-106b-b052cde38705@solarflare.com> Date: Tue, 23 Jul 2019 13:54:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190723053821.30227-3-vattunuru@marvell.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [85.187.13.152] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24788.000 X-TM-AS-Result: No-12.187500-8.000000-10 X-TMASE-MatchedRID: PL66URbwWA/mLzc6AOD8DfHkpkyUphL9zy/2cI4Is/dXiLrvhpKLfIYM M3r3suSeYT8lhiANBQQb2FeqZDf44F/8tX/1KHzFimHWEC28pk0isyg/lfGoZ1Or/+udyw1ZmN9 zbf2ftOPnUZFgetPxf9seKHBzEjWEIeFIFB+CV+wYw0T6R7qoWnqLr3o+NE+ICgNjqBgJU5MxxV Ol5e9jSv7Hd1D+UIpjiJKZtMYpIn5Zn5gzZLkRYPSG/+sPtZVkTPM1foW4ZgOqQmWjpwt8sOg6D D179VtAvtoKD5YN6RNd3GFZQf/Pt5FLy8wKkfMfI0cHLI6lhgJnAst8At+c3Qzvg1/q1MH2LURe LvdYkFoQOGCGH0ZF5hZlqpUfercQ+f9d9BiBckfvVbHa5Rs8tyIk3dpe5X+hUCRb2Y/AtCa+Eod AtMqKbEI4zKnU8koDxIhRtcJgqMYFnsemTbryhRKr5cVbNoDKCBjso/O/VciYh23xcUPEK6PFjJ EFr+olA9Mriq0CDAhZZmMIUsIQGlZ0V5tYhzdWxEHRux+uk8h+ICquNi0WJB959ZlfA0hPIquiE PRulN/VFi/JAaO9dUy1ZROIkooVftwZ3X11IV0= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--12.187500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24788.000 X-MDID: 1563879258-mEYD-R67pgKM Subject: Re: [dpdk-dev] [PATCH v8 2/5] 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" On 7/23/19 8:38 AM, vattunuru@marvell.com 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 struct and passes device info to > kernel KNI module when IOVA=VA mode is enabled. > > Signed-off-by: Vamsi Attunuru > Signed-off-by: Kiran Kumar K <...> > 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'] Not directly related to the patch, but are mempool and mbuf dependencies lost here. Cc Bruce to comment. The library uses rte_mempool_obj_iter() and rte_pktmbuf_free() (which uses rte_mbuf_sanity_check()). > +includes += include_directories('../../drivers/bus/pci') > diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c > index 4b51fb4..ae17075 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,26 @@ kni_release_mz(struct rte_kni *kni) > rte_memzone_free(kni->m_sync_addr); > } > > +static void > +kni_dev_pci_addr_get(struct rte_pci_addr *addr, > + struct rte_pci_id *id, uint16_t port_id) Please, consider to make port_id the first argument. It is mandatory input argument which is used as a key to fill in other two output arguments. > +{ > + const struct rte_pci_device *pci_dev; > + const struct rte_bus *bus = NULL; > + struct rte_eth_dev_info dev_info; > + > + memset(&dev_info, 0, sizeof(dev_info)); Most likely not required even now, but for sure not required if the patch [1] applied. [1] http://patches.dpdk.org/patch/56959/ > + 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); > + *addr = pci_dev->addr; > + *id = pci_dev->id; I think it would be better to always init addr and id in the function. Otherwise caller does not know when it is initialized or not. > + } > +} > + > struct rte_kni * > rte_kni_alloc(struct rte_mempool *pktmbuf_pool, > const struct rte_kni_conf *conf, > @@ -247,6 +268,19 @@ 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; > + struct rte_pci_addr addr = { 0 }; > + struct rte_pci_id id = { 0 }; If addr and id are always initialized in kni_dev_pci_addr_get() init here would be not required. > + > + kni_dev_pci_addr_get(&addr, &id, port_id); > + dev_info.bus = addr.bus; > + dev_info.devid = addr.devid; > + dev_info.function = addr.function; > + dev_info.vendor_id = id.vendor_id; > + dev_info.device_id = id.device_id; > + } > dev_info.core_id = conf->core_id; > dev_info.force_bind = conf->force_bind; > dev_info.group_id = conf->group_id; > @@ -300,6 +334,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;