summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarini Ramakrishnan <haramakr@microsoft.com>2019-01-14 11:13:58 -0800
committerHarini Ramakrishnan <haramakr@microsoft.com>2019-01-14 11:13:58 -0800
commitc7520c282d0f75f78a600806e8fa300e33670384 (patch)
treea83078f07df440d8d14d45683d2a9475c01a5986
parent4c99c0a59a7e33144af2333bff590bdff37fd65d (diff)
downloaddpdk-draft-windows-c7520c282d0f75f78a600806e8fa300e33670384.zip
dpdk-draft-windows-c7520c282d0f75f78a600806e8fa300e33670384.tar.gz
dpdk-draft-windows-c7520c282d0f75f78a600806e8fa300e33670384.tar.xz
doc: remove embedded buffer from Windows UIO ioctl
-rw-r--r--drivers/bus/pci/windows/pci.c11
-rw-r--r--kernel/windows/netuio/netuio_interface.h9
-rw-r--r--kernel/windows/netuio/netuio_queue.c43
-rw-r--r--mk/exec-env/windows/netuio/netuio.vcxproj6
4 files changed, 54 insertions, 15 deletions
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index b6b7dcd..6779731 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -195,18 +195,23 @@ 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.buf = buf;
+ {
+ pci_io.data.u32 = *(UINT32 UNALIGNED*)buf;
+ }
- uint32_t outputbuf = 0;
+ uint64_t outputbuf = 0;
if (send_ioctl(f, IOCTL_NETUIO_PCI_CONFIG_IO, &pci_io, sizeof(pci_io),
&outputbuf, sizeof(outputbuf)) != ERROR_SUCCESS)
goto error;
if (operation == PCI_IO_READ)
- memcpy(buf, &outputbuf, sizeof(outputbuf));
+ {
+ memcpy(buf, &outputbuf, sizeof(UINT32));
+ }
ret = 0;
error:
diff --git a/kernel/windows/netuio/netuio_interface.h b/kernel/windows/netuio/netuio_interface.h
index b86bf5d..f84ee89 100644
--- a/kernel/windows/netuio/netuio_interface.h
+++ b/kernel/windows/netuio/netuio_interface.h
@@ -59,9 +59,16 @@ struct dpdk_private_info
struct dpdk_pci_config_io
{
struct dev_addr dev_addr;
- PVOID buf;
UINT32 offset;
enum pci_io op;
+ UINT32 access_size; // 1, 2, 4, or 8 bytes
+
+ union dpdk_pci_config_io_data {
+ UINT8 u8;
+ UINT16 u16;
+ UINT32 u32;
+ UINT64 u64;
+ } data;
};
#pragma pack(pop)
diff --git a/kernel/windows/netuio/netuio_queue.c b/kernel/windows/netuio/netuio_queue.c
index 312d4b6..9291928 100644
--- a/kernel/windows/netuio/netuio_queue.c
+++ b/kernel/windows/netuio/netuio_queue.c
@@ -11,22 +11,23 @@
#pragma alloc_text (PAGE, netuio_queue_initialize)
#endif
-VOID netuio_read_PCI_config(PNETUIO_CONTEXT_DATA netuio_contextdata, ULONG offset, PVOID buffer)
+VOID netuio_read_PCI_config(PNETUIO_CONTEXT_DATA netuio_contextdata, ULONG offset, UINT32 access_size, _Out_ UINT64 *output)
{
+ *output = 0;
netuio_contextdata->bus_interface.GetBusData(netuio_contextdata->bus_interface.Context,
PCI_WHICHSPACE_CONFIG,
- buffer,
+ output,
offset,
- sizeof(UINT32));
+ access_size);
}
-VOID netuio_write_PCI_config(PNETUIO_CONTEXT_DATA netuio_contextdata, ULONG offset, PVOID buffer)
+VOID netuio_write_PCI_config(PNETUIO_CONTEXT_DATA netuio_contextdata, ULONG offset, UINT32 access_size, union dpdk_pci_config_io_data const *input)
{
netuio_contextdata->bus_interface.SetBusData(netuio_contextdata->bus_interface.Context,
PCI_WHICHSPACE_CONFIG,
- buffer,
+ (PVOID)input,
offset,
- sizeof(UINT32));
+ access_size);
}
static NTSTATUS
@@ -180,6 +181,15 @@ netuio_evt_IO_device_control(_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request,
}
struct dpdk_pci_config_io *dpdk_pci_io_input = (struct dpdk_pci_config_io *)input_buf;
+
+ if (dpdk_pci_io_input->access_size != 1 &&
+ dpdk_pci_io_input->access_size != 2 &&
+ dpdk_pci_io_input->access_size != 4 &&
+ dpdk_pci_io_input->access_size != 8) {
+ status = STATUS_INVALID_PARAMETER;
+ break;
+ }
+
// Ensure that the B:D:F match - otherwise, fail the IOCTL
if ((netuio_contextdata->addr.bus_num != dpdk_pci_io_input->dev_addr.bus_num) ||
(netuio_contextdata->addr.dev_num != dpdk_pci_io_input->dev_addr.dev_num) ||
@@ -188,7 +198,7 @@ netuio_evt_IO_device_control(_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request,
break;
}
// Retrieve output buffer
- status = WdfRequestRetrieveOutputBuffer(Request, sizeof(UINT32), &output_buf, &output_buf_size);
+ status = WdfRequestRetrieveOutputBuffer(Request, sizeof(UINT64), &output_buf, &output_buf_size);
if (!NT_SUCCESS(status)) {
status = STATUS_INVALID_BUFFER_SIZE;
break;
@@ -196,13 +206,24 @@ netuio_evt_IO_device_control(_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request,
ASSERT(output_buf_size == OutputBufferLength);
if (dpdk_pci_io_input->op == PCI_IO_READ) {
- netuio_read_PCI_config(netuio_contextdata, dpdk_pci_io_input->offset, output_buf);
- bytes_returned = output_buf_size;
+ netuio_read_PCI_config(netuio_contextdata,
+ dpdk_pci_io_input->offset,
+ dpdk_pci_io_input->access_size,
+ (UINT64*)output_buf);
+
+ bytes_returned = sizeof(UINT64);
}
- else {
- netuio_write_PCI_config(netuio_contextdata, dpdk_pci_io_input->offset, dpdk_pci_io_input->buf);
+ else if (dpdk_pci_io_input->op == PCI_IO_WRITE) {
+ netuio_write_PCI_config(netuio_contextdata,
+ dpdk_pci_io_input->offset,
+ dpdk_pci_io_input->access_size,
+ &dpdk_pci_io_input->data);
bytes_returned = 0;
}
+ else {
+ status = STATUS_INVALID_PARAMETER;
+ break;
+ }
break;
diff --git a/mk/exec-env/windows/netuio/netuio.vcxproj b/mk/exec-env/windows/netuio/netuio.vcxproj
index b6564e4..b6b11e4 100644
--- a/mk/exec-env/windows/netuio/netuio.vcxproj
+++ b/mk/exec-env/windows/netuio/netuio.vcxproj
@@ -68,6 +68,9 @@
<Inf>
<TimeStamp>0.6.0.5</TimeStamp>
</Inf>
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -80,6 +83,9 @@
<Inf>
<TimeStamp>0.6.0.5</TimeStamp>
</Inf>
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)\wdmsec.lib</AdditionalDependencies>
+ </Link>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />