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 EC5D2A00E6 for ; Thu, 11 Jul 2019 18:43:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 733DC322C; Thu, 11 Jul 2019 18:43:49 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id CAD5631FC for ; Thu, 11 Jul 2019 18:43:47 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id k8so3326973plt.3 for ; Thu, 11 Jul 2019 09:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vHuR/uY1168WjUB6ex5D7SabD2nEq/YQSpuqYNcG/qk=; b=IgBKyvip/hFx3Jd+KFaIkA7kl55oyE5V41sH4BAkpevQtD9ClbLNm0m6v5xEyJjzXM CMcTh4H6aPXNT4qI7Q5+QAbdI7BbP3MKnYZKmNEsGPwwxDeLPcWE8xnh8ssfGIaeJ96l vuIVYq7bf8xKMn3XR3IZSTWegTU+0W9brA3DMoU5688uh4wY3nv1XI5Ub5ZhId0jJJeT JaAkhqZgRb4X3E8eMoRP8hkOA7p3vCR6ntBD5viU+CObjBz+aFCfa0rkmTf6NTe4rWAY a8eNF5s07iwaGpHKD1gz/0h1iem7o59GbftTmxuGL61izf3xXtKtTJygYo5sjIU6CFV5 JJIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vHuR/uY1168WjUB6ex5D7SabD2nEq/YQSpuqYNcG/qk=; b=q36i/iLNi9sKWyEeGwt14F3ul8jdR3+9BoaOBCWAgk/bb8Jl3KBwtyflTenIC6QEEq Hp/M2sl+Nmw+DByLMZWDW3IFgJgPwBSKjPlvCw44hB3eHLpsbTwIRZ9impu5b6N6yiWY xQj4Xai2NjENK7IoCTz8Ga5rplwubJQceRBWjo8PzE23hFkIMDcBVhozjTCFIA5J71L/ 2lerqkeNceP6SlMKPqJrwZyVdFXzTR6fHf5ikKN35JQirB6e6ISFBQCsu5uYFCLY6wIN Pq7i14PA8sTCsTLF+/z7LQ+j8ta0HsD6S3w3MkuYxhkIurTLDwhvxoh0A/yiSla+Hz5p igHQ== X-Gm-Message-State: APjAAAURz29dA5pxqqmYjXfbihYxeWvXtoVqLVXiegHmZKzJxwp+qBwM 9FAxBiOmYWOEyLxRHgQ0tq0= X-Google-Smtp-Source: APXvYqzIn0sR0r6DgueWejC1Q4YwL7HgIreTM5P6frYr/uJB8um2IaubyS9ieqNIUYHX+WfOQ7lxMw== X-Received: by 2002:a17:902:aa5:: with SMTP id 34mr5928047plp.166.1562863426845; Thu, 11 Jul 2019 09:43:46 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id n98sm5766920pjc.26.2019.07.11.09.43.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:43:46 -0700 (PDT) Date: Thu, 11 Jul 2019 09:43:39 -0700 From: Stephen Hemminger To: Cc: , , , , Kiran Kumar K Message-ID: <20190711094339.7ffa1eed@hermes.lan> In-Reply-To: <20190625035700.2953-5-vattunuru@marvell.com> References: <20190422061533.17538-1-kirankumark@marvell.com> <20190625035700.2953-1-vattunuru@marvell.com> <20190625035700.2953-5-vattunuru@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 4/4] kernel/linux/kni: add IOVA support in kni module 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 Tue, 25 Jun 2019 09:27:00 +0530 wrote: > diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c > index 1fc5eeb..b70c827 100644 > --- a/kernel/linux/kni/kni_misc.c > +++ b/kernel/linux/kni/kni_misc.c > @@ -294,6 +294,9 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, > struct rte_kni_device_info dev_info; > struct net_device *net_dev = NULL; > struct kni_dev *kni, *dev, *n; > + struct pci_dev *pci = NULL; > + struct iommu_domain *domain = NULL; Please don't do unnecessary initailization. It defeats the purpose of compiler and static checkers. > + phys_addr_t phys_addr; > > pr_info("Creating kni...\n"); > /* Check the buffer size, to avoid warning */ > @@ -351,15 +354,56 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, > strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); > > /* Translate user space info into kernel space info */ > - kni->tx_q = phys_to_virt(dev_info.tx_phys); > - kni->rx_q = phys_to_virt(dev_info.rx_phys); > - kni->alloc_q = phys_to_virt(dev_info.alloc_phys); > - kni->free_q = phys_to_virt(dev_info.free_phys); > - > - kni->req_q = phys_to_virt(dev_info.req_phys); > - kni->resp_q = phys_to_virt(dev_info.resp_phys); > - kni->sync_va = dev_info.sync_va; > - kni->sync_kva = phys_to_virt(dev_info.sync_phys); > + if (dev_info.iova_mode) { > +#if KERNEL_VERSION(4, 4, 0) > LINUX_VERSION_CODE > + (void)pci; > + pr_err("Kernel version is not supported\n"); > + return -EINVAL; > +#else > + pci = pci_get_device(dev_info.vendor_id, > + dev_info.device_id, NULL); > + while (pci) { > + if ((pci->bus->number == dev_info.bus) && > + (PCI_SLOT(pci->devfn) == dev_info.devid) && > + (PCI_FUNC(pci->devfn) == dev_info.function)) { > + domain = iommu_get_domain_for_dev(&pci->dev); > + break; > + } > + pci = pci_get_device(dev_info.vendor_id, > + dev_info.device_id, pci); > + } > +#endif Why not move the variable pci inside the if() statement, then (void)pci is unnecessary.