1# compare_vpd
2
3## Description
4
5Compares a VPD (Vital Product Data) keyword value to an expected value.
6
7VPD is information that describes a hardware component. VPD is typically read
8from an EEPROM on a Field-Replaceable Unit (FRU). For this reason, VPD is also
9called "FRU data".
10
11The phosphor-regulators application obtains VPD keyword values from D-Bus. Other
12BMC applications and drivers are responsible for reading VPD from hardware
13components and publishing it on D-Bus.
14
15The following VPD keywords are currently supported:
16
17- CCIN
18- Manufacturer
19- Model
20- PartNumber
21- HW
22
23This action can be used in an [if](if.md) condition to execute actions based on
24a VPD keyword value. For example, you could set the output voltage only for
25regulators with a specific Model number.
26
27### Unavailable keyword values
28
29A keyword value may be unavailable if:
30
31- The hardware component does not support the keyword.
32- An error occurred while attempting to read VPD from the hardware component.
33- The BMC cannot access the VPD due to the system hardware design, such as not
34  being connected to the necessary I2C bus.
35
36If the keyword value is unavailable, it will be treated as having an "empty"
37value:
38
39- An empty string ("") if the "value" property was specified.
40- An empty array ([]) if the "byte_values" property was specified.
41
42If the expected value is not "empty", the compare_vpd action will return false
43since the values will not match.
44
45## Properties
46
47| Name        |      Required       | Type             | Description                                                                                                                                                                                                                                                             |
48| :---------- | :-----------------: | :--------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49| fru         |         yes         | string           | Field-Replaceable Unit (FRU) that contains the VPD. Specify the relative D-Bus inventory path of the FRU. Full inventory paths begin with the root "/xyz/openbmc_project/inventory". Specify the relative path below the root, such as "system/chassis/disk_backplane". |
50| keyword     |         yes         | string           | VPD keyword. Specify one of the following: "CCIN", "Manufacturer", "Model", "PartNumber", "HW".                                                                                                                                                                         |
51| value       | see [notes](#notes) | string           | Expected value.                                                                                                                                                                                                                                                         |
52| byte_values | see [notes](#notes) | array of strings | Zero or more expected byte values expressed in hexadecimal. Each value must be prefixed with 0x and surrounded by double quotes.                                                                                                                                        |
53
54### Notes
55
56- You must specify either "value" or "byte_values".
57
58## Return Value
59
60Returns true if the keyword value equals the expected value, otherwise returns
61false.
62
63## Examples
64
65```
66{
67  "comments": [ "Check if disk backplane has CCIN value 2D35" ],
68  "compare_vpd": {
69    "fru": "system/chassis/disk_backplane",
70    "keyword": "CCIN",
71    "value": "2D35"
72  }
73}
74```
75
76```
77{
78  "comments": [ "Check if disk backplane has CCIN value 0x32, 0x44, 0x33, 0x35" ],
79  "compare_vpd": {
80    "fru": "system/chassis/disk_backplane",
81    "keyword": "CCIN",
82    "byte_values": [ "0x32", "0x44", "0x33", "0x35" ]
83  }
84}
85```
86