From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by dpdk.org (Postfix) with ESMTP id 5CEF7594F for ; Thu, 22 May 2014 14:03:38 +0200 (CEST) Received: by mail-wi0-f176.google.com with SMTP id n15so9109293wiw.9 for ; Thu, 22 May 2014 05:03:48 -0700 (PDT) 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:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=uTG2i+GKX8KTA6Fbvu2Jtpgm1D6UzDiLo8FfyPoV3Jg=; b=kUVJ70JdV5to3HCrBFcUbTdmND8p3sa4UpEka6CcGyCd+9VEVWl9G01lzcJyKUYC5+ gJhCtVsniE/TsDM3mgVnEAADGxnA0AHP2yGAVCFqyzITe/lBRmc563yu+bz6IG5SbVO+ MXexaxKrS+4dHkGc71eH/9chicPfVQAnImYBpxkPv5FldHUdy67KFbQPbvs251WHPZJF u5Uuu/KzJze0kXaf2ZuZKNjJRZRhjlia65HkCqbTBvyTokuHqXbAF21LGDUKSeXzqaaA DV8bsUhhRXseXN9zIkfUd29/FfEriA8wCY3A5pswtynCoLYyqgkmlEomhnvKMR6asvHL 2FNA== X-Gm-Message-State: ALoCoQnkxSP/yzE7WpRnfKnTE8PeC4DiZ5GvG5yczuV/rHw2dHD+yko4K2+MqnA3JlP6f1zJentx X-Received: by 10.180.108.146 with SMTP id hk18mr7691713wib.42.1400760227967; Thu, 22 May 2014 05:03:47 -0700 (PDT) Received: from xps13.localnet (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id ed6sm7620154wib.20.2014.05.22.05.03.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 May 2014 05:03:47 -0700 (PDT) From: Thomas Monjalon To: Anatoly Burakov Date: Thu, 22 May 2014 14:03:44 +0200 Message-ID: <1414388.FIrhq1zrZl@xps13> Organization: 6WIND User-Agent: KMail/4.13 (Linux/3.14.4-1-ARCH; KDE/4.13.0; x86_64; ; ) In-Reply-To: <1400514709-24087-10-git-send-email-anatoly.burakov@intel.com> References: <1400514709-24087-10-git-send-email-anatoly.burakov@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2 09/16] Enable VFIO device binding 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: Thu, 22 May 2014 12:03:38 -0000 2014-05-19 16:51, Anatoly Burakov: > Add support for binding VFIO devices if RTE_PCI_DRV_NEED_IGB_UIO > is set for this driver. Try VFIO first, if not mapped then try > IGB_UIO too. You have renamed RTE_PCI_DRV_NEED_IGB_UIO. Please update this log :) > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c > @@ -401,6 +401,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, > struct rte_pci_device *d { > struct rte_pci_id *id_table; > int ret = 0; > + int mapped = 0; > > for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) { > > @@ -435,8 +436,17 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, > struct rte_pci_device *d } > > if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { > + /* try mapping the NIC resources using VFIO if it exists */ > +#ifdef VFIO_PRESENT > + if (vfio_cfg.vfio_enabled) { > + if ((ret = pci_vfio_map_resource(dev)) == 0) > + mapped = 1; > + else if (ret < 0) > + return ret; > + } > +#endif > /* map resources for devices that use igb_uio */ > - if ((ret = pci_uio_map_resource(dev)) != 0) > + if (!mapped && (ret = pci_uio_map_resource(dev)) != 0) > return ret; I think creating a function pci_map_resource() could be cleaner (you won't need variable mapped). > +#ifdef VFIO_PRESENT > + memset(&vfio_cfg, 0, sizeof(vfio_cfg)); > + > + /* initialize group list */ > + int i, ret; > + > + for (i = 0; i < VFIO_MAX_GROUPS; i++) { > + vfio_cfg.vfio_groups[i].fd = -1; > + vfio_cfg.vfio_groups[i].group_no = -1; > + } > + vfio_cfg.vfio_container_fd = -1; > + > + /* check if we have VFIO driver enabled */ > + if (access(VFIO_DIR, F_OK) == 0) { > + static int socket_fd; > + > + vfio_cfg.vfio_enabled = 1; > + > + /* if we are primary process, create a thread to communicate with > + * secondary processes. the thread will use a socket to wait for > + * requests from secondary process to send open file descriptors, > + * because VFIO does not allow multiple open descriptors on a group or > + * VFIO container. > + */ > + if (internal_config.process_type == RTE_PROC_PRIMARY) { > + /* set up local socket */ > + if ((socket_fd = pci_vfio_socket_setup()) < 0) { > + RTE_LOG(ERR, EAL, "Failed to set up local socket!\n"); > + return -1; > + } > + ret = pthread_create(&socket_thread, NULL, > + pci_vfio_socket_thread, (void*) &socket_fd); > + if (ret) { > + RTE_LOG(ERR, EAL, > + "Failed to create thread for communication with secondary " > + "processes!\n"); > + return -1; > + } > + } Also here, it could help to have a dedicated function for vfio init. > + } > + else checkpatch.pl reports an error: "else should follow close brace '}'" > + RTE_LOG(INFO, EAL, "VFIO driver not loaded or wrong permissions\n"); > +#endif Thanks -- Thomas