Skip to content

Commit f7eed73

Browse files
committed
Handle copilot comments
Signed-off-by: Zili Bombach <zbombach@nvidia.com>
1 parent fa308e5 commit f7eed73

3 files changed

Lines changed: 102 additions & 15 deletions

File tree

doc/Command-Reference.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5964,6 +5964,7 @@ Subsequent pages explain each of these commands in detail.
59645964
switchport Show Interface switchport information
59655965
tpid Show Interface tpid information
59665966
transceiver Show SFP Transceiver information
5967+
label-port Show label-port mapping information
59675968
```
59685969

59695970
**show interfaces autoneg**
@@ -6845,6 +6846,91 @@ is command.
68456846

68466847
This command is already explained [here](#Transceivers)
68476848

6849+
**show interfaces label-port status**
6850+
6851+
This command displays a standardized mapping of front-panel label ports to SONiC interface names, their lanes, and operational status under the current breakout configuration. Each table cell shows the mapped interface name and status for the corresponding lane (for example, `Ethernet0(UP)`). On multi-ASIC systems, the interface name also includes the ASIC namespace (for example, `Ethernet0|asic0(UP)`).
6852+
6853+
- Usage:
6854+
```
6855+
show interfaces label-port status
6856+
```
6857+
6858+
- Example (single-ASIC, 2 x 4x breakout):
6859+
```
6860+
admin@sonic:~$ show interfaces label-port status
6861+
+--------------+-----------------+-----------------+-----------------+-----------------+
6862+
| Label Port | Lane 1 | Lane 2 | Lane 3 | Lane 4 |
6863+
+==============+=================+=================+=================+=================+
6864+
| 1 | Ethernet0(UP) | Ethernet0(UP) | Ethernet0(UP) | Ethernet0(UP) |
6865+
| 2 | Ethernet4(UP) | Ethernet4(UP) | Ethernet4(UP) | Ethernet4(UP) |
6866+
| 3 | Ethernet8(UP) | Ethernet8(UP) | Ethernet8(UP) | Ethernet8(UP) |
6867+
| ... | ... | ... | ... | ... |
6868+
| 128 | Ethernet508(UP) | Ethernet508(UP) | Ethernet508(DOWN) | Ethernet508(UP) |
6869+
+--------------+-----------------+-----------------+-----------------+-----------------+
6870+
```
6871+
6872+
- Example (single-ASIC, 4 x 2x breakout):
6873+
```
6874+
admin@sonic:~$ show interfaces label-port status
6875+
+--------------+-----------------+-----------------+------------------+------------------+
6876+
| Label Port | Lane 1 | Lane 2 | Lane 3 | Lane 4 |
6877+
+==============+=================+=================+==================+==================+
6878+
| 1 | Ethernet0(UP) | Ethernet0(UP) | Ethernet2(UP) | Ethernet2(UP) |
6879+
| 2 | Ethernet4(UP) | Ethernet4(UP) | Ethernet6(UP) | Ethernet6(UP) |
6880+
| 3 | Ethernet8(UP) | Ethernet8(UP) | Ethernet10(UP) | Ethernet10(UP) |
6881+
| ... | ... | ... | ... | ... |
6882+
| 128 | Ethernet508(UP) | Ethernet508(UP) | Ethernet510(DOWN) | Ethernet510(UP) |
6883+
+--------------+-----------------+-----------------+------------------+------------------+
6884+
```
6885+
6886+
- Example (multi-ASIC):
6887+
```
6888+
admin@sonic:~$ show interfaces label-port status
6889+
+--------------+---------------------+-----------------------+------------------------+------------------------+
6890+
| Label Port | Lane 1 | Lane 2 | Lane 3 | Lane 4 |
6891+
+==============+=====================+=======================+========================+========================+
6892+
| 1 | Ethernet0|asic0(UP) | Ethernet512|asic1(UP) | Ethernet1024|asic2(UP) | Ethernet1536|asic3(UP) |
6893+
| 2 | Ethernet1|asic0(UP) | Ethernet513|asic1(UP) | Ethernet1025/asic2(UP) | Ethernet1537|asic3(UP) |
6894+
| 3 | Ethernet2|asic0(UP) | Ethernet514|asic1(UP) | Ethernet1026/asic2(UP) | Ethernet1538|asic3(UP) |
6895+
| ... | ... | ... | ... | ... |
6896+
| 512 | Ethernet511|asic0(UP) | Ethernet1023|asic1(UP) | Ethernet1535|asic2(DOWN) | Ethernet2047|asic3(UP) |
6897+
+--------------+---------------------+-----------------------+------------------------+------------------------+
6898+
```
6899+
6900+
- Platform requirements (`platform.json`):
6901+
6902+
All supported platforms must define `label_port_lanes_mapping`:
6903+
6904+
- **Key**: label-port identifier (string), for example `"1"`, `"2"`.
6905+
- **Value**: list of global lane numbers (strings), for example `["0", "1", "2", "3"]`.
6906+
6907+
Multi-ASIC platforms must also define `number_of_lanes_per_asic`. This value is used to compute global lane offsets:
6908+
6909+
`global_lane = local_lane + (asic_index x number_of_lanes_per_asic)`
6910+
6911+
Single-ASIC example:
6912+
```json
6913+
"label_port_lanes_mapping": {
6914+
"1": ["0", "1", "2", "3"],
6915+
"2": ["4", "5", "6", "7"],
6916+
...
6917+
"127": ["504", "505", "506", "507"],
6918+
"128": ["508", "509", "510", "511"]
6919+
}
6920+
```
6921+
6922+
Multi-ASIC example:
6923+
```json
6924+
"number_of_lanes_per_asic": "512",
6925+
"label_port_lanes_mapping": {
6926+
"1": ["0", "512", "1024", "1536"],
6927+
"2": ["1", "513", "1025", "1537"],
6928+
...
6929+
"511": ["510", "1022", "1534", "2046"],
6930+
"512": ["511", "1023", "1535", "2047"]
6931+
}
6932+
```
6933+
68486934
Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces)
68496935

68506936
### Interface Config Commands

show/interfaces/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,11 +1531,9 @@ def get_ports_data():
15311531
db = multi_asic.connect_to_all_dbs_for_ns(namespace=namespace)
15321532
port_table = multi_asic.get_port_table(namespace=namespace)
15331533
for port_name, port_info in port_table.items():
1534-
lanes = port_info.get(LANES, []).split(',')
1534+
lanes = [lane for lane in port_info.get(LANES, "").split(',') if lane]
15351535
oper = db.get(db.APPL_DB, f"{APPL_PORT_TABLE}:{port_name}", OPER_STATUS)
15361536
status = (oper or DOWN).upper()
1537-
if namespace not in ports_dict:
1538-
ports_dict[namespace] = {}
15391537
ports_dict[port_name] = {
15401538
LANES: [int(lane) for lane in lanes],
15411539
STATUS: status,
@@ -1565,16 +1563,15 @@ def get_labelport_to_ports_map(ports_dict, labelport_map, lanes_per_asic):
15651563
except (KeyError, ValueError):
15661564
log.log_debug("Lane {} not found in labelport {}".format(lane, labelport_num))
15671565
continue
1568-
port_name = f"{port}/{info.get(ASIC)}" if info.get(ASIC) != "" else port
1566+
port_name = f"{port}|{info.get(ASIC)}" if info.get(ASIC) != "" else port
15691567
if labelport_num not in labelport_to_ports_map:
15701568
labelport_to_ports_map[int(labelport_num)] = ['-'] * labelport_lanes_number
15711569
labelport_to_ports_map[int(labelport_num)][position] = f"{port_name}({info.get(STATUS, DOWN)})"
15721570
return labelport_to_ports_map
15731571

15741572

15751573
@labelport.command(name='status')
1576-
@clicommon.pass_db
1577-
def labelport_status(db):
1574+
def labelport_status():
15781575
"""
15791576
Show a mapping and status of label-ports -> ports
15801577
"""
@@ -1603,5 +1600,10 @@ def labelport_status(db):
16031600

16041601
# Build the table
16051602
header = ['Label Port'] + [f'Lane {i+1}' for i in range(labelport_lanes_number)]
1606-
body = [[int(labelport)] + labelport_to_ports_map[labelport] for labelport in sorted(labelport_to_ports_map.keys())]
1603+
body = [
1604+
[int(labelport)] + labelport_to_ports_map.get(
1605+
int(labelport), ['-'] * labelport_lanes_number
1606+
)
1607+
for labelport in sorted(labelport_map.keys(), key=int)
1608+
]
16071609
click.echo(tabulate(body, header, tablefmt="outline"))

tests/interfaces_test.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,7 @@ def invoke_labelport_status():
974974
runner = CliRunner()
975975
return runner.invoke(
976976
show.cli.commands["interfaces"].commands["label-port"].commands["status"],
977-
[],
978-
obj=object.__new__(Db)
977+
[]
979978
)
980979

981980

@@ -1039,10 +1038,10 @@ def test_basic_multi_asic(self, monkeypatch):
10391038

10401039
assert result.exit_code == 0
10411040
assert result.output == expected_labelport_output([
1042-
[1, 'Ethernet0/asic0(UP)', 'Ethernet512/asic1(UP)', 'Ethernet1024/asic2(UP)',
1043-
'Ethernet1536/asic3(UP)'],
1044-
[2, 'Ethernet1/asic0(UP)', 'Ethernet513/asic1(UP)', 'Ethernet1025/asic2(UP)',
1045-
'Ethernet1537/asic3(UP)'],
1041+
[1, 'Ethernet0|asic0(UP)', 'Ethernet512|asic1(UP)', 'Ethernet1024|asic2(UP)',
1042+
'Ethernet1536|asic3(UP)'],
1043+
[2, 'Ethernet1|asic0(UP)', 'Ethernet513|asic1(UP)', 'Ethernet1025|asic2(UP)',
1044+
'Ethernet1537|asic3(UP)'],
10461045
])
10471046

10481047
def test_mixed_splits_lane_positions_and_fanout(self, monkeypatch):
@@ -1140,8 +1139,8 @@ def test_multi_asic_one_asic_down(self, monkeypatch):
11401139

11411140
assert result.exit_code == 0
11421141
assert result.output == expected_labelport_output([
1143-
[1, 'Ethernet0/asic0(UP)', '-', 'Ethernet1024/asic2(UP)', 'Ethernet1536/asic3(UP)'],
1144-
[2, 'Ethernet1/asic0(UP)', '-', 'Ethernet1025/asic2(UP)', 'Ethernet1537/asic3(UP)'],
1142+
[1, 'Ethernet0|asic0(UP)', '-', 'Ethernet1024|asic2(UP)', 'Ethernet1536|asic3(UP)'],
1143+
[2, 'Ethernet1|asic0(UP)', '-', 'Ethernet1025|asic2(UP)', 'Ethernet1537|asic3(UP)'],
11451144
])
11461145

11471146
def test_missing_oper_status_displays_down(self, monkeypatch):

0 commit comments

Comments
 (0)