From 45d174663a1dff965b06e7778311ae1d29770bcb Mon Sep 17 00:00:00 2001 From: ntoorchi <52223501+ntoorchi@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:18:42 -0700 Subject: [PATCH] Enable P4RT at build time and disable at startup (#10499) #### Why I did it Currently at the Azure build system, the P4RT container is disabled by default at the build time. Here the goal is to include the P4RT container at the build time while disabling it at the runtime. The user can enable/disable the p4rt app through the config based on the preference. #### How I did it Changed the config in rules/config and init-cfg.json.j2 --- files/build_templates/init_cfg.json.j2 | 2 +- rules/config | 2 +- rules/docker-p4rt.mk | 5 +++-- rules/p4rt.mk | 3 ++- slave.mk | 16 ++++++++-------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 38bd7c2e43..3f0465be15 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -49,7 +49,7 @@ {%- 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 %} {%- if include_nat == "y" %}{% do features.append(("nat", "disabled", false, "enabled")) %}{% endif %} -{%- if include_p4rt == "y" %}{% do features.append(("p4rt", "enabled", false, "enabled")) %}{% endif %} +{%- if include_p4rt == "y" %}{% do features.append(("p4rt", "disabled", false, "enabled")) %}{% endif %} {%- if include_restapi == "y" %}{% do features.append(("restapi", "enabled", false, "enabled")) %}{% endif %} {%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %} {%- if include_macsec == "y" %}{% do features.append(("macsec", "disabled", false, "enabled")) %}{% endif %} diff --git a/rules/config b/rules/config index 888c470cde..0391abff36 100644 --- a/rules/config +++ b/rules/config @@ -151,7 +151,7 @@ INCLUDE_NAT = y INCLUDE_DHCP_RELAY = y # INCLUDE_P4RT - build docker-p4rt for P4RT support -INCLUDE_P4RT = n +INCLUDE_P4RT = y # ENABLE_AUTO_TECH_SUPPORT - Enable the configuration for event-driven techsupport & coredump mgmt feature ENABLE_AUTO_TECH_SUPPORT = y diff --git a/rules/docker-p4rt.mk b/rules/docker-p4rt.mk index 60e0d7d752..172346742c 100644 --- a/rules/docker-p4rt.mk +++ b/rules/docker-p4rt.mk @@ -19,12 +19,13 @@ $(DOCKER_P4RT)_PACKAGE_NAME = p4rt $(DOCKER_P4RT)_WARM_SHUTDOWN_BEFORE = swss $(DOCKER_P4RT)_FAST_SHUTDOWN_BEFORE = swss +# TODO: Enable P4RT DBG SONIC_DOCKER_IMAGES += $(DOCKER_P4RT) -SONIC_DOCKER_DBG_IMAGES += $(DOCKER_P4RT_DBG) +# SONIC_DOCKER_DBG_IMAGES += $(DOCKER_P4RT_DBG) ifeq ($(INCLUDE_P4RT), y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_P4RT) -SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_P4RT_DBG) +# SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_P4RT_DBG) endif $(DOCKER_P4RT)_CONTAINER_NAME = p4rt diff --git a/rules/p4rt.mk b/rules/p4rt.mk index a402bac002..9f19168795 100644 --- a/rules/p4rt.mk +++ b/rules/p4rt.mk @@ -17,4 +17,5 @@ export SONIC_P4RT SONIC_P4RT_DBG SONIC_P4RT_VERSION # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} # are archived into debug one image to facilitate debugging. -DBG_SRC_ARCHIVE += sonic-p4rt +# TODO: Enable P4RT DBG +# DBG_SRC_ARCHIVE += sonic-p4rt diff --git a/slave.mk b/slave.mk index 561f6b47db..ec484af944 100644 --- a/slave.mk +++ b/slave.mk @@ -178,10 +178,10 @@ endif # Pre-built Bazel is not available for armhf, so exclude P4RT # TODO(PINS): Remove when Bazel binaries are available for armhf ifeq ($(CONFIGURED_ARCH),armhf) - ifeq ($(INCLUDE_P4RT),y) - $(Q)echo "Disabling P4RT due to incompatible CPU architecture: $(CONFIGURED_ARCH)" - endif - override INCLUDE_P4RT = n +ifeq ($(INCLUDE_P4RT),y) +$(Q)echo "Disabling P4RT due to incompatible CPU architecture: $(CONFIGURED_ARCH)" +endif +override INCLUDE_P4RT = n endif ifeq ($(SONIC_INCLUDE_MACSEC),y) @@ -206,10 +206,10 @@ endif ifeq ($(ENABLE_ASAN),y) - ifneq ($(CONFIGURED_ARCH),amd64) - $(Q)echo "Disabling SWSS address sanitizer due to incompatible CPU architecture: $(CONFIGURED_ARCH)" - override ENABLE_ASAN = n - endif +ifneq ($(CONFIGURED_ARCH),amd64) +$(Q)echo "Disabling SWSS address sanitizer due to incompatible CPU architecture: $(CONFIGURED_ARCH)" +override ENABLE_ASAN = n +endif endif include $(RULES_PATH)/functions