diff mbox

[7/8] ipmi: introduce an ipmi_bmc_sdr_find() API

Message ID 1455020010-17532-8-git-send-email-clg@fr.ibm.com
State New
Headers show

Commit Message

Cédric Le Goater Feb. 9, 2016, 12:13 p.m. UTC
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 <clg@fr.ibm.com>
---
 hw/ipmi/ipmi_bmc_sim.c | 16 ++++++++++++++++
 include/hw/ipmi/ipmi.h |  2 ++
 2 files changed, 18 insertions(+)

Comments

Marcel Apfelbaum Feb. 14, 2016, 9:30 a.m. UTC | #1
On 02/09/2016 02:13 PM, Cédric Le Goater wrote:
> 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 <clg@fr.ibm.com>
> ---
>   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);

This method is not used yet. I suppose you have a work in progress
using it, I suggest to add this to your next series when it will be used.

Thanks,
Marcel

>   #endif
>
Cédric Le Goater Feb. 15, 2016, 5:21 p.m. UTC | #2
On 02/14/2016 10:30 AM, Marcel Apfelbaum wrote:
> On 02/09/2016 02:13 PM, Cédric Le Goater wrote:
>> 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 <clg@fr.ibm.com>
>> ---
>>   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);
> 
> This method is not used yet. I suppose you have a work in progress
> using it, I suggest to add this to your next series when it will be used.

OK. I will do. 

Thanks,

C.



> Thanks,
> Marcel
> 
>>   #endif
>>
>
diff mbox

Patch

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