From 0598b574e8a02209ba089c9bfadd6c5a9cc0b3b0 Mon Sep 17 00:00:00 2001 From: Chris Wang Date: Tue, 12 Mar 2024 17:29:15 +0800 Subject: meta-facebook: yosemite4: Support NIC endpoint setup Setup the MCTP Endpoint for the NIC when inserted. Remove the MCTP Endpoint for the NIC when unplugged. Change-Id: I0c36cecda6509a64e4f26c70bf61590467571a7b Signed-off-by: Delphine CC Chiu --- .../configure-nic-mctp-endpoint.sh | 20 ++++++++++++++++++ .../remove-nic-endpoint-slot@.service | 8 ++++++++ .../setup-nic-endpoint-slot@.service | 8 ++++++++ .../yosemite4-phosphor-multi-gpio-monitor.json | 24 ++++++++++++++-------- .../gpio/phosphor-gpio-monitor_%.bbappend | 9 ++++++++ 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/configure-nic-mctp-endpoint.sh create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/remove-nic-endpoint-slot@.service create mode 100644 meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/setup-nic-endpoint-slot@.service (limited to 'meta-facebook/meta-yosemite4/recipes-phosphor/gpio') diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/configure-nic-mctp-endpoint.sh b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/configure-nic-mctp-endpoint.sh new file mode 100644 index 0000000000..b2036bc5f0 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/configure-nic-mctp-endpoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This script is a backup solution for setting up/removing MCTP endpoint for NICs +action=$1 +slot=$2 +# NIC bus are 24~27. +bus=$((23 + slot)) +# Static EID for NIC are 90~93. +eid=$((89 + slot)) + +sleep 2 + +if [ "$action" = "add" ]; then + echo "Adding MCTP endpoint for slot $slot" + busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp au.com.CodeConstruct.MCTP AssignEndpointStatic sayy "mctpi2c${bus}" 1 0x32 "$eid" +elif [ "$action" = "remove" ]; then + echo "Removing MCTP endpoint for slot $slot" + busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/1/${eid} au.com.CodeConstruct.MCTP.Endpoint Remove +fi + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/remove-nic-endpoint-slot@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/remove-nic-endpoint-slot@.service new file mode 100644 index 0000000000..d16ba2f44f --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/remove-nic-endpoint-slot@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Remove MCTP endpoint for Slot%i NIC + +[Service] +Type=oneshot +ExecStart=/usr/bin/configure-nic-mctp-endpoint.sh remove %i +SyslogIdentifier=remove-nic-endpoint-slot%i + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/setup-nic-endpoint-slot@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/setup-nic-endpoint-slot@.service new file mode 100644 index 0000000000..db06940930 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/setup-nic-endpoint-slot@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Setup MCTP endpoint for Slot%i NIC + +[Service] +Type=oneshot +ExecStart=/usr/bin/configure-nic-mctp-endpoint.sh add %i +SyslogIdentifier=setup-nic-endpoint-slot%i + diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json index 87073889fa..925719c0d5 100644 --- a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json @@ -101,11 +101,13 @@ "Name": "PRSNT_NIC0_N", "ChipId": "0", "GpioNum": 165, - "EventMon": "FALLING", + "EventMon": "BOTH", "Targets": { + "RISING": ["remove-nic-endpoint-slot@1.service"], "FALLING": [ "obmc-chassis-powercycle@1.target", - "obmc-chassis-powercycle@2.target" + "obmc-chassis-powercycle@2.target", + "setup-nic-endpoint-slot@1.service" ] }, "Continue": true @@ -114,11 +116,13 @@ "Name": "PRSNT_NIC1_N", "ChipId": "0", "GpioNum": 32, - "EventMon": "FALLING", + "EventMon": "BOTH", "Targets": { + "RISING": ["remove-nic-endpoint-slot@2.service"], "FALLING": [ "obmc-chassis-powercycle@3.target", - "obmc-chassis-powercycle@4.target" + "obmc-chassis-powercycle@4.target", + "setup-nic-endpoint-slot@2.service" ] }, "Continue": true @@ -127,11 +131,13 @@ "Name": "PRSNT_NIC2_N", "ChipId": "0", "GpioNum": 33, - "EventMon": "FALLING", + "EventMon": "BOTH", "Targets": { + "RISING": ["remove-nic-endpoint-slot@3.service"], "FALLING": [ "obmc-chassis-powercycle@5.target", - "obmc-chassis-powercycle@6.target" + "obmc-chassis-powercycle@6.target", + "setup-nic-endpoint-slot@3.service" ] }, "Continue": true @@ -140,11 +146,13 @@ "Name": "PRSNT_NIC3_N", "ChipId": "0", "GpioNum": 99, - "EventMon": "FALLING", + "EventMon": "BOTH", "Targets": { + "RISING": ["remove-nic-endpoint-slot@3.service"], "FALLING": [ "obmc-chassis-powercycle@7.target", - "obmc-chassis-powercycle@8.target" + "obmc-chassis-powercycle@8.target", + "setup-nic-endpoint-slot@4.service" ] }, "Continue": true diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend index 135d8e7f75..9033632150 100644 --- a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend @@ -3,6 +3,9 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" inherit obmc-phosphor-systemd systemd SRC_URI += "file://yosemite4-phosphor-multi-gpio-monitor.json \ + file://configure-nic-mctp-endpoint.sh \ + file://setup-nic-endpoint-slot@.service \ + file://remove-nic-endpoint-slot@.service \ file://set-button-sled.service \ file://probe-slot-device@.service \ file://probe-slot-device \ @@ -20,6 +23,8 @@ SYSTEMD_SERVICE:${PN} += " \ probe-slot-device@.service \ rescan-fru-device@.service \ slot-hot-plug@.service \ + setup-nic-endpoint-slot@.service \ + remove-nic-endpoint-slot@.service \ " SYSTEMD_AUTO_ENABLE = "enable" @@ -32,7 +37,11 @@ do_install:append:() { install -m 0644 ${WORKDIR}/probe-slot-device@.service ${D}${systemd_system_unitdir}/probe-slot-device@.service install -m 0644 ${WORKDIR}/rescan-fru-device@.service ${D}${systemd_system_unitdir}/rescan-fru-device@.service install -m 0644 ${WORKDIR}/slot-hot-plug@.service ${D}${systemd_system_unitdir}/slot-hot-plug@.service + install -m 0644 ${WORKDIR}/setup-nic-endpoint-slot@.service ${D}${systemd_system_unitdir}/ + install -m 0644 ${WORKDIR}/remove-nic-endpoint-slot@.service ${D}${systemd_system_unitdir}/ install -d ${D}${libexecdir}/${PN} install -m 0755 ${WORKDIR}/probe-slot-device ${D}${libexecdir}/${PN}/ install -m 0755 ${WORKDIR}/rescan-fru-device ${D}${libexecdir}/${PN}/ + install -d ${D}/${bindir} + install -m 0755 ${WORKDIR}/configure-nic-mctp-endpoint.sh ${D}/${bindir}/ } -- cgit v1.2.3