From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id B71427CB0 for ; Thu, 28 Jun 2018 15:06:04 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id t21-v6so4461925lji.0 for ; Thu, 28 Jun 2018 06:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8936pSBPolxnel0eKD5SLwue+s8qV0xifgdrblxOR2g=; b=oIiFPHQFu49oXEem5i39/gJ4JInVqrKQvXV5p4L/M+528V91odj8pgdngqL3MxdVK4 uRtaRmABgyhEZ4xYXfCBuuLodVSdS/FNqdnWKzDYzrzwtP39d+RN4oKG+LW0s/cVxmWe tgpVKGHcsYc4N21SvP/ohVjvym+yEPrNraqXfUhkufOVQerUxoNtHOGulB/KCiMqlyVV D8z58JmH4dmkAVN48C5ErZmsSEZFow9tjIL8+mSNiiCcAQ5II1/AtVGBmjUDGUSCVdww 74r1WUHmPpOCgL16rIgQS3iYBawpvfdKJm3Y42rfCieM32G/SbB9GFk0pjqLMqgrk478 N8OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8936pSBPolxnel0eKD5SLwue+s8qV0xifgdrblxOR2g=; b=Q7vN61JEv1Ug2LJEI86lltsdVWksyZij/cOBWz+a5u+a2jFCPm5ti1Xn6ik/CqG6oV 4TARNaIJHOog/J56sFeIZnpCwI2tSf2uofLjJYMdTmkHjbBJuUK3WRowqfsAY2roNY1z 9TikDCW6t0UvDNv4ODsv4B5lCfORq18etr+/X1dAyZEzDJqZe+iBDnLyKhOyLQRUPbHb tHx09pYyvj1SNgi0dSzPe/X3LyO0VVsSut5NH/fSvUk5DMrmT5CO6v3G58zIJIrn/2gD dlLSTwcTIu/3vs54ELB8SmMr211dZEfAeu4KiVR8HAkmzzsiAZd/zHHDrrckLeM/9tEL QGaQ== X-Gm-Message-State: APt69E2BCUCz6os6jBDtmmMb6Ehwu4P/j7ElD2wTLgivSiru2SltRQ5Q 2ESZ5/AGfYrMWwuXhgQW+gv388SyEIAY6fISzFYB5g== X-Google-Smtp-Source: AAOMgpdo8mMbAwhEMAlku5GmyGpVNyEEIE9O73kBLdaMctMYK+0HcjSNX1kXhTtPNF4bY8++CrMdq0VDPg3ot66P734= X-Received: by 2002:a2e:2bc9:: with SMTP id r70-v6mr2823814ljr.133.1530191164417; Thu, 28 Jun 2018 06:06:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:4a95:0:0:0:0:0 with HTTP; Thu, 28 Jun 2018 06:06:03 -0700 (PDT) In-Reply-To: References: <1523455637-31719-1-git-send-email-rk@semihalf.com> <1523455637-31719-4-git-send-email-rk@semihalf.com> From: =?UTF-8?B?UmFmYcWCIEtvemlr?= Date: Thu, 28 Jun 2018 15:06:03 +0200 Message-ID: To: Ferruh Yigit Cc: dev@dpdk.org, Marcin Wojtas , =?UTF-8?Q?Micha=C5=82_Krawczyk?= , "Tzalik, Guy" , "Schmeilin, Evgeny" , "Matushevsky, Alexander" , "Chauskin, Igor" Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 3/4] eal: enable WC during resources mapping X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 13:06:04 -0000 2018-06-27 18:41 GMT+02:00 Ferruh Yigit : > On 4/11/2018 3:07 PM, Rafal Kozik wrote: >> Write combining (wc) increase NIC performenca by making better >> utilization of PCI bus, but cannot be used by all PMD. >> >> It will be enable only if RTE_PCI_DRV_WC_ACTIVATE will be set in >> drivers flags. For proper work also igb driver must be loaded with >> wc_activate set to 1. >> >> When mapping PCI resources firstly try to us wc. >> If it is not supported it will fallback to normal mode. >> >> Signed-off-by: Rafal Kozik >> --- >> drivers/bus/pci/linux/pci_uio.c | 39 ++++++++++++++++++++++++++++----------- >> drivers/bus/pci/rte_bus_pci.h | 2 ++ >> 2 files changed, 30 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c >> index d423e4b..a1570c9 100644 >> --- a/drivers/bus/pci/linux/pci_uio.c >> +++ b/drivers/bus/pci/linux/pci_uio.c >> @@ -287,17 +287,14 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, >> void *mapaddr; >> struct rte_pci_addr *loc; >> struct pci_map *maps; >> + int wc_activate = 0; >> + >> + if (dev->driver != NULL) >> + wc_activate = dev->driver->drv_flags & RTE_PCI_DRV_WC_ACTIVATE; >> >> loc = &dev->addr; >> maps = uio_res->maps; >> >> - /* update devname for mmap */ >> - snprintf(devname, sizeof(devname), >> - "%s/" PCI_PRI_FMT "/resource%d", >> - rte_pci_get_sysfs_path(), >> - loc->domain, loc->bus, loc->devid, >> - loc->function, res_idx); >> - >> /* allocate memory to keep path */ >> maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0); >> if (maps[map_idx].path == NULL) { >> @@ -309,11 +306,31 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, >> /* >> * open resource file, to mmap it >> */ >> - fd = open(devname, O_RDWR); >> - if (fd < 0) { >> - RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", >> + if (wc_activate) { >> + /* update devname for mmap */ >> + snprintf(devname, sizeof(devname), >> + "%s/" PCI_PRI_FMT "/resource%d_wc", >> + rte_pci_get_sysfs_path(), >> + loc->domain, loc->bus, loc->devid, >> + loc->function, res_idx); >> + >> + fd = open(devname, O_RDWR); >> + } >> + >> + if (!wc_activate || fd < 0) { > > "fd" may be used uninitialized here, although its value doesn't affect the > branch taken it can be good to initialize it for any possible static analyzer > warning. > I will fix it in new, rebased patch set. >> + snprintf(devname, sizeof(devname), >> + "%s/" PCI_PRI_FMT "/resource%d", >> + rte_pci_get_sysfs_path(), >> + loc->domain, loc->bus, loc->devid, >> + loc->function, res_idx); >> + >> + /* then try to map resource file */ >> + fd = open(devname, O_RDWR); >> + if (fd < 0) { >> + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", >> devname, strerror(errno)); >> - goto error; >> + goto error; >> + } >> } >> >> /* try mapping somewhere close to the end of hugepages */ >> diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h >> index 357afb9..b7bcce3 100644 >> --- a/drivers/bus/pci/rte_bus_pci.h >> +++ b/drivers/bus/pci/rte_bus_pci.h >> @@ -132,6 +132,8 @@ struct rte_pci_bus { >> >> /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */ >> #define RTE_PCI_DRV_NEED_MAPPING 0x0001 >> +/** Device needs PCI BAR mapping with enabled write combining (wc) */ >> +#define RTE_PCI_DRV_WC_ACTIVATE 0x0002 >> /** Device driver supports link state interrupt */ >> #define RTE_PCI_DRV_INTR_LSC 0x0008 >> /** Device driver supports device removal interrupt */ >> >