Skip to contentSkip to conversation

ofnet: Do not set SUFFIX for sun4v network devices

PATCH Superseded Stanislav Kholmanskikh 2 participants 9 messages Jul 16, 2015 – Oct 8, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ofnet: Do not set SUFFIX for sun4v network devices

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
 grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +21 -2
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
   grub_uint64_t prop;
   grub_uint8_t *pprop;
   char *shortname;
+  char need_suffix = 1;
 
   if (grub_strcmp (alias->type, "network") != 0)
     return 0;
@@ -325,7 +326,25 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
 #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+				     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+	if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+			   sizeof("SUNW,sun4v-network")))
+	  need_suffix = 0;
+      }
+  }
+  
+  if (need_suffix)
     ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
   else
     ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       return 0;
     }
   ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
     grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
   else
     *ofdata->suffix = '\0';
Signature · 1 line
1.7.1
#1 lore raw

В Thu, 16 Jul 2015 10:21:41 +0300
Stanislav Kholmanskikh <[email protected]> пишет:

Quoted 45 lines

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
 grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +9 -1
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
   grub_uint64_t prop;
   grub_uint8_t *pprop;
   char *shortname;
+  char need_suffix = 1;
 
   if (grub_strcmp (alias->type, "network") != 0)
     return 0;
@@ -325,7 +326,25 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
 #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 346

Quoted 10 lines
grub-core/net/drivers/ieee1275/ofnet.c +10 -0
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+				     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+	if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+			   sizeof("SUNW,sun4v-network")))
+	  need_suffix = 0;
+      }
+  }
+  

Can it have devices that do support suffix? If no, it is better to extend grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() and set GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX for the platform.

Quoted 13 lines
grub-core/net/drivers/ieee1275/ofnet.c +2 -1
+  if (need_suffix)
     ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
   else
     ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       return 0;
     }
   ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
     grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
   else
     *ofdata->suffix = '\0';
#2 lore raw
Quoted 54 lines · Andrei Borzenkov

В Thu, 16 Jul 2015 10:21:41 +0300
Stanislav Kholmanskikh <[email protected]> пишет:

Quoted 51 lines

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
  grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
  1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +15 -1
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
    grub_uint64_t prop;
    grub_uint8_t *pprop;
    char *shortname;
+  char need_suffix = 1;
 
    if (grub_strcmp (alias->type, "network") != 0)
      return 0;
@@ -325,7 +326,25 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
  #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+				     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+	if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+			   sizeof("SUNW,sun4v-network")))
Quoted 8 lines

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 346

Quoted 4 lines
grub-core/net/drivers/ieee1275/ofnet.c +4 -0
+	  need_suffix = 0;
+      }
+  }
+

Can it have devices that do support suffix? If no, it is better to extend grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() and set GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX for the platform.

A ldom may have both virtual an physical network devices at the same time. One can assign entire PCIE root complexes, individual cards or SR-IOV virtual functions to a ldom. More details are:

https://docs.oracle.com/cd/E38405_01/html/E38406/usingpcibuseswithldoms.html#scrolltoc

Thanks.

Quoted 21 lines
Quoted 6 lines
grub-core/net/drivers/ieee1275/ofnet.c +1 -0
+  if (need_suffix)
      ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
    else
      ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 360

Quoted 8 lines
grub-core/net/drivers/ieee1275/ofnet.c +1 -1
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
        return 0;
      }
    ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
      grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
    else
      *ofdata->suffix = '\0';

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

Hi!

Quoted 73 lines · Stanislav Kholmanskikh
Quoted 61 lines · Andrei Borzenkov

В Thu, 16 Jul 2015 10:21:41 +0300
Stanislav Kholmanskikh <[email protected]> пишет:

Quoted 58 lines

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

Signed-off-by: Stanislav Kholmanskikh
<[email protected]>

---
  grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
  1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +1 -0
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias
 *alias)
    grub_uint64_t prop;
    grub_uint8_t *pprop;
    char *shortname;
+  char need_suffix = 1;
 
    if (grub_strcmp (alias->type, "network") != 0)
      return 0;
grub-core/net/drivers/ieee1275/ofnet.c +0 -0
@@ -325,7 +326,25 @@ search_net_devices (struct
 grub_ieee1275_devalias *alias)
 
  #define SUFFIX

":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"

grub-core/net/drivers/ieee1275/ofnet.c +14 -1
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+                     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+    if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+               sizeof("SUNW,sun4v-network")))
Quoted 8 lines

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 346

Quoted 4 lines
grub-core/net/drivers/ieee1275/ofnet.c +4 -0
+      need_suffix = 0;
+      }
+  }
+

Can it have devices that do support suffix? If no, it is better to extend grub-core/kern/ieee1275/cmain.c:grub_ieee1275_find_options() and set GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX for the platform.

Quoted 5 lines

