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 B622CAFD4 for ; Mon, 28 Apr 2014 15:19:58 +0200 (CEST) Received: by mail-wi0-f176.google.com with SMTP id r20so5662919wiv.3 for ; Mon, 28 Apr 2014 06:20:02 -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:subject:date:message-id:in-reply-to :references; bh=L3ItoRaiK3JQYbLRuqh164OIeoks2JguUxG3Qoe85LU=; b=Rncbauz+WWBIgSf0DE3qgew+pWQ0XNOcPBRzR897jyF0ypM/a7324A6zw7QgRBUAFc TwiY9y6ihypoiKI2yWOKM7qSzvmrh+IqIBtQ7qn1djSpdFltLMhTyuyzoJFUcrAs1Qwm 0tFSOeEB60UAtv5KpKHQw1MaGGi6wq2WqnjJJII5Z94zompshK17+wnVa9YGIip+2lMf 5vc+NQrE6HgNWrfdA8pbPiRAx9JNnCL0mZxPO0iqzhIsYIskHpNJsZoNZTe6azICD3Ix 8rcb2cdKzZRTCMIXfqh/4zqZx2csg8xkzJBYc/e98um1mYi5pdgJnKXuNQLj54WrcKcC RjiQ== X-Gm-Message-State: ALoCoQlg/kW6EkpH6Fj+bRh8oBxw6xxlI8kswoVwks9BZD45Oo3ainvgEGhdyfPKfPST+nxlO9RK X-Received: by 10.194.189.116 with SMTP id gh20mr19218254wjc.41.1398691202336; Mon, 28 Apr 2014 06:20:02 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id ej7sm17746555wib.9.2014.04.28.06.20.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Apr 2014 06:20:01 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Mon, 28 Apr 2014 15:19:45 +0200 Message-Id: <1398691187-4918-6-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398691187-4918-1-git-send-email-david.marchand@6wind.com> References: <1398691187-4918-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 5/7] pci: pci_switch_module cleanup 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: Mon, 28 Apr 2014 13:20:00 -0000 The pci_switch_module() function should only do what its name tells: unbind pci devices and rebind them on the specified kernel driver. Hence, it can not call pci_uio_map_resource(). Call to pci_uio_map_resource() should be moved to rte_eal_pci_probe_one_driver() so that we can factorize code. Signed-off-by: David Marchand --- lib/librte_eal/linuxapp/eal/eal_pci.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 2c3b914..db1fb3f 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -107,9 +107,6 @@ TAILQ_HEAD(uio_res_list, uio_resource); static struct uio_res_list *uio_res_list = NULL; static int pci_parse_sysfs_value(const char *filename, uint64_t *val); -/* forward prototype of function called in pci_switch_module below */ -static int pci_uio_map_resource(struct rte_pci_device *dev); - #ifdef RTE_EAL_UNBIND_PORTS #define PROC_MODULES "/proc/modules" @@ -279,12 +276,11 @@ error: static int pci_switch_module(struct rte_pci_driver *dr, struct rte_pci_device *dev, - int uio_status, const char *module_name) + const char *module_name) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) { /* check that our driver is loaded */ - if (uio_status != 0 && - (uio_status = pci_uio_check_module(module_name)) != 0) + if (pci_uio_check_module(module_name) != 0) rte_exit(EXIT_FAILURE, "The %s module is required by the " "%s driver\n", module_name, dr->name); @@ -294,9 +290,6 @@ pci_switch_module(struct rte_pci_driver *dr, struct rte_pci_device *dev, if (pci_uio_bind_device(dev, module_name) < 0) return -1; } - /* map the NIC resources */ - if (pci_uio_map_resource(dev) < 0) - return -1; return 0; } @@ -1010,8 +1003,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d #ifdef RTE_EAL_UNBIND_PORTS if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) { - /* unbind driver and load uio resources for Intel NICs */ - if (pci_switch_module(dr, dev, 1, IGB_UIO_NAME) < 0) + /* unbind current driver and bind on igb_uio */ + if (pci_switch_module(dr, dev, IGB_UIO_NAME) < 0) return -1; } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && rte_eal_process_type() == RTE_PROC_PRIMARY) { @@ -1019,12 +1012,13 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d if (pci_unbind_kernel_driver(dev) < 0) return -1; } -#else - if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) - /* just map resources for Intel NICs */ +#endif + + if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) { + /* map resources for devices that use igb_uio */ if (pci_uio_map_resource(dev) < 0) return -1; -#endif + } /* reference driver structure */ dev->driver = dr; -- 1.7.10.4