Introduce ICSSG based ethernet Driver
MD Danish Anwar
reviewerv8 cover Introduce ICSSG based ethernet Driver
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like the implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.
The subsystem includes many accelerators for data processing like multiplier and multiplier-accumulator. It also has peripherals like UART, MII/RGMII, MDIO, etc. Every ICSSG core includes two 32-bit load/store RISC CPU cores called PRUs.
The above features allow it to be used for implementing custom firmware based peripherals like ethernet.
This series adds the YAML documentation and the driver with basic EMAC support for TI AM654 Silicon Rev 2 SoC with the PRU_ICSSG Sub-system. running dual-EMAC firmware.
This currently supports basic EMAC with 1Gbps and 100Mbps link. 10M and half-duplex modes are not yet supported because they require the support of an IEP, which will be added later.
Advanced features like switch-dev and timestamping will be added later.
This is the v8 of the patch series [v1]. This version of the patchset is rebased on 6.5-rc1. There were no active comments on v7.
There series doesn't have any dependency.
Changes from v7 to v8 :
*) Rebased the series on 6.5-rc1.
*) Fixed few formattings.
Changes from v6 to v7 :
*) Added RB tag of Rob in patch 1 of this series. *) Addressed Simon's comment on patch 2 of the series. *) Rebased patchset on next-20230428 linux-next.
Changes from v5 to v6 :
*) Added RB tag of Andrew Lunn in patch 2 of this series. *) Addressed Rob's comment on patch 1 of the series. *) Rebased patchset on next-20230421 linux-next.
Changes from v4 to v5 :
*) Re-arranged properties section in ti,icssg-prueth.yaml file. *) Added requirement for minimum one ethernet port.
*) Fixed some minor formatting errors as asked by Krzysztof. *) Dropped SGMII mode from enum mii_mode as SGMII mode is not currently
supported by the driver.
*) Added switch-case block to handle different phy modes by ICSSG driver.
Changes from v3 to v4 :
*) Addressed Krzysztof's comments and fixed dt_binding_check errors in
patch 1/2.
*) Added interrupt-extended property in ethernet-ports properties section. *) Fixed comments in file icssg_switch_map.h according to the Linux coding
style in patch 2/2. Added Documentation of structures in patch 2/2.
Changes from v2 to v3 :
*) Addressed Rob and Krzysztof's comments on patch 1 of this series.
Fixed indentation. Removed description and pinctrl section from ti,icssg-prueth.yaml file.
*) Addressed Krzysztof, Paolo, Randy, Andrew and Christophe's comments on
patch 2 of this seires.
*) Fixed blanklines in Kconfig and Makefile. Changed structures to const
as suggested by Krzysztof.
*) Fixed while loop logic in emac_tx_complete_packets() API as suggested
by Paolo. Previously in the loop's last iteration 'budget' was 0 and napi_consume_skb would wrongly assume the caller is not in NAPI context Now, budget won't be zero in last iteration of loop.
*) Removed inline functions addr_to_da1() and addr_to_da0() as asked by
Andrew.
*) Added dev_err_probe() instead of dev_err() as suggested by Christophe. *) In ti,icssg-prueth.yaml file, in the patternProperties section of
ethernet-ports, kept the port name as "port" instead of "ethernet-port" as all other drivers were using "port". Will change it if is compulsory to use "ethernet-port".
[v1] https://lore.kernel.org/all/[email protected]/
[v2] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/all/[email protected]/
[v4] https://lore.kernel.org/all/[email protected]/
[v5] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/all/[email protected]/
[v7] https://lore.kernel.org/all/[email protected]/
Thanks and Regards,
Md Danish Anwar
MD Danish Anwar (1):
dt-bindings: net: Add ICSSG Ethernet
Roger Quadros (1):
net: ti: icssg-prueth: Add ICSSG ethernet driver
.../bindings/net/ti,icssg-prueth.yaml | 184 ++ drivers/net/ethernet/ti/Kconfig | 13 + drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/icssg_classifier.c | 361 ++++ drivers/net/ethernet/ti/icssg_config.c | 449 ++++ drivers/net/ethernet/ti/icssg_config.h | 200 ++ drivers/net/ethernet/ti/icssg_ethtool.c | 325 +++ drivers/net/ethernet/ti/icssg_mii_cfg.c | 120 ++ drivers/net/ethernet/ti/icssg_mii_rt.h | 151 ++ drivers/net/ethernet/ti/icssg_prueth.c | 1886 +++++++++++++++++ drivers/net/ethernet/ti/icssg_prueth.h | 248 +++ drivers/net/ethernet/ti/icssg_queues.c | 38 + drivers/net/ethernet/ti/icssg_switch_map.h | 234 ++ 13 files changed, 4211 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml create mode 100644 drivers/net/ethernet/ti/icssg_classifier.c create mode 100644 drivers/net/ethernet/ti/icssg_config.c create mode 100644 drivers/net/ethernet/ti/icssg_config.h create mode 100644 drivers/net/ethernet/ti/icssg_ethtool.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_cfg.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_rt.h create mode 100644 drivers/net/ethernet/ti/icssg_prueth.c create mode 100644 drivers/net/ethernet/ti/icssg_prueth.h create mode 100644 drivers/net/ethernet/ti/icssg_queues.c create mode 100644 drivers/net/ethernet/ti/icssg_switch_map.h
Signature · 1 line
2.34.1
MD Danish Anwar
reviewerPATCH v8 1/2 dt-bindings: net: Add ICSSG Ethernet
Add a YAML binding document for the ICSSG Programmable real time unit based Ethernet hardware. The ICSSG driver uses the PRU and PRUSS consumer APIs to interface the PRUs and load/run the firmware for supporting ethernet functionality.
--- .../bindings/net/ti,icssg-prueth.yaml | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml
Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml new file +184 -0
@@ -0,0 +1,184 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ti,icssg-prueth.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ICSSG PRUSS Ethernet + +maintainers: + - Md Danish Anwar <[email protected]> + +description: + Ethernet based on the Programmable Real-Time Unit and Industrial + Communication Subsystem. + +allOf: + - $ref: /schemas/remoteproc/ti,pru-consumer.yaml# + +properties: + compatible: + enum: + - ti,am654-icssg-prueth # for AM65x SoC family + + sram: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MSMC SRAM node + + dmas: + maxItems: 10 + + dma-names: + items: + - const: tx0-0 + - const: tx0-1 + - const: tx0-2 + - const: tx0-3 + - const: tx1-0 + - const: tx1-1 + - const: tx1-2 + - const: tx1-3 + - const: rx0 + - const: rx1 + + ti,mii-g-rt: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MII_G_RT module's syscon regmap. + + ti,mii-rt: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MII_RT module's syscon regmap + + interrupts: + maxItems: 2 + description: + Interrupt specifiers to TX timestamp IRQ. + + interrupt-names: + items: + - const: tx_ts0 + - const: tx_ts1 + + ethernet-ports: + type: object + additionalProperties: false + + properties: + '#address-cells': + const: 1 + '#size-cells': + const: 0 + + patternProperties: + ^port@[0-1]$: + type: object + description: ICSSG PRUETH external ports + $ref: ethernet-controller.yaml# + unevaluatedProperties: false + + properties: + reg: + items: + - enum: [0, 1] + description: ICSSG PRUETH port number + + interrupts: + maxItems: 1 + + ti,syscon-rgmii-delay: + items: + - items: + - description: phandle to system controller node + - description: The offset to ICSSG control register + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + phandle to system controller node and register offset + to ICSSG control register for RGMII transmit delay + + required: + - reg + anyOf: + - required: + - port@0 + - required: + - port@1 + +required: + - compatible + - sram + - dmas + - dma-names + - ethernet-ports + - ti,mii-g-rt + - interrupts + - interrupt-names + +unevaluatedProperties: false + +examples: + - | + /* Example k3-am654 base board SR2.0, dual-emac */ + pruss2_eth: ethernet { + compatible = "ti,am654-icssg-prueth"; + pinctrl-names = "default"; + pinctrl-0 = <&icssg2_rgmii_pins_default>; + sram = <&msmc_ram>; + + ti,prus = <&pru2_0>, <&rtu2_0>, <&tx_pru2_0>, + <&pru2_1>, <&rtu2_1>, <&tx_pru2_1>; + firmware-name = "ti-pruss/am65x-pru0-prueth-fw.elf", + "ti-pruss/am65x-rtu0-prueth-fw.elf", + "ti-pruss/am65x-txpru0-prueth-fw.elf", + "ti-pruss/am65x-pru1-prueth-fw.elf", + "ti-pruss/am65x-rtu1-prueth-fw.elf", + "ti-pruss/am65x-txpru1-prueth-fw.elf"; + ti,pruss-gp-mux-sel = <2>, /* MII mode */ + <2>, + <2>, + <2>, /* MII mode */ + <2>, + <2>; + dmas = <&main_udmap 0xc300>, /* egress slice 0 */ + <&main_udmap 0xc301>, /* egress slice 0 */ + <&main_udmap 0xc302>, /* egress slice 0 */ + <&main_udmap 0xc303>, /* egress slice 0 */ + <&main_udmap 0xc304>, /* egress slice 1 */ + <&main_udmap 0xc305>, /* egress slice 1 */ + <&main_udmap 0xc306>, /* egress slice 1 */ + <&main_udmap 0xc307>, /* egress slice 1 */ + <&main_udmap 0x4300>, /* ingress slice 0 */ + <&main_udmap 0x4301>; /* ingress slice 1 */ + dma-names = "tx0-0", "tx0-1", "tx0-2", "tx0-3", + "tx1-0", "tx1-1", "tx1-2", "tx1-3", + "rx0", "rx1"; + ti,mii-g-rt = <&icssg2_mii_g_rt>; + interrupt-parent = <&icssg2_intc>; + interrupts = <24 0 2>, <25 1 3>; + interrupt-names = "tx_ts0", "tx_ts1"; + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + pruss2_emac0: port@0 { + reg = <0>; + phy-handle = <&pruss2_eth0_phy>; + phy-mode = "rgmii-id"; + interrupts-extended = <&icssg2_intc 24>; + ti,syscon-rgmii-delay = <&scm_conf 0x4120>; + /* Filled in by bootloader */ + local-mac-address = [00 00 00 00 00 00]; + }; + + pruss2_emac1: port@1 { + reg = <1>; + phy-handle = <&pruss2_eth1_phy>; + phy-mode = "rgmii-id"; + interrupts-extended = <&icssg2_intc 25>; + ti,syscon-rgmii-delay = <&scm_conf 0x4124>; + /* Filled in by bootloader */ + local-mac-address = [00 00 00 00 00 00]; + }; + }; + };
Signature · 1 line
2.34.1
MD Danish Anwar
reviewerPATCH v8 2/2 net: ti: icssg-prueth: Add ICSSG ethernet driver
In reply to MD Danish AnwarFrom: Roger Quadros <[email protected]>
This is the Ethernet driver for TI AM654 Silicon rev. 2 with the ICSSG PRU Sub-system running dual-EMAC firmware.
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.
Every ICSSG core has two Programmable Real-Time Unit(PRUs), two auxiliary Real-Time Transfer Unit (RT_PRUs), and
two Transmit Real-Time Transfer Units (TX_PRUs). Each one of these runs its own firmware. Every ICSSG core has two MII ports connect to these PRUs and also a MDIO port.
The cores can run different firmwares to support different protocols and features like switch-dev, timestamping, etc.
It uses System DMA to transfer and receive packets and shared memory register emulation between the firmware and driver for control and configuration.
This patch adds support for basic EMAC functionality with 1Gbps and 100Mbps link speed. 10M and half duplex mode are not supported currently as they require IEP, the support for which will be added later. Support for switch-dev, timestamp, etc. will be added later by subsequent patch series.
--- drivers/net/ethernet/ti/Kconfig | 13 + drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/icssg_classifier.c | 361 ++++ drivers/net/ethernet/ti/icssg_config.c | 449 +++++ drivers/net/ethernet/ti/icssg_config.h | 200 +++ drivers/net/ethernet/ti/icssg_ethtool.c | 325 ++++ drivers/net/ethernet/ti/icssg_mii_cfg.c | 120 ++ drivers/net/ethernet/ti/icssg_mii_rt.h | 151 ++ drivers/net/ethernet/ti/icssg_prueth.c | 1886 ++++++++++++++++++++ drivers/net/ethernet/ti/icssg_prueth.h | 248 +++ drivers/net/ethernet/ti/icssg_queues.c | 38 + drivers/net/ethernet/ti/icssg_switch_map.h | 234 +++ 12 files changed, 4027 insertions(+) create mode 100644 drivers/net/ethernet/ti/icssg_classifier.c create mode 100644 drivers/net/ethernet/ti/icssg_config.c create mode 100644 drivers/net/ethernet/ti/icssg_config.h create mode 100644 drivers/net/ethernet/ti/icssg_ethtool.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_cfg.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_rt.h create mode 100644 drivers/net/ethernet/ti/icssg_prueth.c create mode 100644 drivers/net/ethernet/ti/icssg_prueth.h create mode 100644 drivers/net/ethernet/ti/icssg_queues.c create mode 100644 drivers/net/ethernet/ti/icssg_switch_map.h
drivers/net/ethernet/ti/Kconfig +13 -0
@@ -183,4 +183,17 @@ config CPMAC help TI AR7 CPMAC Ethernet support +config TI_ICSSG_PRUETH + tristate "TI Gigabit PRU Ethernet driver" + select PHYLIB + depends on PRU_REMOTEPROC + depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER + help + Support dual Gigabit Ethernet ports over the ICSSG PRU Subsystem. + This subsystem is available starting with the AM65 platform. + + This driver requires firmware binaries which will run on the PRUs + to support the Ethernet operation. Currently, it supports Ethernet + with 1G and 100M link speed. + endif # NET_VENDOR_TI
drivers/net/ethernet/ti/Makefile +2 -0
@@ -28,3 +28,5 @@ 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-cppi-desc-pool.o am65-cpsw-qos.o ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o +obj-$(CONFIG_TI_ICSSG_PRUETH) += icssg-prueth.o +icssg-prueth-y := icssg_prueth.o icssg_classifier.o icssg_ethtool.o icssg_queues.o icssg_config.o k3-cppi-desc-pool.o icssg_mii_cfg.o
drivers/net/ethernet/ti/icssg_classifier.c new file +361 -0
361 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_config.c new file +449 -0
449 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_config.h new file +200 -0
200 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_ethtool.c new file +325 -0
325 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_mii_cfg.c new file +120 -0
120 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_mii_rt.h new file +151 -0
151 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_prueth.c new file +1886 -0
1,372 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_prueth.h new file +248 -0
248 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_queues.c new file +38 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/ti/icssg_switch_map.h new file +234 -0
234 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v8 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
Quoted 38 lines · MD Danish Anwar
From: Roger Quadros <[email protected]>
This is the Ethernet driver for TI AM654 Silicon rev. 2 with the ICSSG PRU Sub-system running dual-EMAC firmware.
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (
PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.Every ICSSG core has two Programmable Real-Time Unit(PRUs), two auxiliary Real-Time Transfer Unit (
RT_PRUs), and
two Transmit Real-Time Transfer Units (TX_PRUs). Each one of these runs its own firmware. Every ICSSG core has two MII ports connect to these PRUs and also a MDIO port.The cores can run different firmwares to support different protocols and features like switch-dev, timestamping, etc.
It uses System DMA to transfer and receive packets and shared memory register emulation between the firmware and driver for control and configuration.
This patch adds support for basic EMAC functionality with 1Gbps and 100Mbps link speed. 10M and half duplex mode are not supported currently as they require IEP, the support for which will be added later. Support for switch-dev, timestamp, etc. will be added later by subsequent patch series.
Signed-off-by Roger Quadros <[email protected]>[Vignesh Raghavendra: add 10M full duplex support]Signed-off-by Vignesh Raghavendra <[email protected]>[Grygorii Strashko: add support for half duplex operation]Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Puranjay Mohan <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Signed-off-by MD Danish Anwar <[email protected]>
...
Quoted 6 lines
drivers/net/ethernet/ti/icssg_config.c new file +6
-0+/** +* struct map - ICSSG Queue Map +* @queue: Queue number +* @pd_addr_start: Packet descriptor queue reserved memory +* @flags: Flags +* @special: Indicates whether this queue is a special queue or not
drivers/net/ethernet/ti/icssg_config.c line 91
Quoted 10 lines
drivers/net/ethernet/ti/icssg_config.c new file +10
-0+*/ +struct map { +int queue; +u32 pd_addr_start; +u32 flags; +bool special; +}; + +/* Hardware queue map for ICSSG */ +const struct map hwq_map[2 ][ICSSG_NUM_OTHER_QUEUES ] = {
Should this be static?
Quoted 89 lines
drivers/net/ethernet/ti/icssg_config.c new file +89
-0+ { + { PORT_HI_Q_SLICE0, PORT_DESC0_HI, 0x200000, 0 }, + { PORT_LO_Q_SLICE0, PORT_DESC0_LO, 0, 0 }, + { HOST_HI_Q_SLICE0, HOST_DESC0_HI, 0x200000, 0 }, + { HOST_LO_Q_SLICE0, HOST_DESC0_LO, 0, 0 }, + { HOST_SPL_Q_SLICE0, HOST_SPPD0, 0x400000, 1 }, + }, + { + { PORT_HI_Q_SLICE1, PORT_DESC1_HI, 0xa00000, 0 }, + { PORT_LO_Q_SLICE1, PORT_DESC1_LO, 0x800000, 0 }, + { HOST_HI_Q_SLICE1, HOST_DESC1_HI, 0xa00000, 0 }, + { HOST_LO_Q_SLICE1, HOST_DESC1_LO, 0x800000, 0 }, + { HOST_SPL_Q_SLICE1, HOST_SPPD1, 0xc00000, 1 }, + }, +}; + +static void icssg_config_mii_init(struct prueth_emac *emac) +{ + u32 rxcfg, txcfg, rxcfg_reg, txcfg_reg, pcnt_reg; + struct prueth *prueth = emac->prueth; + int slice = prueth_emac_slice(emac); + struct regmap *mii_rt; + + mii_rt = prueth->mii_rt; + + rxcfg_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_RXCFG0 : + PRUSS_MII_RT_RXCFG1; + txcfg_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_TXCFG0 : + PRUSS_MII_RT_TXCFG1; + pcnt_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_RX_PCNT0 : + PRUSS_MII_RT_RX_PCNT1; + + rxcfg = MII_RXCFG_DEFAULT; + txcfg = MII_TXCFG_DEFAULT; + + if (slice == ICSS_MII1) + rxcfg |= PRUSS_MII_RT_RXCFG_RX_MUX_SEL; + + /* In MII mode TX lines swapped inside ICSSG, so TX_MUX_SEL cfg need + * to be swapped also comparing to RGMII mode. + */ + if (emac->phy_if == PHY_INTERFACE_MODE_MII && slice == ICSS_MII0) + txcfg |= PRUSS_MII_RT_TXCFG_TX_MUX_SEL; + else if (emac->phy_if != PHY_INTERFACE_MODE_MII && slice == ICSS_MII1) + txcfg |= PRUSS_MII_RT_TXCFG_TX_MUX_SEL; + + regmap_write(mii_rt, rxcfg_reg, rxcfg); + regmap_write(mii_rt, txcfg_reg, txcfg); + regmap_write(mii_rt, pcnt_reg, 0x1); +} + +static void icssg_miig_queues_init(struct prueth *prueth, int slice) +{ + struct regmap *miig_rt = prueth->miig_rt; + void __iomem *smem = prueth->shram.va; + u8 pd[ICSSG_SPECIAL_PD_SIZE]; + int queue = 0, i, j; + u32 *pdword; + + /* reset hwqueues */ + if (slice) + queue = ICSSG_NUM_TX_QUEUES; + + for (i = 0; i < ICSSG_NUM_TX_QUEUES; i++) { + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, queue); + queue++; + } + + queue = slice ? RECYCLE_Q_SLICE1 : RECYCLE_Q_SLICE0; + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, queue); + + for (i = 0; i < ICSSG_NUM_OTHER_QUEUES; i++) { + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, + hwq_map[slice][i].queue); + } + + /* initialize packet descriptors in SMEM */ + /* push pakcet descriptors to hwqueues */ + + pdword = (u32 *)pd; + for (j = 0; j < ICSSG_NUM_OTHER_QUEUES; j++) { + const struct map *mp; + int pd_size, num_pds; + u32 pdaddr; + + mp = &hwq_map[slice][j]; + if (mp->special) { + pd_size = ICSSG_SPECIAL_PD_SIZE; + num_pds = ICSSG_NUM_SPECIAL_PDS;
drivers/net/ethernet/ti/icssg_config.c line 190
Quoted 10 lines
drivers/net/ethernet/ti/icssg_config.c new file +10
-0+ }else { + pd_size =ICSSG_NORMAL_PD_SIZE ; + num_pds =ICSSG_NUM_NORMAL_PDS ; + } + +for (i =0 ; i < num_pds; i++) { +memset (pd,0 , pd_size); + + pdword[0 ] &=cpu_to_le32 (ICSSG_FLAG_MASK ); + pdword[0 ] |=cpu_to_le32 (mp->flags);
Sparse warns that the endieness of pdword is not le32. There are also other sparse warnings added by this patch. Please look over them.
Quoted 9 lines
drivers/net/ethernet/ti/icssg_config.c new file +9
-0+ pdaddr = mp->pd_addr_start + i * pd_size; + +memcpy_toio (smem + pdaddr, pd, pd_size); + queue = mp->queue; +regmap_write (miig_rt,ICSSG_QUEUE_OFFSET +4 * queue, + pdaddr); + } + } +}
...
Quoted 20 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +20
-0+static int prueth_netdev_init (struct prueth *prueth, +struct device_node *eth_node) +{ +int ret, num_tx_chn =PRUETH_MAX_TX_QUEUES ; +struct prueth_emac *emac; +struct net_device *ndev; +enum prueth_port port; +enum prueth_mac mac; + + port =prueth_node_port (eth_node); +if (port <0 ) +return -EINVAL ; + + mac =prueth_node_mac (eth_node); +if (mac <0 ) +return -EINVAL ; + + ndev =alloc_etherdev_mq (sizeof (*emac), num_tx_chn); +if (!ndev) +return -ENOMEM ;
...
drivers/net/ethernet/ti/icssg_prueth.c line 1430
Quoted 11 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +11
-0+return 0 ; + +free: +pruss_release_mem_region (prueth->pruss, &emac->dram); +free_wq: +destroy_workqueue (emac->cmd_wq); +free_ndev: +free_netdev (ndev); + prueth->emac[mac] =NULL ; + +return ret;
ndev appears to be leaked here.
...
Quoted 22 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +22
-0+ prueth->dev = dev; + eth_ports_node =of_get_child_by_name (np,"ethernet-ports" ); +if (!eth_ports_node) +return -ENOENT ; + +for_each_child_of_node (eth_ports_node, eth_node) { +u32 reg; + +if (strcmp (eth_node->name,"port" )) +continue ; + ret =of_property_read_u32 (eth_node,"reg" , ®); +if (ret <0 ) { +dev_err (dev,"%pOF error reading port_id %d\n" , + eth_node, ret); + } + +of_node_get (eth_node); + +if (reg ==0 ) { + eth0_node = eth_node; +if (!of_device_is_available (eth0_node)) { +of_node_put (eth0_node);
drivers/net/ethernet/ti/icssg_prueth.c line 1578
Quoted 10 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +10
-0+ eth0_node =NULL ; + } + }else if (reg ==1 ) { + eth1_node = eth_node; +if (!of_device_is_available (eth1_node)) { +of_node_put (eth1_node); + eth1_node =NULL ; + } + }else { +dev_err (dev,"port reg should be 0 or 1\n" );
Should this be treated as an error and either return or goto an unwind path?
drivers/net/ethernet/ti/icssg_prueth.c line 1585
Quoted 7 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +7
-0+ } + } + +of_node_put (eth_ports_node); + +/* At least one node must be present and available else we fail */ +if (!eth0_node && !eth1_node) {
Smatch warns that eth0_node and eth1_node may be uninitialised here.
Quoted 9 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +9
-0+dev_err (dev,"neither port0 nor port1 node available\n" ); +return -ENODEV ; + } + +if (eth0_node == eth1_node) { +dev_err (dev,"port0 and port1 can't have same reg\n" ); +of_node_put (eth0_node); +return -ENODEV ; + }
...
Signature · 1 line
pw-bot: changes-requested
Re: [EXTERNAL] Re: [PATCH v8 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
Hi Simon
Quoted 52 lines · Simon Horman
Quoted 38 lines · MD Danish Anwar
From: Roger Quadros <[email protected]>
This is the Ethernet driver for TI AM654 Silicon rev. 2 with the ICSSG PRU Sub-system running dual-EMAC firmware.
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (
PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.Every ICSSG core has two Programmable Real-Time Unit(PRUs), two auxiliary Real-Time Transfer Unit (
RT_PRUs), and
two Transmit Real-Time Transfer Units (TX_PRUs). Each one of these runs its own firmware. Every ICSSG core has two MII ports connect to these PRUs and also a MDIO port.The cores can run different firmwares to support different protocols and features like switch-dev, timestamping, etc.
It uses System DMA to transfer and receive packets and shared memory register emulation between the firmware and driver for control and configuration.
This patch adds support for basic EMAC functionality with 1Gbps and 100Mbps link speed. 10M and half duplex mode are not supported currently as they require IEP, the support for which will be added later. Support for switch-dev, timestamp, etc. will be added later by subsequent patch series.
Signed-off-by Roger Quadros <[email protected]>[Vignesh Raghavendra: add 10M full duplex support]Signed-off-by Vignesh Raghavendra <[email protected]>[Grygorii Strashko: add support for half duplex operation]Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Puranjay Mohan <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Signed-off-by MD Danish Anwar <[email protected]>...
Quoted 10 lines
drivers/net/ethernet/ti/icssg_config.c new file +10
-0+/** +* struct map - ICSSG Queue Map +* @queue: Queue number +* @pd_addr_start: Packet descriptor queue reserved memory +* @flags: Flags +* @special: Indicates whether this queue is a special queue or not +*/ +struct map { +int queue; +u32 pd_addr_start;
Quoted 9 lines
drivers/net/ethernet/ti/icssg_config.c line 91
Quoted 6 lines
drivers/net/ethernet/ti/icssg_config.c new file +6
-0+u32 flags; +bool special; +}; + +/* Hardware queue map for ICSSG */ +const struct map hwq_map[2 ][ICSSG_NUM_OTHER_QUEUES ] = {Should this be static?
Yes this can be static. I will change this to static.
Quoted 93 lines
Quoted 93 lines
drivers/net/ethernet/ti/icssg_config.c new file +93
-0+ { + { PORT_HI_Q_SLICE0, PORT_DESC0_HI, 0x200000, 0 }, + { PORT_LO_Q_SLICE0, PORT_DESC0_LO, 0, 0 }, + { HOST_HI_Q_SLICE0, HOST_DESC0_HI, 0x200000, 0 }, + { HOST_LO_Q_SLICE0, HOST_DESC0_LO, 0, 0 }, + { HOST_SPL_Q_SLICE0, HOST_SPPD0, 0x400000, 1 }, + }, + { + { PORT_HI_Q_SLICE1, PORT_DESC1_HI, 0xa00000, 0 }, + { PORT_LO_Q_SLICE1, PORT_DESC1_LO, 0x800000, 0 }, + { HOST_HI_Q_SLICE1, HOST_DESC1_HI, 0xa00000, 0 }, + { HOST_LO_Q_SLICE1, HOST_DESC1_LO, 0x800000, 0 }, + { HOST_SPL_Q_SLICE1, HOST_SPPD1, 0xc00000, 1 }, + }, +}; + +static void icssg_config_mii_init(struct prueth_emac *emac) +{ + u32 rxcfg, txcfg, rxcfg_reg, txcfg_reg, pcnt_reg; + struct prueth *prueth = emac->prueth; + int slice = prueth_emac_slice(emac); + struct regmap *mii_rt; + + mii_rt = prueth->mii_rt; + + rxcfg_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_RXCFG0 : + PRUSS_MII_RT_RXCFG1; + txcfg_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_TXCFG0 : + PRUSS_MII_RT_TXCFG1; + pcnt_reg = (slice == ICSS_MII0) ? PRUSS_MII_RT_RX_PCNT0 : + PRUSS_MII_RT_RX_PCNT1; + + rxcfg = MII_RXCFG_DEFAULT; + txcfg = MII_TXCFG_DEFAULT; + + if (slice == ICSS_MII1) + rxcfg |= PRUSS_MII_RT_RXCFG_RX_MUX_SEL; + + /* In MII mode TX lines swapped inside ICSSG, so TX_MUX_SEL cfg need + * to be swapped also comparing to RGMII mode. + */ + if (emac->phy_if == PHY_INTERFACE_MODE_MII && slice == ICSS_MII0) + txcfg |= PRUSS_MII_RT_TXCFG_TX_MUX_SEL; + else if (emac->phy_if != PHY_INTERFACE_MODE_MII && slice == ICSS_MII1) + txcfg |= PRUSS_MII_RT_TXCFG_TX_MUX_SEL; + + regmap_write(mii_rt, rxcfg_reg, rxcfg); + regmap_write(mii_rt, txcfg_reg, txcfg); + regmap_write(mii_rt, pcnt_reg, 0x1); +} + +static void icssg_miig_queues_init(struct prueth *prueth, int slice) +{ + struct regmap *miig_rt = prueth->miig_rt; + void __iomem *smem = prueth->shram.va; + u8 pd[ICSSG_SPECIAL_PD_SIZE]; + int queue = 0, i, j; + u32 *pdword; + + /* reset hwqueues */ + if (slice) + queue = ICSSG_NUM_TX_QUEUES; + + for (i = 0; i < ICSSG_NUM_TX_QUEUES; i++) { + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, queue); + queue++; + } + + queue = slice ? RECYCLE_Q_SLICE1 : RECYCLE_Q_SLICE0; + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, queue); + + for (i = 0; i < ICSSG_NUM_OTHER_QUEUES; i++) { + regmap_write(miig_rt, ICSSG_QUEUE_RESET_OFFSET, + hwq_map[slice][i].queue); + } + + /* initialize packet descriptors in SMEM */ + /* push pakcet descriptors to hwqueues */ + + pdword = (u32 *)pd; + for (j = 0; j < ICSSG_NUM_OTHER_QUEUES; j++) { + const struct map *mp; + int pd_size, num_pds; + u32 pdaddr; + + mp = &hwq_map[slice][j]; + if (mp->special) { + pd_size = ICSSG_SPECIAL_PD_SIZE; + num_pds = ICSSG_NUM_SPECIAL_PDS; + } else { + pd_size = ICSSG_NORMAL_PD_SIZE; + num_pds = ICSSG_NUM_NORMAL_PDS; + }
Quoted 8 lines
drivers/net/ethernet/ti/icssg_config.c line 190
Quoted 6 lines
drivers/net/ethernet/ti/icssg_config.c new file +6
-0+ +for (i =0 ; i < num_pds; i++) { +memset (pd,0 , pd_size); + + pdword[0 ] &=cpu_to_le32 (ICSSG_FLAG_MASK ); + pdword[0 ] |=cpu_to_le32 (mp->flags);Sparse warns that the endieness of pdword is not le32.
I will fix this.
Quoted 2 lines
There are also other sparse warnings added by this patch. Please look over them.
There is one more warning for "expected restricted __le16 [usertype] rx_base_flow got restricted __le32 [usertype]". I will fix this as well.
There is one more sparse warning "warning: symbol 'icssg_ethtool_ops' was not declared. Should it be static?". This should be ignored as no need to change 'icssg_ethtool_ops' to static as this is decalred in icssg_ethtool.c and used in icssg_prueth.c
Quoted 79 lines
Quoted 10 lines
drivers/net/ethernet/ti/icssg_config.c new file +9
-0+ pdaddr = mp->pd_addr_start + i * pd_size; + +memcpy_toio (smem + pdaddr, pd, pd_size); + queue = mp->queue; +regmap_write (miig_rt,ICSSG_QUEUE_OFFSET +4 * queue, + pdaddr); + } + } +}...
Quoted 20 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +20
-0+static int prueth_netdev_init (struct prueth *prueth, +struct device_node *eth_node) +{ +int ret, num_tx_chn =PRUETH_MAX_TX_QUEUES ; +struct prueth_emac *emac; +struct net_device *ndev; +enum prueth_port port; +enum prueth_mac mac; + + port =prueth_node_port (eth_node); +if (port <0 ) +return -EINVAL ; + + mac =prueth_node_mac (eth_node); +if (mac <0 ) +return -EINVAL ; + + ndev =alloc_etherdev_mq (sizeof (*emac), num_tx_chn); +if (!ndev) +return -ENOMEM ;...
drivers/net/ethernet/ti/icssg_prueth.c line 1430
Quoted 11 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +11
-0+return 0 ; + +free: +pruss_release_mem_region (prueth->pruss, &emac->dram); +free_wq: +destroy_workqueue (emac->cmd_wq); +free_ndev: +free_netdev (ndev); + prueth->emac[mac] =NULL ; + +return ret;ndev appears to be leaked here.
...
Quoted 27 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +27
-0+ prueth->dev = dev; + eth_ports_node =of_get_child_by_name (np,"ethernet-ports" ); +if (!eth_ports_node) +return -ENOENT ; + +for_each_child_of_node (eth_ports_node, eth_node) { +u32 reg; + +if (strcmp (eth_node->name,"port" )) +continue ; + ret =of_property_read_u32 (eth_node,"reg" , ®); +if (ret <0 ) { +dev_err (dev,"%pOF error reading port_id %d\n" , + eth_node, ret); + } + +of_node_get (eth_node); + +if (reg ==0 ) { + eth0_node = eth_node; +if (!of_device_is_available (eth0_node)) { +of_node_put (eth0_node); + eth0_node =NULL ; + } + }else if (reg ==1 ) { + eth1_node = eth_node; +if (!of_device_is_available (eth1_node)) {
Quoted 9 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1578
Quoted 5 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +5
-0+of_node_put (eth1_node); + eth1_node =NULL ; + } + }else { +dev_err (dev,"port reg should be 0 or 1\n" );Should this be treated as an error and either return or goto an unwind path?
I don't think we should error out or return to any goto label here. Here we are checking 'reg' property in all available ports. If reg=0, we assign the node to eth0_node. If reg=1, we assign the node to eth1_node. If the reg is neither 0 nor 1, we will just keep looking through other available ports, instead of returning error. We will eventually look through all available nodes.
Once we come out of the for loop, we should at least have one node with reg property being either 0 or 1. If no node had reg as 0 or 1, both eth0_node and eth1_node will be NULL, then we will error out with -ENODEV error by below if check.
if (!eth0_node && !eth1_node) {
dev_err(dev, "neither port0 nor port1 node available\n");
return -ENODEV;
}Quoted 10 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1585
Quoted 7 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +7
-0+ } + } + +of_node_put (eth_ports_node); + +/* At least one node must be present and available else we fail */ +if (!eth0_node && !eth1_node) {Smatch warns that
eth0_nodeandeth1_nodemay be uninitialised here.
Sure, I will initialise eth0_node and eth1_node as NULL.
Quoted 12 lines
Quoted 9 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +9
-0+dev_err (dev,"neither port0 nor port1 node available\n" ); +return -ENODEV ; + } + +if (eth0_node == eth1_node) { +dev_err (dev,"port0 and port1 can't have same reg\n" ); +of_node_put (eth0_node); +return -ENODEV ; + }...
Signature · 2 lines
Thanks and Regards, Md Danish Anwar
Re: [EXTERNAL] Re: [PATCH v8 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
Hi Anwar,
Quoted 4 lines · Md Danish
Hi Simon
Quoted 2 lines · Simon Horman
Quoted 1 line · MD Danish Anwar
From: Roger Quadros <[email protected]>
...
Quoted 51 lines
Quoted 42 lines
Quoted 42 lines
drivers/net/ethernet/ti/icssg_config.c new file +42
-0+static void icssg_miig_queues_init (struct prueth *prueth,int slice) +{ +struct regmap *miig_rt = prueth->miig_rt; +void __iomem *smem = prueth->shram.va; +u8 pd[ICSSG_SPECIAL_PD_SIZE ]; +int queue =0 , i, j; +u32 *pdword; + +/* reset hwqueues */ +if (slice) + queue =ICSSG_NUM_TX_QUEUES ; + +for (i =0 ; i <ICSSG_NUM_TX_QUEUES ; i++) { +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , queue); + queue++; + } + + queue = slice ?RECYCLE_Q_SLICE1 :RECYCLE_Q_SLICE0 ; +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , queue); + +for (i =0 ; i <ICSSG_NUM_OTHER_QUEUES ; i++) { +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , + hwq_map[slice][i].queue); + } + +/* initialize packet descriptors in SMEM */ +/* push pakcet descriptors to hwqueues */ + + pdword = (u32 *)pd; +for (j =0 ; j <ICSSG_NUM_OTHER_QUEUES ; j++) { +const struct map *mp; +int pd_size, num_pds; +u32 pdaddr; + + mp = &hwq_map[slice][j]; +if (mp->special) { + pd_size =ICSSG_SPECIAL_PD_SIZE ; + num_pds =ICSSG_NUM_SPECIAL_PDS ; + }else { + pd_size =ICSSG_NORMAL_PD_SIZE ; + num_pds =ICSSG_NUM_NORMAL_PDS ; + }Quoted 8 lines
drivers/net/ethernet/ti/icssg_config.c line 190
Quoted 6 lines
drivers/net/ethernet/ti/icssg_config.c new file +6
-0+ +for (i =0 ; i < num_pds; i++) { +memset (pd,0 , pd_size); + + pdword[0 ] &=cpu_to_le32 (ICSSG_FLAG_MASK ); + pdword[0 ] |=cpu_to_le32 (mp->flags);Sparse warns that the endieness of pdword is not le32.
Quoted 1 line
I will fix this.
Thanks.
Quoted 5 lines
Quoted 2 lines
There are also other sparse warnings added by this patch. Please look over them.
There is one more warning for "expected restricted
__le16[usertype]rx_base_flowgot restricted__le32[usertype]". I will fix this as well.
I haven't looked carefully through these.
But for the record, this is what Sparse tells me:
.../icssg_config.c:91:18: warning: symbol 'hwq_map' was not declared. Should it be static? .../icssg_config.c:189:35: warning: invalid assignment: &=
.../icssg_config.c:189:35: left side has type unsigned int
.../icssg_config.c:189:35: right side has type restricted __le32
.../icssg_config.c:190:35: warning: invalid assignment: |=
.../icssg_config.c:190:35: left side has type unsigned int
.../icssg_config.c:190:35: right side has type restricted __le32
.../icssg_config.c:225:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:225:11: expected struct icssg_r30_cmd *p
.../icssg_config.c:225:11: got void [noderef] __iomem *
.../icssg_config.c:228:42: warning: incorrect type in argument 2 (different address spaces)
.../icssg_config.c:228:42: expected void volatile [noderef] __iomem *addr
.../icssg_config.c:228:42: got unsigned int *
.../icssg_config.c:237:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:237:11: expected struct icssg_r30_cmd const *p
.../icssg_config.c:237:11: got void [noderef] __iomem *
.../icssg_config.c:240:36: warning: incorrect type in argument 1 (different address spaces)
.../icssg_config.c:240:36: expected void const volatile [noderef] __iomem *addr
.../icssg_config.c:240:36: got unsigned int const *
.../icssg_config.c:270:19: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:270:19: expected struct icssg_buffer_pool_cfg *bpool_cfg
.../icssg_config.c:270:19: got void [noderef] __iomem *
.../icssg_config.c:289:17: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:289:17: expected struct icssg_rxq_ctx *rxq_ctx
.../icssg_config.c:289:17: got void [noderef] __iomem *
.../icssg_config.c:297:17: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:297:17: expected struct icssg_rxq_ctx *rxq_ctx
.../icssg_config.c:297:17: got void [noderef] __iomem *
.../icssg_config.c:325:38: warning: incorrect type in initializer (different address spaces)
.../icssg_config.c:325:38: expected void *config
.../icssg_config.c:325:38: got void [noderef] __iomem *
.../icssg_config.c:332:19: warning: incorrect type in argument 1 (different address spaces)
.../icssg_config.c:332:19: expected void volatile [noderef] __iomem *
.../icssg_config.c:332:19: got void *config
.../icssg_config.c:361:32: warning: incorrect type in assignment (different base types)
.../icssg_config.c:361:32: expected restricted __le16 [usertype] rx_base_flow
.../icssg_config.c:361:32: got restricted __le32 [usertype]
.../icssg_config.c:406:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:406:11: expected struct icssg_r30_cmd *p
.../icssg_config.c:406:11: got void [noderef] __iomem *
.../icssg_config.c:417:61: warning: incorrect type in argument 2 (different address spaces)
.../icssg_config.c:417:61: expected void volatile [noderef] __iomem *addr
.../icssg_config.c:417:61: got unsigned int *
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void const *
.../icssg_prueth.c:1665:9: got void [noderef] __iomem *va
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void const *
.../icssg_prueth.c:1665:9: got void [noderef] __iomem *va
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void *
.../icssg_prueth.c:1665:9: got void [noderef] __iomem *va
Quoted 4 lines
There is one more sparse warning "warning: symbol '
icssg_ethtool_ops' was not declared. Should it be static?". This should be ignored as no need to change 'icssg_ethtool_ops' to static as this is decalred inicssg_ethtool.cand used inicssg_prueth.c
I think the preferred approach there would be to declare the symbol in a header file that is available to both .c files.
...
Quoted 49 lines
Quoted 27 lines
Quoted 27 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +27
-0+ prueth->dev = dev; + eth_ports_node =of_get_child_by_name (np,"ethernet-ports" ); +if (!eth_ports_node) +return -ENOENT ; + +for_each_child_of_node (eth_ports_node, eth_node) { +u32 reg; + +if (strcmp (eth_node->name,"port" )) +continue ; + ret =of_property_read_u32 (eth_node,"reg" , ®); +if (ret <0 ) { +dev_err (dev,"%pOF error reading port_id %d\n" , + eth_node, ret); + } + +of_node_get (eth_node); + +if (reg ==0 ) { + eth0_node = eth_node; +if (!of_device_is_available (eth0_node)) { +of_node_put (eth0_node); + eth0_node =NULL ; + } + }else if (reg ==1 ) { + eth1_node = eth_node; +if (!of_device_is_available (eth1_node)) {Quoted 9 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1578
Quoted 5 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +5
-0+of_node_put (eth1_node); + eth1_node =NULL ; + } + }else { +dev_err (dev,"port reg should be 0 or 1\n" );Should this be treated as an error and either return or goto an unwind path?
I don't think we should error out or return to any goto label here. Here we are checking 'reg' property in all available ports. If reg=0, we assign the node to
eth0_node. If reg=1, we assign the node toeth1_node. If the reg is neither 0 nor 1, we will just keep looking through other available ports, instead of returning error. We will eventually look through all available nodes.Once we come out of the for loop, we should at least have one node with reg property being either 0 or 1. If no node had reg as 0 or 1, both
eth0_nodeandeth1_nodewill be NULL, then we will error out with-ENODEVerror by below if check.
Quoted 4 lines
if (!eth0_node && !eth1_node) {
dev_err(dev, "neither port0 nor port1 node available\n");
return -ENODEV;
}Thanks, that makes sense to me.
Quoted 11 lines
Quoted 10 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1585
Quoted 7 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +7
-0+ } + } + +of_node_put (eth_ports_node); + +/* At least one node must be present and available else we fail */ +if (!eth0_node && !eth1_node) {Smatch warns that
eth0_nodeandeth1_nodemay be uninitialised here.
Quoted 1 line
Sure, I will initialise
eth0_nodeandeth1_nodeas NULL.
Thanks.
...
Re: [EXTERNAL] Re: [EXTERNAL] Re: [PATCH v8 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
Hi Simon,
Quoted 65 lines · Simon Horman
Hi Anwar,
Quoted 4 lines · Md Danish
Hi Simon
Quoted 2 lines · Simon Horman
Quoted 1 line · MD Danish Anwar
From: Roger Quadros <[email protected]>
...
Quoted 51 lines
Quoted 42 lines
Quoted 42 lines
drivers/net/ethernet/ti/icssg_config.c new file +42
-0+static void icssg_miig_queues_init (struct prueth *prueth,int slice) +{ +struct regmap *miig_rt = prueth->miig_rt; +void __iomem *smem = prueth->shram.va; +u8 pd[ICSSG_SPECIAL_PD_SIZE ]; +int queue =0 , i, j; +u32 *pdword; + +/* reset hwqueues */ +if (slice) + queue =ICSSG_NUM_TX_QUEUES ; + +for (i =0 ; i <ICSSG_NUM_TX_QUEUES ; i++) { +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , queue); + queue++; + } + + queue = slice ?RECYCLE_Q_SLICE1 :RECYCLE_Q_SLICE0 ; +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , queue); + +for (i =0 ; i <ICSSG_NUM_OTHER_QUEUES ; i++) { +regmap_write (miig_rt,ICSSG_QUEUE_RESET_OFFSET , + hwq_map[slice][i].queue); + } + +/* initialize packet descriptors in SMEM */ +/* push pakcet descriptors to hwqueues */ + + pdword = (u32 *)pd; +for (j =0 ; j <ICSSG_NUM_OTHER_QUEUES ; j++) { +const struct map *mp; +int pd_size, num_pds; +u32 pdaddr; + + mp = &hwq_map[slice][j]; +if (mp->special) { + pd_size =ICSSG_SPECIAL_PD_SIZE ; + num_pds =ICSSG_NUM_SPECIAL_PDS ; + }else { + pd_size =ICSSG_NORMAL_PD_SIZE ; + num_pds =ICSSG_NUM_NORMAL_PDS ; + }Quoted 8 lines
drivers/net/ethernet/ti/icssg_config.c line 190
Quoted 6 lines
drivers/net/ethernet/ti/icssg_config.c new file +6
-0+ +for (i =0 ; i < num_pds; i++) { +memset (pd,0 , pd_size); + + pdword[0 ] &=cpu_to_le32 (ICSSG_FLAG_MASK ); + pdword[0 ] |=cpu_to_le32 (mp->flags);Sparse warns that the endieness of pdword is not le32.
Quoted 1 line
I will fix this.
Thanks.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
There are also other sparse warnings added by this patch. Please look over them.
There is one more warning for "expected restricted
__le16[usertype]rx_base_flowgot restricted__le32[usertype]". I will fix this as well.I haven't looked carefully through these.
But for the record, this is what Sparse tells me:
I am working on fixing all these sparse warning. I will send next revision after fixing these warning.
Quoted 53 lines
.../icssg_config.c:91:18: warning: symbol 'hwq_map' was not declared. Should it be static?.../icssg_config.c:189:35: warning: invalid assignment: &=
.../icssg_config.c:189:35: left side has type unsigned int
.../icssg_config.c:189:35: right side has type restricted__le32
.../icssg_config.c:190:35: warning: invalid assignment: |=
.../icssg_config.c:190:35: left side has type unsigned int
.../icssg_config.c:190:35: right side has type restricted__le32
.../icssg_config.c:225:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:225:11: expected structicssg_r30_cmd*p
.../icssg_config.c:225:11: got void [noderef]__iomem*
.../icssg_config.c:228:42: warning: incorrect type in argument 2 (different address spaces)
.../icssg_config.c:228:42: expected void volatile [noderef]__iomem*addr
.../icssg_config.c:228:42: got unsigned int *
.../icssg_config.c:237:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:237:11: expected structicssg_r30_cmdconst *p
.../icssg_config.c:237:11: got void [noderef]__iomem*
.../icssg_config.c:240:36: warning: incorrect type in argument 1 (different address spaces)
.../icssg_config.c:240:36: expected void const volatile [noderef]__iomem*addr
.../icssg_config.c:240:36: got unsigned int const *
.../icssg_config.c:270:19: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:270:19: expected structicssg_buffer_pool_cfg*bpool_cfg
.../icssg_config.c:270:19: got void [noderef]__iomem*
.../icssg_config.c:289:17: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:289:17: expected structicssg_rxq_ctx*rxq_ctx
.../icssg_config.c:289:17: got void [noderef]__iomem*
.../icssg_config.c:297:17: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:297:17: expected structicssg_rxq_ctx*rxq_ctx
.../icssg_config.c:297:17: got void [noderef]__iomem*
.../icssg_config.c:325:38: warning: incorrect type in initializer (different address spaces)
.../icssg_config.c:325:38: expected void *config
.../icssg_config.c:325:38: got void [noderef]__iomem*
.../icssg_config.c:332:19: warning: incorrect type in argument 1 (different address spaces)
.../icssg_config.c:332:19: expected void volatile [noderef]__iomem*
.../icssg_config.c:332:19: got void *config
.../icssg_config.c:361:32: warning: incorrect type in assignment (different base types)
.../icssg_config.c:361:32: expected restricted__le16[usertype]rx_base_flow
.../icssg_config.c:361:32: got restricted__le32[usertype]
.../icssg_config.c:406:11: warning: incorrect type in assignment (different address spaces)
.../icssg_config.c:406:11: expected structicssg_r30_cmd*p
.../icssg_config.c:406:11: got void [noderef]__iomem*
.../icssg_config.c:417:61: warning: incorrect type in argument 2 (different address spaces)
.../icssg_config.c:417:61: expected void volatile [noderef]__iomem*addr
.../icssg_config.c:417:61: got unsigned int *
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void const *
.../icssg_prueth.c:1665:9: got void [noderef]__iomem*va
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void const *
.../icssg_prueth.c:1665:9: got void [noderef]__iomem*va
.../icssg_prueth.c:1665:9: warning: incorrect type in argument 1 (different address spaces)
.../icssg_prueth.c:1665:9: expected void *
.../icssg_prueth.c:1665:9: got void [noderef]__iomem*va
Quoted 8 lines
Quoted 4 lines
There is one more sparse warning "warning: symbol '
icssg_ethtool_ops' was not declared. Should it be static?". This should be ignored as no need to change 'icssg_ethtool_ops' to static as this is decalred inicssg_ethtool.cand used inicssg_prueth.cI think the preferred approach there would be to declare the symbol in a header file that is available to both .c files.
Sure. I will keep the declaration in a icssg_prueth.h.
Quoted 69 lines
...
Quoted 49 lines
Quoted 27 lines
Quoted 27 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +27
-0+ prueth->dev = dev; + eth_ports_node =of_get_child_by_name (np,"ethernet-ports" ); +if (!eth_ports_node) +return -ENOENT ; + +for_each_child_of_node (eth_ports_node, eth_node) { +u32 reg; + +if (strcmp (eth_node->name,"port" )) +continue ; + ret =of_property_read_u32 (eth_node,"reg" , ®); +if (ret <0 ) { +dev_err (dev,"%pOF error reading port_id %d\n" , + eth_node, ret); + } + +of_node_get (eth_node); + +if (reg ==0 ) { + eth0_node = eth_node; +if (!of_device_is_available (eth0_node)) { +of_node_put (eth0_node); + eth0_node =NULL ; + } + }else if (reg ==1 ) { + eth1_node = eth_node; +if (!of_device_is_available (eth1_node)) {Quoted 9 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1578
Quoted 5 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +5
-0+of_node_put (eth1_node); + eth1_node =NULL ; + } + }else { +dev_err (dev,"port reg should be 0 or 1\n" );Should this be treated as an error and either return or goto an unwind path?
I don't think we should error out or return to any goto label here. Here we are checking 'reg' property in all available ports. If reg=0, we assign the node to
eth0_node. If reg=1, we assign the node toeth1_node. If the reg is neither 0 nor 1, we will just keep looking through other available ports, instead of returning error. We will eventually look through all available nodes.Once we come out of the for loop, we should at least have one node with reg property being either 0 or 1. If no node had reg as 0 or 1, both
eth0_nodeandeth1_nodewill be NULL, then we will error out with-ENODEVerror by below if check.Quoted 4 lines
if (!eth0_node && !eth1_node) { dev_err(dev, "neither port0 nor port1 node available\n"); return -ENODEV; }Thanks, that makes sense to me.
Quoted 11 lines
Quoted 10 lines
drivers/net/ethernet/ti/icssg_prueth.c line 1585
Quoted 7 lines
drivers/net/ethernet/ti/icssg_prueth.c new file +7
-0+ } + } + +of_node_put (eth_ports_node); + +/* At least one node must be present and available else we fail */ +if (!eth0_node && !eth1_node) {Smatch warns that
eth0_nodeandeth1_nodemay be uninitialised here.
Quoted 5 lines
Quoted 1 line
Sure, I will initialise
eth0_nodeandeth1_nodeas NULL.Thanks.
...
I will fix all the sparse and smatch warning and send next revision.
Signature · 7 lines
Thanks and Regards, Danish. _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [EXTERNAL] Re: [EXTERNAL] Re: [PATCH v8 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
Hi Danish,
Quoted 10 lines · Md Danish Anwar
Hi Simon,
Quoted 7 lines · Simon Horman
Hi Anwar,
Quoted 4 lines · Md Danish
Hi Simon
Quoted 2 lines · Simon Horman
Quoted 1 line · MD Danish Anwar
From: Roger Quadros <[email protected]>
...
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Smatch warns that
eth0_nodeandeth1_nodemay be uninitialised here.Sure, I will initialise
eth0_nodeandeth1_nodeas NULL.Thanks.
...
I will fix all the sparse and smatch warning and send next revision.
Perfect, thanks!
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel