Added a missing #include

Ticket: none
Reviewed By: none
Testing Done: successfully compiled with MACHINE=kvm_x86_64

The previous commit worked for p2020 compiles, but failed for kvm_x86_64 compiles
because of a missing #include.  That #include has now been added to broadcom.c.
EEPROM-TLV-Add-new-service-tag-TLV-code

Reviewed By: Curt Brune <curt@cumulusnetworks.com>

This patch adds a new "Service Tag" TLV to the ONIE EEPROM format.

The new TLV code is 0x2F.

The format of the data is a variable length ASCII string.

It is intended to contain a vendor defined service tag.

Testing Done:

Updated an existing system and exercised the new TLV:

- verified setting the new TLV:
    sys_eeprom set 0x2F "fake service tag"

- verified displaying the new TLV:
    sys_eeprom

- verified removing the new TLV:
    sys_eeprom set 0x2F

- verified the new code shows up in the list of available codes:
    sys_eeprom list

Signed-off-by: Srideep <srideep_devireddy@dell.com)>
Adding support for sys-eeprom tool for x86_64 platforms

Ticket: ONIE-19
Reviewed By: curt, scotte
Testing Done: Tested on dell_s6000

Currently onie doesnt have a sys_eeprom tool. In powerpc based platforms, we
have U-boot from we can access the eeprom, and hence we could live without
this tool. But with x86, there is no u-boot, and eeprom access will now
have to be from ONIE.
Updates:
- Added support for Service Tag TLV
- Changed name from sys-eeprom to onie-syseeprom
onie-sysinfo: allow platform and architecture overrides

Reviewed By: vidya, dustin

The onie-sysinfo command dumps a number of different information
fields.

This patch lets a particular implementation override the default
beahviour for the 'serial number' and 'base MAC address' fields.

For both of these fields search for the value in the following order:

1. is the value set in the environment?  highest priority
2. the platform provides an accessor function
3. the CPU architecture provides an accessor function
4. use the contents of /sys/class/net/eth0/address
5. return 'unknown'

Setting the value in the environment has the highest priority.  This
is useful in development where you can set the value on the kernel
command line.

Next, a platform implementation takes priority.  If a particular
platform has special hoops to jump through it can implement a
function.

Next comes the CPU architecture implementation.  This implementation
should apply to a wide class of machines that share a common
access method.

Testing Done:

Exercised the implementation on PowerPC and x86_64 platforms.
Exercised the priority order, testing each one in turn.
x86_64: onie-sysinfo arch overrides

Reviewed By: vidya, dustin

Provide x86_64 arch overrides for the onie-sysinfo 'serial number' and
'base MAC address' fields.

On x86_64 the default implementation will rely on the onie-syseeprom
command and the ONIE TLV EEPROM format to locate the required
information.

Testing Done:

Exercised 'onie-sysinfo -a' on a x86_64 based system and validated the
results.
configure Ethernet management interface MAC addresses

Reviewed By: vidya, dustin

At boot time set each Ethernet management interface MAC address based
on the output of the 'onie-sysinfo -e' command.

Testing Done:

Exercised the code changes on both PowerPC and x86_64 platforms.  In
both cases verified that the eth0 MAC address matched the output of
'onie-sysinfo -e'.
i2tools.make: fix build time patch assembly directory

Reviewed By: No one

The temporary directory used to conflate the core ONIE i2ctools
patches with the platform specific patches was incorrectly.

This patch places the temp directory *outside* of the i2ctools source
code directory.

Testing Done:

Compiled images successfully.
i2ctools: allow platforms to disable i2ctools support

Allow platforms on a case by case basis disable support for the
i2ctools and related onie-syseeprom command.  The KVM machine for
example does not have an EEPROM.
im_n29xx_t40n: skip i2ctools for this platform

At the moment the EEPROM is unsupported on this platform.

Revisit this when EEPROM access is supported.
kvm_x86_64:  misc updates

Bundle together a few updates for the KVM target.

