diff mbox

[U-Boot,07/14] net: core: Inform the user of the device MAC address

Message ID 20161125153032.14617-8-oliver@schinagl.nl
State Superseded
Delegated to: Joe Hershberger
Headers show

Commit Message

Olliver Schinagl Nov. 25, 2016, 3:30 p.m. UTC
In certain conditions we currently print the MAC address. For example a
warning when a random mac address is in use or a missmatch between HW
and ENV.

If all things went well however (but even if there is a miss-match) we
do not inform the user what the final MAC address of the device is.

Lets print the final MAC address of the device with which it has been
setup.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
 net/eth-uclass.c | 9 ++++++---
 net/eth_legacy.c | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Joe Hershberger Nov. 30, 2016, 7:29 p.m. UTC | #1
On Fri, Nov 25, 2016 at 9:30 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
> In certain conditions we currently print the MAC address. For example a
> warning when a random mac address is in use or a missmatch between HW
> and ENV.
>
> If all things went well however (but even if there is a miss-match) we
> do not inform the user what the final MAC address of the device is.
>
> Lets print the final MAC address of the device with which it has been
> setup.
>
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> ---
>  net/eth-uclass.c | 9 ++++++---
>  net/eth_legacy.c | 3 +++
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> index aca3f6d..5c888b8 100644
> --- a/net/eth-uclass.c
> +++ b/net/eth-uclass.c
> @@ -413,11 +413,12 @@ int eth_initialize(void)
>                 }
>
>                 bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
> +               putc('\n');
>                 do {
> -                       if (num_devices)
> -                               printf(", ");
> +                       struct eth_pdata *pdata = dev->platdata;
>
> -                       printf("eth%d: %s", dev->seq, dev->name);
> +                       printf("eth%d:  %s [%pM]\n", dev->seq, dev->name,
> +                                                    pdata->enetaddr);
>
>                         if (ethprime && dev == prime_dev)
>                                 printf(" [PRIME]");
> @@ -522,6 +523,8 @@ static int eth_post_probe(struct udevice *dev)
>  #endif
>         }
>
> +       printf("%s ", dev->name);
> +

Why this?

Can you send to the list what an example output looks like?

Thanks,
-Joe

>         return 0;
>  }
>
> diff --git a/net/eth_legacy.c b/net/eth_legacy.c
> index 2b2c2de..bf4de37 100644
> --- a/net/eth_legacy.c
> +++ b/net/eth_legacy.c
> @@ -178,6 +178,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>                                dev->name);
>         }
>
> +       printf("%s (eth%d) has MAC address: %pM\n",
> +              dev->name, eth_number, dev->enetaddr);
> +
>         return ret;
>  }
>
> --
> 2.10.2
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Olliver Schinagl Dec. 2, 2016, 10:08 a.m. UTC | #2
Hey Joe,


On 30-11-16 20:29, Joe Hershberger wrote:
> On Fri, Nov 25, 2016 at 9:30 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
>> In certain conditions we currently print the MAC address. For example a
>> warning when a random mac address is in use or a missmatch between HW
>> and ENV.
>>
>> If all things went well however (but even if there is a miss-match) we
>> do not inform the user what the final MAC address of the device is.
>>
>> Lets print the final MAC address of the device with which it has been
>> setup.
>>
>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>> ---
>>   net/eth-uclass.c | 9 ++++++---
>>   net/eth_legacy.c | 3 +++
>>   2 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>> index aca3f6d..5c888b8 100644
>> --- a/net/eth-uclass.c
>> +++ b/net/eth-uclass.c
>> @@ -413,11 +413,12 @@ int eth_initialize(void)
>>                  }
>>
>>                  bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
>> +               putc('\n');
>>                  do {
>> -                       if (num_devices)
>> -                               printf(", ");
>> +                       struct eth_pdata *pdata = dev->platdata;
>>
>> -                       printf("eth%d: %s", dev->seq, dev->name);
>> +                       printf("eth%d:  %s [%pM]\n", dev->seq, dev->name,
>> +                                                    pdata->enetaddr);
>>
>>                          if (ethprime && dev == prime_dev)
>>                                  printf(" [PRIME]");
>> @@ -522,6 +523,8 @@ static int eth_post_probe(struct udevice *dev)
>>   #endif
>>          }
>>
>> +       printf("%s ", dev->name);
>> +
> Why this?
>
> Can you send to the list what an example output looks like?

Absolutly. Right now I have this, with the v2 work I'm doing to print 
the mac source.

Net:   ethernet@01c50000 <other etnernet devices>
eth0:  ethernet@01c50000 [cc:bd:d3:00:01:c6] (EEPROM)
eth1: <other_ethernet_device1> [<other_mac>] (<other_source>)


If there is an error or warning from the net layer (during probe, during 
init etc)
we get something like

Net:   CRC error on MAC address from EEPROM on device: ethernet@01c50000 
<other warning> on device: <other_device>
eth0:  ethernet@01c50000 [02:4b:04:42:12:31] (driver)

