From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Subject: [dpdk-dev] [RFC PATCH 3/5] pci/windows: split config I/O into series of fixed-size operations
Date: Fri, 28 Feb 2020 09:07:25 +0300 [thread overview]
Message-ID: <20200228060727.192491-4-dmitry.kozliuk@gmail.com> (raw)
In-Reply-To: <20200228060727.192491-1-dmitry.kozliuk@gmail.com>
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 <dmitry.kozliuk@gmail.com>
---
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
next prev parent reply other threads:[~2020-02-28 6:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-08 8:45 [dpdk-dev] Windows Draft Build Dmitry Kozlyuk
2020-02-10 5:03 ` Ranjit Menon
2020-02-10 6:14 ` Dmitry Kozlyuk
2020-02-17 1:14 ` Dmitry Kozlyuk
2020-02-18 21:44 ` Ranjit Menon
2020-02-25 2:37 ` Dmitry Kozlyuk
2020-02-25 9:06 ` Ranjit Menon
2020-02-26 6:22 ` Dmitry Kozlyuk
2020-02-27 4:11 ` Dmitry Kozlyuk
2020-02-27 15:25 ` William Tu
2020-02-27 15:42 ` David Marchand
2020-02-28 6:07 ` [dpdk-dev] [RFC PATCH 0/5] virtio-net support for Windows draft Dmitry Kozlyuk
2020-02-28 6:07 ` [dpdk-dev] [RFC PATCH 1/5] pci/windows: add stubs for port IO Dmitry Kozlyuk
2020-02-28 6:07 ` [dpdk-dev] [RFC PATCH 2/5] net: add stub for RARP packet generation on Windows Dmitry Kozlyuk
2020-02-28 6:07 ` Dmitry Kozlyuk [this message]
2020-02-28 6:07 ` [dpdk-dev] [RFC PATCH 4/5] netuio: change class for Net to custom Dmitry Kozlyuk
2020-02-28 6:07 ` [dpdk-dev] [RFC PATCH 5/5] mk/windows: add virtio-net PMD Dmitry Kozlyuk
2021-08-14 15:55 ` William Tu
2021-08-14 17:00 ` Dmitry Kozlyuk
2021-08-15 14:28 ` William Tu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200228060727.192491-4-dmitry.kozliuk@gmail.com \
--to=dmitry.kozliuk@gmail.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).