18971c
From d02f522089863af2a802cef9e63965349bfcc819 Mon Sep 17 00:00:00 2001
18971c
From: Chris Leech <cleech@redhat.com>
18971c
Date: Fri, 3 Jul 2015 13:40:12 +0200
18971c
Subject: [PATCH] fcoe: start with fcoemon instead of fipvlan
18971c
18971c
---
18971c
 modules.d/95fcoe/fcoe-up.sh      | 30 ++++++++++++++++++++++++++++--
18971c
 modules.d/95fcoe/module-setup.sh |  7 +++++--
18971c
 modules.d/95fcoe/parse-fcoe.sh   |  4 ++--
18971c
 3 files changed, 35 insertions(+), 6 deletions(-)
18971c
18971c
diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh
18971c
index edbfcc84..823d7acc 100755
18971c
--- a/modules.d/95fcoe/fcoe-up.sh
18971c
+++ b/modules.d/95fcoe/fcoe-up.sh
18971c
@@ -20,12 +20,28 @@ type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
18971c
 
18971c
 netif=$1
18971c
 dcb=$2
18971c
+vlan="yes"
18971c
 
18971c
 linkup "$netif"
18971c
 
18971c
 netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
18971c
 netdriver=${netdriver##*/}
18971c
 
18971c
+write_fcoemon_cfg() {
18971c
+    echo FCOE_ENABLE=\"yes\" > /etc/fcoe/cfg-$netif
18971c
+    if [ "$dcb" = "dcb" ]; then
18971c
+        echo DCB_REQUIRED=\"yes\" >> /etc/fcoe/cfg-$netif
18971c
+    else
18971c
+        echo DCB_REQUIRED=\"no\" >> /etc/fcoe/cfg-$netif
18971c
+    fi
18971c
+    if [ "$vlan" = "yes" ]; then
18971c
+	    echo AUTO_VLAN=\"yes\" >> /etc/fcoe/cfg-$netif
18971c
+    else
18971c
+	    echo AUTO_VLAN=\"no\" >> /etc/fcoe/cfg-$netif
18971c
+    fi
18971c
+    echo MODE=\"fabric\" >> /etc/fcoe/cfg-$netif
18971c
+}
18971c
+
18971c
 if [ "$dcb" = "dcb" ]; then
18971c
     # Note lldpad will stay running after switchroot, the system initscripts
18971c
     # are to kill it and start a new lldpad to take over. Data is transfered
18971c
@@ -51,6 +67,13 @@ if [ "$dcb" = "dcb" ]; then
18971c
         i=$(($i+1))
18971c
     done
18971c
 
18971c
+    while [ $i -lt 60 ]; do
18971c
+        dcbtool sc "$netif" pfc e:1 a:1 w:1 && break
18971c
+        info "Retrying to turn dcb on"
18971c
+        sleep 1
18971c
+        i=$(($i+1))
18971c
+    done
18971c
+
18971c
     while [ $i -lt 60 ]; do
18971c
         dcbtool sc "$netif" app:fcoe e:1 a:1 w:1 && break
18971c
         info "Retrying to turn fcoe on"
18971c
@@ -60,7 +83,8 @@ if [ "$dcb" = "dcb" ]; then
18971c
 
18971c
     sleep 1
18971c
 
18971c
-    fipvlan "$netif" -c -s
18971c
+    write_fcoemon_cfg
18971c
+    fcoemon --syslog
18971c
 elif [ "$netdriver" = "bnx2x" ]; then
18971c
     # If driver is bnx2x, do not use /sys/module/fcoe/parameters/create but fipvlan
18971c
     modprobe 8021q
18971c
@@ -69,7 +93,9 @@ elif [ "$netdriver" = "bnx2x" ]; then
18971c
     sleep 3
18971c
     fipvlan "$netif" -c -s
18971c
 else
18971c
-    echo -n "$netif" > /sys/module/fcoe/parameters/create
18971c
+    vlan="no"
18971c
+    write_fcoemon_cfg
18971c
+    fcoemon --syslog
18971c
 fi
18971c
 
18971c
 need_shutdown
18971c
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
18971c
index 8c6290d4..ec573ea0 100755
18971c
--- a/modules.d/95fcoe/module-setup.sh
18971c
+++ b/modules.d/95fcoe/module-setup.sh
18971c
@@ -3,7 +3,7 @@
18971c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
 
18971c
 check() {
18971c
-    require_binaries dcbtool fipvlan lldpad ip readlink || return 1
18971c
+    require_binaries dcbtool fipvlan lldpad ip readlink fcoemon fcoeadm || return 1
18971c
     return 0
18971c
 }
18971c
 
18971c
@@ -17,9 +17,12 @@ installkernel() {
18971c
 }
18971c
 
18971c
 install() {
18971c
-    inst_multiple ip dcbtool fipvlan lldpad readlink lldptool
18971c
+    inst_multiple ip dcbtool fipvlan lldpad readlink lldptool fcoemon fcoeadm
18971c
+    inst_libdir_file 'libhbalinux.so*'
18971c
+    inst "/etc/hba.conf" "/etc/hba.conf"
18971c
 
18971c
     mkdir -m 0755 -p "$initdir/var/lib/lldpad"
18971c
+    mkdir -m 0755 -p "$initdir/etc/fcoe"
18971c
 
18971c
     inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up"
18971c
     inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
18971c
diff --git a/modules.d/95fcoe/parse-fcoe.sh b/modules.d/95fcoe/parse-fcoe.sh
18971c
index dc40c825..7eca0b6c 100755
18971c
--- a/modules.d/95fcoe/parse-fcoe.sh
18971c
+++ b/modules.d/95fcoe/parse-fcoe.sh
18971c
@@ -22,13 +22,13 @@
18971c
 
18971c
 
18971c
 # BRCM: Later, should check whether bnx2x is loaded first before loading bnx2fc so do not load bnx2fc when there are no Broadcom adapters
18971c
-[ -e /sys/module/fcoe/parameters/create ] || modprobe -a fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
18971c
+[ -e /sys/bus/fcoe/ctlr_create ] || modprobe -a fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
18971c
 
18971c
 modprobe bnx2fc >/dev/null 2>&1
18971c
 udevadm settle --timeout=30
18971c
 
18971c
 # FCoE actually supported?
18971c
-[ -e /sys/module/fcoe/parameters/create ] || modprobe fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
18971c
+[ -e /sys/bus/fcoe/ctlr_create ] || modprobe fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
18971c
 
18971c
 parse_fcoe_opts() {
18971c
     local IFS=: