Translate Udev Event path to a generic path
Given Udev event generated path is translated into sys bus path - as the json will
have the sys/bus path.
Test:
-> Translation successful for all frus including frus behind muxes.
-> If the system vpd is triggered by udev event, then the execution stops as
the system vpd will already be parsed via system-vpd.service.
Few Reasons why we translate the path to a generic path:
-> Each i2c bus is memory mapped to a certain address in ASPEED.
In future if there are any architectural changes in the kernel, we need to
make changes to the JSON accordingly.
-> Also in future if the system runs on a different ASPEED, we need to
update the JSON accordingly.
-> This generic /sys/bus path represents the system wiring and doesnot rely on
how the busses are memory mapped.
-> Also for call out based events, generic path is expected than the udev event path.
Sample Udev Event i2c path : "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0050/8-00500/nvmem"
Which gets translated to /sys/bus/ path as : "/sys/bus/i2c/drivers/at24/8-0050/eeprom"
Sample Udev Event spi path : "/sys/devices/platform/ahb/ahb:apb/1e79b000.fsi/fsi-master/fsi0/slave@00:00/00:00:00:0a/fsi-master/fsi1/slave@03:00/01:03:00:04/spi_master/spi6/spi6.0/spi6.00/nvmem"
Which gets translated to /sys/bus/ path as : "/sys/bus/spi/drivers/at25/spi6.0/eeprom"
Sample Udev Event i2c path for frus behind mux : "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a300.i2c-bus/i2c-5/i2c-24/24-0051/24-00510/nvmem"
Which gets translated to generic path as /sys/bus/i2c/drivers/at24/24-0051/eeprom
Tested on simics:
<the inventory json should have generic eeprom paths for all frus>
root@rainier:/tmp# ./ibm-read-vpd-UG -f /sys/devices/platform/ahb/ahb:apb/1e79b000.fsi/fsi-master/fsi0/slave@00:00/00:00:00:04/spi_master/spi12/spi12.0/spi12.00/nvmem
the path after translation : /sys/bus/spi/drivers/at25/spi12.0/eeprom
root@rainier:/tmp# ./ibm-read-vpd-UG -f /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0051/8-00510/nvmem
the path after translation : /sys/bus/i2c/drivers/at24/8-0051/eeprom
root@rainier:/tmp# ./ibm-read-vpd-UG -f /sys/bus/i2c/drivers/at24/8-0051/8-00510/nvmem
the path after translation : /sys/bus/i2c/drivers/at24/8-0051/eeprom
Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
Change-Id: I6d5995a85ef15e63d2d0b6f054fb0bf14a2b756c
diff --git a/const.hpp b/const.hpp
index 92107fa..e173e89 100644
--- a/const.hpp
+++ b/const.hpp
@@ -90,6 +90,9 @@
constexpr auto motherBoardInterface =
"xyz.openbmc_project.Inventory.Item.Board.Motherboard";
constexpr auto systemVpdFilePath = "/sys/bus/i2c/drivers/at24/8-0050/eeprom";
+constexpr auto i2cPathPrefix = "/sys/bus/i2c/drivers/at24/";
+constexpr auto spiPathPrefix = "/sys/bus/spi/drivers/at25/";
+
namespace lengths
{
enum Lengths