diff --git a/pkg/pci/address/address.go b/pkg/pci/address/address.go index 65e8cca..660238c 100644 --- a/pkg/pci/address/address.go +++ b/pkg/pci/address/address.go @@ -13,7 +13,7 @@ import ( var ( regexAddress *regexp.Regexp = regexp.MustCompile( - `^(([0-9a-f]{0,8}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`, + `^((1?[0-9a-f]{0,4}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`, ) ) @@ -32,7 +32,7 @@ func (addr *Address) String() string { // FromString returns [Address] from an address string in either // $BUS:$DEVICE.$FUNCTION (BDF) format or a full PCI address that -// includes the $DOMAIN: $DOMAIN:$BUS:$DEVICE.$FUNCTION. +// includes the domain: $DOMAIN:$BUS:$DEVICE.$FUNCTION. // // If the address string isn't a valid PCI address, then nil is returned. func FromString(address string) *Address { diff --git a/pkg/pci/address/address_test.go b/pkg/pci/address/address_test.go index daf0eaa..54c873e 100644 --- a/pkg/pci/address/address_test.go +++ b/pkg/pci/address/address_test.go @@ -62,6 +62,16 @@ func TestPCIAddressFromString(t *testing.T) { Function: "a", }, }, + { + // PCI-X / PCI Express extensions may use 5-digit domain + addrStr: "10000:03:00.A", + expected: &pciaddr.Address{ + Domain: "10000", + Bus: "03", + Device: "00", + Function: "a", + }, + }, } for x, test := range tests { got := pciaddr.FromString(test.addrStr)