(where driver is the read_rom_hwaddr hook a driver supplies).

I did not go over all error messages to print it as pretty. So in that 
case it will be
Net:   Some error. ethernet@01c50000

Olliver
>
> Thanks,
> -Joe
>
>>          return 0;
>>   }
>>
>> diff --git a/net/eth_legacy.c b/net/eth_legacy.c
>> index 2b2c2de..bf4de37 100644
>> --- a/net/eth_legacy.c
>> +++ b/net/eth_legacy.c
>> @@ -178,6 +178,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>>                                 dev->name);
>>          }
>>
>> +       printf("%s (eth%d) has MAC address: %pM\n",
>> +              dev->name, eth_number, dev->enetaddr);
>> +
>>          return ret;
>>   }
>>
>> --
>> 2.10.2
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
Joe Hershberger Feb. 2, 2017, 5:52 p.m. UTC | #3
Hi Olliver,

On Fri, Dec 2, 2016 at 4:08 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
> Hey Joe,
>
>
>
> On 30-11-16 20:29, Joe Hershberger wrote:
>>
>> On Fri, Nov 25, 2016 at 9:30 AM, Olliver Schinagl <oliver@schinagl.nl>
>> wrote:
>>>
>>> In certain conditions we currently print the MAC address. For example a
>>> warning when a random mac address is in use or a missmatch between HW
>>> and ENV.
>>>
>>> If all things went well however (but even if there is a miss-match) we
>>> do not inform the user what the final MAC address of the device is.
>>>
>>> Lets print the final MAC address of the device with which it has been
>>> setup.
>>>
>>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>>> ---
>>>   net/eth-uclass.c | 9 ++++++---
>>>   net/eth_legacy.c | 3 +++
>>>   2 files changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>>> index aca3f6d..5c888b8 100644
>>> --- a/net/eth-uclass.c
>>> +++ b/net/eth-uclass.c
>>> @@ -413,11 +413,12 @@ int eth_initialize(void)
>>>                  }
>>>
>>>                  bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
>>> +               putc('\n');
>>>                  do {
>>> -                       if (num_devices)
>>> -                               printf(", ");
>>> +                       struct eth_pdata *pdata = dev->platdata;
>>>
>>> -                       printf("eth%d: %s", dev->seq, dev->name);
>>> +                       printf("eth%d:  %s [%pM]\n", dev->seq, dev->name,
>>> +                                                    pdata->enetaddr);
>>>
>>>                          if (ethprime && dev == prime_dev)
>>>                                  printf(" [PRIME]");
>>> @@ -522,6 +523,8 @@ static int eth_post_probe(struct udevice *dev)
>>>   #endif
>>>          }
>>>
>>> +       printf("%s ", dev->name);
>>> +
>>
>> Why this?
>>
>> Can you send to the list what an example output looks like?
>
>
> Absolutly. Right now I have this, with the v2 work I'm doing to print the
> mac source.

Was there a v2?

> Net:   ethernet@01c50000 <other etnernet devices>
> eth0:  ethernet@01c50000 [cc:bd:d3:00:01:c6] (EEPROM)
> eth1: <other_ethernet_device1> [<other_mac>] (<other_source>)
>
>
> If there is an error or warning from the net layer (during probe, during
> init etc)
> we get something like
>
> Net:   CRC error on MAC address from EEPROM on device: ethernet@01c50000
> <other warning> on device: <other_device>
> eth0:  ethernet@01c50000 [02:4b:04:42:12:31] (driver)
>
> (where driver is the read_rom_hwaddr hook a driver supplies).
>
> I did not go over all error messages to print it as pretty. So in that case
> it will be
> Net:   Some error. ethernet@01c50000
>
> Olliver
>
>>
>> Thanks,
>> -Joe
>>
>>>          return 0;
>>>   }
>>>
>>> diff --git a/net/eth_legacy.c b/net/eth_legacy.c
>>> index 2b2c2de..bf4de37 100644
>>> --- a/net/eth_legacy.c
>>> +++ b/net/eth_legacy.c
>>> @@ -178,6 +178,9 @@ int eth_write_hwaddr(struct eth_device *dev, const
>>> char *base_name,
>>>                                 dev->name);
>>>          }
>>>
>>> +       printf("%s (eth%d) has MAC address: %pM\n",
>>> +              dev->name, eth_number, dev->enetaddr);
>>> +
>>>          return ret;
>>>   }
>>>
>>> --
>>> 2.10.2
>>>
>>> _______________________________________________
>>> U-Boot mailing list
>>> U-Boot@lists.denx.de
>>> http://lists.denx.de/mailman/listinfo/u-boot
>
>
Olliver Schinagl Feb. 20, 2017, 3:27 p.m. UTC | #4
Hey Joe,