1 - disable CONFIG_MD in the kernel config.  For some reason CONFIG_MD
    does not play nice with the virtual machine's virtio block device.

2 - disable i2ctools and onie-syseeprom.  The VM does not have an
    EEPROM.

3 - use eth0's MAC address as is during boot up.
kvm_x86_64:  create virtio device dynamically

Commit 062d8d29e88e5fed197fbe5628311016ba522567 disabled the CONFIG_MD
kernel parameter for this platform because the virtio devices were not
working properly.

The cause of the problem is that the virto MAJOR device number is
determined dynamically, while we were assigning it statically.

This patch reverts the CONFIG_MD kernel configuration change and
creates the virtio devices, /dev/vda[1-8], dynamically at boot time.

Testing:

- Exercised the image on the kvm_x86_64 target, which uses virtio.

- Exercised the image on a real x86_64 target, which does not use
  virtio.
Update ONIE compiler and linker flags

Reviewed By: puneet

Some projects (notably GRUB) require CPPFLAGS to be set irrespective
of what CFLAGS is set to.  Having all the required options in CFLAGS is
not enough.

This patch moves the "--sysroot=$(DEV_SYSROOT)" setting from
ONIE_CFLAGS and ONIE_CXXFLAGS, putting it into ONIE_CPPFLAGS.  This
setting only affects search directories and is appropriate for
CPPFLAGS.

The true compile flags, -Os, remains with ONIE_CFLAGS and
ONIE_CXXFLAGS.

The patch also exports the following variables:

  ONIE_CPPFLAGS
  ONIE_CFLAGS
  ONIE_CXXFLAGS
  ONIE_LDFLAGS

This allows sub-projects' Makefiles to append the ONIE flags onto
their own flags.  This only applies to projects that lack a
./configure script and require patching of their Makefiles.

Testing Done:
Compiled images and exercised on powerpc and x86 platforms
x86_64: add dmidecode utility

Reviewed By: puneet, dustin

This patch adds the 'dmidecode' utility from the dmidecode project to
x86_64 platforms.

See:  http://www.nongnu.org/dmidecode/

Testing Done:

Built an image and loaded on a x86_64 based platform.  Exercised the
dmidecode command.  The output looks reasonable.
gptfdisk: use exported ONIE compiler and linker flags

Reviewed By: puneet

Updates the gptfdisk Makefile to append the ONIE compiler and linker
flags to its own definitions.

Previously the ONIE gptfdisk.make commands were overriding the
gptfdisk project's definitions with the ONIE definitions.  We really
wanted the ONIE definitions to be appended to the project's
definitions, not to replace them.

Testing Done:
Compiled images and exercised on x86 platform
Add support for lvm2 and device-mapper

Reviewed By: puneet, dustin

This patch adds support for logical volume management, specifically
lvm2.  This cuts across a number of components:

GRUB -- adds support for loading the kernel and initrd from logical
        volumes.

Linux Kernel -- adds device mapper support, which lvm2 is built on top
                of.

user space -- adds lvm2 utilities for creating / managing logical
              volumes.

Testing Done:

1.  Boot into ONIE.
2.  Create a volume group on /dev/sda4
3.  Create a logical volume
4.  Create a ext4 file system on logical volume, with a label
5.  Mount logical volume
6.  copy ONIE kernel and initramfs to logical volume
7.  umount logical volume
8.  Reboot, stopping in grub
9.  From grub 'insmod lvm'
10. grub> ls  -- shows the logical volume
11. grub> search command finds partition by file system label
12. grub> load kernel and initramfs from volume
13. grub> boot -- boots in ONIE from logical volume
onie-syseeprom:  add get TLV by type_code option

Reviewed By:  puneet, scotte, dustin

This patch adds a new option, -g (--get) <TLV code>, that extracts the
relevant TLV from the EEPROM and prints it to stdout.  This option is
very nice for scripts that are interested in particular fields, like
finding the serial number:

  ONIE:/ # /bin/onie-syseeprom -g 0x23
  fake-serial-12345

Using this option scripts can extract specific fields without dealing
with error prone screen scraping techniques.

