Skip to content

Commit a4c41d2

Browse files
Update PoE implementation
Add build flag to disable PoE feature (enabled by default). Add cleanup of PoE database during config reload. Update poesyncd-platform.sh to disable the POESYNCD feature if the device is missing the poe_config.json file Fix poesyncd.service using the wrong file path. Signed-off-by: Serhiy Boiko <[email protected]> Change-Id: I58d836fd89d9d80a56d5b737fc996b2b5fe23399
1 parent 2fd3cc7 commit a4c41d2

File tree

10 files changed

+104
-28
lines changed

10 files changed

+104
-28
lines changed

Makefile.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
540540
INCLUDE_DHCP_RELAY=$(INCLUDE_DHCP_RELAY) \
541541
INCLUDE_DHCP_SERVER=$(INCLUDE_DHCP_SERVER) \
542542
INCLUDE_MACSEC=$(INCLUDE_MACSEC) \
543+
INCLUDE_POE=$(INCLUDE_POE) \
543544
INCLUDE_ICCPD=$(INCLUDE_ICCPD) \
544545
SONIC_INCLUDE_RESTAPI=$(INCLUDE_RESTAPI) \
545546
SONIC_INCLUDE_MUX=$(INCLUDE_MUX) \

files/build_templates/init_cfg.json.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
{% 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")) %}
7575
{%- if include_dhcp_server == "y" %}{% do features.append(("dhcp_server", "disabled", false, "enabled")) %}{% endif %}
7676
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
77-
{%- if sonic_asic_platform == "vs" %}{% do features.append(("poesyncd", "enabled", false, "enabled")) %}{% endif %}
77+
{%- if include_poe == "y" %}{% do features.append(("poesyncd", "enabled", false, "enabled")) %}{% endif %}
7878
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
7979
{%- if include_mgmt_framework == "y" %}{% do features.append(("mgmt-framework", "enabled", true, "enabled")) %}{% endif %}
8080
{%- 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 %}

files/build_templates/per_namespace/poesyncd.service.j2

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ BindsTo=sonic.target
88
After=sonic.target
99

1010
[Service]
11-
User={{ sonicadmin_user }}
11+
User=root
1212
Environment=sonic_asic_platform={{ sonic_asic_platform }}
1313
Environment=poesyncd_platform={{ docker_container_name }}
1414
ExecCondition=/usr/bin/{{docker_container_name}}-platform.sh
15-
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
16-
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
17-
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
18-
Restart=always
19-
RestartSec=30
15+
ExecStartPre=/usr/local/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
16+
ExecStart=/usr/local/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
17+
ExecStop=/usr/local/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
2018

2119
[Install]
2220
WantedBy=sonic.target

files/build_templates/sonic_debian_extension.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
10111011
sudo LANG=C cp $SCRIPTS_DIR/syncd_common.sh $FILESYSTEM_ROOT/usr/local/bin/syncd_common.sh
10121012
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd.sh $FILESYSTEM_ROOT/usr/local/bin/gbsyncd.sh
10131013
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd-platform.sh $FILESYSTEM_ROOT/usr/bin/gbsyncd-platform.sh
1014+
sudo LANG=C cp $SCRIPTS_DIR/poesyncd.sh $FILESYSTEM_ROOT/usr/local/bin/poesyncd.sh
10141015
sudo LANG=C cp $SCRIPTS_DIR/poesyncd-platform.sh $FILESYSTEM_ROOT/usr/bin/poesyncd-platform.sh
10151016
sudo LANG=C cp $SCRIPTS_DIR/bgp.sh $FILESYSTEM_ROOT/usr/local/bin/bgp.sh
10161017
sudo LANG=C cp $SCRIPTS_DIR/teamd.sh $FILESYSTEM_ROOT/usr/local/bin/teamd.sh

files/scripts/poesyncd-platform.sh

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
#!/bin/bash
2-
# Check the poesyncd platform defined on the device matching the service,
3-
# or otherwise skip starting the service
42

5-
SERVICE="$poesyncd_platform"
63
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
7-
DEVPATH="/usr/share/sonic/device"
8-
CONFIGFILE="${DEVPATH}/${PLATFORM}/poesyncd.ini"
4+
HWSKU=${HWSKU:-`sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku`}
5+
POECONFIG="/usr/share/sonic/device/${PLATFORM}/${HWSKU}/poe_config.json"
96

10-
# Skip checking the service for vs
11-
[ "$sonic_asic_platform" = vs ] && exit 0
12-
13-
if [ ! -f "$CONFIGFILE" ]; then
7+
if [ ! -f "$POECONFIG" ]; then
8+
sudo config feature state poesyncd disabled
149
exit 1
1510
fi
1611

17-
while IFS="=" read -r key value; do
18-
case "$key" in
19-
platform)
20-
if [[ "$value" = "$SERVICE"* ]]; then
21-
exit 0
22-
fi
23-
;;
24-
esac
25-
done < "$CONFIGFILE"
26-
27-
exit 1
12+
exit 0

