Skip to contentSkip to conversation

s390x/pci: add common function measurement block

PATCH Superseded Pierre Morel 3 participants 4 messages Dec 14, 2018 – Dec 23, 2018

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 s390x/pci: add common function measurement block

From: Yi Min Zhao <[email protected]>

Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.

This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s by default.

An error while attemping to update the FMB, would generated an error event to the guest.

The pcilg/stg/stb and rpcit interception handlers issue, increase the related counter on success.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instrcuction to switch off FMB and stop the corresponding timer.

---
 hw/s390x/s390-pci-bus.c  |   4 +-
 hw/s390x/s390-pci-bus.h  |  29 ++++++++++
 hw/s390x/s390-pci-inst.c | 138 +++++++++++++++++++++++++++++++++++++++++++++--
 hw/s390x/s390-pci-inst.h |   1 +
 4 files changed, 168 insertions(+), 4 deletions(-)
hw/s390x/s390-pci-bus.c +3 -1
index 060ff06..f0d34dd 100644
@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev,
     bus = pci_get_bus(pci_dev);
     devfn = pci_dev->devfn;
     object_unparent(OBJECT(pci_dev));
+    fmb_timer_free(pbdev);
     s390_pci_msix_free(pbdev);
     s390_pci_iommu_free(s, bus, devfn);
     pbdev->pdev = NULL;
@@ -1136,6 +1137,7 @@ static void s390_pci_device_realize(DeviceState *dev, Error **errp)
     }
 
     zpci->state = ZPCI_FS_RESERVED;
+    zpci->fmb.format = ZPCI_FMB_FORMAT;
 }
 
 static void s390_pci_device_reset(DeviceState *dev)
@@ -1160,7 +1162,7 @@ static void s390_pci_device_reset(DeviceState *dev)
         pci_dereg_ioat(pbdev->iommu);
     }
 
-    pbdev->fmb_addr = 0;
+    fmb_timer_free(pbdev);
 }
 
 static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,
hw/s390x/s390-pci-bus.h +29 -0
index 1f7f9b5..458cd3a 100644
@@ -286,6 +286,33 @@ typedef struct S390PCIIOMMUTable {
     S390PCIIOMMU *iommu[PCI_SLOT_MAX];
 } S390PCIIOMMUTable;
 
+/* Function Measurement Block */
+#define DEFAULT_MUI 4000
+#define UPDATE_U_BIT 0x1ULL
+#define FMBK_MASK 0xfULL
+
+typedef struct ZpciFmbFmt0 {
+    uint64_t dma_rbytes;
+    uint64_t dma_wbytes;
+} ZpciFmbFmt0;
+
+#define ZPCI_FMB_CNT_LD    0
+#define ZPCI_FMB_CNT_ST    1
+#define ZPCI_FMB_CNT_STB   2
+#define ZPCI_FMB_CNT_RPCIT 3
+#define ZPCI_FMB_CNT_MAX   4
+
+#define ZPCI_FMB_FORMAT	0
+
+typedef struct ZpciFmb {
+    uint32_t format;
+    uint32_t sample;
+    uint64_t last_update;
+    uint64_t counter[ZPCI_FMB_CNT_MAX];
+    ZpciFmbFmt0 fmt0;
+} ZpciFmb;
+QEMU_BUILD_BUG_MSG(offsetof(ZpciFmb, fmt0) != 48, "padding in ZpciFmb");
+
 struct S390PCIBusDevice {
     DeviceState qdev;
     PCIDevice *pdev;
@@ -297,6 +324,8 @@ struct S390PCIBusDevice {
     uint32_t fid;
     bool fid_defined;
     uint64_t fmb_addr;
+    ZpciFmb fmb;
+    QEMUTimer *fmb_timer;
     uint8_t isc;
     uint16_t noi;
     uint16_t maxstbl;
hw/s390x/s390-pci-inst.c +135 -3

187 lines not on this page · raw message

hw/s390x/s390-pci-inst.h +1 -0
index 91c3d61..fa3bf8b 100644
@@ -303,6 +303,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
                         uintptr_t ra);
 int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
                          uintptr_t ra);
+void fmb_timer_free(S390PCIBusDevice *pbdev);
 
 #define ZPCI_IO_BAR_MIN 0
 #define ZPCI_IO_BAR_MAX 5
Signature · 1 line
2.7.4
#1 lore raw
Quoted 19 lines · On Fri, 14 Dec 2018 15:11:18 +0100 Pierre Morel <[email protected]> wrote:

From: Yi Min Zhao <[email protected]>

Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.

This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s by default.

An error while attemping to update the FMB, would generated an error event to the guest.

The pcilg/stg/stb and rpcit interception handlers issue, increase the related counter on success.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instrcuction to switch off FMB and stop the corresponding timer.

Quoted 8 lines
---
 hw/s390x/s390-pci-bus.c  |   4 +-
 hw/s390x/s390-pci-bus.h  |  29 ++++++++++
 hw/s390x/s390-pci-inst.c | 138 +++++++++++++++++++++++++++++++++++++++++++++--
 hw/s390x/s390-pci-inst.h |   1 +
 4 files changed, 168 insertions(+), 4 deletions(-)

Are there any changes in there other than the endianness handling?

#2 lore raw
Quoted 31 lines · Cornelia Huck
Quoted 19 lines · On Fri, 14 Dec 2018 15:11:18 +0100 Pierre Morel <[email protected]> wrote:

From: Yi Min Zhao <[email protected]>

Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.

This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s by default.

An error while attemping to update the FMB, would generated an error event to the guest.

The pcilg/stg/stb and rpcit interception handlers issue, increase the related counter on success.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instrcuction to switch off FMB and stop the corresponding timer.

Quoted 8 lines
---
  hw/s390x/s390-pci-bus.c  |   4 +-
  hw/s390x/s390-pci-bus.h  |  29 ++++++++++
  hw/s390x/s390-pci-inst.c | 138 +++++++++++++++++++++++++++++++++++++++++++++--
  hw/s390x/s390-pci-inst.h |   1 +
  4 files changed, 168 insertions(+), 4 deletions(-)
Quoted 2 lines

Are there any changes in there other than the endianness handling?

Hum, yes.
Forget this patch, I post a new one with a complete changelog. I also noticed that I forgot an error report.

Regards,
Pierre

Signature · 2 lines
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany
#3 lore raw
In reply to Pierre Morel
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v3] s390x/pci: add common function measurement block

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
3664584 s390x/pci: add common function measurement block

=== OUTPUT BEGIN ===
Checking PATCH 1/1: s390x/pci: add common function measurement block...
ERROR: code indent should never use tabs
#80: FILE: hw/s390x/s390-pci-bus.h:304:
+#define ZPCI_FMB_FORMAT^I0$

ERROR: code indent should never use tabs
#213: FILE: hw/s390x/s390-pci-inst.c:950:
+^Iret = MEMTX_ERROR;$

WARNING: line over 80 characters
#241: FILE: hw/s390x/s390-pci-inst.c:978:
+ if (fmb_do_update(pbdev, offset, pbdev->fmb.sample++, sizeof(pbdev->fmb.sample))) {

total: 2 errors, 1 warnings, 257 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]