This patch also cleans up a number of error handling cases that
previously went undetected.  The exit status of this program now
accurately reflects the status of the operation.

Testing Done:

- ran with -h, verifying the new option is described correctly
- ran with -g for existing code. verified dumped code matched what was
  in the eeprom.  Program return code was 0.

- ran with -g for non-existing code.  verified error reported and
  program return code was non-zero.

- exercised existing features, like -s, -l, -e, verified the program
  return status was 0.

- exercised existing -e with bad code and verified the program return
  status was non-zero.
x86_64: sysinfo use onie-syseeprom -g option

Instead of grepping the output of 'onie-syseeprom' for the serial
number and MAC address use the new "--get" option to retrieve an
EEPROM field by TLV code number.
Set partition attributes for ONIE GPT partitions

The GUUID Partition Table format allocates 64 bits of attributes for
each partition.  Of interest here are the "system partition" (bit 0)
and the "read only" (bit 60) attributes.

During ONIE installation set the partition attributes as follows:

GRUB_BOOT   -- system partition, read-only
ONIE_BOOT   -- system partition, read-only
ONIE_CONFIG -- system partition

The goal is that NOS installers will respect these partition
attributes and avoid destroying/modifying the ONIE partitions.

Reviewed By: dustin

Testing Done:

Installed ONIE on the kvm_x86_64 machine and verified the partition
attributes were set correctly using sgdisk:

    ONIE:/ # sgdisk -i 1 /dev/vda
    Partition GUID code: 21686148-6449-6E6F-744E-656564454649 (BIOS boot partition)
    Partition unique GUID: 7442636D-5160-4872-A8AA-90078D97E556
    First sector: 2048 (at 1024.0 KiB)
    Last sector: 6143 (at 3.0 MiB)
    Partition size: 4096 sectors (2.0 MiB)
==> Attribute flags: 1000000000000001
    Partition name: 'GRUB-BOOT'

    ONIE:/ # sgdisk -i 2 /dev/vda
    Partition GUID code: 7412F7D5-A156-4B13-81DC-867174929325 (ONIE boot)
    Partition unique GUID: 81C55EA1-48E0-44F7-A557-2990C3CB9490
    First sector: 6144 (at 3.0 MiB)
    Last sector: 268287 (at 131.0 MiB)
    Partition size: 262144 sectors (128.0 MiB)
==> Attribute flags: 1000000000000001
    Partition name: 'ONIE-BOOT'

    ONIE:/ # sgdisk -i 3 /dev/vda
    Partition GUID code: D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149 (ONIE config)
    Partition unique GUID: E6729645-42C8-45F2-9581-6C6CBD47BB0D
    First sector: 268288 (at 131.0 MiB)
    Last sector: 276479 (at 135.0 MiB)
    Partition size: 8192 sectors (4.0 MiB)
==> Attribute flags: 0000000000000001
    Partition name: 'ONIE-CONFIG'
makefiles: add missing dependencies on DEV_SYSROOT_INIT_STAMP

Reviewed By: curt
Testing Done: make -j32 all

dmidecode.make and gptfdisk.make were missing dependencies on the development
sysroot.  This causes a build error for distclean trees.

Add the dependencies, fix the build error.

I also modified i2ctools.make to use the same order-only-prerequisite the other
targets use.

Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
Check if network interface is operationally "up" before configuration

This patch adds a check to the Ethernet management interface(s) for
"link up" before trying to configure the interface via DHCP.

On platforms with multiple management interfaces this check is a boot
time optimization.  In those cases where only one of the interfaces
has link, the boot process would pause waiting for the unconnected
interface DHCP operation to time out.  With this patch the boot
process does not pause, moving on after configuring the first
interface.

The check tries to verify the link up condition for 5 seconds before
declaring the link is down.

Reviewed By:  dustin

Testing Done:

Built images and verified the boot time 'link up' detection process.

- The process was verified for PowerPC and x86 platforms.

- For each platform the process was verified with port speeds 1000M,
  100M and 10M.