summaryrefslogtreecommitdiff
path: root/machine
diff options
context:
space:
mode:
authorLu Qiuwen <[email protected]>2021-04-29 15:58:15 +0800
committerLu Qiuwen <[email protected]>2021-04-29 15:58:15 +0800
commitc2594d110b2a24682e0648cf8dbcf7dbd8bb343a (patch)
treef4d9d985aa5dda175f8b1945afb52227bd3039c3 /machine
parent43e6aba0558655f3e18e74c022b320a62d3ae7f7 (diff)
Support auto IP address config based on IPMI addr.
Diffstat (limited to 'machine')
-rw-r--r--machine/geedge/9000-NPB-P01R01/kernel/config50
-rwxr-xr-xmachine/geedge/9000-NPB-P01R01/machine.make5
-rwxr-xr-xmachine/geedge/9000-NPB-P01R01/rootconf/sysroot-init/networking.sh224
-rwxr-xr-xmachine/geedge/9000-NPB-P01R01/rootconf/sysroot-lib-onie/networking-platform34
4 files changed, 271 insertions, 42 deletions
diff --git a/machine/geedge/9000-NPB-P01R01/kernel/config b/machine/geedge/9000-NPB-P01R01/kernel/config
index bf366e00..55c0a83f 100644
--- a/machine/geedge/9000-NPB-P01R01/kernel/config
+++ b/machine/geedge/9000-NPB-P01R01/kernel/config
@@ -1,43 +1,3 @@
-# CONFIG_I2C_I801=y
-# CONFIG_USB_SISUSBVGA=y
-# CONFIG_USB_SISUSBVGA_CON=y
-# CONFIG_INPUT_KEYBOARD=y
-# CONFIG_KEYBOARD_ADP5588 is not set
-# CONFIG_KEYBOARD_ADP5589 is not set
-# CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_QT1070 is not set
-# CONFIG_KEYBOARD_QT2160 is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_GPIO is not set
-# CONFIG_KEYBOARD_GPIO_POLLED is not set
-# CONFIG_KEYBOARD_TCA6416 is not set
-# CONFIG_KEYBOARD_TCA8418 is not set
-# CONFIG_KEYBOARD_MATRIX is not set
-# CONFIG_KEYBOARD_LM8333 is not set
-# CONFIG_KEYBOARD_MAX7359 is not set
-# CONFIG_KEYBOARD_MCS is not set
-# CONFIG_KEYBOARD_MPR121 is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_KEYBOARD_OPENCORES is not set
-# CONFIG_KEYBOARD_STOWAWAY is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-
-#CONFIG_VGA_ARB=y
-#CONFIG_NET_VENDOR_INTEL=y
-#CONFIG_E100=y
-#CONFIG_E1000=y
-#CONFIG_E1000E=y
-#CONFIG_E1000E_HWTS=y
-#CONFIG_IGB=y
-#CONFIG_IGBVF=y
-#CONFIG_IXGB=y
-#CONFIG_IXGBE=y
-#CONFIG_IXGBEVF=y
-#CONFIG_I40E=y
-#CONFIG_I40EVF=y
-#CONFIG_FM10K=y
-
CONFIG_MDIO=y
CONFIG_IGBVF=y
CONFIG_IXGB=y
@@ -101,3 +61,13 @@ CONFIG_SERIO_PS2MULT=y
CONFIG_SERIO_ARC_PS2=y
CONFIG_USERIO=y
CONFIG_HP_ACCEL=n
+CONFIG_ACPI_IPMI=y
+CONFIG_IPMI_HANDLER=y
+CONFIG_IPMI_DMI_DECODE=y
+CONFIG_IPMI_PLAT_DATA=y
+# CONFIG_IPMI_PANIC_EVENT is not set
+CONFIG_IPMI_DEVICE_INTERFACE=y
+CONFIG_IPMI_SI=y
+# CONFIG_IPMI_SSIF is not set
+CONFIG_IPMI_WATCHDOG=y
+CONFIG_IPMI_POWEROFF=y \ No newline at end of file
diff --git a/machine/geedge/9000-NPB-P01R01/machine.make b/machine/geedge/9000-NPB-P01R01/machine.make
index c77d2ccf..d788ba89 100755
--- a/machine/geedge/9000-NPB-P01R01/machine.make
+++ b/machine/geedge/9000-NPB-P01R01/machine.make
@@ -31,8 +31,9 @@ endif
CONSOLE_DEV = 0
CONSOLE_SPEED = 115200
-#Enable UEFI support
+# Enable UEFI support
UEFI_ENABLE = yes
+SKIP_ETHMGMT_MACS = yes
# Set Linux kernel version
LINUX_VERSION = 4.9
@@ -43,7 +44,7 @@ LINUX_MINOR_VERSION = 95
# GCC_VERSION = 9.3.1
# Extra kernel command line
-# EXTRA_CMDLINE_LINUX ?=
+EXTRA_CMDLINE_LINUX ?= biosdevname=0 net.ifnames=1
IPMITOOL_ENABLE ?= yes
#-------------------------------------------------------------------------------
diff --git a/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-init/networking.sh b/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-init/networking.sh
new file mode 100755
index 00000000..4603a88c
--- /dev/null
+++ b/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-init/networking.sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+
+# Copyright (C) 2013,2014,2016 Curt Brune <[email protected]>
+# Copyright (C) 2014 david_yang <[email protected]>
+# Copyright (C) 2013 Doron Tsur <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0
+
+PATH=/usr/bin:/usr/sbin:/bin:/sbin
+
+. /lib/onie/functions
+
+import_cmdline
+
+# Static ethernet management configuration
+config_ethmgmt_static()
+{
+ local intf=$1
+ shift
+
+ if [ -n "$onie_ip" ] ; then
+ # ip= was set on the kernel command line and configured by the
+ # kernel already. Do no more.
+ log_console_msg "${intf}: Using static IP config: ip=$onie_ip"
+ return 0
+ fi
+
+ return 1
+}
+
+# DHCPv6 ethernet management configuration
+config_ethmgmt_dhcp6()
+{
+ intf=$1
+ shift
+
+ # TODO
+ # log_info_msg "TODO: Checking for DHCPv6 ethmgmt configuration."
+
+ return 1
+}
+
+# DHCPv4 ethernet management configuration
+config_ethmgmt_dhcp4()
+{
+ intf=$1
+ shift
+
+ # no default args
+ udhcp_args="$(udhcpc_args) -n -o"
+ if [ "$1" = "discover" ] ; then
+ udhcp_args="$udhcp_args -t 5 -T 3"
+ else
+ udhcp_args="$udhcp_args -t 15 -T 3"
+ fi
+ udhcp_request_opts=
+ for o in subnet broadcast router domain hostname ntpsrv dns logsrv search ; do
+ udhcp_request_opts="$udhcp_request_opts -O $o"
+ done
+
+ log_info_msg "Trying DHCPv4 on interface: $intf"
+ udhcpc $udhcp_args $udhcp_request_opts $udhcp_user_class \
+ -i $intf -s /lib/onie/udhcp4_net > /dev/null 2>&1
+ if [ "$?" = "0" ] ; then
+ local ipaddr=$(ifconfig $intf |grep 'inet '|sed -e 's/:/ /g'|awk '{ print $3 " / " $7 }')
+ log_console_msg "Using DHCPv4 addr: ${intf}: $ipaddr"
+ else
+ log_warning_msg "Unable to configure interface using DHCPv4: $intf"
+ return 1
+ fi
+ return 0
+
+}
+
+# Fall back ethernet management configuration
+# Configure an IPv4 link-local address per RFC-3927.
+config_ethmgmt_fallback()
+{
+
+ local prefix=16
+ local default_hn="onie-host"
+ local intf_counter=$1
+ shift
+ local intf=$1
+ shift
+
+ # Remove any previously configured, IPv4 addresses
+ ip -f inet addr flush dev $intf
+
+ # Maximum number of attempts to find an unused 169.254.x.y/16
+ # address.
+ local max_retry=20
+ local attempt=1
+ while [ $attempt -lt $max_retry ] ; do
+ local rnd1=$(( ( $RANDOM % 254 ) + 1 ))
+ local rnd2=$(( ( $RANDOM % 254 ) + 1 ))
+ local test_ip="169.254.${rnd1}.${rnd2}"
+
+ # use arping to check if IP is in use
+ arping -qD -c 5 -I $intf $test_ip && {
+ # Claim this IP
+ ip addr add ${test_ip}/$prefix dev $intf || {
+ log_failure_msg "Problems setting default IPv4 addr: ${intf}: ${test_ip}/$prefix"
+ return 1
+ }
+ arping -c 3 -Uq -I $intf -s $test_ip $test_ip
+ log_console_msg "Using link-local IPv4 addr: ${intf}: ${test_ip}/$prefix"
+ break
+ }
+ attempt=$(( $attempt + 1 ))
+ done
+
+ if [ $attempt -eq $max_retry ] ; then
+ log_warning_msg "Unable to configure link-local IPv4 address within $max_retry attempts"
+ fi
+
+ hostname $default_hn || {
+ log_failure_msg "Problems setting default hostname: ${intf}: ${default_hn}\n"
+ return 1
+ }
+
+ return 0
+
+}
+
+# Check the operational state of the specified interface before trying
+# DHCP. From linux/Documentation/networking/operstates.txt, the
+# appropriate states are "up" and "unknown" for DHCP.
+check_link_up()
+{
+ local intf=$1
+ local operstate="/sys/class/net/${intf}/operstate"
+
+ _log_info_msg "Info: ${intf}: Checking link... "
+ local i=0
+ [ -r $operstate ] && while [ $i -lt 100 ] ; do
+ intf_operstate="$(cat $operstate)"
+ if [ "$intf_operstate" = "up" -o "$intf_operstate" = "unknown" ] ; then
+ _log_info_msg "up.\n"
+ return 0
+ fi
+ sleep 0.1
+ i=$(( $i + 1 ))
+ done
+
+ # no link
+ _log_info_msg "down.\n"
+ return 1
+}
+
+# Configure the management interface
+# Try these methods in order:
+# 1. static, from kernel command line parameters
+# 2. DHCPv6
+# 3. DHCPv4
+# 4. Fall back to well known IP address
+config_ethmgmt()
+{
+ intf_list=$(net_intf)
+ intf_counter=0
+ return_value=0
+
+ # Bring up all the interfaces for the subsequent methods.
+ for intf in $intf_list ; do
+ cmd_run ifconfig $intf up
+ params="$intf $*"
+ eval "result_${intf}=0"
+ check_link_up $intf || {
+ log_console_msg "${intf}: link down. Skipping configuration."
+ eval "result_${intf}=1"
+ continue
+ }
+ config_ethmgmt_static $params || \
+ config_ethmgmt_dhcp6 $params || \
+ config_ethmgmt_dhcp4 $params || \
+ config_ethmgmt_fallback $intf_counter $params || \
+ eval "result_${intf}=1"
+ intf_counter=$(( $intf_counter + 1))
+ done
+ for intf in $intf_list ; do
+ eval "curr_intf_result=\${result_${intf}}"
+ if [ "x$curr_intf_result" != "x0" ] ; then
+ log_console_msg "Failed to configure ${intf} interface"
+ return_value=1
+ fi
+ done
+ return $return_value
+}
+
+arch_networking="/lib/onie/networking-${onie_switch_asic}"
+platform_networking="/lib/onie/networking-platform"
+
+[ -r "$arch_networking" ] && . "$arch_networking"
+[ -r "$platform_networking" ] && . "$platform_networking"
+
+if [ "$1" = "start" ] ; then
+ # Bring up the loopback interface
+ cmd_run ip link set dev lo up
+
+ # When starting the network at boot time configure the MAC
+ # addresses for all the Ethernet management interfaces.
+ intf_list=$(net_intf)
+ intf_counter=0
+
+ # Set MAC addr for all interfaces, but leave the interfaces down.
+ base_mac=$(onie-sysinfo -e)
+ for intf in $intf_list ; do
+ if [ "$onie_skip_ethmgmt_macs" = "no" ] ; then
+ mac="$(mac_add $base_mac $intf_counter)"
+ if [ $? -eq 0 ] ; then
+ cmd_run ifconfig $intf down
+ cmd_run ifconfig $intf hw ether $mac down
+ else
+ log_failure_msg "Unable to configure MAC address for $intf"
+ fi
+ else
+ mac="$(cat /sys/class/net/${intf}/address)"
+ fi
+ log_info_msg "Using $intf MAC address: $mac"
+ intf_counter=$(( $intf_counter + 1))
+ done
+fi
+
+config_ethmgmt "$*"
diff --git a/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-lib-onie/networking-platform b/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-lib-onie/networking-platform
new file mode 100755
index 00000000..abc406dc
--- /dev/null
+++ b/machine/geedge/9000-NPB-P01R01/rootconf/sysroot-lib-onie/networking-platform
@@ -0,0 +1,34 @@
+config_ethmgmt_static() {
+ local intf=$1
+ shift
+
+ # eth0 -- BASE#1
+ # eth1 -- BASE#2
+ # eth2 -- Front GE#1
+ # eth3 -- Front GE#2
+
+ # For BASE#1 BASE#2, we use static IP caculated from IPMI address.
+ # For Front GE#1, GE#2, use DHCPv4
+
+ local chassis_mgmt_id=$(ipmitool picmg addrinfo | grep "Hardware Address" | sed 's/^Hardware Address.*0x4\(.*\)/\1/' | awk '{print $1+16'})
+ local chassis_mgmt_ip_addr="10.254.${chassis_mgmt_id}.1"
+ local chassis_mgmt_ip_prefix="255.255.0.0"
+
+ case $intf in
+ eth0)
+ ip addr add ${chassis_mgmt_ip_addr}/$chassis_mgmt_ip_prefix dev $intf || {
+ log_failure_msg "Problems setting IPv4 addr: ${intf}: ${chassis_mgmt_ip_addr}/$chassis_mgmt_ip_prefix"
+ return 1
+ }
+
+ log_console_msg "${intf}: Using static IP config: ${chassis_mgmt_ip_addr}/$chassis_mgmt_ip_prefix, intf=$intf"
+ ;;
+ *)
+ ifconfig $intf down
+ return 0
+ ;;
+ esac
+
+ # other interface, do nothing and disable DHCPv4
+ return 0
+} \ No newline at end of file