[Mellanox] Use MAC from EEPROM for PortChannels and VLAN Interfaces (#1793)
* Use MAC from EEPROM for PortChannels Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Use MAC from EEPROM in DEVICE_METADATA Will affect MAC for VLAN interfaces Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Get MAC via decode-syseeprom Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * hw-management is now a service Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Add error handling for MAC fetch process Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
This commit is contained in:
parent
927c41f26c
commit
dadc17d9e6
@ -6,7 +6,12 @@ rm -rf $TEAMD_CONF_PATH
|
||||
mkdir -p $TEAMD_CONF_PATH
|
||||
|
||||
SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
|
||||
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
||||
|
||||
if [ "$SONIC_ASIC_TYPE" == "mellanox" ]; then
|
||||
MAC_ADDRESS=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)
|
||||
else
|
||||
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
||||
fi
|
||||
|
||||
# Align last byte
|
||||
if [ "$SONIC_ASIC_TYPE" == "mellanox" -o "$SONIC_ASIC_TYPE" == "centec" ]; then
|
||||
|
@ -162,7 +162,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostname-config.service
|
||||
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
# Copy updategraph script and service file
|
||||
sudo cp $IMAGE_CONFIGS/updategraph/updategraph.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/updategraph.service
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable updategraph.service
|
||||
sudo cp $IMAGE_CONFIGS/updategraph/updategraph $FILESYSTEM_ROOT/usr/bin/
|
||||
{% if enable_dhcp_graph_service == "y" %}
|
||||
|
@ -3,6 +3,10 @@ Description=Update minigraph and set configuration based on minigraph
|
||||
After=rc-local.service
|
||||
After=database.service
|
||||
Requires=database.service
|
||||
{% if sonic_asic_platform == 'mellanox' -%}
|
||||
Requires=hw-management.service
|
||||
{% endif -%}
|
||||
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
1
platform/mellanox/.gitignore
vendored
1
platform/mellanox/.gitignore
vendored
@ -3,6 +3,7 @@ mlnx-sai/*
|
||||
!mlnx-sai/Makefile
|
||||
hw-management/*
|
||||
!hw-management/Makefile
|
||||
!hw-management/*.patch
|
||||
mft/*
|
||||
!mft/Makefile
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
From 22fef644b1150677353ab0559828ea45a982d901 Mon Sep 17 00:00:00 2001
|
||||
From: Andriy Moroz <c_andriym@mellanox.com>
|
||||
Date: Wed, 11 Jul 2018 16:51:07 +0300
|
||||
Subject: [PATCH] Add systemd service config
|
||||
|
||||
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
|
||||
---
|
||||
debian/control | 2 +-
|
||||
debian/hw-management.service | 10 ++++++++++
|
||||
debian/rules | 2 +-
|
||||
3 files changed, 12 insertions(+), 2 deletions(-)
|
||||
create mode 100644 debian/hw-management.service
|
||||
|
||||
diff --git a/debian/control b/debian/control
|
||||
index 048cd61..7e3a545 100644
|
||||
--- a/debian/control
|
||||
+++ b/debian/control
|
||||
@@ -1,7 +1,7 @@
|
||||
Source: hw-management
|
||||
Priority: extra
|
||||
Maintainer: Adir Atias <adira@dev-r-vrt-128-008>
|
||||
-Build-Depends:
|
||||
+Build-Depends: dh-systemd
|
||||
Standards-Version:
|
||||
Section: libs
|
||||
Homepage: http://www.mellanox.com
|
||||
diff --git a/debian/hw-management.service b/debian/hw-management.service
|
||||
new file mode 100644
|
||||
index 0000000..d18916d
|
||||
--- /dev/null
|
||||
+++ b/debian/hw-management.service
|
||||
@@ -0,0 +1,10 @@
|
||||
+[Unit]
|
||||
+Description=Mellanox Hardware Management
|
||||
+
|
||||
+[Service]
|
||||
+Type=oneshot
|
||||
+EnvironmentFile=/host/machine.conf
|
||||
+ExecStart=/bin/bash -c "/usr/share/sonic/device/$onie_platform/hw-management start"
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=multi-user.target
|
||||
diff --git a/debian/rules b/debian/rules
|
||||
index fc38817..fba4150 100755
|
||||
--- a/debian/rules
|
||||
+++ b/debian/rules
|
||||
@@ -8,7 +8,7 @@ K_SRC ?= "/lib/modules/$(KVERSION)/build"
|
||||
pwd=$(shell pwd)
|
||||
|
||||
%:
|
||||
- dh $@
|
||||
+ dh $@ --with systemd
|
||||
|
||||
override_dh_auto_configure:
|
||||
|
||||
--
|
||||
1.9.1
|
||||
|
@ -10,6 +10,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
|
||||
|
||||
# build
|
||||
pushd hw-management
|
||||
git am ../*.patch
|
||||
sed "s~@SED_VERSION@~$(MLNX_HW_MANAGEMENT_VERSION)~" -i debian/changelog
|
||||
chmod +x ./debian/rules
|
||||
sudo ./debian/rules binary KVERSION=$(KVERSION)
|
||||
|
2
slave.mk
2
slave.mk
@ -494,6 +494,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
||||
j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount
|
||||
j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs
|
||||
|
||||
j2 files/build_templates/updategraph.service.j2 > updategraph.service
|
||||
|
||||
$(if $($*_DOCKERS),
|
||||
j2 files/build_templates/sonic_debian_extension.j2 > sonic_debian_extension.sh
|
||||
chmod +x sonic_debian_extension.sh,
|
||||
|
@ -41,12 +41,21 @@ def get_sonic_version_info():
|
||||
return data
|
||||
|
||||
def get_system_mac():
|
||||
proc = subprocess.Popen("ip link show eth0 | grep ether | awk '{print $2}'", shell=True, stdout=subprocess.PIPE)
|
||||
version_info = get_sonic_version_info()
|
||||
|
||||
if (version_info['asic_type'] == 'mellanox'):
|
||||
get_mac_cmd = "sudo decode-syseeprom -m"
|
||||
else:
|
||||
get_mac_cmd = "ip link show eth0 | grep ether | awk '{print $2}'"
|
||||
|
||||
proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(mac, err) = proc.communicate()
|
||||
if err:
|
||||
return None
|
||||
|
||||
mac = mac.strip()
|
||||
|
||||
# Align last byte of MAC if necessary
|
||||
version_info = get_sonic_version_info()
|
||||
if version_info and (version_info['asic_type'] == 'mellanox' or version_info['asic_type'] == 'centec'):
|
||||
last_byte = mac[-2:]
|
||||
aligned_last_byte = format(int(int(last_byte, 16) & 0b11000000), '02x')
|
||||
|
Loading…
Reference in New Issue
Block a user