On 02-02-17 18:52, Joe Hershberger wrote:
> Hi Olliver,
>
> On Fri, Dec 2, 2016 at 4:08 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
>> Hey Joe,
>>
>>
>>
>> On 30-11-16 20:29, Joe Hershberger wrote:
>>>
>>> On Fri, Nov 25, 2016 at 9:30 AM, Olliver Schinagl <oliver@schinagl.nl>
>>> wrote:
>>>>
>>>> In certain conditions we currently print the MAC address. For example a
>>>> warning when a random mac address is in use or a missmatch between HW
>>>> and ENV.
>>>>
>>>> If all things went well however (but even if there is a miss-match) we
>>>> do not inform the user what the final MAC address of the device is.
>>>>
>>>> Lets print the final MAC address of the device with which it has been
>>>> setup.
>>>>
>>>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>>>> ---
>>>>   net/eth-uclass.c | 9 ++++++---
>>>>   net/eth_legacy.c | 3 +++
>>>>   2 files changed, 9 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>>>> index aca3f6d..5c888b8 100644
>>>> --- a/net/eth-uclass.c
>>>> +++ b/net/eth-uclass.c
>>>> @@ -413,11 +413,12 @@ int eth_initialize(void)
>>>>                  }
>>>>
>>>>                  bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
>>>> +               putc('\n');
>>>>                  do {
>>>> -                       if (num_devices)
>>>> -                               printf(", ");
>>>> +                       struct eth_pdata *pdata = dev->platdata;
>>>>
>>>> -                       printf("eth%d: %s", dev->seq, dev->name);
>>>> +                       printf("eth%d:  %s [%pM]\n", dev->seq, dev->name,
>>>> +                                                    pdata->enetaddr);
>>>>
>>>>                          if (ethprime && dev == prime_dev)
>>>>                                  printf(" [PRIME]");
>>>> @@ -522,6 +523,8 @@ static int eth_post_probe(struct udevice *dev)
>>>>   #endif
>>>>          }
>>>>
>>>> +       printf("%s ", dev->name);
>>>> +
>>>
>>> Why this?
>>>
>>> Can you send to the list what an example output looks like?
>>
>>
>> Absolutly. Right now I have this, with the v2 work I'm doing to print the
>> mac source.
>
> Was there a v2?
I think so, I will go over my mailbox and my local commits to double 
check and send the v2 (or v3) if I missed it.
>
>> Net:   ethernet@01c50000 <other etnernet devices>
>> eth0:  ethernet@01c50000 [cc:bd:d3:00:01:c6] (EEPROM)
>> eth1: <other_ethernet_device1> [<other_mac>] (<other_source>)
>>
>>
>> If there is an error or warning from the net layer (during probe, during
>> init etc)
>> we get something like
>>
>> Net:   CRC error on MAC address from EEPROM on device: ethernet@01c50000
>> <other warning> on device: <other_device>
>> eth0:  ethernet@01c50000 [02:4b:04:42:12:31] (driver)
>>
>> (where driver is the read_rom_hwaddr hook a driver supplies).
>>
>> I did not go over all error messages to print it as pretty. So in that case
>> it will be
>> Net:   Some error. ethernet@01c50000
>>
>> Olliver
>>
>>>
>>> Thanks,
>>> -Joe
>>>
>>>>          return 0;
>>>>   }
>>>>
>>>> diff --git a/net/eth_legacy.c b/net/eth_legacy.c
>>>> index 2b2c2de..bf4de37 100644
>>>> --- a/net/eth_legacy.c
>>>> +++ b/net/eth_legacy.c
>>>> @@ -178,6 +178,9 @@ int eth_write_hwaddr(struct eth_device *dev, const
>>>> char *base_name,
>>>>                                 dev->name);
>>>>          }
>>>>
>>>> +       printf("%s (eth%d) has MAC address: %pM\n",
>>>> +              dev->name, eth_number, dev->enetaddr);
>>>> +
>>>>          return ret;
>>>>   }
>>>>
>>>> --
>>>> 2.10.2
>>>>
>>>> _______________________________________________
>>>> U-Boot mailing list
>>>> U-Boot@lists.denx.de
>>>> http://lists.denx.de/mailman/listinfo/u-boot
>>
>>
diff mbox

Patch

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index aca3f6d..5c888b8 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -413,11 +413,12 @@  int eth_initialize(void)
 		}
 
 		bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
+		putc('\n');
 		do {
-			if (num_devices)
-				printf(", ");
+			struct eth_pdata *pdata = dev->platdata;
 
-			printf("eth%d: %s", dev->seq, dev->name);
+			printf("eth%d:  %s [%pM]\n", dev->seq, dev->name,
+						     pdata->enetaddr);
 
 			if (ethprime && dev == prime_dev)
 				printf(" [PRIME]");
@@ -522,6 +523,8 @@  static int eth_post_probe(struct udevice *dev)
 #endif
 	}
 
+	printf("%s ", dev->name);
+
 	return 0;
 }
 
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 2b2c2de..bf4de37 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -178,6 +178,9 @@  int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 			       dev->name);
 	}
 
+	printf("%s (eth%d) has MAC address: %pM\n",
+	       dev->name, eth_number, dev->enetaddr);
+
 	return ret;
 }