net: ethernet: ti: introduce am65x/j721e gigabit eth switch subsystem driver
The TI AM65x/J721E SoCs Gigabit Ethernet Switch subsystem (CPSW NUSS) has
two ports and provides Ethernet packet communication for the device and can
be configured as an Ethernet switch. CPSW NUSS features: the Reduced
Gigabit Media Independent Interface (RGMII), Reduced Media Independent
Interface (RMII), and the Management Data Input/Output (MDIO) interface for
physical layer device (PHY) management.
The TI am65x/J721E SoCs have integrated two-port Gigabit Ethernet Switch
subsystem into device MCU domain named MCU_CPSW0. One Ethernet port (port 1)
with selectable RGMII and RMII interfaces and an internal Communications
Port Programming Interface (CPPI) port (Host port 0).
Host Port 0 CPPI Packet Streaming Interface interface supports 8 TX
channels and on RX channels operating by TI am654 NAVSS Unified DMA
Peripheral Root Complex (UDMA-P) controller.
Introduced driver provides one linux net_device to user space and supports:
- ifconfig up/down
- MAC address configuration
- ethtool operation:
--driver
--change
--register-dump
--negotiate phy
--statistics
--set-eee phy
--show-ring
--show-channels
- net_device ioctl mii-control
- promisc mode
- Common Platform Time Sync (CPTS) module support:
-- support for SIOCSHWTSTAMP/SIOCGHWTSTAMP net_device ioctls
-- RX : timestamps all received packets (HWTSTAMP_FILTER_ALL)
-- TX : timestamps only PTP packets
-- PTP event messages - Sync, Delay_Req, Pdelay_Req, and Pdelay_Resp
-- IEEE 1588 Annex D, Annex E and Annex F
-- Add ethtool .get_ts_info()
- rx checksum offload support
CPSW NUSS can verify IPv4/IPv6 TCP/UDP packets checksum and fills
csum information for each packet in psdata[2] word:
- BIT(16) CHECKSUM_ERROR - indicates csum error
- BIT(17) FRAGMENT - indicates fragmented packet
- BIT(18) TCP_UDP_N - Indicates TCP packet was detected
- BIT(19) IPV6_VALID, BIT(20) IPV4_VALID - indicates IPv6/IPv4 packet
- BIT(15, 0) CHECKSUM_ADD - This is the value that was summed
during the checksum computation. This value is FFFFh for non fragmented
IPV4/6 UDP/TCP packets with no checksum error.
The CPSW NUSS driver will pass csum info to upper layer as below:
if (ipv4_valid || ipv6_valid) && fragment) then
skb->ip_summed = CHECKSUM_COMPLETE
skb->csum = CHECKSUM_ADD
if (ipv4_valid || ipv6_valid) && not fragment) then
skb->ip_summed = CHECKSUM_UNNECESSARY
if (ipv4_valid || ipv6_valid) && checksum_error) then
skb->ip_summed = CHECKSUM_NONE
else
skb->ip_summed = CHECKSUM_NONE
RX csum offload can be disabled:
ethtool -K <dev> rx-checksum on|off
- tx checksum offload support (disabled by default due to am65x HW bug)
AM65x CPSW NUSS can calculate TX packets checksum and write csum value
in specified location in the packet. How HW should calculate csum
determined in CPPI5 psdata[2] word for each packet:
- BITS 31-24 CHECKSUM_RESULT: This is the packet byte number where
the checksum result will be placed in the egress packet.
- BITS 23-16 CHECKSUM_START_BYTE: This is the packet byte number to
start the checksum calculation on.
- BIT 15 CHECKSUM_INV - When set, a zero checksum value will be
inverted and sent as FFFFh.
- BITS 13-0 CHECKSUM_BYTECOUNT: This is the number of bytes to
calculate the checksum on. The outgoing Ethernet packet will have a
checksum inserted when this value is non-zero. The bit 0 RX_CHECKSUM_EN has
to be set in P0_CONTROL_REG to enable TX csum offload.
TX csum HW offload can be enabled/disabled:
ethtool -K <dev> tx-checksum-ip-generic on|off
- multiq and switch between round robin/prio modes for cppi tx queues
By default Linux network stack does not assume the multiqueue network
device works in fixed priority mode. As result, it will try to dispatch
packets between HW queues fairly - basing on skb hash (and XPS map if
enabled). So, by default, MCU CPSW TX statistic looks like below:
tx_pri0: 14
tx_pri1: 2
tx_pri2: 0
tx_pri3: 12
tx_pri4: 12
tx_pri5: 0
tx_pri6: 306127
tx_pri7: 0
From another side, MCU CPSW HW processes TX queues in fixed priority mode
(7 - high prio) and this is does not corresponds to what Linux network
stack expects as some packets might be delayed, MCU CPSW CPPI interface set
to Round Robin mode (CPPI_P0_Pri_Ctl.p0_rx_ptype) by default.
Fixed priority can be used with multiq, prio and mqprio qdisc's.
Netdev private flag "p0-rx-ptype-rrobin" can be used to switch between
Round Robin and Fixed priority modes:
# ethtool --show-priv-flags eth0
Private flags for eth0:
p0-rx-ptype-rrobin: on
# ethtool --set-priv-flags eth0 p0-rx-ptype-rrobin off
Number of TX DMA channels can be changed using "ethtool -L eth0 tx <N>".
- GRO support
The netif_receive_skb(skb) is replaced with
napi_gro_receive(&common->napi_rx, skb), and the napi_complete() is
replaced with napi_complete_done().
TCP throughput improvement:
-- gro off
ethtool -K eth0 gro off
iperf -s (client: iperf -c <addr> -d -w128K -t30)
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-30.0 sec 2.53 GBytes 723 Mbits/ses
[ 6] 0.0-30.0 sec 1.36 GBytes 388 Mbits/sec
-- gro on
ethtool -K eth0 gso on gro on
iperf -s
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-30.0 sec 3.27 GBytes 935 Mbits/sec
[ 6] 0.0-30.0 sec 1.75 GBytes 501 Mbits/sec
Squashed in this version:
net: ethernet: ti: am65-cpsw-nuss: fix dma mask
net: ethernet: ti: am65-cpsw-nuss: fix checksum offload for IPv4
net: ethernet: ti: am65-cpsw-nuss: fix rx napi add function
net: ethernet: ti: am65-cpsw-nuss: enable gro
net: ethernet: ti: am65-cpsw-nuss: use rnd mac addr if efuse is 0
net: ethernet: ti: am65-cpsw-nuss: add support for J721E SoC
net: ethernet: ti: am65-cpsw-nuss: fix race between netif down and rx napi
net: ethernet: ti: am65-cpsw-nuss: optimize napi rx during netif down
net: ethernet: ti: am65-cpsw-nuss: fix ale port state on netif open
net: ethernet: ti: am65-cpsw-nuss: fix cpsw2g hw stuck on netif down
net: ethernet: ti: am65-cpsw-nuss: clean up am65_cpsw_nuss_ndo_slave_stop()
net: ethernet: ti: am65-cpsw-nuss: enable 10Mbps link speed in rgmii mode
ethernet: ti: am65-cpsw: allow hwts for ptp sync msgs and others
Signed-off-by:
Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by:
Sekhar Nori <nsekhar@ti.com>
Loading
Please sign in to comment