MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pci_dbdf_parse

Function pci_dbdf_parse

dpdk/lib/pci/rte_pci.c:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static int
61pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr)
62{
63 const char *in = input;
64 unsigned long val;
65 char *end;
66
67 /* PCI id starting with spaces is forbidden.
68 * Negative wrap-around is not reported as an error by strtoul.
69 */
70 if (*in == ' ' || *in == '-')
71 return -EINVAL;
72
73 errno = 0;
74 val = strtoul(in, &end, 16);
75 /* Empty string is not an error for strtoul, but the check
76 * end[0] != ':'
77 * will detect the issue.
78 */
79 if (errno != 0 || end[0] != ':' || val > UINT32_MAX)
80 return -EINVAL;
81 dev_addr->domain = (uint32_t)val;
82 in = end + 1;
83 in = get_u8_pciaddr_field(in, &dev_addr->bus, ':');
84 if (in == NULL)
85 return -EINVAL;
86 in = get_u8_pciaddr_field(in, &dev_addr->devid, '.');
87 if (in == NULL)
88 return -EINVAL;
89 in = get_u8_pciaddr_field(in, &dev_addr->function, '\0');
90 if (in == NULL)
91 return -EINVAL;
92 return 0;
93}
94
95void
96rte_pci_device_name(const struct rte_pci_addr *addr,

Callers 1

rte_pci_addr_parseFunction · 0.85

Calls 2

strtoulFunction · 0.85
get_u8_pciaddr_fieldFunction · 0.85

Tested by

no test coverage detected