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