Received: from eggs.gnu.org ([2001:4830:134:3::10]:56837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3Gwt-0005Nv-9P for qemu-devel@nongnu.org; Wed, 26 Apr 2017 03:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3Gwk-00084a-1X for qemu-devel@nongnu.org; Wed, 26 Apr 2017 03:01:15 -0400 From: David Gibson Date: Wed, 26 Apr 2017 17:00:18 +1000 Message-Id: <20170426070034.10727-33-david@gibson.dropbear.id.au> In-Reply-To: <20170426070034.10727-1-david@gibson.dropbear.id.au> References: <20170426070034.10727-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 32/48] ipmi: introduce an ipmi_bmc_sdr_find() API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: agraf@suse.de, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson From: C=C3=A9dric Le Goater This patch exposes a new IPMI routine to query a sdr entry from the sdr table maintained by the IPMI BMC simulator. The API is very similar to the internal sdr_find_entry() routine and should be used the same way to query one or all sdrs. A typical use would be to loop on the sdrs to build nodes of a device tree. Signed-off-by: C=C3=A9dric Le Goater Acked-by: Corey Minyard Signed-off-by: David Gibson --- hw/ipmi/ipmi_bmc_sim.c | 16 ++++++++++++++++ include/hw/ipmi/ipmi.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index feb7627..09213ab 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -416,6 +416,22 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t rec= id, return 1; } =20 +int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, + const struct ipmi_sdr_compact **sdr, uint16_t *nex= trec) + +{ + IPMIBmcSim *ibs =3D IPMI_BMC_SIMULATOR(b); + unsigned int pos; + + pos =3D 0; + if (sdr_find_entry(&ibs->sdr, recid, &pos, nextrec)) { + return -1; + } + + *sdr =3D (const struct ipmi_sdr_compact *) &ibs->sdr.sdr[pos]; + return 0; +} + static void sel_inc_reservation(IPMISel *sel) { sel->reservation++; diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index 91b83b5..0d36cfc 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -259,4 +259,6 @@ struct ipmi_sdr_compact { =20 typedef uint8_t ipmi_sdr_compact_buffer[sizeof(struct ipmi_sdr_compact)]= ; =20 +int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, + const struct ipmi_sdr_compact **sdr, uint16_t *nex= trec); #endif --=20 2.9.3