Skip to content

Commit

Permalink
Merge branch 'master' into SN5640-utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
noaOrMlnx authored Sep 11, 2024
2 parents 4ea392f + 8fa076d commit 0a96ad8
Show file tree
Hide file tree
Showing 66 changed files with 5,727 additions and 2,088 deletions.
8 changes: 4 additions & 4 deletions config/chassis_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def fabric_module_set_admin_status(db, chassis_module_name, state):
if state == "down":
for asic in asic_list:
click.echo("Stop swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl stop swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'stop', 'swss@{}.service'.format(asic)])

is_active = subprocess.call(["systemctl", "is-active", "--quiet", "swss@{}.service".format(asic)])

Expand All @@ -89,13 +89,13 @@ def fabric_module_set_admin_status(db, chassis_module_name, state):
# without bring down the hardware
for asic in asic_list:
# To address systemd service restart limit by resetting the count
clicommon.run_command('sudo systemctl reset-failed swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'reset-failed', 'swss@{}.service'.format(asic)])
click.echo("Start swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl start swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'start', 'swss@{}.service'.format(asic)])
elif state == "up":
for asic in asic_list:
click.echo("Start swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl start swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'start', 'swss@{}.service'.format(asic)])

#
# 'shutdown' subcommand ('config chassis_modules shutdown ...')
Expand Down
101 changes: 86 additions & 15 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import itertools
import copy
import tempfile
import sonic_yang

from jsonpatch import JsonPatchConflict
from jsonpointer import JsonPointerException
Expand Down Expand Up @@ -59,7 +60,7 @@
from . import vlan
from . import vxlan
from . import plugins
from .config_mgmt import ConfigMgmtDPB, ConfigMgmt
from .config_mgmt import ConfigMgmtDPB, ConfigMgmt, YANG_DIR
from . import mclag
from . import syslog
from . import switchport
Expand Down Expand Up @@ -1994,8 +1995,22 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
fg='magenta')
raise click.Abort()

# Dependency check golden config json
config_to_check = read_json_file(golden_config_path)
if multi_asic.is_multi_asic():
# Multiasic has not 100% fully validated. Thus pass here.
pass
else:
sy = sonic_yang.SonicYang(YANG_DIR)
sy.loadYangModel()
try:
sy.loadData(configdbJson=config_to_check)
sy.validate_data_tree()
except sonic_yang.SonicYangException as e:
click.secho("{} fails YANG validation! Error: {}".format(golden_config_path, str(e)),
fg='magenta')
raise click.Abort()

# Dependency check golden config json
if multi_asic.is_multi_asic():
host_config = config_to_check.get('localhost', {})
else:
Expand Down Expand Up @@ -2322,7 +2337,7 @@ def aaa_table_hard_dependency_check(config_json):
tacacs_enable = "tacacs+" in aaa_authentication_login.split(",")
tacplus_passkey = TACPLUS_TABLE.get("global", {}).get("passkey", "")
if tacacs_enable and len(tacplus_passkey) == 0:
click.secho("Authentication with 'tacacs+' is not allowed when passkey not exits.", fg="magenta")
click.secho("Authentication with 'tacacs+' is not allowed when passkey not exists.", fg="magenta")
sys.exit(1)


Expand Down Expand Up @@ -2376,6 +2391,20 @@ def synchronous_mode(sync_mode):
config reload -y \n
Option 2. systemctl restart swss""" % sync_mode)


#
# 'suppress-fib-pending' command ('config suppress-fib-pending ...')
#
@config.command('suppress-fib-pending')
@click.argument('state', metavar='<enabled|disabled>', required=True, type=click.Choice(['enabled', 'disabled']))
@clicommon.pass_db
def suppress_pending_fib(db, state):
''' Enable or disable pending FIB suppression. Once enabled,
BGP will not advertise routes that are not yet installed in the hardware '''

config_db = db.cfgdb
config_db.mod_entry('DEVICE_METADATA', 'localhost', {"suppress-fib-pending": state})

#
# 'yang_config_validation' command ('config yang_config_validation ...')
#
Expand Down Expand Up @@ -3127,7 +3156,7 @@ def reload(ctx, no_dynamic_buffer, no_delay, dry_run, json_data, ports, verbose)

_, hwsku_path = device_info.get_paths_to_platform_and_hwsku_dirs()
sonic_version_file = device_info.get_sonic_version_file()
from_db = ['-d', '--write-to-db']
from_db = ['-d']
if dry_run:
from_db = ['--additional-data'] + [str(json_data)] if json_data else []

Expand Down Expand Up @@ -3173,11 +3202,27 @@ def reload(ctx, no_dynamic_buffer, no_delay, dry_run, json_data, ports, verbose)
)
if os.path.isfile(qos_template_file):
cmd_ns = [] if ns is DEFAULT_NAMESPACE else ['-n', str(ns)]
fname = "{}{}".format(dry_run, asic_id_suffix) if dry_run else "config-db"
command = [SONIC_CFGGEN_PATH] + cmd_ns + from_db + ['-t', '{},{}'.format(buffer_template_file, fname), '-t', '{},{}'.format(qos_template_file, fname), '-y', sonic_version_file]
# Apply the configurations only when both buffer and qos
# configuration files are present
buffer_fname = "/tmp/cfg_buffer{}.json".format(asic_id_suffix)
qos_fname = "/tmp/cfg_qos{}.json".format(asic_id_suffix)

command = [SONIC_CFGGEN_PATH] + cmd_ns + from_db + [
'-t', '{},{}'.format(buffer_template_file, buffer_fname),
'-t', '{},{}'.format(qos_template_file, qos_fname),
'-y', sonic_version_file
]
clicommon.run_command(command, display_cmd=True)

command = [SONIC_CFGGEN_PATH] + cmd_ns + ["-j", buffer_fname, "-j", qos_fname]
if dry_run:
out, rc = clicommon.run_command(command + ["--print-data"], display_cmd=True, return_cmd=True)
if rc != 0:
# clicommon.run_command does this by default when rc != 0 and return_cmd=False
sys.exit(rc)
with open("{}{}".format(dry_run, asic_id_suffix), 'w') as f:
json.dump(json.loads(out), f, sort_keys=True, indent=4)
else:
clicommon.run_command(command + ["--write-to-db"], display_cmd=True)

else:
click.secho("QoS definition template not found at {}".format(
qos_template_file
Expand Down Expand Up @@ -6399,7 +6444,8 @@ def remove_reasons(counter_name, reasons, verbose):
@click.option('-ydrop', metavar='<yellow drop probability>', type=click.IntRange(0, 100), help="Set yellow drop probability")
@click.option('-gdrop', metavar='<green drop probability>', type=click.IntRange(0, 100), help="Set green drop probability")
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def ecn(profile, rmax, rmin, ymax, ymin, gmax, gmin, rdrop, ydrop, gdrop, verbose):
@multi_asic_util.multi_asic_click_option_namespace
def ecn(profile, rmax, rmin, ymax, ymin, gmax, gmin, rdrop, ydrop, gdrop, verbose, namespace):
"""ECN-related configuration tasks"""
log.log_info("'ecn -profile {}' executing...".format(profile))
command = ['ecnconfig', '-p', str(profile)]
Expand All @@ -6413,6 +6459,8 @@ def ecn(profile, rmax, rmin, ymax, ymin, gmax, gmin, rdrop, ydrop, gdrop, verbos
if ydrop is not None: command += ['-ydrop', str(ydrop)]
if gdrop is not None: command += ['-gdrop', str(gdrop)]
if verbose: command += ["-vv"]
if namespace is not None:
command += ['-n', str(namespace)]
clicommon.run_command(command, display_cmd=verbose)


Expand All @@ -6422,13 +6470,26 @@ def ecn(profile, rmax, rmin, ymax, ymin, gmax, gmin, rdrop, ydrop, gdrop, verbos
@config.command()
@click.option('-p', metavar='<profile_name>', type=str, required=True, help="Profile name")
@click.option('-a', metavar='<alpha>', type=click.IntRange(-8,8), help="Set alpha for profile type dynamic")
@click.option('-s', metavar='<staticth>', type=int, help="Set staticth for profile type static")
def mmu(p, a, s):
@click.option('-s', metavar='<staticth>', type=click.IntRange(min=0), help="Set staticth for profile type static")
@click.option('--verbose', '-vv', is_flag=True, help="Enable verbose output")
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def mmu(p, a, s, namespace, verbose):
"""mmuconfig configuration tasks"""
log.log_info("'mmuconfig -p {}' executing...".format(p))
command = ['mmuconfig', '-p', str(p)]
if a is not None: command += ['-a', str(a)]
if s is not None: command += ['-s', str(s)]
if namespace is not None:
command += ['-n', str(namespace)]
if verbose:
command += ['-vv']
clicommon.run_command(command)


Expand All @@ -6450,8 +6511,9 @@ def pfc(ctx):
@pfc.command()
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.argument('status', type=click.Choice(['on', 'off']))
@multi_asic_util.multi_asic_click_option_namespace
@click.pass_context
def asymmetric(ctx, interface_name, status):
def asymmetric(ctx, interface_name, status, namespace):
"""Set asymmetric PFC configuration."""
# Get the config_db connector
config_db = ctx.obj['config_db']
Expand All @@ -6461,7 +6523,11 @@ def asymmetric(ctx, interface_name, status):
if interface_name is None:
ctx.fail("'interface_name' is None!")

clicommon.run_command(['pfc', 'config', 'asymmetric', str(status), str(interface_name)])
cmd = ['pfc', 'config', 'asymmetric', str(status), str(interface_name)]
if namespace is not None:
cmd += ['-n', str(namespace)]

clicommon.run_command(cmd)

#
# 'pfc priority' command ('config interface pfc priority ...')
Expand All @@ -6471,8 +6537,9 @@ def asymmetric(ctx, interface_name, status):
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.argument('priority', type=click.Choice([str(x) for x in range(8)]))
@click.argument('status', type=click.Choice(['on', 'off']))
@multi_asic_util.multi_asic_click_option_namespace
@click.pass_context
def priority(ctx, interface_name, priority, status):
def priority(ctx, interface_name, priority, status, namespace):
"""Set PFC priority configuration."""
# Get the config_db connector
config_db = ctx.obj['config_db']
Expand All @@ -6482,7 +6549,11 @@ def priority(ctx, interface_name, priority, status):
if interface_name is None:
ctx.fail("'interface_name' is None!")

clicommon.run_command(['pfc', 'config', 'priority', str(status), str(interface_name), str(priority)])
cmd = ['pfc', 'config', 'priority', str(status), str(interface_name), str(priority)]
if namespace is not None:
cmd += ['-n', str(namespace)]

clicommon.run_command(cmd)

#
# 'buffer' group ('config buffer ...')
Expand Down
72 changes: 72 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,26 @@ This command displays the routing policy that takes precedence over the other ro
Exit routemap
```
**show suppress-fib-pending**
This command is used to show the status of suppress pending FIB feature.
When enabled, BGP will not advertise routes which aren't yet offloaded.
- Usage:
```
show suppress-fib-pending
```
- Examples:
```
admin@sonic:~$ show suppress-fib-pending
Enabled
```
```
admin@sonic:~$ show suppress-fib-pending
Disabled
```
**show bgp device-global**
This command displays BGP device global configuration.
Expand Down Expand Up @@ -2724,6 +2744,24 @@ This command is used to remove particular IPv4 or IPv6 BGP neighbor configuratio
admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE
```
**config suppress-fib-pending**
This command is used to enable or disable announcements of routes not yet installed in the HW.
Once enabled, BGP will not advertise routes which aren't yet offloaded.

- Usage:
```
config suppress-fib-pending <enabled|disabled>
```

- Examples:
```
admin@sonic:~$ sudo config suppress-fib-pending enabled
```
```
admin@sonic:~$ sudo config suppress-fib-pending disabled
```

**config bgp device-global tsa/w-ecmp**

This command is used to manage BGP device global configuration.
Expand Down Expand Up @@ -4768,6 +4806,7 @@ Optional argument "-p" specify a period (in seconds) with which to gather counte
show interfaces counters errors
show interfaces counters rates
show interfaces counters rif [-p|--period <period>] [-i <interface_name>]
show interfaces counters fec-histogram [-i <interface_name>]
```
- Example:
Expand Down Expand Up @@ -4885,6 +4924,39 @@ Optionally, you can specify a period (in seconds) with which to gather counters
admin@sonic:~$ sonic-clear rifcounters
```
The "fec-histogram" subcommand is used to display the fec histogram for the port.
When data is transmitted, it's broken down into units called codewords. FEC algorithms add extra data to each codeword that can be used to detect and correct errors in transmission.
In a FEC histogram, "bins" represent ranges of errors or specific categories of errors. For instance, Bin0 might represent codewords with no errors, while Bin1 could represent codewords with a single bit error, and so on. The histogram shows how many codewords fell into each bin. A high number in the higher bins might indicate a problem with the transmission link, such as signal degradation.
- Example:
```
admin@str-s6000-acs-11:/usr/bin$ show interface counters fec-histogram -i <PORT>
Symbol Errors Per Codeword Codewords
-------------------------- ---------
BIN0: 1000000
BIN1: 900000
BIN2: 800000
BIN3: 700000
BIN4: 600000
BIN5: 500000
BIN6: 400000
BIN7: 300000
BIN8: 0
BIN9: 0
BIN10: 0
BIN11: 0
BIN12: 0
BIN13: 0
BIN14: 0
BIN15: 0
```
**show interfaces description**
This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and Description.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"spc2": [ "ACS-MSN3800", "Mellanox-SN3800-D112C8", "ACS-MSN3420", "ACS-MSN3700C", "ACS-MSN3700", "Mellanox-SN3800-C64", "Mellanox-SN3800-D100C12S2", "Mellanox-SN3800-D24C52", "Mellanox-SN3800-D28C49S1", "Mellanox-SN3800-D28C50" ],
"spc3": [ "ACS-MSN4700", "ACS-MSN4600", "ACS-MSN4600C", "ACS-MSN4410", "ACS-SN4280", "Mellanox-SN4600C-D112C8", "Mellanox-SN4600C-C64", "Mellanox-SN4700-O8C48", "Mellanox-SN4600C-D100C12S2", "Mellanox-SN4600C-D48C40","Mellanox-SN4700-O32","Mellanox-SN4700-V64",
"Mellanox-SN4700-A96C8V8", "Mellanox-SN4700-C128", "Mellanox-SN4700-O28", "Mellanox-SN4700-O8V48", "Mellanox-SN4700-V48C32", "Mellanox-SN4280-O28"],
"spc4": [ "ACS-SN5600", "Mellanox-SN5600-O128", "Mellanox-SN5600-V256", "Mellanox-SN5600-C256", "ACS-SN5400" ],
"spc4": [ "ACS-SN5600", "Mellanox-SN5600-O128", "Mellanox-SN5600-V256", "Mellanox-SN5600-C256", "ACS-SN5400" ],
"spc5": ["ACS-SN5640"]
},
"broadcom_asics": {
Expand Down
Loading

0 comments on commit 0a96ad8

Please sign in to comment.