Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Michael Shych
2017-11-13 09:55:44 +00:00
1389 changed files with 180535 additions and 2282 deletions

3
.gitmodules vendored
View File

@@ -16,3 +16,6 @@
[submodule "packages/platforms-closed"]
path = packages/platforms-closed
url = git@github.com:opennetworklinux/platforms-closed
[submodule "sm/build-artifacts"]
path = sm/build-artifacts
url = git://github.com/opennetworklinux/build-artifacts

View File

@@ -26,6 +26,7 @@ $(foreach a,$(ALL_ARCHES),$(eval $(call build_arch_template,$(a))))
# Available build architectures based on the current suite
BUILD_ARCHES_wheezy := amd64 powerpc
BUILD_ARCHES_jessie := $(ALL_ARCHES)
BUILD_ARCHES_stretch := amd64
# Build available architectures by default.
.DEFAULT_GOAL := all

1
REPO/stretch/Makefile Normal file
View File

@@ -0,0 +1 @@
include $(ONL)/make/repo-suite.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/repo.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/repo.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/repo.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/repo.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/repo.mk

View File

@@ -528,7 +528,7 @@ installer_force_umount() {
dev=$1; shift
mpt=$1; shift
case "$mpt" in
/mnt/*)
/mnt/*|/boot/*)
installer_say "Unmounting $mpt (--force)"
umount "$mpt"
;;
@@ -548,6 +548,9 @@ if test -f preinstall.sh; then
./preinstall.sh $rootdir
fi
# make sure any GPT data is valid and clean
installer_fixup_gpt || :
chroot "${rootdir}" $installer_shell
if test -f "$postinst"; then

View File

@@ -11,3 +11,5 @@
- hw-management
- sx-kernel
- onl-kernel-3.16-lts-x86-64-all-modules
- efibootmgr
- gdisk

View File

@@ -17,3 +17,11 @@ mounts:
mount: ro
dir: /mnt/onl/boot
fsck: false
# ESP (EFI system partition)
EFI-BOOT:
mount: ro
dir: /boot/efi
fsck: false
label: EFI System
optional: true

View File

@@ -0,0 +1,79 @@
############################################################
#
# Common Release Packages for all systems.
#
############################################################
- base-files
- sysvinit-core
- locales
- python
- apt
- apt-utils
- procps
- net-tools
- iputils-ping
- less
- sudo
- openssh-server
- iproute
- resolvconf
- vim-tiny
- zile
- nano
- lsof
- mingetty
- traceroute
- realpath
- rsyslog
- nfs-common
- netbase
- bsdmainutils
- ifupdown
- psmisc
- make
- python-cherrypy3
- python-tz
- scapy
- python-pypcap
- snmpd
- snmp
- pciutils
- usbutils
- mtd-utils
- i2c-tools
- isc-dhcp-client
- ntp
- wget
- ethtool
- localepurge
- telnetd
- python-pyinotify
- cpio
- util-linux
- dosfstools
- rssh
- u-boot-tools
- ntpdate
- onlp
- parted
- watchdog
- netplug
- binutils
- file
- smartmontools
- realpath
- iptables
- onl-faultd
- onlp-snmpd
- oom-shim
- python-parted
- python-yaml
- bzip2
- xz-utils
- unzip
- onl-mibs
- openssl
- gdb
- tcpdump
- strace
- sysstat

View File

@@ -0,0 +1,15 @@
############################################################
#
# Common packages for all amd64 systems.
#
############################################################
- dmidecode
- parted
- smartmontools
- grub2
- onl-upgrade
- hw-management
- sx-kernel
- onl-kernel-3.16-lts-x86-64-all-modules
- efibootmgr
- gdisk

View File

@@ -0,0 +1,11 @@
############################################################
#
# These packages are specific to the ONL root filesystem build.
#
############################################################
- onl-upgrade

View File

@@ -0,0 +1 @@
- u-boot-tools

View File

@@ -0,0 +1,9 @@
############################################################
#
# These packages are specific to the ONL root filesystem build.
#
############################################################
- onl-loader-fit

View File

@@ -0,0 +1 @@
- u-boot-tools

View File

@@ -0,0 +1,9 @@
############################################################
#
# These packages are specific to the ONL root filesystem build.
#
############################################################
- onl-loader-fit

View File

@@ -0,0 +1 @@
0.0 0 0.0

View File

@@ -0,0 +1,6 @@
jffs2
ubifs
vfat
ext4
ext3
ext2

View File

@@ -0,0 +1,3 @@
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
qotd stream tcp nowait telnetd /usr/sbin/tcpd /sbin/versiond

View File

@@ -0,0 +1,67 @@
# The default runlevel.
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si0::sysinit:/etc/boot.d/boot
si1::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."
# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3

View File

@@ -0,0 +1,27 @@
mounts:
ONL-IMAGES:
mount: ro
dir: /mnt/onl/images
fsck: true
ONL-DATA:
mount: rw
dir: /mnt/onl/data
ONL-CONFIG:
mount: ro
dir: /mnt/onl/config
fsck: true
ONL-BOOT:
mount: ro
dir: /mnt/onl/boot
fsck: false
# ESP (EFI system partition)
EFI-BOOT:
mount: ro
dir: /boot/efi
fsck: false
label: EFI System
optional: true

View File

@@ -0,0 +1,7 @@
############################################################
#
# Add platform specific directories to path.
#
############################################################
dir=/lib/platform-config/current/onl
export PATH="$PATH:$dir/bin:$dir/sbin:$dir/lib/bin:$dir/lib/sbin"

View File

@@ -0,0 +1,4 @@
logfacility = LOG_USER
allowsftp
allowscp
umask = 022

View File

@@ -0,0 +1,195 @@
###############################################################################
#
# EXAMPLE.conf:
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See the 'snmpd.conf(5)' man page for details
#
# Some entries are deliberately commented out, and will need to be explicitly activated
#
###############################################################################
#
# AGENT BEHAVIOUR
#
# Listen for connections from the local system only
# agentAddress udp:127.0.0.1:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
###############################################################################
#
# SNMPv3 AUTHENTICATION
#
# Note that these particular settings don't actually belong here.
# They should be copied to the file /var/lib/snmp/snmpd.conf
# and the passwords changed, before being uncommented in that file *only*.
# Then restart the agent
# createUser authOnlyUser MD5 "remember to change this password"
# createUser authPrivUser SHA "remember to change this one too" DES
# createUser internalUser MD5 "this is only ever used internally, but still change the password"
# If you also change the usernames (which might be sensible),
# then remember to update the other occurances in this example config file to match.
###############################################################################
#
# ACCESS CONTROL
#
# system + hrSystem groups only
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
view systemonly included .1.3.6.1.4.1.42623
# Full access from the local host
rocommunity public localhost
# Default access to basic system info
rocommunity public default -V systemonly
# rocommunity6 is for IPv6
rocommunity6 public default -V systemonly
# Full access from an example network
# Adjust this network address to match your local
# settings, change the community string,
# and check the 'agentAddress' setting above
#rocommunity secret 10.0.0.0/16
# Full read-only access for SNMPv3
rouser authOnlyUser
# Full write access for encrypted requests
# Remember to activate the 'createUser' lines above
#rwuser authPrivUser priv
# It's no longer typically necessary to use the full 'com2sec/group/access' configuration
# r[ow]user and r[ow]community, together with suitable views, should cover most requirements
###############################################################################
#
# SYSTEM INFORMATION
#
# Note that setting these values here, results in the corresponding MIB objects being 'read-only'
# See snmpd.conf(5) for more details
sysLocation Sitting on the Dock of the Bay
sysContact Me <me@example.org>
# Application + End-to-End layers
sysServices 72
#
# Process Monitoring
#
# At least one 'mountd' process
proc mountd
# No more than 4 'ntalkd' processes - 0 is OK
proc ntalkd 4
# At least one 'sendmail' process, but no more than 10
proc sendmail 10 1
# Walk the UCD-SNMP-MIB::prTable to see the resulting output
# Note that this table will be empty if there are no "proc" entries in the snmpd.conf file
#
# Disk Monitoring
#
# 10MBs required on root disk, 5% free on /var, 10% free on all other disks
disk / 10000
disk /var 5%
includeAllDisks 10%
# Walk the UCD-SNMP-MIB::dskTable to see the resulting output
# Note that this table will be empty if there are no "disk" entries in the snmpd.conf file
#
# System Load
#
# Unacceptable 1-, 5-, and 15-minute load averages
load 12 10 5
# Walk the UCD-SNMP-MIB::laTable to see the resulting output
# Note that this table *will* be populated, even without a "load" entry in the snmpd.conf file
###############################################################################
#
# ACTIVE MONITORING
#
# send SNMPv1 traps
trapsink localhost public
# send SNMPv2c traps
#trap2sink localhost public
# send SNMPv2c INFORMs
#informsink localhost public
# Note that you typically only want *one* of these three lines
# Uncommenting two (or all three) will result in multiple copies of each notification.
#
# Event MIB - automatically generate alerts
#
# Remember to activate the 'createUser' lines above
iquerySecName internalUser
rouser internalUser
# generate traps on UCD error conditions
defaultMonitors yes
# generate traps on linkUp/Down
linkUpDownNotifications yes
###############################################################################
#
# EXTENDING THE AGENT
#
#
# Arbitrary extension commands
#
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
#extend-sh test3 /bin/sh /tmp/shtest
# Note that this last entry requires the script '/tmp/shtest' to be created first,
# containing the same three shell commands, before the line is uncommented
# Walk the NET-SNMP-EXTEND-MIB tables (nsExtendConfigTable, nsExtendOutput1Table
# and nsExtendOutput2Table) to see the resulting output
# Note that the "extend" directive supercedes the previous "exec" and "sh" directives
# However, walking the UCD-SNMP-MIB::extTable should still returns the same output,
# as well as the fuller results in the above tables.
#
# "Pass-through" MIB extension command
#
#pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest
#pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl
# Note that this requires one of the two 'passtest' scripts to be installed first,
# before the appropriate line is uncommented.
# These scripts can be found in the 'local' directory of the source distribution,
# and are not installed automatically.
# Walk the NET-SNMP-PASS-MIB::netSnmpPassExamples subtree to see the resulting output
#
# AgentX Sub-agents
#
# Run as an AgentX master agent
master agentx
# Listen for network connections (from localhost)
# rather than the default named socket /var/agentx/master
#agentXSocket tcp:localhost:705

View File

@@ -0,0 +1 @@
SUBSYSTEM=="block", RUN+="/sbin/initblockdev $kernel $env{ACTION}"

View File

@@ -0,0 +1 @@
SUBSYSTEM=="net", RUN+="/sbin/initnetdev $kernel $env{ACTION}"

View File

@@ -0,0 +1,23 @@
#!/bin/sh
t=/dev/$1
# if $1 is not set, use linux cmdline console as default tty
[ -z "$1" ] && {
tty=$(/bin/sed 's/.*console=\([^,]*\).*/\1/' /proc/cmdline)
t=/dev/$tty
}
# Reset the console tty to standard settings
/bin/stty -F $t sane pass8 -ixon -cstopb clocal
# Kill any processes with the console tty open before starting a new
# login session (login tries to do this, but vhangup() spares processes
# that ignore SIGHUP)
#/usr/bin/lsof -p ^$$ -t $t 0<&- 1>&- 2>&- | /usr/bin/xargs -r /bin/kill -9
# Flush tty input and output queues
#/sbin/flushtty <$t
# We use mingetty instead of agetty, as the latter messes up the tty
# settings if it receives junk characters at the wrong speed
exec /sbin/mingetty --noclear $t

View File

@@ -0,0 +1,71 @@
#!/usr/bin/python
############################################################
# <bsn.cl fy=2013 v=onl>
#
# Copyright 2013, 2014 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
# watchdir
#
############################################################
import optparse, os.path, sys
import pyinotify
#pyinotify.log.setLevel(pyinotify.logging.DEBUG)
op = optparse.OptionParser( usage="%prog [OPTIONS] command")
op.add_option("-w", "--watchdir", action="append",
help="monitor watchdir for changes (may be used multiple times)")
op.add_option("--period", action="store", type="float",
help="run command at most every period sec (default=%default)")
op.add_option("-d", "--daemon", action="store_true",
help="run in background")
op.add_option("--logfile", action="store",
help="send output to logfile when running in background")
op.add_option("--pidfile", action="store",
help="write pid to pidfile when running in background")
op.set_defaults(period=0, logfile="/dev/stdout", pidfile=False)
opts, args = op.parse_args()
if not opts.watchdir:
op.error("need at least one watchdir")
os.close(0)
os.open("/dev/null", os.O_RDONLY)
wm = pyinotify.WatchManager()
n = pyinotify.Notifier(wm, read_freq=opts.period)
def handle(event):
dir = None
for d in opts.watchdir:
if os.path.commonprefix([d, event.pathname]) == d:
dir = d
sys.stdout.write("%s: %s %s\n" % (dir, event.pathname, event))
sys.stdout.flush()
if args:
os.spawnvp(os.P_WAIT, args[0],
args + [dir, event.pathname, event.maskname])
wm.add_watch(
opts.watchdir,
pyinotify.IN_ATTRIB | pyinotify.IN_CREATE | pyinotify.IN_DELETE |
pyinotify.IN_MODIFY | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO,
handle,
rec=True,
auto_add=True)
n.loop(daemonize=opts.daemon, stdout=opts.logfile, stderr=opts.logfile,
pid_file=opts.pidfile)

View File

@@ -0,0 +1,11 @@
############################################################
#
# Common packages for all PowerPC systems.
#
############################################################
- u-boot-tools

View File

@@ -0,0 +1,9 @@
############################################################
#
# These packages are specific to the ONL root filesystem build.
#
############################################################
- onl-loader-fit

View File

@@ -0,0 +1,105 @@
############################################################
#
# Standard ONL Debian 9 Root Filesystem Configuration.
#
# Requires:
# ARCH, PLATFORM_LIST
#
#
############################################################
variables:
!include $ONL/make/versions/version-onl.yml
Packages: &Packages
- !include $ONL/builds/any/rootfs/$ONL_DEBIAN_SUITE/common/all-base-packages.yml
- !include $ONL/builds/any/rootfs/$ONL_DEBIAN_SUITE/common/${ARCH}-base-packages.yml
- !include $ONL/builds/any/rootfs/$ONL_DEBIAN_SUITE/common/${ARCH}-onl-packages.yml
- !script $ONL/tools/onl-platform-pkgs.py ${PLATFORM_LIST}
Multistrap:
General:
arch: ${ARCH}
cleanup: true
noauth: true
explicitsuite: false
unpack: true
debootstrap: Debian-Local Local-All Local-Arch ONL
aptsources: Debian ONL
Debian:
packages: *Packages
source: http://${DEBIAN_MIRROR}
suite: ${ONL_DEBIAN_SUITE}
keyring: debian-archive-keyring
omitdebsrc: true
Debian-Local:
packages: *Packages
source: http://${APT_CACHE}${DEBIAN_MIRROR}
suite: ${ONL_DEBIAN_SUITE}
keyring: debian-archive-keyring
omitdebsrc: true
ONL:
packages: *Packages
source: http://apt.opennetlinux.org/debian
suite: unstable
omitdebsrc: true
Local-All:
source: ${ONLPM_OPTION_REPO}/${ONL_DEBIAN_SUITE}/packages/binary-all
omitdebsrc: true
Local-Arch:
source: ${ONLPM_OPTION_REPO}/${ONL_DEBIAN_SUITE}/packages/binary-${ARCH}
omitdebsrc: true
Configure:
overlays:
- ${ONL}/builds/any/rootfs/${ONL_DEBIAN_SUITE}/common/overlay
update-rc.d:
- 'faultd defaults'
- 'onlpd defaults'
- 'snmpd defaults'
- 'onlp-snmpd defaults'
- 'ssh defaults'
- 'openbsd-inetd remove'
- 'ntp remove'
- 'nfs-common remove'
- 'rpcbind remove'
- 'motd remove'
- 'mountall-bootclean.sh remove'
- 'mountall.sh remove'
- 'checkfs.sh remove'
- 'mtab.sh remove'
- 'checkroot-bootclean.sh remove'
- 'checkroot.sh remove'
- 'mountnfs-bootclean.sh remove'
- 'mountnfs.sh remove'
- 'lm-sensors remove'
- 'netplug defaults'
- 'watchdog defaults'
- 'wd_keepalive remove'
options:
clean: True
securetty: False
ttys: False
console: True
PermitRootLogin: 'yes'
users:
root:
password: onl
manifests:
'/etc/onl/rootfs/manifest.json' :
version : $ONL/make/versions/version-onl.json
platforms : $PLATFORM_LIST
issue: $VERSION_STRING
files:
remove:
- /etc/motd

View File

@@ -0,0 +1,37 @@
############################################################
#
# Update with FRR support dependencies.
#
############################################################
FROM opennetworklinux/builder8:1.5
MAINTAINER Jeffrey Townsend <jeffrey.townsend@bigswitch.com>
RUN apt-get update && apt-get install -y \
chrpath devscripts dh-autoreconf dh-systemd flex \
hardening-wrapper libcap-dev libc-ares-dev libjson0 \
libjson0-dev libjson-c-dev libpam0g-dev libpcre3-dev \
libreadline-dev libsystemd-dev pkg-config \
texlive-generic-recommended texinfo texlive-latex-base
RUN xapt -a powerpc chrpath hardening-wrapper \
libcap-dev libc-ares-dev libjson0 libjson0-dev \
libjson-c-dev libpam0g-dev libpcre3-dev libreadline-dev \
libsystemd-dev pkg-config texinfo libreadline6-dev \
libtext-unidecode-perl libintl-perl libxml-libxml-perl
RUN xapt -a arm64 chrpath hardening-wrapper \
libcap-dev libc-ares-dev libjson0 libjson0-dev \
libjson-c-dev libpam0g-dev libpcre3-dev libreadline-dev \
libsystemd-dev pkg-config texinfo libreadline6-dev \
libintl-perl libxml-libxml-perl
RUN xapt -a armel chrpath hardening-wrapper \
libcap-dev libc-ares-dev libjson0 libjson0-dev \
libjson-c-dev libpam0g-dev libpcre3-dev libreadline-dev \
libsystemd-dev pkg-config texinfo libreadline6-dev \
libintl-perl libxml-libxml-perl
# Docker shell and other container tools.
#
COPY docker_shell /bin/docker_shell
COPY container-id /bin/container-id

View File

@@ -0,0 +1,19 @@
VERSION=1.6
USER=opennetworklinux
REPO=builder8
TOOLS=../../../tools/docker_shell ../../../tools/container-id
build: check_version
cp $(TOOLS) .
docker build -t $(USER)/$(REPO):$(VERSION) .
rm -rf $(notdir $(TOOLS))
#
# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites
# when a new image is built but the VERSION variable is not updated.
#
check_version:
push:
docker push $(USER)/$(REPO):$(VERSION)

View File

@@ -0,0 +1,27 @@
############################################################
#
# Fix broken cross dependencies.
# Update Packages.
# Additional build dependencies.
#
############################################################
FROM opennetworklinux/builder8:1.6
MAINTAINER Jeffrey Townsend <jeffrey.townsend@bigswitch.com>
#ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install -f && \
apt-get update
RUN xapt -a powerpc libsnmp-dev && \
xapt -a armel libsnmp-dev && \
xapt -a arm64 libsnmp-dev
RUN apt-get install -f
RUN DEBIAN_FRONTEND=noninteractive apt-get install tshark -y
RUN sudo apt-get install -yq libpcap-dev libxml2-dev python-dev g++ swig tcpreplay libusb-dev
# Docker shell and other container tools.
#
COPY docker_shell /bin/docker_shell
COPY container-id /bin/container-id

View File

@@ -0,0 +1,19 @@
VERSION=1.7
USER=opennetworklinux
REPO=builder8
TOOLS=../../../tools/docker_shell ../../../tools/container-id
build: check_version
cp $(TOOLS) .
docker build -t $(USER)/$(REPO):$(VERSION) .
rm -rf $(notdir $(TOOLS))
#
# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites
# when a new image is built but the VERSION variable is not updated.
#
check_version:
push:
docker push $(USER)/$(REPO):$(VERSION)

View File

@@ -0,0 +1,137 @@
FROM debian:9.1
MAINTAINER Jeff Townsend <jeffrey.townsend@bigswitch.com>
# First round of dependences
RUN apt-get update && apt-get install -y \
apt \
apt-cacher-ng \
apt-file \
apt-utils \
autoconf \
automake \
autotools-dev \
bash-completion \
bc \
bind9-host \
binfmt-support \
binfmt-support \
bison \
bsdmainutils \
build-essential \
ccache \
cdbs \
cpio \
cryptsetup-bin \
debhelper \
debhelper \
debhelper \
device-tree-compiler \
devscripts \
devscripts \
dialog \
dosfstools \
doxygen \
dpkg-sig \
emacs \
file \
flex \
gawk \
gcc \
gdb \
genisoimage \
git \
gperf \
ifupdown \
iproute \
iputils-ping \
isolinux \
kmod \
less \
libc6-dev \
libcurl4-nss-dev \
libdouble-conversion-dev \
libedit-dev \
libevent-dev \
libexpat1-dev \
libgoogle-glog-dev \
libi2c-dev \
libkrb5-dev \
libnuma-dev \
libsasl2-dev \
libsnappy-dev \
libpam-dev \
libpcap-dev \
libsnmp-dev \
libssl-dev \
libtool \
libtool-bin \
locales \
lsof \
make \
mingetty \
mtd-utils \
mtools \
multistrap \
nano \
ncurses-dev \
netbase \
net-tools \
nfs-common \
openssh-server \
pkg-config \
pkg-config \
procps \
psmisc \
python \
python-debian \
python-dnspython \
python-yaml \
qemu \
qemu-user-static \
realpath \
realpath \
rsyslog \
ruby \
ruby-dev \
rubygems \
screen \
squashfs-tools \
sshpass \
stgit \
sudo \
syslinux-utils \
telnet \
texinfo \
traceroute \
u-boot-tools \
vim-tiny \
wget \
xorriso \
zile \
zip
RUN apt-get install -y \
chrpath devscripts dh-autoreconf dh-systemd flex \
libcap-dev libc-ares-dev libjson-c-dev libpam0g-dev libpcre3-dev \
libreadline-dev libsystemd-dev pkg-config \
texlive-generic-recommended texinfo texlive-latex-base
RUN gem install --version 1.3.3 fpm
#
# The i2c-dev.h user/kernel header conflict is a nightmare.
#
# The ONLP implementation expects a new file called <linux/i2c-device.h> to be in place which contains the correct user-space driver definitions.
# This should be manually populated here after the toolchains have been installed.
#
RUN cp /usr/include/linux/i2c-dev.h /usr/include/linux/i2c-devices.h
RUN rm /etc/apt/apt.conf.d/docker-* && \
wget "https://launchpad.net/ubuntu/+source/qemu/1.4.0+dfsg-1expubuntu3/+build/4336762/+files/qemu-user-static_1.4.0%2Bdfsg-1expubuntu3_amd64.deb" && \
dpkg -i qemu-user-static_1.4.0+dfsg-1expubuntu3_amd64.deb
#
# Copy the docker shell init script to /bin
#
COPY docker_shell /bin/docker_shell
COPY container-id /bin/container-id

View File

@@ -0,0 +1,19 @@
VERSION=1.0
USER=opennetworklinux
REPO=builder9
TOOLS=../../../tools/docker_shell ../../../tools/container-id
build: check_version
cp $(TOOLS) .
docker build -t $(USER)/$(REPO):$(VERSION) .
rm -rf $(notdir $(TOOLS))
#
# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites
# when a new image is built but the VERSION variable is not updated.
#
check_version:
push:
docker push $(USER)/$(REPO):$(VERSION)

View File

@@ -1,6 +1,6 @@
common:
arch: all
version: 1.3.0
version: 1.4.0
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
maintainer: support@bigswitch.com
support: opennetworklinux@googlegroups.com

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2
# -*- python -*-
import re

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2
import os
import sys
@@ -18,7 +18,8 @@ g_current_uid = os.getuid()
g_timestamp = datetime.datetime.now().strftime("%Y-%m-%d.%H%M%S")
g_builder7_image_name="opennetworklinux/builder7:1.2"
g_builder8_image_name="opennetworklinux/builder8:1.5"
g_builder8_image_name="opennetworklinux/builder8:1.7"
g_builder9_image_name="opennetworklinux/builder9:1.0"
g_default_image_name=g_builder8_image_name
g_default_container_name = "%s_%s" % (g_current_user, g_timestamp)
@@ -26,6 +27,9 @@ g_default_user="%s:%s" % (g_current_user, g_current_uid)
ap = argparse.ArgumentParser("ONL Docker Build")
ap.add_argument('--9', '-9',
help="Run the Debian 9 version.",
action='store_true', dest='debian9')
ap.add_argument('--8', '-8',
help="Run the Debian 8 version.",
action='store_true', dest='debian8')
@@ -117,6 +121,8 @@ if ops.debian7:
if ops.debian8:
ops.image = g_builder8_image_name
if ops.debian9:
ops.image = g_builder9_image_name
if ops.verbose or ops.dry:
logger.setLevel(logging.DEBUG)

View File

@@ -7,5 +7,4 @@ include $(ONL)/make/config.mk
export TOOLCHAIN := x86_64-linux-gnu
export ARCH := amd64
export UARCH := AMD64
export __$(ARCH)__ := 1

View File

@@ -7,3 +7,4 @@ include $(ONL)/make/config.mk
export TOOLCHAIN := aarch64-linux-gnu
export ARCH := arm64
export UARCH := ARM64
export __$(ARCH)__ := 1

View File

@@ -7,3 +7,4 @@ include $(ONL)/make/config.mk
export TOOLCHAIN := arm-linux-gnueabi
export ARCH := armel
export UARCH := ARMEL
export __$(ARCH)__ := 1

View File

@@ -7,5 +7,4 @@ include $(ONL)/make/config.mk
export TOOLCHAIN := powerpc-linux-gnu
export ARCH := powerpc
export UARCH := PPC
export __$(ARCH)__ := 1

View File

@@ -103,10 +103,11 @@ K_ARCHIVE_NAME := $(K_NAME).$(K_ARCHIVE_EXT)
endif
K_ARCHIVE_PATH := $(ONL_KERNELS)/archives/$(K_ARCHIVE_NAME)
ifndef K_ARCHIVE_URL
K_ARCHIVE_URL := https://www.kernel.org/pub/linux/kernel/v3.x/$(K_ARCHIVE_NAME)
K_ARCHIVE_URL := https://www.kernel.org/pub/linux/kernel/v$(K_MAJOR_VERSION).x/$(K_ARCHIVE_NAME)
endif
K_SOURCE_DIR := $(K_TARGET_DIR)/$(K_NAME)
K_MBUILD_DIR := $(K_SOURCE_DIR)-mbuild
K_INSTALL_MOD_PATH := $(K_TARGET_DIR)
K_DTBS_DIR := $(K_SOURCE_DIR)-dtbs
#
@@ -153,6 +154,12 @@ K_MAKE := $(MAKE) -C $(K_SOURCE_DIR)
#
build: setup
+$(K_MAKE) $(K_BUILD_TARGET)
+$(K_MAKE) modules
+$(K_MAKE) modules_install INSTALL_MOD_PATH=$(K_INSTALL_MOD_PATH)
find $(K_INSTALL_MOD_PATH) -type l -name source -delete
find $(K_INSTALL_MOD_PATH) -type l -name build -delete
ifdef K_COPY_SRC
ifdef K_COPY_DST
ifdef K_COPY_GZIP
@@ -180,6 +187,7 @@ mbuild: build
$(foreach f,$(MODSYNCLIST),$(ONL)/tools/scripts/tree-copy.sh $(K_SOURCE_DIR) $(f) $(K_MBUILD_DIR);)
find $(K_MBUILD_DIR) -name "*.o*" -delete
find $(K_MBUILD_DIR) -name "*.c" -delete
find $(K_MBUILD_DIR) -name "*.ko" -delete
$(foreach f,$(MODSYNCKEEP), cp $(K_SOURCE_DIR)/$(f) $(K_MBUILD_DIR)/$(f) || true;)
dtbs: mbuild

View File

@@ -85,10 +85,42 @@ shift
[ ! "${testonly}" ] || set -x
# set up some tempfs for our download
swi_kmin=1048576
workdir=$(mktemp -d -t boot-tmpfs-XXXXXX)
export TMPDIR=$workdir
# export this tempfs as temporary space for swiprep below
echo "creating ${swi_kmin}k of tmpfs in $workdir"
mount -v -t tmpfs -o size=${swi_kmin}k tmpfs $workdir
workmnt=$workdir
do_cleanup() {
cd /tmp
if [ "$workmnt" ]; then
if grep -q "$workmnt" /proc/mounts; then
umount -v "$workmnt" || :
fi
fi
rm -fr "$workdir"
}
trap "do_cleanup" 0 1
unset swipath host bhost port dir file dev user password scope
case "${SWI}" in
nfs://*/|dir:*)
echo "Mounting ${SWI}"
# do not use the ephemeral temporary directory for
# locally-mounted directories
if test "$workmnt"; then
umount "$workmnt" || :
fi
unset TMPDIR
swipath=$(swimount $SWI)
if [ "$rootfs" ]; then
[ -d "${swipath}/${rootfs}" ] || { echo "${SWI}${rootfs} must be an unpacked rootfs"; exit 1; }
@@ -131,6 +163,10 @@ fi
if [ "$testonly" ]; then
echo "swipath=$swipath rootfs=$rootfs"
echo "Stop here"
trap "" 0 1
# leave temporary directory and mounts
exit 0
fi
@@ -140,6 +176,45 @@ if [ -d "${swipath}" ]; then
umount -l /newroot 2>/dev/null || :
mount --bind "${swipath}/${rootfs}" /newroot
else
##############################
#
# swiprep will (1) unpack the squashfs image to a file,
# and (2) extract the filesystem to /newroot.
#
# We need to make sure there is enough disk space for this...
#
##############################
set dummy $(df -k -P "$workmnt" | tail -1)
tmpavail=$5
# estimate the squashfs size based on the largest one here
# (there may be more than one arch in the SWI file)
squashsz=0
ifs=$IFS; IFS=$CR
for line in $(unzip -ql "$swipath"); do
IFS=$ifs
set dummy $line
case "$5" in
*.sqsh)
if [ "$2" -gt $squashsz ]; then
squashsz=$2
fi
;;
esac
done
IFS=$ifs
# pad by a little to account for inodes and such
squashsz=$(( $squashsz * 105 / 100 ))
if [ $squashsz -gt $tmpavail ]; then
tmpsz=$(( $swi_kmin + $squashsz - $tmpavail ))
echo "Resizing tmpfs to ${tmpsz}k"
mount -o remount,size=${tmpsz}k $workmnt
fi
swiprep --overlay "${swipath}${rootfs}" --unmount --swiref "$swistamp" /newroot
swiprep --record "${swipath}${rootfs}" --swiref "$swistamp" /newroot
fi
@@ -152,6 +227,10 @@ if [ -f /lib/boot-custom ]; then
. /lib/boot-custom
fi
# done with the temporary dirs and mounts
trap "" 0 1
do_cleanup || :
echo "Switching rootfs" # limit 16 chars since serial buffer is not flushed
kill -QUIT 1 # exec /bin/switchroot as PID 1
sleep 30
@@ -162,4 +241,5 @@ exit 1
# Local variables:
# mode: sh
# sh-basic-offset: 4
# sh-indentation: 4
# End:

View File

@@ -85,9 +85,10 @@ case "${NETAUTO}" in
if [ "${NETIP}" ] && [ "${NETMASK}" ] && [ "${NETIP#*/}" = "${NETIP}" ]; then
NETIP=${NETIP}/$(ipcalc -p -s ${NETIP} ${NETMASK} | sed -n 's/PREFIX=//p')
fi
ip link set ${NETDEV} down
echo 0 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf
ip addr flush dev ${NETDEV}
ip addr flush dev ${NETDEV}
ip route flush dev ${NETDEV}
if [ "${NETIP}" ]; then
ip addr add ${NETIP} dev ${NETDEV}
fi
@@ -140,4 +141,7 @@ wait_link_up()
return 1
}
wait_link_up $NETDEV 100
if [ -n "${NETAUTO}" ]; then
wait_link_up $NETDEV 100
fi
return 0

View File

@@ -141,16 +141,24 @@ case $(uname -m) in
ARCH_LIST="armel"
;;
aarch64)
ARCH_LIST="arm64"
;;
ARCH_LIST="arm64"
;;
*)
q;;
;;
esac
if test "${mode_install}${mode_overlay}"; then
for arch in $ARCH_LIST; do
unzip -pq "$swipath" "rootfs-${arch}.sqsh" > "$workdir/rootfs.sqsh"
if test -s "$workdir/rootfs.sqsh"; then break; fi
if unzip -q "$swipath" "rootfs-${arch}.sqsh" -d "$workdir"; then
:
else
echo "*** unzip of root squashfs failed" 1>&2
rm -f "$workdir/rootfs-${arch}.sqsh"
fi
if test -s "$workdir/rootfs-${arch}.sqsh"; then
mv "$workdir/rootfs-${arch}.sqsh" "$workdir/rootfs.sqsh"
break;
fi
done
if test ! -s "$workdir/rootfs.sqsh"; then
echo "*** cannot find a valid rootfs" 1>&2

View File

@@ -49,7 +49,13 @@ done <${mtab}
rm -f ${mtab}
mount --move /proc /newroot/proc
if [ -d /sys/firmware/efi/efivars ]; then
umount /sys/firmware/efi/efivars || :
fi
mount --move /sys /newroot/sys
if [ -d /newroot/sys/firmware/efi/efivars ]; then
mount -t efivarfs efivarfs /newroot/sys/firmware/efi/efivars
fi
mount --move /dev /newroot/dev
# Switch to /newroot if possible, else re-execute /init
@@ -58,3 +64,8 @@ if [ -x /newroot/sbin/init ]; then
else
exec /init
fi
# Local variables:
# sh-indentation: 4
# sh-basic-offset: 4
# End:

View File

@@ -35,6 +35,9 @@ trap "restoreconsole; reboot -f" EXIT
# Mount special filesystems
mount -t proc proc /proc
mount -t sysfs sysfs /sys
if [ -d /sys/firmware/efi/efivars ]; then
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
fi
mount -o remount,size=1M /dev
case "$(stat -f -c "%T" /tmp)" in
tmpfs|ramfs) ;;
@@ -144,4 +147,5 @@ trap - EXIT
# Local variables:
# sh-basic-offset: 4
# sh-indentation: 4
# End:

View File

@@ -26,4 +26,4 @@
. /lib/customize.sh
kill $(cat /tmp/udhcpc.pid 2>/dev/null) 2>/dev/null
exec busybox udhcpc -V $ONL_UDHCPC_VENDOR -p /tmp/udhcpc.pid -s /lib/udhcpc-script "$@"
exec busybox udhcpc -O url -V $ONL_UDHCPC_VENDOR -p /tmp/udhcpc.pid -s /lib/udhcpc-script "$@"

View File

@@ -19,7 +19,7 @@ fi
#
for url in $SWI; do
msg_info "Trying ${url}..."
timeout -t 60 boot "${url}" && exit 0
timeout -t 180 boot "${url}" && exit 0
done
exit 1

View File

@@ -18,3 +18,11 @@ mounts:
mount: rw
dir: /mnt/onl/boot
fsck: true
# ESP (EFI system partition)
EFI-BOOT:
mount: ro
dir: /boot/efi
fsck: false
label: EFI System
optional: true

View File

@@ -1,22 +1,22 @@
#!/bin/sh
############################################################
# <bsn.cl fy=2013 v=onl>
#
# Copyright 2013, 2014 BigSwitch Networks, Inc.
#
#
# Copyright 2013, 2014 BigSwitch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.eclipse.org/legal/epl-v10.html
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
#
# </bsn.cl>
############################################################
#
@@ -26,6 +26,9 @@
[ "${interface}" ] || exit
URUN=/var/run/udhcpc
rm -rf ${URUN} && mkdir -p ${URUN}
case "$1" in
deconfig)
ifconfig ${interface} 0.0.0.0
@@ -36,6 +39,9 @@ case "$1" in
: >/etc/resolv.conf
[ ! "${domain}" ] || echo "search ${domain}" >>/etc/resolv.conf
[ ! "${dns}" ] || echo "nameserver ${dns}" >>/etc/resolv.conf
[ ! "${boot_file}" ] || echo "${boot_file}" >/tmp/udhcpc.boot_file
[ ! "${boot_file}" ] || echo "${boot_file}" > ${URUN}/boot_file
[ ! "${siaddr}" ] || echo "${siaddr}" > ${URUN}/siaddr
[ ! "${url}" ] || echo "${url}" > ${URUN}/url
;;
esac

View File

