From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E0F635A62 for ; Tue, 19 Jan 2016 15:18:09 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 19 Jan 2016 06:18:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,317,1449561600"; d="scan'208";a="863815078" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2016 06:18:02 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.56]) by IRSMSX154.ger.corp.intel.com ([169.254.12.231]) with mapi id 14.03.0248.002; Tue, 19 Jan 2016 14:18:01 +0000 From: "Burakov, Anatoly" To: Santosh Shukla , "dev@dpdk.org" Thread-Topic: [PATCH v5 08/11] eal: pci: introduce RTE_KDRV_VFIO_NOIOMMUi driver mode Thread-Index: AQHRUq8st6OixDDjpUeEOnUxUf9Eyp8C4acw Date: Tue, 19 Jan 2016 14:18:00 +0000 Message-ID: References: <1453203972-24855-1-git-send-email-sshukla@mvista.com> <1453203972-24855-9-git-send-email-sshukla@mvista.com> In-Reply-To: <1453203972-24855-9-git-send-email-sshukla@mvista.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 08/11] eal: pci: introduce RTE_KDRV_VFIO_NOIOMMUi driver mode 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: Tue, 19 Jan 2016 14:18:11 -0000 Hi Santosh, > +int > +pci_vfio_is_noiommu(struct rte_pci_device *pci_dev) { > + FILE *fp; > + struct rte_pci_addr *loc; > + const char *path =3D > "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"; > + char filename[PATH_MAX] =3D {0}; > + char buf[PATH_MAX] =3D {0}; > + > + /* > + * 1. chk vfio-noiommu mode set in kernel driver > + * 2. verify pci device attached to vfio-noiommu driver > + * example: > + * cd /sys/bus/pci/drivers/vfio-pci//iommu_group > + * > cat name > + * > vfio-noiommu --> means virtio_dev attached to vfio-noiommu > driver > + */ > + > + fp =3D fopen(path, "r"); > + if (fp =3D=3D NULL) { > + RTE_LOG(ERR, EAL, "can't open %s\n", path); > + return -1; > + } > + > + if (fread(buf, sizeof(char), 1, fp) !=3D 1) { > + RTE_LOG(ERR, EAL, "can't read from file %s\n", path); > + fclose(fp); > + return -1; > + } > + > + if (strncmp(buf, "Y", 1) !=3D 0) { > + RTE_LOG(ERR, EAL, "[%s]: vfio: noiommu mode not set\n", > path); > + fclose(fp); > + return -1; > + } > + > + fclose(fp); > + > + /* 2. chk whether attached driver is vfio-noiommu or not */ > + loc =3D &pci_dev->addr; > + snprintf(filename, sizeof(filename), > + SYSFS_PCI_DEVICES "/" PCI_PRI_FMT > "/iommu_group/name", > + loc->domain, loc->bus, loc->devid, loc->function); > + > + /* check for vfio-noiommu */ > + fp =3D fopen(filename, "r"); > + if (fp =3D=3D NULL) { > + RTE_LOG(ERR, EAL, "can't open %s\n", filename); > + return -1; > + } > + > + if (fread(buf, sizeof(char), sizeof("vfio-noiommu"), fp) !=3D > + sizeof("vfio-noiommu")) { > + RTE_LOG(ERR, EAL, "can't read from file %s\n", filename); > + fclose(fp); > + return -1; > + } > + > + if (strncmp(buf, "vfio-noiommu", strlen("vfio-noiommu")) !=3D 0) { > + RTE_LOG(ERR, EAL, "not a vfio-noiommu driver\n"); > + fclose(fp); > + return -1; > + } > + > + fclose(fp); > + > + return 0; > +} Since this is a public non-performance critical API, shouldn't we check if = pci_dev is NULL? Otherwise the patch-set seems fine to me as far as VFIO pa= rts are concerned. Thanks, Anatoly