exporter: Add USB hub abstraction for simpler device matching#1854
Open
sjg20 wants to merge 1 commit intolabgrid-project:masterfrom
Open
exporter: Add USB hub abstraction for simpler device matching#1854sjg20 wants to merge 1 commit intolabgrid-project:masterfrom
sjg20 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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: