From c32dd3654eaf99121cc44a3f828883a69e7760e5 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Fri, 24 Sep 2021 12:40:42 +0200
Subject: [statistics/passthrough] WIP
---
.../passthrough/inc/passthrough.inc.php | 17 ++++++++--
modules-available/passthrough/page.inc.php | 39 +++++++++++++++++++---
.../passthrough/templates/hardware-list.html | 39 +++++++++++++++++++---
modules-available/statistics/api.inc.php | 2 +-
.../statistics/inc/hardwareinfo.inc.php | 19 +++++++++--
.../statistics/inc/hardwareparser.inc.php | 6 ++--
.../statistics/inc/hardwarequery.inc.php | 22 ++++++++++++
modules-available/statistics/inc/pciid.inc.php | 15 ++++++++-
modules-available/statistics/page.inc.php | 24 ++++++++-----
9 files changed, 156 insertions(+), 27 deletions(-)
diff --git a/modules-available/passthrough/inc/passthrough.inc.php b/modules-available/passthrough/inc/passthrough.inc.php
index 51fe7214..524aea5e 100644
--- a/modules-available/passthrough/inc/passthrough.inc.php
+++ b/modules-available/passthrough/inc/passthrough.inc.php
@@ -3,16 +3,27 @@
class Passthrough
{
- public static function getGroupDropdown(array $row): array
+ public static function getGroupDropdown(array &$row): array
{
+ $out = [];
+ if ($row['class'] === '0300') {
+ foreach (['GPU', 'GVT'] as $id) {
+ $out[] = [
+ 'ptid' => $id,
+ 'ptname' => $id,
+ 'selected' => ($row['@PASSTHROUGH'] === $id ? 'selected' : ''),
+ ];
+ }
+ return $out;
+ }
static $list = false;
if ($list === false) {
$list = Database::queryKeyValueList("SELECT groupid, title FROM passthrough_group ORDER BY groupid");
self::ensurePrepopulated($list);
}
- $out = [];
+ $row['custom_groups'] = true;
foreach ($list as $id => $title) {
- if ($row['class'] !== '0300' && ($id === 'GPU' || $id === 'GVT'))
+ if ($id === 'GPU' || $id === 'GVT')
continue;
$item = ['ptid' => $id, 'ptname' => $id . ' (' . $title . ')'];
if ($row['@PASSTHROUGH'] === $id) {
diff --git a/modules-available/passthrough/page.inc.php b/modules-available/passthrough/page.inc.php
index 33f2e4a3..0911550c 100644
--- a/modules-available/passthrough/page.inc.php
+++ b/modules-available/passthrough/page.inc.php
@@ -87,11 +87,42 @@ class Page_Passthrough extends Page
return 1;
return hexdec($a) - hexdec($b);
});
- foreach ($rows as &$row) {
- $row['vendor_name'] = PciId::getPciId(PciId::VENDOR, $row['vendor'] ?? '', true);
- $row['device_name'] = PciId::getPciId(PciId::DEVICE, $row['vendor'] . ':' . $row['device'], true);
+ $finalRows = [];
+ $missing = [];
+ $lastClass = '';
+ foreach ($rows as $row) {
+ if ($row['class'] !== $lastClass) {
+ // Add class row header
+ $lastClass = $row['class'];
+ $finalRows[] = [
+ 'class' => $row['class'],
+ 'class_name' => PciId::getPciId(PciId::DEVCLASS, $row['class'], true) ?: 'Unknown',
+ ];
+ }
+ $row['vendor_name'] = PciId::getPciId(PciId::VENDOR, $row['vendor'] ?? '');
+ $row['device_name'] = PciId::getPciId(PciId::DEVICE, $row['vendor'] . ':' . $row['device']);
+ $finalRows[] = $row;
+ // Build up query
+ if ($row['vendor_name'] === false) {
+ $missing[$row['vendor']] = true;
+ }
+ if ($row['device_name'] === false) {
+ $missing[$row['vendor'] . ':' . $row['device']] = true;
+ }
}
- Render::addTemplate('hardware-list', ['list' => $rows]);
+ Render::addTemplate('hardware-list', [
+ 'list' => $finalRows,
+ 'missing_ids' => json_encode(array_keys($missing)),
+ ]);
+ }
+
+ /*
+ *
+ */
+
+ protected function doAjax()
+ {
+ //
}
}
\ No newline at end of file
diff --git a/modules-available/passthrough/templates/hardware-list.html b/modules-available/passthrough/templates/hardware-list.html
index 2450e457..d331acb5 100644
--- a/modules-available/passthrough/templates/hardware-list.html
+++ b/modules-available/passthrough/templates/hardware-list.html
@@ -3,7 +3,6 @@
- {{lang_class}} |
{{lang_deviceIdNumeric}} |
{{lang_deviceName}} |
{{lang_useCount}} |
@@ -13,25 +12,35 @@
{{#list}}
- {{class}} |
+ {{#class_name}}
+
+ {{class}} – {{class_name}}
+ |
+ {{/class_name}}
+ {{^class_name}}
{{vendor}}:{{device}} |
- {{device_name}} |
+
+ {{device_name}}
+ |
- {{vendor_name}}
+
+ {{vendor_name}}
+
|
{{connected_count}} |
- |
+ {{/class_name}}
{{/list}}
@@ -92,5 +101,25 @@
$(this).append($('