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