summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/ipmi/intel-ipmi-oem/0002-GetFwVersionInfo-Fix-for-Firmware-aux-version.patch
blob: 514f2dde77fc59b59460dd0f564d6eb9a2d54338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From 52a292b8dd1b5705a6e0ce8e260d3b960b2b6edb Mon Sep 17 00:00:00 2001
From: srikanta mondal <srikantax.mondal@intel.com>
Date: Mon, 27 Jul 2020 23:49:14 +0000
Subject: [PATCH] GetFwVersionInfo: Fix for Firmware aux version

Issue: Get Version Information return incorrect Firmware AUX version

FIX: Firmware aux version was parsing incorrectly. Do the parsing by
     correct regex pattern of BMC version.

Tested:
Verified using ipmitool raw commands
Before fix:
Command: ipmitool raw 0x08 0x20 // Get version Information
Response: 01 02 00 70 01 00 00 00 00 00 00 00 00 00 00 00

After fix:
Command: ipmitool raw 0x08 0x20 // Get version Information
Response: 02 01 00 74 0a 8a 37 78 00 00 00 00 00 00 00 00
          02 00 70 01 00 00 00 00 00 00 00 00 00 00 00

Signed-off-by: srikanta mondal <srikantax.mondal@intel.com>
Change-Id: I7c2baf8a0da15e3ca4db5d6f9d6de7bf739aa755
---
 src/firmware-update.cpp | 56 +++++++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/src/firmware-update.cpp b/src/firmware-update.cpp
index 8c3cc94..ec1d14a 100644
--- a/src/firmware-update.cpp
+++ b/src/firmware-update.cpp
@@ -1,3 +1,4 @@
+#include <byteswap.h>
 #include <ipmid/api.h>
 #include <openssl/evp.h>
 #include <openssl/sha.h>
@@ -6,6 +7,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <appcommands.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/container/flat_map.hpp>
 #include <boost/process/child.hpp>
@@ -836,26 +838,44 @@ ipmi::RspType<uint8_t, std::vector<fwVersionInfoType>> ipmiGetFwVersionInfo()
             continue;
         }
 
-        // BMC Version format: <major>.<minor>-<build bum>-<build hash>
-        std::vector<std::string> splitVer;
-        boost::split(splitVer, verStr, boost::is_any_of(".-"));
-        if (splitVer.size() < 3)
-        {
-            phosphor::logging::log<phosphor::logging::level::INFO>(
-                "Invalid Version format.",
-                phosphor::logging::entry("Version=%s", verStr.c_str()),
-                phosphor::logging::entry("PATH=%s", fwDev.second));
-            continue;
-        }
-
         uint8_t majorNum = 0;
         uint8_t minorNum = 0;
         uint32_t buildNum = 0;
         try
         {
-            majorNum = std::stoul(splitVer[0], nullptr, 16);
-            minorNum = std::stoul(splitVer[1], nullptr, 16);
-            buildNum = std::stoul(splitVer[2], nullptr, 16);
+            std::optional<ipmi::MetaRevision> rev =
+                ipmi::convertIntelVersion(verStr);
+            if (rev.has_value())
+            {
+                ipmi::MetaRevision revision = rev.value();
+                majorNum = revision.major % 10 + (revision.major / 10) * 16;
+                minorNum = (revision.minor > 99 ? 99 : revision.minor);
+                minorNum = minorNum % 10 + (minorNum / 10) * 16;
+                uint32_t hash = std::stoul(revision.metaHash, 0, 16);
+                hash = bswap_32(hash);
+                buildNum = (revision.buildNo & 0xFF) + (hash & 0xFFFFFF00);
+            }
+            else
+            {
+                std::vector<std::string> splitVer;
+                boost::split(splitVer, verStr, boost::is_any_of(".-"));
+                if (splitVer.size() < 3)
+                {
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Invalid Version format.",
+                        phosphor::logging::entry("Version=%s", verStr.c_str()),
+                        phosphor::logging::entry("PATH=%s", fwDev.second));
+                    continue;
+                }
+                majorNum = std::stoul(splitVer[0], nullptr, 16);
+                minorNum = std::stoul(splitVer[1], nullptr, 16);
+                buildNum = std::stoul(splitVer[2], nullptr, 16);
+            }
+            // Build Timestamp - Not supported.
+            // Update Timestamp - TODO: Need to check with CPLD team.
+            fwVerInfoList.emplace_back(
+                fwVersionInfoType(static_cast<uint8_t>(fwDev.first), majorNum,
+                                  minorNum, buildNum, 0, 0));
         }
         catch (const std::exception& e)
         {
@@ -864,12 +884,6 @@ ipmi::RspType<uint8_t, std::vector<fwVersionInfoType>> ipmiGetFwVersionInfo()
                 phosphor::logging::entry("ERROR=%s", e.what()));
             continue;
         }
-
-        // Build Timestamp - Not supported.
-        // Update Timestamp - TODO: Need to check with CPLD team.
-        fwVerInfoList.emplace_back(
-            fwVersionInfoType(static_cast<uint8_t>(fwDev.first), majorNum,
-                              minorNum, buildNum, 0, 0));
     }
 
     return ipmi::responseSuccess(fwVerInfoList.size(), fwVerInfoList);
-- 
2.17.1