File 0217-95fcoe-Allow-to-specify-the-FCoE-mode-via-the-fcoe-p.patch of Package dracut.16003

From 77a524b3659529b14abfdb574094b92216b59af5 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 24 Aug 2016 08:32:04 +0200
Subject: [PATCH] 95fcoe: Allow to specify the FCoE mode via the fcoe=
 parameter

FCoE can run in Fabric (ie FCF) or VN2VN mode, so we should allowing
to set this parameter from the commandline, too.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 dracut.cmdline.7.asc              |  8 +++++---
 modules.d/95fcoe/fcoe-genrules.sh |  4 ++--
 modules.d/95fcoe/fcoe-up.sh       |  9 +++++++--
 modules.d/95fcoe/module-setup.sh  |  8 +++++++-
 modules.d/95fcoe/parse-fcoe.sh    | 22 ++++++++++++++++++----
 5 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index 7368aa1..b885946 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -746,10 +746,12 @@ iscsistart -b --param node.session.timeo.replacement_timeout=30
 
 FCoE
 ~~~~
-**fcoe=**__<edd|interface|MAC>__:__{dcb|nodcb}__::
+**fcoe=**__<edd|interface|MAC>__:__{dcb|nodcb}__:__{fabric|vn2vn}__::
     Try to connect to a FCoE SAN through the NIC specified by _<interface>_ or
-    _<MAC>_ or EDD settings. For the second argument, currently only nodcb is
-    supported. This parameter can be specified multiple times.
+    _<MAC>_ or EDD settings. The second argument specifies if DCB
+    should be used. The optional third argument specifies whether
+    fabric or VN2VN mode should be used.
+    This parameter can be specified multiple times.
 +
 NOTE: letters in the MAC-address must be lowercase!
 
diff --git a/modules.d/95fcoe/fcoe-genrules.sh b/modules.d/95fcoe/fcoe-genrules.sh
index eb58601..af15a58 100755
--- a/modules.d/95fcoe/fcoe-genrules.sh
+++ b/modules.d/95fcoe/fcoe-genrules.sh
@@ -7,8 +7,8 @@
 # Write udev rules
 {
     if [ -n "$fcoe_mac" ] ; then
-        printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_mac" "$fcoe_dcb"
+        printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
     else
-        printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_interface" "$fcoe_dcb"
+        printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode"
     fi
 } >> /etc/udev/rules.d/92-fcoe.rules
diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh
index 662b21a..ffcc4e3 100755
--- a/modules.d/95fcoe/fcoe-up.sh
+++ b/modules.d/95fcoe/fcoe-up.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # We get called like this:
-# fcoe-up <network-device> <dcb|nodcb>
+# fcoe-up <network-device> <dcb|nodcb> <fabric|vn2vn>
 #
 # Note currently only nodcb is supported, the dcb option is reserved for
 # future use.
@@ -15,6 +15,7 @@ type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
 
 netif=$1
 dcb=$2
+mode=$3
 vlan="yes"
 
 iflink=$(cat /sys/class/net/$netif/iflink)
@@ -43,7 +44,11 @@ write_fcoemon_cfg() {
     else
 	    echo AUTO_VLAN=\"no\" >> /etc/fcoe/cfg-$netif
     fi
-    echo MODE=\"fabric\" >> /etc/fcoe/cfg-$netif
+    if [ "$mode" = "vn2vn" ] ; then
+        echo MODE=\"vn2vn\" >> /etc/fcoe/cfg-$netif
+    else
+        echo MODE=\"fabric\" >> /etc/fcoe/cfg-$netif
+    fi
 }
 
 if [ "$netdriver" = "bnx2x" ]; then
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
index 18c00b3..2a5c71a 100755
--- a/modules.d/95fcoe/module-setup.sh
+++ b/modules.d/95fcoe/module-setup.sh
@@ -44,7 +44,13 @@ cmdline() {
     for c in /sys/bus/fcoe/devices/ctlr_* ; do
         [ -L $c ] || continue
         read enabled < $c/enabled
+        read mode < $c/mode
         [ $enabled -eq 0 ] && continue
+        if [ $mode = "VN2VN" ] ; then
+            mode="vn2vn"
+        else
+            mode="fabric"
+        fi
         d=$(cd -P $c; echo $PWD)
         i=${d%/*}
         read mac < ${i}/address
@@ -60,7 +66,7 @@ cmdline() {
         else
 	    dcb="nodcb"
         fi
-        echo "fcoe=${mac}:${dcb}"
+        echo "fcoe=${mac}:${dcb}:${mode}"
     done
 }
 
diff --git a/modules.d/95fcoe/parse-fcoe.sh b/modules.d/95fcoe/parse-fcoe.sh
index 9f47184..75cca9a 100755
--- a/modules.d/95fcoe/parse-fcoe.sh
+++ b/modules.d/95fcoe/parse-fcoe.sh
@@ -1,8 +1,8 @@
 #!/bin/sh
 #
 # Supported formats:
-# fcoe=<networkdevice>:<dcb|nodcb>
-# fcoe=<macaddress>:<dcb|nodcb>
+# fcoe=<networkdevice>:<dcb|nodcb>:<fabric|vn2vn>
+# fcoe=<macaddress>:<dcb|nodcb>:<fabric|vn2vn>
 #
 # Note currently only nodcb is supported, the dcb option is reserved for
 # future use.
@@ -10,8 +10,8 @@
 # Note letters in the macaddress must be lowercase!
 #
 # Examples:
-# fcoe=eth0:nodcb
-# fcoe=4a:3f:4c:04:f8:d7:nodcb
+# fcoe=eth0:nodcb:vn2vn
+# fcoe=4a:3f:4c:04:f8:d7:nodcb:fabric
 
 [ -z "$fcoe" ] && fcoe=$(getarg fcoe=)
 
@@ -32,11 +32,25 @@ parse_fcoe_opts() {
         2)
             fcoe_interface=$1
             fcoe_dcb=$2
+            fcoe_mode="fabric"
+            return 0
+            ;;
+        3)
+            fcoe_interface=$1
+            fcoe_dcb=$2
+            fcoe_mode=$3
             return 0
             ;;
         7)
             fcoe_mac=$1:$2:$3:$4:$5:$6
             fcoe_dcb=$7
+            fcoe_mode="fabric"
+            return 0
+            ;;
+        8)
+            fcoe_mac=$1:$2:$3:$4:$5:$6
+            fcoe_dcb=$7
+            fcoe_mode=$8
             return 0
             ;;
         *)
-- 
2.6.6