-
Notifications
You must be signed in to change notification settings - Fork 35
Interfaces
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. OpenSwitch allocates an ifindex
(interface index) for each Linux interface. The ifindex
value is used in CPS APIs to refer to a Linux interface.
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 fan-out ports (0 to 9)
vvv - Specifies the VLAN ID number (0 to 4095)
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 "tap device" 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).
The OPX 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 CPS API.
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.
$ 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
$ ip addr add 10.1.1.1/24 dev e101-001-0
$ ip -6 addr add 2000::1/64 dev e101-001-0
$ 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 Programming examples to learn how to program physical port configuration using the CPS API.
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 opx-config-fanout
command to fanout and fanin a capable port. Refer to this page for more details about its usage.
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 LAG. The term LAG refers to an NPU configuration, while the term bond interface refers to a Linux configuration.
A Linux bond interface must be up before you can add member ports.
$ ip link add bond1 type bond mode balance-rr miimon 50
$ 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
$ ip link set e101-010-0 master bond1
$ 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
$ 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)
$ 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
$ ip link delete bond1
$ ip link show | grep bond1
See Bonding on kernel.org for more information about how to use Linux bond interfaces. You may also use the opx-config-lag utility to configure a bond. The source code for opx-config-lag also serves as an example for how to program a bond interface using the CPS API.
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. For more information about configuring Layer 2 VLANs, refer to the Layer 2 portion of this guide.
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.
$ 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)
A port profile determines the enabled front-panel ports and their supported breakout modes (where applicable). Change the port profile on a switch to customize uplink port operation and the availability of uplink and front-panel data ports.
Here is an example of CPS API usage surrounding switch profiles, using the base-switch/switching-entities/switching-entity-object attribute.
#!/bin/bash
# Copyright
# Script to display and set switch profiles
# For an explanation of switch profiles, see ???
#
# Usage:
#
# opx-switch-profile <switch-id>
# - Show current profile and profile on next boot
#
# opx-switch-profile <switch-id> --list
# - Show all available profiles
#
# opx-switch-profile <switch-id> <profile-name>
# - Set profile to take effect on next boot
function usage()
{
# Show brief command usage
echo "$0: <switch-id> [ --list | <profile-name> ]"
exit 1
}
if [ $# -lt 1 ]; then
usage
fi
if [ $# -eq 1 ]; then
# Show profiles
# Show profile currently in effect
echo -n "Current profile: "
cps_get_oid.py -qua observed base-switch/switching-entities/switching-entity switch-id=$1 | grep 'switch-profile' | sed 's/^.* = //'
# Show profile that will be in effect on next boot
echo -n "Profile on next boot: "
cps_get_oid.py -db -qua target base-switch/switching-entities/switching-entity switch-id=$1 | grep 'switch-profile' | sed 's/^.* = //'
elif [ $# -eq 2 ]; then
if [ $2 = '--list' ]; then
# Show available profiles
cps_get_oid.py -qua observed base-switch/switching-entities/switching-entity switch-id=$1 | grep 'supported-profiles' | sed 's/^.* = //'
else
# Set profile to take effect on next boot
cps_set_oid.py -oper set -db -qua target -commit-event base-switch/switching-entities/switching-entity switch-id=$1 switch-profile=$2 >& /dev/null
fi
else
usage
fi
© 2019 OpenSwitch project. All information is contributed to and made available by OPX under the Creative Commons Attribution 4.0 International License (available at http://creativecommons.org/licenses/by/4.0/).
- Home
- System overview
- Software releases
- Hardware support
- FAQs
- Install
- Build
- Configure
- Develop
- Administer
- Troubleshoot
- Software compatibility
- Contribute
- DevOps
- Join