exporter: Add USB hub abstraction for simpler device matching#1854
exporter: Add USB hub abstraction for simpler device matching#1854sjg20 wants to merge 1 commit intolabgrid-project:masterfrom
Conversation
The exporter config requires full @ID_PATH strings for every USB
resource, which are long and hard to maintain. Add a 'hubs' section
to the exporter config that defines USB hubs by name, base path,
and a mapping of logical port numbers to USB path suffixes.
Resources can then use 'hub' and 'port' in their match dict instead
of a raw @ID_PATH string.
For example, instead of:
board1:
USBSerialPort:
match:
'@ID_PATH': 'pci-0000:04:00.0-usb-0:2.2.3'
the config can be written as:
hubs:
a:
base: 'pci-0000:04:00.0-usb-0:2'
ports:
7: '2.3'
board1:
USBSerialPort:
match:
hub: a
port: 7
The expansion happens at config load time before any resource
matching, so it works with any USB resource type.
Signed-off-by: Simon Glass <sjg@chromium.org>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1854 +/- ##
========================================
+ Coverage 45.8% 47.3% +1.5%
========================================
Files 182 182
Lines 14718 14756 +38
========================================
+ Hits 6743 6991 +248
+ Misses 7975 7765 -210
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
We already provide jinja2 templating in the exporter configuration, so a lot of USB resources can be added at once: I'd rather properly document this than adding a special case for group parsing. |
Thanks for looking at this! I did look at the templating. It is very powerful but also a bit fiddly for hubs. My proposal is to build in hubs as first-class citizens. Here is an example, showing how this approach is very easy to follow. It is also self-documenting. The important distinction is that I can look at the board, immediately see which hub has the USB, if it needs a replug, etc. |
The exporter config requires full @ID_PATH strings for every USB resource, which are long and hard to maintain, particular for labs with multiple hubs.
This PR adds a 'hubs' section to the exporter config that defines USB hubs by name, base path, and a mapping of logical port numbers to USB path suffixes. Resources can then use 'hub' and 'port' in their match dict instead of a raw @ID_PATH string.
For example, instead of:
the config can be written as:
The expansion happens at config load time before any resource matching, so it works with any USB resource type.
This feature is used to help diagnose problems - e.g. if a device's UART stops working, which USB port do I need to replug? It saves a lot of confusion mapping a string of numbers to a physical port.
This feature has been manually verified on my lab (about 30 boards) with 7 16-port hubs connected to a single machine. Operation appears to be the same before and after the change. I think modified the lab to actually use this feature and checked that things still work.
Checklist
If you add a feature other drivers/resources can benefit from: