Skip to content

Commit

Permalink
sync from broadcom_sonic_4.x_share to dell_sonic_4.x_share - 0803 (#157)
Browse files Browse the repository at this point in the history
* [JIRA SONIC-54751] Flex-DPB UMF changes

    - Rejecting config when max ports per pipe-line is reached.
    - Support some new modes in different formats - 1x50G-PAM and 1x50G-NRZ

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: I1305e237f000434f7c837d11b9977246df30efec

* [JIRA SONIC-54751] FlexDPB

- modifying the show interface breakout modes command to display the pipe.

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: Icadd5afd3729f65180a99cb8133fae47e090849c

* [JIRA SONIC-54751] FlexDPB

- Making the CLI output better when there are too many breakout modes.

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: I38ec87ef6025978dbd88d7d5a2fa9ff7209ac969

* [JIRA SONIC-54751] Flex-DPB UM

Adding CLI "show interface breakout resources"

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: I8b9658b289557e0c708fa02f65e392b112c11609

* [JIRA SONIC-59502] User name field in not applicable cases should be displayed as Not Applicable instead of empty.

Change-Id: Ie96be7eacf13a9ebe4c9e95abbd6a88f1e47533f

* [JIRA SONIC-60245] Field to display the operational value of the session timeout in the output of the show authentication clients.

Change-Id: Ieddba8ac30568d55197fe1ce172b8cc208ffdc30

* [JIRA SONIC-56405] Added support for pac configuration over range of interfaces.

Change-Id: I0ce68fc2497fcc45fcd0c15d6113542967d974c2

* [JIRA SONIC-61478] KLISH: add 50G AN support

Signed-off-by: Dante Su <[email protected]>
Change-Id: If6c05a49f18469858b66c58cd456e7b4f6a3c0e0

* [JIRA SONIC-61803] GetTablePattern ExistKeysPattern API in DB Layer

- Added Statistics

Change-Id: I3732e78e13881842e9394a571788abe3ab1ac337

* [JIRA SONIC-61314] go.sum update

Change-Id: I7576ffc6933f9727747d3463b022c23ad7def609

* [JIRA SONIC-61807] - Model Identity as enumeration

Used Enum to represent identities
This will allow swagger ui to show drop-down in case of parameters.

Change-Id: I8e438545d0b28c9c2ee545a2704366da512b5c74

* [JIRA SONIC-60508]: ospf neighbor details template fix

Change-Id: Iee1dbdc72e02a6d23e0dfac71220843be3730ddd

* [JIRA SONIC-61879] PAC - Added required changes for config knobs dymanic_vlan_enable, vlan_assign_enable.

Change-Id: Ib38db8f2e9917b4261fc709e1548ea78f0196453

* [JIRA SONIC-61168] Klish support for ND config commands

Change-Id: I7227cb99ecf82bddac169c3b544bd28758f40c3b

* [JIRA SONIC-61223] With user added explicit snooping configuration on Vlan, actioner has called PATCH with default value for the no form of the user configuration, this has resulted in running configuration showing default value when there is no explicit configuration for the default

- Fixed actioner script to trigger DELETE for the snooping configuration instead of PATCH with the default values.
- Fix added in l2mcmgrd to fill snooping configuration IPC message by reading redisDB update instead of keeping separate local cache for snooping configurations which comes before snooping enable.

Change-Id: I3ace4e6eca5cb7608d48bb9e3a11bb1c4976e4d9

* [JIRA SONIC-61948] - Using oc-yang for dhcp snooping trusted port configuration in Klish

Change-Id: I33c811e9316b552b08cdbc12489c73806f4e3e95

* [JIRA SONIC-54751] Flex DPB

- PAM/NRZ generic lane count approach
- System level max ports
- Lane count notation translation, display, config display

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: If8b5429e732fce5342d960b0980a250f75a5ff8c

* [JIRA SONIC-54751] Flex DPB - 20G speed support

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: I8a0f581c70c0aa6b30e76a64fe4262d44f828568

* [JIRA SONIC-62134] - Corrected the sag xml order to come after vrf config

Change-Id: I0d463d9d16e014d39b343d14d36ff801019017d4

* [JIRA SONIC-61997] using escap_chars option to skip '\' for special chars

Change-Id: I3b654ea105931c0e3605b84ed5db560cb5e13e95

* [JIRA SONIC-62061] validating tag field of SNMP_SERVER_TARGET entry, before using it

Change-Id: I504812121a85e83693d00dae76d5321583b1b7a0

* [JIRA SONIC-61168] Klish support for show command

Change-Id: Ia2e6d4d8b8ae598af3cdcdbbb051bcddc8625bbc

* [JIRA SONIC-62420] Added changes to not format debug logs until its enabled to speed up execuction of actioners for ACL and FBS

Change-Id: Ibbad404d7f6890d03b99d63f26f9ddd36eab728d

* [JIRA SONIC-54751] Flex DPB - rename lane-count to total-lane-count

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: I2ecb8e0a5e6ca0ced86bb795ef2a98a155c25fdc

* [JIRA SONIC-60841]  The NTP client must support the "prefer" option and provide CLI for enabling it

Change-Id: I724543e858a256032fa9d45a5982a4124266a859

* [JIRA SONIC-61168] Klish support for modifying help string associated with config commands to make it more descriptive

Change-Id: I9377ef77a093c3b0ed5269a1df874965ae6a3298

* [JIRA SONIC-61879] PAC - Added required UI changes for Auth Fail Retry config command.

Change-Id: Id66b4d31e6a509816f4d5b598c005b109397856e

* [JIRA SONIC-60945] Show redirect ACL binding in show access-group CLI

Change-Id: I56a2f7bce3a34eec51c4371210a4379ee8730589

* [JIRA SONIC-62672] Fix exception when per interface acl mode is enabled

Change-Id: If924f71bc4e614ff948351a94a3a26b9ef18df6b

* [JIRA SONIC-62110] SONIC_4.1.0 - media_autoconf: initial commit

Signed-off-by: Dante Su <[email protected]>
Change-Id: Id799deb252c489102d9efcc3b3280d32ff86dce4

* [JIRA SONIC-62796] SONIC_4.1.0 - KLISH CLI: Add 200G support to 'show interface advertise'

Signed-off-by: Dante Su <[email protected]>
Change-Id: Ic66c272a8bc8826480365eb5780ef4db2aa4f1ca

* [JIRA SONIC-62847] Clish pre-exec hook

* Added a new pre-exec hook, which gets called before executing the
  ACTION or CONFIG handlers
* Hook function receives the current command context
* Command execution is aborted if hook returns non-zero value
* Added a skeleton implementation in clish plugin
* Few utility functions for the future pre-hook implementation
  char *get_uname(clish_context_t *c)
  char *get_masked_line(clish_context_t *c)

Change-Id: I44a0a5df4419fb51ad90ff9898db6b9534ef5eb1

* [JIRA SONIC-62732] [JIRA SONIC-62730] : 1.Fix jinja template to show proper state for helper strict lsa checking

Change-Id: I313baac45137b46eab821fb5e17234ca365270a5

* [JIRA SONIC-62280] Added COA klish CLI changes.

Change-Id: Ie7498ad7451763256641862da4d5ba12efdc750a

* [JIRA SONIC-61879] Modified authentication fail retry default value to 1, made minor corrections in authmgr appl.

Change-Id: I1cef51a96991d22a54e407c0b6dd60d0edef055c

* [JIRA SONIC-62875] Fix processing of dynamic acls and redirect acls when per interface acl counter mode is enabled

Change-Id: Ic8d3e0c8b16ac9785b8f9c687e603c3f8659cd77

* [JIRA SONIC-61950]: Dot1x/MAB timers config support

Change-Id: I022b1d75b183e3028db5c083b1d70a971616a597

* [JIRA SONIC-62911] PTP 1-step and TH3 support

- UMF changes

Signed-off-by: Prasanth Kunjum Veettil <[email protected]>
Change-Id: Ib46e89a9f82c73b8e8af5b53d479258f424a51f5

* [JIRA SONIC-63025] SONIC_4.1.0 - KLISH: add the missing link-training status support

Signed-off-by: Dante Su <[email protected]>
Change-Id: Icb05d69abd3a9042d5d2838868fcbde7871caf09

* [JIRA SONIC-63081] SONIC_4.1.0 - KLISH/YANG: Reverting SONIC-51042 to use float with precision 2 in DOM values

Signed-off-by: Dante Su <[email protected]>
Change-Id: I200df89d1dcc234965eb87a27b5c6df8e28c3f0a

* [JIRA SONIC-62637] : 1. Added support for -:show ip ospf database opaque-link 2.Support opaque-link lsa summary for -:show ip ospf database

Change-Id: I631ca9918bb90630420a94caed1603d673923e81

* [JIRA SONIC-62953] added check for security-nme key before accessing it.

Change-Id: I5ff72ed7a4b183cf939455e2afba97d0f964d618

* [JIRA SONIC-63000] Portchannel min-links related changes

Change-Id: I3ab9f27c8b6fe5266eddfc60295d0fa3bb806557

* [JIRA SONIC-63158] Kernel 5.10 does not support l3mdev cgroups, instead
cgroups with BPF programs are used to achieve this.
Since kernel vrf support now adds CGROUPS with BPF which iproute2 utils
uses in ip vrf exec commands. Update SONiC scripts to "ip vrf exec" from
cgexec.

Change-Id: I8df96902b4d933462fa23cb14100caf5f432de6f

* [JIRA SONIC-62104] SONIC_4.1.0 - EVPN Multihoming Task - KLISH system-mac and evpn ethernet segment

Change-Id: Iad4153e21c9f67b0326aced909f7c9d07ef67429

* [JIRA SONIC-63064] SONIC_4.1.0 - EVPN Multihoming Task - mclag domain config checking

Change-Id: I8bc1619034e37fd99fdbac8a096fbe51de0d85b3

* [JIRA SONIC-62780] SONIC_4.1.0 - Add interface Portchannel range support for system-mac configuration

Change-Id: I10bec6d70e1eaff6af16de33c12f3dbc1aa47433

* [JIRA SONIC-63320] Added UI support for multi-vrf functionality of TAM
collectors.

Change-Id: Ie44af58c8aab48b54b43aa843ccf5ea7870db479

* [JIRA SONIC-63333] bgp clis - disable-ead-evi-rx, disable-ead-evi-tx, use-es-l3nhg

Change-Id: I12470dbf82495e14cc3638e9b329897d5d9156f5

* [JIRA SONIC-63377] TCAM Keyprofile CLI Changes

Few key-profile names are missing in TCAM CLI. Code changes has
been done to add the missing key-profile names in TCAM CLI.

Change-Id: I249cd34b6266e6c35e79b77d5fb9d95a0dccaf04

* [JIRA SONIC-63000] Portchannel fallback config updated related changes

Change-Id: I9fb8885f8f055ffe7a8556788f1e8b50ac5fb73f

* [JIRA SONIC-63408] - Fix CLI docgen issue

Re-Enaled cli docgen
made it to execute with python3 always
Fixed unicode issues.

Change-Id: I611133abbf0d389172768153e6e3fc2fa2f1b996

* [JIRA SONIC-63053] : 1.Add ospf gr prepartion status to ospf global state info 2.Fixed a template issue

Change-Id: I0a875f2b7b520b535f564061eb92427be8db26dd

* [JIRA SONIC-62082] Support for clearing evpn duplicate address based on
 IP address.

Change-Id: I3f0ab0428cca4e37285ffa12416d7755cc4ce020

* [JIRA SONIC-63000] Portchannel fast-rate config updated related changes

Change-Id: If154af9ada867067aee3b631170e1a7c815d9f05

* [JIRA SONIC-62800] Invoking new statistics detail URLs.

Change-Id: I29290a17cc85223c6ba5f23f4d64cb9c29c08380

* [JIRA SONIC-63378] Fix ACL description update to not include double quotes, ACL subintf binding to use subintf index, added exception handling to prevent exception in 1 show running callback to impact other callbacks

Change-Id: Ib796610c3fe4bfb1dee090518c564f2069e95d5c

* [JIRA SONIC-62913] Unable to remove tacacs-server host and observing "% Error: Client is not authorized to perform this operation"

Change-Id: I972174c64374ab198678e7722bcf8822cced1830

* [JIRA SONIC-63479] WFB: "speed auto 400000" throwing Error " Speed 400000 is not supported on Ethernet56" on z9332

Signed-off-by: Dante Su <[email protected]>
Change-Id: I3f06248c2f5a3d5b82058753dfc16256d99cb40a

* [JIRA SONIC-63000] Fixing the show-configuration and show-running-configuration for the config updated related changes

Change-Id: I2c4e4a5a02a3508e86d8111b7dd1a66db4caf548

* [JIRA SONIC-63303] [JIRA SONIC-63459] Neighbor Discovery fixes for alias mode and reboot case for ra-lifetime

Change-Id: I98f8d738e9d4196debe12323931306004caecf0c

* [JIRA SONIC-63000] Fallback value is showing incorrect in the command 'show interface portchannel' as it is not picking the value from DB correctly. Fixing the issue by picking the correct value from CONFIG_DB.

Change-Id: I58db4bcde4f9af7e8dae79151b1b5768189ff8e3

* [JIRA SONIC-62130] Tpcm Enhancements

Along with previous enhancements, added support for "tpcm update disk-limit <value>"

Change-Id: I8ee3058f1d69d39c19d8c06d96c5faf60843db9b

* [JIRA SONIC-63601] checking presence of target-params and udp in the dictionary before accession them

Change-Id: Ia147b385087449487e2c91ac2ed8de3adb37e540

* Fixing merge conflict

Co-authored-by: sonicmergeuser <[email protected]>
Co-authored-by: Prasanth Kunjum Veettil <[email protected]>
Co-authored-by: Sravani Maddukuri <[email protected]>
Co-authored-by: Shiva Kumar Boddula <[email protected]>
Co-authored-by: Dante Su <[email protected]>
Co-authored-by: Sonic Build <[email protected]>
Co-authored-by: Arun Barboza <[email protected]>
Co-authored-by: Sachin Holla <[email protected]>
Co-authored-by: Faraaz <[email protected]>
Co-authored-by: Ramachandran Sathianandan <[email protected]>
Co-authored-by: sudhanshukumar22 <[email protected]>
Co-authored-by: Ashok Krishnegowda <[email protected]>
Co-authored-by: Akhilesh Samineni <[email protected]>
Co-authored-by: suresh-rupanagudi <[email protected]>
Co-authored-by: Lakshmi Sruthy <[email protected]>
Co-authored-by: Abhishek Dharwadkar <[email protected]>
Co-authored-by: Asha Behera <[email protected]>
Co-authored-by: Rama Chandra Reddy Gaddam <[email protected]>
Co-authored-by: madhukar-kamarapu <[email protected]>
Co-authored-by: Preetham Singh <[email protected]>
Co-authored-by: leeprecy <[email protected]>
Co-authored-by: Mayank Maheshwari <[email protected]>
Co-authored-by: karthik raj <[email protected]>
Co-authored-by: Ashok Narayanasamy <[email protected]>
Co-authored-by: Kishore Kunal <[email protected]>
Co-authored-by: Phanindra TV <[email protected]>
Co-authored-by: Prabhu Sreenivasan <[email protected]>
Co-authored-by: sg893052 <[email protected]>
Co-authored-by: SONiC Syncbot <[email protected]>
  • Loading branch information
30 people authored and GitHub Enterprise committed Aug 3, 2022
1 parent b79ebad commit d909a48
Show file tree
Hide file tree
Showing 20 changed files with 1,054 additions and 211 deletions.
1 change: 1 addition & 0 deletions CLI/actioner/show_config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"if_autoneg": show_if_autoneg,
"if_fec": show_if_fec,
"if_speed": show_if_speed,
"if_unlos": show_if_unlos,
"tacacs_server_source_if": show_tacacs_source_if,
"dns_server_source_if": show_dns_source_if,
"ntp_server_source_if": show_ntp_source_if,
Expand Down
18 changes: 17 additions & 1 deletion CLI/actioner/show_config_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,28 @@ def show_if_fec(render_tables):
if port.get("ifname") != ifname_key:
continue
fec = port.get("fec")
if fec not in ['rs', 'RS', 'fc', 'FC']:
if fec not in ['rs', 'RS', 'fc', 'FC', 'auto', 'AUTO']:
continue
cmd_str = "fec {}".format(fec.upper())

return "CB_SUCCESS", cmd_str

def show_if_unlos(render_tables):
cmd_str = ""

if "name" in render_tables:
ifname_key = render_tables["name"]
if "sonic-port:sonic-port/PORT/PORT_LIST" in render_tables:
for port in render_tables["sonic-port:sonic-port/PORT/PORT_LIST"]:
if port.get("ifname") != ifname_key:
continue
mode = port.get("unreliable_los")
if mode not in ['off', 'OFF', 'on', 'ON']:
continue
cmd_str = "unreliable-los {}".format(mode)

return "CB_SUCCESS", cmd_str

def show_if_loopback(render_tables):
cmd_str = ""

Expand Down
4 changes: 2 additions & 2 deletions CLI/actioner/show_running_config_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def show_nd_running_intf_config(render_tables):
elif "interval" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-interval {}".format(
nd_cfg_intf["interval"]) + cmd_end)
if "ra-lifetime" in nd_cfg_intf:
if "lifetime" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-lifetime {}".format(
nd_cfg_intf["ra-lifetime"]) + cmd_end)
nd_cfg_intf["lifetime"]) + cmd_end)
if "ra-retrans-interval" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-retrans-interval {}".format(
nd_cfg_intf["ra-retrans-interval"]) + cmd_end)
Expand Down
9 changes: 5 additions & 4 deletions CLI/actioner/sonic-cli-neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from rpipe_utils import pipestr
from collections import OrderedDict
from scripts.render_cli import show_cli_output
from six.moves.urllib.parse import quote
import json
import socket
import syslog as log
Expand Down Expand Up @@ -198,7 +199,7 @@ def get_nd_intf_keypath(intf_name, config_add, param_name):
sub_intf_index = 0
intf_name, sub_intf_index = get_nd_if_and_subif(intf_name)
if 'Eth' in intf_name or 'Po' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(intf_name, sub_intf_index) + \
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(quote(intf_name, safe=""), sub_intf_index) + \
"openconfig-if-ip:ipv6/router-advertisement/"
elif 'Vlan' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/openconfig-vlan:routed-vlan/".format(intf_name) + \
Expand All @@ -214,7 +215,7 @@ def fill_nd_prefix_info(intf_name, output):
api = cc.ApiClient()
intf_name, sub_intf_index = get_nd_if_and_subif(intf_name)
if 'Eth' in intf_name or 'Po' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(intf_name, sub_intf_index) + \
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(quote(intf_name, safe=""), sub_intf_index) + \
"openconfig-if-ip:ipv6/router-advertisement/openconfig-interfaces-ext:ra-prefixes"
elif 'Vlan' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/openconfig-vlan:routed-vlan/".format(intf_name) + \
Expand All @@ -235,7 +236,7 @@ def fill_nd_rdnss_info(intf_name, output):
api = cc.ApiClient()
intf_name, sub_intf_index = get_nd_if_and_subif(intf_name)
if 'Eth' in intf_name or 'Po' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(intf_name, sub_intf_index) + \
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(quote(intf_name, safe=""), sub_intf_index) + \
"openconfig-if-ip:ipv6/router-advertisement/openconfig-interfaces-ext:rdnss-addresses"
elif 'Vlan' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/openconfig-vlan:routed-vlan/".format(intf_name) + \
Expand All @@ -256,7 +257,7 @@ def fill_nd_dnssl_info(intf_name, output):
api = cc.ApiClient()
intf_name, sub_intf_index = get_nd_if_and_subif(intf_name)
if 'Eth' in intf_name or 'Po' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(intf_name, sub_intf_index) + \
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/subinterfaces/subinterface={}/".format(quote(intf_name, safe=""), sub_intf_index) + \
"openconfig-if-ip:ipv6/router-advertisement/openconfig-interfaces-ext:dns-search-names"
elif 'Vlan' in intf_name:
keypath = "/restconf/data/openconfig-interfaces:interfaces/interface={}/openconfig-vlan:routed-vlan/".format(intf_name) + \
Expand Down
3 changes: 2 additions & 1 deletion CLI/actioner/sonic_cli_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def invoke_api(func, args=[]):
"RS": "FEC_RS",
"FC": "FEC_FC",
"none": "FEC_DISABLED",
"default": "FEC_AUTO",
"default": "FEC_DEFAULT",
"AUTO": "FEC_AUTO"
}

