From patchwork Tue Mar 14 10:27:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ananth N Mavinakayanahalli X-Patchwork-Id: 738625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vj9t40Tf0z9s1y for ; Tue, 14 Mar 2017 21:27:56 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vj9t36mdxzDqZL for ; Tue, 14 Mar 2017 21:27:55 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vj9st3Z0szDqYw for ; Tue, 14 Mar 2017 21:27:46 +1100 (AEDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2EANvdo035784 for ; Tue, 14 Mar 2017 06:27:35 -0400 Received: from e28smtp05.in.ibm.com (e28smtp05.in.ibm.com [125.16.236.5]) by mx0a-001b2d01.pphosted.com with ESMTP id 295xm3tqk2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Mar 2017 06:27:31 -0400 Received: from localhost by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Mar 2017 15:57:28 +0530 Received: from d28relay03.in.ibm.com (9.184.220.60) by e28smtp05.in.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Mar 2017 15:57:25 +0530 Received: from d28av08.in.ibm.com (d28av08.in.ibm.com [9.184.220.148]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2EARP7S10551478 for ; Tue, 14 Mar 2017 15:57:25 +0530 Received: from d28av08.in.ibm.com (localhost [127.0.0.1]) by d28av08.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2EAROga006420 for ; Tue, 14 Mar 2017 15:57:24 +0530 Received: from thinktux.in.ibm.com (thinktux.in.ibm.com [9.124.35.193]) by d28av08.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2EAROLu006417 for ; Tue, 14 Mar 2017 15:57:24 +0530 From: Ananth N Mavinakayanahalli To: skiboot@lists.ozlabs.org Date: Tue, 14 Mar 2017 15:57:24 +0530 In-Reply-To: <148948723452.25437.16956459316985787450.stgit@thinktux.in.ibm.com> References: <148948723452.25437.16956459316985787450.stgit@thinktux.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17031410-0016-0000-0000-000003F39F7C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031410-0017-0000-0000-000028DB1D74 Message-Id: <148948724469.25437.16885492359069043256.stgit@thinktux.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-14_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703140086 Subject: [Skiboot] [PATCH V4 2/4] hdata/vpd: Parse additional VINI records X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" These records provide hardware version details, CCIN extension information, card type details and hardware characteristics of the FRU While there, use the helper to add individual records. Signed-off-by: Ananth N Mavinakayanahalli Reviewed-by: Vasant Hegde --- hdata/vpd.c | 99 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 56 deletions(-) diff --git a/hdata/vpd.c b/hdata/vpd.c index 4c787c6..462a7f0 100644 --- a/hdata/vpd.c +++ b/hdata/vpd.c @@ -220,7 +220,8 @@ static const struct card_info *card_info_lookup(char *ccin) { int i; for(i = 0; i < ARRAY_SIZE(card_table); i++) - if (!strcmp(card_table[i].ccin, ccin)) + /* CCIN is always 4 bytes in size */ + if (!strncmp(card_table[i].ccin, ccin, 4)) return &card_table[i]; return NULL; } @@ -229,65 +230,62 @@ static void vpd_vini_parse(struct dt_node *node, const void *fruvpd, unsigned int fruvpd_sz) { const void *kw; - char *str; - uint8_t kwsz; + uint8_t sz; const struct card_info *cinfo; /* FRU Stocking Part Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "FN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "fru-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "FN", &sz); + if (kw) + dt_add_property_nstr(node, "fru-number", kw, sz); /* Serial Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "SN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "serial-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "SN", &sz); + if (kw) + dt_add_property_nstr(node, "serial-number", kw, sz); /* Part Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "PN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "part-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "PN", &sz); + if (kw) + dt_add_property_nstr(node, "part-number", kw, sz); + + /* CCIN Extension */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CE", &sz); + if (kw) + dt_add_property_nstr(node, "ccin-extension", kw, sz); + + /* HW Version info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "HW", &sz); + if (kw) + dt_add_property_nstr(node, "hw-version", kw, sz); + + /* Card type info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CT", &sz); + if (kw) + dt_add_property_nstr(node, "card-type", kw, sz); + + /* HW characteristics info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "B3", &sz); + if (kw) + dt_add_property_nstr(node, "hw-characteristics", kw, sz); /* Customer Card Identification Number (CCIN) */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &kwsz); + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &sz); if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "ccin", str); - cinfo = card_info_lookup(str); + dt_add_property_nstr(node, "ccin", kw, sz); + + cinfo = card_info_lookup((char *)kw); if (cinfo) { dt_add_property_string(node, "description", cinfo->description); } else { dt_add_property_string(node, "description", "Unknown"); prlog(PR_WARNING, - "VPD: CCIN desc not available for : %s\n", str); + "VPD: CCIN desc not available for: %s\n", + (char *)kw); } - free(str); } + return; -no_memory: - prerror("VPD: memory allocation failure in VINI parsing\n"); } static bool valid_child_entry(const struct slca_entry *entry) @@ -486,17 +484,6 @@ def_model: dt_add_property_string(dt_root, "model-name", model_name); } -static void vpd_add_property_string(struct dt_node *n, const char *name, - const void *vpd, unsigned int sz) -{ - char *str = zalloc(sz + 1); - if (!str) - return; - memcpy(str, vpd, sz); - dt_add_property_string(n, name, str); - free(str); -} - static void sysvpd_parse_opp(const void *sysvpd, unsigned int sysvpd_sz) { const char *v; @@ -504,10 +491,10 @@ static void sysvpd_parse_opp(const void *sysvpd, unsigned int sysvpd_sz) v = vpd_find(sysvpd, sysvpd_sz, "OSYS", "MM", &sz); if (v) - vpd_add_property_string(dt_root, "model", v, sz); + dt_add_property_nstr(dt_root, "model", v, sz); v = vpd_find(sysvpd, sysvpd_sz, "OSYS", "SS", &sz); if (v) - vpd_add_property_string(dt_root, "system-id", v, sz); + dt_add_property_nstr(dt_root, "system-id", v, sz); } @@ -533,13 +520,13 @@ static void sysvpd_parse_legacy(const void *sysvpd, unsigned int sysvpd_sz) system_id = vpd_find(sysvpd, sysvpd_sz, "VSYS", "SE", &sz); if (system_id) - vpd_add_property_string(dt_root, "system-id", system_id, sz); + dt_add_property_nstr(dt_root, "system-id", system_id, sz); else dt_add_property_string(dt_root, "system-id", "Unknown"); brand = vpd_find(sysvpd, sysvpd_sz, "VSYS", "BR", &sz); if (brand) - vpd_add_property_string(dt_root, "system-brand", brand, sz); + dt_add_property_nstr(dt_root, "system-brand", brand, sz); else dt_add_property_string(dt_root, "brand", "Unknown"); }