penguin/monok8s

k8s image for Mono Gateway Dev Kit

commit ee1f78f49648d23d0cde876acf1901d2ceb101ab983a289a62e704383187c32d

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-04-09T16:41:11Z
subjectOops: 0000000096000004
commit ee1f78f49648d23d0cde876acf1901d2ceb101ab983a289a62e704383187c32d
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-04-09T16:41:11Z

    Oops: 0000000096000004
---
 clitools/pkg/node/kubeadm.go             |  2 +-
 docker/vpp.Dockerfile                    | 43 +++++++++++++++++++++++++++++---
 kernel-build/dts/mono-gateway-dk-sdk.dts |  2 +-
 vpp/start-vpp.sh                         | 40 +++++++++++++++++++++++------
 4 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/clitools/pkg/node/kubeadm.go b/clitools/pkg/node/kubeadm.go
index dcd08f5..2d20806 100644
--- a/clitools/pkg/node/kubeadm.go
+++ b/clitools/pkg/node/kubeadm.go
@@ -410,7 +410,7 @@ func checkImagePresent(ctx context.Context, n *NodeContext, image string) error
 	// crictl inspecti exits non-zero when the image is absent.
 	_, err := n.SystemRunner.RunRetry(ctx, system.RetryOptions{
 		Attempts: 3,
-		Delay:    1 * system.DefaultSecond,
+		Delay:    2 * system.DefaultSecond,
 	}, "crictl", "inspecti", image)
 	if err != nil {
 		return fmt.Errorf("image %q not present: %w", image, err)
diff --git a/docker/vpp.Dockerfile b/docker/vpp.Dockerfile
index 7682199..8fda4b0 100644
--- a/docker/vpp.Dockerfile
+++ b/docker/vpp.Dockerfile
@@ -225,15 +225,50 @@ RUN set -eux; \
     # Create a structured staging area
     mkdir -p /tmp/fmc_staging/config; \
     \
-    # Copy main files to the root of staging
+    # Copy main files
     cp "$XML_SRC" /tmp/fmc_staging/config.xml; \
-    # Copy the HXS and schemas into the 'config' subfolder where fmc expects them
     cp "$HXS_FILE" /tmp/fmc_staging/config/; \
     cp "$SCHEMA_DIR"/*.xsd /tmp/fmc_staging/config/; \
     \
-    # Production Cleanup (Remove MAC 3 from the main config)
+    # Production Cleanup: Remove RJ45 ports (MAC 3, 4, 5, 6) from the FMC config
+    # This ensures FMC only touches the SFP ports (MAC 9, 10)
     sed -i '/<macport name="fm0-gb3"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
-    cp /tmp/fmc_staging/config.xml /tmp/fmc_staging/policy.xml
+    sed -i '/<macport name="fm0-gb4"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
+    sed -i '/<macport name="fm0-gb5"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
+    sed -i '/<macport name="fm0-gb6"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
+    \
+    # Also remove the port bindings for those MACs
+    sed -i '/<port type="MAC" number="3"/d' /tmp/fmc_staging/config.xml; \
+    sed -i '/<port type="MAC" number="4"/d' /tmp/fmc_staging/config.xml; \
+    sed -i '/<port type="MAC" number="5"/d' /tmp/fmc_staging/config.xml; \
+    sed -i '/<port type="MAC" number="6"/d' /tmp/fmc_staging/config.xml; \
+    \
+    # 1. Initialize policy.xml with the correct <netpcd> root tag
+    echo '<?xml version="1.0" encoding="UTF-8"?>' > /tmp/fmc_staging/policy.xml; \
+    echo '<netpcd>' >> /tmp/fmc_staging/policy.xml; \
+    \
+    # 2. Extract policy names and generate dummy blocks
+    # We use a subshell and tr to handle potential weird spacing
+    POLICY_NAMES=$(grep -o 'policy="[^"]*"' /tmp/fmc_staging/config.xml | cut -d'"' -f2 | sort -u); \
+    \
+    for NAME in $POLICY_NAMES; do \
+        echo "    <policy name=\"$NAME\">" >> /tmp/fmc_staging/policy.xml; \
+        echo "        <dist_order><distributionref name=\"dist_dummy\"/></dist_order>" >> /tmp/fmc_staging/policy.xml; \
+        echo "    </policy>" >> /tmp/fmc_staging/policy.xml; \
+    done; \
+    \
+    # 3. Append the distribution and close the root tag
+    # Updated Distribution block for the Dockerfile RUN command
+    cat << 'EOF' >> /tmp/fmc_staging/policy.xml
+    <distribution name="dist_dummy">
+        <protocols><protocolref name="ethernet"/></protocols>
+        <standardhash>
+            <algorithm name="fms_hash_default"/>
+        </standardhash>
+        <keycount>1</keycount>
+    </distribution>
+</netpcd>
+EOF
 
 RUN set -eux; \
     cd /src/vpp; \
diff --git a/kernel-build/dts/mono-gateway-dk-sdk.dts b/kernel-build/dts/mono-gateway-dk-sdk.dts
index 80fea88..dea3305 100644
--- a/kernel-build/dts/mono-gateway-dk-sdk.dts
+++ b/kernel-build/dts/mono-gateway-dk-sdk.dts
@@ -28,7 +28,7 @@
 
 		usdpaa_mem: usdpaa_mem {
 			compatible = "fsl,usdpaa-mem";
-			alloc-ranges = <0 0 0x10000 0>;
+            alloc-ranges = <0 0x80000000 0 0xffffffff>;
 			size = <0 0x10000000>;		// 256MB
 			alignment = <0 0x10000000>;
 		};
diff --git a/vpp/start-vpp.sh b/vpp/start-vpp.sh
index 175e4a4..1b4b9a0 100755
--- a/vpp/start-vpp.sh
+++ b/vpp/start-vpp.sh
@@ -3,20 +3,44 @@ set -e
 
 echo "--- Starting NXP DPAA1 Hardware Initialization ---"
 
-# 1. Run FMC to configure FMan, QMan, and BMan
-# -c: path to config xml
-# -p: path to policy xml
-# -a: apply the configuration
+# Only unbind the SFP ports (MAC 9 and 10)
+# Leave MAC 3, 4, 5, 6 for Linux (Kubernetes management)
+SFP_PORTS="9 10"
+
+echo "Releasing SFP hardware ports from kernel..."
+for port in $SFP_PORTS; do
+    if [ -e /sys/bus/platform/drivers/fsl-dpa-ethernet/fm0-port.$port ]; then
+        echo "fm0-port.$port" > /sys/bus/platform/drivers/fsl-dpa-ethernet/unbind 2>/dev/null || true
+        echo "Successfully unbound MAC $port"
+    else
+        echo "MAC $port already released or not found."
+    fi
+done
+
+# 1. PRE-REQUISITE: Unbind ports from the kernel
+# This frees the hardware so FMC/VPP can claim it.
+# MAC 3 usually maps to fm0-port.3 or similar in sysfs.
+echo "Releasing hardware ports from kernel..."
+for port in 3 4 5 6 9 10; do
+    # Try to unbind from the DPAA Ethernet driver if it exists
+    if [ -e /sys/bus/platform/drivers/fsl-dpa-ethernet/fm0-port.$port ]; then
+        echo "fm0-port.$port" > /sys/bus/platform/drivers/fsl-dpa-ethernet/unbind 2>/dev/null || true
+    fi
+    # Ensure the interface is DOWN
+    # Note: You may need to map MAC numbers to eth names (eth0, eth1, etc.)
+done
+
+# 2. Run FMC
 if [ -f /etc/fmc/config.xml ]; then
     echo "Applying FMC Configuration..."
-	cd /etc/fmc
-    fmc -c /etc/fmc/config.xml -p /etc/fmc/policy.xml -a
+    cd /etc/fmc
+    # Using -l dbg1 helps see exactly why a port fails if it happens again
+    fmc -c /etc/fmc/config.xml -p /etc/fmc/policy.xml -a -l dbg1
     echo "FMC Configuration applied successfully."
 else
     echo "ERROR: /etc/fmc/config.xml not found!"
-    echo "VPP will likely fail with 'Main heap allocation failure'."
+    exit 1
 fi
 
 echo "--- Starting VPP Forwarder ---"
-# 2. Start VPP and replace this script's process (exec)
 exec vpp -c /etc/vpp/startup.conf