|
@@ -87,7 +87,7 @@ static struct {
|
|
int length;
|
|
int length;
|
|
} eth_rcv_bufs[PKTBUFSRX];
|
|
} eth_rcv_bufs[PKTBUFSRX];
|
|
|
|
|
|
-static unsigned int eth_rcv_current = 0, eth_rcv_last = 0;
|
|
|
|
|
|
+static unsigned int eth_rcv_current, eth_rcv_last;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
static struct eth_device *eth_devices, *eth_current;
|
|
static struct eth_device *eth_devices, *eth_current;
|
|
@@ -139,11 +139,10 @@ struct eth_device *eth_get_dev_by_index(int index)
|
|
return target_dev;
|
|
return target_dev;
|
|
}
|
|
}
|
|
|
|
|
|
-int eth_get_dev_index (void)
|
|
|
|
|
|
+int eth_get_dev_index(void)
|
|
{
|
|
{
|
|
- if (!eth_current) {
|
|
|
|
|
|
+ if (!eth_current)
|
|
return -1;
|
|
return -1;
|
|
- }
|
|
|
|
|
|
|
|
return eth_current->index;
|
|
return eth_current->index;
|
|
}
|
|
}
|
|
@@ -174,7 +173,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
|
|
|
|
|
|
if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
|
|
if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
|
|
if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
|
|
if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
|
|
- memcmp(dev->enetaddr, env_enetaddr, 6)) {
|
|
|
|
|
|
+ memcmp(dev->enetaddr, env_enetaddr, 6)) {
|
|
printf("\nWarning: %s MAC addresses don't match:\n",
|
|
printf("\nWarning: %s MAC addresses don't match:\n",
|
|
dev->name);
|
|
dev->name);
|
|
printf("Address in SROM is %pM\n",
|
|
printf("Address in SROM is %pM\n",
|
|
@@ -187,10 +186,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
|
|
}
|
|
}
|
|
|
|
|
|
if (dev->write_hwaddr &&
|
|
if (dev->write_hwaddr &&
|
|
- !eth_mac_skip(eth_number) &&
|
|
|
|
- is_valid_ether_addr(dev->enetaddr)) {
|
|
|
|
|
|
+ !eth_mac_skip(eth_number) &&
|
|
|
|
+ is_valid_ether_addr(dev->enetaddr))
|
|
ret = dev->write_hwaddr(dev);
|
|
ret = dev->write_hwaddr(dev);
|
|
- }
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -198,7 +196,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
|
|
int eth_register(struct eth_device *dev)
|
|
int eth_register(struct eth_device *dev)
|
|
{
|
|
{
|
|
struct eth_device *d;
|
|
struct eth_device *d;
|
|
- static int index = 0;
|
|
|
|
|
|
+ static int index;
|
|
|
|
|
|
assert(strlen(dev->name) < sizeof(dev->name));
|
|
assert(strlen(dev->name) < sizeof(dev->name));
|
|
|
|
|
|
@@ -206,7 +204,7 @@ int eth_register(struct eth_device *dev)
|
|
eth_current = eth_devices = dev;
|
|
eth_current = eth_devices = dev;
|
|
eth_current_changed();
|
|
eth_current_changed();
|
|
} else {
|
|
} else {
|
|
- for (d=eth_devices; d->next!=eth_devices; d=d->next)
|
|
|
|
|
|
+ for (d = eth_devices; d->next != eth_devices; d = d->next)
|
|
;
|
|
;
|
|
d->next = dev;
|
|
d->next = dev;
|
|
}
|
|
}
|
|
@@ -276,36 +274,37 @@ int eth_initialize(bd_t *bis)
|
|
printf("Net Initialization Skipped\n");
|
|
printf("Net Initialization Skipped\n");
|
|
|
|
|
|
if (!eth_devices) {
|
|
if (!eth_devices) {
|
|
- puts ("No ethernet found.\n");
|
|
|
|
|
|
+ puts("No ethernet found.\n");
|
|
bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
|
|
bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
|
|
} else {
|
|
} else {
|
|
struct eth_device *dev = eth_devices;
|
|
struct eth_device *dev = eth_devices;
|
|
- char *ethprime = getenv ("ethprime");
|
|
|
|
|
|
+ char *ethprime = getenv("ethprime");
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
|
|
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
|
|
do {
|
|
do {
|
|
if (dev->index)
|
|
if (dev->index)
|
|
- puts (", ");
|
|
|
|
|
|
+ puts(", ");
|
|
|
|
|
|
printf("%s", dev->name);
|
|
printf("%s", dev->name);
|
|
|
|
|
|
- if (ethprime && strcmp (dev->name, ethprime) == 0) {
|
|
|
|
|
|
+ if (ethprime && strcmp(dev->name, ethprime) == 0) {
|
|
eth_current = dev;
|
|
eth_current = dev;
|
|
- puts (" [PRIME]");
|
|
|
|
|
|
+ puts(" [PRIME]");
|
|
}
|
|
}
|
|
|
|
|
|
if (strchr(dev->name, ' '))
|
|
if (strchr(dev->name, ' '))
|
|
- puts("\nWarning: eth device name has a space!\n");
|
|
|
|
|
|
+ puts("\nWarning: eth device name has a space!"
|
|
|
|
+ "\n");
|
|
|
|
|
|
if (eth_write_hwaddr(dev, "eth", dev->index))
|
|
if (eth_write_hwaddr(dev, "eth", dev->index))
|
|
puts("\nWarning: failed to set MAC address\n");
|
|
puts("\nWarning: failed to set MAC address\n");
|
|
|
|
|
|
dev = dev->next;
|
|
dev = dev->next;
|
|
num_devices++;
|
|
num_devices++;
|
|
- } while(dev != eth_devices);
|
|
|
|
|
|
+ } while (dev != eth_devices);
|
|
|
|
|
|
eth_current_changed();
|
|
eth_current_changed();
|
|
- putc ('\n');
|
|
|
|
|
|
+ putc('\n');
|
|
}
|
|
}
|
|
|
|
|
|
return num_devices;
|
|
return num_devices;
|
|
@@ -316,9 +315,9 @@ int eth_initialize(bd_t *bis)
|
|
* mcast_addr: multicast ipaddr from which multicast Mac is made
|
|
* mcast_addr: multicast ipaddr from which multicast Mac is made
|
|
* join: 1=join, 0=leave.
|
|
* join: 1=join, 0=leave.
|
|
*/
|
|
*/
|
|
-int eth_mcast_join( IPaddr_t mcast_ip, u8 join)
|
|
|
|
|
|
+int eth_mcast_join(IPaddr_t mcast_ip, u8 join)
|
|
{
|
|
{
|
|
- u8 mcast_mac[6];
|
|
|
|
|
|
+ u8 mcast_mac[6];
|
|
if (!eth_current || !eth_current->mcast)
|
|
if (!eth_current || !eth_current->mcast)
|
|
return -1;
|
|
return -1;
|
|
mcast_mac[5] = htonl(mcast_ip) & 0xff;
|
|
mcast_mac[5] = htonl(mcast_ip) & 0xff;
|
|
@@ -335,7 +334,7 @@ int eth_mcast_join( IPaddr_t mcast_ip, u8 join)
|
|
* some other adapter -- hash tables
|
|
* some other adapter -- hash tables
|
|
*/
|
|
*/
|
|
#define CRCPOLY_LE 0xedb88320
|
|
#define CRCPOLY_LE 0xedb88320
|
|
-u32 ether_crc (size_t len, unsigned char const *p)
|
|
|
|
|
|
+u32 ether_crc(size_t len, unsigned char const *p)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
u32 crc;
|
|
u32 crc;
|
|
@@ -362,7 +361,7 @@ int eth_init(bd_t *bis)
|
|
struct eth_device *old_current, *dev;
|
|
struct eth_device *old_current, *dev;
|
|
|
|
|
|
if (!eth_current) {
|
|
if (!eth_current) {
|
|
- puts ("No ethernet found.\n");
|
|
|
|
|
|
+ puts("No ethernet found.\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -382,7 +381,7 @@ int eth_init(bd_t *bis)
|
|
do {
|
|
do {
|
|
debug("Trying %s\n", eth_current->name);
|
|
debug("Trying %s\n", eth_current->name);
|
|
|
|
|
|
- if (eth_current->init(eth_current,bis) >= 0) {
|
|
|
|
|
|
+ if (eth_current->init(eth_current, bis) >= 0) {
|
|
eth_current->state = ETH_STATE_ACTIVE;
|
|
eth_current->state = ETH_STATE_ACTIVE;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -470,38 +469,36 @@ int eth_receive(void *packet, int length)
|
|
|
|
|
|
void eth_try_another(int first_restart)
|
|
void eth_try_another(int first_restart)
|
|
{
|
|
{
|
|
- static struct eth_device *first_failed = NULL;
|
|
|
|
|
|
+ static struct eth_device *first_failed;
|
|
char *ethrotate;
|
|
char *ethrotate;
|
|
|
|
|
|
/*
|
|
/*
|
|
* Do not rotate between network interfaces when
|
|
* Do not rotate between network interfaces when
|
|
* 'ethrotate' variable is set to 'no'.
|
|
* 'ethrotate' variable is set to 'no'.
|
|
*/
|
|
*/
|
|
- if (((ethrotate = getenv ("ethrotate")) != NULL) &&
|
|
|
|
- (strcmp(ethrotate, "no") == 0))
|
|
|
|
|
|
+ ethrotate = getenv("ethrotate");
|
|
|
|
+ if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
|
|
return;
|
|
return;
|
|
|
|
|
|
if (!eth_current)
|
|
if (!eth_current)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (first_restart) {
|
|
|
|
|
|
+ if (first_restart)
|
|
first_failed = eth_current;
|
|
first_failed = eth_current;
|
|
- }
|
|
|
|
|
|
|
|
eth_current = eth_current->next;
|
|
eth_current = eth_current->next;
|
|
|
|
|
|
eth_current_changed();
|
|
eth_current_changed();
|
|
|
|
|
|
- if (first_failed == eth_current) {
|
|
|
|
|
|
+ if (first_failed == eth_current)
|
|
NetRestartWrap = 1;
|
|
NetRestartWrap = 1;
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void eth_set_current(void)
|
|
void eth_set_current(void)
|
|
{
|
|
{
|
|
- static char *act = NULL;
|
|
|
|
- static int env_changed_id = 0;
|
|
|
|
- struct eth_device* old_current;
|
|
|
|
|
|
+ static char *act;
|
|
|
|
+ static int env_changed_id;
|
|
|
|
+ struct eth_device *old_current;
|
|
int env_id;
|
|
int env_id;
|
|
|
|
|
|
if (!eth_current) /* XXX no current */
|
|
if (!eth_current) /* XXX no current */
|
|
@@ -524,7 +521,7 @@ void eth_set_current(void)
|
|
eth_current_changed();
|
|
eth_current_changed();
|
|
}
|
|
}
|
|
|
|
|
|
-char *eth_get_name (void)
|
|
|
|
|
|
+char *eth_get_name(void)
|
|
{
|
|
{
|
|
- return (eth_current ? eth_current->name : "unknown");
|
|
|
|
|
|
+ return eth_current ? eth_current->name : "unknown";
|
|
}
|
|
}
|