Skip to content

Commit

Permalink
Address issue with rte_eth_devices in a different way
Browse files Browse the repository at this point in the history
  • Loading branch information
gab-arrobo committed Mar 5, 2024
1 parent ed42124 commit af34576
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/drivers/pmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,15 @@ void PMDPort::InitDriver() {
// returns > 0 on error.
static CommandResponse find_dpdk_port_by_id(dpdk_port_t port_id,
dpdk_port_t *ret_port_id) {
uint16_t user_id = RTE_ETH_DEV_NO_OWNER;
port_id = rte_eth_find_next_owned_by(port_id, user_id);

if (port_id == RTE_MAX_ETHPORTS) {
if (port_id >= RTE_MAX_ETHPORTS) {
return CommandFailure(EINVAL, "Invalid port id %d", port_id);
}
if (!rte_eth_dev_is_valid_port(port_id)) {
return CommandFailure(ENODEV, "Port id %d is not available", port_id);
}
if (rte_eth_dev_socket_id(port_id) < 0) {
return CommandFailure(ENODEV, "Port id %d is not attached", port_id);
}

*ret_port_id = port_id;
return CommandSuccess();
Expand Down

0 comments on commit af34576

Please sign in to comment.