[dpdk-kmods,v2] windows/netuio: fix BAR parsing

Message ID 20220811221723.2124-1-pallavi.kadam@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [dpdk-kmods,v2] windows/netuio: fix BAR parsing |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Kadam, Pallavi Aug. 11, 2022, 10:17 p.m. UTC
  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(-)
  

Comments

Liu, Qiao Aug. 18, 2022, 2:51 a.m. UTC | #1
在 2022/8/12 6:17, Pallavi Kadam 写道:
> 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>
> ---

Acked-by: Qiao Liu <qiao.liu@intel.com>
  
Menon, Ranjit Aug. 19, 2022, 6:13 p.m. UTC | #2
On 8/11/2022 3:17 PM, Pallavi Kadam wrote:
> 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(-)
>
Acked-by: Ranjit Menon <ranjit.menon@intel.com>
  
Thomas Monjalon Aug. 29, 2022, 8:04 a.m. UTC | #3
19/08/2022 20:13, Menon, Ranjit:
> On 8/11/2022 3:17 PM, Pallavi Kadam wrote:
> > 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(-)
> >
> Acked-by: Ranjit Menon <ranjit.menon@intel.com>

Applied, thanks.
  

Patch

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;