@@ -5,9 +5,28 @@ if [ -z "$1" ]; then
exit 1
fi
ARCH=`uname -m`
case $ARCH in
armv7l|ppc)
;;
*)
echo "This script cannot be used on $ARCH platforms."
exit 1
;;
esac
PLATFORM=$(cat /etc/onl/platform)
dir=`mktemp -d`
(cd $dir && wget $1)
onlfs rw boot mv $dir/* /mnt/onl/boot/${PLATFORM}.itb
rc=
if (cd $dir && wget $1); then
onlfs rw boot mv $dir/* /mnt/onl/boot/${PLATFORM}.itb
rc=0
else
echo "Download failed."
rc=1
fi
rmdir $dir
exit $rc

View File

@@ -0,0 +1,32 @@
#!/bin/sh
############################################################
if [ -z "$1" ]; then
echo "usage: $0 <initrd url>"
exit 1
fi
ARCH=`uname -m`
case $ARCH in
x86_64)
;;
*)
echo "This script cannot be used on $ARCH platforms."
exit 1
;;
esac
PLATFORM=$(cat /etc/onl/platform)
dir=`mktemp -d`
rc=
if (cd $dir && wget $1); then
onlfs rw boot mv $dir/* /mnt/onl/boot/${PLATFORM}.cpio.gz
rc=0
else
echo "Download failed."
rc=1
fi
rmdir $dir
exit $rc

View File

@@ -5,7 +5,26 @@ if [ -z "$1" ]; then
exit 1
fi
ARCH=`uname -m`
case $ARCH in
x86_64)
;;
*)
echo "This script cannot be used on $ARCH platforms."
exit 1
;;
esac
dir=`mktemp -d`
(cd $dir && wget $1)
onlfs rw boot mv $dir/* /mnt/onl/boot
rc=
if (cd $dir && wget $1); then
onlfs rw boot mv $dir/* /mnt/onl/boot
rc=0
else
echo "Download failed."
rc=1
fi
rmdir $dir
exit $rc

View File

@@ -113,6 +113,9 @@ installer_mkchroot() {
mkdir -p ${rootdir}/dev/pts
fi
mount -t devpts devpts "${rootdir}/dev/pts"
if test -d "${rootdir}/sys/firmware/efi/efivars"; then
mount -t efivarfs efivarfs "${rootdir}/sys/firmware/efi/efivars"
fi
if test ${TMPDIR+set}; then
# make the tempdir available to the chroot
@@ -186,6 +189,166 @@ visit_blkid()
return 0
}
##############################
#
# Fixup a corrupted GPT partition, within reason
# See SWL-3971
#
##############################
blkid_find_gpt_boot() {
local dev label
dev=$1; shift
label=$1; shift
rest="$@"
installer_say "Examining $dev --> $label"
# EFI partition shows up as a valid partition with blkid
if test "$label" = "EFI System"; then
installer_say "Found EFI System partition at $dev"
ESP_DEVICE=$(echo "$dev" | sed -e 's/[0-9]$//')
# this is definitely the boot disk
return 2
fi
# sometimes this is hidden from blkid (no filesystem)
if test "$label" = "GRUB-BOOT"; then
installer_say "Found GRUB boot partition at $dev"
GRUB_DEVICE=$(echo "$dev" | sed -e 's/[0-9]$//')
# probably the boot disk, look for a GPT header
return 0
fi
# shows up in blkid but may not be GPT
if test "$label" = "ONIE-BOOT"; then
installer_say "Found ONIE boot partition at $dev"
ONIE_DEVICE=$(echo "$dev" | sed -e 's/[0-9]$//')
# probably the boot disk, look for a GPT header
return 0
fi
# not found, skip
return 0
}
installer_fixup_gpt() {
local buf dat sts dev do_recover
buf=$(mktemp -u -t sgdisk-XXXXXX)
ESP_DEVICE=
GRUB_DEVICE=
ONIE_DEVICE=
visit_blkid blkid_find_gpt_boot
dev=
if test -b "$ESP_DEVICE"; then
dev=$ESP_DEVICE
elif test -b "$GRUB_DEVICE"; then
sgdisk -p "$GRUB_DEVICE" > "$buf" 2>&1 || :
if grep -q GUID "$buf"; then
dev=$GRUB_DEVICE
fi
elif test -b "$ONIE_DEVICE"; then
sgdisk -p "$ONIE_DEVICE" > "$buf" 2>&1 || :
if grep -q GUID "$buf"; then
# here we assume that the ONIE boot partition is on
# the boot disk
# (additionally we could also look for 'GRUB-BOOT')
dev=$ONIE_DEVICE
fi
fi
test -b "$dev" || return 0
do_recover=
# simple validation using sgdisk
if test "$do_recover"; then
:
else
if sgdisk -p "$dev" > "$buf" 2>&1; then
sts=0
else
sts=$?
fi
if test $sts -ne 0; then
cat "$buf" 1>&2
rm -f "$buf"
installer_say "Cannot reliably get GPT partition table"
return 1
fi
case $(cat "$buf") in
*Caution*|*Warning*)
cat $buf 1>&2
installer_say "Found issues with the GPT partition table"
do_recover=1
rm -f "$buf"
;;
esac
fi
# more thorough validation
if test "$do_recover"; then
:
else
local inp
inp=$(mktemp -u -t sgdisk-XXXXXX)
cat > "$inp" <<-END
x
r
v
q
END
if gdisk "$dev" < "$inp" > "$buf" 2>&1; then
sts=0
else
sts=$?
fi
rm -f "$inp"
if test $sts -ne 0; then
cat "$buf" 1>&2
rm -f "$buf"
installer_say "Cannot reliably verify GPT partition table"
return 1
fi
case $(cat "$buf") in
*Caution*|*Warning*|*Problem:*)
cat $buf 1>&2
installer_say "Found issues with the GPT partition table"
do_recover=1
rm -f "$buf"
;;
esac
fi
if test "$do_recover"; then
:
else
installer_say "Found a clean GPT partition table"
rm -f "$buf"
return 0
fi
installer_say "Attempting to correct the GPT partition table"
# this is the simple method; gdisk/sfgdisk will correct
# simple errors but not horrendous faults
dat=$(mktemp -u -t sgdisk-XXXXXX)
sgdisk -b "$dat" "$dev" || return 1
sgdisk -l "$dat" "$dev" || return 1
rm -f "$dat"
return 0
}
# Local variables
# mode: sh
# sh-basic-offset: 2

View File

@@ -19,10 +19,18 @@ default:
# this is mostly to *reject* invalid disk labels,
# since we will never create our own
kernel-3.2: &kernel-3-2
=: kernel-3.2-lts-x86_64-all
package: onl-kernel-3.2-lts-x86-64-all:amd64
kernel-3.16: &kernel-3-16
=: kernel-3.16-lts-x86_64-all
package: onl-kernel-3.16-lts-x86-64-all:amd64
kernel-4.9: &kernel-4-9
=: kernel-4.9-lts-x86_64-all
package: onl-kernel-4.9-lts-x86-64-all:amd64
# pick one of the above kernels
kernel:
<<: *kernel-3-16

View File

@@ -22,6 +22,10 @@ def _makedirs(d):
if not os.path.exists(d):
os.makedirs(d)
def onie_fwpkg_exists():
with OnlOnieBootContext() as ob:
return os.path.exists(os.path.join(ob.directory, "onie/tools/bin/onie-fwpkg"))
def onie_fwpkg(arguments):
with OnlOnieBootContext() as ob:
# This is necessary if we've upgraded ONIE but haven't booted into it yet...
@@ -35,9 +39,3 @@ def boot_entry_set(index):
def boot_onie():
return boot_entry_set(1)

View File

@@ -19,8 +19,12 @@ import fnmatch, glob
from InstallUtils import SubprocessMixin
from InstallUtils import MountContext, BlkidParser, PartedParser
from InstallUtils import ProcMountsParser
from InstallUtils import GdiskParser
from InstallUtils import OnieSubprocess
from Plugin import Plugin
import onl.install.ConfUtils
import onl.YamlUtils
from onl.sysconfig import sysconfig
@@ -509,15 +513,34 @@ menuentry %(boot_menu_entry)s {
initrd /%(platform)s.cpio.gz
}
# Menu entry to chainload ONIE
menuentry ONIE {
search --no-floppy --label --set=root ONIE-BOOT
# Always return to entry 0 by default.
set onie_boot_label="ONIE-BOOT"
set onie_boot_uuid="%(onie_boot_uuid)s"
# filesystem UUID, *not* GPT partition GUID, *not* GPT partition unique GUID
# (tee hee, GPT GRUB cannot grok partition attributes)
function onie_boot_uefi {
set root='(hd0,gpt1)'
search --no-floppy --fs-uuid --set=root "${onie_boot_uuid}"
echo 'Loading ONIE ...'
chainloader /EFI/onie/grubx64.efi
}
function onie_boot_dos {
search --no-floppy --label --set=root "${onie_boot_label}"
set saved_entry="0"
save_env saved_entry
echo 'Loading ONIE ...'
chainloader +1
}
# Menu entry to chainload ONIE
menuentry ONIE {
if [ -n "${onie_boot_uuid}" ]; then
onie_boot_uefi
else
onie_boot_dos
fi
}
"""
class GrubInstaller(SubprocessMixin, Base):
@@ -529,6 +552,14 @@ class GrubInstaller(SubprocessMixin, Base):
def __init__(self, *args, **kwargs):
Base.__init__(self, *args, **kwargs)
self.espDevice = None
self.espFsUuid = None
# optionally fill in ESP partition information
@property
def isUEFI(self):
return os.path.isdir('/sys/firmware/efi/efivars')
def findGpt(self):
self.blkidParts = BlkidParser(log=self.log.getChild("blkid"))
@@ -566,8 +597,9 @@ class GrubInstaller(SubprocessMixin, Base):
self.log.error("cannot find an install device")
return 1
code = self.assertUnmounted()
if code: return code
if not self.isUEFI:
code = self.assertUnmounted()
if code: return code
# optionally back up a config partition
# if it's on the boot device
@@ -610,6 +642,42 @@ class GrubInstaller(SubprocessMixin, Base):
return 0
def findEsp(self):
"""Find the block device holding the EFI System Partition.
XXX assume boot (ESP) partition is on the same device as GRUB
"""
self.log.info("extracting partition UUIDs for %s", self.device)
if isinstance(self.im.grubEnv, onl.install.ConfUtils.GrubEnv):
# direct (or chroot) access
gp = GdiskParser(self.device,
subprocessContext=self.im.grubEnv,
log=self.log)
else:
# indirect access using onie-shell
ctx = OnieSubprocess(log=self.log.getChild("onie"))
gp = GdiskParser(self.device,
subprocessContext=ctx,
log=self.log)
espParts = [x for x in gp.parts if x.isEsp]
if not espParts:
self.log.error("cannot find ESP partition on %s", self.device)
return 1
self.espDevice = espParts[0].device
self.log.info("found ESP partition %s", self.espDevice)
espParts = [x for x in self.blkidParts if x.device==self.espDevice]
if not espParts:
self.log.error("cannot find blkid entry for ESP partition on %s", self.espDevice)
return 1
self.espFsUuid = espParts[0].uuid
self.log.info("found ESP filesystem UUID %s", self.espFsUuid)
return 0
def installLoader(self):
kernels = []
@@ -656,6 +724,11 @@ class GrubInstaller(SubprocessMixin, Base):
ctx['boot_menu_entry'] = sysconfig.installer.menu_name
ctx['boot_loading_name'] = sysconfig.installer.os_name
if self.isUEFI:
ctx['onie_boot_uuid'] = self.espFsUuid
else:
ctx['onie_boot_uuid'] = ""
cf = GRUB_TPL % ctx
with MountContext(dev.device, log=self.log) as ctx:
@@ -689,6 +762,13 @@ class GrubInstaller(SubprocessMixin, Base):
code = self.findGpt()
if code: return code
if self.isUEFI:
code = self.findEsp()
if code: return code
self.im.grubEnv.__dict__['espPart'] = self.espDevice
else:
self.im.grubEnv.__dict__['espPart'] = None
self.log.info("Installing to %s starting at partition %d",
self.device, self.minpart)
@@ -757,6 +837,7 @@ class GrubInstaller(SubprocessMixin, Base):
if label != 'gpt':
self.log.error("invalid GRUB label in platform config: %s", label)
return 1
return self.installGpt()
def upgradeBootLoader(self):

View File

@@ -7,7 +7,11 @@ import os
import logging
import subprocess
from InstallUtils import SubprocessMixin, ChrootSubprocessMixin, MountContext
from InstallUtils import OnieSubprocess
from cStringIO import StringIO
import re
from onl.sysconfig import sysconfig
class ConfBase:
@@ -90,13 +94,16 @@ class GrubEnv(SubprocessMixin):
INSTALL = "grub-install"
EDITENV = "grub-editenv"
EFIBOOTMGR = "efibootmgr"
# system default
ENV_PATH = "/grub/grubenv"
# override me
EFI_BOOT_RE = re.compile("Boot([0-9a-fA-F]*)[*] (.*)")
def __init__(self,
bootDir=None, bootPart=None,
bootDir=None, bootPart=None, espPart=None,
path=None,
log=None):
@@ -108,13 +115,16 @@ class GrubEnv(SubprocessMixin):
self.__dict__['bootPart'] = bootPart
# location of GRUB boot files (mounted directory or unmounted partition)
self.__dict__['espPart'] = espPart
# location of EFI System Partition
self.__dict__['path'] = path or self.ENV_PATH
# path to grubenv, relative to above
self.__dict__['log'] = log or logging.getLogger("grub")
def mountCtx(self, device):
return MountContext(device, fsType='ext4', log=self.log)
def mountCtx(self, device, fsType='ext4'):
return MountContext(device, fsType=fsType, log=self.log)
def asDict(self):
if self.bootPart:
@@ -164,36 +174,83 @@ class GrubEnv(SubprocessMixin):
cmd = (self.EDITENV, p, 'unset', attr,)
self.check_call(cmd)
@property
def isUEFI(self):
return os.path.isdir('/sys/firmware/efi/efivars')
def install(self, device):
if self.bootDir is not None:
self.check_call((self.INSTALL, '--boot-directory=' + self.bootDir, device,))
elif self.bootPart is not None:
with self.mountCtx(self.bootPart) as ctx:
self.check_call((self.INSTALL, '--boot-directory=' + ctx.dir, device,))
uidx = None
if self.isUEFI:
buf = self.check_output((self.EFIBOOTMGR,))
for line in buf.splitlines(False):
m = self.EFI_BOOT_RE.match(line)
if m:
if m.group(2) == sysconfig.installer.os_name:
uidx = m.group(1)
break
if uidx is not None:
self.check_output((self.EFIBOOTMGR, '-b', uidx, '-B',))
grubOpts = []
if self.isUEFI:
grubOpts.append('--target=x86_64-efi')
grubOpts.append('--no-nvram')
grubOpts.append('--recheck')
grubOpts.append('--bootloader-id=ONL')
# All ONL-derived distros should be able to use
# the same profile
def _install():
if self.bootDir is not None:
self.check_call([self.INSTALL, '--boot-directory=' + self.bootDir,]
+ grubOpts
+ [device,])
elif self.bootPart is not None:
with self.mountCtx(self.bootPart) as ctx:
self.check_call([self.INSTALL, '--boot-directory=' + ctx.dir,]
+ grubOpts
+ [device,])
else:
self.check_call([self.INSTALL,] + grubOpts + [device,])
if self.espPart is not None:
with self.mountCtx(self.espPart, fsType=None) as ctx:
grubOpts.append('--efi-directory=' + ctx.dir)
_install()
else:
self.check_call((self.INSTALL, device,))
_install()
if self.isUEFI:
self.check_call((self.EFIBOOTMGR,
'--create',
'--label', sysconfig.installer.os_name,
'--disk', device,
'--part', '1',
'--loader', '/EFI/ONL/grubx64.efi',))
class ChrootGrubEnv(ChrootSubprocessMixin, GrubEnv):
def __init__(self,
chrootDir,
mounted=False,
bootDir=None, bootPart=None,
bootDir=None, bootPart=None, espPart=None,
path=None,
log=None):
self.__dict__['chrootDir'] = chrootDir
self.__dict__['mounted'] = mounted
GrubEnv.__init__(self,
bootDir=bootDir, bootPart=bootPart,
bootDir=bootDir, bootPart=bootPart, espPart=espPart,
path=path,
log=log)
def mountCtx(self, device):
def mountCtx(self, device, fsType='ext4'):
return MountContext(device,
chroot=self.chrootDir, fsType='ext4',
chroot=self.chrootDir, fsType=fsType,
log=self.log)
class ProxyGrubEnv:
class ProxyGrubEnv(SubprocessMixin):
"""Pretend to manipulate the GRUB environment.
Instead, write a trace of shell commands to a log
@@ -203,6 +260,7 @@ class ProxyGrubEnv:
INSTALL = "grub-install"
EDITENV = "grub-editenv"
EFIBOOTMGR = "efibootmgr"
# system defaults
ENV_PATH = "/grub/grubenv"
@@ -210,7 +268,7 @@ class ProxyGrubEnv:
def __init__(self,
installerConf,
bootDir=None, chroot=True, bootPart=None,
bootDir=None, chroot=True, bootPart=None, espPart=None,
path=None,
log=None):
@@ -225,6 +283,9 @@ class ProxyGrubEnv:
self.__dict__['bootPart'] = bootPart
# location of GRUB boot files (mounted directory or unmounted partition)
self.__dict__['espPart'] = espPart
# location of EFI System Partition
self.__dict__['chroot'] = chroot
# True of the bootDir is inside the chroot,
# else bootDir is in the host's file namespace
@@ -260,7 +321,8 @@ class ProxyGrubEnv:
% (self.path.lstrip('/'),))
cmds.append("mpt=$(mktemp -t -d)")
cmds.append("mount %s $mpt" % self.bootPart)
cmds.append(("sts=0; %s %s set %s=\"%s\" || sts=$?"
cmds.append("sts=0")
cmds.append(("%s %s set %s=\"%s\" || sts=$?"
% (self.EDITENV, p, attr, val,)))
cmds.append("umount $mpt")
cmds.append("rmdir $mpt")
@@ -290,7 +352,8 @@ class ProxyGrubEnv:
% (self.path.lstrip('/'),))
cmds.append("mpt=$(mktemp -t -d)")
cmds.append("mount %s $mpt" % self.bootPart)
cmds.append(("sts=0; %s %s unset %s || sts=$?"
cmds.append("sts=0")
cmds.append(("%s %s unset %s || sts=$?"
% (self.EDITENV, p, attr,)))
cmds.append("umount $mpt")
cmds.append("rmdir $mpt")
@@ -302,27 +365,83 @@ class ProxyGrubEnv:
fd.write(cmd)
fd.write("\n")
@property
def isUEFI(self):
return os.path.isdir('/sys/firmware/efi/efivars')
def install(self, device):
self.log.warn("deferring commands to %s...", self.installerConf.installer_postinst)
cmds.append("os_name=\"%s\"" % sysconfig.installer.os_name)
if self.isUEFI:
sub = OnieSubprocess(log=self.log.getChild("onie"))
cmd = (self.EFIBOOTMGR,)
buf = sub.check_output(cmd)
bidx = None
for line in buf.splitlines(False):
m = self.EFI_BOOT_RE.match(line)
if m:
if m.group(2) == sysconfig.installer.os_name:
uidx = m.group(1)
break
if uidx is not None:
cmds.append("%s -b %s -B || sts=$?" % (self.EFIBOOTMGR, bidx,))
grubOpts = []
if self.isUEFI:
grubOpts.append('--target=x86_64-efi')
grubOpts.append('--no-nvram')
grubOpts.append('--bootloader-id=ONL')
grubOpts.append('--efi-directory=/boot/efi')
grubOpts.append('--recheck')
cmds = []
if self.bootPart and not self.bootDir:
cmds.append("bootMpt=$(mktemp -t -d)")
cmds.append("mount %s $bootMpt" % self.bootPart)
if self.espPart is not None:
cmds.append("espMpt=$(mktemp -t -d)")
cmds.append("mount %s $espMpt" % self.espPart)
cmds.append("sts=0")
if self.bootDir and self.chroot:
p = os.pat.join(self.installerConf.installer_chroot,
self.bootDir.lstrip('/'))
cmds.append(("%s --boot-directory=\"%s\" %s" % (self.INSTALL, p, device,)))
cmd = ([self.INSTALL, '--boot-directory=' + p,]
+ grubOpts
+ [device,])
cmds.append(" ".join(cmd) + " || sts=$?")
elif self.bootDir:
p = self.bootDir
cmds.append(("%s --boot-directory=\"%s\" %s" % (self.INSTALL, p, device,)))
cmd = ([self.INSTALL, '--boot-directory=' + p,]
+ grubOpts
+ [device,])
cmds.append(" ".join(cmd) + " || sts=$?")
elif self.bootPart:
cmds.append("mpt=$(mktemp -t -d)")
cmds.append("mount %s $mpt" % self.bootPart)
cmds.append(("sts=0; %s --boot-directory=\"$mpt\" %s || sts=$?"
% (self.INSTALL, device,)))
cmds.append("umount $mpt")
cmds.append("rmdir $mpt")
cmds.append("test $sts -eq 0")
cmd = ([self.INSTALL, '--boot-directory=\"$bootMpt\"',]
+ grubOpts
+ [device,])
cmds.append(" ".join(cmd) + " || sts=$?")
else:
cmds.append(("%s %s"
% (self.INSTALL, device,)))
cmd = ([self.INSTALL,]
+ grubOpts
+ [device,])
cmds.append(" ".join(cmd) + " || sts=$?")
if self.bootPart and not self.bootDir:
cmds.append("umount $bootMpt")
cmds.append("rmdir $bootMpt")
if self.espPart is not None:
cmds.append("umount $espMpt")
cmds.append("rmdir $espMpt")
cmds.append("test $sts -eq 0")
with open(self.installerConf.installer_postinst, "a") as fd:
for cmd in cmds:

View File

@@ -9,6 +9,7 @@ import subprocess
import tempfile
import string
import shutil
import re
import Fit, Legacy
@@ -620,6 +621,186 @@ class PartedParser(SubprocessMixin):
def __len__(self):
return len(self.parts)
class GdiskDiskEntry:
DEVICE_RE = re.compile("Disk ([^:]*): .*")
BLOCKS_RE = re.compile("Disk [^:]*: ([0-9][0-9]*) sectors")
LBSZ_RE = re.compile("Logical sector size: ([0-9][0-9]*) bytes")
GUID_RE = re.compile("Disk identifier [(]GUID[)]: ([0-9a-fA-F-][0-9a-fA-F-]*)")
def __init__(self, device, blocks, lbsz, guid):
self.device = device
self.blocks = blocks
self.lbsz = lbsz
self.guid = guid
@classmethod
def fromOutput(cls, buf):
m = cls.BLOCKS_RE.search(buf)
if m:
blocks = int(m.group(1))
else:
raise ValueError("cannot get block count")
m = cls.DEVICE_RE.search(buf)
if m:
device = m.group(1)
else:
raise ValueError("cannot get block count")
m = cls.LBSZ_RE.search(buf)
if m:
lbsz = int(m.group(1))
else:
raise ValueError("cannot get block size")
m = cls.GUID_RE.search(buf)
if m:
guid = m.group(1)
else:
raise ValueError("cannot get block size")
return cls(device, blocks, lbsz, guid)
class GdiskPartEntry:
PGUID_RE = re.compile("Partition GUID code: ([0-9a-fA-F-][0-9a-fA-F-]*) [(]([^)]*)[)]")
PGUID2_RE = re.compile("Partition GUID code: ([0-9a-fA-F-][0-9a-fA-F-]*)")
GUID_RE = re.compile("Partition unique GUID: ([0-9a-fA-F-][0-9a-fA-F-]*)")
START_RE = re.compile("First sector: ([0-9][0-9]*)")
END_RE = re.compile("Last sector: ([0-9][0-9]*)")
SIZE_RE = re.compile("Partition size: ([0-9][0-9]*) sectors")
NAME_RE = re.compile("Partition name: [']([^']+)[']")
ESP_PGUID = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
GRUB_PGUID = "21686148-6449-6e6f-744e-656564454649"
ONIE_PGUID = "7412f7d5-a156-4b13-81dc-867174929325"
def __init__(self, device, pguid, guid, start, end, sz, pguidName=None, name=None):
self.device = device
self.pguid = pguid
self.pguidName = pguidName
self.guid = guid
self.name = name
self.start = start
self.end = end
self.sz = sz
@property
def isEsp(self):
return self.pguid == self.ESP_PGUID
@property
def isGrub(self):
return self.pguid == self.GRUB_PGUID
@property
def isOnie(self):
return self.pguid == self.ONIE_PGUID
@classmethod
def fromOutput(cls, partDevice, buf):
m = cls.PGUID_RE.search(buf)
if m:
pguid = m.group(1).lower()
pguidName = m.group(2)
else:
m = cls.PGUID2_RE.search(buf)
if m:
pguid = m.group(1).lower()
pguidName = None
else:
raise ValueError("cannot get partition GUID")
m = cls.GUID_RE.search(buf)
if m:
guid = m.group(1).lower()
else:
raise ValueError("cannot get partition unique GUID")
m = cls.START_RE.search(buf)
if m:
start = int(m.group(1))
else:
raise ValueError("cannot get partition start")
m = cls.END_RE.search(buf)
if m:
end = int(m.group(1))
else:
raise ValueError("cannot get partition end")
m = cls.SIZE_RE.search(buf)
if m:
sz = int(m.group(1))
else:
raise ValueError("cannot get partition size")
m = cls.NAME_RE.search(buf)
if m:
name = m.group(1)
else:
name = None
return cls(partDevice,
pguid, guid, start, end, sz,
pguidName=pguidName,
name=name)
class GdiskParser(SubprocessMixin):
def __init__(self, device, subprocessContext=subprocess, log=None):
self.device = device
self.log = log or logging.getLogger("parted")
self.subprocessContext = subprocessContext
self.parse()
def parse(self):
cmd = ('sgdisk', '-p', self.device,)
buf = self.subprocessContext.check_output(cmd)
self.disk = GdiskDiskEntry.fromOutput(buf)
parts = {}
pidx = 1
for line in buf.splitlines():
line = line.strip()
if not line: continue
if not line[0] in string.digits: continue
partno = int(line.split()[0])
partDevice = "%s%d" % (self.device, pidx,)
pidx += 1
# linux partitions may be numbered differently,
# if there are holes in the GPT partition table
cmd = ('sgdisk', '-i', str(partno), self.device,)
try:
buf = self.subprocessContext.check_output(cmd)
except subprocess.CalledProcessError as ex:
sys.stdout.write(ex.output)
self.log.warn("sgdisk failed with code %s", ex.returncode)
continue
# skip this partition, but otherwise do not give up
ent = GdiskPartEntry.fromOutput(partDevice, buf)
parts[partno] = ent
self.parts = []
for partno in sorted(parts.keys()):
self.parts.append(parts[partno])
if self.disk is None:
raise ValueError("no partition table found")
def __len__(self):
return len(self.parts)
class ProcMountsEntry:
def __init__(self, device, dir, fsType, flags={}):
@@ -821,6 +1002,11 @@ class InitrdContext(SubprocessMixin):
cmd = ('mount', '-t', 'sysfs', 'sysfs', dst,)
self.check_call(cmd, vmode=self.V1)
dst = os.path.join(self.dir, "sys/firmware/efi/efivars")
if os.path.exists(dst):
cmd = ('mount', '-t', 'efivarfs', 'efivarfs', dst,)
self.check_call(cmd, vmode=self.V1)
# maybe mount devtmpfs
if self._hasDevTmpfs:
dst = os.path.join(self.dir, "dev")
@@ -1022,9 +1208,55 @@ class ChrootSubprocessMixin:
cmd = ['chroot', self.chrootDir,] + list(cmd)
if not self.mounted:
with InitrdContext(self.chrootDir, log=self.log) as ctx:
with InitrdContext(dir=self.chrootDir, log=self.log) as ctx:
self.log.debug("+ " + " ".join(cmd))
return subprocess.check_output(cmd, *args, cwd=cwd, **kwargs)
else:
self.log.debug("+ " + " ".join(cmd))
return subprocess.check_output(cmd, *args, cwd=cwd, **kwargs)
class OnieSubprocess:
"""Simple subprocess mixin that defers to onie-shell."""
def __init__(self, log=None):
self.log = log or logging.getLogger("onie")
def check_call(self, *args, **kwargs):
args = list(args)
kwargs = dict(kwargs)
cwd = kwargs.pop('cwd', None)
if cwd is not None:
raise ValueError("cwd not supported")
if args:
cmd = args.pop(0)
else:
cmd = kwargs.pop('cmd')
if isinstance(cmd, basestring):
cmd = ('onie-shell', '-c', 'IFS=;' + cmd,)
else:
cmd = ['onie-shell', '-c',] + " ".join(cmd)
self.log.debug("+ " + " ".join(cmd))
subprocess.check_call(cmd, *args, cwd=cwd, **kwargs)
def check_output(self, *args, **kwargs):
args = list(args)
kwargs = dict(kwargs)
cwd = kwargs.pop('cwd', None)
if cwd is not None:
raise ValueError("cwd not supported")
if args:
cmd = args.pop(0)
else:
cmd = kwargs.pop('cmd')
if isinstance(cmd, basestring):
cmd = ('onie-shell', '-c', 'IFS=;' + cmd,)
else:
cmd = ['onie-shell', '-c',] + " ".join(list(cmd))
self.log.debug("+ " + " ".join(cmd))
return subprocess.check_output(cmd, *args, cwd=cwd, **kwargs)

View File

@@ -88,7 +88,7 @@ class AppBase(SubprocessMixin, object):
sys.exit(code)
class OnieBootContext:
"""Find the ONIE initrd and umpack/mount it."""
"""Find the ONIE initrd and unpack/mount it."""
def __init__(self, log=None):
self.log = log or logging.getLogger(self.__class__.__name__)
@@ -128,6 +128,7 @@ class OnieBootContext:
initrd = _g(parts[0].dir)
if initrd is None:
raise ValueError("cannot find ONIE initrd on %s" % parts[0].dir)
self.onieDir = parts[0].dir
self.log.debug("found ONIE initrd at %s", initrd)
with InitrdContext(initrd=initrd, log=self.log) as self.ictx:
self.initrd = initrd

View File

@@ -195,7 +195,7 @@ class App(SubprocessMixin):
pdir,))
for m in pm.mounts:
if m.dir.startswith('/mnt/onl'):
if m.dir.startswith('/mnt/onl') or m.dir.startswith('/boot'):
if not self.force:
self.log.error("directory %s is still mounted (try --force)", m.dir)
return 1

View File

@@ -138,35 +138,53 @@ class OnlMountManager(object):
def init(self, timeout=5):
for(k, v) in self.mdata['mounts'].iteritems():
#
# Get the partition device for the given label.
# The timeout logic is here to handle waiting for the
# block devices to arrive at boot.
#
t = timeout
while t >= 0:
try:
v['device'] = subprocess.check_output("blkid -L %s" % k, shell=True).strip()
break
except subprocess.CalledProcessError:
self.logger.debug("Block label %s does not yet exist..." % k)
time.sleep(1)
t -= 1
now = time.time()
future = now + timeout
if 'device' not in v:
self.logger.error("Timeout waiting for block label %s after %d seconds." % (k, timeout))
self.missing = k
md = self.mdata['mounts']
optional = set(x for x in md if md[x].get('optional', False))
pending = set(x for x in md if not md[x].get('optional', False))
def _discover(k):
v = md[k]
lbl = v.get('label', k)
try:
v['device'] = subprocess.check_output(('blkid', '-L', lbl,)).strip()
except subprocess.CalledProcessError:
return False
#
# Make the mount point for future use.
#
if not os.path.isdir(v['dir']):
self.logger.debug("Make directory '%s'..." % v['dir'])
self.logger.debug("Make directory '%s'...", v['dir'])
os.makedirs(v['dir'])
self.logger.debug("%s @ %s" % (k, v['device']))
self.logger.debug("%s @ %s", k, v['dir'])
return True
while True:
now = time.time()
if now > future:
break
pending_ = pending
pending = [k for k in pending_ if not _discover(k)]
optional_ = optional
optional = [k for k in optional_ if not _discover(k)]
if not pending: break
if pending != pending_: continue
if optional != optional_: continue
self.logger.debug("Still waiting for block devices: %s",
" ".join(pending+optional))
time.sleep(0.25)
if pending:
for k in pending+optional:
self.logger.error("Timeout waiting for block label %s after %d seconds.", k, timeout)
# ignore the any optional labels that were not found
def __fsck(self, label, device):
self.logger.info("Running fsck on %s [ %s ]..." % (label, device))
@@ -202,20 +220,37 @@ class OnlMountManager(object):
raise ValueError("invalid labels argument.")
if 'all' in labels:
labels = filter(lambda l: l != 'all', labels) + self.mdata['mounts'].keys()
labels = list(labels)
labels.remove('all')
labels = labels + self.mdata['mounts'].keys()
def _f(label):
"""skip labels that do not resolve to a block device (ideally, optional ones)"""
mpt = self.mdata['mounts'][label]
dev = mpt.get('device', None)
opt = mpt.get('optional', False)
if dev: return True
if not opt: return True
return False
rv = []
for l in list(set(labels)):
if self.__label_entry("ONL-%s" % l.upper(), False):
rv.append("ONL-%s" % l.upper())
elif self.__label_entry(l.upper(), False):
rv.append(l.upper())
elif self.__label_entry(l):
rv.append(l)
else:
pass
return rv;
lbl = "ONL-%s" % l.upper()
if self.__label_entry(lbl, False) and _f(lbl):
rv.append("ONL-%s" % l.upper())
continue
lbl = l.upper()
if self.__label_entry(lbl, False) and _f(lbl):
rv.append(l.upper())
continue
lbl = l
if self.__label_entry(lbl) and _f(lbl):
rv.append(l)
return rv
def fsck(self, labels, force=False):
labels = self.validate_labels(labels)

View File

@@ -164,6 +164,7 @@ class OnlPlatformBase(object):
except ValueError, e:
if required:
raise e
self.add_info_dict(name, {}, klass)
elif required:
raise RuntimeError("A required system file (%s) is missing." % f)
@@ -354,36 +355,34 @@ class OnlPlatformBase(object):
return self.platform_info.CPLD_VERSIONS
def dmi_versions(self):
# Note - the dmidecode module returns empty lists for powerpc systems.
if platform.machine() != "x86_64":
return {}
try:
import dmidecode
except ImportError:
return {}
fields = [
{
'name': 'DMI BIOS Version',
'subsystem': dmidecode.bios,
'dmi_type' : 0,
'key' : 'Version',
},
{
'name': 'DMI System Version',
'subsystem': dmidecode.system,
'dmi_type' : 1,
'key' : 'Version',
},
]
rv = {}
for field in fields:
for v in field['subsystem']().values():
if type(v) is dict and v['dmi_type'] == field['dmi_type']:
rv[field['name']] = v['data'][field['key']]
arches = [ 'x86_64' ]
if platform.machine() in arches:
try:
import dmidecode
fields = [
{
'name': 'DMI BIOS Version',
'subsystem': dmidecode.bios,
'dmi_type' : 0,
'key' : 'Version',
},
{
'name': 'DMI System Version',
'subsystem': dmidecode.system,
'dmi_type' : 1,
'key' : 'Version',
},
]
# Todo -- disable dmidecode library warnings to stderr
# or figure out how to clear the warning log in the decode module.
for field in fields:
for v in field['subsystem']().values():
if type(v) is dict and v['dmi_type'] == field['dmi_type']:
rv[field['name']] = v['data'][field['key']]
except:
pass
return rv
def upgrade_manifest(self, type_, override_dir=None):
@@ -487,6 +486,10 @@ class OnlPlatformPortConfig_48x25_6x100(object):
PORT_COUNT=54
PORT_CONFIG="48x25 + 6x100"
class OnlPlatformPortConfig_48x25_8x100(object):
PORT_COUNT=56
PORT_CONFIG="48x25 + 8x100"
class OnlPlatformPortConfig_32x40(object):
PORT_COUNT=32
PORT_CONFIG="32x40"
@@ -499,6 +502,10 @@ class OnlPlatformPortConfig_32x100(object):
PORT_COUNT=32
PORT_CONFIG="32x100"
class OnlPlatformPortConfig_64x100(object):
PORT_COUNT=64
PORT_CONFIG="64x100"
class OnlPlatformPortConfig_24x1_4x10(object):
PORT_COUNT=28
PORT_CONFIG="24x1 + 4x10"

View File

@@ -29,6 +29,11 @@ class FirmwareUpgrade(ubase.BaseOnieUpgrade):
def do_upgrade(self, forced=False):
if self.manifest.get('fwpkg', False):
if not self.onie_fwpkg_exists():
# An ONIE upgrade is probably required.
print "The firmware cannot be upgraded because the current ONIE version is not correct. Please perform an ONIE upgrade first."
self.abort()
self.onie_fwpkg_add(os.path.join(sysconfig.upgrade.firmware.package.dir,
self.manifest['updater']))
else:
@@ -56,4 +61,3 @@ class FirmwareUpgrade(ubase.BaseOnieUpgrade):
def do_no_upgrade(self):
self.clean_onie_updater()

View File

@@ -391,6 +391,10 @@ class BaseOnieUpgrade(BaseUpgrade):
dst = os.path.join(self.ONIE_UPDATER_PATH, f)
self.copyfile(src, dst)
def onie_fwpkg_exists(self):
import onl.grub
return onl.grub.onie_fwpkg_exists()
def onie_fwpkg_add(self, pkg):
import onl.grub
onl.grub.onie_fwpkg("-f purge")

View File

@@ -13,8 +13,8 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(ONL)/make/config.mk
kernel:
$(MAKE) -C $(ONL)/packages/base/any/kernels/3.16-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL)
rm -rf lib
$(MAKE) -C $(ONL)/packages/base/any/kernels/3.16-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL)
ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-3.16.39-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common
clean:

View File

@@ -0,0 +1,29 @@
variables:
basename: onl-kernel-3.2-lts-x86-64-all
common:
arch: amd64
version: 1.0.0
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
maintainer: support@bigswitch.com
support: opennetworklinux@googlegroups.com
packages:
- name: $basename
version: 1.0.0
summary: Open Network Linux 3.2 LTS Kernel for X86_64 Platforms.
files:
builds/kernel-3.2* : $$PKG_INSTALL/
builds/linux-*mbuild : $$PKG_INSTALL/mbuilds
changelog: Change changes changes.,
- name: $basename-modules
version: 1.0.0
summary: Open Network Linux 3.2 LTS Kernel Modules for X86_64 Platforms
files:
builds/lib: /lib
changelog: Change changes changes.,

View File

@@ -0,0 +1,3 @@
linux-*
kernel-*
lib

View File

@@ -0,0 +1,21 @@
# -*- Makefile -*-
############################################################
# <bsn.cl fy=2013 v=none>
#
# Copyright 2013, 2014 BigSwitch Networks, Inc.
#
#
#
# </bsn.cl>
############################################################
THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(ONL)/make/config.mk
kernel:
$(MAKE) -C $(ONL)/packages/base/any/kernels/3.2-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL)
rm -rf lib
ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-3.2.84-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common
clean:
rm -rf linux-3.2* kernel-3.2*

View File

@@ -0,0 +1,29 @@
variables:
basename: onl-kernel-4.9-lts-x86-64-all
common:
arch: amd64
version: 1.0.0
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
maintainer: support@bigswitch.com
support: opennetworklinux@googlegroups.com
packages:
- name: $basename
version: 1.0.0
summary: Open Network Linux 4.9 LTS Kernel for X86_64 Platforms.
files:
builds/kernel-4.9* : $$PKG_INSTALL/
builds/linux-*mbuild : $$PKG_INSTALL/mbuilds
changelog: Change changes changes.,
- name: $basename-modules
version: 1.0.0
summary: Open Network Linux 4.9 LTS Kernel Modules for X86_64 Platforms
files:
builds/lib: /lib
changelog: Change changes changes.,

View File

@@ -0,0 +1,3 @@
linux-*
kernel-*
lib

View File

@@ -0,0 +1,21 @@
# -*- Makefile -*-
############################################################
# <bsn.cl fy=2013 v=none>
#
# Copyright 2013, 2014 BigSwitch Networks, Inc.
#
#
#
# </bsn.cl>
############################################################
THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(ONL)/make/config.mk
kernel:
rm -rf lib
$(MAKE) -C $(ONL)/packages/base/any/kernels/4.9-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL)
ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.9.30-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common
clean:
rm -rf linux-4.9* kernel-4.9*

View File

@@ -1,6 +1,7 @@
prerequisites:
packages:
- onl-kernel-3.16-lts-x86-64-all:amd64
- onl-kernel-4.9-lts-x86-64-all:amd64
- onl-loader-initrd:amd64
common:

View File

@@ -1,7 +1,8 @@
include $(ONL)/make/config.amd64.mk
# All amd64 kernels
KERNELS := $(shell $(ONLPM) --find-file onl-kernel-3.16-lts-x86-64-all:amd64 kernel-3.16-lts-x86_64-all)
KERNELS := $(shell $(ONLPM) --find-file onl-kernel-3.16-lts-x86-64-all:amd64 kernel-3.16-lts-x86_64-all) \
$(shell $(ONLPM) --find-file onl-kernel-4.9-lts-x86-64-all:amd64 kernel-4.9-lts-x86_64-all)
# Loader initrd

View File

@@ -1,21 +1,21 @@
/**************************************************************************//**
* <bsn.cl fy=2013 v=onl>
*
* Copyright 2013, 2014 BigSwitch Networks, Inc.
*
*
* Copyright 2013, 2014 BigSwitch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
*
* </bsn.cl>
*****************************************************************************/
#include <faultd/faultd_config.h>
@@ -46,157 +46,151 @@
static pthread_spinlock_t thread_lock__;
static faultd_client_t* faultd_client__ = NULL;
static faultd_client_t* faultd_client__ = NULL;
static faultd_info_t faultd_info__;
static int localfd__ = -1;
static int localfd__ = -1;
inline int signal_backtrace__(void** buffer, int size, ucontext_t* context,
int signal_backtrace__(void** buffer, int size, ucontext_t* context,
int distance)
{
#define IP_STACK_FRAME_NUMBER 3
int rv;
int rv;
rv = backtrace(buffer, size);
if(context) {
distance += IP_STACK_FRAME_NUMBER;
if(context) {
distance += IP_STACK_FRAME_NUMBER;
#ifdef __i386__
buffer[distance] = (void*)(context->uc_mcontext.gregs[REG_EIP]);
buffer[distance] = (void*)(context->uc_mcontext.gregs[REG_EIP]);
#endif
#ifdef __PPC__
buffer[distance] = (void*)(context->uc_mcontext.regs->nip);
buffer[distance] = (void*)(context->uc_mcontext.regs->nip);
#endif
/* Note -- 64bit does not require require modifications */
}
return rv;
}
#include <AIM/aim_pvs.h>
static void
}
return rv;
}
#include <AIM/aim_pvs.h>
static void
faultd_signal_handler__(int signal, siginfo_t* siginfo, void* context)
{
int rv;
int rv;
/*
* Make sure we syncronize properly with other threads that
* may *also* be faulting
*/
rv = pthread_spin_trylock(&thread_lock__);
rv = pthread_spin_trylock(&thread_lock__);
if (rv == EBUSY) {
sigset_t mask;
sigemptyset(&mask);
pselect(0, NULL, NULL, NULL, NULL, &mask);
if (rv == EBUSY) {
sigset_t mask;
sigemptyset(&mask);
pselect(0, NULL, NULL, NULL, NULL, &mask);
}
/*
* Generate our fault information.
*/
faultd_info__.pid = getpid();
faultd_info__.tid = 0;
faultd_info__.signal = signal;
faultd_info__.signal_code = siginfo->si_code;
faultd_info__.fault_address = siginfo->si_addr;
faultd_info__.last_errno = errno;
* Generate our fault information.
*/
faultd_info__.pid = getpid();
faultd_info__.tid = 0;
faultd_info__.signal = signal;
faultd_info__.signal_code = siginfo->si_code;
faultd_info__.fault_address = siginfo->si_addr;
faultd_info__.last_errno = errno;
faultd_info__.backtrace_size = signal_backtrace__(faultd_info__.backtrace,
faultd_info__.backtrace_size = signal_backtrace__(faultd_info__.backtrace,
AIM_ARRAYSIZE(faultd_info__.backtrace),
context, 0);
faultd_info__.backtrace_symbols = (void*)1;
if(faultd_client__) {
faultd_client_write(faultd_client__, &faultd_info__);
context, 0);
faultd_info__.backtrace_symbols = (void*)1;
if(faultd_client__) {
faultd_client_write(faultd_client__, &faultd_info__);
}
if(localfd__ >= 0) {
char* signame = strsignal(faultd_info__.signal);
char* nl = "\n";
write(localfd__, signame, strlen(signame)+1);
write(localfd__, nl, 2);
backtrace_symbols_fd(faultd_info__.backtrace,
faultd_info__.backtrace_size,
localfd__);
if(localfd__ >= 0) {
char* signame = strsignal(faultd_info__.signal);
char* nl = "\n";
write(localfd__, signame, strlen(signame)+1);
write(localfd__, nl, 2);
backtrace_symbols_fd(faultd_info__.backtrace,
faultd_info__.backtrace_size,
localfd__);
}
/*
/*
* Unlock spinlock, in case this signal wasn't fatal
*/
pthread_spin_unlock(&thread_lock__);
pthread_spin_unlock(&thread_lock__);
}
int
faultd_handler_register(int localfd,
const char* pipename,
faultd_handler_register(int localfd,
const char* pipename,
const char* binaryname)
{
int rv;
struct sigaction saction;
void* dummy_backtrace[1];
int dummy_backtrace_size;
int fd;
int rv;
struct sigaction saction;
void* dummy_backtrace[1];
int dummy_backtrace_size;
int fd;
if ( (rv = pthread_spin_init(&thread_lock__, 0)) ) {
return rv;
if ( (rv = pthread_spin_init(&thread_lock__, 0)) ) {
return rv;
}
/*
* These calls to backtrace are to assure that
* backtrace() and backtrace_symbols_fd() have actually
* been loaded into our process -- its possible they
/*
* These calls to backtrace are to assure that
* backtrace() and backtrace_symbols_fd() have actually
* been loaded into our process -- its possible they
* come from a dynamic library, and we don't want them
* to get loaded at fault-time.
*/
dummy_backtrace_size = backtrace(dummy_backtrace, 1);
/** Note - we could just pass an invalid descriptor here, but it
* it flags errors in valgrind.
dummy_backtrace_size = backtrace(dummy_backtrace, 1);
/** Note - we could just pass an invalid descriptor here, but it
* it flags errors in valgrind.
*/
fd = open("/dev/null", O_WRONLY);
backtrace_symbols_fd(dummy_backtrace, dummy_backtrace_size, fd);
close(fd);
fd = open("/dev/null", O_WRONLY);
backtrace_symbols_fd(dummy_backtrace, dummy_backtrace_size, fd);
close(fd);
AIM_MEMSET(&faultd_info__, 0, sizeof(faultd_info__));
if(!binaryname) {
binaryname = "Not specified.";
AIM_MEMSET(&faultd_info__, 0, sizeof(faultd_info__));
if(!binaryname) {
binaryname = "Not specified.";
}
aim_strlcpy(faultd_info__.binary, binaryname, sizeof(faultd_info__.binary));
aim_strlcpy(faultd_info__.binary, binaryname, sizeof(faultd_info__.binary));
if(pipename) {
faultd_client_create(&faultd_client__, pipename);
if(pipename) {
faultd_client_create(&faultd_client__, pipename);
}
AIM_MEMSET(&saction, 0, sizeof(saction));
saction.sa_sigaction = faultd_signal_handler__;
AIM_MEMSET(&saction, 0, sizeof(saction));
saction.sa_sigaction = faultd_signal_handler__;
sigfillset(&saction.sa_mask);
saction.sa_flags = SA_SIGINFO | SA_RESETHAND;
rv = sigaction (SIGSEGV, &saction, NULL);
sigfillset(&saction.sa_mask);
saction.sa_flags = SA_SIGINFO | SA_RESETHAND;
rv = sigaction (SIGSEGV, &saction, NULL);
rv |= sigaction (SIGILL, &saction, NULL);
rv |= sigaction (SIGFPE, &saction, NULL);
rv |= sigaction (SIGFPE, &saction, NULL);
rv |= sigaction (SIGBUS, &saction, NULL);
rv |= sigaction (SIGQUIT, &saction, NULL);
rv |= sigaction (SIGALRM, &saction, NULL);
/*
* SIGUSR2 can be used to request a backtrace explicitly.
* In this case, we don't want to reset the handler.
* SIGUSR2 can be used to request a backtrace explicitly.
* In this case, we don't want to reset the handler.
*/
saction.sa_flags = SA_SIGINFO;
rv |= sigaction (SIGUSR2, &saction, NULL);
saction.sa_flags = SA_SIGINFO;
rv |= sigaction (SIGUSR2, &saction, NULL);
/*
* The local fault handler will attempt to write a subset of
* the fault information (signal type and backtrace)
* to the localfd descriptor if specified.
* the fault information (signal type and backtrace)
* to the localfd descriptor if specified.
*/
localfd__ = localfd;
localfd__ = localfd;
return rv;
}

View File

@@ -26,7 +26,7 @@ all: setup $(BUILDROOT_ARCHDIRS)
clean:
rm -rf $(BUILDROOT_ARCHDIRS)
rm -rf .setup.done
setup: setup-pyroute2 setup-dnspython setup-libyaml setup-pyyaml setup-jq setup-pyparted
cp $(wildcard patches/busybox*.patch) $(BUILDROOT_SOURCE)/package/busybox/

View File

@@ -0,0 +1,126 @@
dhcp additional options patch
Copyright (C) 2013 Curt Brune <curt@cumulusnetworks.com>
Copyright (C) 2014 david_yang <david_yang@accton.com>
Copyright (C) 2017 Jeffrey Townsend <jeffrey.townsend@bigswitch.com>
SPDX-License-Identifier: GPL-2.0
Enable the send/receive of additional DHCP options:
DHCP_LOG_SERVER
DHCP_WWW_SERVER
DHCP_DEFAULT_URL
diff -urpN a/networking/udhcp/common.c b/networking/udhcp/common.c
--- a/networking/udhcp/common.c 2017-07-18 15:11:59.626055248 +0000
+++ b/networking/udhcp/common.c 2017-07-18 15:09:47.942052391 +0000
@@ -26,7 +26,7 @@ const struct dhcp_optflag dhcp_optflags[
// { OPTION_IP | OPTION_LIST , 0x04 }, /* DHCP_TIME_SERVER */
// { OPTION_IP | OPTION_LIST , 0x05 }, /* DHCP_NAME_SERVER */
{ OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06 }, /* DHCP_DNS_SERVER */
-// { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */
+ { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */
// { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */
{ OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */
{ OPTION_STRING_HOST | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
@@ -44,6 +44,7 @@ const struct dhcp_optflag dhcp_optflags[
{ OPTION_STRING_HOST , 0x28 }, /* DHCP_NIS_DOMAIN */
{ OPTION_IP | OPTION_LIST , 0x29 }, /* DHCP_NIS_SERVER */
{ OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */
+ { OPTION_BIN , 0x2b }, /* DHCP_VENDOR_OPTS */
{ OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */
{ OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */
{ OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
@@ -51,18 +52,22 @@ const struct dhcp_optflag dhcp_optflags[
//TODO: must be combined with 'sname' and 'file' handling:
{ OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
{ OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
+ { OPTION_IP | OPTION_LIST , 0x48 }, /* DHCP_WWW_SERVER */
//TODO: not a string, but a set of LASCII strings:
// { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
+ { OPTION_STRING , 0x72 }, /* DHCP_DEFAULT_URL */
#if ENABLE_FEATURE_UDHCP_RFC3397
{ OPTION_DNS_STRING | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */
{ OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */
#endif
{ OPTION_STATIC_ROUTES | OPTION_LIST , 0x79 }, /* DHCP_STATIC_ROUTES */
+ { OPTION_BIN , 0x7d }, /* DHCP_VIVSO_OPTS */
#if ENABLE_FEATURE_UDHCP_8021Q
{ OPTION_U16 , 0x84 }, /* DHCP_VLAN_ID */
{ OPTION_U8 , 0x85 }, /* DHCP_VLAN_PRIORITY */
#endif
{ OPTION_6RD , 0xd4 }, /* DHCP_6RD */
+ { OPTION_IP , 0x96 }, /* DHCP_TFTP_SERVER_IP */
{ OPTION_STATIC_ROUTES | OPTION_LIST , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
{ OPTION_STRING , 0xfc }, /* DHCP_WPAD */
@@ -95,7 +100,7 @@ const char dhcp_option_strings[] ALIGN1
// "timesrv" "\0" /* DHCP_TIME_SERVER */
// "namesrv" "\0" /* DHCP_NAME_SERVER */
"dns" "\0" /* DHCP_DNS_SERVER */
-// "logsrv" "\0" /* DHCP_LOG_SERVER */
+ "logsrv" "\0" /* DHCP_LOG_SERVER */
// "cookiesrv" "\0" /* DHCP_COOKIE_SERVER */
"lprsrv" "\0" /* DHCP_LPR_SERVER */
"hostname" "\0" /* DHCP_HOST_NAME */
@@ -110,13 +115,16 @@ const char dhcp_option_strings[] ALIGN1
"nisdomain" "\0" /* DHCP_NIS_DOMAIN */
"nissrv" "\0" /* DHCP_NIS_SERVER */
"ntpsrv" "\0" /* DHCP_NTP_SERVER */
+ "vendoropts" "\0" /* DHCP_VENDOR_OPTS */
"wins" "\0" /* DHCP_WINS_SERVER */
"lease" "\0" /* DHCP_LEASE_TIME */
"serverid" "\0" /* DHCP_SERVER_ID */
"message" "\0" /* DHCP_ERR_MESSAGE */
"tftp" "\0" /* DHCP_TFTP_SERVER_NAME */
"bootfile" "\0" /* DHCP_BOOT_FILE */
+ "wwwsrv" "\0" /* DHCP_WWW_SERVER */
// "userclass" "\0" /* DHCP_USER_CLASS */
+ "url" "\0" /* DHCP_DEFAULT_URL */
#if ENABLE_FEATURE_UDHCP_RFC3397
"search" "\0" /* DHCP_DOMAIN_SEARCH */
// doesn't work in udhcpd.conf since OPTION_SIP_SERVERS
@@ -124,11 +132,13 @@ const char dhcp_option_strings[] ALIGN1
"sipsrv" "\0" /* DHCP_SIP_SERVERS */
#endif
"staticroutes" "\0"/* DHCP_STATIC_ROUTES */
+ "vivso" "\0" /* DHCP_VIVSO_OPTS */
#if ENABLE_FEATURE_UDHCP_8021Q
"vlanid" "\0" /* DHCP_VLAN_ID */
"vlanpriority" "\0"/* DHCP_VLAN_PRIORITY */
#endif
"ip6rd" "\0" /* DHCP_6RD */
+ "tftpsiaddr" "\0" /* DHCP_TFTP_SERVER_IP */
"msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
"wpad" "\0" /* DHCP_WPAD */
;
@@ -145,6 +155,7 @@ const uint8_t dhcp_option_lengths[] ALIG
[OPTION_IP] = 4,
[OPTION_IP_PAIR] = 8,
// [OPTION_BOOLEAN] = 1,
+ [OPTION_BIN] = 1, /* ignored by udhcp_str2optset */
[OPTION_STRING] = 1, /* ignored by udhcp_str2optset */
[OPTION_STRING_HOST] = 1, /* ignored by udhcp_str2optset */
#if ENABLE_FEATURE_UDHCP_RFC3397
diff -urpN a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
--- a/networking/udhcp/dhcpc.c 2017-07-18 15:11:59.626055248 +0000
+++ b/networking/udhcp/dhcpc.c 2017-07-18 15:11:11.066054194 +0000
@@ -100,6 +100,7 @@ static const uint8_t len_of_option_as_st
[OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
[OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
[OPTION_6RD ] = sizeof("32 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 "),
+ [OPTION_BIN ] = 2,
[OPTION_STRING ] = 1,
[OPTION_STRING_HOST ] = 1,
#if ENABLE_FEATURE_UDHCP_RFC3397
@@ -240,6 +241,9 @@ static NOINLINE char *xmalloc_optname_op
dest += sprintf(dest, type == OPTION_U32 ? "%lu" : "%ld", (unsigned long) ntohl(val_u32));
break;
}
+ case OPTION_BIN:
+ *bin2hex(dest, (void*) option, len) = '\0';
+ return ret;
/* Note: options which use 'return' instead of 'break'
* (for example, OPTION_STRING) skip the code which handles
* the case of list of options.

View File

@@ -1391,7 +1391,7 @@ CONFIG_I2C_MUX=y
# CONFIG_I2C_MUX_GPIO is not set
# CONFIG_I2C_MUX_PCA9541 is not set
CONFIG_I2C_MUX_PCA954x=y
# CONFIG_I2C_MUX_PCA954X_DESELECT_ON_EXIT is not set
CONFIG_I2C_MUX_PCA954X_DESELECT_ON_EXIT=y
CONFIG_I2C_HELPER_AUTO=y
#

View File

@@ -470,7 +470,9 @@ CONFIG_X86_PAT=y
CONFIG_ARCH_USES_PG_UNCACHED=y
CONFIG_ARCH_RANDOM=y
CONFIG_X86_SMAP=y
# CONFIG_EFI is not set
CONFIG_EFI=y
CONFIG_EFI_STUB=y
# CONFIG_EFI_MIXED is not set
CONFIG_SECCOMP=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y
@@ -521,6 +523,7 @@ CONFIG_ACPI_CONTAINER=y
# CONFIG_ACPI_SBS is not set
# CONFIG_ACPI_HED is not set
CONFIG_ACPI_CUSTOM_METHOD=y
# CONFIG_ACPI_BGRT is not set
# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set
# CONFIG_ACPI_APEI is not set
# CONFIG_ACPI_EXTLOG is not set
@@ -1200,7 +1203,7 @@ CONFIG_EDA_DEF_ALIGN=0x00100000
#
CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_AT25=y
# CONFIG_EEPROM_LEGACY is not set
CONFIG_EEPROM_LEGACY=m
# CONFIG_EEPROM_MAX6875 is not set
CONFIG_EEPROM_93CX6=y
# CONFIG_EEPROM_93XX46 is not set
@@ -1219,6 +1222,9 @@ CONFIG_CB710_DEBUG_ASSUMPTIONS=y
# Altera FPGA firmware download module
#
# CONFIG_ALTERA_STAPL is not set
# CONFIG_INTEL_MEI is not set
# CONFIG_INTEL_MEI_ME is not set
# CONFIG_INTEL_MEI_TXE is not set
# CONFIG_VMWARE_VMCI is not set
#
@@ -2180,6 +2186,8 @@ CONFIG_SENSORS_UCD9200=y
# CONFIG_SENSORS_SMSC47M192 is not set
# CONFIG_SENSORS_SMSC47B397 is not set
# CONFIG_SENSORS_SCH56XX_COMMON is not set
# CONFIG_SENSORS_SCH5627 is not set
# CONFIG_SENSORS_SCH5636 is not set
# CONFIG_SENSORS_SMM665 is not set
# CONFIG_SENSORS_ADC128D818 is not set
# CONFIG_SENSORS_ADS1015 is not set
@@ -2200,7 +2208,8 @@ CONFIG_SENSORS_W83781D=y
# CONFIG_SENSORS_W83791D is not set
# CONFIG_SENSORS_W83792D is not set
# CONFIG_SENSORS_W83793 is not set
# CONFIG_SENSORS_W83795 is not set
CONFIG_SENSORS_W83795=m
CONFIG_SENSORS_W83795_FANCTRL=y
# CONFIG_SENSORS_W83L785TS is not set
# CONFIG_SENSORS_W83L786NG is not set
# CONFIG_SENSORS_W83627HF is not set
@@ -2228,7 +2237,59 @@ CONFIG_X86_PKG_TEMP_THERMAL=m
#
# Texas Instruments thermal drivers
#
# CONFIG_WATCHDOG is not set
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
# CONFIG_WATCHDOG_NOWAYOUT is not set
#
# Watchdog Device Drivers
#
# CONFIG_SOFT_WATCHDOG is not set
# CONFIG_XILINX_WATCHDOG is not set
# CONFIG_DW_WATCHDOG is not set
# CONFIG_ACQUIRE_WDT is not set
# CONFIG_ADVANTECH_WDT is not set
# CONFIG_ALIM1535_WDT is not set
# CONFIG_ALIM7101_WDT is not set
# CONFIG_F71808E_WDT is not set
# CONFIG_SP5100_TCO is not set
# CONFIG_SBC_FITPC2_WATCHDOG is not set
# CONFIG_EUROTECH_WDT is not set
# CONFIG_IB700_WDT is not set
# CONFIG_IBMASR is not set
# CONFIG_WAFER_WDT is not set
# CONFIG_I6300ESB_WDT is not set
# CONFIG_IE6XX_WDT is not set
CONFIG_ITCO_WDT=y
# CONFIG_ITCO_VENDOR_SUPPORT is not set
# CONFIG_IT8712F_WDT is not set
# CONFIG_IT87_WDT is not set
# CONFIG_HP_WATCHDOG is not set
# CONFIG_SC1200_WDT is not set
# CONFIG_PC87413_WDT is not set
# CONFIG_NV_TCO is not set
# CONFIG_60XX_WDT is not set
# CONFIG_CPU5_WDT is not set
# CONFIG_SMSC_SCH311X_WDT is not set
# CONFIG_SMSC37B787_WDT is not set
# CONFIG_VIA_WDT is not set
# CONFIG_W83627HF_WDT is not set
# CONFIG_W83877F_WDT is not set
# CONFIG_W83977F_WDT is not set
# CONFIG_MACHZ_WDT is not set
# CONFIG_SBC_EPX_C3_WATCHDOG is not set
# CONFIG_MEN_A21_WDT is not set
#
# PCI-based Watchdog Cards
#
# CONFIG_PCIPCWATCHDOG is not set
# CONFIG_WDTPCI is not set
#
# USB-based Watchdog Cards
#
# CONFIG_USBPCWATCHDOG is not set
CONFIG_SSB_POSSIBLE=y
#
@@ -2281,7 +2342,7 @@ CONFIG_MFD_CORE=y
# CONFIG_MFD_MC13XXX_I2C is not set
# CONFIG_HTC_PASIC3 is not set
# CONFIG_HTC_I2CPLD is not set
# CONFIG_LPC_ICH is not set
CONFIG_LPC_ICH=y
CONFIG_LPC_SCH=y
# CONFIG_MFD_JANZ_CMODIO is not set
# CONFIG_MFD_KEMPLD is not set
@@ -2914,6 +2975,12 @@ CONFIG_ISCSI_IBFT_FIND=y
CONFIG_ISCSI_IBFT=y
# CONFIG_GOOGLE_FIRMWARE is not set
#
# EFI (Extensible Firmware Interface) Support
#
# CONFIG_EFI_VARS is not set
CONFIG_EFI_RUNTIME_MAP=y
#
# File systems
#
@@ -3045,6 +3112,7 @@ CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
# CONFIG_UFS_FS is not set
# CONFIG_EXOFS_FS is not set
# CONFIG_F2FS_FS is not set
CONFIG_EFIVAR_FS=y
CONFIG_ORE=y
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NFS_FS=y
@@ -3308,6 +3376,7 @@ CONFIG_STRICT_DEVMEM=y
CONFIG_X86_VERBOSE_BOOTUP=y
CONFIG_EARLY_PRINTK=y
# CONFIG_EARLY_PRINTK_DBGP is not set
# CONFIG_EARLY_PRINTK_EFI is not set
# CONFIG_X86_PTDUMP is not set
CONFIG_DEBUG_RODATA=y
# CONFIG_DEBUG_RODATA_TEST is not set

View File

@@ -0,0 +1,400 @@
diff -Nu a/drivers/net/ethernet/intel/igb/bcm_phy.c b/drivers/net/ethernet/intel/igb/bcm_phy.c
--- a/drivers/net/ethernet/intel/igb/bcm_phy.c 1970-01-01 08:00:00.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/bcm_phy.c 2017-06-20 17:00:46.000000000 +0800
@@ -0,0 +1,206 @@
+#include "e1000_hw.h"
+#include "linux/brcmphy.h"
+
+/*
+ * 1000Base-T Control Register
+ */
+#define MII_BCM54XX_AUX_CTL_ENCODE(val) (((val & 0x7) << 12)|(val & 0x7))
+
+/*
+ * MII Link Advertisment
+ */
+#define MII_ANA_ASF (1 << 0) /* Advertise Selector Field */
+#define MII_ANA_HD_10 (1 << 5) /* Half duplex 10Mb/s supported */
+#define MII_ANA_FD_10 (1 << 6) /* Full duplex 10Mb/s supported */
+#define MII_ANA_HD_100 (1 << 7) /* Half duplex 100Mb/s supported */
+#define MII_ANA_FD_100 (1 << 8) /* Full duplex 100Mb/s supported */
+#define MII_ANA_T4 (1 << 9) /* T4 */
+#define MII_ANA_PAUSE (1 << 10)/* Pause supported */
+#define MII_ANA_ASYM_PAUSE (1 << 11)/* Asymmetric pause supported */
+#define MII_ANA_RF (1 << 13)/* Remote fault */
+#define MII_ANA_NP (1 << 15)/* Next Page */
+
+#define MII_ANA_ASF_802_3 (1) /* 802.3 PHY */
+
+/*
+ * BCM54XX: Shadow registers
+ * Shadow values go into bits [14:10] of register 0x1c to select a shadow
+ * register to access.
+ */
+#define BCM54XX_SHD_AUTODETECT 0x1e /* 11110: Auto detect Regisrer */
+#define BCM54XX_SHD_MODE 0x1f /* 11111: Mode Control Register */
+#define BCM54XX_SHD_MODE_SER 1<<6
+
+/*
+ * Indirect register access functions for the 1000BASE-T/100BASE-TX/10BASE-T
+ * 0x1c shadow registers.
+ */
+
+int bcmphy_write(struct e1000_hw *hw,u32 reg, u16 regval)
+{
+ u32 ret;
+ struct e1000_phy_info *phy = &hw->phy;
+
+ ret = phy->ops.write_reg(hw,reg, regval);
+ return ret;
+}
+
+u16 bcmphy_read(struct e1000_hw *hw, u32 reg)
+{
+ u16 val;
+ struct e1000_phy_info *phy = &hw->phy;
+
+ phy->ops.read_reg(hw,reg, &val);
+ return val;
+}
+
+static int bcm54xx_shadow_read(struct e1000_hw *hw, u16 shadow)
+{
+ bcmphy_write(hw, MII_BCM54XX_SHD, MII_BCM54XX_SHD_VAL(shadow));
+ return MII_BCM54XX_SHD_DATA(bcmphy_read(hw, MII_BCM54XX_SHD));
+}
+
+static int bcm54xx_shadow_write(struct e1000_hw *hw, u16 shadow, u16 val)
+{
+ return bcmphy_write(hw, MII_BCM54XX_SHD,
+ MII_BCM54XX_SHD_WRITE |
+ MII_BCM54XX_SHD_VAL(shadow) |
+ MII_BCM54XX_SHD_DATA(val));
+}
+
+static int bcm54xx_auxctl_write(struct e1000_hw *hw, u16 regnum, u16 val)
+{
+ return bcmphy_write(hw, MII_BCM54XX_AUX_CTL, (regnum | val));
+}
+
+static int bcm54xx_config_init(struct e1000_hw *hw)
+{
+ int reg, err;
+
+ reg = bcmphy_read(hw, MII_BCM54XX_ECR);
+ if (reg < 0)
+ return reg;
+
+ /* Mask interrupts globally. */
+ reg |= MII_BCM54XX_ECR_IM;
+ err = bcmphy_write(hw, MII_BCM54XX_ECR, reg);
+ if (err < 0)
+ return err;
+
+ /* Unmask events we are interested in. */
+ reg = ~(MII_BCM54XX_INT_DUPLEX |
+ MII_BCM54XX_INT_SPEED |
+ MII_BCM54XX_INT_LINK);
+ err = bcmphy_write(hw, MII_BCM54XX_IMR, reg);
+ if (err < 0)
+ return err;
+
+ return 0;
+}
+
+void bcm54616s_linkup(struct e1000_hw *hw, int speed, int duplex)
+{
+ u16 regval;
+
+ /* set speed and full duplex*/
+ regval = bcmphy_read(hw,PHY_CONTROL);
+ regval &= ~(MII_CR_SPEED_SELECT_MSB |
+ MII_CR_SPEED_SELECT_LSB |
+ MII_CR_FULL_DUPLEX);
+
+ switch(speed) {
+ case SPEED_10:
+ regval |= MII_CR_SPEED_10;
+ break;
+ case SPEED_100:
+ regval |= MII_CR_SPEED_100;
+ break;
+ case SPEED_1000:
+ default:
+ regval |= MII_CR_SPEED_1000;
+ break;
+ }
+
+ switch(duplex) {
+ case FULL_DUPLEX:
+ regval |= MII_CR_FULL_DUPLEX;
+ break;
+ }
+
+ bcmphy_write(hw,PHY_CONTROL, regval);
+
+ regval = bcmphy_read(hw, PHY_CONTROL);
+ regval &= ~(MII_CR_ISOLATE);
+ bcmphy_write(hw, PHY_CONTROL, regval);
+}
+
+int bcm54616s_config_init(struct e1000_hw *hw)
+{
+ int err, reg;
+ u16 regval;
+ int i;
+
+ /* reset PHY */
+ regval = (1<<15);
+ bcmphy_write(hw, PHY_CONTROL, regval);
+
+ mdelay(10);
+
+ /* disable Power down and iso */
+ regval = bcmphy_read(hw,PHY_CONTROL);
+ regval &= ~(MII_CR_POWER_DOWN | MII_CR_ISOLATE);
+ bcmphy_write(hw, PHY_CONTROL, regval);
+
+ /* disable suport I */
+ /*0000 0100 1100 0010 */
+ bcm54xx_auxctl_write(hw, 0, 0x04c2);
+
+ regval = bcmphy_read(hw, MII_BCM54XX_AUX_CTL);
+
+ /* set 1000base-T */
+ regval = bcmphy_read(hw, PHY_1000T_CTRL);
+ regval |= (CR_1000T_FD_CAPS | CR_1000T_REPEATER_DTE);
+ bcmphy_write(hw, PHY_1000T_CTRL, regval);
+
+ /* set ctrl */
+ regval = (MII_CR_SPEED_1000 |
+ MII_CR_FULL_DUPLEX |
+ MII_CR_SPEED_SELECT_MSB);
+ bcmphy_write(hw, PHY_CONTROL, regval);
+
+ /* Setup read from auxilary control shadow register 7 */
+ bcmphy_write(hw, MII_BCM54XX_AUX_CTL, MII_BCM54XX_AUX_CTL_ENCODE(7));
+
+ /* Read Misc Control register */
+ reg = ((bcmphy_read(hw, MII_BCM54XX_AUX_CTL) & 0x8FFF) | 0x8010);
+ bcmphy_write(hw, MII_BCM54XX_AUX_CTL, reg);
+
+ /* Enable auto-detect and copper prefer */
+ bcm54xx_shadow_write(hw, BCM54XX_SHD_AUTODETECT, 0x31);
+
+ err = bcm54xx_config_init(hw);
+
+ /* set link parner */
+ regval = MII_ANA_ASF_802_3;
+ regval |= MII_ANA_HD_10;
+ regval |= MII_ANA_HD_100;
+ regval |= MII_ANA_FD_10;
+ regval |= MII_ANA_FD_100;
+ regval |= MII_ANA_ASYM_PAUSE;
+ regval |= (MII_ANA_PAUSE | MII_ANA_ASYM_PAUSE);
+ regval |= MII_ANA_PAUSE;
+ bcmphy_write(hw, PHY_AUTONEG_ADV, reg);
+
+ i=0;
+ while (1) {
+ regval = bcm54xx_shadow_read(hw,BCM54XX_SHD_MODE);
+ if (regval & BCM54XX_SHD_MODE_SER)
+ break;
+ if (i++ > 500) {
+ //printk("SERDES no link %x\n",regval);
+ break;
+ }
+ mdelay(1); /* 1 ms */
+ }
+ return err;
+}
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c 2017-06-20 16:44:29.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c 2017-06-20 17:00:52.000000000 +0800
@@ -317,6 +317,10 @@
break;
case BCM54616_E_PHY_ID:
phy->type = e1000_phy_bcm54616;
+ phy->ops.check_polarity = NULL;
+ phy->ops.get_info = igb_get_phy_info_bcm;
+ phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_bcm;
+ bcm54616s_config_init(hw);
break;
case BCM50210S_E_PHY_ID:
break;
@@ -1636,6 +1640,7 @@
ret_val = igb_e1000_copper_link_setup_82577(hw);
break;
case e1000_phy_bcm54616:
+ ret_val = igb_copper_link_setup_bcm(hw);
break;
case e1000_phy_bcm5461s:
break;
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_82575.h b/drivers/net/ethernet/intel/igb/e1000_82575.h
--- a/drivers/net/ethernet/intel/igb/e1000_82575.h 2017-06-20 16:44:27.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.h 2017-06-20 17:00:57.000000000 +0800
@@ -25,6 +25,8 @@
#ifndef _E1000_82575_H_
#define _E1000_82575_H_
+extern void bcm54616s_linkup(struct e1000_hw *hw,int speed , int duplex);
+extern int bcm54616s_config_init(struct e1000_hw *hw);
#define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \
(ID_LED_DEF1_DEF2 << 8) | \
(ID_LED_DEF1_DEF2 << 4) | \
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c 2017-06-20 16:44:27.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c 2017-06-20 17:01:05.000000000 +0800
@@ -1187,6 +1187,19 @@
return E1000_SUCCESS;
}
+s32 igb_copper_link_setup_bcm(struct e1000_hw *hw)
+{
+ struct e1000_phy_info *phy = &hw->phy;
+ s32 ret_val;
+ u16 phy_data;
+
+ ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data);
+ phy_data &= ~(MII_CR_ISOLATE);
+ ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data);
+
+ return 0;
+}
+
/**
* e1000_copper_link_setup_m88_gen2 - Setup m88 PHY's for copper link
* @hw: pointer to the HW structure
@@ -1720,6 +1733,62 @@
return ret_val;
}
+s32 igb_phy_force_speed_duplex_bcm(struct e1000_hw *hw)
+{
+ struct e1000_phy_info *phy = &hw->phy;
+ s32 ret_val;
+ u16 phy_data;
+ bool link;
+
+ ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data);
+ if (ret_val)
+ return ret_val;
+
+ e1000_phy_force_speed_duplex_setup(hw, &phy_data);
+
+ phy_data &= ~(MII_CR_POWER_DOWN | MII_CR_ISOLATE);
+ ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data);
+ if (ret_val)
+ return ret_val;
+
+ /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
+ * forced whenever speed and duplex are forced.
+ */
+ #if 0
+ ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
+ if (ret_val)
+ return ret_val;
+
+ phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
+ phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
+
+ ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
+ if (ret_val)
+ return ret_val;
+
+ hw_dbg("IGP PSCR: %X\n", phy_data);
+ #endif
+ udelay(1);
+
+ if (phy->autoneg_wait_to_complete) {
+ DEBUGFUNC("Waiting for forced speed/duplex link on IGP phy.\n");
+
+ ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
+ 100000, &link);
+ if (ret_val)
+ return ret_val;
+
+ if (!link)
+ DEBUGFUNC("Link taking longer than expected.\n");
+
+ /* Try once more */
+ ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
+ 100000, &link);
+ }
+
+ return ret_val;
+}
+
/**
* e1000_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
* @hw: pointer to the HW structure
@@ -2614,6 +2683,29 @@
}
return ret_val;
+}
+
+s32 igb_get_phy_info_bcm(struct e1000_hw *hw)
+{
+ struct e1000_phy_info *phy = &hw->phy;
+ s32 ret_val;
+ bool link;
+
+ if (phy->media_type != e1000_media_type_copper) {
+ DEBUGFUNC("Phy info is only valid for copper media\n");
+ return -E1000_ERR_CONFIG;
+ }
+
+ ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
+ if (ret_val)
+ return ret_val;
+
+ if (!link) {
+ DEBUGFUNC("Phy info is only valid if link is up\n");
+ return -E1000_ERR_CONFIG;
+ }
+
+ return ret_val;
}
/**
diff -Nu a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h
--- a/drivers/net/ethernet/intel/igb/e1000_phy.h 2017-06-20 16:44:27.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.h 2017-06-20 17:01:24.000000000 +0800
@@ -99,6 +99,9 @@
s32 e1000_write_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 data,
bool line_override);
bool e1000_is_mphy_ready(struct e1000_hw *hw);
+s32 igb_copper_link_setup_bcm(struct e1000_hw *hw);
+s32 igb_phy_force_speed_duplex_bcm(struct e1000_hw *hw);
+s32 igb_get_phy_info_bcm(struct e1000_hw *hw);
#define E1000_MAX_PHY_ADDR 8
diff -Nu a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
--- a/drivers/net/ethernet/intel/igb/igb_main.c 2017-06-20 16:44:27.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/igb_main.c 2017-06-20 17:01:29.000000000 +0800
@@ -4814,6 +4814,14 @@
&adapter->link_speed,
&adapter->link_duplex);
+ switch (hw->phy.type) {
+ case e1000_phy_bcm54616:
+ bcm54616s_linkup(hw, adapter->link_speed, adapter->link_duplex);
+ break;
+ default:
+ break;
+ }
+
ctrl = E1000_READ_REG(hw, E1000_CTRL);
/* Links status message must follow this format */
netdev_info(netdev,
diff -Nu a/drivers/net/ethernet/intel/igb/Makefile b/drivers/net/ethernet/intel/igb/Makefile
--- a/drivers/net/ethernet/intel/igb/Makefile 2017-06-20 16:44:27.000000000 +0800
+++ b/drivers/net/ethernet/intel/igb/Makefile 2017-06-20 17:01:34.000000000 +0800
@@ -35,4 +35,4 @@
e1000_mac.o e1000_nvm.o e1000_phy.o e1000_mbx.o \
e1000_i210.o igb_ptp.o igb_hwmon.o \
e1000_manage.o igb_param.o kcompat.o e1000_api.o \
- igb_vmdq.o igb_procfs.o igb_debugfs.o
+ igb_vmdq.o igb_procfs.o igb_debugfs.o bcm_phy.o

View File

@@ -0,0 +1,16 @@
diff -urpN a/Makefile b/Makefile
--- a/Makefile 2017-08-22 17:42:57.037875653 +0000
+++ b/Makefile 2017-08-22 17:43:53.089875539 +0000
@@ -616,6 +616,12 @@ include $(srctree)/arch/$(SRCARCH)/Makef
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
+# Required for GCC-5/6
+KBUILD_CFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CFLAGS += $(call cc-option, -no-pie)
+KBUILD_AFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
+
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
else

View File

@@ -25,3 +25,5 @@ platform-powerpc-85xx-Makefile.patch
platform-powerpc-dni-7448-r0.patch
platform-powerpc-quanta-lb9-r0.patch
driver-support-intel-igb-bcm50210-phy.patch
driver-igb-netberg-aurora.patch
gcc-no-pie.patch

View File

@@ -2302,8 +2302,13 @@ CONFIG_DMA_OF=y
# CONFIG_DMATEST is not set
# CONFIG_AUXDISPLAY is not set
# CONFIG_UIO is not set
# CONFIG_VFIO is not set
# CONFIG_VIRT_DRIVERS is not set
CONFIG_VFIO_IOMMU_TYPE1=y
CONFIG_VFIO=y
CONFIG_VFIO_PCI=y
CONFIG_VFIO_FSL_MC=y
CONFIG_VIRTIO=y
#
@@ -3029,3 +3034,4 @@ CONFIG_FONT_SUPPORT=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_ARCH_HAS_SG_CHAIN=y
CONFIG_FSL_LS2_CONSOLE=y

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,327 @@
diff -uNr a/drivers/soc/fsl/Kconfig.arm b/drivers/soc/fsl/Kconfig.arm
--- a/drivers/soc/fsl/Kconfig.arm 2017-06-05 17:37:14.530348991 +0530
+++ b/drivers/soc/fsl/Kconfig.arm 2017-06-05 17:32:18.630348990 +0530
@@ -23,3 +23,7 @@
if LS1_SOC_DRIVERS
source "drivers/soc/fsl/ls1/Kconfig"
endif
+
+if LS_SOC_DRIVERS
+ source "drivers/soc/fsl/ls2-console/Kconfig"
+endif
diff -uNr a/drivers/soc/fsl/ls2-console/Kconfig b/drivers/soc/fsl/ls2-console/Kconfig
--- a/drivers/soc/fsl/ls2-console/Kconfig 1970-01-01 05:30:00.000000000 +0530
+++ b/drivers/soc/fsl/ls2-console/Kconfig 2017-06-05 17:32:52.582348990 +0530
@@ -0,0 +1,4 @@
+config FSL_LS2_CONSOLE
+ tristate "Layerscape MC and AIOP console support"
+ depends on ARCH_LAYERSCAPE
+ default y
diff -uNr a/drivers/soc/fsl/ls2-console/ls2-console.c b/drivers/soc/fsl/ls2-console/ls2-console.c
--- a/drivers/soc/fsl/ls2-console/ls2-console.c 1970-01-01 05:30:00.000000000 +0530
+++ b/drivers/soc/fsl/ls2-console/ls2-console.c 2017-06-05 17:50:42.494348990 +0530
@@ -0,0 +1,291 @@
+/* Copyright 2015-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <linux/miscdevice.h>
+#include <linux/uaccess.h>
+#include <linux/poll.h>
+#include <linux/compat.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+
+/* SoC address for the MC firmware base low/high registers */
+#define SOC_CCSR_MC_FW_BASE_ADDR_REGS 0x8340020
+#define SOC_CCSR_MC_FW_BASE_ADDR_REGS_SIZE 2
+/* MC firmware base low/high registers indexes */
+#define MCFBALR_OFFSET 0
+#define MCFBAHR_OFFSET 1
+
+/* Bit mask used to obtain the most significant part of the MC base address */
+#define MC_FW_HIGH_ADDR_MASK 0x1FFFF
+/* Bit mask used to obtain the least significant part of the MC base address */
+#define MC_FW_LOW_ADDR_MASK 0xE0000000
+
+#define MC_BUFFER_OFFSET 0x01000000
+#define MC_BUFFER_SIZE (1024*1024*16)
+#define MC_OFFSET_DELTA (MC_BUFFER_OFFSET)
+
+#define AIOP_BUFFER_OFFSET 0x06000000
+#define AIOP_BUFFER_SIZE (1024*1024*16)
+#define AIOP_OFFSET_DELTA (0)
+
+struct log_header {
+ char magic_word[8]; /* magic word */
+ uint32_t buf_start; /* holds the 32-bit little-endian
+ offset of the start of the buffer */
+ uint32_t buf_length; /* holds the 32-bit little-endian
+ length of the buffer */
+ uint32_t last_byte; /* holds the 32-bit little-endian offset
+ of the byte after the last byte that was written */
+ char reserved[44];
+};
+
+#define LOG_HEADER_FLAG_BUFFER_WRAPAROUND 0x80000000
+#define LOG_VERSION_MAJOR 1
+#define LOG_VERSION_MINOR 0
+
+
+#define invalidate(p) { asm volatile("dc ivac, %0" : : "r" (p) : "memory"); }
+
+struct console_data {
+ char *map_addr;
+ struct log_header *hdr;
+ char *start_addr; /* Start of buffer */
+ char *end_addr; /* End of buffer */
+ char *end_of_data; /* Current end of data */
+ char *cur_ptr; /* Last data sent to console */
+};
+
+#define LAST_BYTE(a) ((a) & ~(LOG_HEADER_FLAG_BUFFER_WRAPAROUND))
+
+static inline void __adjust_end(struct console_data *cd)
+{
+ cd->end_of_data = cd->start_addr
+ + LAST_BYTE(le32_to_cpu(cd->hdr->last_byte));
+}
+
+static inline void adjust_end(struct console_data *cd)
+{
+ invalidate(cd->hdr);
+ __adjust_end(cd);
+}
+
+static inline uint64_t get_mc_fw_base_address(void) {
+ uint32_t* mcfbaregs = (uint32_t*) ioremap(SOC_CCSR_MC_FW_BASE_ADDR_REGS,
+ SOC_CCSR_MC_FW_BASE_ADDR_REGS_SIZE);
+ uint64_t mcfwbase = 0ULL;
+ mcfwbase = readl(mcfbaregs + MCFBAHR_OFFSET) & MC_FW_HIGH_ADDR_MASK;
+ mcfwbase <<= 32;
+ mcfwbase |= readl(mcfbaregs + MCFBALR_OFFSET) & MC_FW_LOW_ADDR_MASK;
+ iounmap(mcfbaregs);
+ pr_info("fsl-ls2-console: MC base address at 0x%016llx\n", mcfwbase);
+ return mcfwbase;
+}
+
+static int fsl_ls2_generic_console_open(struct inode *node, struct file *fp,
+ u64 offset, u64 size,
+ uint8_t *emagic, uint8_t magic_len,
+ u32 offset_delta)
+{
+ struct console_data *cd;
+ uint8_t *magic;
+ uint32_t wrapped;
+
+ cd = kmalloc(sizeof(*cd), GFP_KERNEL);
+ if (cd == NULL)
+ return -ENOMEM;
+ fp->private_data = cd;
+ cd->map_addr = ioremap(get_mc_fw_base_address() + offset, size);
+
+ cd->hdr = (struct log_header *) cd->map_addr;
+ invalidate(cd->hdr);
+
+ magic = cd->hdr->magic_word;
+ if (memcmp(magic, emagic, magic_len)) {
+ pr_info("magic didn't match!\n");
+ pr_info("expected: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ emagic[0], emagic[1], emagic[2], emagic[3],
+ emagic[4], emagic[5], emagic[6], emagic[7]);
+ pr_info(" seen: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ magic[0], magic[1], magic[2], magic[3],
+ magic[4], magic[5], magic[6], magic[7]);
+ kfree(cd);
+ iounmap(cd->map_addr);
+ return -EIO;
+ }
+
+ cd->start_addr = cd->map_addr
+ + le32_to_cpu(cd->hdr->buf_start) - offset_delta;
+ cd->end_addr = cd->start_addr + le32_to_cpu(cd->hdr->buf_length);
+
+ wrapped = le32_to_cpu(cd->hdr->last_byte)
+ & LOG_HEADER_FLAG_BUFFER_WRAPAROUND;
+
+ __adjust_end(cd);
+ if (wrapped && (cd->end_of_data != cd->end_addr))
+ cd->cur_ptr = cd->end_of_data+1;
+ else
+ cd->cur_ptr = cd->start_addr;
+
+ return 0;
+}
+
+static int fsl_ls2_mc_console_open(struct inode *node, struct file *fp)
+{
+ uint8_t magic_word[] = { 0, 1, 'C', 'M' };
+
+ return fsl_ls2_generic_console_open(node, fp,
+ MC_BUFFER_OFFSET, MC_BUFFER_SIZE,
+ magic_word, sizeof(magic_word),
+ MC_OFFSET_DELTA);
+}
+
+static int fsl_ls2_aiop_console_open(struct inode *node, struct file *fp)
+{
+ uint8_t magic_word[] = { 'P', 'O', 'I', 'A' };
+
+ return fsl_ls2_generic_console_open(node, fp,
+ AIOP_BUFFER_OFFSET, AIOP_BUFFER_SIZE,
+ magic_word, sizeof(magic_word),
+ AIOP_OFFSET_DELTA);
+}
+
+static int fsl_ls2_console_close(struct inode *node, struct file *fp)
+{
+ struct console_data *cd = fp->private_data;
+
+ iounmap(cd->map_addr);
+ kfree(cd);
+ return 0;
+}
+
+ssize_t fsl_ls2_console_read(struct file *fp, char __user *buf, size_t count,
+ loff_t *f_pos)
+{
+ struct console_data *cd = fp->private_data;
+ size_t bytes = 0;
+ char data;
+
+ /* Check if we need to adjust the end of data addr */
+ adjust_end(cd);
+
+ while ((count != bytes) && (cd->end_of_data != cd->cur_ptr)) {
+ if (((u64)cd->cur_ptr) % 64 == 0)
+ invalidate(cd->cur_ptr);
+
+ data = *(cd->cur_ptr);
+ if (copy_to_user(&buf[bytes], &data, 1))
+ return -EFAULT;
+ cd->cur_ptr++;
+ if (cd->cur_ptr >= cd->end_addr)
+ cd->cur_ptr = cd->start_addr;
+ ++bytes;
+ }
+ return bytes;
+}
+
+static const struct file_operations fsl_ls2_mc_console_fops = {
+ .owner = THIS_MODULE,
+ .open = fsl_ls2_mc_console_open,
+ .release = fsl_ls2_console_close,
+ .read = fsl_ls2_console_read,
+};
+
+static struct miscdevice fsl_ls2_mc_console_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "fsl_mc_console",
+ .fops = &fsl_ls2_mc_console_fops
+};
+
+static const struct file_operations fsl_ls2_aiop_console_fops = {
+ .owner = THIS_MODULE,
+ .open = fsl_ls2_aiop_console_open,
+ .release = fsl_ls2_console_close,
+ .read = fsl_ls2_console_read,
+};
+
+static struct miscdevice fsl_ls2_aiop_console_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "fsl_aiop_console",
+ .fops = &fsl_ls2_aiop_console_fops
+};
+
+static int __init fsl_ls2_console_init(void)
+{
+ int err = 0;
+
+ pr_info("Freescale LS2 console driver\n");
+ err = misc_register(&fsl_ls2_mc_console_dev);
+ if (err) {
+ pr_err("fsl_mc_console: cannot register device\n");
+ return err;
+ }
+ pr_info("fsl-ls2-console: device %s registered\n",
+ fsl_ls2_mc_console_dev.name);
+
+ err = misc_register(&fsl_ls2_aiop_console_dev);
+ if (err) {
+ pr_err("fsl_aiop_console: cannot register device\n");
+ return err;
+ }
+ pr_info("fsl-ls2-console: device %s registered\n",
+ fsl_ls2_aiop_console_dev.name);
+
+ return 0;
+}
+
+static void __exit fsl_ls2_console_exit(void)
+{
+ int err = misc_deregister(&fsl_ls2_mc_console_dev);
+
+ if (err)
+ pr_err("Failed to deregister device %s code %d\n",
+ fsl_ls2_mc_console_dev.name, err);
+ else
+ pr_info("device %s deregistered\n",
+ fsl_ls2_mc_console_dev.name);
+
+ err = misc_deregister(&fsl_ls2_aiop_console_dev);
+ if (err)
+ pr_err("Failed to deregister device %s code %d\n",
+ fsl_ls2_aiop_console_dev.name, err);
+ else
+ pr_info("device %s deregistered\n",
+ fsl_ls2_aiop_console_dev.name);
+}
+
+module_init(fsl_ls2_console_init);
+module_exit(fsl_ls2_console_exit);
+
+MODULE_AUTHOR("Roy Pledge <roy.pledge@freescale.com>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Freescale LS2 console driver");
diff -uNr a/drivers/soc/fsl/ls2-console/Makefile b/drivers/soc/fsl/ls2-console/Makefile
--- a/drivers/soc/fsl/ls2-console/Makefile 1970-01-01 05:30:00.000000000 +0530
+++ b/drivers/soc/fsl/ls2-console/Makefile 2017-06-05 17:32:52.582348990 +0530
@@ -0,0 +1 @@
+obj-$(CONFIG_FSL_LS2_CONSOLE) += ls2-console.o
diff -uNr a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
--- a/drivers/soc/fsl/Makefile 2017-06-05 17:37:14.530348991 +0530
+++ b/drivers/soc/fsl/Makefile 2017-06-05 17:33:54.022348991 +0530
@@ -4,3 +4,4 @@
obj-$(CONFIG_LS1_SOC_DRIVERS) += ls1/
obj-$(CONFIG_FSL_GUTS) += guts.o
+obj-$(CONFIG_LS_SOC_DRIVERS) += ls2-console/

View File

@@ -1,6 +1,2 @@
aufs.patch
driver-support-intel-igb-bcm54616-phy.patch
add-kernel-patches-for-nxp-arm64-ls2080ardb-based-on.patch
add-nxp-arm64-ls2088ardb-device-tree.patch
add-fsl-dpaa2-and-fsl-mc-support-based-on-3.18.25.patch
backport-some-kernel-patches-based-on-3.18.25.patch
0001-Patch-set-for-booting-ls2088rdb-with-vfio.patch
ls2_mc_console.patch

View File

@@ -26,6 +26,8 @@ ifndef K_TARGET_DIR
K_TARGET_DIR := $(THIS_DIR)
endif
K_PATCH_DIR := $(THIS_DIR)/patches
include ../../kconfig.mk
K_CONFIG := arm-iproc-all.config
K_BUILD_TARGET := Image

Some files were not shown because too many files have changed in this diff Show More