xref: /openbmc/docs/designs/cable-monitor.md (revision 7eb2d98e7b687d260880515c09c1c25ccbcfab00)
1*7eb2d98eSJagpal Singh Gill# Cable Monitor
2*7eb2d98eSJagpal Singh Gill
3*7eb2d98eSJagpal Singh GillAuthor: Jagpal Singh Gill <paligill@gmail.com>
4*7eb2d98eSJagpal Singh Gill
5*7eb2d98eSJagpal Singh GillCreated: July 26, 2024
6*7eb2d98eSJagpal Singh Gill
7*7eb2d98eSJagpal Singh Gill## Problem Description
8*7eb2d98eSJagpal Singh Gill
9*7eb2d98eSJagpal Singh GillCables are components that can be intentionally or unintentionally inserted or
10*7eb2d98eSJagpal Singh Gillremoved while a system is running. Additionally, the specific configuration of
11*7eb2d98eSJagpal Singh Gillcables connected for a particular hardware setup may need to be determined at
12*7eb2d98eSJagpal Singh Gillruntime based on datacenter deployments. Currently, there is no service
13*7eb2d98eSJagpal Singh Gillavailable in openBMC that can be configured at runtime to monitor connected
14*7eb2d98eSJagpal Singh Gillcables and compare them against the expected cables. Hence, there is no way to
15*7eb2d98eSJagpal Singh Gillgenerate Redfish events based on this comparison.
16*7eb2d98eSJagpal Singh Gill
17*7eb2d98eSJagpal Singh Gill## Background and References
18*7eb2d98eSJagpal Singh Gill
19*7eb2d98eSJagpal Singh GillopenBMC provides a GPIO monitoring framework through
20*7eb2d98eSJagpal Singh Gill[phosphor-gpio-monitor](https://github.com/openbmc/phosphor-gpio-monitor), but
21*7eb2d98eSJagpal Singh Gillthis framework is too generic in its design that allows for watching a GPIO and
22*7eb2d98eSJagpal Singh Gillrunning a related systemd target. For more information, please refer to the
23*7eb2d98eSJagpal Singh GillAlternative section.
24*7eb2d98eSJagpal Singh Gill
25*7eb2d98eSJagpal Singh Gill## Requirements
26*7eb2d98eSJagpal Singh Gill
27*7eb2d98eSJagpal Singh Gill1. Able to support runtime configuration of cable connectivity.
28*7eb2d98eSJagpal Singh Gill2. Able to monitor inventory interface events related to cables and generate
29*7eb2d98eSJagpal Singh Gill   corresponding Redfish events.
30*7eb2d98eSJagpal Singh Gill
31*7eb2d98eSJagpal Singh Gill## Proposed Design
32*7eb2d98eSJagpal Singh Gill
33*7eb2d98eSJagpal Singh Gill### Cable Monitor
34*7eb2d98eSJagpal Singh Gill
35*7eb2d98eSJagpal Singh Gill```mermaid
36*7eb2d98eSJagpal Singh Gill---
37*7eb2d98eSJagpal Singh Gillconfig:
38*7eb2d98eSJagpal Singh Gill  layout: fixed
39*7eb2d98eSJagpal Singh Gill---
40*7eb2d98eSJagpal Singh Gillflowchart LR
41*7eb2d98eSJagpal Singh Gill    A["cable-config.json"] --> B["Cable Monitor"]
42*7eb2d98eSJagpal Singh Gill    C["EntityManager"] -- xyz.openbmc_project.Inventory.Item.Cable
43*7eb2d98eSJagpal Singh Gill                           inventory updates --> B
44*7eb2d98eSJagpal Singh Gill    B -- Generate Cable Events --> D["bmcweb"]
45*7eb2d98eSJagpal Singh Gill```
46*7eb2d98eSJagpal Singh Gill
47*7eb2d98eSJagpal Singh Gill#### cable.conf
48*7eb2d98eSJagpal Singh Gill
49*7eb2d98eSJagpal Singh GillThe format of the runtime configuration is as under -
50*7eb2d98eSJagpal Singh Gill
51*7eb2d98eSJagpal Singh Gill##### JSON schema
52*7eb2d98eSJagpal Singh Gill
53*7eb2d98eSJagpal Singh Gill```json
54*7eb2d98eSJagpal Singh Gill{
55*7eb2d98eSJagpal Singh Gill  "$schema": "https://json-schema.org/draft/2020-12/schema",
56*7eb2d98eSJagpal Singh Gill  "$defs": {
57*7eb2d98eSJagpal Singh Gill    "CablesDef": {
58*7eb2d98eSJagpal Singh Gill      "description": "The connected cable definition.",
59*7eb2d98eSJagpal Singh Gill      "type": "object",
60*7eb2d98eSJagpal Singh Gill      "properties": {
61*7eb2d98eSJagpal Singh Gill        "ConnectedCables": {
62*7eb2d98eSJagpal Singh Gill          "description": "The connected cable list.",
63*7eb2d98eSJagpal Singh Gill          "type": "array",
64*7eb2d98eSJagpal Singh Gill          "prefixItems": [
65*7eb2d98eSJagpal Singh Gill            {
66*7eb2d98eSJagpal Singh Gill              "type": "string",
67*7eb2d98eSJagpal Singh Gill              "description": "The name of the cable"
68*7eb2d98eSJagpal Singh Gill            }
69*7eb2d98eSJagpal Singh Gill          ]
70*7eb2d98eSJagpal Singh Gill        }
71*7eb2d98eSJagpal Singh Gill      },
72*7eb2d98eSJagpal Singh Gill      "required": ["ConnectedCables"]
73*7eb2d98eSJagpal Singh Gill    }
74*7eb2d98eSJagpal Singh Gill  },
75*7eb2d98eSJagpal Singh Gill  "$ref": "#/$defs/CablesDef"
76*7eb2d98eSJagpal Singh Gill}
77*7eb2d98eSJagpal Singh Gill```
78*7eb2d98eSJagpal Singh Gill
79*7eb2d98eSJagpal Singh Gill##### Example cablemonitor/cable-config.json
80*7eb2d98eSJagpal Singh Gill
81*7eb2d98eSJagpal Singh Gill```json
82*7eb2d98eSJagpal Singh Gill{
83*7eb2d98eSJagpal Singh Gill  "ConnectedCables": ["Cable_1", "Cable_2"]
84*7eb2d98eSJagpal Singh Gill}
85*7eb2d98eSJagpal Singh Gill```
86*7eb2d98eSJagpal Singh Gill
87*7eb2d98eSJagpal Singh GillThe configuration lists the cables that should be connected and monitored.
88*7eb2d98eSJagpal Singh Gill
89*7eb2d98eSJagpal Singh GillThis fulfills requirement #1.
90*7eb2d98eSJagpal Singh Gill
91*7eb2d98eSJagpal Singh Gill#### cable-monitor
92*7eb2d98eSJagpal Singh Gill
93*7eb2d98eSJagpal Singh GillThe cable monitor is responsible for processing the cable-config.json file and
94*7eb2d98eSJagpal Singh Gillparsing its contents. It uses this information to raise appropriate alerts based
95*7eb2d98eSJagpal Singh Gillon expected cable connectivity and inventory item status. Additionally, it
96*7eb2d98eSJagpal Singh Gillcontinuously monitors any changes in the cable inventory item status and raises
97*7eb2d98eSJagpal Singh Gillor resolves alerts accordingly. This fulfills requirement #2.
98*7eb2d98eSJagpal Singh Gill
99*7eb2d98eSJagpal Singh Gill### Error Reporting
100*7eb2d98eSJagpal Singh Gill
101*7eb2d98eSJagpal Singh GillA definition for
102*7eb2d98eSJagpal Singh Gill[missing cable](https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/74397)
103*7eb2d98eSJagpal Singh Gillevent is proposed for Redfish, which is based on
104*7eb2d98eSJagpal Singh Gill[event logging design](https://github.com/openbmc/docs/blob/master/designs/event-logging.md).
105*7eb2d98eSJagpal Singh Gill
106*7eb2d98eSJagpal Singh Gill### Future Enhancements
107*7eb2d98eSJagpal Singh Gill
108*7eb2d98eSJagpal Singh GillThe cable monitor can be extended to support runtime cable configurations
109*7eb2d98eSJagpal Singh Gillthrough the Redfish
110*7eb2d98eSJagpal Singh Gill[Cable](https://redfish.dmtf.org/schemas/v1/Cable.v1_2_3.json) schema by using
111*7eb2d98eSJagpal Singh Gillthe CableStatus property.
112*7eb2d98eSJagpal Singh Gill
113*7eb2d98eSJagpal Singh Gill## Alternatives Considered
114*7eb2d98eSJagpal Singh Gill
115*7eb2d98eSJagpal Singh Gill### phosphor-gpio-monitor
116*7eb2d98eSJagpal Singh Gill
117*7eb2d98eSJagpal Singh GillThe phosphor-gpio-monitor does not currently support monitoring inventory items
118*7eb2d98eSJagpal Singh Gillsuch as cable inventory items, although it could be extended to do so. However,
119*7eb2d98eSJagpal Singh Gillthis would not align with its intended purpose and nomenclature. Additionally,
120*7eb2d98eSJagpal Singh Gillthere is no support for runtime configuration in phosphor-gpio-monitor. Any
121*7eb2d98eSJagpal Singh Gillchange to add these features would result in a monolithic daemon that would need
122*7eb2d98eSJagpal Singh Gillto be extended for every other inventory item type.
123*7eb2d98eSJagpal Singh Gill
124*7eb2d98eSJagpal Singh Gill## Impacts
125*7eb2d98eSJagpal Singh Gill
126*7eb2d98eSJagpal Singh Gill### API Impacts
127*7eb2d98eSJagpal Singh Gill
128*7eb2d98eSJagpal Singh Gill- A cable connect event api is being suggested as the source of Redfish event.
129*7eb2d98eSJagpal Singh Gill
130*7eb2d98eSJagpal Singh Gill### Organizational
131*7eb2d98eSJagpal Singh Gill
132*7eb2d98eSJagpal Singh Gill- Does this repository require a new repository? No.
133*7eb2d98eSJagpal Singh Gill- Which repositories are expected to be modified to execute this design?
134*7eb2d98eSJagpal Singh Gill  `dbus-sensors`
135*7eb2d98eSJagpal Singh Gill- Make a list, and add listed repository maintainers to the gerrit review.
136*7eb2d98eSJagpal Singh Gill
137*7eb2d98eSJagpal Singh Gill## Testing
138*7eb2d98eSJagpal Singh Gill
139*7eb2d98eSJagpal Singh Gill### Unit Testing
140*7eb2d98eSJagpal Singh Gill
141*7eb2d98eSJagpal Singh GillAll the functional testing of the reference implementation will be performed
142*7eb2d98eSJagpal Singh Gillusing GTest.
143*7eb2d98eSJagpal Singh Gill
144*7eb2d98eSJagpal Singh Gill### Integration Testing
145*7eb2d98eSJagpal Singh Gill
146*7eb2d98eSJagpal Singh GillIntegration testing for generating Redfish events will be carried out using the
147*7eb2d98eSJagpal Singh Gillinventory item interface by creating and deleting cable inventory.
148