From 062def2a24c108fe1c3b808973945336eadfefb7 Mon Sep 17 00:00:00 2001 From: Chris Wang Date: Wed, 10 Apr 2024 16:35:42 +0800 Subject: Setup NIC MCTP Endpoint after mctpd initialization Since NIC's Entity Manager configuration cannot store information of static EID for Yosemite4 platform, setup the NIC's MCTP Endpoint after mctpd is successfully initilized if the corresponding slot is plugged in. Change-Id: Ida647d60d7ed72897f641dd9783f0105c2a5c0d5 Signed-off-by: Delphine CC Chiu --- .../mctp/files/setup-static-endpoints.conf | 8 ++++++ .../mctp/files/setup-static-endpoints.sh | 30 ++++++++++++++++++++++ .../recipes-networking/mctp/mctp_%.bbappend | 6 +++++ 3 files changed, 44 insertions(+) create mode 100644 meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.conf create mode 100644 meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.sh diff --git a/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.conf b/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.conf new file mode 100644 index 0000000000..ad532c9a7d --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.conf @@ -0,0 +1,8 @@ +[Unit] +After=mctpd.service +Requires=mctpd.service + +[Service] +ExecStartPost=-/usr/share/mctp/setup-static-endpoints.sh +Restart=always +RestartSec=10 diff --git a/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.sh b/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.sh new file mode 100644 index 0000000000..dba9f8c060 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-networking/mctp/files/setup-static-endpoints.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Setup Endpoint for NICs, using devmem to read GPIO value since +# the gpio pin is occupied by gpio-monitor, read the value from +# gpioget is not possible. + +# Setup slot1 NIC +gpio_val=$(devmem 0x1e780088 8) +# PRSNT_NIC0 is at the 6th bit (GPIOU5), 0 means NIC is present +if [ $((gpio_val & 0x20)) -eq 0 ]; then + /usr/bin/configure-nic-mctp-endpoint.sh add 1 +fi + +# Setup slot2 & 3 NIC +gpio_val=$(devmem 0x1e780020 8) +# PRSNT_NIC1 is at the 1th bit (GPIOE0), 0 means NIC is present +if [ $((gpio_val & 0x01)) -eq 0 ]; then + /usr/bin/configure-nic-mctp-endpoint.sh add 2 +fi +# PRSNT_NIC2 is at the 2th bit (GPIOE1), 0 means NIC is present +if [ $((gpio_val & 0x02)) -eq 0 ]; then + /usr/bin/configure-nic-mctp-endpoint.sh add 3 +fi + +# Setup slot4 NIC +gpio_val=$(devmem 0x1e780078 8) +# PRSNT_NIC3 is at the 4th bit (GPIOM3), 0 means NIC is present +if [ $((gpio_val & 0x08)) -eq 0 ]; then + /usr/bin/configure-nic-mctp-endpoint.sh add 4 +fi diff --git a/meta-facebook/meta-yosemite4/recipes-networking/mctp/mctp_%.bbappend b/meta-facebook/meta-yosemite4/recipes-networking/mctp/mctp_%.bbappend index 6f8771345d..04dcac30d9 100644 --- a/meta-facebook/meta-yosemite4/recipes-networking/mctp/mctp_%.bbappend +++ b/meta-facebook/meta-yosemite4/recipes-networking/mctp/mctp_%.bbappend @@ -3,7 +3,9 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI += " \ file://setup-local-eid.conf \ + file://setup-static-endpoints.conf \ file://mctp-config.sh \ + file://setup-static-endpoints.sh \ " FILES:${PN} += "${systemd_system_unitdir}/*" @@ -14,6 +16,10 @@ do_install:append () { install -d ${D}${datadir}/mctp install -m 0644 ${WORKDIR}/setup-local-eid.conf \ ${override_dir}/setup-local-eid.conf + install -m 0644 ${WORKDIR}/setup-static-endpoints.conf \ + ${override_dir}/setup-static-endpoints.conf install -m 0755 ${WORKDIR}/mctp-config.sh \ ${D}${datadir}/mctp/ + install -m 0755 ${WORKDIR}/setup-static-endpoints.sh \ + ${D}${datadir}/mctp/ } -- cgit v1.2.3