struct sub_device *sdev;
struct rte_devargs *da;
uint8_t i;
+ uint16_t j;
int ret;
FOREACH_SUBDEV(sdev, i, dev) {
rte_errno ? ")" : "");
continue;
}
- ETH(sdev) = rte_eth_dev_allocated(da->name);
+ RTE_ETH_FOREACH_DEV(j) {
+ if (strcmp(rte_eth_devices[j].device->name,
+ da->name) == 0) {
+ ETH(sdev) = &rte_eth_devices[j];
+ break;
+ }
+ }
if (ETH(sdev) == NULL) {
ERROR("sub_device %d init went wrong", i);
return -ENODEV;
}
+ SUB_ID(sdev) = i;
+ sdev->fs_dev = dev;
sdev->dev = ETH(sdev)->device;
ETH(sdev)->state = RTE_ETH_DEV_DEFERRED;
sdev->state = DEV_PROBED;
int
failsafe_eal_init(struct rte_eth_dev *dev)
{
- struct sub_device *sdev;
- uint8_t i;
int ret;
ret = fs_bus_init(dev);
if (ret)
return ret;
- /*
- * We only update TX_SUBDEV if we are not started.
- * If a sub_device is emitting, we will switch the TX_SUBDEV to the
- * preferred port only upon starting it, so that the switch is smoother.
- */
- if (PREFERRED_SUBDEV(dev)->state >= DEV_PROBED) {
- if (TX_SUBDEV(dev) != PREFERRED_SUBDEV(dev) &&
- (TX_SUBDEV(dev) == NULL ||
- (TX_SUBDEV(dev) && TX_SUBDEV(dev)->state < DEV_STARTED))) {
- DEBUG("Switching tx_dev to preferred sub_device");
- PRIV(dev)->subs_tx = 0;
- }
- } else {
- if ((TX_SUBDEV(dev) && TX_SUBDEV(dev)->state < DEV_PROBED) ||
- TX_SUBDEV(dev) == NULL) {
- /* Using first probed device */
- FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
- DEBUG("Switching tx_dev to sub_device %d",
- i);
- PRIV(dev)->subs_tx = i;
- break;
- }
- }
- }
+ if (PRIV(dev)->state < DEV_PROBED)
+ PRIV(dev)->state = DEV_PROBED;
+ fs_switch_dev(dev, NULL);
return 0;
}
{
struct sub_device *sdev = NULL;
uint8_t i;
- int ret;
+ int sdev_ret;
+ int ret = 0;
FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
- ret = rte_eal_hotplug_remove(sdev->bus->name,
- sdev->dev->name);
- if (ret) {
- ERROR("Failed to remove requested device %s",
- sdev->dev->name);
+ sdev_ret = rte_eal_hotplug_remove(sdev->bus->name,
+ sdev->dev->name);
+ if (sdev_ret) {
+ ERROR("Failed to remove requested device %s (err: %d)",
+ sdev->dev->name, sdev_ret);
continue;
}
sdev->state = DEV_PROBED - 1;
}
- return 0;
+ return ret;
}
int
int ret;
ret = fs_bus_uninit(dev);
- if (ret)
- return ret;
- return 0;
+ PRIV(dev)->state = DEV_PROBED - 1;
+ return ret;
}