From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id C66B268A9 for ; Fri, 9 May 2014 15:16:04 +0200 (CEST) Received: by mail-wg0-f46.google.com with SMTP id n12so3873486wgh.17 for ; Fri, 09 May 2014 06:16:11 -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=vx1UzMuONW2Fh02Zb/r6goZxZMXms5Ju9V7puwbqrD0=; b=L8EwsqdY1s4fT8rXwD32A3GL/aGh14fbGBLrX4Y2FDtDOikCOdzjHcJHVpbKjGVFwc B4bpFuv4U1+fr/NaOPxxNVQv4rxAZwnehBjhEOPOw+hlICadocY8TFm41svzZ5pYeHOF QvVth+Fk8rj1rL9tpxTK+ET0bDTGJJ5JIAH3oZgOceLFcDliR0vykj7PvAQmiKVDS28A iYPJDI0gVHQJUii49WqRd/+ZwAVs9n0zKDvdyi+c1N04TSQhesTE3/SjEB4A4bWQ4e7s miENkR9CT7YOsbi317icroP4jFx6pWpXG9AdNIlkNJ/SzIjhbHOYU27ENGdICBKLEMlP YhOQ== X-Gm-Message-State: ALoCoQlj3d+ltE56jwnqppFJCEAe2xFpxMGxXtAgpy1QUUDj6vUscqDhy76wofO/zhvGoNq484Aa X-Received: by 10.180.95.4 with SMTP id dg4mr3358721wib.9.1399641370939; Fri, 09 May 2014 06:16:10 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id go1sm5086560wib.7.2014.05.09.06.16.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 May 2014 06:16:10 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Fri, 9 May 2014 15:15:54 +0200 Message-Id: <1399641359-11267-3-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399641359-11267-1-git-send-email-david.marchand@6wind.com> References: <1399641359-11267-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 2/7] pci: align bsd implementation on linux 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: Fri, 09 May 2014 13:16:05 -0000 bsd implementation lacks check on driver flags, fix this. Besides, check on BAR0 is not needed and could cause trouble for devices that have no BAR0. Signed-off-by: David Marchand --- lib/librte_eal/bsdapp/eal/eal_pci.c | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 987b446..5d8bcbd 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -108,8 +108,14 @@ TAILQ_HEAD(uio_res_list, uio_resource); static struct uio_res_list *uio_res_list = NULL; -/* forward prototype of function called in pci_switch_module below */ -static int pci_uio_map_resource(struct rte_pci_device *dev); +/* unbind kernel driver for this device */ +static int +pci_unbind_kernel_driver(struct rte_pci_device *dev) +{ + RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " + "for BSD\n"); + return -ENOTSUP; +} /* map a particular resource from a file */ static void * @@ -214,6 +220,11 @@ pci_uio_map_resource(struct rte_pci_device *dev) dev->intr_handle.fd = -1; + /* secondary processes - use already recorded details */ + if ((rte_eal_process_type() != RTE_PROC_PRIMARY) && + (dev->id.vendor_id != PCI_VENDOR_ID_QUMRANET)) + return (pci_uio_map_secondary(dev)); + rte_snprintf(devname, sizeof(devname), "/dev/uio@pci:%u:%u:%u", dev->addr.bus, dev->addr.devid, dev->addr.function); @@ -223,11 +234,6 @@ pci_uio_map_resource(struct rte_pci_device *dev) return -1; } - /* secondary processes - use already recorded details */ - if ((rte_eal_process_type() != RTE_PROC_PRIMARY) && - (dev->id.vendor_id != PCI_VENDOR_ID_QUMRANET)) - return (pci_uio_map_secondary(dev)); - if(dev->id.vendor_id == PCI_VENDOR_ID_QUMRANET) { /* I/O port address already assigned */ /* rte_virtio_pmd does not need any other bar even if available */ @@ -479,19 +485,17 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d return 0; } - /* just map the NIC resources */ - if (pci_uio_map_resource(dev) < 0) - return -1; - - /* We always should have BAR0 mapped */ - if (rte_eal_process_type() == RTE_PROC_PRIMARY && - dev->mem_resource[0].addr == NULL) { - RTE_LOG(ERR, EAL, - "%s(): BAR0 is not mapped\n", - __func__); - return (-1); + 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; + } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && + rte_eal_process_type() == RTE_PROC_PRIMARY) { + /* unbind current driver */ + if (pci_unbind_kernel_driver(dev) < 0) + return -1; } - + /* reference driver structure */ dev->driver = dr; -- 1.7.10.4