diff options
| author | luwenpeng <[email protected]> | 2022-02-15 14:16:41 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2022-03-03 14:29:55 +0800 |
| commit | a47944fd762fc6a5fa701a2842ed4d13cc68abf5 (patch) | |
| tree | 4529bb7b24ea08d385ae5453ea0a4abfc2f41be2 | |
| parent | b40949ff9dd9e7efcc2cd265da65219fbd0212f7 (diff) | |
TSG-9616 ONIE适配TSG-X设备的显卡驱动
| -rw-r--r-- | .gitlab-ci.yml | 24 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/INSTALL | 112 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/busybox/conf/config | 10 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/demo/platform.conf | 1 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/installer.conf | 14 | ||||
| -rw-r--r-- | machine/geedge/TSG-X/kernel/config | 234 | ||||
| -rw-r--r-- | machine/geedge/TSG-X/kernel/series | 0 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/machine.make | 56 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/rootconf/sysroot-init/networking.sh | 224 | ||||
| -rwxr-xr-x | machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform | 10 |
10 files changed, 684 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3bafbcdc..88fd21d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,10 @@ release-TSG-7400-ONIE: PROJECT_DIR: "/builds/tsg/tsg-os-onie" IMAGE_NAME: TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz FILE_REPO_PATH: install/release/onie-os-images + artifacts: + name: "TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz" + paths: + - ${CI_PROJECT_DIR}/*.tar.gz only: - tags except: @@ -46,7 +50,25 @@ release-TSG-9140-ONIE: MACHINE_NAME: 9000-NPB-P01R01 IMAGE_NAME: TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz FILE_REPO_PATH: install/release/onie-os-images + artifacts: + name: "TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz" + paths: + - ${CI_PROJECT_DIR}/*.tar.gz only: - tags except: - - /^rel-.*$/i
\ No newline at end of file + - /^rel-.*$/i + +release-TSG-X: + stage: build + extends: .build_by_travis + variables: + PULP3_FILE_REPO_NAME: onie-os-images-release + PULP3_FILE_DIST_NAME: onie-os-images-release + MACHINE_NAME: TSG-X + IMAGE_NAME: TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz + FILE_REPO_PATH: install/release/onie-os-images + artifacts: + name: "TSG-ONIE-${MACHINE_NAME}-${CI_COMMIT_TAG}-${CI_COMMIT_SHORT_SHA}.tar.gz" + paths: + - ${CI_PROJECT_DIR}/*.tar.gz
\ No newline at end of file diff --git a/machine/geedge/TSG-X/INSTALL b/machine/geedge/TSG-X/INSTALL new file mode 100755 index 00000000..49e95ba5 --- /dev/null +++ b/machine/geedge/TSG-X/INSTALL @@ -0,0 +1,112 @@ +================================================ +Installing ONIE on GEEDGENETWORKS TSG-X Series +================================================ + +Cross-Compiling ONIE +==================== + +Change directories to ``build-config`` to compile ONIE. + +To compile ONIE first change directories to ``build-config`` and then +type ``"make MACHINEROOT=../machine/geedge MACHINE=TSG-X all"``. +For example:: + + $ cd build-config + $ make -j4 MACHINEROOT=../machine/geedge MACHINE=TSG-X all + +When complete, the ONIE binaries are located in +``build/images``:: + +-rw-r--r-- 8569516 Jul 19 10:50 TSG-X-r0.initrd +-rw-r--r-- 3479872 Jul 19 10:47 TSG-X-r0.vmlinuz +-rw-r--r-- 29753344 Jul 19 10:51 onie-recovery-x86_64-TSG-X-r0.iso +-rw-r--r-- 12105591 Jul 19 10:50 onie-updater-x86_64-TSG-X-r0 + +TSG-X-r0.vmlinuz -- This is the ONIE kernel image + +TSG-X-r0.initrd -- This is the ONIE initramfs (filesystem) + +onie-updater-x86_64-TSG-X-r0 -- This is the ONIE self-update +image. This image is a self-extracting archive used for installing ONIE. + +onie-recovery-x86_64-TSG-X-r0.iso -- This is the ONIE recovery +ISO image. This image can be used to create a bootable USB memory stick +for installing/recovery ONIE. + +Installing ONIE on a Blank Machine +================================== + +To install ONIE on a new machine, you can use the recovery ISO image to +create a bootable USB memory stick. + +Creating bootable USB stick +--------------------------- + +Use rufus (https://rufus.akeo.ie/) to create a bootable USB stick. +- Under "Create a bootable disk using" load the onie-recovery image (above) + from your filesystem and choose "DD Image" from the drop down box + (load the file first, then choose DD Image) . +- Hit Start and agree with the prompts and a boot able USB stick should be created +- Use the usb converter cable to plug your USB stick into the NE10032 + (the cable should have come with the switch) + +Booting from USB stick +---------------------- + +To enable booting from USB in the BIOS: + +1. Insert the USB stick + +2. Power on the switch and enter the BIOS configuration + +3. Set the hard drive boot order: + + In "Boot Option #1" select the device that corresponds to your + device:: + + Boot-->Boot Option Priorities-->Boot Option #1 + + If the device name is not listed in "Boot Option #1", please + check the priorities in the hard drive boot order:: + + Boot-->Hard Drive BBS Priorities-->Boot Option #1 + + Taking ``UEFI: Generic Flash Disk 8.07`` as an example, the boot + order will look like following:: + + Boot Option Priorities + Boot Option #1 [UEFI: Generic Flash...] + Boot Option #2 [UEFI: TS32GMTS400 ...] + Boot Option #3 [P0: TS32GMTS400 ...] + Boot Option #4 [UEFI: Built-in EFI ...] + +4. Save and Exit the BIOS configuration + +5. After several seconds, you should see: + + GNU GRUB version 2.02~beta3 + + +----------------------------------------------------------------------------+ + | ONIE: Rescue | + |*ONIE: Embed ONIE | + | | + | | + | | + | | + | | + | | + | | + | | + | | + | | + +----------------------------------------------------------------------------+ + + Use the ^ and v keys to select which entry is highlighted. + Press enter to boot the selected OS, `e' to edit the commands + before booting or `c' for a command-line. + + - Choose ``ONIE: Embed ONIE`` for creating a fresh partition layout and + installing ONIE automatically. All data on the mass storage will be + erased. + - Choose ``ONIE: Rescue`` for entering ONIE recovery command-line shell. + diff --git a/machine/geedge/TSG-X/busybox/conf/config b/machine/geedge/TSG-X/busybox/conf/config new file mode 100755 index 00000000..b1c83e5a --- /dev/null +++ b/machine/geedge/TSG-X/busybox/conf/config @@ -0,0 +1,10 @@ +#CONFIG_SYS_EEPROM=y +#CONFIG_SYS_EEPROM_DEVICE_I2C=y +#CONFIG_SYS_EEPROM_I2C_DEVICE="/dev/i2c-0" +#CONFIG_SYS_EEPROM_I2C_ADDR=0x56 +#CONFIG_SYS_EEPROM_I2C_MEM_ADDR_BITS=16 +#CONFIG_SYS_EEPROM_I2C_WRITE_2B_DELAY=5000 +#CONFIG_SYS_EEPROM_I2C_WRITE_3B_DELAY=5000 +#CONFIG_SYS_EEPROM_OFFSET=0 +#CONFIG_SYS_EEPROM_SIZE=2048 +#CONFIG_SYS_EEPROM_MAX_SIZE=16384
\ No newline at end of file diff --git a/machine/geedge/TSG-X/demo/platform.conf b/machine/geedge/TSG-X/demo/platform.conf new file mode 100755 index 00000000..139d67e9 --- /dev/null +++ b/machine/geedge/TSG-X/demo/platform.conf @@ -0,0 +1 @@ +# Geedge TSG-X specific info
\ No newline at end of file diff --git a/machine/geedge/TSG-X/installer.conf b/machine/geedge/TSG-X/installer.conf new file mode 100755 index 00000000..e4c5f303 --- /dev/null +++ b/machine/geedge/TSG-X/installer.conf @@ -0,0 +1,14 @@ +# Geedge TSG-X ONIE installer configuration + +description="Geedge, TSG-X" + +# Default ONIE block device +install_device_platform() +{ + echo /dev/sda +} + +# Local Variables: +# mode: shell-script +# eval: (sh-set-shell "/bin/sh" t nil) +# End:
\ No newline at end of file diff --git a/machine/geedge/TSG-X/kernel/config b/machine/geedge/TSG-X/kernel/config new file mode 100644 index 00000000..6bb26d5e --- /dev/null +++ b/machine/geedge/TSG-X/kernel/config @@ -0,0 +1,234 @@ + +# CONFIG_ACER_WMI is not set +CONFIG_ACPI_VIDEO=y +CONFIG_ACPI_WMI=y +# CONFIG_APPLE_GMUX is not set +# CONFIG_ASUS_LAPTOP is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_BD6107 is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +CONFIG_BACKLIGHT_GENERIC=y +# CONFIG_BACKLIGHT_GPIO is not set +CONFIG_BACKLIGHT_LCD_SUPPORT=y +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_PM8941_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +CONFIG_CLKDEV_LOOKUP=y +# CONFIG_COMMON_CLK_CDCE706 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PIC32 is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_SI5351 is not set +CONFIG_COMMON_CLK=y +# CONFIG_CYPRESS_FIRMWARE is not set +# CONFIG_DELL_WMI_AIO is not set +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_DEVTMPFS=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DRM_AMD_ACP=y +# CONFIG_DRM_AMDGPU_CIK is not set +# CONFIG_DRM_AMDGPU_GART_DEBUGFS is not set +# CONFIG_DRM_AMDGPU_SI is not set +CONFIG_DRM_AMDGPU_USERPTR=y +CONFIG_DRM_AMDGPU=y +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +CONFIG_DRM_AST=y +CONFIG_DRM_BOCHS=y +CONFIG_DRM_BRIDGE=y +CONFIG_DRM_CIRRUS_QEMU=y +CONFIG_DRM_DP_AUX_CHARDEV=y +CONFIG_DRM_FBDEV_EMULATION=y +# CONFIG_DRM_GMA3600 is not set +CONFIG_DRM_GMA500=y +CONFIG_DRM_GMA600=y +CONFIG_DRM_I2C_CH7006=y +# CONFIG_DRM_I2C_NXP_TDA998X is not set +CONFIG_DRM_I2C_SIL164=y +# CONFIG_DRM_I915_DEBUG is not set +CONFIG_DRM_I915_GVT=y +# CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT is not set +CONFIG_DRM_I915_USERPTR=y +# CONFIG_DRM_I915_WERROR is not set +CONFIG_DRM_I915=y +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_KMS_HELPER=y +# CONFIG_DRM_LEGACY is not set +CONFIG_DRM_LOAD_EDID_FIRMWARE=y +CONFIG_DRM_MGAG200=y +CONFIG_DRM_MIPI_DSI=y +CONFIG_DRM_NOUVEAU_BACKLIGHT=y +CONFIG_DRM_NOUVEAU=y +CONFIG_DRM_PANEL=y +CONFIG_DRM_QXL=y +CONFIG_DRM_RADEON_USERPTR=y +CONFIG_DRM_RADEON=y +CONFIG_DRM_TTM=y +CONFIG_DRM_UDL=y +# CONFIG_DRM_VGEM is not set +CONFIG_DRM_VMWGFX_FBCON=y +CONFIG_DRM_VMWGFX=y +CONFIG_DRM=y +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +CONFIG_DUMMY_CONSOLE=y +# CONFIG_DVB_DUMMY_FE is not set +CONFIG_DVB_TUNER_DIB0070=m +CONFIG_DVB_TUNER_DIB0090=m +# CONFIG_FB_3DFX is not set +# CONFIG_FB_ARC is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_AUO_K190X is not set +CONFIG_FB_BACKLIGHT=y +CONFIG_FB_BOOT_VESA_SUPPORT=y +# CONFIG_FB_BROADSHEET is not set +# CONFIG_FB_CARMINE is not set +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +# CONFIG_FB_CIRRUS is not set +CONFIG_FB_CMDLINE=y +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_DDC is not set +CONFIG_FB_DEFERRED_IO=y +CONFIG_FB_EFI=y +# CONFIG_FB_FOREIGN_ENDIAN is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_IMSTT is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_LE80578 is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MODE_HELPERS is not set +# CONFIG_FB_N411 is not set +# CONFIG_FB_NEOMAGIC is not set +CONFIG_FB_NOTIFY=y +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIMPLE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_SM501 is not set +# CONFIG_FB_SM712 is not set +# CONFIG_FB_SMSCUFX is not set +# CONFIG_FB_SVGALIB is not set +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_FOPS=y +CONFIG_FB_SYS_IMAGEBLIT=y +CONFIG_FB_TILEBLITTING=y +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_UDL is not set +# CONFIG_FB_UVESA is not set +CONFIG_FB_VESA=y +# CONFIG_FB_VGA16 is not set +# CONFIG_FB_VIA is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +CONFIG_FB=y +# CONFIG_FENCE_TRACE is not set +# CONFIG_FIRMWARE_EDID is not set +CONFIG_FONT_8x16=y +CONFIG_FONT_8x8=y +# CONFIG_FONTS is not set +CONFIG_FONT_SUPPORT=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +CONFIG_FRAMEBUFFER_CONSOLE=y +# CONFIG_FUJITSU_LAPTOP is not set +# CONFIG_GPIO_VIPERBOARD is not set +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_HAVE_CLK=y +CONFIG_HDMI=y +# CONFIG_HP_ACCEL is not set +# CONFIG_HP_WMI is not set +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set +# CONFIG_I2C_EMEV2 is not set +# CONFIG_I2C_VIPERBOARD is not set +CONFIG_INTEL_GTT=y +CONFIG_INTERVAL_TREE=y +# CONFIG_LCD_AMS369FG06 is not set +CONFIG_LCD_CLASS_DEVICE=m +# CONFIG_LCD_HX8357 is not set +# CONFIG_LCD_ILI922X is not set +# CONFIG_LCD_ILI9320 is not set +# CONFIG_LCD_L4F00242T03 is not set +# CONFIG_LCD_LD9040 is not set +# CONFIG_LCD_LMS283GF05 is not set +# CONFIG_LCD_LMS501KF03 is not set +# CONFIG_LCD_LTV350QV is not set +# CONFIG_LCD_PLATFORM is not set +# CONFIG_LCD_S6E63M0 is not set +# CONFIG_LCD_TDO24M is not set +# CONFIG_LCD_VGG2432A4 is not set +CONFIG_LOGO_LINUX_CLUT224=y +CONFIG_LOGO_LINUX_MONO=y +CONFIG_LOGO_LINUX_VGA16=y +CONFIG_LOGO=y +CONFIG_LPC_ICH=y +CONFIG_LPC_SCH=y +# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set +# CONFIG_MEDIA_CAMERA_SUPPORT is not set +# CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set +# CONFIG_MEDIA_PCI_SUPPORT is not set +# CONFIG_MEDIA_RADIO_SUPPORT is not set +# CONFIG_MEDIA_RC_SUPPORT is not set +# CONFIG_MEDIA_SDR_SUPPORT is not set +CONFIG_MEDIA_SUPPORT=y +# CONFIG_MEDIA_USB_SUPPORT is not set +CONFIG_MFD_CORE=y +CONFIG_MFD_INTEL_LPSS_ACPI=y +CONFIG_MFD_INTEL_LPSS=y +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +CONFIG_MFD_SM501_GPIO=y +CONFIG_MFD_SM501=y +CONFIG_MFD_VIPERBOARD=y +CONFIG_MFD_VX855=y +CONFIG_MMU_NOTIFIER=y +# CONFIG_MSI_WMI is not set +CONFIG_MXM_WMI=y +CONFIG_NOUVEAU_DEBUG=5 +CONFIG_NOUVEAU_DEBUG_DEFAULT=3 +# CONFIG_PANASONIC_LAPTOP is not set +CONFIG_PREVENT_FIRMWARE_BUILD=y +# CONFIG_SAMSUNG_LAPTOP is not set +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_SERIO_CT82C710 is not set +CONFIG_SERIO_I8042=y +# CONFIG_SERIO_LIBPS2 is not set +# CONFIG_SERIO_PCIPS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_RAW is not set +CONFIG_SERIO_SERPORT=y +CONFIG_SERIO=y +CONFIG_STANDALONE=y +# CONFIG_THINKPAD_ACPI is not set +# CONFIG_TOSHIBA_WMI is not set +# CONFIG_TTPCI_EEPROM is not set +# CONFIG_USERIO is not set +CONFIG_VGA_ARB_MAX_GPUS=64 +CONFIG_VGA_ARB=y +CONFIG_VGA_CONSOLE=y +CONFIG_VGA_SWITCHEROO=y +# CONFIG_VIDEO_ADV_DEBUG is not set +# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set +CONFIG_VT_HW_CONSOLE_BINDING=y
\ No newline at end of file diff --git a/machine/geedge/TSG-X/kernel/series b/machine/geedge/TSG-X/kernel/series new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/machine/geedge/TSG-X/kernel/series diff --git a/machine/geedge/TSG-X/machine.make b/machine/geedge/TSG-X/machine.make new file mode 100755 index 00000000..fa152586 --- /dev/null +++ b/machine/geedge/TSG-X/machine.make @@ -0,0 +1,56 @@ +# Copyright (C) 2018 GeedgeNetworks. +# Geedge/TSG-X + +ONIE_ARCH ?= x86_64 +SWITCH_ASIC_VENDOR = none + +VENDOR_REV ?= 0 + +# Translate hardware revision to ONIE hardware revision +ifeq ($(VENDOR_REV),0) + MACHINE_REV = 0 +else + $(warning Unknown VENDOR_REV '$(VENDOR_REV)' for MACHINE '$(MACHINE)') + $(error Unknown VENDOR_REV) +endif + +# The VENDOR_VERSION string is appended to the overal ONIE version +# string. HW vendors can use this to appended their own versioning +# information to the base ONIE version string. +# VENDOR_VERSION = .0.3 + +# Vendor ID -- IANA Private Enterprise Number: +# http://www.iana.org/assignments/enterprise-numbers +# Lenovo +# VENDOR_ID = 19046 + +# Enable the i2ctools and the onie-syseeprom command for this platform +# I2CTOOLS_ENABLE = yes + +# Console parameters +#CONSOLE_DEV = 0 +#CONSOLE_SPEED = 115200 +SERIAL_CONSOLE_ENABLE = no + +# Enable UEFI support +UEFI_ENABLE = yes +SKIP_ETHMGMT_MACS = yes + +# Set Linux kernel version +LINUX_VERSION = 4.9 +LINUX_MINOR_VERSION = 95 + +# Specify uClibc version +# UCLIBC_VERSION = 0.9.32.1 +# GCC_VERSION = 9.3.1 + +# Extra kernel command line +EXTRA_CMDLINE_LINUX ?= biosdevname=0 net.ifnames=1 +IPMITOOL_ENABLE ?= yes + +#------------------------------------------------------------------------------- +# +# Local Variables: +# mode: makefile-gmake +# End: + diff --git a/machine/geedge/TSG-X/rootconf/sysroot-init/networking.sh b/machine/geedge/TSG-X/rootconf/sysroot-init/networking.sh new file mode 100755 index 00000000..4603a88c --- /dev/null +++ b/machine/geedge/TSG-X/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/TSG-X/rootconf/sysroot-lib-onie/networking-platform b/machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform new file mode 100755 index 00000000..e8f6843a --- /dev/null +++ b/machine/geedge/TSG-X/rootconf/sysroot-lib-onie/networking-platform @@ -0,0 +1,10 @@ +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 |
