DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pallavi Kadam <pallavi.kadam@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, ranjit.menon@intel.com,
	dmitry.kozliuk@gmail.com, Narcisa.Vasile@microsoft.com,
	roretzla@linux.microsoft.com, qiao.liu@intel.com,
	pallavi.kadam@intel.com
Subject: [dpdk-kmods v2] windows/netuio: fix BAR parsing
Date: Thu, 11 Aug 2022 15:17:23 -0700	[thread overview]
Message-ID: <20220811221723.2124-1-pallavi.kadam@intel.com> (raw)
In-Reply-To: <20220802191058.1779-1-pallavi.kadam@intel.com>

Current code was always checking the 'prev_bar & PCI_TYPE_64BIT'
though only the first BAR slot of a 64-bit BAR contains flags.
Also for certain PCIe devices, BAR values were not continuous.
This patch fixes this incorrectness and maps the BAR addresses
correctly.

Reported-by: Qiao Liu <qiao.liu@intel.com>
Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Tested-by: Pallavi Kadam <pallavi.kadam@intel.com>
---
 windows/netuio/netuio_dev.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/windows/netuio/netuio_dev.c b/windows/netuio/netuio_dev.c
index b2deb10..073fac8 100644
--- a/windows/netuio/netuio_dev.c
+++ b/windows/netuio/netuio_dev.c
@@ -170,8 +170,6 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R
 
     PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor;
     ULONG next_descriptor = 0;
-    ULONG curr_bar = 0;
-    ULONG prev_bar = 0;
 
    /*
     * ResourcesTranslated report MMIO BARs in the correct order, but their
@@ -195,9 +193,9 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R
     * searching for the next MMIO resource each time.
     */
     for (INT bar_index = 0; bar_index < PCI_MAX_BAR; bar_index++) {
-        prev_bar = curr_bar;
-        curr_bar = pci_config.u.type0.BaseAddresses[bar_index];
-        if (curr_bar == 0 || (prev_bar & PCI_TYPE_64BIT)) {
+        ULONG bar_value = pci_config.u.type0.BaseAddresses[bar_index];
+
+        if (bar_value == 0) {
             continue;
         }
 
@@ -236,6 +234,11 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R
         }
 
         ctx->dpdk_hw[bar_index].mem.size = ctx->bar[bar_index].size;
+
+        // Skip the next BAR slot used by the current 64-bit address.
+        if (bar_value & PCI_TYPE_64BIT) {
+            bar_index++;
+        }
     } // for bar_index
 
     status = STATUS_SUCCESS;
-- 
2.31.1.windows.1


  parent reply	other threads:[~2022-08-11 22:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 19:10 [dpdk-kmods] windows/netuio: fix bar parsing Pallavi Kadam
2022-08-06 21:01 ` Dmitry Kozlyuk
2022-08-08 20:40   ` Kadam, Pallavi
2022-08-09  0:33   ` Kadam, Pallavi
2022-08-09  9:15     ` Dmitry Kozlyuk
2022-08-11 22:21       ` Kadam, Pallavi
2022-08-11 22:17 ` Pallavi Kadam [this message]
2022-08-18  2:51   ` [dpdk-kmods v2] windows/netuio: fix BAR parsing Liu, Qiao
2022-08-19 18:13   ` Menon, Ranjit
2022-08-29  8:04     ` Thomas Monjalon

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=20220811221723.2124-1-pallavi.kadam@intel.com \
    --to=pallavi.kadam@intel.com \
    --cc=Narcisa.Vasile@microsoft.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=qiao.liu@intel.com \
    --cc=ranjit.menon@intel.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=thomas@monjalon.net \
    /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).