Interfaces - amybuck/SONiC-NAS GitHub Wiki

This information describes how to create and manage physical and virtual interfaces. Physical port interfaces refer to ports on the NPU and do not include the Management port. Each physical port on the NPU maps to a data port on the front panel of the switch.

To manage interfaces, applications access physical and virtual ports using the Linux interfaces to which they are mapped. SONiC NAS Host-Adapter allocates an ifindex (interface index) for each Linux interface. The ifindex value is used in SONiC Object Library APIs to refer to a Linux interface.

Map Physical Ports to Linux Interfaces

Each physical port is mapped to an internal Linux interface — eNSS-PPP-F.vvv

e — Specifies an Ethernet port

N — Specifies the node ID (always set to 1)

SS — Specifies the slot number (always set to 1)

PPP — Specifies the port number (1 to 999)

F — Specifies the number of 4x10G fanout ports (0 to 9)

vvv — Specifies the VLAN ID number (0 to 4095)

Port Mapping from NPU to Linux Interfaces

The e101-031-0 interface refers to physical port 31 without a fanout, e101-005-4 identifies fanout port 4 on physical port 5, and e101-001-2 identifies fanout port 2 on physical port 1.

Linux interfaces are created during bootup and represent the physical ports on the NPU in a one-to-one mapping. The internal Linux interfaces allow applications to configure physical port parameters including MTU, port state, and link state. Linux interfaces also provide packet I/O functionality and support applications in control plane transmission (sending and receiving).

Map CPU Port to Linux Interface

The SONiC NAS Host-Adapter software creates a dedicated Linux interface that maps to the CPU port. Configure control-plane policy (CoPP) queue rates by specifying npu0 as the port in the QoS SONiC Object Library API.

Physical Ports

The status of a physical port is administratively down by default. Each interface has its own MAC address that is reserved and derived from the system MAC address. Use standard Linux commands to configure physical interface parameters.

Set MTU

$ ip link set dev e101-002-0 mtu 1400

$ ip link show e101-002-0
17: e101-002-0: <BROADCAST,MULTICAST> mtu 1400 qdisc noop state DOWN mode DEFAULT 
group default qlen 500
    link/ether 90:b1:1c:f4:ab:f2 brd ff:ff:ff:ff:ff:ff
    alias NAS## 0 29

Show Interface Parameters

$ ip addr show e101-001-0
16: e101-001-0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default 
qlen 500
    link/ether 90:b1:1c:f4:ab:ee brd ff:ff:ff:ff:ff:ff
    inet 10.1.1.1/24 scope global e101-001-0
        valid_lft forever preferred_lft forever
    inet6 2000::1/64 scope global tentative
        valid_lft forever preferred_lft forever

See SONiC Object Library Application Examples to learn how to program physical port configuration using the SONiC Object Library API.

Fanout (4x10G) Interfaces

Using a breakout cable, you can split a 40GbE physical port into four (quad) 10GbE SFP+ ports — only if supported by the NPU. Each 4x10G port is represented by a Linux interface with a fanout field in the interface name that identifies the 4x10G port.

Use the sonic-config-fanout command to fanout a 40GbE port (true), or disable the port configuration (false), and return the physical port to 40G operation.

Syntax

sonic-config-fanout <linux-interface> [true | false]

Example

$ sonic-config-fanout e101-005-0 true
Key: 1.20.1310766.1310754.1310755.1310756.1310757.
base-port/physical/unit-id = 0
base-port/physical/phy-media = 1
base-port/physical/front-panel-number = 0
base-port/physical/loopback = 0
base-port/physical/hardware-port-id = 45
base-port/physical/npu-id = 0
base-port/physical/fanout-mode = 4
base-port/physical/breakout-capabilities  =  4,2
base-port/physical/port-id = 45
base-port/physical/slot-id = 0

Deleting.. e101-005-0
Completed...

Creating interface e101-005-1

Creating interface e101-005-2
Creating interface e101-005-3
Creating interface e101-005-4

Successfully created interfaces...

Port Channel (LAG) Bond Interfaces

A port channel also known as a link aggregation group (LAG) corresponds to a Linux bond interface, which aggregates multiple physical interfaces into one virtual interface for load-balancing and link failovers. A LAG and a bond interface both refer to a link aggregation group. The term LAG refers to an NPU configuration, while the term bond interface refers to a Linux configuration.

NOTE: A Linux bond interface must be up before you can add member ports.

Create Bond Interface (LAG)

$ ip link add bond1 type bond mode balance-rr miimon 50

Bring Up Bond Interface

$ ip link set dev bond1 up

$ ip link show|grep bond1 
50: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state 
UNKNOWN mode DEFAULT group default

Add Port to Bond Interface

$ ip link set e101-010-0 master bond1

Show Bond Interface

$ ip link show | grep bond1
12: e101-010-0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master 
bond1 state UP mode DEFAULT group default qlen 500
50: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state 
UP mode DEFAULT group default

Configure IP Address on Bond Interface

$ ip addr add 20.1.1.1/24 dev bond1

$ ifconfig bond1
bond1    Link encap:Ethernet  HWaddr 90:b1:1c:f4:9d:60
         inet addr:20.1.1.1  Bcast:0.0.0.0  Mask:255.255.255.0
         inet6 addr: fe80::8480:fcff:fe2f:d93b/64 Scope:Link
         UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
         RX packets:66 errors:0 dropped:1 overruns:0 frame:0
         TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:4224 (4.1 KiB)  TX bytes:15648 (15.2 KiB)

Delete Port from Bond Interface

$ ip link set e101-010-0 nomaster

$ ip link show | grep bond1
49: bond1: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state 
DOWN mode DEFAULT group default

Delete Bond Interface

$ ip link delete bond1

$ ip link show | grep bond1

See Bonding on kernel.org for more information about how to use Linux bond interfaces, and see SONiC Object Library Examples to learn how to program a bond interface using the SONiC Object Library API.

VLAN Bridge Interfaces

Virtual LANs (VLANs) define broadcast domains in a Layer 2 network. Each VLAN is modeled as a separate Linux bridge instance, and is exposed as a Linux interface. A Linux bridge interface uses the MAC address from the first port added as its member port.

The bridge interface is operationally up when at least one of its member interfaces is up. You can assign IP addresses to multiple bridge interfaces to create an inter-VLAN routing domain.

Configure IP Address on Bridge Interface

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br100           8000.90b11cf49d3c       no              e101-001-0.100

$ ip addr add 100.1.1.1 dev br100

$ ifconfig br100
br100    Link encap:Ethernet  HWaddr 90:b1:1c:f4:9d:3c
         inet addr:100.1.1.1  Bcast:0.0.0.0  Mask:255.255.255.255
         inet6 addr: fe80::92b1:1cff:fef4:9d3c/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)