All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] efi_loader: completely initialize network
@ 2018-04-03 20:06 Heinrich Schuchardt
  2018-04-04  9:42 ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-04-03 20:06 UTC (permalink / raw)
  To: u-boot

Add missing network initialization code.

Before the patch the network was only usable if a network command like
dhcp or tftp had beed executed.

This was visible when interrupting the console countdown and executing
bootefi selftest for vexpress_ca15_tc2_defconfig.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_net.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index 3d860e658e..9afe76cdb3 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -54,14 +54,46 @@ static efi_status_t EFIAPI efi_net_stop(struct efi_simple_network *this)
 	return EFI_EXIT(EFI_SUCCESS);
 }
 
+/*
+ * Initialize network adapter and allocate transmit and receive buffers.
+ *
+ * This function implements the Initialize service of the
+ * EFI_SIMPLE_NETWORK_PROTOCOL. See the Unified Extensible Firmware Interface
+ * (UEFI) specification for details.
+ *
+ * @this:	pointer to the protocol instance
+ * @extra_rx:	extra receive buffer to be allocated
+ * @extra_tx:	extra transmit buffer to be allocated
+ * @return:	status code
+ */
 static efi_status_t EFIAPI efi_net_initialize(struct efi_simple_network *this,
 					      ulong extra_rx, ulong extra_tx)
 {
+	int ret;
+	efi_status_t r = EFI_SUCCESS;
+
 	EFI_ENTRY("%p, %lx, %lx", this, extra_rx, extra_tx);
 
-	eth_init();
+	if (!this) {
+		r = EFI_INVALID_PARAMETER;
+		goto error;
+	}
 
-	return EFI_EXIT(EFI_SUCCESS);
+	/* Setup packet buffers */
+	net_init();
+	/* Disable hardware and put it into the reset state */
+	eth_halt();
+	/* Set current device according to environment variables */
+	eth_set_current();
+	/* Get hardware ready for send and receive operations */
+	ret = eth_init();
+	if (ret < 0) {
+		eth_halt();
+		r = EFI_DEVICE_ERROR;
+	}
+
+error:
+	return EFI_EXIT(r);
 }
 
 static efi_status_t EFIAPI efi_net_reset(struct efi_simple_network *this,
-- 
2.16.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: completely initialize network
  2018-04-03 20:06 [U-Boot] [PATCH 1/1] efi_loader: completely initialize network Heinrich Schuchardt
@ 2018-04-04  9:42 ` Alexander Graf
  2018-04-04 11:20   ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2018-04-04  9:42 UTC (permalink / raw)
  To: u-boot



On 03.04.18 22:06, Heinrich Schuchardt wrote:
> Add missing network initialization code.
> 
> Before the patch the network was only usable if a network command like
> dhcp or tftp had beed executed.
> 
> This was visible when interrupting the console countdown and executing
> bootefi selftest for vexpress_ca15_tc2_defconfig.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  lib/efi_loader/efi_net.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
> index 3d860e658e..9afe76cdb3 100644
> --- a/lib/efi_loader/efi_net.c
> +++ b/lib/efi_loader/efi_net.c
> @@ -54,14 +54,46 @@ static efi_status_t EFIAPI efi_net_stop(struct efi_simple_network *this)
>  	return EFI_EXIT(EFI_SUCCESS);
>  }
>  
> +/*
> + * Initialize network adapter and allocate transmit and receive buffers.
> + *
> + * This function implements the Initialize service of the
> + * EFI_SIMPLE_NETWORK_PROTOCOL. See the Unified Extensible Firmware Interface
> + * (UEFI) specification for details.
> + *
> + * @this:	pointer to the protocol instance
> + * @extra_rx:	extra receive buffer to be allocated
> + * @extra_tx:	extra transmit buffer to be allocated
> + * @return:	status code
> + */
>  static efi_status_t EFIAPI efi_net_initialize(struct efi_simple_network *this,
>  					      ulong extra_rx, ulong extra_tx)
>  {
> +	int ret;
> +	efi_status_t r = EFI_SUCCESS;
> +
>  	EFI_ENTRY("%p, %lx, %lx", this, extra_rx, extra_tx);
>  
> -	eth_init();
> +	if (!this) {
> +		r = EFI_INVALID_PARAMETER;
> +		goto error;
> +	}
>  
> -	return EFI_EXIT(EFI_SUCCESS);
> +	/* Setup packet buffers */
> +	net_init();
> +	/* Disable hardware and put it into the reset state */
> +	eth_halt();
> +	/* Set current device according to environment variables */
> +	eth_set_current();

Is there any way to do the above dance only when needed? Some network
adapters can take quite a while to initialize and I'd prefer to not go
through that when not absolutely necessary.


Alex

> +	/* Get hardware ready for send and receive operations */
> +	ret = eth_init();
> +	if (ret < 0) {
> +		eth_halt();
> +		r = EFI_DEVICE_ERROR;
> +	}
> +
> +error:
> +	return EFI_EXIT(r);
>  }
>  
>  static efi_status_t EFIAPI efi_net_reset(struct efi_simple_network *this,
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: completely initialize network
  2018-04-04  9:42 ` Alexander Graf
@ 2018-04-04 11:20   ` Heinrich Schuchardt
  0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-04-04 11:20 UTC (permalink / raw)
  To: u-boot

On 04/04/2018 11:42 AM, Alexander Graf wrote:
> 
> 
> On 03.04.18 22:06, Heinrich Schuchardt wrote:
>> Add missing network initialization code.
>>
>> Before the patch the network was only usable if a network command like
>> dhcp or tftp had beed executed.
>>
>> This was visible when interrupting the console countdown and executing
>> bootefi selftest for vexpress_ca15_tc2_defconfig.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>  lib/efi_loader/efi_net.c | 36 ++++++++++++++++++++++++++++++++++--
>>  1 file changed, 34 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
>> index 3d860e658e..9afe76cdb3 100644
>> --- a/lib/efi_loader/efi_net.c
>> +++ b/lib/efi_loader/efi_net.c
>> @@ -54,14 +54,46 @@ static efi_status_t EFIAPI efi_net_stop(struct efi_simple_network *this)
>>  	return EFI_EXIT(EFI_SUCCESS);
>>  }
>>  
>> +/*
>> + * Initialize network adapter and allocate transmit and receive buffers.
>> + *
>> + * This function implements the Initialize service of the
>> + * EFI_SIMPLE_NETWORK_PROTOCOL. See the Unified Extensible Firmware Interface
>> + * (UEFI) specification for details.
>> + *
>> + * @this:	pointer to the protocol instance
>> + * @extra_rx:	extra receive buffer to be allocated
>> + * @extra_tx:	extra transmit buffer to be allocated
>> + * @return:	status code
>> + */
>>  static efi_status_t EFIAPI efi_net_initialize(struct efi_simple_network *this,
>>  					      ulong extra_rx, ulong extra_tx)
>>  {
>> +	int ret;
>> +	efi_status_t r = EFI_SUCCESS;
>> +
>>  	EFI_ENTRY("%p, %lx, %lx", this, extra_rx, extra_tx);
>>  
>> -	eth_init();
>> +	if (!this) {
>> +		r = EFI_INVALID_PARAMETER;
>> +		goto error;
>> +	}
>>  
>> -	return EFI_EXIT(EFI_SUCCESS);
>> +	/* Setup packet buffers */
>> +	net_init();
>> +	/* Disable hardware and put it into the reset state */
>> +	eth_halt();
>> +	/* Set current device according to environment variables */
>> +	eth_set_current();
> 
> Is there any way to do the above dance only when needed? Some network
> adapters can take quite a while to initialize and I'd prefer to not go
> through that when not absolutely necessary.
> 
> 
> Alex

Please, have a look at function net_loop() in net/net.c. This sequence
is always used if any network boot command is issued (except when
executing the network console).

The sequence is only executed when the EFI application requests to
initialize the network. So if you start grub.efi from disk you will not
have to wait for the network.

Best regards

Heinrich

> 
>> +	/* Get hardware ready for send and receive operations */
>> +	ret = eth_init();
>> +	if (ret < 0) {
>> +		eth_halt();
>> +		r = EFI_DEVICE_ERROR;
>> +	}
>> +
>> +error:
>> +	return EFI_EXIT(r);
>>  }
>>  
>>  static efi_status_t EFIAPI efi_net_reset(struct efi_simple_network *this,
>>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: completely initialize network
@ 2018-04-02 13:58 Heinrich Schuchardt
  0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-04-02 13:58 UTC (permalink / raw)
  To: u-boot

Add missing network initialization code.

Before the patch the network was only usable if a network command like
dhcp or tftp had beed executed.

This was visible when interrupting the console countdown and executing
bootefi selftest for vexpress_ca15_tc2_defconfig.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_net.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index 8c5d5b492c..829d6fa43e 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -54,14 +54,46 @@ static efi_status_t EFIAPI efi_net_stop(struct efi_simple_network *this)
 	return EFI_EXIT(EFI_SUCCESS);
 }
 
+/*
+ * Initialize network adapter and allocate transmit and receive buffers.
+ *
+ * This function implements the Initialize service of the
+ * EFI_SIMPLE_NETWORK_PROTOCOL. See the Unified Extensible Firmware Interface
+ * (UEFI) specification for details.
+ *
+ * @this:	pointer to the protocol instance
+ * @extra_rx:	extra receive buffer to be allocated
+ * @extra_tx:	extra transmit buffer to be allocated
+ * @return:	status code
+ */
 static efi_status_t EFIAPI efi_net_initialize(struct efi_simple_network *this,
 					      ulong extra_rx, ulong extra_tx)
 {
+	int ret;
+	efi_status_t r = EFI_SUCCESS;
+
 	EFI_ENTRY("%p, %lx, %lx", this, extra_rx, extra_tx);
 
-	eth_init();
+	if (!this) {
+		r = EFI_INVALID_PARAMETER;
+		goto error;
+	}
 
-	return EFI_EXIT(EFI_SUCCESS);
+	/* Setup packet buffers */
+	net_init();
+	/* Disable hardware and put it into the reset state */
+	eth_halt();
+	/* Set current device according to environment variables */
+	eth_set_current();
+	/* Get hardware ready for send and receive operations */
+	ret = eth_init();
+	if (ret < 0) {
+		eth_halt();
+		r = EFI_DEVICE_ERROR;
+	}
+
+error:
+	return EFI_EXIT(r);
 }
 
 static efi_status_t EFIAPI efi_net_reset(struct efi_simple_network *this,
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-04 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-03 20:06 [U-Boot] [PATCH 1/1] efi_loader: completely initialize network Heinrich Schuchardt
2018-04-04  9:42 ` Alexander Graf
2018-04-04 11:20   ` Heinrich Schuchardt
  -- strict thread matches above, loose matches on Subject: below --
2018-04-02 13:58 Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.