From patchwork Tue Dec 11 02:40:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 1010820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43DPN11Bjbz9s3q for ; Tue, 11 Dec 2018 13:41:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="b1fgOHBi"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="e0ig41Gb"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43DPN0649VzDqwC for ; Tue, 11 Dec 2018 13:41:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="b1fgOHBi"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="e0ig41Gb"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="b1fgOHBi"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="e0ig41Gb"; dkim-atps=neutral Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43DPMM3qXrzDqrn for ; Tue, 11 Dec 2018 13:41:03 +1100 (AEDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 0C6EE21EDD; Mon, 10 Dec 2018 21:41:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 10 Dec 2018 21:41:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=fm1; bh=dPJcrjVdVkDBvgds7iwWXSWe+5ERWHkhsDW4bcHWlEI=; b=b1fgO HBicVs8//RbkelxDCMoI0vS6CCtkY6R9wYRGQL33s8tUP6yHzzPQGArw/nmnWILP 6Zkoe4+Xvr9rvGveFee0YycX514VtA5GXDf+y21CK6wepewzgG3m4mqPjawqgTXr ufJJjHC9y/z8Hwhprtezp7KdO5wSDVJMNkTg+34BQ9vGokafyyydJ4fIyAZWwJg/ rAFqbt5SAKAhVgap4hRsu8p/CrWIuDKlqj6tQiV+VNJwf4lQpPceh0A6NtqluvZo wZzagSYlEhsZyWnpeb+IpLNJ45CezeF76CLBuJfs2r8Y0I+YAfGB9OUYcsXjpBn5 8+ebZ6mNA+UEZ7g8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=dPJcrjVdVkDBvgds7iwWXSWe+5ERWHkhsDW4bcHWlEI=; b=e0ig41Gb telhkJQAezkyt5EfsBNZqBNMH0xYMklvJiPw4AUjSM+C/Y+KnblRs6Pu1LaVp7s4 mdRwawKLmbsScq8wkBFysoRzFnD6s5pyi4bD7zozBI2dRm3X5NZbyFU5ZPObGB0r PzkhgOBtaUt0fbHud1+J8da97iJG5CCNMvP5wmVfTFONEukM8/kQsml5iuygVSZs AMCMOsMsEkM7+wXAQxvHOZxhSmETCmnB/z4ZWJfacEQzKepfSJwoWueNrKnUt/3w U/vuHxulTEIut7mK8AGSGQlKq8QbB11qQ/n2I6LArQoNpwQb2I5rNAL7/zyYlT9e 0zy55VcaUzdP2A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegiedggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpe furghmuhgvlhcuofgvnhguohiirgdqlfhonhgrshcuoehsrghmsehmvghnughoiigrjhho nhgrshdrtghomheqnecukfhppeduvddvrdelledrkedvrddutdenucfrrghrrghmpehmrg hilhhfrhhomhepshgrmhesmhgvnhguohiirghjohhnrghsrdgtohhmnecuvehluhhsthgv rhfuihiivgepvd X-ME-Proxy: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 760BFE4675; Mon, 10 Dec 2018 21:40:59 -0500 (EST) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH v2 3/3] ui/ncurses: Add option to clear IPMI boot mailbox Date: Tue, 11 Dec 2018 13:40:46 +1100 Message-Id: <20181211024046.17067-4-sam@mendozajonas.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211024046.17067-1-sam@mendozajonas.com> References: <20181211024046.17067-1-sam@mendozajonas.com> MIME-Version: 1.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" If there is an IPMI boot mailbox configuration present display a message in the System Configuration screen and provide the option to clear the mailbox. Signed-off-by: Samuel Mendoza-Jonas --- discover/platform-powerpc.c | 9 ++++--- lib/pb-config/pb-config.c | 1 + lib/pb-protocol/pb-protocol.c | 6 +++++ lib/types/types.h | 1 + ui/ncurses/nc-config.c | 49 ++++++++++++++++++++++++++++++++++- 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 3e700983..5d7cc597 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -617,7 +617,7 @@ static int clear_ipmi_boot_mailbox(struct platform_powerpc *platform) resp_len = sizeof(resp); - for (i = 0; i < 16; i++) { + for (i = 0; i < UCHAR_MAX; i++) { req[1] = i; /* set selector */ rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_CHASSIS, IPMI_CMD_CHASSIS_SET_SYSTEM_BOOT_OPTIONS, @@ -627,11 +627,12 @@ static int clear_ipmi_boot_mailbox(struct platform_powerpc *platform) if (rc || resp[0]) { if (i == 0) { - pb_log("platform: error clearing IPMI boot mailbox, rc %d resp[0] %hu\n", + pb_log_fn("error clearing IPMI boot mailbox, " + "rc %d resp[0] %hu\n", rc, resp[0]); return -1; - } else - break; + } + break; } } diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 7fa925c2..a802c92f 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -83,6 +83,7 @@ struct config *config_copy(void *ctx, const struct config *src) dest->ipmi_bootdev = src->ipmi_bootdev; dest->ipmi_bootdev_persistent = src->ipmi_bootdev_persistent; + dest->ipmi_bootdev_mailbox = src->ipmi_bootdev_mailbox; dest->allow_writes = src->allow_writes; diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index d8771fcb..b4138bbf 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -324,6 +324,7 @@ int pb_protocol_config_len(const struct config *config) } len += 4 + 4; /* ipmi_bootdev, ipmi_bootdev_persistent */ + len += 4; /* ipmi_bootdev_mailbox */ len += 4; /* allow_writes */ @@ -646,6 +647,8 @@ int pb_protocol_serialise_config(const struct config *config, pos += 4; *(uint32_t *)pos = config->ipmi_bootdev_persistent; pos += 4; + *(uint32_t *)pos = config->ipmi_bootdev_mailbox; + pos += 4; *(uint32_t *)pos = config->allow_writes; pos += 4; @@ -1277,6 +1280,9 @@ int pb_protocol_deserialise_config(struct config *config, if (read_u32(&pos, &len, &tmp)) goto out; config->ipmi_bootdev_persistent = !!tmp; + if (read_u32(&pos, &len, &tmp)) + goto out; + config->ipmi_bootdev_mailbox = !!tmp; if (read_u32(&pos, &len, &tmp)) goto out; diff --git a/lib/types/types.h b/lib/types/types.h index 39760d91..9d83d87d 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -188,6 +188,7 @@ struct config { unsigned int ipmi_bootdev; bool ipmi_bootdev_persistent; + bool ipmi_bootdev_mailbox; char *http_proxy; char *https_proxy; diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 4685fa5d..943ee8a8 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -34,7 +34,7 @@ #include "nc-config.h" #include "nc-widgets.h" -#define N_FIELDS 49 +#define N_FIELDS 51 extern struct help_text config_help_text; @@ -67,6 +67,7 @@ struct config_screen { bool autoboot_enabled; bool ipmi_override; + bool ipmi_mailbox; bool net_override; struct { @@ -86,6 +87,9 @@ struct config_screen { struct nc_widget_label *ipmi_clear_l; struct nc_widget_button *ipmi_clear_b; + struct nc_widget_label *ipmi_mailbox_l; + struct nc_widget_button *ipmi_mailbox_b; + struct nc_widget_label *network_l; struct nc_widget_select *network_f; @@ -439,6 +443,27 @@ static void ipmi_clear_click(void *arg) screen->exit = true; } +static void ipmi_clear_mailbox_click(void *arg) +{ + struct config_screen *screen = arg; + struct config *config; + int rc; + + config = config_copy(screen, screen->cui->config); + config->ipmi_bootdev_mailbox = false; + config->safe_mode = false; + + rc = cui_send_config(screen->cui, config); + talloc_free(config); + + if (rc) + pb_log("cui_send_config failed!\n"); + else + pb_debug("config sent!\n"); + screen->exit = true; +} + + static int layout_pair(struct config_screen *screen, int y, struct nc_widget_label *label, struct nc_widget *field) @@ -546,6 +571,18 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; } + if (screen->ipmi_mailbox) { + wl = widget_label_base(screen->widgets.ipmi_mailbox_l); + widget_set_visible(wl, true); + widget_move(wl, y, screen->label_x); + y += 1; + + wf = widget_button_base(screen->widgets.ipmi_mailbox_b); + widget_set_visible(wf, true); + widget_move(wf, y, screen->field_x); + y += 1; + } + y += 1; y += layout_pair(screen, y, screen->widgets.network_l, @@ -990,6 +1027,16 @@ static void config_screen_setup_widgets(struct config_screen *screen, screen->ipmi_override = true; } + if (config->ipmi_bootdev_mailbox) { + screen->widgets.ipmi_mailbox_l = widget_new_label(set, 0, 0, + _("IPMI boot order mailbox config present")); + screen->widgets.ipmi_mailbox_b = widget_new_button(set, 0, 0, + strncols(_("Clear IPMI boot order mailbox now")) + 10, + _("Clear IPMI boot order mailbox now"), + ipmi_clear_mailbox_click, screen); + screen->ipmi_mailbox = true; + } + screen->widgets.network_l = widget_new_label(set, 0, 0, _("Network:")); screen->widgets.network_f = widget_new_select(set, 0, 0, COLS - screen->field_x - 1);