summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaptor Engineering Development Team <support@raptorengineering.com>2020-02-19 02:37:54 +0000
committerRaptor Engineering Development Team <support@raptorengineering.com>2020-02-19 02:59:03 +0000
commit1752ac31124e59dca0423886cec32e7bcea6f228 (patch)
tree07330902af5b4c21778284d30fb46fc66d1c6b03
parentd639e6bc2171683738415b07df6e6b4739a3c54e (diff)
downloadtalos-openbmc-1752ac31124e59dca0423886cec32e7bcea6f228.tar.gz
talos-openbmc-1752ac31124e59dca0423886cec32e7bcea6f228.zip
Add JSNBD hooks for ASpeed virtual media
Backport of upstream version
-rwxr-xr-xmeta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd/state_hook68
-rw-r--r--meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd_git.bbappend9
2 files changed, 77 insertions, 0 deletions
diff --git a/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd/state_hook b/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd/state_hook
new file mode 100755
index 000000000..0df6ff973
--- /dev/null
+++ b/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd/state_hook
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]
+then
+ echo "usage: $0 <start|stop> <config>" >&2
+ exit 1
+fi
+
+action=$1
+config=$2
+
+gadget_name=mass-storage
+gadget_dir=/sys/kernel/config/usb_gadget/$gadget_name
+
+case "$config" in
+0)
+ nbd_device=/dev/nbd0
+ ;;
+*)
+ echo "invalid config $config" >&2
+ exit 1
+ ;;
+esac
+
+set -ex
+
+case "$action" in
+start)
+ mkdir -p $gadget_dir
+ (
+ cd $gadget_dir
+ # http://www.linux-usb.org/usb.ids
+ # |-> 1d6b Linux Foundation
+ # |-> 0104 Multifunction Composite Gadget
+ echo "0x1d6b" > idVendor
+ echo "0x0104" > idProduct
+ mkdir -p strings/0x409
+ echo "OpenBMC" > strings/0x409/manufacturer
+ echo "Virtual Media Device" > strings/0x409/product
+ mkdir -p configs/c.1/strings/0x409
+ echo "config 1" > configs/c.1/strings/0x409/configuration
+ mkdir -p functions/mass_storage.usb0
+ ln -s functions/mass_storage.usb0 configs/c.1
+ echo 1 > functions/mass_storage.usb0/lun.0/removable
+ echo 1 > functions/mass_storage.usb0/lun.0/ro
+ echo 0 > functions/mass_storage.usb0/lun.0/cdrom
+ echo $nbd_device > functions/mass_storage.usb0/lun.0/file
+ echo "1e6a0000.usb-vhub:p4" > UDC
+ )
+ ;;
+stop)
+ (
+ cd $gadget_dir
+ rm configs/c.1/mass_storage.usb0
+ rmdir functions/mass_storage.usb0
+ rmdir configs/c.1/strings/0x409
+ rmdir configs/c.1
+ rmdir strings/0x409
+ )
+ rmdir $gadget_dir
+ ;;
+*)
+ echo "invalid action $action" >&2
+ exit 1
+esac
+
+exit 0
+
diff --git a/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd_git.bbappend b/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd_git.bbappend
new file mode 100644
index 000000000..3ccc08798
--- /dev/null
+++ b/meta-phosphor/aspeed-layer/recipes-connectivity/jsnbd/jsnbd_git.bbappend
@@ -0,0 +1,9 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+FILES_${PN} += "${sysconfdir}/nbd-proxy/state"
+SRC_URI += "file://state_hook"
+
+do_install_append() {
+ install -d ${D}${sysconfdir}/nbd-proxy/
+ install -m 0755 ${WORKDIR}/state_hook ${D}${sysconfdir}/nbd-proxy/state
+}
OpenPOWER on IntegriCloud