cgem
—
Cadence GEM Gigabit Ethernet driver
To compile this driver into the kernel, place the following lines in your kernel
configuration file:
device ether
device miibus
device cgem
The cgem
driver provides support for the Cadence GEM
(Gigabit Ethernet MAC). The Cadence GEM is used in some SoC (System on a Chip)
devices such as the Xilinx Zynq-7000, the Xilinx Zynq UltraScale+, and the
SiFive HiFive Unleashed.
The cgem
driver supports the following
media types:
autoselect
- Enable autoselection of the media type and options. The user can manually
override the autoselected mode using
ifconfig(8)
or by adding media options to
rc.conf(5).
10baseT/UTP
- Set 10Mbps operation. The
ifconfig(8)
mediaopt
option can also be used to select either
full-duplex
or half-duplex
modes.
100baseTX
- Set 100Mbps (Fast Ethernet) operation. The
ifconfig(8)
mediaopt
option can also be used to select either
full-duplex
or half-duplex
modes.
1000baseT
- Set 1000Mbps (Gigabit Ethernet) operation over twisted pair. The GEM
supports 1000Mbps in
full-duplex
mode only.
The cgem
driver supports the following
media options:
full-duplex
- Force full-duplex operation.
half-duplex
- Force half-duplex operation.
The driver provides support for TCP/UDP/IP checksum offloading
(although disabled by default). The device and driver also support 1536-byte
frames for VLANs (vlanmtu).
The following variables are available as both
sysctl(8)
variables and
loader(8)
tunables:
- dev.cgem.%d.rxbufs
- The number of receive buffers allocated to the hardware. The default value
is 256. The maximum value is 511. If this number is increased while the
interface is UP, it will not take effect until the next packet is
received. If this number is decreased while the interface is UP, buffers
will not be immediately removed from the receive buffer ring but the
number of buffers will decrease as packets are received until it reaches
the new value.
- dev.cgem.%d.rxhangwar
- This tunable enables a work-around to recover from receive hangs. The
default value is 1. Set to 0 to disable the work-around.
The following read-only variables are available as
sysctl(8)
variables:
- dev.cgem.%d._rxoverruns
- This variable counts the number of receive packet buffer overrun
interrupts.
- dev.cgem.%d._rxnobufs
- This variable counts the number of interrupts due to the GEM buffer ring
going empty.
- dev.cgem.%d._rxdmamapfails
- This variable is the number of times bus_dmamap_load_mbuf_sg(9) failed in
the receive path.
- dev.cgem.%d._txfull
- The number of times the GEM's transmit ring was full.
- dev.cgem.%d._txdmamapfails
- This variable is the number of times bus_dmamap_load_mbuf_sg(9) failed in
the transmit path.
- dev.cgem.%d._txdefrags
- This variable is the number of times the driver needed to call m_defrag(9)
because a packet queued for transmit had too many DMA segments.
- dev.cgem.%d._txdefragfails
- This variable is the number of times
m_defrag(9)
failed.
- dev.cgem.%d.stats.*
- The following variables are useful MAC counters supplied by the
hardware:
- dev.cgem.%d.stats.tx_bytes
- A 64-bit counter of the number of bytes transmitted in frames without
error.
- dev.cgem.%d.stats.tx_frames
- Counter of frames transmitted without error excluding pause frames.
- dev.cgem.%d.stats.tx_frames_bcast
- Counter of broadcast frames transmitted without error excluding pause
frames.
- dev.cgem.%d.stats.tx_frames_multi
- Counter of multicast frames transmitted without error excluding pause
frames.
- dev.cgem.%d.stats.tx_frames_pause
- Counter of pause frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_64b
- Counter of 64 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_65to127b
- Counter of 65 to 127 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_128to255b
- Counter of 128 to 255 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_256to511b
- Counter of 256 to 511 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_512to1023b
- Counter of 512 to 1023 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_frames_1024to1536b
- Counter of 1024 to 1536 byte frames transmitted without error.
- dev.cgem.%d.stats.tx_under_runs
- Counter of frames not transmitted due to a transmit underrun.
- dev.cgem.%d.stats.tx_single_collisn
- Counter of frames experiencing a single collision before being
successfully transmitted.
- dev.cgem.%d.stats.tx_multi_collisn
- Counter of frames experiencing between 2 and 15 collisions before being
successfully transmitted.
- dev.cgem.%d.stats.tx_excsv_collisn
- Counter of frames that failed to transmit because they experienced 16
collisions.
- dev.cgem.%d.stats.tx_late_collisn
- Counter of frames that experienced a late collision.
- dev.cgem.%d.stats.tx_deferred_frames
- Counter of frames experiencing deferral due to carrier sense being active
on their first attempt at transmission.
- dev.cgem.%d.stats.tx_carrier_sense_errs
- Counter of frames transmitted where carrier sense was not seen during
transmission or where carrier sense was deasserted after being asserted in
a transmit frame without collision.
- dev.cgem.%d.stats.rx_bytes
- A 64-bit counter of bytes received without error excluding pause
frames.
- dev.cgem.%d.stats.rx_frames
- Counter of frames received without error excluding pause frames.
- dev.cgem.%d.stats.rx_frames_bcast
- Counter of broadcast frames receive without error excluding pause
frames.
- dev.cgem.%d.stats.rx_frames_multi
- Counter of multicast frames receive without error excluding pause
frames.
- dev.cgem.%d.stats.rx_frames_pause
- Counter of pause frames recevied without error.
- dev.cgem.%d.stats.rx_frames_64b
- Counter of 64-byte frames received without error.
- dev.cgem.%d.stats.rx_frames_65to127b
- Counter of 65 to 127 byte frames received without error.
- dev.cgem.%d.stats.rx_frames_128to255b
- Counter of 128 to 255 byte frames received without error.
- dev.cgem.%d.stats.rx_frames_256to511b
- Counter of 256 to 511 byte frames received without error.
- dev.cgem.%d.stats.rx_frames_512to1023b
- Counter of 512 to 1023 byte frames received without error.
- dev.cgem.%d.stats.rx_frames_1024to1536b
- Counter of 1024 to 1536 byte frames received without error.
- dev.cgem.%d.stats.rx_frames_undersize
- Counter of frames received less than 64 bytes in length that do not also
have either a CRC error or an alignment error.
- dev.cgem.%d.stats.rx_frames_oversize
- Counter of frames received exceeding 1536 bytes and do not also have
either a CRC error or an alignment error.
- dev.cgem.%d.stats.rx_frames_jabber
- Counter of frames received exceeding 1536 bytes and also have either a CRC
error, an alignment error, or a receive symbol error.
- dev.cgem.%d.stats.rx_frames_fcs_errs
- Counter of frames received with a bad CRC and are between 64 and 1536
bytes.
- dev.cgem.%d.stats.rx_frames_length_errs
- Counter of frames received that are shorter than that extracted from the
length field.
- dev.cgem.%d.stats.rx_symbol_errs
- Counter of receive symbol errors.
- dev.cgem.%d.stats.rx_align_errs
- Counter of received frames that are not an integral number of bytes.
- dev.cgem.%d.stats.rx_resource_errs
- Counter of frames successfully receive by the MAC but could not be copied
to memory because no receive buffer was available.
- dev.cgem.%d.stats.rx_overrun_errs
- Counter of frames that are address recognized but were not copied to
memory due to a receive overrun.
- dev.cgem.%d.stats.rx_frames_ip_hdr_csum_errs
- Counter of frames discarded due to an incorrect IP header checksum when
checksum offloading is enabled.
- dev.cgem.%d.stats.rx_frames_tcp_csum_errs
- Counter of frames discarded due to an incorrect TCP checksum when checksum
offloading is enabled.
- dev.cgem.%d.stats.rx_frames_udp_csum_errs
- Counter of frames discarded due to an incorrect UDP checksum when checksum
offloading is enabled.
The cgem
device driver first appeared in
FreeBSD 10.0.
The GEM can perform TCP/UDP/IP checksum offloading. However, when transmit
checksum offloading is enabled, the GEM generates and replaces checksums for
all packets it transmits. In a system that is forwarding packets, the device
could potentially correct the checksum of packet that was corrupted in
transit. For this reason, checksum offloading is disabled by default but can
be enabled using ifconfig(8).
When receive checksum offloading is enabled, the device will
discard packets with bad TCP/UDP/IP checksums. The bad packets will not be
counted in any
netstat(1)
statistics. There are
sysctl(8)
variables that count packets discarded by the hardware (see below).
The GEM used in the Zynq-7000 has a bug such that the receiver can
potentially freeze up under a high load. The issue is described in sec. 16.7
"Known Issues" of the Zynq-7000 SoC Technical Reference Manual
(Xilinx UG585 v1.7). The cgem
driver implements the
work-around suggested in the manual. It is believed that the bug does not
exist in the Zynq UltraScale+ and SiFive SoCs so the work-around is disabled
in those instances and enabled in all others. The work-around can be
disabled by setting the dev.cgem.%d.rxhangwar
sysctl(8)
variable to 0.