SEL log Generator ID should Conform to IPMI Spec

In IMPI specification, the generator ID for SEL log is 2 bytes long.
Apart from the Generator ID, it contains LUN and channel information.
The fix is to change 1-Byte Generator ID to 2-byte generator ID and
include all missing information into it.

Tested
Following tests were executed:
1) Run ipmitool raw -l 1 0x4 0x2 0x4 0x8 0x1 0x6 0x1 0x5
This ensures that non-zero LUN information is included
in the SEL record.

2) Instrument the code to look like ME has created an event
and make sure that logs are saved properly.

For 1) and 2) logs are read from the WebUI to make sure that
they are being saved as expected.

Signed-off-by: Sujoy Ray <sujoy.ray@intel.com>
Change-Id: I78d4423cc24c941af7bf0cd70423a95747ba4a76
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index ac0b52d..601fea6 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -541,7 +541,7 @@
     constexpr const uint8_t lastSensorType = 0x2C;
     constexpr const uint8_t oemReserved = 0xC0;
 
-    uint8_t generatorID = 0;
+    uint8_t sysgeneratorID = 0;
     uint8_t evmRev = 0;
     uint8_t sensorType = 0;
     uint8_t sensorNum = 0;
@@ -549,6 +549,7 @@
     uint8_t eventData1 = 0;
     std::optional<uint8_t> eventData2 = 0;
     std::optional<uint8_t> eventData3 = 0;
+    [[maybe_unused]] uint16_t generatorID = 0;
     ipmi::ChannelInfo chInfo;
 
     if (ipmi::getChannelInfo(ctx->channel, chInfo) != ipmi::ccSuccess)
@@ -563,15 +564,24 @@
         ipmi::EChannelMediumType::systemInterface)
     {
 
-        p.unpack(generatorID, evmRev, sensorType, sensorNum, eventType,
+        p.unpack(sysgeneratorID, evmRev, sensorType, sensorNum, eventType,
                  eventData1, eventData2, eventData3);
+        // Refer to IPMI Spec Table 32: SEL Event Records
+        generatorID = (ctx->channel << 12) // Channel
+                      | (0x0 << 10)        // Reserved
+                      | (0x0 << 8)         // 0x0 for sys-soft ID
+                      | ((sysgeneratorID << 1) | 0x1);
     }
     else
     {
 
         p.unpack(evmRev, sensorType, sensorNum, eventType, eventData1,
                  eventData2, eventData3);
-        generatorID = ctx->rqSA << 1;
+        // Refer to IPMI Spec Table 32: SEL Event Records
+        generatorID = (ctx->channel << 12)      // Channel
+                      | (0x0 << 10)             // Reserved
+                      | ((ctx->lun & 0x3) << 8) // Lun
+                      | (ctx->rqSA << 1);
     }
 
     if (!p.fullyUnpacked())