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

[docker-sonic-vs]: More changes to support DPU-2P HWKSU #15695

Merged
merged 4 commits into from
Jul 11, 2023
Merged
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
10 changes: 10 additions & 0 deletions device/virtual/x86_64-kvm_x86_64-r0/DPU-2P/hwsku.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"interfaces": {
"Ethernet0": {
"default_brkout_mode": "1x100G"
},
"Ethernet4": {
"default_brkout_mode": "1x100G"
}
}
}
3 changes: 3 additions & 0 deletions device/virtual/x86_64-kvm_x86_64-r0/DPU-2P/port_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# name lanes alias index
Ethernet0 0,1,2,3 etp1 1
Ethernet4 4,5,6,7 etp2 2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_NPU
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_DPU_SIMU_2P
SAI_VS_HOSTIF_USE_TAP_DEVICE=true
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
SAI_VS_CORE_PORT_INDEX_MAP_FILE=/usr/share/sonic/hwsku/coreportindexmap.ini
Expand Down
2 changes: 1 addition & 1 deletion platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ COPY ["zero_profiles.json", "/etc/sonic"]
COPY ["buffermgrd.sh", "/usr/bin/"]

COPY ["platform.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/"]
COPY ["platform-npu-2p.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/"]
COPY ["platform-dpu-2p.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/"]
COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/Force10-S6000/"]
COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/brcm_gearbox_vs/"]
COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/Mellanox-SN2700/"]
Expand Down
12 changes: 8 additions & 4 deletions platform/vs/docker-sonic-vs/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
"DEVICE_METADATA": {
"localhost": {
"mac": "{{ system_mac }}",
"switch_type": "{{ switch_type }}",
"buffer_model": "traditional"
}
},
{% set features = ["swss", "bgp", "teamd", "nat", "database", "lldp", "dhcp_relay", "macsec"] %}
{% if switch_type != "dpu" %}
{% set features = ({"swss": "enabled", "bgp": "enabled", "teamd": "enabled", "nat": "enabled", "database": "enabled", "lldp": "enabled", "dhcp_relay": "enabled", "macsec": "enabled"}) %}
{% else %}
{% set features = ({"swss": "enabled", "bgp": "enabled", "teamd": "disabled", "nat": "disabled", "database": "enabled", "lldp": "enabled", "dhcp_relay": "disabled", "macsec": "disabled"}) %}
{% endif %}
"FEATURE": {
{% for feature in features %}
{% for feature, state in features.items() %}
"{{ feature }}": {
"state": "enabled"
"state": "{{ state }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
}
}

17 changes: 11 additions & 6 deletions platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
ln -sf /usr/share/sonic/device/$PLATFORM /usr/share/sonic/platform
ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku

SWITCH_TYPE=switch
PLATFORM_CONF=platform.json
if [[ $HWSKU == "NPU-2P" ]]; then
PLATFORM_CONF=platform-npu-2p.json
if [[ $HWSKU == "DPU-2P" ]]; then
SWITCH_TYPE=dpu
prabhataravind marked this conversation as resolved.
Show resolved Hide resolved
PLATFORM_CONF=platform-dpu-2p.json
fi

pushd /usr/share/sonic/hwsku
Expand Down Expand Up @@ -38,7 +40,7 @@ mkdir -p /var/run/redis/sonic-db
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/

SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\"}" > /etc/sonic/init_cfg.json
sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\", \"switch_type\": \"$SWITCH_TYPE\"}" > /etc/sonic/init_cfg.json

if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then
sonic-cfggen -j /etc/sonic/init_cfg.json -j /usr/share/sonic/virtual_chassis/default_config.json --print-data > /tmp/init_cfg.json
Expand All @@ -52,22 +54,25 @@ else
# generate and merge buffers configuration into config file
if [ -f /usr/share/sonic/hwsku/buffers.json.j2 ]; then
sonic-cfggen -k $HWSKU -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json
buffers_cmd="-j /tmp/buffers.json"
fi
if [ -f /usr/share/sonic/hwsku/qos.json.j2 ]; then
sonic-cfggen -j /etc/sonic/init_cfg.json -t /usr/share/sonic/hwsku/qos.json.j2 > /tmp/qos.json
qos_cmd="-j /tmp/qos.json"
prabhataravind marked this conversation as resolved.
Show resolved Hide resolved
fi

sonic-cfggen -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -k $HWSKU --print-data > /tmp/ports.json
# change admin_status from up to down; Test cases dependent
sed -i "s/up/down/g" /tmp/ports.json
sonic-cfggen -j /etc/sonic/init_cfg.json -j /tmp/buffers.json -j /tmp/qos.json -j /tmp/ports.json --print-data > /etc/sonic/config_db.json
sonic-cfggen -j /etc/sonic/init_cfg.json $buffers_cmd $qos_cmd -j /tmp/ports.json --print-data > /etc/sonic/config_db.json
fi

sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json

if [ "$HWSKU" == "Mellanox-SN2700" ]; then
cp /usr/share/sonic/hwsku/sai_mlnx.profile /usr/share/sonic/hwsku/sai.profile
elif [ "$HWSKU" == "NPU" ]; then
cp /usr/share/sonic/hwsku/sai_npu.profile /usr/share/sonic/hwsku/sai.profile
elif [ "$HWSKU" == "DPU-2P" ]; then
cp /usr/share/sonic/hwsku/sai_dpu_2p.profile /usr/share/sonic/hwsku/sai.profile
fi

mkdir -p /etc/swss/config.d/
Expand Down