From da422760f1e3e7ef508df484cbb25c1e88b91313 Mon Sep 17 00:00:00 2001 From: Chris Wang Date: Thu, 2 May 2024 14:25:15 +0800 Subject: meta-facebook: yosemite4: Control NIC main/aux mode Support NIC 1 switch to main mode when one of slot1 or slot2 Host's ACPI power status reach to S3. NIC 2 targets to slot3 and slot4, NIC 3 targets to slot5 and slot6, etc. Support NIC 1 switch to aux mode when slot1 and slot2 Host's ACPI power status are S4. NIC 3 targets to slot3 and slot4, NIC 3 targets to slot5 and slot6, etc. Tested: - Power off corresponding Hosts and check the NIC's power status. - Power on one of the corresponding Host and check the NIC's power status. - All NICs have been tested. Change-Id: I2e76ce3d18f81328789bb9a5d5be4025832b21e7 Signed-off-by: Delphine CC Chiu --- .../dbus/phosphor-dbus-monitor-config.bbappend | 1 + .../switch-nic-main-or-aux-mode | 34 ++++++++++ .../switch-nic-to-aux-mode@.service | 7 ++ .../switch-nic-to-main-mode@.service | 7 ++ .../dbus/phosphor-dbus-monitor_%.bbappend | 17 +++++ .../recipes-phosphor/dbus/power-saving-policy.bb | 31 +++++++++ .../dbus/power-saving-policy/nic-1.yaml | 79 ++++++++++++++++++++++ .../dbus/power-saving-policy/nic-2.yaml | 79 ++++++++++++++++++++++ .../dbus/power-saving-policy/nic-3.yaml | 79 ++++++++++++++++++++++ .../dbus/power-saving-policy/nic-4.yaml | 79 ++++++++++++++++++++++ .../images/fb-yosemite4-phosphor-image.inc | 4 ++ 11 files changed, 417 insertions(+) create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor-config.bbappend create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-aux-mode@.service create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-main-mode@.service create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor_%.bbappend create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy.bb create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-1.yaml create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-2.yaml create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-3.yaml create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-4.yaml diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor-config.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor-config.bbappend new file mode 100644 index 0000000000..860e605e9c --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor-config.bbappend @@ -0,0 +1 @@ +PHOSPHOR_DBUS_MONITOR_CONFIGS:append = " power-saving-policy" diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode new file mode 100644 index 0000000000..d82733e5e1 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +SLOT=$1 +MODE=$2 +GPIO_CHIP=$(basename "/sys/bus/i2c/devices/28-0024/"*gpiochip*) + +if [ "$MODE" = "main" ] +then + gpio_val=1 +elif [ "$MODE" = "aux" ] +then + gpio_val=0 +else + echo "Mode must be either main or aux instead of \"$MODE\"." + exit 255 +fi + +if test -z "$SLOT" +then + echo "Slot number(1st parameter) is required." + exit 255 +elif [ "$SLOT" -gt 4 ] +then + echo "Slot number must between 1~4." + exit 255 +fi + +# nic1~4 = gpio pin 4~7 +gpio_pin=$(( SLOT + 3 )) + +gpioset "$GPIO_CHIP" $gpio_pin=$gpio_val + +exit 0 diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-aux-mode@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-aux-mode@.service new file mode 100644 index 0000000000..f6189881d1 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-aux-mode@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Switch nic %i to aux mode + +[Service] +Type=oneshot +ExecStart=switch-nic-main-or-aux-mode %i aux + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-main-mode@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-main-mode@.service new file mode 100644 index 0000000000..d46859156c --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-to-main-mode@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Switch nic %i to main mode + +[Service] +Type=oneshot +ExecStart=switch-nic-main-or-aux-mode %i main + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor_%.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor_%.bbappend new file mode 100644 index 0000000000..4da9e510bd --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor_%.bbappend @@ -0,0 +1,17 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +inherit obmc-phosphor-systemd + +SRC_URI:append = " \ + file://switch-nic-main-or-aux-mode \ +" + +SYSTEMD_SERVICE:${PN}:append = " \ + switch-nic-to-aux-mode@.service \ + switch-nic-to-main-mode@.service \ +" + +do_install:append() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/switch-nic-main-or-aux-mode ${D}${bindir}/switch-nic-main-or-aux-mode +} diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy.bb b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy.bb new file mode 100644 index 0000000000..6855fe0e4f --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy.bb @@ -0,0 +1,31 @@ +SUMMARY = "Power saving policy configurations for meta-yosemite4 machines" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit allarch +inherit phosphor-dbus-monitor + +FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" + +SRC_URI:append = " \ + file://nic-1.yaml \ + file://nic-2.yaml \ + file://nic-3.yaml \ + file://nic-4.yaml \ +" + +do_install() { + install -D ${WORKDIR}/nic-1.yaml ${D}${config_dir}/nic-1.yaml + install -D ${WORKDIR}/nic-2.yaml ${D}${config_dir}/nic-2.yaml + install -D ${WORKDIR}/nic-3.yaml ${D}${config_dir}/nic-3.yaml + install -D ${WORKDIR}/nic-4.yaml ${D}${config_dir}/nic-4.yaml +} + +FILES:${PN}:append = " \ + ${config_dir}/nic-1.yaml \ + ${config_dir}/nic-2.yaml \ + ${config_dir}/nic-3.yaml \ + ${config_dir}/nic-4.yaml \ +" + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-1.yaml b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-1.yaml new file mode 100644 index 0000000000..827e6898ef --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-1.yaml @@ -0,0 +1,79 @@ +- name: nic 1 current host state path group + class: group + group: path + members: + - meta: PATH + path: /xyz/openbmc_project/state/host1 + - meta: PATH + path: /xyz/openbmc_project/state/host2 + +- name: current host state property + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.State.Host + meta: PROPERTY + property: CurrentHostState + +- name: nic 1 main mode monitor + class: watch + watch: property + paths: nic 1 current host state path group + properties: current host state property + callback: check if fulfill nic main mode requirement + +- name: nic 1 aux mode monitor + class: watch + watch: property + paths: nic 1 current host state path group + properties: current host state property + callback: check if fulfill nic aux mode requirement + +- name: check if fulfill nic main mode requirement + class: condition + condition: count + paths: nic 1 current host state path group + properties: current host state property + callback: switch nic 1 to main mode + countop: ">=" + countbound: 1 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Running + +- name: check if fulfill nic aux mode requirement + class: condition + condition: count + paths: nic 1 current host state path group + properties: current host state property + callback: switch nic 1 to aux mode + countop: "==" + countbound: 2 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Off + +- name: switch nic 1 to main mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-main-mode@1.service + type: string + - value: replace + type: string + +- name: switch nic 1 to aux mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-aux-mode@1.service + type: string + - value: replace + type: string diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-2.yaml b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-2.yaml new file mode 100644 index 0000000000..823f71a611 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-2.yaml @@ -0,0 +1,79 @@ +- name: nic 2 current host state path group + class: group + group: path + members: + - meta: PATH + path: /xyz/openbmc_project/state/host3 + - meta: PATH + path: /xyz/openbmc_project/state/host4 + +- name: current host state property + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.State.Host + meta: PROPERTY + property: CurrentHostState + +- name: nic 2 main mode monitor + class: watch + watch: property + paths: nic 2 current host state path group + properties: current host state property + callback: check if fulfill nic main mode requirement + +- name: nic 2 aux mode monitor + class: watch + watch: property + paths: nic 2 current host state path group + properties: current host state property + callback: check if fulfill nic aux mode requirement + +- name: check if fulfill nic main mode requirement + class: condition + condition: count + paths: nic 2 current host state path group + properties: current host state property + callback: switch nic 2 to main mode + countop: ">=" + countbound: 1 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Running + +- name: check if fulfill nic aux mode requirement + class: condition + condition: count + paths: nic 2 current host state path group + properties: current host state property + callback: switch nic 2 to aux mode + countop: "==" + countbound: 2 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Off + +- name: switch nic 2 to main mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-main-mode@2.service + type: string + - value: replace + type: string + +- name: switch nic 2 to aux mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-aux-mode@2.service + type: string + - value: replace + type: string diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-3.yaml b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-3.yaml new file mode 100644 index 0000000000..7b207a80e4 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-3.yaml @@ -0,0 +1,79 @@ +- name: nic 3 current host state path group + class: group + group: path + members: + - meta: PATH + path: /xyz/openbmc_project/state/host5 + - meta: PATH + path: /xyz/openbmc_project/state/host6 + +- name: current host state property + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.State.Host + meta: PROPERTY + property: CurrentHostState + +- name: nic 3 main mode monitor + class: watch + watch: property + paths: nic 3 current host state path group + properties: current host state property + callback: check if fulfill nic main mode requirement + +- name: nic 3 aux mode monitor + class: watch + watch: property + paths: nic 3 current host state path group + properties: current host state property + callback: check if fulfill nic aux mode requirement + +- name: check if fulfill nic main mode requirement + class: condition + condition: count + paths: nic 3 current host state path group + properties: current host state property + callback: switch nic 3 to main mode + countop: ">=" + countbound: 1 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Running + +- name: check if fulfill nic aux mode requirement + class: condition + condition: count + paths: nic 3 current host state path group + properties: current host state property + callback: switch nic 3 to aux mode + countop: "==" + countbound: 2 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Off + +- name: switch nic 3 to main mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-main-mode@3.service + type: string + - value: replace + type: string + +- name: switch nic 3 to aux mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-aux-mode@3.service + type: string + - value: replace + type: string diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-4.yaml b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-4.yaml new file mode 100644 index 0000000000..df8bd42e18 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/power-saving-policy/nic-4.yaml @@ -0,0 +1,79 @@ +- name: nic 4 current host state path group + class: group + group: path + members: + - meta: PATH + path: /xyz/openbmc_project/state/host7 + - meta: PATH + path: /xyz/openbmc_project/state/host8 + +- name: current host state property + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.State.Host + meta: PROPERTY + property: CurrentHostState + +- name: nic 4 main mode monitor + class: watch + watch: property + paths: nic 4 current host state path group + properties: current host state property + callback: check if fulfill nic main mode requirement + +- name: nic 4 aux mode monitor + class: watch + watch: property + paths: nic 4 current host state path group + properties: current host state property + callback: check if fulfill nic aux mode requirement + +- name: check if fulfill nic main mode requirement + class: condition + condition: count + paths: nic 4 current host state path group + properties: current host state property + callback: switch nic 4 to main mode + countop: ">=" + countbound: 1 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Running + +- name: check if fulfill nic aux mode requirement + class: condition + condition: count + paths: nic 4 current host state path group + properties: current host state property + callback: switch nic 4 to aux mode + countop: "==" + countbound: 2 + op: "==" + bound: xyz.openbmc_project.State.Host.HostState.Off + +- name: switch nic 4 to main mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-main-mode@4.service + type: string + - value: replace + type: string + +- name: switch nic 4 to aux mode + class: callback + callback: method + service: org.freedesktop.systemd1 + path: /org/freedesktop/systemd1 + interface: org.freedesktop.systemd1.Manager + method: StartUnit + args: + - value: switch-nic-to-aux-mode@4.service + type: string + - value: replace + type: string diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/images/fb-yosemite4-phosphor-image.inc b/meta-facebook/meta-yosemite4/recipes-phosphor/images/fb-yosemite4-phosphor-image.inc index 79d109ca7c..fe7a36754d 100644 --- a/meta-facebook/meta-yosemite4/recipes-phosphor/images/fb-yosemite4-phosphor-image.inc +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/images/fb-yosemite4-phosphor-image.inc @@ -22,3 +22,7 @@ OBMC_IMAGE_EXTRA_INSTALL:append = " \ phosphor-gpio-monitor \ " +# This enables the feature of dbus-monitor which defined in +# `meta-phosphor/classes/obmc-phosphor-images.bbclass` +IMAGE_FEATURES:append = " obmc-dbus-monitor" + -- cgit v1.2.3