files/scripts/poesyncd.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
. /usr/local/bin/syncd_common.sh
4+
5+
function startplatform() {
6+
7+
declare -A DbCliArray=([0]=$SONIC_GLOBAL_DB_CLI [1]=$SONIC_DB_CLI)
8+
for DB_CLI in "${DbCliArray[@]}"; do
9+
# Add poesyncd to FEATURE table, if not in. It did have same config as syncd.
10+
if [ -z $($DB_CLI CONFIG_DB HGET 'FEATURE|poesyncd' state) ]; then
11+
local CMD="local r=redis.call('DUMP', KEYS[1]); redis.call('RESTORE', KEYS[2], 0, r)"
12+
$DB_CLI CONFIG_DB EVAL "$CMD" 2 'FEATURE|syncd' 'FEATURE|poesyncd'
13+
$DB_CLI CONFIG_DB EVAL "$CMD" 2 'SYSLOG_CONFIG_FEATURE|syncd' 'SYSLOG_CONFIG_FEATURE|poesyncd'
14+
fi
15+
done
16+
}
17+
18+
function waitplatform() {
19+
:
20+
}
21+
22+
function stopplatform1() {
23+
if ! docker top poesyncd$DEV | grep -q /usr/bin/syncd; then
24+
debug "syncd process in container poesyncd$DEV is not running"
25+
return
26+
fi
27+
28+
# Invoke platform specific pre shutdown routine.
29+
PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
30+
PLATFORM_PRE_SHUTDOWN="/usr/share/sonic/device/$PLATFORM/plugins/poesyncd_request_pre_shutdown"
31+
[ -f $PLATFORM_PRE_SHUTDOWN ] && \
32+
/usr/bin/docker exec -i poesyncd$DEV /usr/share/sonic/platform/plugins/poesyncd_request_pre_shutdown --${TYPE}
33+
34+
debug "${TYPE} shutdown syncd process in container poesyncd$DEV ..."
35+
/usr/bin/docker exec -i poesyncd$DEV /usr/bin/syncd_request_shutdown -g 1 -x /usr/share/sonic/hwsku/context_config.json --${TYPE}
36+
37+
# wait until syncd quits gracefully or force syncd to exit after
38+
# waiting for 20 seconds
39+
start_in_secs=${SECONDS}
40+
end_in_secs=${SECONDS}
41+
timer_threshold=20
42+
while docker top poesyncd$DEV | grep -q /usr/bin/syncd \
43+
&& [[ $((end_in_secs - start_in_secs)) -le $timer_threshold ]]; do
44+
sleep 0.1
45+
end_in_secs=${SECONDS}
46+
done
47+
48+
if [[ $((end_in_secs - start_in_secs)) -gt $timer_threshold ]]; then
49+
debug "syncd process in container poesyncd$DEV did not exit gracefully"
50+
fi
51+
52+
/usr/bin/docker exec -i poesyncd$DEV /bin/sync
53+
debug "Finished ${TYPE} shutdown syncd process in container poesyncd$DEV ..."
54+
}
55+
56+
function stopplatform2() {
57+
:
58+
}
59+
60+
OP=$1
61+
DEV=$2
62+
63+
SERVICE="$poesyncd_platform"
64+
PEER="swss"
65+
DEBUGLOG="/tmp/swss-$SERVICE-debug$DEV.log"
66+
LOCKFILE="/tmp/swss-$SERVICE-lock$DEV"
67+
NAMESPACE_PREFIX="asic"
68+
SONIC_GLOBAL_DB_CLI="sonic-db-cli"
69+
SONIC_DB_CLI="sonic-db-cli"
70+
if [ "$DEV" ]; then
71+
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
72+
SONIC_DB_CLI="sonic-db-cli -n $NET_NS"
73+
fi
74+
75+
case "$1" in
76+
start|wait|stop)
77+
$1
78+
;;
79+
*)
80+
echo "Usage: $0 {start|wait|stop}"
81+
exit 1
82+
;;
83+
esac

