mbox series

[net-next,v4,00/11] net: ethernet: ti: add networking support for k3 am65x/j721e soc

Message ID 20200317072739.23950-1-grygorii.strashko@ti.com
Headers show
Series net: ethernet: ti: add networking support for k3 am65x/j721e soc | expand

Message

Grygorii Strashko March 17, 2020, 7:27 a.m. UTC
Hi

This v4 series adds basic networking support support TI K3 AM654x/J721E SoC which
have integrated Gigabit Ethernet MAC (Media Access Controller) into device MCU
domain and named MCU_CPSW0 (CPSW2G NUSS).

Formally TRMs refer CPSW2G NUSS as two-port Gigabit Ethernet Switch subsystem
with port 0 being the CPPI DMA host port and port 1 being the external Ethernet
port, but for 1 external port device it's just Port 0 <-> ALE <-> Port 1 and it's
rather device with HW filtering capabilities then actually switching device.
It's expected to have similar devices, but with more external ports.

The new Host port 0 Communications Port Programming Interface (CPPI5) is
operating by TI AM654x/J721E NAVSS Unified DMA Peripheral Root Complex (UDMA-P)
controller [1].

The CPSW2G contains below modules for which existing code is re-used:
 - MAC SL: cpsw_sl.c
 - Address Lookup Engine (ALE): cpsw_ale.c, basically compatible with K2 66AK2E/G
 - Management Data Input/Output interface (MDIO): davinci_mdio.c, fully 
   compatible with TI AM3/4/5 devices

Basic features supported by CPSW2G NUSS driver:
 - VLAN support, 802.1Q compliant, Auto add port VLAN for untagged frames on
   ingress, Auto VLAN removal on egress and auto pad to minimum frame size.
 - multicast filtering
 - promisc mode
 - TX multiq support in Round Robin or Fixed priority modes
 - RX checksum offload for non-fragmented IPv4/IPv6 TCP/UDP packets
 - TX checksum offload support for IPv4/IPv6 TCP/UDP packets (J721E only).

Features under development:
 - Support for IEEE 1588 Clock Synchronization. The CPSW2G NUSS includes new
   version of Common Platform Time Sync (CPTS)
 - tc-mqprio: priority level Quality Of Service (QOS) support (802.1p)
 - tc-cbs: Support for Audio/Video Bridging (P802.1Qav/D6.0) HW shapers
 - tc-taprio: IEEE 802.1Qbv/D2.2 Enhancements for Scheduled Traffic
 - frame preemption: IEEE P902.3br/D2.0 Interspersing Express Traffic, 802.1Qbu
 - extended ALE features: classifier/policers, auto-aging

Patches 1-6 are intended for netdev, Patches 7-11 are intended for K3 Platform
tree and provided here for testing purposes.

Changes in v4:
 - fixed minor comments from Jakub Kicinski <kuba@kernel.org>
 - dependencies resolved: required phy-rmii-sel changes [2] queued for merge
   except one [3] which is included in this series with Kishon's ask.

Changes in v3:
 - add ARM64 defconfig changes for testing purposes
 - fixed DT yaml definition
 - fixed comments from Jakub Kicinski <kuba@kernel.org>

Changes in v2:
 - fixed DT yaml definition
 - fixed comments from David Miller

v3: https://patchwork.ozlabs.org/cover/1254568/
v2: https://patchwork.ozlabs.org/cover/1250674/
v1: https://lwn.net/Articles/813087/

TRMs:
 AM654: http://www.ti.com/lit/ug/spruid7e/spruid7e.pdf
 J721E: http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf

Preliminary documentation can be found at:
 http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components/Kernel/Kernel_Drivers/Network/K3_CPSW2g.html

[1] https://lwn.net/Articles/808030/
[2] https://lkml.org/lkml/2020/2/22/100
[3] https://lkml.org/lkml/2020/3/3/724

Grygorii Strashko (11):
  phy: ti: gmii-sel: simplify config dependencies between net drivers
    and gmii phy
  net: ethernet: ti: ale: fix seeing unreg mcast packets with promisc
    and allmulti disabled
  net: ethernet: ti: ale: add support for mac-only mode
  net: ethernet: ti: ale: am65: add support for default thread cfg
  dt-binding: ti: am65x: document mcu cpsw nuss
  net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
  arm64: dts: ti: k3-am65-mcu: add cpsw nuss node
  arm64: dts: k3-am654-base-board: add mcu cpsw nuss pinmux and phy defs
  arm64: dts: ti: k3-j721e-mcu: add mcu cpsw nuss node
  arm64: dts: ti: k3-j721e-common-proc-board: add mcu cpsw nuss pinmux
    and phy defs
  arm64: defconfig: ti: k3: enable dma and networking

 .../bindings/net/ti,k3-am654-cpsw-nuss.yaml   |  226 ++
 arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi       |   49 +
 arch/arm64/boot/dts/ti/k3-am65.dtsi           |    1 +
 .../arm64/boot/dts/ti/k3-am654-base-board.dts |   42 +
 .../dts/ti/k3-j721e-common-proc-board.dts     |   43 +
 .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   49 +
 arch/arm64/boot/dts/ti/k3-j721e.dtsi          |    1 +
 arch/arm64/configs/defconfig                  |    3 +
 drivers/net/ethernet/ti/Kconfig               |   20 +-
 drivers/net/ethernet/ti/Makefile              |    3 +
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c   |  747 +++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c      | 1965 +++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.h      |  143 ++
 drivers/net/ethernet/ti/cpsw_ale.c            |   38 +
 drivers/net/ethernet/ti/cpsw_ale.h            |    4 +
 drivers/net/ethernet/ti/k3-udma-desc-pool.c   |  126 ++
 drivers/net/ethernet/ti/k3-udma-desc-pool.h   |   30 +
 drivers/phy/ti/Kconfig                        |    3 -
 18 files changed, 3488 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
 create mode 100644 drivers/net/ethernet/ti/am65-cpsw-ethtool.c
 create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.c
 create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.h
 create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.c
 create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.h

Comments

Peter Ujfalusi March 19, 2020, 11:46 a.m. UTC | #1
Hi Grygorii,

On 17/03/2020 9.27, Grygorii Strashko wrote:
> The TI AM65x/J721E SoCs Gigabit Ethernet Switch subsystem (CPSW2G NUSS) has
> two ports - One Ethernet port (port 1) with selectable RGMII and RMII
> interfaces and an internal Communications Port Programming Interface (CPPI)
> port (Host port 0) and with ALE in between. It also contains
>  - Management Data Input/Output (MDIO) interface for physical layer device
> (PHY) management;
>  - Updated Address Lookup Engine (ALE) module;
>  - (TBD) New version of Common platform time sync (CPTS) module.
> 
> On the TI am65x/J721E SoCs CPSW NUSS Ethernet subsystem into device MCU
> domain named MCU_CPSW0.
> 
> Host Port 0 CPPI Packet Streaming Interface interface supports 8 TX
> channels and one RX channels operating by TI am654 NAVSS Unified DMA
> Peripheral Root Complex (UDMA-P) controller.
> 
> Introduced driver provides standard 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
>    --set-channels
>  - net_device ioctl mii-control
>  - promisc mode
> 
>  - rx checksum offload for non-fragmented IPv4/IPv6 TCP/UDP packets.
>    The 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.
> 
>    RX csum offload can be disabled:
> 	 ethtool -K <dev> rx-checksum on|off
> 
>  - tx checksum offload support for IPv4/IPv6 TCP/UDP packets (J721E only).
>    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
>    using Netdev private flag "p0-rx-ptype-rrobin" 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 napi_gro_receive() and napi_complete_done() are used.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
>  drivers/net/ethernet/ti/Kconfig             |   19 +-
>  drivers/net/ethernet/ti/Makefile            |    3 +
>  drivers/net/ethernet/ti/am65-cpsw-ethtool.c |  747 +++++++
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 1965 +++++++++++++++++++
>  drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  143 ++
>  drivers/net/ethernet/ti/k3-udma-desc-pool.c |  126 ++
>  drivers/net/ethernet/ti/k3-udma-desc-pool.h |   30 +

I would rather loose the 'udma' from the name and API. It is more like
CPPI5 descriptor pool than UDMA. UDMA is just happen to use CPPI5.
Probably ti-cppi5-desc-pool?

>  7 files changed, 3031 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>  create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.c
>  create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.h
>  create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.c
>  create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.h

> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index 8a6ca16eee3b..89cec778cf2d 100644
> --- a/drivers/net/ethernet/ti/Kconfig
> +++ b/drivers/net/ethernet/ti/Kconfig
> @@ -6,7 +6,7 @@
>  config NET_VENDOR_TI
>  	bool "Texas Instruments (TI) devices"
>  	default y
> -	depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE
> +	depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || ARCH_K3
>  	---help---
>  	  If you have a network (Ethernet) card belonging to this class, say Y.
>  
> @@ -31,7 +31,7 @@ config TI_DAVINCI_EMAC
>  
>  config TI_DAVINCI_MDIO
>  	tristate "TI DaVinci MDIO Support"
> -	depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
> +	depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
>  	select PHYLIB
>  	---help---
>  	  This driver supports TI's DaVinci MDIO module.
> @@ -95,6 +95,21 @@ config TI_CPTS_MOD
>  	imply PTP_1588_CLOCK
>  	default m
>  
> +config TI_K3_AM65_CPSW_NUSS
> +	tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
> +	depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
> +	select TI_DAVINCI_MDIO
> +	imply PHY_TI_GMII_SEL
> +	help
> +	  This driver supports TI K3 AM654/J721E CPSW2G Ethernet SubSystem.
> +	  The two-port Gigabit Ethernet MAC (MCU_CPSW0) subsystem provides
> +	  Ethernet packet communication for the device: One Ethernet port
> +	  (port 1) with selectable RGMII and RMII interfaces and an internal
> +	  Communications Port Programming Interface (CPPI) port (port 0).
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called ti-am65-cpsw-nuss.
> +
>  config TI_KEYSTONE_NETCP
>  	tristate "TI Keystone NETCP Core Support"
>  	select TI_DAVINCI_MDIO
> diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
> index ecf776ad8689..6362a9b0bb8a 100644
> --- a/drivers/net/ethernet/ti/Makefile
> +++ b/drivers/net/ethernet/ti/Makefile
> @@ -23,3 +23,6 @@ obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
>  keystone_netcp-y := netcp_core.o cpsw_ale.o
>  obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
>  keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.o
> +
> +obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
> +ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-udma-desc-pool.o

Would not be better to have the desc-pool (silent) Kconfig selectable?
The not yet upstream icssg-prueth also needs the same desc-pool library
as cpsw.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Grygorii Strashko March 19, 2020, 1:09 p.m. UTC | #2
On 19/03/2020 13:46, Peter Ujfalusi wrote:
> Hi Grygorii,
> 
> On 17/03/2020 9.27, Grygorii Strashko wrote:
>> The TI AM65x/J721E SoCs Gigabit Ethernet Switch subsystem (CPSW2G NUSS) has
>> two ports - One Ethernet port (port 1) with selectable RGMII and RMII
>> interfaces and an internal Communications Port Programming Interface (CPPI)
>> port (Host port 0) and with ALE in between. It also contains
>>   - Management Data Input/Output (MDIO) interface for physical layer device
>> (PHY) management;
>>   - Updated Address Lookup Engine (ALE) module;
>>   - (TBD) New version of Common platform time sync (CPTS) module.
>>
>> On the TI am65x/J721E SoCs CPSW NUSS Ethernet subsystem into device MCU
>> domain named MCU_CPSW0.
>>
>> Host Port 0 CPPI Packet Streaming Interface interface supports 8 TX
>> channels and one RX channels operating by TI am654 NAVSS Unified DMA
>> Peripheral Root Complex (UDMA-P) controller.
>>
>> Introduced driver provides standard 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
>>     --set-channels
>>   - net_device ioctl mii-control
>>   - promisc mode
>>
>>   - rx checksum offload for non-fragmented IPv4/IPv6 TCP/UDP packets.
>>     The 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.
>>
>>     RX csum offload can be disabled:
>> 	 ethtool -K <dev> rx-checksum on|off
>>
>>   - tx checksum offload support for IPv4/IPv6 TCP/UDP packets (J721E only).
>>     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
>>     using Netdev private flag "p0-rx-ptype-rrobin" 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 napi_gro_receive() and napi_complete_done() are used.
>>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>> ---
>>   drivers/net/ethernet/ti/Kconfig             |   19 +-
>>   drivers/net/ethernet/ti/Makefile            |    3 +
>>   drivers/net/ethernet/ti/am65-cpsw-ethtool.c |  747 +++++++
>>   drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 1965 +++++++++++++++++++
>>   drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  143 ++
>>   drivers/net/ethernet/ti/k3-udma-desc-pool.c |  126 ++
>>   drivers/net/ethernet/ti/k3-udma-desc-pool.h |   30 +
> 
> I would rather loose the 'udma' from the name and API. It is more like
> CPPI5 descriptor pool than UDMA. UDMA is just happen to use CPPI5.
> Probably ti-cppi5-desc-pool?

ok. I'll update and re-send

> 
>>   7 files changed, 3031 insertions(+), 2 deletions(-)
>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.c
>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.h
>>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.c
>>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.h
> 
>> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
>> index 8a6ca16eee3b..89cec778cf2d 100644
>> --- a/drivers/net/ethernet/ti/Kconfig
>> +++ b/drivers/net/ethernet/ti/Kconfig
>> @@ -6,7 +6,7 @@
>>   config NET_VENDOR_TI
>>   	bool "Texas Instruments (TI) devices"
>>   	default y
>> -	depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE
>> +	depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || ARCH_K3
>>   	---help---
>>   	  If you have a network (Ethernet) card belonging to this class, say Y.
>>   
>> @@ -31,7 +31,7 @@ config TI_DAVINCI_EMAC
>>   
>>   config TI_DAVINCI_MDIO
>>   	tristate "TI DaVinci MDIO Support"
>> -	depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
>> +	depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
>>   	select PHYLIB
>>   	---help---
>>   	  This driver supports TI's DaVinci MDIO module.
>> @@ -95,6 +95,21 @@ config TI_CPTS_MOD
>>   	imply PTP_1588_CLOCK
>>   	default m
>>   
>> +config TI_K3_AM65_CPSW_NUSS
>> +	tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
>> +	depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
>> +	select TI_DAVINCI_MDIO
>> +	imply PHY_TI_GMII_SEL
>> +	help
>> +	  This driver supports TI K3 AM654/J721E CPSW2G Ethernet SubSystem.
>> +	  The two-port Gigabit Ethernet MAC (MCU_CPSW0) subsystem provides
>> +	  Ethernet packet communication for the device: One Ethernet port
>> +	  (port 1) with selectable RGMII and RMII interfaces and an internal
>> +	  Communications Port Programming Interface (CPPI) port (port 0).
>> +
>> +	  To compile this driver as a module, choose M here: the module
>> +	  will be called ti-am65-cpsw-nuss.
>> +
>>   config TI_KEYSTONE_NETCP
>>   	tristate "TI Keystone NETCP Core Support"
>>   	select TI_DAVINCI_MDIO
>> diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
>> index ecf776ad8689..6362a9b0bb8a 100644
>> --- a/drivers/net/ethernet/ti/Makefile
>> +++ b/drivers/net/ethernet/ti/Makefile
>> @@ -23,3 +23,6 @@ obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
>>   keystone_netcp-y := netcp_core.o cpsw_ale.o
>>   obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
>>   keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.o
>> +
>> +obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
>> +ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-udma-desc-pool.o
> 
> Would not be better to have the desc-pool (silent) Kconfig selectable?
> The not yet upstream icssg-prueth also needs the same desc-pool library
> as cpsw.
>

I'd prefer not to add new Kconfig options unless required.
This driver simply not work without it, so no Kconfig option for now.
Peter Ujfalusi March 19, 2020, 1:11 p.m. UTC | #3
Hi Grygorii,

On 19/03/2020 15.09, Grygorii Strashko wrote:
> 
> 
> On 19/03/2020 13:46, Peter Ujfalusi wrote:
>> Hi Grygorii,
>>
>> On 17/03/2020 9.27, Grygorii Strashko wrote:
>>> The TI AM65x/J721E SoCs Gigabit Ethernet Switch subsystem (CPSW2G
>>> NUSS) has
>>> two ports - One Ethernet port (port 1) with selectable RGMII and RMII
>>> interfaces and an internal Communications Port Programming Interface
>>> (CPPI)
>>> port (Host port 0) and with ALE in between. It also contains
>>>   - Management Data Input/Output (MDIO) interface for physical layer
>>> device
>>> (PHY) management;
>>>   - Updated Address Lookup Engine (ALE) module;
>>>   - (TBD) New version of Common platform time sync (CPTS) module.
>>>
>>> On the TI am65x/J721E SoCs CPSW NUSS Ethernet subsystem into device MCU
>>> domain named MCU_CPSW0.
>>>
>>> Host Port 0 CPPI Packet Streaming Interface interface supports 8 TX
>>> channels and one RX channels operating by TI am654 NAVSS Unified DMA
>>> Peripheral Root Complex (UDMA-P) controller.
>>>
>>> Introduced driver provides standard 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
>>>     --set-channels
>>>   - net_device ioctl mii-control
>>>   - promisc mode
>>>
>>>   - rx checksum offload for non-fragmented IPv4/IPv6 TCP/UDP packets.
>>>     The 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.
>>>
>>>     RX csum offload can be disabled:
>>>      ethtool -K <dev> rx-checksum on|off
>>>
>>>   - tx checksum offload support for IPv4/IPv6 TCP/UDP packets (J721E
>>> only).
>>>     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
>>>     using Netdev private flag "p0-rx-ptype-rrobin" 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 napi_gro_receive() and napi_complete_done() are
>>> used.
>>>
>>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>>> ---
>>>   drivers/net/ethernet/ti/Kconfig             |   19 +-
>>>   drivers/net/ethernet/ti/Makefile            |    3 +
>>>   drivers/net/ethernet/ti/am65-cpsw-ethtool.c |  747 +++++++
>>>   drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 1965 +++++++++++++++++++
>>>   drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  143 ++
>>>   drivers/net/ethernet/ti/k3-udma-desc-pool.c |  126 ++
>>>   drivers/net/ethernet/ti/k3-udma-desc-pool.h |   30 +
>>
>> I would rather loose the 'udma' from the name and API. It is more like
>> CPPI5 descriptor pool than UDMA. UDMA is just happen to use CPPI5.
>> Probably ti-cppi5-desc-pool?
> 
> ok. I'll update and re-send

Thank you!
Probably drop the ti- prefix as well from the filename as it is under a
ti directory?

>>
>>>   7 files changed, 3031 insertions(+), 2 deletions(-)
>>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.c
>>>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.h
>>>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.c
>>>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.h
>>
>>> diff --git a/drivers/net/ethernet/ti/Kconfig
>>> b/drivers/net/ethernet/ti/Kconfig
>>> index 8a6ca16eee3b..89cec778cf2d 100644
>>> --- a/drivers/net/ethernet/ti/Kconfig
>>> +++ b/drivers/net/ethernet/ti/Kconfig
>>> @@ -6,7 +6,7 @@
>>>   config NET_VENDOR_TI
>>>       bool "Texas Instruments (TI) devices"
>>>       default y
>>> -    depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS
>>> || ARCH_KEYSTONE
>>> +    depends on PCI || EISA || AR7 || ARCH_DAVINCI || ARCH_OMAP2PLUS
>>> || ARCH_KEYSTONE || ARCH_K3
>>>       ---help---
>>>         If you have a network (Ethernet) card belonging to this
>>> class, say Y.
>>>   @@ -31,7 +31,7 @@ config TI_DAVINCI_EMAC
>>>     config TI_DAVINCI_MDIO
>>>       tristate "TI DaVinci MDIO Support"
>>> -    depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE ||
>>> COMPILE_TEST
>>> +    depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || ARCH_KEYSTONE ||
>>> ARCH_K3 || COMPILE_TEST
>>>       select PHYLIB
>>>       ---help---
>>>         This driver supports TI's DaVinci MDIO module.
>>> @@ -95,6 +95,21 @@ config TI_CPTS_MOD
>>>       imply PTP_1588_CLOCK
>>>       default m
>>>   +config TI_K3_AM65_CPSW_NUSS
>>> +    tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
>>> +    depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
>>> +    select TI_DAVINCI_MDIO
>>> +    imply PHY_TI_GMII_SEL
>>> +    help
>>> +      This driver supports TI K3 AM654/J721E CPSW2G Ethernet SubSystem.
>>> +      The two-port Gigabit Ethernet MAC (MCU_CPSW0) subsystem provides
>>> +      Ethernet packet communication for the device: One Ethernet port
>>> +      (port 1) with selectable RGMII and RMII interfaces and an
>>> internal
>>> +      Communications Port Programming Interface (CPPI) port (port 0).
>>> +
>>> +      To compile this driver as a module, choose M here: the module
>>> +      will be called ti-am65-cpsw-nuss.
>>> +
>>>   config TI_KEYSTONE_NETCP
>>>       tristate "TI Keystone NETCP Core Support"
>>>       select TI_DAVINCI_MDIO
>>> diff --git a/drivers/net/ethernet/ti/Makefile
>>> b/drivers/net/ethernet/ti/Makefile
>>> index ecf776ad8689..6362a9b0bb8a 100644
>>> --- a/drivers/net/ethernet/ti/Makefile
>>> +++ b/drivers/net/ethernet/ti/Makefile
>>> @@ -23,3 +23,6 @@ obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
>>>   keystone_netcp-y := netcp_core.o cpsw_ale.o
>>>   obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
>>>   keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o
>>> netcp_xgbepcsr.o cpsw_ale.o
>>> +
>>> +obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
>>> +ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o
>>> am65-cpsw-ethtool.o cpsw_ale.o k3-udma-desc-pool.o
>>
>> Would not be better to have the desc-pool (silent) Kconfig selectable?
>> The not yet upstream icssg-prueth also needs the same desc-pool library
>> as cpsw.
>>
> 
> I'd prefer not to add new Kconfig options unless required.
> This driver simply not work without it, so no Kconfig option for now.

OK, fair enough.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Murali Karicheri March 19, 2020, 1:12 p.m. UTC | #4
On 03/17/2020 03:27 AM, Grygorii Strashko wrote:
> Hi
> 
> This v4 series adds basic networking support support TI K3 AM654x/J721E SoC which
> have integrated Gigabit Ethernet MAC (Media Access Controller) into device MCU
> domain and named MCU_CPSW0 (CPSW2G NUSS).
> 
> Formally TRMs refer CPSW2G NUSS as two-port Gigabit Ethernet Switch subsystem
> with port 0 being the CPPI DMA host port and port 1 being the external Ethernet
> port, but for 1 external port device it's just Port 0 <-> ALE <-> Port 1 and it's
> rather device with HW filtering capabilities then actually switching device.
> It's expected to have similar devices, but with more external ports.
> 
> The new Host port 0 Communications Port Programming Interface (CPPI5) is
> operating by TI AM654x/J721E NAVSS Unified DMA Peripheral Root Complex (UDMA-P)
> controller [1].
> 
> The CPSW2G contains below modules for which existing code is re-used:
>   - MAC SL: cpsw_sl.c
>   - Address Lookup Engine (ALE): cpsw_ale.c, basically compatible with K2 66AK2E/G
>   - Management Data Input/Output interface (MDIO): davinci_mdio.c, fully
>     compatible with TI AM3/4/5 devices
> 
> Basic features supported by CPSW2G NUSS driver:
>   - VLAN support, 802.1Q compliant, Auto add port VLAN for untagged frames on
>     ingress, Auto VLAN removal on egress and auto pad to minimum frame size.
>   - multicast filtering
>   - promisc mode
>   - TX multiq support in Round Robin or Fixed priority modes
>   - RX checksum offload for non-fragmented IPv4/IPv6 TCP/UDP packets
>   - TX checksum offload support for IPv4/IPv6 TCP/UDP packets (J721E only).
> 
> Features under development:
>   - Support for IEEE 1588 Clock Synchronization. The CPSW2G NUSS includes new
>     version of Common Platform Time Sync (CPTS)
>   - tc-mqprio: priority level Quality Of Service (QOS) support (802.1p)
>   - tc-cbs: Support for Audio/Video Bridging (P802.1Qav/D6.0) HW shapers
>   - tc-taprio: IEEE 802.1Qbv/D2.2 Enhancements for Scheduled Traffic
>   - frame preemption: IEEE P902.3br/D2.0 Interspersing Express Traffic, 802.1Qbu
>   - extended ALE features: classifier/policers, auto-aging
> 
> Patches 1-6 are intended for netdev, Patches 7-11 are intended for K3 Platform
> tree and provided here for testing purposes.
> 
> Changes in v4:
>   - fixed minor comments from Jakub Kicinski <kuba@kernel.org>
>   - dependencies resolved: required phy-rmii-sel changes [2] queued for merge
>     except one [3] which is included in this series with Kishon's ask.
> 

Tested-by: Murali Karicheri <m-karicheri2@ti.com>

Logs at https://pastebin.ubuntu.com/p/rP6pcMqcw5/

> Changes in v3:
>   - add ARM64 defconfig changes for testing purposes
>   - fixed DT yaml definition
>   - fixed comments from Jakub Kicinski <kuba@kernel.org>
> 
> Changes in v2:
>   - fixed DT yaml definition
>   - fixed comments from David Miller
> 
> v3: https://patchwork.ozlabs.org/cover/1254568/
> v2: https://patchwork.ozlabs.org/cover/1250674/
> v1: https://lwn.net/Articles/813087/
> 
> TRMs:
>   AM654: http://www.ti.com/lit/ug/spruid7e/spruid7e.pdf
>   J721E: http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf
> 
> Preliminary documentation can be found at:
>   http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components/Kernel/Kernel_Drivers/Network/K3_CPSW2g.html
> 
> [1] https://lwn.net/Articles/808030/
> [2] https://lkml.org/lkml/2020/2/22/100
> [3] https://lkml.org/lkml/2020/3/3/724
> 
> Grygorii Strashko (11):
>    phy: ti: gmii-sel: simplify config dependencies between net drivers
>      and gmii phy
>    net: ethernet: ti: ale: fix seeing unreg mcast packets with promisc
>      and allmulti disabled
>    net: ethernet: ti: ale: add support for mac-only mode
>    net: ethernet: ti: ale: am65: add support for default thread cfg
>    dt-binding: ti: am65x: document mcu cpsw nuss
>    net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
>    arm64: dts: ti: k3-am65-mcu: add cpsw nuss node
>    arm64: dts: k3-am654-base-board: add mcu cpsw nuss pinmux and phy defs
>    arm64: dts: ti: k3-j721e-mcu: add mcu cpsw nuss node
>    arm64: dts: ti: k3-j721e-common-proc-board: add mcu cpsw nuss pinmux
>      and phy defs
>    arm64: defconfig: ti: k3: enable dma and networking
> 
>   .../bindings/net/ti,k3-am654-cpsw-nuss.yaml   |  226 ++
>   arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi       |   49 +
>   arch/arm64/boot/dts/ti/k3-am65.dtsi           |    1 +
>   .../arm64/boot/dts/ti/k3-am654-base-board.dts |   42 +
>   .../dts/ti/k3-j721e-common-proc-board.dts     |   43 +
>   .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   49 +
>   arch/arm64/boot/dts/ti/k3-j721e.dtsi          |    1 +
>   arch/arm64/configs/defconfig                  |    3 +
>   drivers/net/ethernet/ti/Kconfig               |   20 +-
>   drivers/net/ethernet/ti/Makefile              |    3 +
>   drivers/net/ethernet/ti/am65-cpsw-ethtool.c   |  747 +++++++
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c      | 1965 +++++++++++++++++
>   drivers/net/ethernet/ti/am65-cpsw-nuss.h      |  143 ++
>   drivers/net/ethernet/ti/cpsw_ale.c            |   38 +
>   drivers/net/ethernet/ti/cpsw_ale.h            |    4 +
>   drivers/net/ethernet/ti/k3-udma-desc-pool.c   |  126 ++
>   drivers/net/ethernet/ti/k3-udma-desc-pool.h   |   30 +
>   drivers/phy/ti/Kconfig                        |    3 -
>   18 files changed, 3488 insertions(+), 5 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.c
>   create mode 100644 drivers/net/ethernet/ti/am65-cpsw-nuss.h
>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.c
>   create mode 100644 drivers/net/ethernet/ti/k3-udma-desc-pool.h
>