summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2022-03-08 14:52:31 +0800
committerluwenpeng <[email protected]>2022-03-11 17:18:50 +0800
commite0a792e838787d4d67ad63aa37219cc531eb032e (patch)
tree68869f0ced3614486d9120bd6b2b8def1f69c54a
parent76afa744935ed678ae92edbd5b7047f60ed1b1ec (diff)
TSG-9879 ONIE适配TSG-X设备HOST的网络配置
-rw-r--r--build-config/make/images.make1
-rw-r--r--installer/grub-arch/grub/grub-common.cfg6
-rw-r--r--machine/geedge/TSG-X/kernel/config11
-rwxr-xr-xmachine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform10
-rwxr-xr-xrootconf/default/bin/onie-netcfg-set127
5 files changed, 143 insertions, 12 deletions
diff --git a/build-config/make/images.make b/build-config/make/images.make
index c4d214d2..530c8af8 100644
--- a/build-config/make/images.make
+++ b/build-config/make/images.make
@@ -30,6 +30,7 @@ ONIE_SYSROOT_TOOLS_LIST = \
lib/onie \
bin/onie-boot-mode \
bin/onie-nos-mode \
+ bin/onie-netcfg-set \
bin/onie-fwpkg
IMAGE_BIN_STAMP = $(STAMPDIR)/image-bin
diff --git a/installer/grub-arch/grub/grub-common.cfg b/installer/grub-arch/grub/grub-common.cfg
index 7d3af560..821ca6ff 100644
--- a/installer/grub-arch/grub/grub-common.cfg
+++ b/installer/grub-arch/grub/grub-common.cfg
@@ -66,6 +66,12 @@ function onie_bootcmd {
else
onie_args="$GRUB_ONIE_CMDLINE_LINUX $ONIE_EXTRA_CMDLINE_LINUX"
fi
+
+ if [ -n "$ONIE_NETWORK_CONFIG" ] ; then
+ onie_debugargs="$ONIE_NETWORK_CONFIG $onie_debugargs"
+ echo "ONIE: Network: $onie_debugargs"
+ fi
+
linux $onie_linux $onie_args boot_reason=$onie_boot_reason $onie_debugargs
initrd $onie_initrd
onie_entry_end
diff --git a/machine/geedge/TSG-X/kernel/config b/machine/geedge/TSG-X/kernel/config
index cec4bed0..0de5f57d 100644
--- a/machine/geedge/TSG-X/kernel/config
+++ b/machine/geedge/TSG-X/kernel/config
@@ -288,7 +288,6 @@ CONFIG_USB_HID=y
# CONFIG_HID_PID is not set
CONFIG_USB_HIDDEV=y
# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set
-#CONFIG_HID_UCLOGIC is not set
# CONFIG_HID_ROCCAT is not set
# CONFIG_HID_PENMOUNT is not set
# CONFIG_HID_NTRIG is not set
@@ -297,4 +296,12 @@ CONFIG_USB_HIDDEV=y
# CONFIG_HID_CP2112 is not set
# CONFIG_HID_BETOP_FF is not set
# CONFIG_HID_APPLEIR is not set
-# CONFIG_HID_UCLOGIC is not set \ No newline at end of file
+# CONFIG_HID_UCLOGIC is not set
+
+#
+# Intel(R) Ethernet Controller XL710 Family support
+#
+
+CONFIG_I40E=y
+CONFIG_I40E_DCB=y
+CONFIG_I40EVF=y \ No newline at end of file
diff --git a/machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform b/machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform
deleted file mode 100755
index e8f6843a..00000000
--- a/machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform
+++ /dev/null
@@ -1,10 +0,0 @@
-config_ethmgmt_static() {
- log_console_msg "==================== TSG-X TEST ===================="
- local msg=$(lspci -k)
- log_console_msg "==================== msg: ${msg}"
-
- local env=$(env | sort)
- log_console_msg "==================== env: ${msg}"
-
- return 0
-} \ No newline at end of file
diff --git a/rootconf/default/bin/onie-netcfg-set b/rootconf/default/bin/onie-netcfg-set
new file mode 100755
index 00000000..243a1ae7
--- /dev/null
+++ b/rootconf/default/bin/onie-netcfg-set
@@ -0,0 +1,127 @@
+#!/bin/sh
+
+function usage() {
+ echo "$(basename $0) interface address netmask [gateway]"
+ cat <<EOF
+Configuring the IPv4 Network of the ONIE Management Port.
+
+ Example: onie-netcfg-set eth0 192.168.100.10 255.255.255.0 192.168.100.1
+ Example: onie-netcfg-set eth1 192.168.200.10 255.255.255.0
+EOF
+}
+
+function check_ipv4_foramt() {
+ IP=$1
+
+ VALID_CHECK_STEP1=$(echo $IP | awk -F . '$1<=255 && $2<=255 && $3<=255 && $4<=255 {print "yes"}')
+ VALID_CHECK_STEP2=$(echo $IP | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
+ if [ ${VALID_CHECK_STEP1:-no} == "yes" ] && [ -n "${VALID_CHECK_STEP2}" ]; then
+ return 0
+ else
+ echo "Invalid IPv4 Address Format: $IP."
+ return 1
+ fi
+}
+
+function check_interface() {
+ eth=$1
+
+ if ifconfig $eth >/dev/null; then
+ return 0
+ else
+ echo "Network Interface $eth not exist."
+ return 1
+ fi
+}
+
+function check_cmd_args() {
+ interface=$1
+ address=$2
+ netmask=$3
+ gateway=$4
+
+ # check network interface, interface is required
+ if [ -z "$interface" ]; then
+ echo "Network Interface not config."
+ return 1
+ fi
+
+ check_interface $interface
+ ret=$?
+ if [ "$ret" == 1 ]; then
+ usage
+ exit 1
+ fi
+
+ # check ipv4 network address, address is required
+ if [ -z "$address" ]; then
+ echo "IPv4 Network Address not config."
+ return 1
+ fi
+
+ check_ipv4_foramt $address
+ ret=$?
+ if [ "$ret" == 1 ]; then
+ return 1
+ fi
+
+ # check ipv4 network mask, mask is required
+ if [ -z "$netmask" ]; then
+ echo "IPv4 Network Mask not config."
+ return 1
+ fi
+
+ check_ipv4_foramt $netmask
+ ret=$?
+ if [ "$ret" == 1 ]; then
+ return 1
+ fi
+
+ # check ipv4 network gateway, gateway is optioned
+ if [ -z "$gateway" ]; then
+ return 0
+ fi
+
+ check_ipv4_foramt $gateway
+ ret=$?
+ if [ "$ret" == 1 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+ret=0
+interface=$1
+address=$2
+netmask=$3
+gateway=$4
+
+check_cmd_args $interface $address $netmask $gateway
+ret=$?
+if [ "$ret" == 1 ]; then
+ usage
+ exit 1
+fi
+
+# save config to file
+if [ -r /mnt/onie-boot/grub/grubenv ]; then
+ # Plan A: If the current network interface has been configured with an IP, delete it
+ # sed -i "/::$interface$/d" /mnt/onie-boot/grub/grubenv
+
+ # Plan B: Delete all config info
+ sed -i "/ONIE_NETWORK_CONFIG/d" /mnt/onie-boot/grub/grubenv
+else
+ touch /mnt/onie-boot/grub/grubenv
+fi
+
+curr_time=$(date)
+echo "# ONIE_NETWORK_CONFIG config date: $curr_time, content: $address::$gateway:$netmask::$interface" >>/mnt/onie-boot/grub/grubenv
+echo "ONIE_NETWORK_CONFIG=ip=$address::$gateway:$netmask::$interface" >>/mnt/onie-boot/grub/grubenv
+
+#ifconfig $interface up
+#ifconfig $interface $address netmask $netmask
+#route add default gw $gateway
+
+echo "ONIE Network config Success !!!"
+echo "Please reboot to take effect."