diff mbox

[v2,05/12] hdat: Grab system model name from HDAT when available

Message ID 1477751795-20128-6-git-send-email-hegdevasant@linux.vnet.ibm.com
State Changes Requested
Headers show

Commit Message

Vasant Hegde Oct. 29, 2016, 2:36 p.m. UTC
Latest spec added system model information to IPL PARAMS ntuple.
Grab this information when available instead of using hardcoded
table (machine_table).

Its better to parse all IPL params in one place. But on P8 we depend
on model information ..which we get from sysvpd_parse(). Hence for now
I've added code inside sysvpd_parse().

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hdata/vpd.c | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

Comments

Stewart Smith Dec. 20, 2016, 6:04 a.m. UTC | #1
Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
> --- a/hdata/vpd.c
> +++ b/hdata/vpd.c
> @@ -598,6 +598,36 @@ struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
>  	return node;
>  }
>
> +static void dt_add_model_name(char *model)
> +{
> +	const struct machine_info *mi;
> +	const struct iplparams_sysparams *p;
> +	const struct HDIF_common_hdr *iplp;
> +
> +	iplp = get_hdif(&spira.ntuples.ipl_parms, "IPLPMS");
> +	if (!iplp)
> +		goto def_model;
> +
> +	p = HDIF_get_idata(iplp, IPLPARAMS_SYSPARAMS, NULL);
> +	if (!CHECK_SPPTR(p))
> +		goto def_model;
> +
> +	if (proc_gen >= proc_gen_p9) {
> +		dt_add_property_string(dt_root,
> +				       "model-name", p->sys_type_str);
> +		return;
> +	}

Is there just an empty string otherwise? Why not fall through if there's
an empty string instead? or check version?

> +
> +def_model:
> +	mi = machine_info_lookup(model);
> +	if (mi) {
> +		dt_add_property_string(dt_root, "model-name", mi->name);
> +	} else {
> +		dt_add_property_string(dt_root, "model-name", "Unknown");
> +		prlog(PR_WARNING, "VPD: Model name %s not known\n", model);
> +	}
> +}
> +
Vasant Hegde Jan. 4, 2017, 10:41 a.m. UTC | #2
On 12/20/2016 11:34 AM, Stewart Smith wrote:
> Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
>> --- a/hdata/vpd.c
>> +++ b/hdata/vpd.c
>> @@ -598,6 +598,36 @@ struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
>>   	return node;
>>   }
>>
>> +static void dt_add_model_name(char *model)
>> +{
>> +	const struct machine_info *mi;
>> +	const struct iplparams_sysparams *p;
>> +	const struct HDIF_common_hdr *iplp;
>> +
>> +	iplp = get_hdif(&spira.ntuples.ipl_parms, "IPLPMS");
>> +	if (!iplp)
>> +		goto def_model;
>> +
>> +	p = HDIF_get_idata(iplp, IPLPARAMS_SYSPARAMS, NULL);
>> +	if (!CHECK_SPPTR(p))
>> +		goto def_model;
>> +
>> +	if (proc_gen >= proc_gen_p9) {
>> +		dt_add_property_string(dt_root,
>> +				       "model-name", p->sys_type_str);
>> +		return;
>> +	}
>
> Is there just an empty string otherwise? Why not fall through if there's
> an empty string instead? or check version?

I think this field is always populated on P9 system. Hence I added P9 check 
instead of HDAT version check.  May be I can check for HDAT  version instead and 
fall through it this string is empty.


-Vasant
diff mbox

Patch

diff --git a/hdata/vpd.c b/hdata/vpd.c
index a463170..a111e5f 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -598,6 +598,36 @@  struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
 	return node;
 }
 
+static void dt_add_model_name(char *model)
+{
+	const struct machine_info *mi;
+	const struct iplparams_sysparams *p;
+	const struct HDIF_common_hdr *iplp;
+
+	iplp = get_hdif(&spira.ntuples.ipl_parms, "IPLPMS");
+	if (!iplp)
+		goto def_model;
+
+	p = HDIF_get_idata(iplp, IPLPARAMS_SYSPARAMS, NULL);
+	if (!CHECK_SPPTR(p))
+		goto def_model;
+
+	if (proc_gen >= proc_gen_p9) {
+		dt_add_property_string(dt_root,
+				       "model-name", p->sys_type_str);
+		return;
+	}
+
+def_model:
+	mi = machine_info_lookup(model);
+	if (mi) {
+		dt_add_property_string(dt_root, "model-name", mi->name);
+	} else {
+		dt_add_property_string(dt_root, "model-name", "Unknown");
+		prlog(PR_WARNING, "VPD: Model name %s not known\n", model);
+	}
+}
+
 static void sysvpd_parse(void)
 {
 	const char *model;
@@ -611,7 +641,6 @@  static void sysvpd_parse(void)
 	struct dt_node *dt_vpd;
 	const struct spira_fru_id *fru_id;
 	struct HDIF_common_hdr *sysvpd_hdr;
-	const struct machine_info *mi;
 
 	sysvpd_hdr = get_hdif(&spira.ntuples.system_vpd, SYSVPD_HDIF_SIG);
 	if (!sysvpd_hdr)
@@ -640,13 +669,8 @@  static void sysvpd_parse(void)
 		goto no_sysvpd;
 	memcpy(str, model, sz);
 	dt_add_property_string(dt_root, "model", str);
-	mi = machine_info_lookup(str);
-	if (mi) {
-		dt_add_property_string(dt_root, "model-name", mi->name);
-	} else {
-		dt_add_property_string(dt_root, "model-name", "Unknown");
-		prlog(PR_WARNING, "VPD: Model name %s not known\n", str);
-	}
+
+	dt_add_model_name(str);
 
 	free(str);