int eth_init(bd_t *bis) { struct eth_device* old_current; if (!eth_current) return 0; old_current = eth_current; do { debug ("Trying %s\n", eth_current->name); if (eth_current->init(eth_current, bis)) { eth_current->state = ETH_STATE_ACTIVE; printf("\n ETH_STATE_ACTIVE!! \n"); return 1; } printf ("FAIL\n"); //kaiker return (-1); eth_try_another(0); } while (old_current != eth_current); return 0; }
int eth_init(bd_t *bis){ struct eth_device* old_current; if (!eth_current){ return(0); } old_current = eth_current; do { #if !defined(CFG_ATHRS26_PHY) && !defined(CFG_ATHRHDR_EN) //debug("Trying %s\n", eth_current->name); #endif if(eth_current->init(eth_current, bis)){ eth_current->state = ETH_STATE_ACTIVE; return(1); } //debug("FAIL\n"); eth_try_another(0); } while(old_current != eth_current); return(0); }
int net_start_again(void) { char *nretry; int retry_forever = 0; unsigned long retrycnt = 0; int ret; nretry = getenv("netretry"); if (nretry) { if (!strcmp(nretry, "yes")) retry_forever = 1; else if (!strcmp(nretry, "no")) retrycnt = 0; else if (!strcmp(nretry, "once")) retrycnt = 1; else retrycnt = simple_strtoul(nretry, NULL, 0); } else { retrycnt = 0; retry_forever = 0; } if ((!retry_forever) && (net_try_count >= retrycnt)) { eth_halt(); net_set_state(NETLOOP_FAIL); /* * We don't provide a way for the protocol to return an error, * but this is almost always the reason. */ return -ETIMEDOUT; } net_try_count++; eth_halt(); #if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) eth_try_another(!net_restarted); #endif ret = eth_init(); if (net_restart_wrap) { net_restart_wrap = 0; if (net_dev_exists) { net_set_timeout_handler(10000UL, start_again_timeout_handler); net_set_udp_handler(NULL); } else { net_set_state(NETLOOP_FAIL); } } else { net_set_state(NETLOOP_RESTART); } return ret; }
void NetStartAgain(void) { char *nretry; int retry_forever = 0; unsigned long retrycnt = 0; nretry = getenv("netretry"); if (nretry) { if (!strcmp(nretry, "yes")) retry_forever = 1; else if (!strcmp(nretry, "no")) retrycnt = 0; else if (!strcmp(nretry, "once")) retrycnt = 1; else retrycnt = simple_strtoul(nretry, NULL, 0); } else retry_forever = 1; if ((!retry_forever) && (NetTryCount >= retrycnt)) { eth_halt(); net_set_state(NETLOOP_FAIL); return; } NetTryCount++; eth_halt(); #if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) eth_try_another(!NetRestarted); #endif eth_init(gd->bd); if (NetRestartWrap) { NetRestartWrap = 0; if (NetDevExists) { NetSetTimeout(10000UL, startAgainTimeout); net_set_udp_handler(NULL); } else { net_set_state(NETLOOP_FAIL); } } else { net_set_state(NETLOOP_RESTART); } }
int eth_init(void) { char *ethact = getenv("ethact"); char *ethrotate = getenv("ethrotate"); struct udevice *current = NULL; struct udevice *old_current; int ret = -ENODEV; /* * When 'ethrotate' variable is set to 'no' and 'ethact' variable * is already set to an ethernet device, we should stick to 'ethact'. */ if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) { if (ethact) { current = eth_get_dev_by_name(ethact); if (!current) return -EINVAL; } } if (!current) { current = eth_get_dev(); if (!current) { printf("No ethernet found.\n"); return -ENODEV; } } old_current = current; do { if (current) { debug("Trying %s\n", current->name); if (device_active(current)) { ret = eth_get_ops(current)->start(current); if (ret >= 0) { struct eth_device_priv *priv = current->uclass_priv; priv->state = ETH_STATE_ACTIVE; return 0; } } else { ret = eth_errno; } debug("FAIL\n"); } else { debug("PROBE FAIL\n"); } /* * If ethrotate is enabled, this will change "current", * otherwise we will drop out of this while loop immediately */ eth_try_another(0); /* This will ensure the new "current" attempted to probe */ current = eth_get_dev(); } while (old_current != current); return ret; }