diff mbox

[v3,1/6] Link libnet code to Paflof and add a wrapper for netboot()

Message ID 7728ac39-2720-c087-923c-5ebf62347f6a@redhat.com
State Accepted
Headers show

Commit Message

Thomas Huth Oct. 13, 2016, 6:04 p.m. UTC
On 13.10.2016 01:41, Alexey Kardashevskiy wrote:
> On 12/10/16 21:44, Thomas Huth wrote:
>> Now that all necessary functions are provided by Paflof, too,
>> we can finally link the libnet code to this binary. To be able
>> to call the netboot() function from the Forth code now, we also
>> add a wrapper that takes the parameter string from the obp-tftp
>> package and converts it to an argv array that is expected by
>> the netboot() function.
> 
> This breaks my netboot setup.
[...]
> What I get:
> ==============================================
> Trying to load:  from: /pci@800000020000000/ethernet@2 ...
>  Initializing NIC
>   Reading MAC address from device: c0:41:49:4b:00:00
>   Requesting information via DHCP: done
>   Using IPv4 address: 10.61.191.0
>   Requesting file "image.aiktest0" via TFTP from 10.61.2.7
>   Receiving data:  270 KBytes
>   TFTP: Received image.aiktest0 (270 KBytes)
>   Successfully loaded
> 
> Try to netboot
> 
>  Initializing NIC
>   Reading MAC address from device: c0:41:49:4b:00:00
>   Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
> Error, can't read config file

Bummer! I can reproduce this problem here. And I can fix it with the
following patch:

-----------------------------------------------------------------------
-----------------------------------------------------------------------

i.e. I must not assume that the NIC device tree node is still the
current one when the send() and recv() functions are called.

Unfortunately this slows down the network boot again - all the nice
speed-up is gone, it's as slow again as the booting via the net-snk :-(

I'll try to find a solution for that slowdown ... maybe it's possible to
cache the execution token of the corresponding Forth words or something
similar...

 Thomas

Comments

