This page is a compilation of various items of useful information about how to configure Ethernet interfaces under Linux, how to test the VLAN support, how to use the ethtool support and so forth.
Although, this page contains generic network information for Linux, the targets used for examples are the MAC/GMAC embedded devices.
After booting the kernel, enable or disable the interface manually by using the following command:
ifconfig eth0 up | down
As with setting the MAC address, this is also a three step process:
ifconfig eth0 down ifconfig eth0 mtu <new_value> ifconfig eth0 up
VLAN is an implementation of the 802.1Q VLAN protocol for Linux. With VLAN, it is possible to have Virtual LANs on a single Ethernet cable.
To test that VLAN is working correctly, follow the steps below:
Make sure that the kernel has VLAN support
Create the VLAN interface by defining the vlan ID. To do that, use the vconfig command:
vconfig add eth0 <vlan ID>
where vlan ID is any integer number. The VLAN ID should be same on both machines.
Assign an IP address to the VLAN interface using:
ifconfig eth0,2 <IP address> up.
Ping the remote machine. Ping should be successful without any error.
The VLAN interface has been created successfully. This can be verified by using the ifconfig -a command.
The latest MAC/GMAC cores support IEEE 802.1Q VLAN tag detection for reception frames without VLAN filtering.
The MAC core compares the TIPD field (bytes 13,14 within the frame) and, if they match the value in the VLAN Tag register, the length of the frame is incremented from 1518 to 1522 octets.
Use ethtool to display or change ethernet card settings.
Use the ethtool command to get interface information such as ports, speed, duplex, auto negotiation (ANE) and so forth:
target# ethtool eth0 Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 14 Transceiver: external Auto-negotiation: on Supports Wake-on: d Wake-on: d Current message level: 0x0000003f (63) Link detected: yes
Use ethtool to change the debug level as follows:
target# ethtool -s eth0 msglvl 0xffffwhere 0xffff is the maximum debug level for the drivers.
Note: The driver debug level has been written following the NETIF linux standard message level.
See the Documentation/networking/netif-msg.tx file included in the Linux Kernel source tree for more information.
With STLinux-2.3 and higher, ethtool can dump the mac 10/100/1000 registers. Use the -d option:
target# ethtool -d eth0 MAC 10/100 Registers control reg 0x1010210C addr HI 0x00004718 addr LO 0x12E18000 multicast hash HI 0x00000000 multicast hash LO 0x80000000 MII addr 0x00007440 MII data 00000380 flow control 0x02000002 VLAN1 tag 0x0000FFFF VLAN2 tag 0x0000FFFF mac wakeup frame 0x00000000 mac wakeup crtl 0x00000000 DMA Registers CSR0 0x00002000 CSR1 0x00000000 CSR2 0x00000000 CSR3 0x42C06000 CSR4 0x433D9000 CSR5 0x00660004 CSR6 0x0040A002 CSR7 0x00018041 CSR8 0x00000000 DMA cur tx buf addr 0x00000000 DMA cur rx buf addr 0x00000000
Use the -S option to get extra statistics relating to the ethernet card:
target# ethtool -S eth0 NIC statistics: tx_underflow: 0 tx_carrier: 0 tx_losscarrier: 0 tx_heartbeat: 0 tx_deferred: 0 tx_vlan: 0 tx_jabber: 0 tx_frame_flushed: 0 rx_desc: 0 rx_partial: 0 rx_runt: 0 rx_toolong: 0 rx_collision: 0 rx_crc: 0 rx_lenght: 0 rx_mii: 0 rx_multicast: 0 rx_overflow: 0 rx_watchdog: 0 rx_filter: 0 rx_dropped: 0 rx_bytes: 0 tx_bytes: 0 tx_irq_n: 0 rx_irq_n: 0 tx_undeflow_irq: 0 tx_threshold: 32 tx_process_stopped_irq: 0 tx_jabber_irq: 0 rx_overflow_irq: 0 rx_buf_unav_irq: 0 rx_process_stopped_irq: 0 rx_watchdog_irq: 0 tx_early_irq: 0 fatal_bus_error_irq: 0 rx_poll_n: 0
The latest MAC and GMAC embedded devices allow flow control in Full Duplex by using the PAUSE operation and control frame transmission. They also support flow control in Half Duplex by using back pressure.
See the driver's command line options for details about how to change the pause value and turn-on flow-control.
You can change the pause parameters by using ethtool, as shown below:
ethtool -A ethX [autoneg on|off] [rx on|off] [tx on|off]
Use ethtool to get offload information, as follows:
target# ethtool -k eth0
Offload parameters for eth0:
rx-checksumming: on
tx-checksumming: on
scatter-gather: on
tcp segmentation offload: off
udp fragmentation offload: off
generic segmentation offload: offTurn on scatter-gather (which is enabled by default for the stmmac driver):
target# ethtool -K eth0 sg onTurn on rx or tx checksumming:
target# ethtool -K eth0 rx on target# ethtool -K eth0 tx on
Multicast packets send the same data to multiple network devices at the same time within the same packet stream. A common situation in which Multicast is used is to distribute real time audio and video.
To use multicast, the kernel configuration requires the CONFIG_IP_MULTICAST option to be set.
Use ifconfig to enable and disable all-multicast mode.
If allmulti is enabled, the ifconfig eth0 output displays the keyword ALLMULTI in the second line.
First, make sure that the kernel does not ignore all ICMP ECHO and TIMESTAMP requests sent to it using either broadcast or multicast.
On the target, execute the following:
target# echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcastsThis sets all class D (that is, multicast) IP routes to use "eth0":
target# route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0To join a multicast group, execute the following:
target# ./mjoin eth0 224.1.0.37The mjoin C source can be obtained from here.
Ping multicast IP address:
host# ping -r -I eth0 224.1.0.37To display the multicast group membership information on the target:
target# netstat -g IPv6/IPv4 Group Memberships Interface RefCnt Group --------------- ------ --------------------- lo 1 224.0.0.1 eth0 1 224.1.0.37 eth0 1 224.0.0.1 <code>