e010d83fc3
**- Why I did it** To support dynamic buffer calculation. This PR also depends on the following PRs for sub modules - [sonic-swss: [buffermgr/bufferorch] Support dynamic buffer calculation #1338](https://github.com/Azure/sonic-swss/pull/1338) - [sonic-swss-common: Dynamic buffer calculation #361](https://github.com/Azure/sonic-swss-common/pull/361) - [sonic-utilities: Support dynamic buffer calculation #973](https://github.com/Azure/sonic-utilities/pull/973) **- How I did it** 1. Introduce field `buffer_model` in `DEVICE_METADATA|localhost` to represent which buffer model is running in the system currently: - `dynamic` for the dynamic buffer calculation model - `traditional` for the traditional model in which the `pg_profile_lookup.ini` is used 2. Add the tables required for the feature: - ASIC_TABLE in platform/\<vendor\>/asic_table.j2 - PERIPHERAL_TABLE in platform/\<vendor\>/peripheral_table.j2 - PORT_PERIPHERAL_TABLE on a per-platform basis in device/\<vendor\>/\<platform\>/port_peripheral_config.j2 for each platform with gearbox installed. - DEFAULT_LOSSLESS_BUFFER_PARAMETER and LOSSLESS_TRAFFIC_PATTERN in files/build_templates/buffers_config.j2 - Add lossless PGs (3-4) for each port in files/build_templates/buffers_config.j2 3. Copy the newly introduced j2 files into the image and rendering them when the system starts 4. Update the CLI options for buffermgrd so that it can start with dynamic mode 5. Fetches the ASIC vendor name in orchagent: - fetch the vendor name when creates the docker and pass it as a docker environment variable - `buffermgrd` can use this passed-in variable 6. Clear buffer related tables from STATE_DB when swss docker starts 7. Update the src/sonic-config-engine/tests/sample_output/buffers-dell6100.json according to the buffer_config.j2 8. Remove buffer pool sizes for ingress pools and egress_lossy_pool Update the buffer settings for dynamic buffer calculation
141 lines
4.5 KiB
Bash
Executable File
141 lines
4.5 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
# Generate configuration
|
|
|
|
# NOTE: 'PLATFORM' and 'HWSKU' environment variables are set
|
|
# in the Dockerfile so that they persist for the life of the container
|
|
|
|
ln -sf /usr/share/sonic/device/$PLATFORM /usr/share/sonic/platform
|
|
ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku
|
|
|
|
pushd /usr/share/sonic/hwsku
|
|
|
|
# filter available front panel ports in lanemap.ini
|
|
[ -f lanemap.ini.orig ] || cp lanemap.ini lanemap.ini.orig
|
|
for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do
|
|
grep ^$p: lanemap.ini.orig
|
|
done > lanemap.ini
|
|
|
|
# filter available sonic front panel ports in port_config.ini
|
|
[ -f port_config.ini.orig ] || cp port_config.ini port_config.ini.orig
|
|
grep ^# port_config.ini.orig > port_config.ini
|
|
for lanes in $(awk -F ':' '{print $2}' lanemap.ini); do
|
|
grep -E "\s$lanes\s" port_config.ini.orig
|
|
done >> port_config.ini
|
|
|
|
popd
|
|
|
|
[ -d /etc/sonic ] || mkdir -p /etc/sonic
|
|
|
|
if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then
|
|
CHASS_CFG="-j /usr/share/sonic/virtual_chassis/default_config.json"
|
|
fi
|
|
|
|
SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
|
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "buffer_model": "traditional"}}}' $CHASS_CFG --print-data > /etc/sonic/init_cfg.json
|
|
|
|
if [ -f /etc/sonic/config_db.json ]; then
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json
|
|
mv /tmp/config_db.json /etc/sonic/config_db.json
|
|
else
|
|
# generate and merge buffers configuration into config file
|
|
sonic-cfggen -k $HWSKU -p /usr/share/sonic/device/$PLATFORM/platform.json -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json -t /usr/share/sonic/hwsku/qos.json.j2 > /tmp/qos.json
|
|
sonic-cfggen -p /usr/share/sonic/device/$PLATFORM/platform.json -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
|
|
fi
|
|
sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json
|
|
|
|
mkdir -p /etc/swss/config.d/
|
|
|
|
rm -f /var/run/rsyslogd.pid
|
|
|
|
supervisorctl start rsyslogd
|
|
|
|
supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf"
|
|
chassisdb_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json"
|
|
chassisdb_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json"
|
|
host_template="/usr/share/sonic/templates/hostname.j2"
|
|
db_cfg_file="/var/run/redis/sonic-db/database_config.json"
|
|
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
|
|
|
|
if [ -r "$chassisdb_cfg_file" ]; then
|
|
echo $(sonic-cfggen -j $chassisdb_cfg_file -t $host_template) >> /etc/hosts
|
|
else
|
|
chassisdb_cfg_file="$chassisdb_cfg_file_default"
|
|
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
|
fi
|
|
|
|
mkdir -p /var/run/redis/sonic-db
|
|
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/
|
|
|
|
supervisorctl start redis-server
|
|
|
|
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file`
|
|
if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then
|
|
supervisorctl start redis-chassis
|
|
fi
|
|
|
|
conn_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.connect_to_chassis_db -y $chassisdb_cfg_file`
|
|
if [ "$start_chassis_db" != "1" ] && [ "$conn_chassis_db" != "1" ]; then
|
|
cp $db_cfg_file $db_cfg_file_tmp
|
|
update_chassisdb_config -j $db_cfg_file_tmp -d
|
|
cp $db_cfg_file_tmp $db_cfg_file
|
|
fi
|
|
|
|
if [ "$conn_chassis_db" == "1" ]; then
|
|
if [ -f /usr/share/sonic/virtual_chassis/coreportindexmap.ini ]; then
|
|
cp /usr/share/sonic/virtual_chassis/coreportindexmap.ini /usr/share/sonic/hwsku/
|
|
fi
|
|
fi
|
|
|
|
/usr/bin/configdb-load.sh
|
|
|
|
supervisorctl start syncd
|
|
|
|
supervisorctl start portsyncd
|
|
|
|
supervisorctl start orchagent
|
|
|
|
supervisorctl start coppmgrd
|
|
|
|
supervisorctl start neighsyncd
|
|
|
|
supervisorctl start teamsyncd
|
|
|
|
supervisorctl start fpmsyncd
|
|
|
|
supervisorctl start teammgrd
|
|
|
|
supervisorctl start vrfmgrd
|
|
|
|
supervisorctl start portmgrd
|
|
|
|
supervisorctl start intfmgrd
|
|
|
|
supervisorctl start vlanmgrd
|
|
|
|
supervisorctl start zebra
|
|
|
|
supervisorctl start staticd
|
|
|
|
supervisorctl start buffermgrd
|
|
|
|
supervisorctl start nbrmgrd
|
|
|
|
supervisorctl start vxlanmgrd
|
|
|
|
supervisorctl start sflowmgrd
|
|
|
|
supervisorctl start natmgrd
|
|
|
|
supervisorctl start natsyncd
|
|
|
|
# Start arp_update when VLAN exists
|
|
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
|
|
if [ "$VLAN" != "" ]; then
|
|
supervisorctl start arp_update
|
|
fi
|