A ldom may have both virtual an physical network devices at the same time. One can assign entire PCIE root complexes, individual cards or SR-IOV virtual functions to a ldom. More details are:

https://docs.oracle.com/cd/E38405_01/html/E38406/usingpcibuseswithldoms.html#scrolltoc

So a ldom may have devices that do support the suffix and that do not support the suffix.

Quoted 32 lines

Thanks.

Quoted 14 lines
Quoted 14 lines

+ if (need_suffix)

      ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof
(SUFFIX));
    else
      ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
grub-core/net/drivers/ieee1275/ofnet.c +1 -1
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias
 *alias)
        return 0;
      }
    ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
      grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
Quoted 9 lines
Quoted 2 lines
grub-core/net/drivers/ieee1275/ofnet.c +0 -0
    else
      *ofdata->suffix = '\0';

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
In reply to Stanislav Kholmanskikh

В Thu, 16 Jul 2015 10:21:41 +0300
Stanislav Kholmanskikh <[email protected]> пишет:

Quoted 41 lines

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
 grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +5 -1
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
   grub_uint64_t prop;
   grub_uint8_t *pprop;
   char *shortname;
+  char need_suffix = 1;
 
   if (grub_strcmp (alias->type, "network") != 0)
     return 0;
@@ -325,7 +326,25 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
 #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 342

Quoted 10 lines
grub-core/net/drivers/ieee1275/ofnet.c +10 -0
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+				     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+	if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+			   sizeof("SUNW,sun4v-network")))

Is grub_strncmp intentional? Can it have some suffix that we want to ignore here?

"compatible" property is defined as array of strings. Can it contain more than one value here?

Quoted 17 lines
grub-core/net/drivers/ieee1275/ofnet.c +6 -1
+	  need_suffix = 0;
+      }
+  }
+  
+  if (need_suffix)
     ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
   else
     ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       return 0;
     }
   ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
     grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
   else
     *ofdata->suffix = '\0';
#5 lore raw

Hi.

Quoted 49 lines · Andrei Borzenkov

В Thu, 16 Jul 2015 10:21:41 +0300
Stanislav Kholmanskikh <[email protected]> пишет:

Quoted 46 lines

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
  grub-core/net/drivers/ieee1275/ofnet.c |   23 +++++++++++++++++++++--
  1 files changed, 21 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +10 -1
index eea8e71..dbcf337 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
    grub_uint64_t prop;
    grub_uint8_t *pprop;
    char *shortname;
+  char need_suffix = 1;
 
    if (grub_strcmp (alias->type, "network") != 0)
      return 0;
@@ -325,7 +326,25 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
  #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char tmp[24];
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
Quoted 8 lines

grub-core/net/drivers/ieee1275/ofnet.c search_net_devices (struct grub_ieee1275_devalias *alias) · line 342

Quoted 5 lines
grub-core/net/drivers/ieee1275/ofnet.c +5 -0
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+				     (grub_uint8_t *)tmp, sizeof(tmp), NULL))
+      {
+	if (!grub_strncmp (tmp, "SUNW,sun4v-network",
+			   sizeof("SUNW,sun4v-network")))

Is grub_strncmp intentional? Can it have some suffix that we want to ignore here?

My point was to match "SUNW,sun4v-network" exactly.

Quoted 3 lines

"compatible" property is defined as array of strings. Can it contain more than one value here?

In accordance to the Virtual Machine Specification, sections 8.23.4.2 and 8.23.4.3:

https://kenai.com/downloads/hypervisor/Hypervisor-api-2.0.pdf

it contains single value - "SUNW,sun4v-network".

But yes, indeed, "compatible" is an array of strings, and may contain multiple values here (at least in the future, of one decides to update vnet specs). I missed that.

So on I'm fixing my patch to tread "compatible" as an array, and will send an updated version in a moment.

Thank you for review.

Quoted 19 lines
Quoted 18 lines
grub-core/net/drivers/ieee1275/ofnet.c +6 -1
+	  need_suffix = 0;
+      }
+  }
+
+  if (need_suffix)
      ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
    else
      ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +354,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
        return 0;
      }
    ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
      grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
    else
      *ofdata->suffix = '\0';
#6 lore raw

PATCH v2 1/1 ofnet: Do not set SUFFIX for sun4v network devices

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

---
Changes since V1:
* handle "compatible" property as an array of strings

 grub-core/net/drivers/ieee1275/ofnet.c |   41 ++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +39 -2
index eea8e71..13970bd 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
   grub_uint64_t prop;
   grub_uint8_t *pprop;
   char *shortname;
+  char need_suffix = 1;
 
   if (grub_strcmp (alias->type, "network") != 0)
     return 0;