files/scripts/swss.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ start() {
329329
$SONIC_DB_CLI GB_ASIC_DB FLUSHDB
330330
$SONIC_DB_CLI GB_COUNTERS_DB FLUSHDB
331331
$SONIC_DB_CLI RESTAPI_DB FLUSHDB
332-
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*', 'ADVERTISE_NETWORK_TABLE*', 'VXLAN_TUNNEL_TABLE*', 'VNET_ROUTE*', 'MACSEC_PORT_TABLE*', 'MACSEC_INGRESS_SA_TABLE*', 'MACSEC_EGRESS_SA_TABLE*', 'MACSEC_INGRESS_SC_TABLE*', 'MACSEC_EGRESS_SC_TABLE*', 'VRF_OBJECT_TABLE*', 'VNET_MONITOR_TABLE*', 'BFD_SESSION_TABLE*', 'SYSTEM_NEIGH_TABLE*', 'FABRIC_PORT_TABLE*', 'TUNNEL_DECAP_TABLE*', 'TUNNEL_DECAP_TERM_TABLE*'"
332+
$SONIC_DB_CLI POE_ASIC_DB FLUSHDB
333+
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*', 'ADVERTISE_NETWORK_TABLE*', 'VXLAN_TUNNEL_TABLE*', 'VNET_ROUTE*', 'MACSEC_PORT_TABLE*', 'MACSEC_INGRESS_SA_TABLE*', 'MACSEC_EGRESS_SA_TABLE*', 'MACSEC_INGRESS_SC_TABLE*', 'MACSEC_EGRESS_SC_TABLE*', 'VRF_OBJECT_TABLE*', 'VNET_MONITOR_TABLE*', 'BFD_SESSION_TABLE*', 'SYSTEM_NEIGH_TABLE*', 'FABRIC_PORT_TABLE*', 'TUNNEL_DECAP_TABLE*', 'TUNNEL_DECAP_TERM_TABLE*', 'POE_DEVICE_TABLE*', 'POE_PSE_TABLE*', 'POE_PORT_TABLE*'"
333334
$SONIC_DB_CLI APPL_STATE_DB FLUSHDB
334335
clean_up_chassis_db_tables
335336
rm -rf /tmp/cache

platform/template/docker-poesyncd-base.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ $(DOCKER_POESYNCD_BASE)_DBG_DEPENDS += $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DE
1515

1616
$(DOCKER_POESYNCD_BASE)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)
1717

18+
ifeq ($(INCLUDE_POE), y)
1819
SONIC_DOCKER_IMAGES += $(DOCKER_POESYNCD_BASE)
1920
SONIC_BOOKWORM_DOCKERS += $(DOCKER_POESYNCD_BASE)
2021
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_POESYNCD_BASE)
2122

2223
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_POESYNCD_BASE_DBG)
2324
SONIC_BOOKWORM_DBG_DOCKERS += $(DOCKER_POESYNCD_BASE_DBG)
2425
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_POESYNCD_BASE_DBG)
26+
endif
2527

2628
$(DOCKER_POESYNCD_BASE)_CONTAINER_NAME = poesyncd
2729
$(DOCKER_POESYNCD_BASE)_RUN_OPT += --privileged -t

rules/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ INCLUDE_MACSEC = y
182182
# INCLUDE_GBSYNCD - build docker-gbsyncd-* for gearbox support
183183
INCLUDE_GBSYNCD ?= y
184184

185+
# INCLUDE_POE - build docker-poesyncd-* for PoE support
186+
INCLUDE_POE = y
187+
185188
# INCLUDE_TEAMD - build docker-teamd for LAG protocol support
186189
INCLUDE_TEAMD ?= y
187190

slave.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ $(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)")
456456
$(info "INCLUDE_KUBERNETES_MASTER" : "$(INCLUDE_KUBERNETES_MASTER)")
457457
$(info "INCLUDE_MACSEC" : "$(INCLUDE_MACSEC)")
458458
$(info "INCLUDE_MUX" : "$(INCLUDE_MUX)")
459+
$(info "INCLUDE_POE" : "$(INCLUDE_POE)")
459460
$(info "INCLUDE_TEAMD" : "$(INCLUDE_TEAMD)")
460461
$(info "INCLUDE_ROUTER_ADVERTISER" : "$(INCLUDE_ROUTER_ADVERTISER)")
461462
$(info "INCLUDE_BOOTCHART : "$(INCLUDE_BOOTCHART)")
@@ -1499,6 +1500,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
14991500
export include_bootchart="$(INCLUDE_BOOTCHART)"
15001501
export enable_bootchart="$(ENABLE_BOOTCHART)"
15011502
export enable_multidb="$(ENABLE_MULTIDB)"
1503+
export include_poe="$(INCLUDE_POE)"
15021504
$(foreach docker, $($*_DOCKERS),\
15031505
export docker_image="$(docker)"
15041506
export docker_image_name="$(basename $(docker))"

0 commit comments

Comments
 (0)