From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C3161A0561; Fri, 28 Feb 2020 07:08:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 593A11BFFC; Fri, 28 Feb 2020 07:07:52 +0100 (CET) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id 66A821BFEB for ; Fri, 28 Feb 2020 07:07:42 +0100 (CET) Received: by mail-lj1-f196.google.com with SMTP id x7so2036699ljc.1 for ; Thu, 27 Feb 2020 22:07:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zui5bJjLh1Z1om8Qf1nWSVGOTNxMAqiih05iTDxadGw=; b=oaUisbZe+IhdNsy0hhRzTPKbM/FBAQ6trzjP/sqx7oKSneJRS8LZZT01IJntqVIgVq VAKaARD1tK64eNDOODNPKeqCQPXNdbERg1oqG7p6BodCmBr7F5/47v5nRAZm9G9PSe/G 9Kgf/E4sjvDUV2HVBOHfrdgspGxUnnhLNS3JOWEjMJBAprnRhlfNdYQePMaYCtl5gZap m2eITmgiGMDmu40ny43dksJquLBPYLVBOoZdWKkvcZQ9FtDB8yGGhDgMFpHW4VqYKrJn MnF8osj8wXiDDXoqRrSq8F/URq038LtN8S2MFI7UnFmJTvgmXIt3kyxYJOK3KxCWOrJG uIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zui5bJjLh1Z1om8Qf1nWSVGOTNxMAqiih05iTDxadGw=; b=CLqKj1clSzCoh0wzmw7NR7BsI9WZFv2KazNYovD9WrBalniSfBMjy9AKLJGeGZrHf9 sNIONe7xbZUQ0dD7CoIsuKy/EZ6ciVWFLKZyy5ls1ShhMmBPK9tZlZ68KjwVq42k2fpg BUvcAMfxDEGhcRse63laGlBtezpUJL1YMs0V6X1jfKmg8iBlW7lkHbwtfrOcXaQt9ML8 gN5VkABI5GCBkjkR3SSiptSyU9p/rucczjOG5qFboEesdUpPnKcl7j6X0EyEcx9jLPlG S3kiun8iz2/UIwFGvteOGBItg1c+sOOxfsP/jg82Z65zYJNsJH5ILBFNMIbT4uixENO/ VuBA== X-Gm-Message-State: ANhLgQ3xfQ5KXUe0+oFJ/SLSLmSAPM7XYzTj+ZpmjIevCesHMIlDY9BB d3XGlJ6aESeFlgo9XRNfcZx6A6FF X-Google-Smtp-Source: ADFU+vu8CMvcuCwyZvWYqkhv0GxNf2gukZCIPgdXQ4jg4Y5ICUENRPc6Y+V/MkeVF0yPSOpEoK8YwA== X-Received: by 2002:a2e:96c6:: with SMTP id d6mr1823802ljj.4.1582870061680; Thu, 27 Feb 2020 22:07:41 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id r12sm4819281ljh.105.2020.02.27.22.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 22:07:40 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk Date: Fri, 28 Feb 2020 09:07:25 +0300 Message-Id: <20200228060727.192491-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200228060727.192491-1-dmitry.kozliuk@gmail.com> References: <20200227071126.75162e92@Sovereign> <20200228060727.192491-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC PATCH 3/5] pci/windows: split config I/O into series of fixed-size operations 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" PCI bus kernel driver mandates accessing config space in a series of reads/writes by 4, 2, or 1 bytes. NETUIO driver checks this requirement before performing config space I/O. Users of DPDK PCI bus driver, however, access config space without regard for this requirement. Make DPDK PCI bus driver split config I/O to a series of 4-, 2-, or 1-byte reads/writes. Each of these operations is a syscall to netUIO. Signed-off-by: Dmitry Kozlyuk --- drivers/bus/pci/windows/pci.c | 45 ++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index 387ed4f02..4ffa6a610 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -200,6 +200,32 @@ int send_ioctl(HANDLE f, DWORD ioctl, return ERROR_SUCCESS; } +static int +pci_config_io_sized(HANDLE device, struct dpdk_pci_config_io *io, + void **buf, size_t *left_size, size_t access_size) +{ + uint64_t out; + + io->access_size = access_size; + + while (*left_size >= access_size) { + if (io->op == PCI_IO_WRITE) + memcpy(&io->data, *buf, access_size); + + if (send_ioctl(device, IOCTL_NETUIO_PCI_CONFIG_IO, + io, sizeof(*io), &out, sizeof(out)) != ERROR_SUCCESS) + return -1; + + if (io->op == PCI_IO_READ) + memcpy(*buf, &out, access_size); + + io->offset += access_size; + *buf += access_size; + *left_size -= access_size; + } + return 0; +} + /* Send IOCTL to driver to read/write PCI configuration space */ static int pci_config_io(const struct rte_pci_device *dev, void *buf, @@ -227,23 +253,14 @@ int pci_config_io(const struct rte_pci_device *dev, void *buf, pci_io.dev_addr.dev_num = dev->addr.devid; pci_io.dev_addr.func_num = dev->addr.function; pci_io.offset = offset; - pci_io.access_size = sizeof(UINT32); pci_io.op = operation; - if (operation == PCI_IO_WRITE) - { - pci_io.data.u32 = *(UINT32 UNALIGNED*)buf; - } - - uint64_t outputbuf = 0; - if (send_ioctl(f, IOCTL_NETUIO_PCI_CONFIG_IO, &pci_io, sizeof(pci_io), - &outputbuf, sizeof(outputbuf)) != ERROR_SUCCESS) + if (pci_config_io_sized(f, &pci_io, &buf, &len, sizeof(uint32_t)) < 0) + goto error; + if (pci_config_io_sized(f, &pci_io, &buf, &len, sizeof(uint16_t)) < 0) + goto error; + if (pci_config_io_sized(f, &pci_io, &buf, &len, sizeof(uint8_t)) < 0) goto error; - - if (operation == PCI_IO_READ) - { - memcpy(buf, &outputbuf, sizeof(UINT32)); - } ret = 0; error: -- 2.25.1