Networking and Ethernet devices
A short network guide...
|
|
This page collects a lot of useful information about how to configure Ethernet interfaces under Linux, how to test the VLAN support, how to use the ethtool support etc.
Although, this page collects generic network information for Linux, the targets used as example are the MAC/GMAC embedded devices.
Enable/Disable the interface
After booting the kernel, it's possible to manually enable/disable the interface by usig the following command:
ifconfig eth0 down/up
How to set the MAC Address
- Bring down the interface by
ifconfig eth0 down.
- Assign a MAC address by
ifconfig hw ether eth0 <new_MAC_address>.
- Bring up the interface by
ifconfig eth0 up.
How to modify the MTU
ifconfig eth0 down
ifconfig eth0 mtu <new_value>
ifconfig eth0 up
VLAN support
VLAN is an implementation of the 802.1Q VLAN protocol for Linux. It allows one to have Virtual LANs on a single Ethernet cable.
To test it, follow the steps belows:
- Make sure that the kernel has the VLAN support
- Create the VLAN interface by adding vlan ID. To do that you have to use the vconfig command as shown below:
vconfig add eth0 <vlan ID> where vlan ID is any integer number. Vlan ID on both the machines should be same
- Assign IP address to the vlan interface using
ifconfig eth0,2 <IP address> up
- Ping the remote machine
- So, the VLAN interface should be created successfully. This can be verified by using
ifconfig -a command.
- Ping should be successful without any error.
Hw notes
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 with the value in the VLAN Tag register, the length of the frame is incremented from 1518 to 1522 octets.
Ethtool Support
Display or change ethernet card settings
How to get general driver information
It's possible to get the interface information related to link such as ports, speed, duplex, auto negotiation (ANE) etc. are displayed correctly by using:
root@:~# 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
|
|
|
How to change the debug level
ethtool -s eth0 msglvl 0xffff
|
|
|
Where 0xffff is the maximum debug level for these drivers.
Note: the driver debug level has been written following the NETIF linux standard message level.
Please see the Documentation/networking/netif-msg.tx file included in the Linux Kernel source tree.
Dump registers
Starting from the STLinux-2.3, Ethtool has been patched in order to dump the mac 10/100/1000 registers.
root@:~# 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
|
|
|
Get extra statistics
root@:~# 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
|
|
|
Flow Control
Latest MAC and GMAC Embedded devices allow flow control in Full Duplex by using the PAUSE operation and control frame transmission. They also support FC in Half Duplex using back pressure.
See the driver's command line options for details about how to change the pause value and turn-on flow-control.
It's possible to change the pause parameters by using ethtool as shown below:
ethtool -A ethX [autoneg on|off] [rx on|off] [tx on|off]
|
|
|
Offload parameters
Get offload information
# 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: off
|
|
|
Turn-on scatter-gather (enabled by default for the stmmac driver)
Turn-on rx/tx checksumming
ethtool -K eth0 rx on
ethtool -K eth0 tx on
|
|
|
Multicast
Multicast packets are used to send the same data to
multiple network devices at the same time, with the same packet stream.
One common situation in which it is used is when it is necessary to distribute real time audio and video.
Configuring the Kernel
Kernel configuration requires CONFIG_IP_MULTICAST.
Enable/disable all-multicast mode with ifconfig
- Disable promisc by running
ifconfig eth0 -promisc
- Enable the allmulti mode run the command
ifconfig eth0 allmulti
- Ping some multicast IP address from remote machine:
ping -I eth0 <multicast_ip_addr>
- On the target enabled with allmulti mode check for RX packets count
- Do allmulti off by running
ifconfig eth0 -allmulti on target.
As expected results: if allmulti is enabled, ifconfig eth0 output should show ALLMULTI in second line
Testing multicast
Make sure the kernel will not ignore all ICMP ECHO and
TIMESTAMP requests sent to it via broadcast/multicast.
So executing on the target the following command:
target# echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
|
|
|
Sets all of the class D (multicast) IP routes to go via "eth0":
target# route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
|
|
|
Join a multicast group:
target# ./mjoin eth0 224.1.0.37
|
|
|
Get here the mjoin C source.
Ping multicast ip address:
host# ping -r -I eth0 224.1.0.37
|
|
|
To display 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
|
|
|
|