Skip to contentSkip to conversation

cmd: pxe_utils: sysboot: add label override support

PATCH In review Amjad Ouled-Ameur 4 participants 7 messages Nov 13, 2021 – Jan 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cmd: pxe_utils: sysboot: add label override support

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

---

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

 boot/pxe_utils.c | 15 +++++++++++++++
 doc/README.pxe   |  6 ++++++
 2 files changed, 21 insertions(+)
boot/pxe_utils.c +15 -0
index a7a84f26c1d5..defc806fdc4f 100644
@@ -1349,9 +1349,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
 	struct pxe_label *label;
 	struct list_head *pos;
 	struct menu *m;
+	char *label_override;
 	int err;
 	int i = 1;
 	char *default_num = NULL;
+	char *override_num = NULL;
 
 	/*
 	 * Create a menu and add items for all the labels.
@@ -1361,6 +1363,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
 	if (!m)
 		return NULL;
 
+	label_override = env_get("pxe_label_override");
+
 	list_for_each(pos, &cfg->labels) {
 		label = list_entry(pos, struct pxe_label, list);
 
@@ -1372,6 +1376,17 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
 		if (cfg->default_label &&
 		    (strcmp(label->name, cfg->default_label) == 0))
 			default_num = label->num;
+		if (label_override && !strcmp(label->name, label_override))
+			override_num = label->num;
+	}
+
+
+	if (label_override) {
+		if (override_num)
+			default_num = override_num;
+		else
+			printf("Missing override pxe label: %s\n",
+			      label_override);
 	}
 
 	/*
doc/README.pxe +6 -0
index b67151ca510e..a1f0423adbec 100644
@@ -92,6 +92,12 @@ pxe boot
      fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily store
      fdt overlay(s) before applying them to the fdt blob stored at 'fdt_addr_r'.
 
+     pxe_label_override - override label to be used, if exists, instead of the
+     default label. This will allow consumers to choose a pxe label at
+     runtime instead of having to prompt the user. If "pxe_label_override" is set
+     but does not exist in the pxe menu, pxe would fallback to the default label if
+     given, and no failure is returned but rather a warning message.
+
 pxe file format
 ===============
 The pxe file format is nearly a subset of the PXELINUX file format; see
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw

Hi Amjad,

Quoted 21 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

---

Quoted 7 lines

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

 boot/pxe_utils.c | 15 +++++++++++++++
 doc/README.pxe   |  6 ++++++
 2 files changed, 21 insertions(+)

Can I suggest converting the doc to rST?

Regards,
Simon

#2 lore raw

Hi,

Is there any news about this patch please ?

Regards,

Amjad

Quoted 37 lines · Simon Glass

Hi Amjad,

Quoted 20 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

---

Quoted 7 lines

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

  boot/pxe_utils.c | 15 +++++++++++++++
  doc/README.pxe   |  6 ++++++
  2 files changed, 21 insertions(+)

Can I suggest converting the doc to rST?

Regards,
Simon

Reviewed-by on v2 1/1
#3 lore raw
In reply to Amjad Ouled-Ameur
Quoted 13 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

Quoted 6 lines

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

Good and useful idea! why still not accepted ?!

Regards,
Art

#4 lore raw
Quoted 21 lines · Art Nikpal
Quoted 18 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

Quoted 8 lines
Quoted 1 line

Good and useful idea! why still not accepted ?!

Regards,
Art

Was mistakenly assigned to trini instead of me. I will pull in to my tree. Thanks.
Ramon

#5 lore raw
Quoted 27 lines · Ramon Fried
Quoted 25 lines · Art Nikpal
Quoted 13 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

Quoted 6 lines

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

Quoted 7 lines
Quoted 4 lines

Good and useful idea! why still not accepted ?!

Regards,
Art

Was mistakenly assigned to trini instead of me. I will pull in to my tree. Thanks.
Ramon

Applied to u-boot-net/next
Thanks.

Reviewed-by on v2 1/1
#6 lore raw
In reply to Amjad Ouled-Ameur
Quoted 90 lines · Amjad Ouled-Ameur

This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message.

---

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

 boot/pxe_utils.c | 15 +++++++++++++++
 doc/README.pxe   |  6 ++++++
 2 files changed, 21 insertions(+)
boot/pxe_utils.c +15 -0
index a7a84f26c1d5..defc806fdc4f 100644
@@ -1349,9 +1349,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
        struct pxe_label *label;
        struct list_head *pos;
        struct menu *m;
+       char *label_override;
        int err;
        int i = 1;
        char *default_num = NULL;
+       char *override_num = NULL;
 
        /*
         * Create a menu and add items for all the labels.
@@ -1361,6 +1363,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
        if (!m)
                return NULL;
 
+       label_override = env_get("pxe_label_override");
+
        list_for_each(pos, &cfg->labels) {
                label = list_entry(pos, struct pxe_label, list);
 
@@ -1372,6 +1376,17 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
                if (cfg->default_label &&
                    (strcmp(label->name, cfg->default_label) == 0))
                        default_num = label->num;
+               if (label_override && !strcmp(label->name, label_override))
+                       override_num = label->num;
+       }
+
+
+       if (label_override) {
+               if (override_num)
+                       default_num = override_num;
+               else
+                       printf("Missing override pxe label: %s\n",
+                             label_override);
        }
 
        /*
doc/README.pxe +6 -1
index b67151ca510e..a1f0423adbec 100644
@@ -92,6 +92,12 @@ pxe boot
      fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily store
      fdt overlay(s) before applying them to the fdt blob stored at 'fdt_addr_r'.
 
+     pxe_label_override - override label to be used, if exists, instead of the
+     default label. This will allow consumers to choose a pxe label at
+     runtime instead of having to prompt the user. If "pxe_label_override" is set
+     but does not exist in the pxe menu, pxe would fallback to the default label if
+     given, and no failure is returned but rather a warning message.
+
 pxe file format
 ===============
 The pxe file format is nearly a subset of the PXELINUX file format; see
--
Quoted 2 lines

2.25.1