Harald Hoyer afa7aa
From bada26263c36a8be07aece7e9f4986ee31e4d97f Mon Sep 17 00:00:00 2001
Harald Hoyer afa7aa
From: Harald Hoyer <harald@hoyer.xyz>
Harald Hoyer afa7aa
Date: Mon, 9 Oct 2017 11:47:08 +0200
Harald Hoyer afa7aa
Subject: [PATCH] Merge pull request #287 from xlpang/master
Harald Hoyer afa7aa
Harald Hoyer afa7aa
fcoe: handle CNAs with DCB firmware support
Harald Hoyer afa7aa
---
Harald Hoyer afa7aa
 modules.d/95fcoe/module-setup.sh | 26 ++++++++++++++++++++------
Harald Hoyer afa7aa
 1 file changed, 20 insertions(+), 6 deletions(-)
Harald Hoyer afa7aa
Harald Hoyer afa7aa
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
Harald Hoyer afa7aa
index e14a0ebb..eabb21c7 100755
Harald Hoyer afa7aa
--- a/modules.d/95fcoe/module-setup.sh
Harald Hoyer afa7aa
+++ b/modules.d/95fcoe/module-setup.sh
Harald Hoyer afa7aa
@@ -51,16 +51,30 @@ cmdline() {
Harald Hoyer afa7aa
         read mac < ${i}/address
Harald Hoyer afa7aa
         s=$(dcbtool gc ${i##*/} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
Harald Hoyer afa7aa
         if [ -z "$s" ] ; then
Harald Hoyer afa7aa
-	    p=$(get_vlan_parent ${i})
Harald Hoyer afa7aa
-	    if [ "$p" ] ; then
Harald Hoyer afa7aa
-	        s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
Harald Hoyer afa7aa
-	    fi
Harald Hoyer afa7aa
+            p=$(get_vlan_parent ${i})
Harald Hoyer afa7aa
+            if [ "$p" ] ; then
Harald Hoyer afa7aa
+                s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
Harald Hoyer afa7aa
+            fi
Harald Hoyer afa7aa
         fi
Harald Hoyer afa7aa
         if [ "$s" = "on" ] ; then
Harald Hoyer afa7aa
-	    dcb="dcb"
Harald Hoyer afa7aa
+            dcb="dcb"
Harald Hoyer afa7aa
         else
Harald Hoyer afa7aa
-	    dcb="nodcb"
Harald Hoyer afa7aa
+            dcb="nodcb"
Harald Hoyer afa7aa
         fi
Harald Hoyer afa7aa
+
Harald Hoyer afa7aa
+        # Some Combined Network Adapters(CNAs) implement DCB in firmware.
Harald Hoyer afa7aa
+        # Do not run software-based DCB or LLDP on CNAs that implement DCB.
Harald Hoyer afa7aa
+        # If the network interface provides hardware DCB/DCBX capabilities,
Harald Hoyer afa7aa
+        # DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
Harald Hoyer afa7aa
+        #
Harald Hoyer afa7aa
+        # Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
Harald Hoyer afa7aa
+        grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null
Harald Hoyer afa7aa
+        [ $? -eq 0 ] && dcb="nodcb"
Harald Hoyer afa7aa
+        if [ "$p" ] ; then
Harald Hoyer afa7aa
+            grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
Harald Hoyer afa7aa
+            [ $? -eq 0 ] && dcb="nodcb"
Harald Hoyer afa7aa
+        fi
Harald Hoyer afa7aa
+
Harald Hoyer afa7aa
         echo "fcoe=${mac}:${dcb}"
Harald Hoyer afa7aa
     done
Harald Hoyer afa7aa
 }
Harald Hoyer afa7aa