blob: 73fe8f2de84207a41bee78ca981c952e1b21355f [file] [log] [blame]
Jonathan Doman1cf66fe2023-03-09 12:28:21 -08001#!/bin/sh
Jonathan Doman94c94bf2020-10-05 23:25:45 -07002
3# Utility to print all SST data present on D-Bus.
4# Simply searches for all objects implementing known interfaces and prints out
5# the property values on those interfaces.
6
Jonathan Doman703a1852020-11-11 13:04:02 -08007set -e
8
Jonathan Doman94c94bf2020-10-05 23:25:45 -07009BUSCTL='busctl'
10XYZ='xyz.openbmc_project'
Jonathan Doman94c94bf2020-10-05 23:25:45 -070011CPU_INTF="$XYZ.Control.Processor.CurrentOperatingConfig"
12CONFIG_INTF="$XYZ.Inventory.Item.Cpu.OperatingConfig"
13
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080014trim_quotes() {
Jonathan Doman94c94bf2020-10-05 23:25:45 -070015 trim_obj=${1%\"}
16 trim_obj=${trim_obj#\"}
Patrick Williams3e6be2e2022-12-04 15:46:55 -060017 echo "$trim_obj"
Jonathan Doman94c94bf2020-10-05 23:25:45 -070018}
19
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080020object_mapper_call() {
21 $BUSCTL call $XYZ.ObjectMapper /xyz/openbmc_project/object_mapper \
22 $XYZ.ObjectMapper "$@"
23}
24
25get_sub_tree_paths() {
26 resp=$(object_mapper_call GetSubTreePaths sias "$1" 0 "$2" "$3" \
Patrick Williams306df482022-12-08 06:26:05 -060027 | cut -d' ' -f3-)
Jonathan Doman94c94bf2020-10-05 23:25:45 -070028 for obj in $resp
29 do
Patrick Williams3e6be2e2022-12-04 15:46:55 -060030 trim_quotes "$obj"
Jonathan Doman94c94bf2020-10-05 23:25:45 -070031 done
32}
33
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080034get_service_from_object() {
35 trim_quotes "$(object_mapper_call GetObject sas "$1" "$2" "$3" \
Patrick Williams3e6be2e2022-12-04 15:46:55 -060036 | cut -d' ' -f3)"
Jonathan Doman94c94bf2020-10-05 23:25:45 -070037}
38
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080039get_property_names() {
Jonathan Doman94c94bf2020-10-05 23:25:45 -070040 service=$1
41 object=$2
42 intf=$3
Patrick Williams3e6be2e2022-12-04 15:46:55 -060043 $BUSCTL introspect "$service" "$object" "$intf" \
Jonathan Doman94c94bf2020-10-05 23:25:45 -070044 | awk '/property/ {print substr($1, 2)}'
45}
46
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080047get_property() {
Jonathan Doman94c94bf2020-10-05 23:25:45 -070048 service=$1
49 object=$2
50 intf=$3
51 prop=$4
Patrick Williams3e6be2e2022-12-04 15:46:55 -060052 $BUSCTL get-property "$service" "$object" "$intf" "$prop"
Jonathan Doman94c94bf2020-10-05 23:25:45 -070053}
54
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080055set_property() {
Jonathan Doman703a1852020-11-11 13:04:02 -080056 service=$1
57 object=$2
58 intf=$3
59 prop=$4
60 signature=$5
61 value=$6
Patrick Williams3e6be2e2022-12-04 15:46:55 -060062 $BUSCTL set-property "$service" "$object" "$intf" "$prop" \
63 "$signature" "$value"
Jonathan Doman703a1852020-11-11 13:04:02 -080064}
Jonathan Doman94c94bf2020-10-05 23:25:45 -070065
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080066show() {
Jonathan Doman703a1852020-11-11 13:04:02 -080067 cpu_paths=$(get_sub_tree_paths "/" 1 "$CPU_INTF")
68 for cpu_path in $cpu_paths
Jonathan Doman94c94bf2020-10-05 23:25:45 -070069 do
Patrick Williams3e6be2e2022-12-04 15:46:55 -060070 service=$(get_service_from_object "$cpu_path" 1 "$CPU_INTF")
Jonathan Doman703a1852020-11-11 13:04:02 -080071 echo "Found SST on $cpu_path on $service"
Patrick Williams3e6be2e2022-12-04 15:46:55 -060072 for prop in $(get_property_names "$service" "$cpu_path" "$CPU_INTF")
Jonathan Doman94c94bf2020-10-05 23:25:45 -070073 do
Patrick Williams3e6be2e2022-12-04 15:46:55 -060074 echo " $prop: $(get_property "$service" "$cpu_path" "$CPU_INTF" "$prop")"
Jonathan Doman703a1852020-11-11 13:04:02 -080075 done
76
Jonathan Doman703a1852020-11-11 13:04:02 -080077 profiles=$(get_sub_tree_paths "$cpu_path" 1 "$CONFIG_INTF")
78 for profile in $profiles
79 do
80 echo
81 echo " Found Profile $profile"
Patrick Williams3e6be2e2022-12-04 15:46:55 -060082 for prop in $(get_property_names "$service" "$profile" "$CONFIG_INTF")
Jonathan Doman703a1852020-11-11 13:04:02 -080083 do
Patrick Williams3e6be2e2022-12-04 15:46:55 -060084 echo " $prop: $(get_property "$service" "$profile" "$CONFIG_INTF" "$prop")"
Jonathan Doman703a1852020-11-11 13:04:02 -080085 done
Jonathan Doman94c94bf2020-10-05 23:25:45 -070086 done
87 done
Jonathan Doman703a1852020-11-11 13:04:02 -080088}
89
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080090set_cpu_prop() {
Jonathan Doman703a1852020-11-11 13:04:02 -080091 cpu_basename=$1
92 prop=$2
93 signature=$3
94 value=$4
95
Jonathan Doman703a1852020-11-11 13:04:02 -080096 cpu_paths=$(get_sub_tree_paths "/" 1 "$CPU_INTF")
97 for cpu_path in $cpu_paths
98 do
Jonathan Doman1cf66fe2023-03-09 12:28:21 -080099 case $cpu_path in
100 */$cpu_basename) ;;
101 *) continue ;;
102 esac
Jonathan Doman703a1852020-11-11 13:04:02 -0800103
Jonathan Doman1cf66fe2023-03-09 12:28:21 -0800104 if [ "$prop" = "AppliedConfig" ]
Jonathan Doman703a1852020-11-11 13:04:02 -0800105 then
106 value=$cpu_path/$value
107 fi
108
Patrick Williams3e6be2e2022-12-04 15:46:55 -0600109 service=$(get_service_from_object "$cpu_path" 1 "$CPU_INTF")
110 set_property "$service" "$cpu_path" "$CPU_INTF" "$prop" "$signature" "$value"
Jonathan Doman703a1852020-11-11 13:04:02 -0800111 return 0
112 done
113
114 echo "$cpu_basename not found"
115 return 1
116}
117
Jonathan Doman1cf66fe2023-03-09 12:28:21 -0800118if [ "${DEBUG:=0}" -eq 1 ]
Jonathan Doman703a1852020-11-11 13:04:02 -0800119then
120 set -x
121fi
122
123action=${1:-show}
124
125case "$action" in
126 show) show ;;
Patrick Williams3e6be2e2022-12-04 15:46:55 -0600127 set-config) set_cpu_prop "$2" AppliedConfig o "$3" ;;
128 set-bf) set_cpu_prop "$2" BaseSpeedPriorityEnabled b "$3" ;;
Jonathan Doman703a1852020-11-11 13:04:02 -0800129 *)
130 echo "Usage:"
131 echo "$0 (show|set-config|set-bf) [ARGS...]"
132 echo ""
133 echo "show (Default action) - show info"
134 echo "set-config cpuN configM - Set applied operating config for cpuN to configM"
135 echo "set-bf cpuN val - Set SST-BF enablement for cpuN to val (boolean)"
136 ;;
137esac