Add a new entry 'Download All Microcode' under the 'Work with Microcode'
menu to update microcode of all devices at once, similar to
update-all-ucodes in CLI.

We don't use the print_dev interface in the confirmation screen because
it would require major changes in that function to display useful
information on the update and to avoid loading firmware images more than
once.

Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com>
---
 iprconfig.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 iprconfig.h | 20 ++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/iprconfig.c b/iprconfig.c
index 4be0db1..d4240aa 100644
--- a/iprconfig.c
+++ b/iprconfig.c
@@ -11526,6 +11526,83 @@ static int update_ucode(struct ipr_dev *dev, struct 
ipr_fw_images *fw_image)
        return rc;
 }
 
+struct download_ucode_elem {
+       struct ipr_dev* dev;
+       struct ipr_fw_images *lfw;
+       struct download_ucode_elem *next;
+};
+
+/**
+ * download_all_ucode -
+ * @i_con:             i_container struct
+ *
+ * Returns:
+ *   0 if success / non-zero on failure FIXME
+ **/
+int download_all_ucode(i_container *i_con)
+{
+       struct ipr_ioa *ioa;
+       struct ipr_dev *dev;
+       struct ipr_fw_images *lfw;
+       struct screen_output *s_out;
+       struct download_ucode_elem *elem, *update_list = NULL;
+       int header_lines;
+       char line[BUFSIZ];
+       char *body;
+
+       processing();
+       i_con = free_i_con(i_con);
+       check_current_config(false);
+       body = body_init(n_confirm_download_all_ucode.header, &header_lines);
+
+       for_each_ioa(ioa) {
+               if (!ioa->ioa.scsi_dev_data || ioa->ioa_dead)
+                       continue;
+
+               for_each_dev (ioa, dev) {
+                       if (ipr_is_volume_set(dev))
+                               continue;
+
+                       lfw = get_latest_fw_image(dev);
+                       if (!lfw || lfw->version <= get_fw_version(dev))
+                               continue;
+
+                       if (ioa->is_secondary)
+                               continue;
+
+                       sprintf(line, "%-6s %-10X %-10s %s\n",
+                               basename(dev->gen_name), lfw->version,
+                               lfw->date, lfw->file);
+
+                       body = add_string_to_body(body, line, "", 
&header_lines);
+
+                       /*  Add device to update list */
+                       elem = malloc(sizeof(struct download_ucode_elem));
+                       elem->dev = dev;
+                       elem->lfw = lfw;
+                       elem->next = update_list;
+                       update_list = elem;
+               }
+       }
+
+       n_confirm_download_all_ucode.body = body;
+       s_out = screen_driver(&n_confirm_download_all_ucode, header_lines, 
i_con);
+
+       if (s_out && s_out->rc != CANCEL_FLAG) {
+               while (update_list) {
+                       elem = update_list;
+                       update_list = elem->next;
+                       update_ucode(elem->dev, elem->lfw);
+                       free(elem);
+               }
+       }
+
+       if (s_out)
+               free(s_out);
+
+       return 0;
+}
+
 /**
  * process_choose_ucode -
  * @dev:               ipr dev struct
diff --git a/iprconfig.h b/iprconfig.h
index 6009515..0bb2117 100644
--- a/iprconfig.h
+++ b/iprconfig.h
@@ -137,6 +137,7 @@ int change_disk_config(i_container *);
 int change_ioa_config(i_container *);
 int ucode_screen(i_container *i_con);
 int download_ucode(i_container *);
+int download_all_ucode(i_container *);
 int choose_ucode(i_container *);
 int log_menu(i_container *);
 int ibm_storage_log_tail(i_container *);
@@ -1450,6 +1451,24 @@ s_node n_confirm_download_ucode = {
                "" }
 };
 
+s_node n_confirm_download_all_ucode = {
+       .rc_flags = (CANCEL_FLAG),
+       .f_flags  = (CANCEL_FLAG | FWD_FLAG),
+       .num_opts = NUM_OPTS(null_opt),
+       .options  = &null_opt[0],
+       .title    = __("Confirm Microcode Download"),
+       .header   = {
+               __("The following devices are going to be updated.\n\n"
+                  "ATTENTION:  System performance may be affected during "
+                  "the microcode download process. "
+                  "Download may take some time.\n\n"),
+               __("Press Enter to continue.\n"),
+               __("  q=Cancel to return and change your choice.\n\n"),
+               "Name   Version    Date       Image File\n",
+               "------ ---------  ---------  -----------------------------\n",
+               "" }
+};
+
 s_node n_download_ucode_in_progress = {
        .rc_flags = (CANCEL_FLAG),
        .f_flags  = (CANCEL_FLAG | FWD_FLAG),
@@ -1560,6 +1579,7 @@ s_node n_confirm_set_default_editor = {
 
 struct screen_opts ucode_screen_opt[] = {
        {download_ucode,      "1", __("Download microcode")},
+       {download_all_ucode,  "2", __("Download latest microcode to all 
devices")},
 };
 
 s_node n_ucode_screen = {
-- 
2.1.0


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to