@@ -325,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
 #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char *ptr;
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    grub_ieee1275_get_property_length (devhandle, "compatible", &prop_size);
+    if (prop_size > 0)
+      {
+	pprop = grub_malloc (prop_size);
+	if (!pprop)
+	  {
+	    grub_free (card);
+	    grub_free (ofdata);
+	    grub_print_error ();
+	    return 1;
+	  }
+
+	if (!grub_ieee1275_get_property (devhandle, "compatible",
+					 pprop, prop_size, NULL))
+	  {
+	    for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size;
+		 ptr += grub_strlen (ptr) + 1)
+	      {
+		if (!grub_strcmp(ptr, "SUNW,sun4v-network"))
+		  need_suffix = 0;
+	      }
+	}
+
+	grub_free (pprop);
+      }
+  }
+  
+  if (need_suffix)
     ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
   else
     ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       return 0;
     }
   ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
     grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
   else
     *ofdata->suffix = '\0';
Signature · 1 line
1.7.1
#7 lore raw

Hi!

Quoted 13 lines · Stanislav Kholmanskikh

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Quoted 6 lines

Therefore, let's not set SUFFIX for such devices.

---
Changes since V1:
* handle "compatible" property as an array of strings

Could anybody look at it, please?

Thanks.

Quoted 72 lines

  grub-core/net/drivers/ieee1275/ofnet.c |   41 ++++++++++++++++++++++++++++++-
  1 files changed, 39 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +39 -2
index eea8e71..13970bd 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
    grub_uint64_t prop;
    grub_uint8_t *pprop;
    char *shortname;
+  char need_suffix = 1;
 
    if (grub_strcmp (alias->type, "network") != 0)
      return 0;
@@ -325,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 
  #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
 
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char *ptr;
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    grub_ieee1275_get_property_length (devhandle, "compatible", &prop_size);
+    if (prop_size > 0)
+      {
+	pprop = grub_malloc (prop_size);
+	if (!pprop)
+	  {
+	    grub_free (card);
+	    grub_free (ofdata);
+	    grub_print_error ();
+	    return 1;
+	  }
+
+	if (!grub_ieee1275_get_property (devhandle, "compatible",
+					 pprop, prop_size, NULL))
+	  {
+	    for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size;
+		 ptr += grub_strlen (ptr) + 1)
+	      {
+		if (!grub_strcmp(ptr, "SUNW,sun4v-network"))
+		  need_suffix = 0;
+	      }
+	}
+
+	grub_free (pprop);
+      }
+  }
+
+  if (need_suffix)
      ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
    else
      ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -335,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
        return 0;
      }
    ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
      grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
    else
      *ofdata->suffix = '\0';
#8 lore raw

07.10.2015 17:52, Stanislav Kholmanskikh пишет:

Quoted 17 lines

Hi!

Quoted 14 lines · Stanislav Kholmanskikh

sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Quoted 9 lines
Quoted 6 lines

Therefore, let's not set SUFFIX for such devices.

---
Changes since V1:
* handle "compatible" property as an array of strings

Could anybody look at it, please?

I was hoping you lost patience and fixed FCODE :)

Sorry for delay, applied.

Quoted 88 lines

Thanks.

Quoted 78 lines

  grub-core/net/drivers/ieee1275/ofnet.c |   41
++++++++++++++++++++++++++++++-
  1 files changed, 39 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +1 -0
index eea8e71..13970bd 100644
@@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias
 *alias)
    grub_uint64_t prop;
    grub_uint8_t *pprop;
    char *shortname;
+  char need_suffix = 1;
 
    if (grub_strcmp (alias->type, "network") != 0)
      return 0;
grub-core/net/drivers/ieee1275/ofnet.c +0 -0
@@ -325,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias
 *alias)
 
  #define SUFFIX

":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"

grub-core/net/drivers/ieee1275/ofnet.c +10 -1
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+    need_suffix = 0;
+
+  /* sun4v vnet devices do not support setting duplex/speed */
+  {
+    char *ptr;
+
+    grub_ieee1275_finddevice (alias->path, &devhandle);
+
+    grub_ieee1275_get_property_length (devhandle, "compatible",

&prop_size);

grub-core/net/drivers/ieee1275/ofnet.c +27 -0
+    if (prop_size > 0)
+      {
+    pprop = grub_malloc (prop_size);
+    if (!pprop)
+      {
+        grub_free (card);
+        grub_free (ofdata);
+        grub_print_error ();
+        return 1;
+      }
+
+    if (!grub_ieee1275_get_property (devhandle, "compatible",
+                     pprop, prop_size, NULL))
+      {
+        for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size;
+         ptr += grub_strlen (ptr) + 1)
+          {
+        if (!grub_strcmp(ptr, "SUNW,sun4v-network"))
+          need_suffix = 0;
+          }
+    }
+
+    grub_free (pprop);
+      }
+  }
+
+  if (need_suffix)
      ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof
(SUFFIX));
    else
      ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
grub-core/net/drivers/ieee1275/ofnet.c +1 -1
@@ -335,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias
 *alias)
        return 0;
      }
    ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+  if (need_suffix)
      grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
    else
Quoted 2 lines
      *ofdata->suffix = '\0';

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel