net: enetc: add support for flow control
authorVladimir Oltean <vladimir.oltean@nxp.com>
Fri, 16 Apr 2021 23:42:25 +0000 (02:42 +0300)
committerXiaobo Xie <xiaobo.xie@nxp.com>
Thu, 29 Apr 2021 07:59:58 +0000 (09:59 +0200)
commit9db3ab5991980d441a909144e83ca059df836627
treedb99f02420f9d1ee5905ba37101311f108cd40f8
parent1f74400c0a551813db95ee23fac6ea1000f61e45
net: enetc: add support for flow control

In the ENETC receive path, a frame received by the MAC is first stored
in a 256KB 'FIFO' memory, then transferred to DRAM when enqueuing it to
the RX ring. The FIFO is a shared resource for all ENETC ports, but
every port keeps track of its own memory utilization, on RX and on TX.

There is a setting for RX rings through which they can either operate in
'lossy' mode (where the lack of a free buffer causes an immediate
discard of the frame) or in 'lossless' mode (where the lack of a free
buffer in the ring makes the frame stay longer in the FIFO).

In turn, when the memory utilization of the FIFO exceeds a certain
margin, the MAC can be configured to emit PAUSE frames.

There is enough FIFO memory to buffer up to 3 MTU-sized frames per RX
port while not jeopardizing the other use cases (jumbo frames), and
also not consume bytes from the port TX allocations. Also, 3 MTU-sized
frames worth of memory is enough to ensure zero loss for 64 byte packets
at 1G line rate.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a8648887880f90137f0893aeb1a0abef30858c01)
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
drivers/net/ethernet/freescale/enetc/enetc_hw.h
drivers/net/ethernet/freescale/enetc/enetc_pf.c