From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by dpdk.org (Postfix) with ESMTP id 816C768C0 for ; Fri, 24 Jan 2014 16:30:24 +0100 (CET) Received: by mail-we0-f175.google.com with SMTP id p61so2770391wes.6 for ; Fri, 24 Jan 2014 07:31:41 -0800 (PST) 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:in-reply-to :references; bh=+yAdqQvGw7heysG8GoOx4AMLs14zr0Rpyzs7YEBPZcc=; b=GeHSN440U0mUybhIFu104j7hKbPrO3WlWB584iSHdwrfZjcU92BjC/z0f2cnWPKiBB v9W4v9Sob5LeviNzmLOSf5SxUhaL1JxNEpFKckagKUwENaOEdURfswejZt/Vz1RTI1tJ 2yGJH1gI6ch7ffP6Js+nzRhNC1GIkVzNboMVAEkHamoLEhIR5JBZ64Ui66vpbgIkrd8+ T3TYZzobD4RgYJGLgplcIuw0X4ih4rjNKQGo4X0YE0yrb2sPjHHx38xaW/Y9aIw+SfLM yLG4auHHjus+1VRx3iryq9gbfYSBidtaxJvoXsOC/kGOcOpAvT77KYEGL4D1RKiEaVhd d0CA== X-Gm-Message-State: ALoCoQk9MYC9YLGc6g42WlwoorSs3kNCPO+zhk5oulga/pJkRMb7lyRIHSqGYxzcKBrYvLoVaN78 X-Received: by 10.181.12.76 with SMTP id eo12mr3629506wid.19.1390577501647; Fri, 24 Jan 2014 07:31:41 -0800 (PST) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id v7sm7881913wix.5.2014.01.24.07.31.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jan 2014 07:31:40 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 24 Jan 2014 16:31:27 +0100 Message-Id: <1390577487-22242-3-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1390577487-22242-1-git-send-email-olivier.matz@6wind.com> References: <1390577487-22242-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 2/2] pci: add option --create-uio-dev to run without hotplug 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, 24 Jan 2014 15:30:25 -0000 When the user specifies --create-uio-dev in dpdk eal start options, the DPDK will create the /dev/uioX instead of waiting that a program does it (which is usually hotplug). This option is useful in embedded environments where there is no hotplug to do the work. Signed-off-by: Olivier Matz --- lib/librte_eal/linuxapp/eal/eal.c | 6 +++ lib/librte_eal/linuxapp/eal/eal_pci.c | 47 +++++++++++++++++++++- .../linuxapp/eal/include/eal_internal_cfg.h | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index bd20331..9168b3f 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -94,6 +94,7 @@ #define OPT_SOCKET_MEM "socket-mem" #define OPT_USE_DEVICE "use-device" #define OPT_SYSLOG "syslog" +#define OPT_CREATE_UIO_DEV "create-uio-dev" #define RTE_EAL_BLACKLIST_SIZE 0x100 @@ -357,6 +358,7 @@ eal_usage(const char *prgname) " --"OPT_NO_PCI" : disable pci\n" " --"OPT_NO_HPET" : disable hpet\n" " --"OPT_NO_SHCONF": no shared config (mmap'd files)\n" + " --"OPT_CREATE_UIO_DEV": create /dev/uioX (usually done by hotplug)\n" "\n", prgname); /* Allow the application to print its usage message too if hook is set */ @@ -608,6 +610,7 @@ eal_parse_args(int argc, char **argv) {OPT_SOCKET_MEM, 1, 0, 0}, {OPT_USE_DEVICE, 1, 0, 0}, {OPT_SYSLOG, 1, NULL, 0}, + {OPT_CREATE_UIO_DEV, 1, NULL, 0}, {0, 0, 0, 0} }; struct shared_driver *solib; @@ -747,6 +750,9 @@ eal_parse_args(int argc, char **argv) return -1; } } + else if (!strcmp(lgopts[option_index].name, OPT_CREATE_UIO_DEV)) { + internal_config.create_uio_dev = 1; + } break; default: diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 1039777..af5a8b9 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -460,6 +460,47 @@ pci_uio_map_secondary(struct rte_pci_device *dev) return -1; } +static int pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num) +{ + FILE *f; + char filename[PATH_MAX]; + int ret; + unsigned major, minor; + dev_t dev; + + /* get the name of the sysfs file that contains the major and minor + * of the uio device and read its content */ + rte_snprintf(filename, sizeof(filename), "%s/dev", sysfs_uio_path); + + f = fopen(filename, "r"); + if (f == NULL) { + RTE_LOG(ERR, EAL, "%s(): cannot open sysfs to get major:minor\n", + __func__); + return -1; + } + + ret = fscanf(f, "%d:%d", &major, &minor); + if (ret != 2) { + RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs to get major:minor\n", + __func__); + fclose(f); + return -1; + } + fclose(f); + + /* create the char device "mknod /dev/uioX c major minor" */ + rte_snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num); + dev = makedev(major, minor); + ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev); + if (f == NULL) { + RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n", + __func__, strerror(errno)); + return -1; + } + + return ret; +} + /* * Return the uioX char device used for a pci device. On success, return * the UIO number and fill dstbuf string with the path of the device in @@ -529,7 +570,11 @@ static int pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf, if (e == NULL) return -1; - return 0; + /* create uio device if we've been asked to */ + if (internal_config.create_uio_dev && pci_mknod_uio_dev(dstbuf, uio_num) < 0) + RTE_LOG(WARNING, EAL, "Cannot create /dev/uio%u\n", uio_num); + + return uio_num; } /* map the PCI resource of a PCI device in virtual memory */ diff --git a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h index 45ec058..649bd2b 100644 --- a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h +++ b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h @@ -68,6 +68,7 @@ struct internal_config { volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping * instead of native TSC */ volatile unsigned no_shconf; /**< true if there is no shared config */ + volatile unsigned create_uio_dev; /**< true to create /dev/uioX devices */ volatile enum rte_proc_type_t process_type; /**< multi-process proc type */ /** true to try allocating memory on specific sockets */ volatile unsigned force_sockets; -- 1.8.4.rc3