Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gbsyncd] Add feature gbsyncd with state 'disabled' in init_cfg.json #17575

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platform=gbsyncd-vs
2 changes: 1 addition & 1 deletion files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{%- if include_teamd == "y" %}{% do features.append(("teamd", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}", false, "enabled")) %}{% endif %}
{% do features.append(("dhcp_relay", "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['ToRRouter', 'EPMS', 'MgmtTsToR', 'MgmtToRRouter', 'BmcMgmtToRRouter']) %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}
{%- if include_dhcp_server == "y" %}{% do features.append(("dhcp_server", "disabled", false, "enabled")) %}{% endif %}
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
{%- if include_gbsyncd == "y" %}{% do features.append(("gbsyncd", "disabled", false, "enabled")) %}{% endif %}
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
{%- if include_mgmt_framework == "y" %}{% do features.append(("mgmt-framework", "enabled", true, "enabled")) %}{% endif %}
{%- if include_mux == "y" %}{% do features.append(("mux", "{% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %}enabled{% else %}always_disabled{% endif %}", false, "enabled")) %}{% endif %}
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/gbsyncd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Before=ntp-config.service
User=root
Environment=sonic_asic_platform={{ sonic_asic_platform }}
Environment=gbsyncd_platform={{ docker_container_name }}
ExecCondition=/usr/bin/gbsyncd-platform.sh
ExecStartPre=/usr/local/bin/gbsyncd.sh start{% if multi_instance == 'true' %} %i{% endif %}
ExecStart=/usr/local/bin/gbsyncd.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/local/bin/gbsyncd.sh stop{% if multi_instance == 'true' %} %i{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT_USR
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
sudo mkdir -p $FILESYSTEM_ROOT/etc/config-setup
sudo cp $IMAGE_CONFIGS/config-setup/config-setup.conf $FILESYSTEM_ROOT/etc/config-setup/config-setup.conf
sudo cp -R $IMAGE_CONFIGS/config-setup/factory-default-hooks.d $FILESYSTEM_ROOT/etc/config-setup/
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service

Expand Down Expand Up @@ -909,7 +910,6 @@ sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
sudo LANG=C cp $SCRIPTS_DIR/syncd_common.sh $FILESYSTEM_ROOT/usr/local/bin/syncd_common.sh
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd.sh $FILESYSTEM_ROOT/usr/local/bin/gbsyncd.sh
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd-platform.sh $FILESYSTEM_ROOT/usr/bin/gbsyncd-platform.sh
sudo LANG=C cp $SCRIPTS_DIR/bgp.sh $FILESYSTEM_ROOT/usr/local/bin/bgp.sh
sudo LANG=C cp $SCRIPTS_DIR/teamd.sh $FILESYSTEM_ROOT/usr/local/bin/teamd.sh
sudo LANG=C cp $SCRIPTS_DIR/lldp.sh $FILESYSTEM_ROOT/usr/local/bin/lldp.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# factory-default-hook: gbsyncd
#
# By default, gbsyncd service is disabled. If the platform has gearbox chip,
# enable gbsyncd service in init_cfg.json.

# PLATFORM and HW_KEY must be defined, which are from config-setup
[ -z $PLATFORM ] && exit 1
[ -z $HW_KEY ] && exit 1

DEVPATH="/usr/share/sonic/device"
GBSYNCDINI="${DEVPATH}/${PLATFORM}/gbsyncd.ini"

enable_feature_gbsyncd()
{
local init_cfg="/etc/sonic/init_cfg.json"
local tmp_init_cfg=$(mktemp)

if ! jq -e '.FEATURE.gbsyncd' $init_cfg >/dev/null; then
return
fi

echo "Enable feature gbsyncd in factory-default-hook"
jq --indent 4 '.FEATURE.gbsyncd.state = "enabled"' $init_cfg > $tmp_init_cfg
mv $tmp_init_cfg $init_cfg
systemctl unmask gbsyncd.service
}

if [ ! -f "$GBSYNCDINI" ]; then
GBSYNCDINI="${DEVPATH}/${PLATFORM}/${HW_KEY}/gbsyncd.ini"
fi

if [ -f "$GBSYNCDINI" ]; then
while IFS="=" read -r key value; do
case "$key" in
platform)
if [[ "$value" = gbsyncd* ]]; then
enable_feature_gbsyncd
break
fi
;;
esac
done < "$GBSYNCDINI"
fi

27 changes: 0 additions & 27 deletions files/scripts/gbsyncd-platform.sh

This file was deleted.

11 changes: 1 addition & 10 deletions files/scripts/gbsyncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
. /usr/local/bin/syncd_common.sh

function startplatform() {

declare -A DbCliArray=([0]=$SONIC_GLOBAL_DB_CLI [1]=$SONIC_DB_CLI)
for DB_CLI in "${DbCliArray[@]}"; do
# Add gbsyncd to FEATURE table, if not in. It did have same config as syncd.
if [ -z $($DB_CLI CONFIG_DB HGET 'FEATURE|gbsyncd' state) ]; then
local CMD="local r=redis.call('DUMP', KEYS[1]); redis.call('RESTORE', KEYS[2], 0, r)"
$DB_CLI CONFIG_DB EVAL "$CMD" 2 'FEATURE|syncd' 'FEATURE|gbsyncd'
$DB_CLI CONFIG_DB EVAL "$CMD" 2 'SYSLOG_CONFIG_FEATURE|syncd' 'SYSLOG_CONFIG_FEATURE|gbsyncd'
fi
done
:
}

function waitplatform() {
Expand Down
4 changes: 4 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ ENABLE_NATIVE_WRITE = y
INCLUDE_MACSEC = y

# INCLUDE_GBSYNCD - build docker-gbsyncd-* for gearbox support
ifneq ($(filter broadcom vs,$(CONFIGURED_PLATFORM)),)
INCLUDE_GBSYNCD ?= y
else
INCLUDE_GBSYNCD ?= n
endif

# INCLUDE_TEAMD - build docker-teamd for LAG protocol support
INCLUDE_TEAMD ?= y
Expand Down
2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ $(info "INCLUDE_DHCP_SERVER" : "$(INCLUDE_DHCP_SERVER)")
$(info "INCLUDE_P4RT" : "$(INCLUDE_P4RT)")
$(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)")
$(info "INCLUDE_KUBERNETES_MASTER" : "$(INCLUDE_KUBERNETES_MASTER)")
$(info "INCLUDE_GBSYNCD" : "$(INCLUDE_GBSYNCD)")
$(info "INCLUDE_MACSEC" : "$(INCLUDE_MACSEC)")
$(info "INCLUDE_MUX" : "$(INCLUDE_MUX)")
$(info "INCLUDE_TEAMD" : "$(INCLUDE_TEAMD)")
Expand Down Expand Up @@ -1418,6 +1419,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export include_sflow="$(INCLUDE_SFLOW)"
export enable_auto_tech_support="$(ENABLE_AUTO_TECH_SUPPORT)"
export enable_asan="$(ENABLE_ASAN)"
export include_gbsyncd="$(INCLUDE_GBSYNCD)"
export include_macsec="$(INCLUDE_MACSEC)"
export include_dhcp_server="$(INCLUDE_DHCP_SERVER)"
export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)"
Expand Down