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 86E55A04B1; Fri, 14 Aug 2020 01:24:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8B1CA1C19C; Fri, 14 Aug 2020 01:23:00 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by dpdk.org (Postfix) with ESMTP id EA8DF1C0D0 for ; Fri, 14 Aug 2020 01:22:44 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1059) id D99EF20B491D; Thu, 13 Aug 2020 16:22:43 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D99EF20B491D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1597360963; bh=WJ6ntCn+Z/sRLYQUG9e/b5N02EjyVfEmm9nSeJMvyfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ETZEdMN8rU2DQmZBIbgUg5e/+2LnvXEcwXjiv0rvxxGGCeWBlOsVbYNmRG77wbv0m x8GzfgX4WByxgg0mJy7KKwPwB/NU8J148V7sR5wqey3482o55qheH8jrj2WNY7aeS1 0UGlnF/7/WXFng1G3cBI5tmFBuPqiIZXW/k9UIEg= From: Narcisa Ana Maria Vasile To: dev@dpdk.org, thomas@monjalon.net, haramakr@linux.microsoft.com, ocardona@microsoft.com, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com Cc: ranjit.menon@intel.com, dmitrym@microsoft.com, Harini Ramakrishnan Date: Thu, 13 Aug 2020 16:21:32 -0700 Message-Id: <1597360905-74106-10-git-send-email-navasile@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597360905-74106-1-git-send-email-navasile@linux.microsoft.com> References: <1597360905-74106-1-git-send-email-navasile@linux.microsoft.com> Subject: [dpdk-dev] [PATCH 09/22] doc: remove embedded buffer from Windows UIO ioctl 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" From: Harini Ramakrishnan --- kernel/windows/netuio/netuio_interface.h | 9 ++++- kernel/windows/netuio/netuio_queue.c | 43 ++++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/kernel/windows/netuio/netuio_interface.h b/kernel/windows/netuio/netuio_interface.h index b86bf5d3f..f84ee895c 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 312d4b682..929192880 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; -- 2.23.0.vfs.1.1.63.g5a5ad7f