* Parses a port identifier string to a port id by pci address, then by name, * and finally port id. */
| 77 | * and finally port id. |
| 78 | */ |
| 79 | static inline int |
| 80 | parse_port_id(const char *port_str) |
| 81 | { |
| 82 | struct rte_pci_addr dev_addr; |
| 83 | int port_id; |
| 84 | |
| 85 | /* try parsing as pci address, physical devices */ |
| 86 | if (rte_pci_addr_parse(port_str, &dev_addr) == 0) { |
| 87 | port_id = find_port_id_by_pci_addr(&dev_addr); |
| 88 | if (port_id < 0) |
| 89 | return -1; |
| 90 | } else { |
| 91 | /* try parsing as device name, virtual devices */ |
| 92 | port_id = find_port_id_by_dev_name(port_str); |
| 93 | if (port_id < 0) { |
| 94 | char *end; |
| 95 | errno = 0; |
| 96 | |
| 97 | /* try parsing as port id */ |
| 98 | port_id = strtol(port_str, &end, 10); |
| 99 | if (*end != 0 || errno != 0) |
| 100 | return -1; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (!rte_eth_dev_is_valid_port(port_id)) { |
| 105 | RTE_BOND_LOG(ERR, "Specified port (%s) is invalid", port_str); |
| 106 | return -1; |
| 107 | } |
| 108 | return port_id; |
| 109 | } |
| 110 | |
| 111 | int |
| 112 | bond_ethdev_parse_member_port_kvarg(const char *key, |
no test coverage detected