Thomas Huth Oct. 14, 2016, 7:57 a.m. UTC | #1
On 13.10.2016 20:04, Thomas Huth wrote:
> On 13.10.2016 01:41, Alexey Kardashevskiy wrote:
>> On 12/10/16 21:44, Thomas Huth wrote:
>>> Now that all necessary functions are provided by Paflof, too,
>>> we can finally link the libnet code to this binary. To be able
>>> to call the netboot() function from the Forth code now, we also
>>> add a wrapper that takes the parameter string from the obp-tftp
>>> package and converts it to an argv array that is expected by
>>> the netboot() function.
>>
>> This breaks my netboot setup.
> [...]
>> What I get:
>> ==============================================
>> Trying to load:  from: /pci@800000020000000/ethernet@2 ...
>>  Initializing NIC
>>   Reading MAC address from device: c0:41:49:4b:00:00
>>   Requesting information via DHCP: done
>>   Using IPv4 address: 10.61.191.0
>>   Requesting file "image.aiktest0" via TFTP from 10.61.2.7
>>   Receiving data:  270 KBytes
>>   TFTP: Received image.aiktest0 (270 KBytes)
>>   Successfully loaded
>>
>> Try to netboot
>>
>>  Initializing NIC
>>   Reading MAC address from device: c0:41:49:4b:00:00
>>   Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
>> Error, can't read config file
> 
> Bummer! I can reproduce this problem here. And I can fix it with the
> following patch:
> 
> -----------------------------------------------------------------------
> diff a/slof/ppc64.c b/slof/ppc64.c
> --- a/slof/ppc64.c
> +++ b/slof/ppc64.c
> @@ -180,7 +180,10 @@ int recv(int fd, void *buf, int len, int flags)
>  	forth_push((unsigned long)buf);
>  	forth_push(len);
> 
> -	return forth_eval_pop("read");
> +	forth_push((unsigned long)"read");
> +	forth_push(4);
> +	forth_push(fd_array[fd].ih);
> +	return forth_eval_pop("$call-method");
>  }
> 
>  /**
> @@ -200,7 +203,10 @@ int send(int fd, const void *buf, int len, int flags)
>  	forth_push((unsigned long)buf);
>  	forth_push(len);
> 
> -	return forth_eval_pop("write");
> +	forth_push((unsigned long)"write");
> +	forth_push(5);
> +	forth_push(fd_array[fd].ih);
> +	return forth_eval_pop("$call-method");
>  }
> 
>  /**
> -----------------------------------------------------------------------
> 
> i.e. I must not assume that the NIC device tree node is still the
> current one when the send() and recv() functions are called.
> 
> Unfortunately this slows down the network boot again - all the nice
> speed-up is gone, it's as slow again as the booting via the net-snk :-(
> 
> I'll try to find a solution for that slowdown ... maybe it's possible to
> cache the execution token of the corresponding Forth words or something
> similar...

OK, caching the XTs seems to work. I just sent the fix as a separate
patch ("Remember execution tokens of "write" and "read" for socket
operations"), so could you please try again after applying that patch first?

 Thanks,
  Thomas
Alexey Kardashevskiy Oct. 17, 2016, 12:12 a.m. UTC | #2
On 14/10/16 18:57, Thomas Huth wrote:
> On 13.10.2016 20:04, Thomas Huth wrote:
>> On 13.10.2016 01:41, Alexey Kardashevskiy wrote:
>>> On 12/10/16 21:44, Thomas Huth wrote:
>>>> Now that all necessary functions are provided by Paflof, too,
>>>> we can finally link the libnet code to this binary. To be able
>>>> to call the netboot() function from the Forth code now, we also
>>>> add a wrapper that takes the parameter string from the obp-tftp
>>>> package and converts it to an argv array that is expected by
>>>> the netboot() function.
>>>
>>> This breaks my netboot setup.
>> [...]
>>> What I get:
>>> ==============================================
>>> Trying to load:  from: /pci@800000020000000/ethernet@2 ...
>>>  Initializing NIC
>>>   Reading MAC address from device: c0:41:49:4b:00:00
>>>   Requesting information via DHCP: done
>>>   Using IPv4 address: 10.61.191.0
>>>   Requesting file "image.aiktest0" via TFTP from 10.61.2.7
>>>   Receiving data:  270 KBytes
>>>   TFTP: Received image.aiktest0 (270 KBytes)
>>>   Successfully loaded
>>>
>>> Try to netboot
>>>
>>>  Initializing NIC
>>>   Reading MAC address from device: c0:41:49:4b:00:00
>>>   Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
>>> Error, can't read config file
>>
>> Bummer! I can reproduce this problem here. And I can fix it with the
>> following patch:
>>
>> -----------------------------------------------------------------------
>> diff a/slof/ppc64.c b/slof/ppc64.c
>> --- a/slof/ppc64.c
>> +++ b/slof/ppc64.c
>> @@ -180,7 +180,10 @@ int recv(int fd, void *buf, int len, int flags)
>>  	forth_push((unsigned long)buf);
>>  	forth_push(len);
>>
>> -	return forth_eval_pop("read");
>> +	forth_push((unsigned long)"read");
>> +	forth_push(4);
>> +	forth_push(fd_array[fd].ih);
>> +	return forth_eval_pop("$call-method");
>>  }
>>
>>  /**
>> @@ -200,7 +203,10 @@ int send(int fd, const void *buf, int len, int flags)
>>  	forth_push((unsigned long)buf);
>>  	forth_push(len);
>>
>> -	return forth_eval_pop("write");
>> +	forth_push((unsigned long)"write");
>> +	forth_push(5);
>> +	forth_push(fd_array[fd].ih);
>> +	return forth_eval_pop("$call-method");
>>  }
>>
>>  /**
>> -----------------------------------------------------------------------
>>
>> i.e. I must not assume that the NIC device tree node is still the
>> current one when the send() and recv() functions are called.
>>
>> Unfortunately this slows down the network boot again - all the nice
>> speed-up is gone, it's as slow again as the booting via the net-snk :-(
>>
>> I'll try to find a solution for that slowdown ... maybe it's possible to
>> cache the execution token of the corresponding Forth words or something
>> similar...
> 
> OK, caching the XTs seems to work. I just sent the fix as a separate
> patch ("Remember execution tokens of "write" and "read" for socket
> operations"), so could you please try again after applying that patch first?

Yup, having "Remember execution tokens of ..." applied before this patchset
helps, I'll push it all now. Thanks!
diff mbox

Patch

diff a/slof/ppc64.c b/slof/ppc64.c
--- a/slof/ppc64.c
+++ b/slof/ppc64.c
@@ -180,7 +180,10 @@  int recv(int fd, void *buf, int len, int flags)
 	forth_push((unsigned long)buf);
 	forth_push(len);

-	return forth_eval_pop("read");
+	forth_push((unsigned long)"read");
+	forth_push(4);
+	forth_push(fd_array[fd].ih);
+	return forth_eval_pop("$call-method");
 }

 /**
@@ -200,7 +203,10 @@  int send(int fd, const void *buf, int len, int flags)
 	forth_push((unsigned long)buf);
 	forth_push(len);

-	return forth_eval_pop("write");
+	forth_push((unsigned long)"write");
+	forth_push(5);
+	forth_push(fd_array[fd].ih);
+	return forth_eval_pop("$call-method");
 }

 /**