|
|
18971c |
From 1b827040f8b3e1e4fec19de76526fe0620654502 Mon Sep 17 00:00:00 2001
|
|
|
18971c |
From: Harald Hoyer <harald@redhat.com>
|
|
|
18971c |
Date: Mon, 7 Oct 2013 14:24:36 +0200
|
|
|
18971c |
Subject: [PATCH] fcoe: add FCoE UEFI boot device support
|
|
|
18971c |
|
|
|
18971c |
---
|
|
|
18971c |
modules.d/95fcoe/module-setup.sh | 1 +
|
|
|
18971c |
modules.d/95fcoe/parse-uefifcoe.sh | 35 +++++++
|
|
|
18971c |
modules.d/99base/module-setup.sh | 1 +
|
|
|
18971c |
modules.d/99base/uefi-lib.sh | 155 +++++++++++++++++++++++++++++
|
|
|
18971c |
4 files changed, 192 insertions(+)
|
|
|
18971c |
create mode 100755 modules.d/95fcoe/parse-uefifcoe.sh
|
|
|
18971c |
create mode 100755 modules.d/99base/uefi-lib.sh
|
|
|
18971c |
|
|
|
18971c |
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
|
|
|
18971c |
index d3c58cc6..08ba4eac 100755
|
|
|
18971c |
--- a/modules.d/95fcoe/module-setup.sh
|
|
|
18971c |
+++ b/modules.d/95fcoe/module-setup.sh
|
|
|
18971c |
@@ -32,6 +32,7 @@ install() {
|
|
|
18971c |
inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up"
|
|
|
18971c |
inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
|
|
|
18971c |
inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"
|
|
|
18971c |
+ inst_hook cmdline 20 "$moddir/parse-uefifcoe.sh"
|
|
|
18971c |
inst_hook cmdline 99 "$moddir/parse-fcoe.sh"
|
|
|
18971c |
dracut_need_initqueue
|
|
|
18971c |
}
|
|
|
18971c |
diff --git a/modules.d/95fcoe/parse-uefifcoe.sh b/modules.d/95fcoe/parse-uefifcoe.sh
|
|
|
18971c |
new file mode 100755
|
|
|
18971c |
index 00000000..e03bcb39
|
|
|
18971c |
--- /dev/null
|
|
|
18971c |
+++ b/modules.d/95fcoe/parse-uefifcoe.sh
|
|
|
18971c |
@@ -0,0 +1,35 @@
|
|
|
18971c |
+#!/bin/bash
|
|
|
18971c |
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
18971c |
+# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
18971c |
+
|
|
|
18971c |
+command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
|
|
18971c |
+command -v get_fcoe_boot_mac >/dev/null || . /lib/uefi-lib.sh
|
|
|
18971c |
+command -v set_ifname >/dev/null || . /lib/net-lib.sh
|
|
|
18971c |
+
|
|
|
18971c |
+print_fcoe_uefi_conf()
|
|
|
18971c |
+{
|
|
|
18971c |
+ local mac dev vlan
|
|
|
18971c |
+ mac=$(get_fcoe_boot_mac)
|
|
|
18971c |
+ [ -z "$mac" ] && continue
|
|
|
18971c |
+ dev=$(set_ifname fcoe $mac)
|
|
|
18971c |
+ vlan=$(get_fcoe_boot_vlan)
|
|
|
18971c |
+ if [ "$vlan" -ne "0" ]; then
|
|
|
18971c |
+ case "$vlan" in
|
|
|
18971c |
+ [0-9]*)
|
|
|
18971c |
+ printf "%s\n" "vlan=$dev.$vlan:$dev"
|
|
|
18971c |
+ dev="$dev.$vlan"
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ *)
|
|
|
18971c |
+ printf "%s\n" "vlan=$vlan:$dev"
|
|
|
18971c |
+ dev="$vlan"
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ esac
|
|
|
18971c |
+ fi
|
|
|
18971c |
+ # fcoe=eth0:nodcb
|
|
|
18971c |
+ printf "%s\n" "$dev:nodcb"
|
|
|
18971c |
+}
|
|
|
18971c |
+
|
|
|
18971c |
+
|
|
|
18971c |
+if [ -e /sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data ]; then
|
|
|
18971c |
+ print_fcoe_uefi_conf > /etc/cmdline.d/40-fcoe-uefi.conf
|
|
|
18971c |
+fi
|
|
|
18971c |
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
|
|
|
18971c |
index 52ce4004..d33a0fb4 100755
|
|
|
18971c |
--- a/modules.d/99base/module-setup.sh
|
|
|
18971c |
+++ b/modules.d/99base/module-setup.sh
|
|
|
18971c |
@@ -42,6 +42,7 @@ install() {
|
|
|
18971c |
mkdir -p ${initdir}/tmp
|
|
|
18971c |
|
|
|
18971c |
inst_simple "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
|
|
|
18971c |
+ inst_simple "$moddir/uefi-lib.sh" "/lib/uefi-lib.sh"
|
|
|
18971c |
|
|
|
18971c |
if ! dracut_module_included "systemd"; then
|
|
|
18971c |
inst_multiple switch_root || dfatal "Failed to install switch_root"
|
|
|
18971c |
diff --git a/modules.d/99base/uefi-lib.sh b/modules.d/99base/uefi-lib.sh
|
|
|
18971c |
new file mode 100755
|
|
|
18971c |
index 00000000..faedbac5
|
|
|
18971c |
--- /dev/null
|
|
|
18971c |
+++ b/modules.d/99base/uefi-lib.sh
|
|
|
18971c |
@@ -0,0 +1,155 @@
|
|
|
18971c |
+#!/bin/bash
|
|
|
18971c |
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
18971c |
+# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
18971c |
+#
|
|
|
18971c |
+# Copyright 2013 Red Hat, Inc. All rights reserved.
|
|
|
18971c |
+# Copyright 2013 Harald Hoyer <harald@redhat.com>
|
|
|
18971c |
+#
|
|
|
18971c |
+# This program is free software; you can redistribute it and/or modify
|
|
|
18971c |
+# it under the terms of the GNU General Public License as published by
|
|
|
18971c |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
18971c |
+# (at your option) any later version.
|
|
|
18971c |
+#
|
|
|
18971c |
+# This program is distributed in the hope that it will be useful,
|
|
|
18971c |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
18971c |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18971c |
+# GNU General Public License for more details.
|
|
|
18971c |
+#
|
|
|
18971c |
+# You should have received a copy of the GNU General Public License
|
|
|
18971c |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18971c |
+#
|
|
|
18971c |
+
|
|
|
18971c |
+getbyte () {
|
|
|
18971c |
+ local IFS= LC_CTYPE=C res c
|
|
|
18971c |
+ read -r -n 1 -d '' c
|
|
|
18971c |
+ res=$?
|
|
|
18971c |
+ # the single quote in the argument of the printf
|
|
|
18971c |
+ # yields the numeric value of $c (ASCII since LC_CTYPE=C)
|
|
|
18971c |
+ [[ -n $c ]] && c=$(printf '%u' "'$c") || c=0
|
|
|
18971c |
+ printf "$c"
|
|
|
18971c |
+ return $res
|
|
|
18971c |
+}
|
|
|
18971c |
+
|
|
|
18971c |
+getword () {
|
|
|
18971c |
+ local b1 b2 val
|
|
|
18971c |
+ b1=$(getbyte) || return 1
|
|
|
18971c |
+ b2=$(getbyte) || return 1
|
|
|
18971c |
+ (( val = b2 * 256 + b1 ))
|
|
|
18971c |
+ echo $val
|
|
|
18971c |
+ return 0
|
|
|
18971c |
+}
|
|
|
18971c |
+
|
|
|
18971c |
+# Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
|
|
|
18971c |
+uefi_device_path()
|
|
|
18971c |
+{
|
|
|
18971c |
+ local IFS= LC_CTYPE=C res tt len type hextype first
|
|
|
18971c |
+ first=1
|
|
|
18971c |
+
|
|
|
18971c |
+ while :; do
|
|
|
18971c |
+ type=$(getbyte) || return 1
|
|
|
18971c |
+ subtype=$(getbyte) || return 1
|
|
|
18971c |
+ len=$(getword) || return 1
|
|
|
18971c |
+ hextype=$(printf "%02x%02x" "$type" "$subtype")
|
|
|
18971c |
+ if [[ $first == 1 ]]; then
|
|
|
18971c |
+ first=0
|
|
|
18971c |
+ elif [[ $hextype != "7fff" ]]; then
|
|
|
18971c |
+ printf "/"
|
|
|
18971c |
+ fi
|
|
|
18971c |
+ case $hextype in
|
|
|
18971c |
+ 0101)
|
|
|
18971c |
+ # PCI
|
|
|
18971c |
+ tt=$(getword)
|
|
|
18971c |
+ printf "PCI(0x%x,0x%x)" $(($tt / 256)) $(($tt & 255))
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 0201)
|
|
|
18971c |
+ # ACPI
|
|
|
18971c |
+ printf "Acpi(0x%x,0x%x)" $(($(getword) + $(getword) * 65536)) $(($(getword) + $(getword) * 65536))
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 0303)
|
|
|
18971c |
+ # FIBRE
|
|
|
18971c |
+ getword &>/dev/null
|
|
|
18971c |
+ getword &>/dev/null
|
|
|
18971c |
+ printf "Fibre(0x%x%x%x%x%x%x%x%x,0x%x)" \
|
|
|
18971c |
+ $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
|
|
|
18971c |
+ $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
|
|
|
18971c |
+ $(( $(getword) + $(getword) * 65536 + 4294967296 * ( $(getword) + $(getword) * 65536 ) ))
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 030b)
|
|
|
18971c |
+ # MAC
|
|
|
18971c |
+ printf "MAC(%02x%02x%02x%02x%02x%02x," $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
|
|
|
18971c |
+ read -r -N 26 tt || return 1
|
|
|
18971c |
+ printf "0x%x)" $(getbyte)
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 0314)
|
|
|
18971c |
+ # VLAN
|
|
|
18971c |
+ printf "VLAN(%d)" $(getword)
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 7fff)
|
|
|
18971c |
+ # END
|
|
|
18971c |
+ printf "\n"
|
|
|
18971c |
+ return 0
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ *)
|
|
|
18971c |
+ printf "Unknown(Type:%d SubType:%d len=%d)" "$type" "$subtype" "$len"
|
|
|
18971c |
+ read -r -N $(($len-4)) tt || return 1
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ esac
|
|
|
18971c |
+ done
|
|
|
18971c |
+}
|
|
|
18971c |
+
|
|
|
18971c |
+get_fcoe_boot_mac()
|
|
|
18971c |
+{
|
|
|
18971c |
+ data=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
|
|
|
18971c |
+ [ -f $data ] || return 1
|
|
|
18971c |
+ local IFS= LC_CTYPE=C tt len type hextype
|
|
|
18971c |
+ first=1
|
|
|
18971c |
+
|
|
|
18971c |
+ while :; do
|
|
|
18971c |
+ type=$(getbyte) || return 1
|
|
|
18971c |
+ subtype=$(getbyte) || return 1
|
|
|
18971c |
+ len=$(getword) || return 1
|
|
|
18971c |
+ hextype=$(printf "%02x%02x" "$type" "$subtype")
|
|
|
18971c |
+ case $hextype in
|
|
|
18971c |
+ 030b)
|
|
|
18971c |
+ # MAC
|
|
|
18971c |
+ printf "%02x:%02x:%02x:%02x:%02x:%02x" $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
|
|
|
18971c |
+ read -r -N 27 tt || return 1
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 7fff)
|
|
|
18971c |
+ # END
|
|
|
18971c |
+ return 0
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ *)
|
|
|
18971c |
+ read -r -N $(($len-4)) tt || return 1
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ esac
|
|
|
18971c |
+ done < $data
|
|
|
18971c |
+}
|
|
|
18971c |
+
|
|
|
18971c |
+get_fcoe_boot_vlan()
|
|
|
18971c |
+{
|
|
|
18971c |
+ data=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
|
|
|
18971c |
+ [ -f $data ] || return 1
|
|
|
18971c |
+ local IFS= LC_CTYPE=C tt len type hextype
|
|
|
18971c |
+ first=1
|
|
|
18971c |
+
|
|
|
18971c |
+ while :; do
|
|
|
18971c |
+ type=$(getbyte) || return 1
|
|
|
18971c |
+ subtype=$(getbyte) || return 1
|
|
|
18971c |
+ len=$(getword) || return 1
|
|
|
18971c |
+ hextype=$(printf "%02x%02x" "$type" "$subtype")
|
|
|
18971c |
+ case $hextype in
|
|
|
18971c |
+ 0314)
|
|
|
18971c |
+ # VLAN
|
|
|
18971c |
+ printf "%d" $(getword)
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ 7fff)
|
|
|
18971c |
+ # END
|
|
|
18971c |
+ return 0
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ *)
|
|
|
18971c |
+ read -r -N $(($len-4)) tt || return 1
|
|
|
18971c |
+ ;;
|
|
|
18971c |
+ esac
|
|
|
18971c |
+ done < $data
|
|
|
18971c |
+}
|