fec = args[1]
Expand Down
126 changes: 27 additions & 99 deletions CLI/actioner/sonic_cli_if_autoneg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,67 +37,8 @@

aa = cc.ApiClient()

platform_dict = {}
def initPlatformDict():
global platform_dict
if len(platform_dict) != 0:
return

file = "/usr/share/sonic/hwsku/platform-def.json"
if os.path.exists(file):
with open(file) as json_file:
platform_dict = json.load(json_file)
for id in platform_dict['native-port-supported-speeds'].keys():
ports = getRangedPortList(id)
lanes = platform_dict['native-port-supported-speeds'][id].keys()
for lane in lanes:
num = int(lane)
iii = 0
while iii < len(ports):
intf = ports[iii]
spds = platform_dict['native-port-supported-speeds'][id][lane]
platform_dict[intf] = spds
iii += num

file = "/usr/share/sonic/hwsku/platform.json"
if os.path.exists(file):
with open(file) as json_file:
platform_dict['brkout'] = json.load(json_file)

# alias map
if 'brkout' in platform_dict:
platform_dict['alias_map'] = {}
for phys, info in platform_dict['brkout'].items():
alias_list = info['alias_at_lanes'].replace(' ', '').split(',')
if len(alias_list) == 1:
a = alias_list[0]
platform_dict['alias_map'][a] = phys
elif len(alias_list) > 1:
a = alias_list[0]
p = a[:len(a) - 2]
b = int(phys[8:])
platform_dict['alias_map'][p] = phys
i = 0
for a in alias_list:
platform_dict['alias_map'][a] = "Ethernet{}".format(b + i)
i += 1

def getPortPhysicalName(port):
if port is None:
return port
if '/' not in port:
return port
if 'alias_map' not in platform_dict:
return port
if port not in platform_dict['alias_map']:
return port
return platform_dict['alias_map'][port]

asic_id = 0
def hasAutoNegSupport(port=None):
if port is not None:
port_cfg = getPortConfig(port)
port = getPortPhysicalName(port)

# Check for switch chip id
global asic_id
Expand All @@ -119,23 +60,25 @@ def hasAutoNegSupport(port=None):
except:
asic_id = 0

# TH, TH2 are not supported
# Abort if it's not a supported chip (e.g. TH, TH+, TH2)
if (asic_id & 0xfff0) in [0xb930, 0xb960, 0xb970]:
return False

# TH3, TD4: 1-lane mode is not supported, as they're non-official port mode
if ((asic_id & 0xfff0) in [0xb980, 0xb880, 0xb780]) and (port is not None):
lanes = port_cfg.get('lanes', '0').replace(' ', '').split(',')
if len(lanes) == 1:
return False
# Skip if this is not a per-port capability check
if port is None:
return True

# TD3: merlin port is not supported
if ((asic_id & 0xfff0) in [0xb870]) and (port is not None):
brkout = platform_dict.get('brkout')
if (brkout is not None) and (port in brkout):
lanes = brkout[port].get('lanes', '0').replace(' ', '').split(',')
if (len(lanes) == 1) and (lanes[0] in ['128', '129']):
return False
# Skip if it's a mgmt. port
port_cfg = getPortConfig(port)
lanes = port_cfg.get('lanes', '0').replace(' ', '').split(',')
if len(lanes) == 0:
return False
if len(lanes) == 1:
# TD3
if (asic_id & 0xfff0) in [0xb870]:
return int(lanes[0]) in range(1, 128)
# HR4, MV2, HX5, TH2, TH3, TD4
return int(lanes[0]) in range(1, 257)

return True

Expand Down Expand Up @@ -242,50 +185,35 @@ def getPortInfo(if_list):

def getPortValidSpeeds(port):
port_cfg = getPortConfig(port)

# Is a breakout port?
is_brkout = False
cur_lanes = port_cfg.get('lanes', '0').replace(' ', '').split(',')
cur_speed = port_cfg.get('speed', '0')
if 'brkout' in platform_dict:
phys = getPortPhysicalName(port)
if phys in platform_dict['brkout']:
def_lanes = platform_dict['brkout'][phys].get('lanes', '0').replace(' ', '').split(',')
is_brkout = (len(cur_lanes) < len(def_lanes))
else:
is_brkout = True
if is_brkout:
return [cur_speed]

# Return current speed or the valid speed list in the platform-def.json
val_speed = platform_dict.get(getPortPhysicalName(port))
if val_speed is None:
lanes = port_cfg.get('lanes', '0').replace(' ', '').split(',')
speed = port_cfg.get('speed', '0')
valid_speeds = port_cfg.get('valid_speeds', speed).replace(' ', '').split(',')
if valid_speeds is None or len(valid_speeds) == 0:
# TD3-X7: Valid speed list could be unavailable if it's a member of port-group
if ((asic_id & 0xfff0) in [0xb870]) and (len(cur_lanes) == 1):
if int(cur_speed) == 25000:
if ((asic_id & 0xfff0) in [0xb870]) and (len(lanes) == 1):
if int(speed) == 25000:
return ['25000']
elif int(cur_speed) in [10000, 1000]:
elif int(speed) in [10000, 1000]:
return ['10000', '1000']
return [cur_speed]
return val_speed
return [speed]
return valid_speeds

def getPortConfig(port):
port = port.replace("/", "%2F")
link = "/restconf/data/sonic-port:sonic-port/PORT/PORT_LIST={}".format(port)
path = cc.Path(link)
resp = aa.get(path)
conf = None
if resp.ok() and (resp.content is not None):
return resp.content.get('sonic-port:PORT_LIST', [{}])[0]
return {}
conf = resp.content.get('sonic-port:PORT_LIST', [{}])[0]
return {} if conf is None else conf

def run(func, args):
path = None
if_name = None if len(args) < 1 else args[0]
if_list = []
if_dict = OrderedDict()

initPlatformDict()

if not hasAutoNegSupport():
print("Error: This feature is not available on the current platform")
return
Expand Down
Loading

0 comments on commit d909a48

Please sign in to comment.