[SLOF] [PATCH v2 10/19] virtio-net: move setup-mac to the open routine
thuth at redhat.com
Thu Jan 21 19:15:18 AEDT 2016
On 21.01.2016 08:57, Nikunj A Dadhania wrote:
> Thomas Huth <thuth at redhat.com> writes:
>> On 20.01.2016 13:10, Nikunj A Dadhania wrote:
>>> MAC reading should be done after the initialization of the device after
>>> the features negotiation.
>>> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
>>> board-qemu/slof/virtio-net.fs | 22 +++++++++++-----------
>>> 1 file changed, 11 insertions(+), 11 deletions(-)
>>> diff --git a/board-qemu/slof/virtio-net.fs b/board-qemu/slof/virtio-net.fs
>>> index 412b34f..5414dd1 100644
>>> --- a/board-qemu/slof/virtio-net.fs
>>> +++ b/board-qemu/slof/virtio-net.fs
>>> @@ -21,9 +21,20 @@ virtiodev virtio-setup-vd
>>> 0 VALUE virtio-net-priv
>>> 0 VALUE open-count
>>> +\ Set up MAC address from config virtqueue
>>> +6 BUFFER: local-mac
>>> +: setup-mac ( -- )
>>> + 6 0 DO
>>> + virtiodev i 1 virtio-get-config
>>> + local-mac i + c!
>>> + LOOP
>>> + local-mac 6 encode-bytes s" local-mac-address" property
>>> : open ( -- okay? )
>>> open-count 0= IF
>>> open IF
>>> + setup-mac
>> This way, a new "local-mac-address" property will be created each time
>> the device tree node is opened (and closed inbetween) again.
> with open-count, this will happen only once, am I missing something
> here? Are you suggesting multiple clients opening same device.
open-count can drop back to 0 when the node is closed. So if a client is
opening and closing the device a couple of times, this can be called
more than once. IIRC yaboot was doing something like this when
netbooting: First it loaded its config file from the TFTP server, then
it loaded the kernel and finally it loaded the initrd from the TFTP
server. The network interface was opened and closed for each file.
>> That's somewhat ugly. Maybe you could add some code to "setup-mac"
>> that checks whether the property is already available and only sets it
>> if it is not there yet?
> That would be simple to add to setup-mac:
> s" local-mac-address" get-node get-property not IF 2drop EXIT THEN
More information about the SLOF