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 42F65594F for ; Wed, 21 May 2014 14:42:17 +0200 (CEST) Received: by mail-wi0-f176.google.com with SMTP id n15so7590201wiw.3 for ; Wed, 21 May 2014 05:42:26 -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=omHaX5Sy2CYin5k2n3BGMXfotC4Lqq/CXnCCy8iLOoU=; b=gB1ZNuPxFwKDrZx+pc5qrEYASi/Be7pjE1V7fcIBb1Ir3gQfEr9MdyLAN1muNpsWhH nmarvpFY9Z3TuitVZhE7IdrHXuoEYEszQRptYsuSalr5fQ0QKNR/nfG4OipNjGLGro4x OtM0uiS6XY2v6XrmNawYTE8j3c4BYUds/i5D5GVLJfbkOfZuPBEEr4Rg6tpP77sS6RvO ag5Q4PT7OfPsxyj9xa4cVniI2p69HusmWhwCFLO3v21942E2K0HPR3xZykLgWGFcUZqp MfDplzXDin5kDAMBsu1Mbp344uP8THrlIAo53KAbs6yZkpOUlzyUcoVym7XVE10FSAFO MUKQ== X-Gm-Message-State: ALoCoQmDAnXkTTj+cGDMqezkXB5gO5kc1XuDxhGykfrvcPqH64Oa63Y8uT+Slf4E3QEwMUTwOKKb X-Received: by 10.180.13.113 with SMTP id g17mr10270571wic.48.1400676146403; Wed, 21 May 2014 05:42:26 -0700 (PDT) Received: from xps13.localnet (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id nb8sm2122252wic.18.2014.05.21.05.42.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 May 2014 05:42:25 -0700 (PDT) From: Thomas Monjalon To: Anatoly Burakov Date: Wed, 21 May 2014 14:42:23 +0200 Message-ID: <5094274.XRo5rd3sBr@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-2-git-send-email-anatoly.burakov@intel.com> References: <1400514709-24087-2-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 01/16] Separate igb_uio mapping into a separate file 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: Wed, 21 May 2014 12:42:17 -0000 Hi Anatoly, 2014-05-19 16:51, Anatoly Burakov: > In order to make the code a bit more clean while using multiple > drivers, IGB_UIO mapping has been separated into its own file. > > Signed-off-by: Anatoly Burakov [...] > /* map a particular resource from a file */ > -static void * > -pci_map_resource(void *requested_addr, const char *devname, off_t offset, > +void * > +pci_map_resource(void *requested_addr, int fd, off_t offset, > size_t size) > { > - int fd; > void *mapaddr; > > - /* > - * open devname, to mmap it > - */ > - fd = open(devname, O_RDWR); > - if (fd < 0) { > - RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", > - devname, strerror(errno)); > - goto fail; > - } > - > /* Map the PCI memory resource of device */ > mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE, > MAP_SHARED, fd, offset); > - close(fd); > if (mapaddr == MAP_FAILED || > (requested_addr != NULL && mapaddr != requested_addr)) { > - RTE_LOG(ERR, EAL, "%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx):" > - " %s (%p)\n", __func__, devname, fd, requested_addr, > + RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx):" > + " %s (%p)\n", __func__, fd, requested_addr, > (unsigned long)size, (unsigned long)offset, > strerror(errno), mapaddr); > goto fail; [...] > -static int > -pci_uio_map_resource(struct rte_pci_device *dev) [...] > - /* if matching map is found, then use it */ > - if (j != nb_maps) { > - offset = j * pagesz; > - if (maps[j].addr != NULL || > - (mapaddr = pci_map_resource(NULL, devname, > - (off_t)offset, > - (size_t)maps[j].size) > - ) == NULL) { > - rte_free(uio_res); > - return (-1); > - } > - > - maps[j].addr = mapaddr; > - maps[j].offset = offset; > - dev->mem_resource[i].addr = mapaddr; > - } [...] > + /* if matching map is found, then use it */ > + if (j != nb_maps) { > + offset = j * pagesz; > + > + /* > + * open devname, to mmap it > + */ > + fd = open(uio_res->path, O_RDWR); > + if (fd < 0) { > + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", > + uio_res->path, strerror(errno)); > + rte_free(uio_res); > + return -1; > + } > + > + if (maps[j].addr != NULL > + || (mapaddr = pci_map_resource(NULL, fd, > + (off_t) offset, (size_t) maps[j].size)) == NULL) { > + rte_free(uio_res); > + close(fd); > + return (-1); > + } > + close(fd); > + > + maps[j].addr = mapaddr; > + maps[j].offset = offset; > + dev->mem_resource[i].addr = mapaddr; > + } Looking at pci_map_resource(), it seems you are not only moving functions in another file. Please split this patch in a way we can clearly see what is changing. Thanks -- Thomas