net: ethernet: ti: add networking support for k3 am65x/j721e soc
Subsystems (5)
v2 cover net: ethernet: ti: add networking support for k3 am65x/j721e soc
Hi
This v2 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
This series depends on:
[for-next PATCH 0/5] phy: ti: gmii-sel: add support for am654x/j721e soc
https://lkml.org/lkml/2020/2/22/100
Patches 1-5 are intended for netdev, Patches 6-9 are intended for K# Platform tree and provided here for testing purposes.
Changes:
- fixed DT yaml definition
- fixed comments from David Miller
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/
Grygorii Strashko (9):
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
.../bindings/net/ti,k3-am654-cpsw-nuss.yaml | 225 ++ 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 + drivers/net/ethernet/ti/Kconfig | 19 +- drivers/net/ethernet/ti/Makefile | 3 + drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 763 +++++++ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1991 +++++++++++++++++ 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 + 16 files changed, 3525 insertions(+), 2 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
Signature · 1 line
2.17.1
PATCH v2 1/9 net: ethernet: ti: ale: fix seeing unreg mcast packets with promisc and allmulti disabled
On AM65xx MCU CPSW2G NUSS and 66AK2E/L NUSS the unregistered multicast packets are still can be received with promisc and allmulti disabled.
This happens, because ALE VLAN entries on these SoCs do not contain port masks for reg/unreg mcast packets, but instead store indexes of ALE_VLAN_MASK_MUXx_REG registers which intended for store port masks for reg/unreg mcast packets.
ALE VLAN entry:UNREG_MCAST_FLOOD_INDEX -> ALE_VLAN_MASK_MUXx ALE VLAN entry:REG_MCAST_FLOOD_INDEX -> ALE_VLAN_MASK_MUXy
The commit b361da837392 ("net: netcp: ale: add proper ale entry mask bits for netcp switch ALE") update ALE code to support such ALE entries, it is always used ALE_VLAN_MASK_MUX0_REG index in ALE VLAN entry for unreg mcast packets mask configuration, which is read-only, at least for AM65xx MCU CPSW2G NUSS and 66AK2E/L NUSS. As result unreg mcast packets are allowed always.
Hence, update ALE code to use ALE_VLAN_MASK_MUX1_REG index for ALE VLAN entries to configure unreg mcast port mask.
--- drivers/net/ethernet/ti/cpsw_ale.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/ti/cpsw_ale.c +4 -0
@@ -122,6 +122,8 @@ DEFINE_ALE_FIELD(mcast, 40, 1) DEFINE_ALE_FIELD(vlan_unreg_mcast_idx, 20, 3) DEFINE_ALE_FIELD(vlan_reg_mcast_idx, 44, 3) +#define NU_VLAN_UNREG_MCAST_IDX 1 +/* The MAC address field in the ALE entry cannot be macroized as above */ static inline void cpsw_ale_get_addr (u32 *ale_entry,u8 *addr) {
@@ -455,6 +457,8 @@ int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,cpsw_ale_set_vlan_unreg_mcast (ale_entry, unreg_mcast, ale->vlan_field_bits); }else { +cpsw_ale_set_vlan_unreg_mcast_idx (ale_entry, +NU_VLAN_UNREG_MCAST_IDX );cpsw_ale_set_vlan_mcast (ale, ale_entry, reg_mcast, unreg_mcast); } cpsw_ale_set_vlan_member_list(ale_entry, port_mask,
Signature · 1 line
2.17.1
PATCH v2 2/9 net: ethernet: ti: ale: add support for mac-only mode
In reply to Grygorii StrashkoThe new CPSW ALE version, available on TI K3 AM654/J721E SoCs family, allows to switch any external port to MAC only mode. When MAC only mode enabled this port be treated like a MAC port for the host. All traffic received is only sent to the host. The host must direct traffic to this port as the lookup engine will not send traffic to the ports with the p0_maconly bit set and the p0_no_learn also set. If p0_maconly bit is set and the p0_no_learn is not set, the host can send non-directed packets that can be sent to the destination of a MacOnly port. It is also possible that The host can broadcast to all ports including MacOnly ports in this mode.
This patch add ALE supprt for MAC only mode.
--- drivers/net/ethernet/ti/cpsw_ale.c | 16 ++++++++++++++++ drivers/net/ethernet/ti/cpsw_ale.h | 2 ++ 2 files changed, 18 insertions(+)
drivers/net/ethernet/ti/cpsw_ale.c +16 -0
@@ -779,6 +779,22 @@ static struct ale_control_info ale_controls[ALE_NUM_CONTROLS] = { .port_shift = 0, .bits = 1, }, + [ALE_PORT_MACONLY] = { + .name = "mac_only_port_mode", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 11, + .port_shift = 0, + .bits = 1, + }, + [ALE_PORT_MACONLY_CAF] = { + .name = "mac_only_port_caf", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 13, + .port_shift = 0, + .bits = 1, + }, [ALE_PORT_MCAST_LIMIT] = { .name = "mcast_limit", .offset = ALE_PORTCTL,
drivers/net/ethernet/ti/cpsw_ale.h +2 -0
@@ -62,6 +62,8 @@ enum cpsw_ale_control {ALE_PORT_UNKNOWN_MCAST_FLOOD ,ALE_PORT_UNKNOWN_REG_MCAST_FLOOD ,ALE_PORT_UNTAGGED_EGRESS , +ALE_PORT_MACONLY , +ALE_PORT_MACONLY_CAF ,ALE_PORT_BCAST_LIMIT ,ALE_PORT_MCAST_LIMIT , ALE_NUM_CONTROLS,
Signature · 1 line
2.17.1
PATCH v2 3/9 net: ethernet: ti: ale: am65: add support for default thread cfg
In reply to Grygorii StrashkoAdd support for default thread configuration for AM65x CPSW NUSS ALE to allow route all ingress packets to one default RX UDMA flow.
--- drivers/net/ethernet/ti/cpsw_ale.c | 18 ++++++++++++++++++ drivers/net/ethernet/ti/cpsw_ale.h | 2 ++ 2 files changed, 20 insertions(+)
drivers/net/ethernet/ti/cpsw_ale.c +18 -0
@@ -44,6 +44,8 @@#define ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS 0x9C#define ALE_VLAN_MASK_MUX (reg) (0xc0 + (0x4 * (reg))) +#define AM65_CPSW_ALE_THREAD_DEF_REG 0x134 +#define ALE_TABLE_WRITE BIT(31)#define ALE_TYPE_FREE 0
@@ -843,6 +845,22 @@ static struct ale_control_info ale_controls[ALE_NUM_CONTROLS] = { .port_shift = 0, .bits = 6, }, + [ALE_DEFAULT_THREAD_ID] = { + .name = "default_thread_id", + .offset = AM65_CPSW_ALE_THREAD_DEF_REG, + .port_offset = 0, + .shift = 0, + .port_shift = 0, + .bits = 6, + }, + [ALE_DEFAULT_THREAD_ENABLE] = { + .name = "default_thread_id", + .offset = AM65_CPSW_ALE_THREAD_DEF_REG, + .port_offset = 0, + .shift = 15, + .port_shift = 0, + .bits = 1, + }, }; int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
drivers/net/ethernet/ti/cpsw_ale.h +2 -0
@@ -66,6 +66,8 @@ enum cpsw_ale_control {ALE_PORT_MACONLY_CAF ,ALE_PORT_BCAST_LIMIT ,ALE_PORT_MCAST_LIMIT , +ALE_DEFAULT_THREAD_ID , +ALE_DEFAULT_THREAD_ENABLE , ALE_NUM_CONTROLS, };
Signature · 1 line
2.17.1
PATCH v2 4/9 dt-binding: ti: am65x: document mcu cpsw nuss
In reply to Grygorii StrashkoDocument device tree bindings for The TI AM654x/J721E SoC Gigabit Ethernet MAC (Media Access Controller - CPSW2G NUSS). The CPSW NUSS provides Ethernet packet communication for the device.
--- .../bindings/net/ti,k3-am654-cpsw-nuss.yaml | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml new file +225 -0
@@ -0,0 +1,225 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ti,k3-am654-cpsw-nuss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: The TI AM654x/J721E SoC Gigabit Ethernet MAC (Media Access Controller) Device Tree Bindings + +maintainers: + - Grygorii Strashko <[email protected]> + - Sekhar Nori <[email protected]> + +description: + The TI AM654x/J721E SoC Gigabit Ethernet MAC (CPSW2G NUSS) has two ports + (one external) and provides Ethernet packet communication for the device. + CPSW2G NUSS features - the Reduced Gigabit Media Independent Interface (RGMII), + Reduced Media Independent Interface (RMII), the Management Data + Input/Output (MDIO) interface for physical layer device (PHY) management, + new version of Common Platform Time Sync (CPTS), updated Address Lookup + Engine (ALE). + One external Ethernet port (port 1) with selectable RGMII/RMII interfaces and + an internal Communications Port Programming Interface (CPPI5) (Host port 0). + Host Port 0 CPPI Packet Streaming Interface interface supports 8 TX channels + and one RX channels and operating by TI AM654x/J721E NAVSS Unified DMA + Peripheral Root Complex (UDMA-P) controller. + The CPSW2G NUSS is integrated into device MCU domain named MCU_CPSW0. + + Additional features + priority level Quality Of Service (QOS) support (802.1p) + Support for Audio/Video Bridging (P802.1Qav/D6.0) + Support for IEEE 1588 Clock Synchronization (2008 Annex D, Annex E and Annex F) + Flow Control (802.3x) Support + Time Sensitive Network Support + IEEE P902.3br/D2.0 Interspersing Express Traffic + IEEE 802.1Qbv/D2.2 Enhancements for Scheduled Traffic + Configurable number of addresses plus VLANs + Configurable number of classifier/policers + 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. + RX/TX csum offload + + Specifications can be found at + http://www.ti.com/lit/ug/spruid7e/spruid7e.pdf + http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf + +properties: + "#address-cells": true + "#size-cells": true + + compatible: + oneOf: + - const: ti,am654-cpsw-nuss + - const: ti,j721e-cpsw-nuss + + reg: + maxItems: 1 + description: + The physical base address and size of full the CPSW2G NUSS IO range + + reg-names: + items: + - const: cpsw_nuss + + ranges: true + + dma-coherent: true + + clocks: + description: CPSW2G NUSS functional clock + + clock-names: + items: + - const: fck + + power-domains: + maxItems: 1 + + dmas: + minItems: 9 + maxItems: 9 + + dma-names: + items: + - const: tx0 + - const: tx1 + - const: tx2 + - const: tx3 + - const: tx4 + - const: tx5 + - const: tx6 + - const: tx7 + - const: rx + + pinctrl-names: true + + ethernet-ports: + type: object + properties: + '#address-cells': + const: 1 + '#size-cells': + const: 0 + + patternProperties: + "^port@[0-9]+$": + type: object + description: CPSW2G NUSS external ports + + allOf: + - $ref: ethernet-controller.yaml# + + properties: + reg: + items: + - const: 1 + description: CPSW port number + + phys: + maxItems: 1 + description: phandle on phy-gmii-sel PHY + + label: + description: label associated with this port + + ti,mac-only: + $ref: /schemas/types.yaml#definitions/flag + description: + Specifies the port works in mac-only mode. + + ti,syscon-efuse: + $ref: /schemas/types.yaml#definitions/phandle-array + description: + Phandle to the system control device node which provides access + to efuse IO range with MAC addresses + + required: + - reg + - phys + + mdio: + type: object + allOf: + - $ref: "ti,davinci-mdio.yaml#" + description: + CPSW MDIO bus. + +patternProperties: + "^pinctrl-[0-9]+$": true + +required: + - compatible + - reg + - reg-names + - ranges + - clocks + - clock-names + - power-domains + - dmas + - dma-names + - '#address-cells' + - '#size-cells' + +examples: + - | + #include <dt-bindings/pinctrl/k3.h> + #include <dt-bindings/soc/ti,sci_pm_domain.h> + #include <dt-bindings/net/ti-dp83867.h> + + mcu_cpsw: ethernet@46000000 { + compatible = "ti,am654-cpsw-nuss"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x0 0x46000000 0x0 0x200000>; + reg-names = "cpsw_nuss"; + ranges = <0x0 0x0 0x46000000 0x0 0x200000>; + dma-coherent; + clocks = <&k3_clks 5 10>; + clock-names = "fck"; + power-domains = <&k3_pds 5 TI_SCI_PD_EXCLUSIVE>; + pinctrl-names = "default"; + + dmas = <&mcu_udmap 0xf000>, + <&mcu_udmap 0xf001>, + <&mcu_udmap 0xf002>, + <&mcu_udmap 0xf003>, + <&mcu_udmap 0xf004>, + <&mcu_udmap 0xf005>, + <&mcu_udmap 0xf006>, + <&mcu_udmap 0xf007>, + <&mcu_udmap 0x7000>; + dma-names = "tx0", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", + "rx"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + cpsw_port1: port@1 { + reg = <1>; + ti,mac-only; + label = "port1"; + ti,syscon-efuse = <&mcu_conf 0x200>; + phys = <&phy_gmii_sel 1>; + + phy-mode = "rgmii-rxid"; + phy-handle = <&phy0>; + }; + }; + + davinci_mdio: mdio@f00 { + compatible = "ti,cpsw-mdio","ti,davinci_mdio"; + reg = <0x0 0xf00 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&k3_clks 5 10>; + clock-names = "fck"; + bus_freq = <1000000>; + + phy0: ethernet-phy@0 { + reg = <0>; + ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>; + ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_4_B_NIB>; + }; + }; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH net-next v2 4/9] dt-binding: ti: am65x: document mcu cpsw nuss
Quoted 10 lines · Grygorii Strashko
Document device tree bindings for The TI AM654x/J721E SoC Gigabit Ethernet MAC (Media Access Controller - CPSW2G NUSS). The CPSW NUSS provides Ethernet packet communication for the device.
Signed-off-by Grygorii Strashko <[email protected]>--- .../bindings/net/ti,k3-am654-cpsw-nuss.yaml | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
My bot found errors running 'make dt_binding_check' on your patch:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.example.dt.yaml: ethernet@46000000: 'pinctrl-0' is a dependency of 'pinctrl-names'
See https://patchwork.ozlabs.org/patch/1250679
Please check and re-submit.
PATCH v2 5/9 net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
In reply to Grygorii StrashkoThe 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.
--- drivers/net/ethernet/ti/Kconfig | 19 +- drivers/net/ethernet/ti/Makefile | 3 + drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 763 +++++++ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1991 +++++++++++++++++++ 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 + 7 files changed, 3073 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
drivers/net/ethernet/ti/Kconfig +17 -2
@@ -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
drivers/net/ethernet/ti/Makefile +3 -0
@@ -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
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +763 -0
763 lines not on this page · raw message
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +1991 -0
1,991 lines not on this page · raw message
drivers/net/ethernet/ti/am65-cpsw-nuss.h new file +143 -0
143 lines not on this page · raw message
drivers/net/ethernet/ti/k3-udma-desc-pool.c new file +126 -0
60 lines not on this page · raw message
drivers/net/ethernet/ti/k3-udma-desc-pool.h new file +30 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Jakub Kicinski
maintainerRe: [PATCH net-next v2 5/9] net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 410
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+static void am65_cpsw_get_drvinfo (struct net_device *ndev, +struct ethtool_drvinfo *info) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + +strlcpy (info->driver,dev_driver_string (common->dev), +sizeof (info->driver)); +strlcpy (info->version,AM65_CPSW_DRV_VER ,sizeof (info->version));
Please remove the driver version, use of driver versions is being deprecated upstream.
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 433
Quoted 9 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+strlcpy (info->bus_info,dev_name (common->dev),sizeof (info->bus_info)); +} +static void am65_cpsw_get_channels (struct net_device *ndev, +struct ethtool_channels *ch) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + + ch->max_combined =0 ;
no need to zero fields
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +6
-0+ ch->max_rx =AM65_CPSW_MAX_RX_QUEUES ; + ch->max_tx =AM65_CPSW_MAX_TX_QUEUES ; + ch->max_other =0 ; + ch->other_count =0 ; + ch->rx_count =AM65_CPSW_MAX_RX_QUEUES ; + ch->tx_count = common->tx_ch_num;
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 449
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +10
-0+ ch->combined_count =0 ; +} + +static int am65_cpsw_set_channels (struct net_device *ndev, +struct ethtool_channels *chs) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + +if (chs->combined_count) +return -EINVAL ;
core will check if its larger than max_combined
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 456
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +6
-0+if (!chs->rx_count || !chs->tx_count) +return -EINVAL ; + +if (chs->rx_count !=1 || + chs->tx_count >AM65_CPSW_MAX_TX_QUEUES ) +return -EINVAL ;
ditto
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+/* Check if interface is up. Can change the num queues when +* the interface is down. +*/ +if (netif_running (ndev)) +return -EBUSY ; + +am65_cpsw_nuss_remove_tx_chns (common); +
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 475
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +10
-0+return am65_cpsw_nuss_update_tx_chns (common, chs->tx_count); +} + +static void am65_cpsw_get_ringparam (struct net_device *ndev, +struct ethtool_ringparam *ering) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + +/* not supported */ + ering->tx_max_pending =0 ;
no need to zero fields
drivers/net/ethernet/ti/am65-cpsw-ethtool.c
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +5
-0+ ering->tx_pending = common->tx_chns[0 ].descs_num; + ering->rx_max_pending =0 ; + ering->rx_pending = common->rx_chns.descs_num; +} +EXPORT_SYMBOL_GPL (am65_cpsw_nuss_adjust_link);
Why does this need to be exported?
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 756
Quoted 9 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+ psdata =cppi5_hdesc_get_psdata (desc_rx); + csum_info = psdata[2 ]; +dev_dbg (dev,"%s rx csum_info:%#x\n" , __func__, csum_info); + +dma_unmap_single (dev, buf_dma, buf_dma_len,DMA_FROM_DEVICE ); + +k3_udma_desc_pool_free (rx_chn->desc_pool, desc_rx); + +if (unlikely (!netif_running (skb->dev))) {
This is strange, does am65_cpsw_nuss_ndo_slave_stop() not stop RX?
Quoted 22 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +22
-0+dev_kfree_skb_any (skb); +return 0 ; + } + + new_skb =netdev_alloc_skb_ip_align (ndev,AM65_CPSW_MAX_PACKET_SIZE ); +if (new_skb) { +skb_put (skb, pkt_len); + skb->protocol =eth_type_trans (skb, ndev); +am65_cpsw_nuss_rx_csum (skb, csum_info); +napi_gro_receive (&common->napi_rx, skb); + + ndev_priv =netdev_priv (ndev); + stats =this_cpu_ptr (ndev_priv->stats); + +u64_stats_update_begin (&stats->syncp); + stats->rx_packets++; + stats->rx_bytes += pkt_len; +u64_stats_update_end (&stats->syncp); +kmemleak_not_leak (new_skb); + }else { + ndev->stats.rx_dropped++; + new_skb = skb;
drivers/net/ethernet/ti/am65-cpsw-nuss.c
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+ } +static int am65_cpsw_nuss_tx_poll (struct napi_struct *napi_tx,int budget) +{ +struct am65_cpsw_tx_chn *tx_chn =am65_cpsw_napi_to_tx_chn (napi_tx); +int num_tx; + + num_tx =am65_cpsw_nuss_tx_compl_packets (tx_chn->common, tx_chn->id, + budget); +if (num_tx < budget) {
The budget is for RX, you can just complete all TX on a NAPI poll.
Quoted 18 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +17
-0+napi_complete (napi_tx); +enable_irq (tx_chn->irq); + } + +return num_tx; +} +static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit (struct sk_buff *skb, +struct net_device *ndev) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct cppi5_host_desc_t *first_desc, *next_desc, *cur_desc; +struct am65_cpsw_port *port =am65_ndev_to_port (ndev); +struct device *dev = common->dev; +struct am65_cpsw_tx_chn *tx_chn; +struct netdev_queue *netif_txq; +dma_addr_t desc_dma, buf_dma; +int ret, q_idx, i;
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1005
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +10
-0+void **swdata; +u32 *psdata; +u32 pkt_len; + +/* frag list based linkage is not supported for now. */ +if (skb_shinfo (skb)->frag_list) { +dev_err_ratelimited (dev,"NETIF_F_FRAGLIST not supported\n" ); + ret = -EINVAL ; + goto drop_free_skb; + }
You don't advertise the feature, there is no need for this check.
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1012
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+/* padding enabled in hw */ + pkt_len =skb_headlen (skb); + + q_idx =skb_get_queue_mapping (skb); +dev_dbg (dev,"%s skb_queue:%d\n" , __func__, q_idx); + q_idx = q_idx % common->tx_ch_num;
You should never see a packet for ring above your ring count, this modulo is unnecessary.
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1021
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+ tx_chn = &common->tx_chns[q_idx]; + netif_txq =netdev_get_tx_queue (ndev, q_idx); + +/* Map the linear buffer */ + buf_dma =dma_map_single (dev, skb->data, pkt_len, +DMA_TO_DEVICE ); +if (unlikely (dma_mapping_error (dev, buf_dma))) { +dev_err (dev,"Failed to map tx skb buffer\n" );
You probably don't want to print errors when memory gets depleted. Counter is enough
Review
Quoted 1 line
(quoted diff) +1
-0+ ret = -EINVAL;
EINVAL is not a valid netdev_tx_t..
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1024
Quoted 2 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +2
-0+ ndev->stats.tx_errors++; + goto drop_stop_q;
Why stop queue on memory mapping error? What will re-enable it?
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1029
Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +5
-0+ } + + first_desc =k3_udma_desc_pool_alloc (tx_chn->desc_pool); +if (!first_desc) { +dev_dbg (dev,"Failed to allocate descriptor\n" );
ret not set
Quoted 7 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+dma_unmap_single (dev, buf_dma, pkt_len,DMA_TO_DEVICE ); + goto drop_stop_q_busy; + } +done_tx: +skb_tx_timestamp (skb); +
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1112
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +10
-0+/* report bql before sending packet */ +netdev_tx_sent_queue (netif_txq, pkt_len); + +cppi5_hdesc_set_pktlen (first_desc, pkt_len); + desc_dma =k3_udma_desc_pool_virt2dma (tx_chn->desc_pool, first_desc); + ret =k3_udma_glue_push_tx_chn (tx_chn->tx_chn, first_desc, desc_dma); +if (ret) { +dev_err (dev,"can't push desc %d\n" , ret); + ndev->stats.tx_errors++; + goto drop_free_descs;
BQL already counted this frame.
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1119
Quoted 7 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +7
-0+ } + +if (k3_udma_desc_pool_avail (tx_chn->desc_pool) <MAX_SKB_FRAGS ) { +netif_tx_stop_queue (netif_txq); +/* Barrier, so that stop_queue visible to other cpus */ +smp_mb__after_atomic (); +dev_err (dev,"netif_tx_stop_queue %d\n" , q_idx);
How many descriptors are there if it's okay to print an error when descriptors run out? :o
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+/* re-check for smp */ +if (k3_udma_desc_pool_avail (tx_chn->desc_pool) >= +MAX_SKB_FRAGS ) { +netif_tx_wake_queue (netif_txq); +dev_err (dev,"netif_tx_wake_queue %d\n" , q_idx); + } + } +
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1138
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +10
-0+return NETDEV_TX_OK ; + +drop_free_descs: +am65_cpsw_nuss_xmit_free (tx_chn, dev, first_desc); +drop_stop_q: +netif_tx_stop_queue (netif_txq); +drop_free_skb: + ndev->stats.tx_dropped++; +dev_kfree_skb_any (skb); +return ret;
return NETDEV_TX_OK;
Quoted 17 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +16
-0+ +drop_stop_q_busy: +netif_tx_stop_queue (netif_txq); +return NETDEV_TX_BUSY ; +} +static int am65_cpsw_nuss_ndev_add_napi_2g (struct am65_cpsw_common *common) +{ +struct device *dev = common->dev; +struct am65_cpsw_port *port; +int i, ret =0 ; + + port =am65_common_get_port (common,1 ); + +for (i =0 ; i < common->tx_ch_num; i++) { +struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; +
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1740
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +10
-0+netif_tx_napi_add (port->ndev, &tx_chn->napi_tx, + am65_cpsw_nuss_tx_poll,NAPI_POLL_WEIGHT ); + + ret =devm_request_irq (dev, tx_chn->irq, + am65_cpsw_nuss_tx_irq, +0 , tx_chn->tx_chn_name, tx_chn); +if (ret) { +dev_err (dev,"failure requesting tx%u irq %u, %d\n" , + tx_chn->id, tx_chn->irq, ret); + goto err;
If this fails half way through the loop is there something that'd call netif_tx_napi_del()?
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+ } + } + +err: +return ret; +}
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1886
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+/* register devres action here, so dev will be disabled +* at right moment. The dev will be enabled in .remove() callback +* unconditionally. +*/ + ret =devm_add_action_or_reset (dev, am65_cpsw_pm_runtime_free, dev); +if (ret) { +dev_err (dev,"failed to add pm put reset action %d" , ret); +return ret; + }
Could you explain why you need this? Why can't remove disable PM?
In general looks to me like this driver abuses devm_ infra in ways which make it more complex than it needs to be :(
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+ ret =devm_of_platform_populate (dev); +/* We do not want to force this, as in some cases may not have child */ +if (ret) +dev_warn (dev,"populating child nodes err:%d\n" , ret); + +am65_cpsw_nuss_get_ver (common);
Re: [PATCH net-next v2 5/9] net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
Hi Jakub,
Thank you for your review.
Quoted 10 lines · Jakub Kicinski
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 410
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+static void am65_cpsw_get_drvinfo (struct net_device *ndev, +struct ethtool_drvinfo *info) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + +strlcpy (info->driver,dev_driver_string (common->dev), +sizeof (info->driver)); +strlcpy (info->version,AM65_CPSW_DRV_VER ,sizeof (info->version));Please remove the driver version, use of driver versions is being deprecated upstream.
Hm. I can remove it np. But how do I or anybody else can know that it's deprecated
* @get_drvinfo: Report driver/device information. Should only set the
* @driver, @version, @fw_version and @bus_info fields. If not
* implemented, the @driver and @bus_info fields will be filled in
* according to the netdev's parent device.
* struct ethtool_drvinfo - general driver and device information
..
* @version: Driver version string; may be an empty string
It seems not marked as deprecated.
Quoted 12 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 433
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+strlcpy (info->bus_info,dev_name (common->dev),sizeof (info->bus_info)); +} +static void am65_cpsw_get_channels (struct net_device *ndev, +struct ethtool_channels *ch) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + + ch->max_combined =0 ;no need to zero fields
[...]
Quoted 12 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 756
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+ psdata =cppi5_hdesc_get_psdata (desc_rx); + csum_info = psdata[2 ]; +dev_dbg (dev,"%s rx csum_info:%#x\n" , __func__, csum_info); + +dma_unmap_single (dev, buf_dma, buf_dma_len,DMA_FROM_DEVICE ); + +k3_udma_desc_pool_free (rx_chn->desc_pool, desc_rx); + +if (unlikely (!netif_running (skb->dev))) {This is strange, does
am65_cpsw_nuss_ndo_slave_stop()not stop RX?
Net core will set __LINK_STATE_START = 0 before calling .ndo_stop() and there could some time gap between clearing __LINK_STATE_START and actually disabling RX.
if NAPI is in progress it will just allow to complete current NAPI cycle by discarding unwanted packets and without statistic update.
Quoted 25 lines
Quoted 24 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +23
-0+dev_kfree_skb_any (skb); +return 0 ; + } + + new_skb =netdev_alloc_skb_ip_align (ndev,AM65_CPSW_MAX_PACKET_SIZE ); +if (new_skb) { +skb_put (skb, pkt_len); + skb->protocol =eth_type_trans (skb, ndev); +am65_cpsw_nuss_rx_csum (skb, csum_info); +napi_gro_receive (&common->napi_rx, skb); + + ndev_priv =netdev_priv (ndev); + stats =this_cpu_ptr (ndev_priv->stats); + +u64_stats_update_begin (&stats->syncp); + stats->rx_packets++; + stats->rx_bytes += pkt_len; +u64_stats_update_end (&stats->syncp); +kmemleak_not_leak (new_skb); + }else { + ndev->stats.rx_dropped++; + new_skb = skb; + }
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 957
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+static int am65_cpsw_nuss_tx_poll (struct napi_struct *napi_tx,int budget) +{ +struct am65_cpsw_tx_chn *tx_chn =am65_cpsw_napi_to_tx_chn (napi_tx); +int num_tx; + + num_tx =am65_cpsw_nuss_tx_compl_packets (tx_chn->common, tx_chn->id, + budget); +if (num_tx < budget) {The budget is for RX, you can just complete all TX on a NAPI poll.
Then TX will block RX. Right? this is soft IRQs which are executed one by one.
Quoted 42 lines
Quoted 19 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +17
-0+napi_complete (napi_tx); +enable_irq (tx_chn->irq); + } + +return num_tx; +} +static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit (struct sk_buff *skb, +struct net_device *ndev) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct cppi5_host_desc_t *first_desc, *next_desc, *cur_desc; +struct am65_cpsw_port *port =am65_ndev_to_port (ndev); +struct device *dev = common->dev; +struct am65_cpsw_tx_chn *tx_chn; +struct netdev_queue *netif_txq; +dma_addr_t desc_dma, buf_dma; +int ret, q_idx, i;drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1005
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +10
-0+void **swdata; +u32 *psdata; +u32 pkt_len; + +/* frag list based linkage is not supported for now. */ +if (skb_shinfo (skb)->frag_list) { +dev_err_ratelimited (dev,"NETIF_F_FRAGLIST not supported\n" ); + ret = -EINVAL ; + goto drop_free_skb; + }You don't advertise the feature, there is no need for this check.
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1012
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+/* padding enabled in hw */ + pkt_len =skb_headlen (skb); + + q_idx =skb_get_queue_mapping (skb); +dev_dbg (dev,"%s skb_queue:%d\n" , __func__, q_idx); + q_idx = q_idx % common->tx_ch_num;You should never see a packet for ring above your ring count, this modulo is unnecessary.
Quoted 11 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1021
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+ tx_chn = &common->tx_chns[q_idx]; + netif_txq =netdev_get_tx_queue (ndev, q_idx); + +/* Map the linear buffer */ + buf_dma =dma_map_single (dev, skb->data, pkt_len, +DMA_TO_DEVICE ); +if (unlikely (dma_mapping_error (dev, buf_dma))) { +dev_err (dev,"Failed to map tx skb buffer\n" );You probably don't want to print errors when memory gets depleted. Counter is enough
Could you please help me understand what is the relation between "memory depletion" and dma_mapping_error()?
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ ret = -EINVAL;EINVAL is not a valid
netdev_tx_t..
Considering dev_xmit_complete() - this part was always "black magic" to me :( Will fix.
Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1024
Quoted 3 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +2
-0+ ndev->stats.tx_errors++; + goto drop_stop_q;Why stop queue on memory mapping error? What will re-enable it?
it will not. I'm considering it as critical - no recovery.
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1029
Quoted 6 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +5
-0+ } + + first_desc =k3_udma_desc_pool_alloc (tx_chn->desc_pool); +if (!first_desc) { +dev_dbg (dev,"Failed to allocate descriptor\n" );ret not set
It will return NETDEV_TX_BUSY in this case - below.
Quoted 5 lines
Quoted 4 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +3
-0+dma_unmap_single (dev, buf_dma, pkt_len,DMA_TO_DEVICE ); + goto drop_stop_q_busy; + }
[...]
Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +16
-0+static int am65_cpsw_nuss_ndev_add_napi_2g (struct am65_cpsw_common *common) +{ +struct device *dev = common->dev; +struct am65_cpsw_port *port; +int i, ret =0 ; + + port =am65_common_get_port (common,1 ); + +for (i =0 ; i < common->tx_ch_num; i++) { +struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; + +netif_tx_napi_add (port->ndev, &tx_chn->napi_tx, + am65_cpsw_nuss_tx_poll,NAPI_POLL_WEIGHT ); + + ret = devm_request_irq(dev, tx_chn->irq, + am65_cpsw_nuss_tx_irq,
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1740
Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +5
-0+ 0, tx_chn->tx_chn_name, tx_chn); +if (ret) { +dev_err (dev,"failure requesting tx%u irq %u, %d\n" , + tx_chn->id, tx_chn->irq, ret); + goto err;If this fails half way through the loop is there something that'd call
netif_tx_napi_del()?
free_netdev()
Quoted 20 lines
Quoted 7 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +6
-0+ } + } + +err: +return ret; +}drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1886
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+/* register devres action here, so dev will be disabled +* at right moment. The dev will be enabled in .remove() callback +* unconditionally. +*/ + ret =devm_add_action_or_reset (dev, am65_cpsw_pm_runtime_free, dev); +if (ret) { +dev_err (dev,"failed to add pm put reset action %d" , ret); +return ret; + }Could you explain why you need this? Why can't remove disable PM?
Quoted 2 lines
In general looks to me like this driver abuses
devm_infra in ways which make it more complex than it needs to be :(
Sry, can't agree here. This allows me to keep release sequence in sane way and get rid of mostly all goto for fail cases (which are constant source of errors for complex initialization sequences) by using standard framework.
Regarding PM runtime
- many Linux core framework provide devm_ APIs this and other
drivers are happy to use them.
- but, there is the problem: DD release sequence is
drv->remove(dev); devres_release_all(dev);
and there is no devm_ API for PM runtime. So, if some initialization step is done with devm_ API and It depends on device to be active - no way to solve it in .remove() callback easily. For example, devm_of_platform_populate().
With above code I ensure that:
drv->remove(dev);
|- pm_runtime_get()
devres_release_all(dev);
|- devm_of_platform_populate_release() |- pm_runtime_put() |- pm_runtime_disable()
Signature · 2 lines
Best regards, grygorii
Jakub Kicinski
maintainerRe: [PATCH net-next v2 5/9] net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
Quoted 23 lines · On Sat, 7 Mar 2020 07:19:17 +0200 Grygorii Strashko wrote:
Hi Jakub,
Thank you for your review.
Quoted 10 lines · Jakub Kicinski
drivers/net/ethernet/ti/am65-cpsw-ethtool.c line 410
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c new file +8
-0+static void am65_cpsw_get_drvinfo (struct net_device *ndev, +struct ethtool_drvinfo *info) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); + +strlcpy (info->driver,dev_driver_string (common->dev), +sizeof (info->driver)); +strlcpy (info->version,AM65_CPSW_DRV_VER ,sizeof (info->version));Please remove the driver version, use of driver versions is being deprecated upstream.
Hm. I can remove it np. But how do I or anybody else can know that it's deprecated
* @get_drvinfo: Report driver/device information. Should only set the
* @driver, @version, @fw_version and @bus_info fields. If not
* implemented, the @driver and @bus_info fields will be filled in
* according to the netdev's parent device.
Quoted 5 lines
* struct
ethtool_drvinfo- general driver and device information
..
* @version: Driver version string; may be an empty stringIt seems not marked as deprecated.
Thanks, it's _being_ deprecated, by which I mean we are slowly removing the use, and will mark it as deprecated afterwards. I take your point that we should have started with marking..
Quoted 12 lines
Quoted 11 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 756
Quoted 9 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+ psdata =cppi5_hdesc_get_psdata (desc_rx); + csum_info = psdata[2 ]; +dev_dbg (dev,"%s rx csum_info:%#x\n" , __func__, csum_info); + +dma_unmap_single (dev, buf_dma, buf_dma_len,DMA_FROM_DEVICE ); + +k3_udma_desc_pool_free (rx_chn->desc_pool, desc_rx); + +if (unlikely (!netif_running (skb->dev))) {This is strange, does
am65_cpsw_nuss_ndo_slave_stop()not stop RX?
Quoted 4 lines
Net core will set
__LINK_STATE_START= 0 before calling .ndo_stop() and there could some time gap between clearing__LINK_STATE_STARTand actually disabling RX.
if NAPI is in progress it will just allow to complete current NAPI cycle by discarding unwanted packets and without statistic update.
That's fine, let the core discard those packets if it wants to. Disabling the interface while the traffic is flowing is a rare occurrence, it's a waste of cycles to check for every packet.
Quoted 35 lines
Quoted 24 lines
Quoted 23 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +23
-0+dev_kfree_skb_any (skb); +return 0 ; + } + + new_skb =netdev_alloc_skb_ip_align (ndev,AM65_CPSW_MAX_PACKET_SIZE ); +if (new_skb) { +skb_put (skb, pkt_len); + skb->protocol =eth_type_trans (skb, ndev); +am65_cpsw_nuss_rx_csum (skb, csum_info); +napi_gro_receive (&common->napi_rx, skb); + + ndev_priv =netdev_priv (ndev); + stats =this_cpu_ptr (ndev_priv->stats); + +u64_stats_update_begin (&stats->syncp); + stats->rx_packets++; + stats->rx_bytes += pkt_len; +u64_stats_update_end (&stats->syncp); +kmemleak_not_leak (new_skb); + }else { + ndev->stats.rx_dropped++; + new_skb = skb; + }Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 957
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+static int am65_cpsw_nuss_tx_poll (struct napi_struct *napi_tx,int budget) +{ +struct am65_cpsw_tx_chn *tx_chn =am65_cpsw_napi_to_tx_chn (napi_tx); +int num_tx; + + num_tx =am65_cpsw_nuss_tx_compl_packets (tx_chn->common, tx_chn->id, + budget); +if (num_tx < budget) {The budget is for RX, you can just complete all TX on a NAPI poll.
Quoted 1 line
Then TX will block RX. Right? this is soft IRQs which are executed one by one.
If anything completing all TX frames makes it more likely RX will have another memory to allocate from. AFAIK live lock by TX completions is unheard of.
Quoted 12 lines
Quoted 11 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1021
Quoted 8 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +8
-0+ tx_chn = &common->tx_chns[q_idx]; + netif_txq =netdev_get_tx_queue (ndev, q_idx); + +/* Map the linear buffer */ + buf_dma =dma_map_single (dev, skb->data, pkt_len, +DMA_TO_DEVICE ); +if (unlikely (dma_mapping_error (dev, buf_dma))) { +dev_err (dev,"Failed to map tx skb buffer\n" );You probably don't want to print errors when memory gets depleted. Counter is enough
Quoted 2 lines
Could you please help me understand what is the relation between "memory depletion" and
dma_mapping_error()?
I don't know your platform, so the comment may not be accurate, but usually DMA mappings fail if the device has some memory addressing constraints, and all memory which can satisfy those is used. Or the memory situation is extremely dire and IOMMU driver can't allocate meta data.
Quoted 7 lines
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ ret = -EINVAL;EINVAL is not a valid
netdev_tx_t..Considering
dev_xmit_complete()- this part was always "black magic" to me :( Will fix.
Quoted 6 lines
Quoted 4 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1024
Quoted 2 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +2
-0+ ndev->stats.tx_errors++; + goto drop_stop_q;Why stop queue on memory mapping error? What will re-enable it?
it will not. I'm considering it as critical - no recovery.
Oh, I see. If you're sure this can never happen (tm) on your platfrom I'd throw in a WARN_ON_ONCE() in this path so users know what's going on. That said it doesn't seem too hard to recover from, so normal error handling would be best.
Quoted 33 lines
Quoted 7 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1029
Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +5
-0+ } + + first_desc =k3_udma_desc_pool_alloc (tx_chn->desc_pool); +if (!first_desc) { +dev_dbg (dev,"Failed to allocate descriptor\n" );ret not set
It will return
NETDEV_TX_BUSYin this case - below.Quoted 23 lines
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+dma_unmap_single (dev, buf_dma, pkt_len,DMA_TO_DEVICE ); + goto drop_stop_q_busy; + } + } + } + +err: +return ret; +}drivers/net/ethernet/ti/am65-cpsw-nuss.c line 1886
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c new file +9
-0+/* register devres action here, so dev will be disabled +* at right moment. The dev will be enabled in .remove() callback +* unconditionally. +*/ + ret =devm_add_action_or_reset (dev, am65_cpsw_pm_runtime_free, dev); +if (ret) { +dev_err (dev,"failed to add pm put reset action %d" , ret); +return ret; + }Could you explain why you need this? Why can't remove disable PM?
Quoted 6 lines
Quoted 2 lines
In general looks to me like this driver abuses
devm_infra in ways which make it more complex than it needs to be :(Sry, can't agree here. This allows me to keep release sequence in sane way and get rid of mostly all goto for fail cases (which are constant source of errors for complex initialization sequences) by using standard framework.
As a reviewer I can tell you with absolute certainty that using devm anywhere but in the probe function makes the driver a lot harder to review.
IMHO the API to remove registered callbacks should be avoided like the plague.
Quoted 15 lines
Regarding PM runtime
- many Linux core framework providedevm_APIs this and other
drivers are happy to use them.
- but, there is the problem: DD release sequence isdrv->remove(dev); devres_release_all(dev);and there is no
devm_API for PM runtime. So, if some initialization step is done withdevm_API and It depends on device to be active - no way to solve it in .remove() callback easily. For example,devm_of_platform_populate().With above code I ensure that:
Quoted 7 lines
drv->remove(dev);
|-pm_runtime_get()
devres_release_all(dev);|- devm_of_platform_populate_release() |- pm_runtime_put() |- pm_runtime_disable()
Add devm_pm_* helpers for PM then? That'd the preferred solution upstream.
PATCH v2 6/9 arm64: dts: ti: k3-am65-mcu: add cpsw nuss node
In reply to Grygorii StrashkoAdd DT node for the TI AM65x SoC Gigabit Ethernet two ports Switch subsystem (CPSW NUSS).
--- arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi | 49 +++++++++++++++++++++++++ arch/arm64/boot/dts/ti/k3-am65.dtsi | 1 + 2 files changed, 50 insertions(+)
arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi +49 -0
@@ -193,4 +193,53 @@ #size-cells = <0>; }; }; + + mcu_cpsw: ethernet@46000000 { + compatible = "ti,am654-cpsw-nuss"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x0 0x46000000 0x0 0x200000>; + reg-names = "cpsw_nuss"; + ranges = <0x0 0x0 0x0 0x46000000 0x0 0x200000>; + dma-coherent; + clocks = <&k3_clks 5 10>; + clock-names = "fck"; + power-domains = <&k3_pds 5 TI_SCI_PD_EXCLUSIVE>; + + dmas = <&mcu_udmap 0xf000>, + <&mcu_udmap 0xf001>, + <&mcu_udmap 0xf002>, + <&mcu_udmap 0xf003>, + <&mcu_udmap 0xf004>, + <&mcu_udmap 0xf005>, + <&mcu_udmap 0xf006>, + <&mcu_udmap 0xf007>, + <&mcu_udmap 0x7000>; + dma-names = "tx0", "tx1", "tx2", "tx3", + "tx4", "tx5", "tx6", "tx7", + "rx"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + cpsw_port1: port@1 { + reg = <1>; + ti,mac-only; + label = "port1"; + ti,syscon-efuse = <&mcu_conf 0x200>; + phys = <&phy_gmii_sel 1>; + }; + }; + + davinci_mdio: mdio@f00 { + compatible = "ti,cpsw-mdio","ti,davinci_mdio"; + reg = <0x0 0xf00 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&k3_clks 5 10>; + clock-names = "fck"; + bus_freq = <1000000>; + }; + }; };
arch/arm64/boot/dts/ti/k3-am65.dtsi +1 -0
@@ -30,6 +30,7 @@ i2c3 = &main_i2c1; i2c4 = &main_i2c2; i2c5 = &main_i2c3; + ethernet0 = &cpsw_port1; }; chosen { };
Signature · 1 line
2.17.1
PATCH v2 7/9 arm64: dts: k3-am654-base-board: add mcu cpsw nuss pinmux and phy defs
In reply to Grygorii StrashkoAM654 EVM base board has TI DP83867 PHY connected to external CPSW NUSS Port 1 in rgmii-rxid mode.
Hence, add pinmux and Ethernet PHY configuration for TI am654 SoC Gigabit Ethernet two ports Switch subsystem (CPSW NUSS).
--- .../arm64/boot/dts/ti/k3-am654-base-board.dts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/arm64/boot/dts/ti/k3-am654-base-board.dts +42 -0
@@ -7,6 +7,7 @@ #include "k3-am654.dtsi" #include <dt-bindings/input/input.h> +#include <dt-bindings/net/ti-dp83867.h> / { compatible = "ti,am654-evm", "ti,am654";
@@ -95,7 +96,30 @@ wkup_pca554_default: wkup_pca554_default { pinctrl-single,pins = < AM65X_WKUP_IOPAD(0x0034, PIN_INPUT, 7) /* (T1) MCU_OSPI1_CLK.WKUP_GPIO0_25 */ + >; + }; + + mcu_cpsw_pins_default: mcu_cpsw_pins_default { + pinctrl-single,pins = < + AM65X_WKUP_IOPAD(0x0058, PIN_OUTPUT, 0) /* (N4) MCU_RGMII1_TX_CTL */ + AM65X_WKUP_IOPAD(0x005c, PIN_INPUT, 0) /* (N5) MCU_RGMII1_RX_CTL */ + AM65X_WKUP_IOPAD(0x0060, PIN_OUTPUT, 0) /* (M2) MCU_RGMII1_TD3 */ + AM65X_WKUP_IOPAD(0x0064, PIN_OUTPUT, 0) /* (M3) MCU_RGMII1_TD2 */ + AM65X_WKUP_IOPAD(0x0068, PIN_OUTPUT, 0) /* (M4) MCU_RGMII1_TD1 */ + AM65X_WKUP_IOPAD(0x006c, PIN_OUTPUT, 0) /* (M5) MCU_RGMII1_TD0 */ + AM65X_WKUP_IOPAD(0x0078, PIN_INPUT, 0) /* (L2) MCU_RGMII1_RD3 */ + AM65X_WKUP_IOPAD(0x007c, PIN_INPUT, 0) /* (L5) MCU_RGMII1_RD2 */ + AM65X_WKUP_IOPAD(0x0080, PIN_INPUT, 0) /* (M6) MCU_RGMII1_RD1 */ + AM65X_WKUP_IOPAD(0x0084, PIN_INPUT, 0) /* (L6) MCU_RGMII1_RD0 */ + AM65X_WKUP_IOPAD(0x0070, PIN_INPUT, 0) /* (N1) MCU_RGMII1_TXC */ + AM65X_WKUP_IOPAD(0x0074, PIN_INPUT, 0) /* (M1) MCU_RGMII1_RXC */ + >; + }; + mcu_mdio_pins_default: mcu_mdio1_pins_default { + pinctrl-single,pins = < + AM65X_WKUP_IOPAD(0x008c, PIN_OUTPUT, 0) /* (L1) MCU_MDIO0_MDC */ + AM65X_WKUP_IOPAD(0x0088, PIN_INPUT, 0) /* (L4) MCU_MDIO0_MDIO */ >; }; };
@@ -419,3 +443,21 @@ data-lanes = <1 2>; }; }; + +&mcu_cpsw { + pinctrl-names = "default"; + pinctrl-0 = <&mcu_cpsw_pins_default &mcu_mdio_pins_default>; +}; + +&davinci_mdio { + phy0: ethernet-phy@0 { + reg = <0>; + ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>; + ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_4_B_NIB>; + }; +}; + +&cpsw_port1 { + phy-mode = "rgmii-rxid"; + phy-handle = <&phy0>; +};
Signature · 1 line
2.17.1
PATCH v2 8/9 arm64: dts: ti: k3-j721e-mcu: add mcu cpsw nuss node
In reply to Grygorii StrashkoAdd DT node for The TI J721E MCU SoC Gigabit Ethernet subsystem (MCU CPSW NUSS).
--- .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi | 49 +++++++++++++++++++ arch/arm64/boot/dts/ti/k3-j721e.dtsi | 1 + 2 files changed, 50 insertions(+)
arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi +49 -0
@@ -284,4 +284,53 @@ ti,sci-rm-range-rflow = <0x00>; /* GP RFLOW */ }; }; + + mcu_cpsw: ethernet@46000000 { + compatible = "ti,j721e-cpsw-nuss"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x0 0x46000000 0x0 0x200000>; + reg-names = "cpsw_nuss"; + ranges = <0x0 0x0 0x0 0x46000000 0x0 0x200000>; + dma-coherent; + clocks = <&k3_clks 18 22>; + clock-names = "fck"; + power-domains = <&k3_pds 18 TI_SCI_PD_EXCLUSIVE>; + + dmas = <&mcu_udmap 0xf000>, + <&mcu_udmap 0xf001>, + <&mcu_udmap 0xf002>, + <&mcu_udmap 0xf003>, + <&mcu_udmap 0xf004>, + <&mcu_udmap 0xf005>, + <&mcu_udmap 0xf006>, + <&mcu_udmap 0xf007>, + <&mcu_udmap 0x7000>; + dma-names = "tx0", "tx1", "tx2", "tx3", + "tx4", "tx5", "tx6", "tx7", + "rx"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + cpsw_port1: port@1 { + reg = <1>; + ti,mac-only; + label = "port1"; + ti,syscon-efuse = <&mcu_conf 0x200>; + phys = <&phy_gmii_sel 1>; + }; + }; + + davinci_mdio: mdio@f00 { + compatible = "ti,cpsw-mdio","ti,davinci_mdio"; + reg = <0x0 0xf00 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&k3_clks 18 22>; + clock-names = "fck"; + bus_freq = <1000000>; + }; + }; };
arch/arm64/boot/dts/ti/k3-j721e.dtsi +1 -0
@@ -30,6 +30,7 @@ serial9 = &main_uart7; serial10 = &main_uart8; serial11 = &main_uart9; + ethernet0 = &cpsw_port1; }; chosen { };
Signature · 1 line
2.17.1
PATCH v2 9/9 arm64: dts: ti: k3-j721e-common-proc-board: add mcu cpsw nuss pinmux and phy defs
In reply to Grygorii StrashkoThe TI J721E EVM base board has TI DP83867 PHY connected to external CPSW NUSS Port 1 in rgmii-rxid mode.
Hence, add pinmux and Ethernet PHY configuration for TI j721e SoC MCU Gigabit Ethernet two ports Switch subsystem (CPSW NUSS).
--- .../dts/ti/k3-j721e-common-proc-board.dts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+)
arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts +43 -0
@@ -8,6 +8,7 @@ #include "k3-j721e-som-p0.dtsi" #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/input/input.h> +#include <dt-bindings/net/ti-dp83867.h> / { chosen {
@@ -128,6 +129,30 @@ J721E_WKUP_IOPAD(0x38, PIN_INPUT, 0) /* (A23) MCU_OSPI1_LBCLKO */ >; }; + + mcu_cpsw_pins_default: mcu_cpsw_pins_default { + pinctrl-single,pins = < + J721E_WKUP_IOPAD(0x0058, PIN_OUTPUT, 0) /* MCU_RGMII1_TX_CTL */ + J721E_WKUP_IOPAD(0x005c, PIN_INPUT, 0) /* MCU_RGMII1_RX_CTL */ + J721E_WKUP_IOPAD(0x0060, PIN_OUTPUT, 0) /* MCU_RGMII1_TD3 */ + J721E_WKUP_IOPAD(0x0064, PIN_OUTPUT, 0) /* MCU_RGMII1_TD2 */ + J721E_WKUP_IOPAD(0x0068, PIN_OUTPUT, 0) /* MCU_RGMII1_TD1 */ + J721E_WKUP_IOPAD(0x006c, PIN_OUTPUT, 0) /* MCU_RGMII1_TD0 */ + J721E_WKUP_IOPAD(0x0078, PIN_INPUT, 0) /* MCU_RGMII1_RD3 */ + J721E_WKUP_IOPAD(0x007c, PIN_INPUT, 0) /* MCU_RGMII1_RD2 */ + J721E_WKUP_IOPAD(0x0080, PIN_INPUT, 0) /* MCU_RGMII1_RD1 */ + J721E_WKUP_IOPAD(0x0084, PIN_INPUT, 0) /* MCU_RGMII1_RD0 */ + J721E_WKUP_IOPAD(0x0070, PIN_INPUT, 0) /* MCU_RGMII1_TXC */ + J721E_WKUP_IOPAD(0x0074, PIN_INPUT, 0) /* MCU_RGMII1_RXC */ + >; + }; + + mcu_mdio_pins_default: mcu_mdio1_pins_default { + pinctrl-single,pins = < + J721E_WKUP_IOPAD(0x008c, PIN_OUTPUT, 0) /* MCU_MDIO0_MDC */ + J721E_WKUP_IOPAD(0x0088, PIN_INPUT, 0) /* MCU_MDIO0_MDIO */ + >; + }; }; &wkup_uart0 {
@@ -429,3 +454,21 @@ #gpio-cells = <2>; }; }; + +&mcu_cpsw { + pinctrl-names = "default"; + pinctrl-0 = <&mcu_cpsw_pins_default &mcu_mdio_pins_default>; +}; + +&davinci_mdio { + phy0: ethernet-phy@0 { + reg = <0>; + ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>; + ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_4_B_NIB>; + }; +}; + +&cpsw_port1 { + phy-mode = "rgmii-rxid"; + phy-handle = <&phy0>; +};
Signature · 1 line
2.17.1