From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT7Az-0008Kg-Tv for qemu-devel@nongnu.org; Tue, 09 Feb 2016 07:13:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT7Av-0003tt-Le for qemu-devel@nongnu.org; Tue, 09 Feb 2016 07:13:49 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:36592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT7Av-0003tg-Au for qemu-devel@nongnu.org; Tue, 09 Feb 2016 07:13:45 -0500 Received: from localhost by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Feb 2016 12:13:44 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id E3BC517D8042 for ; Tue, 9 Feb 2016 12:13:56 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u19CDgUm10158506 for ; Tue, 9 Feb 2016 12:13:42 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u19CDfbH006571 for ; Tue, 9 Feb 2016 05:13:42 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 9 Feb 2016 13:13:29 +0100 Message-Id: <1455020010-17532-8-git-send-email-clg@fr.ibm.com> In-Reply-To: <1455020010-17532-1-git-send-email-clg@fr.ibm.com> References: <1455020010-17532-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 7/8] ipmi: introduce an ipmi_bmc_sdr_find() API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corey Minyard Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Greg Kurz , qemu-devel@nongnu.org, "Michael S. Tsirkin" 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édric Le Goater --- 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 b0754893fc08..c952219429f4 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -406,6 +406,22 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t recid, return 1; } +int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, + const struct ipmi_sdr_compact **sdr, uint16_t *nextrec) + +{ + IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b); + unsigned int pos; + + pos = 0; + if (sdr_find_entry(&ibs->sdr, recid, &pos, nextrec)) { + return -1; + } + + *sdr = (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 74a2b5af9613..e41321db174d 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -255,4 +255,6 @@ struct ipmi_sdr_compact { typedef uint8_t ipmi_sdr_compact_buffer[sizeof(struct ipmi_sdr_compact)]; +int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, + const struct ipmi_sdr_compact **sdr, uint16_t *nextrec); #endif -- 2.1.4