net: sxgbe: add basic framework for Samsung 10Gb ethernet driver
Subsystems (4)
Byungho An
maintainerPATCH v5 2/8 net: sxgbe: add basic framework for Samsung 10Gb ethernet driver
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
- sxgbe core initialization
- Tx and Rx support
- MDIO support
- ISRs for Tx and Rx
- ifconfig support to driver
--- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/samsung/Kconfig | 20 + drivers/net/ethernet/samsung/Makefile | 5 + drivers/net/ethernet/samsung/sxgbe/Kconfig | 9 + drivers/net/ethernet/samsung/sxgbe/Makefile | 4 + drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h | 459 +++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c | 157 ++ drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c | 515 +++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h | 291 +++ drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c | 377 ++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.h | 49 + drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c | 44 + drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 2063 ++++++++++++++++++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c | 274 +++ drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.c | 252 +++ drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.h | 104 + .../net/ethernet/samsung/sxgbe/sxgbe_platform.c | 260 +++ drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h | 477 +++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.c | 92 + drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.h | 38 + include/linux/sxgbe_platform.h | 54 + 22 files changed, 5546 insertions(+) create mode 100644 drivers/net/ethernet/samsung/Kconfig create mode 100644 drivers/net/ethernet/samsung/Makefile create mode 100644 drivers/net/ethernet/samsung/sxgbe/Kconfig create mode 100644 drivers/net/ethernet/samsung/sxgbe/Makefile create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.h create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.h create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.c create mode 100644 drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.h create mode 100644 include/linux/sxgbe_platform.h
drivers/net/ethernet/Kconfig +1 -0
@@ -149,6 +149,7 @@ config S6GMAC To compile this driver as a module, choose M here. The module will be called s6gmac. +source "drivers/net/ethernet/samsung/Kconfig" source "drivers/net/ethernet/seeq/Kconfig" source "drivers/net/ethernet/silan/Kconfig" source "drivers/net/ethernet/sis/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/ obj-$(CONFIG_SH_ETH) += renesas/ obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ obj-$(CONFIG_S6GMAC) += s6gmac.o +obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/ obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/ obj-$(CONFIG_NET_VENDOR_SILAN) += silan/ obj-$(CONFIG_NET_VENDOR_SIS) += sis/
drivers/net/ethernet/samsung/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# Samsung Ethernet device configuration +# + +config NET_VENDOR_SAMSUNG + bool "Samsung Ethernet device" + default y + depends on HAS_IOMEM && HAS_DMA + select PHYLIB + select CRC32 + select PTP_1588_CLOCK + ---help--- + This is the driver for the SXGBE 10G Ethernet IP block found on Samsung + platforms. + +if NET_VENDOR_SAMSUNG + +source "drivers/net/ethernet/samsung/sxgbe/Kconfig" + +endif # NET_VENDOR_SAMSUNG
drivers/net/ethernet/samsung/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the Samsung Ethernet device drivers. +# + +obj-$(CONFIG_SXGBE_ETH) += sxgbe/
drivers/net/ethernet/samsung/sxgbe/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config SXGBE_ETH + tristate "Samsung 10G/2.5G/1G SXGBE Ethernet driver" + depends on HAS_IOMEM && HAS_DMA + select PHYLIB + select CRC32 + select PTP_1588_CLOCK + ---help--- + This is the driver for the SXGBE 10G Ethernet IP block found on Samsung + platforms.
drivers/net/ethernet/samsung/sxgbe/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +obj-$(CONFIG_SXGBE_ETH) += samsung-sxgbe.o +samsung-sxgbe-objs:= sxgbe_platform.o sxgbe_main.o sxgbe_desc.o \ + sxgbe_dma.o sxgbe_core.o sxgbe_mtl.o sxgbe_mdio.o \ + sxgbe_ethtool.o sxgbe_xpcs.o $(samsung-sxgbe-y)
drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h new file +459 -0
459 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c new file +157 -0
157 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c new file +515 -0
515 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h new file +291 -0
291 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c new file +377 -0
377 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.h new file +49 -0
49 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c new file +44 -0
44 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +2063 -0
1,056 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +274 -0
274 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.c new file +252 -0
252 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.h new file +104 -0
104 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c new file +260 -0
260 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h new file +477 -0
477 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.c new file +92 -0
92 lines not on this page · raw message
drivers/net/ethernet/samsung/sxgbe/sxgbe_xpcs.h new file +38 -0
Lines of this file are not shown. View the raw message.
include/linux/sxgbe_platform.h new file +54 -0
54 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.10.4
Part of the diff is not shown here. View the raw message.
2014-03-18 11:19 GMT-07:00 Byungho An <[email protected]>:
Quoted 9 lines
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
- sxgbe core initialization
- Tx and Rx support
- MDIO support
- ISRs for Tx and Rx
- ifconfig support to driver
Too many files to review at once, the diffstat was around 5000+ lines! You should split this into logical parts, or just submit the basic bits for now and add the features later.
[snip]
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1931
Quoted 12 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +12
-0+ ret =register_netdev (ndev); +if (ret) { +pr_err ("%s: ERROR %i registering the device\n" , __func__, ret); + goto error_netdev_register; + } + + priv->sxgbe_clk =clk_get (priv->device,SXGBE_RESOURCE_NAME ); +if (IS_ERR (priv->sxgbe_clk)) { +netdev_warn (ndev,"%s: warning: cannot get CSR clock\n" , + __func__); + goto error_clk_get; + }
This is racy, after register_netdev() is called, the network stack is free to use the interface, which means that as much as possible needs to be initialized before you call it, including clocks, and MDIO.
Quoted 9 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +9
-0+ +/* If a specific clk_csr value is passed from the platform +* this means that the CSR Clock Range selection cannot be +* changed at run-time and it is fixed. Viceversa the driver'll try to +* set the MDC clock dynamically according to the csr actual +* clock input. +*/ +if (!priv->plat->clk_csr) +sxgbe_clk_csr_set (priv);
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1950
Quoted 10 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +10
-0+else + priv->clk_csr = priv->plat->clk_csr; + +/* MDIO bus Registration */ + ret =sxgbe_mdio_register (ndev); +if (ret <0 ) { +netdev_dbg (ndev,"%s: MDIO bus (id: %d) registration failed\n" , + __func__, priv->plat->bus_id); + goto error_mdio_register; + }
Don't do this, register your MDIO bus before calling register_netdev().
Quoted 30 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +30
-0+ +sxgbe_check_ether_addr (priv); + +return priv; + +error_mdio_register: +clk_put (priv->sxgbe_clk); +error_clk_get: +unregister_netdev (ndev); +error_netdev_register: +netif_napi_del (&priv->napi); +error_free_netdev: +free_netdev (ndev); + +return NULL ; +} + +/** +* sxgbe_dvr_remove +* @ndev: net device pointer +* Description: this function resets the TX/RX processes, disables the MAC RX/TX +* changes the link status, releases the DMA descriptor rings. +*/ +int sxgbe_dvr_remove (struct net_device *ndev) +{ +struct sxgbe_priv_data *priv =netdev_priv (ndev); + +netdev_info (ndev,"%s: removing driver\n" , __func__); + + priv->hw->dma->stop_rx (priv->ioaddr,SXGBE_RX_QUEUES );
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1990
Quoted 10 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +10
-0+ priv->hw->dma->stop_tx (priv->ioaddr,SXGBE_TX_QUEUES ); + + priv->hw->mac->enable_tx (priv->ioaddr, false); + priv->hw->mac->enable_rx (priv->ioaddr, false); + +netif_napi_del (&priv->napi); + +sxgbe_mdio_unregister (ndev); + +netif_carrier_off (ndev);
This is not required, both the PHY library and the network stack will do that for you.
[snip]
Quoted 36 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +36
-0+/* register with kernel subsystem */ + err =mdiobus_register (mdio_bus); +if (err !=0 ) { +netdev_err (ndev,"mdiobus register failed\n" ); + goto mdiobus_err; + } + +for (phy_addr =0 ; phy_addr <PHY_MAX_ADDR ; phy_addr++) { +struct phy_device *phy = mdio_bus->phy_map[phy_addr]; +if (phy) { +char irq_num[4 ]; +char *irq_str; +/* If an IRQ was provided to be assigned after +* the bus probe, do it here. +*/ +if ((mdio_data->irqs ==NULL ) && + (mdio_data->probed_phy_irq >0 )) { + irqlist[phy_addr] = mdio_data->probed_phy_irq; + phy->irq = mdio_data->probed_phy_irq; + } + +/* If we're going to bind the MAC to this PHY bus, +* and no PHY number was provided to the MAC, +* use the one probed here. +*/ +if (priv->plat->phy_addr ==-1 ) + priv->plat->phy_addr = phy_addr; + + act = (priv->plat->phy_addr == phy_addr); +switch (phy->irq) { +case PHY_POLL : + irq_str ="POLL" ; +break ; +case PHY_IGNORE_INTERRUPT : + irq_str ="IGNORE" ; +break ;
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 242
Quoted 10 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +10
-0+default : +sprintf (irq_num,"%d" , phy->irq); + irq_str = irq_num; +break ; + } +netdev_info (ndev,"PHY ID %08x at %d IRQ %s (%s)%s\n" , + phy->phy_id, phy_addr, irq_str, +dev_name (&phy->dev), act ?" active" :"" ); + phy_found =1 ; + }
This is clunky, and you are duplicating what of_mdiobus_register() will do for you, but since you are not using the standard Ethernet PHY device tree node, you could not use that code. So please use the standard Ethernet PHY device tree node such that you can remove that code and leverage it instead.
Signature · 1 line
Florian
Byungho An
maintainerQuoted 11 lines · Florian Fainelli
2014-03-18 11:19 GMT-07:00 Byungho An <[email protected]>:
Quoted 9 lines
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
- sxgbe core initialization
- Tx and Rx support
- MDIO support
- ISRs for Tx and Rx
- ifconfig support to driver
Quoted 3 lines
Too many files to review at once, the diffstat was around 5000+ lines! You should split this into logical parts, or just submit the basic bits for now and add the features later.
Yes. but I think it is one logically, after this patch there won't be much code at once.
Quoted 33 lines
[snip]
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1931
Quoted 12 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +12
-0+ ret =register_netdev (ndev); +if (ret) { +pr_err ("%s: ERROR %i registering the device\n" , __func__, ret); + goto error_netdev_register; + } + + priv->sxgbe_clk =clk_get (priv->device,SXGBE_RESOURCE_NAME ); +if (IS_ERR (priv->sxgbe_clk)) { +netdev_warn (ndev,"%s: warning: cannot get CSR clock\n" , + __func__); + goto error_clk_get; + }This is racy, after
register_netdev()is called, the network stack is free to use the interface, which means that as much as possible needs to be initialized before you call it, including clocks, and MDIO.Quoted 13 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +13
-0+ +/* If a specific clk_csr value is passed from the platform +* this means that the CSR Clock Range selection cannot be +* changed at run-time and it is fixed. Viceversa the driver'll try to +* set the MDC clock dynamically according to the csr actual +* clock input. +*/ +if (!priv->plat->clk_csr) +sxgbe_clk_csr_set (priv); +else + priv->clk_csr = priv->plat->clk_csr; + +/* MDIO bus Registration */
Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1950
Quoted 6 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +6
-0+ ret =sxgbe_mdio_register (ndev); +if (ret <0 ) { +netdev_dbg (ndev,"%s: MDIO bus (id: %d) registration failed\n" , + __func__, priv->plat->bus_id); + goto error_mdio_register; + }Don't do this, register your MDIO bus before calling
register_netdev().
OK.
Quoted 36 lines
Quoted 36 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +35
-0+ +sxgbe_check_ether_addr (priv); + +return priv; + +error_mdio_register: +clk_put (priv->sxgbe_clk); +error_clk_get: +unregister_netdev (ndev); +error_netdev_register: +netif_napi_del (&priv->napi); +error_free_netdev: +free_netdev (ndev); + +return NULL ; +} + +/** +* sxgbe_dvr_remove +* @ndev: net device pointer +* Description: this function resets the TX/RX processes, disables +the MAC RX/TX +* changes the link status, releases the DMA descriptor rings. +*/ +int sxgbe_dvr_remove (struct net_device *ndev) { +struct sxgbe_priv_data *priv =netdev_priv (ndev); + +netdev_info (ndev,"%s: removing driver\n" , __func__); + + priv->hw->dma->stop_rx (priv->ioaddr,SXGBE_RX_QUEUES ); + priv->hw->dma->stop_tx (priv->ioaddr,SXGBE_TX_QUEUES ); + + priv->hw->mac->enable_tx (priv->ioaddr, false); + priv->hw->mac->enable_rx (priv->ioaddr, false); +
Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1990
Quoted 5 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +5
-0+netif_napi_del (&priv->napi); + +sxgbe_mdio_unregister (ndev); + +netif_carrier_off (ndev);This is not required, both the PHY library and the network stack will do that for you.
You mean netif_napi_del and netif_carrier_off? or all of sxgbe_dvr_remove function? I think dma/mac control are needed.
Quoted 46 lines
[snip]
Quoted 43 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +43
-0+/* register with kernel subsystem */ + err =mdiobus_register (mdio_bus); +if (err !=0 ) { +netdev_err (ndev,"mdiobus register failed\n" ); + goto mdiobus_err; + } + +for (phy_addr =0 ; phy_addr <PHY_MAX_ADDR ; phy_addr++) { +struct phy_device *phy = mdio_bus->phy_map[phy_addr]; +if (phy) { +char irq_num[4 ]; +char *irq_str; +/* If an IRQ was provided to be assigned after +* the bus probe, do it here. +*/ +if ((mdio_data->irqs ==NULL ) && + (mdio_data->probed_phy_irq >0 )) { + irqlist[phy_addr] = mdio_data->probed_phy_irq; + phy->irq = mdio_data->probed_phy_irq; + } + +/* If we're going to bind the MAC to this PHY bus, +* and no PHY number was provided to the MAC, +* use the one probed here. +*/ +if (priv->plat->phy_addr ==-1 ) + priv->plat->phy_addr = phy_addr; + + act = (priv->plat->phy_addr == phy_addr); +switch (phy->irq) { +case PHY_POLL : + irq_str ="POLL" ; +break ; +case PHY_IGNORE_INTERRUPT : + irq_str ="IGNORE" ; +break ; +default : +sprintf (irq_num,"%d" , phy->irq); + irq_str = irq_num; +break ; + } + netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n", + phy->phy_id, phy_addr, irq_str,
Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 242
Quoted 3 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +3
-0+ dev_name(&phy->dev), act ? " active" : ""); + phy_found =1 ; + }This is clunky, and you are duplicating what
of_mdiobus_register()will do for you, but since you are not using the standard Ethernet PHY device tree node, you could not use that code. So please use the standard Ethernet PHY device tree node such that you can remove that code and leverage it instead.
I'll consider it. but I think after this patch set.
Quoted 2 lines
--
Florian
2014-03-18 15:16 GMT-07:00 Byungho An <[email protected]>:
Quoted 12 lines
Quoted 11 lines · Florian Fainelli
2014-03-18 11:19 GMT-07:00 Byungho An <[email protected]>:
Quoted 9 lines
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
- sxgbe core initialization
- Tx and Rx support
- MDIO support
- ISRs for Tx and Rx
- ifconfig support to driver
Quoted 4 lines
Quoted 3 lines
Too many files to review at once, the diffstat was around 5000+ lines! You should split this into logical parts, or just submit the basic bits for now and add the features later.
Yes. but I think it is one logically, after this patch there won't be much code at once.
Since you are adding multiple objects to the Makefile at once, you could very well split the patches to reflect that and submit one object as a separate patch. Also, sometimes, even if the driver is feature complete, it helps submitting the basic support first, and then start adding new features to it progressively.
Quoted 88 lines
Quoted 34 lines
[snip]
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1931
Quoted 12 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +12
-0+ ret =register_netdev (ndev); +if (ret) { +pr_err ("%s: ERROR %i registering the device\n" , __func__, ret); + goto error_netdev_register; + } + + priv->sxgbe_clk =clk_get (priv->device,SXGBE_RESOURCE_NAME ); +if (IS_ERR (priv->sxgbe_clk)) { +netdev_warn (ndev,"%s: warning: cannot get CSR clock\n" , + __func__); + goto error_clk_get; + }This is racy, after
register_netdev()is called, the network stack is free to use the interface, which means that as much as possible needs to be initialized before you call it, including clocks, and MDIO.Quoted 13 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +13
-0+ +/* If a specific clk_csr value is passed from the platform +* this means that the CSR Clock Range selection cannot be +* changed at run-time and it is fixed. Viceversa the driver'll try to +* set the MDC clock dynamically according to the csr actual +* clock input. +*/ +if (!priv->plat->clk_csr) +sxgbe_clk_csr_set (priv); +else + priv->clk_csr = priv->plat->clk_csr; + +/* MDIO bus Registration */ Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1950
Quoted 6 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +6
-0+ ret =sxgbe_mdio_register (ndev); +if (ret <0 ) { +netdev_dbg (ndev,"%s: MDIO bus (id: %d) registration failed\n" , + __func__, priv->plat->bus_id); + goto error_mdio_register; + }Don't do this, register your MDIO bus before calling
register_netdev().OK.
Quoted 36 lines
Quoted 36 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +35
-0+ +sxgbe_check_ether_addr (priv); + +return priv; + +error_mdio_register: +clk_put (priv->sxgbe_clk); +error_clk_get: +unregister_netdev (ndev); +error_netdev_register: +netif_napi_del (&priv->napi); +error_free_netdev: +free_netdev (ndev); + +return NULL ; +} + +/** +* sxgbe_dvr_remove +* @ndev: net device pointer +* Description: this function resets the TX/RX processes, disables +the MAC RX/TX +* changes the link status, releases the DMA descriptor rings. +*/ +int sxgbe_dvr_remove (struct net_device *ndev) { +struct sxgbe_priv_data *priv =netdev_priv (ndev); + +netdev_info (ndev,"%s: removing driver\n" , __func__); + + priv->hw->dma->stop_rx (priv->ioaddr,SXGBE_RX_QUEUES ); + priv->hw->dma->stop_tx (priv->ioaddr,SXGBE_TX_QUEUES ); + + priv->hw->mac->enable_tx (priv->ioaddr, false); + priv->hw->mac->enable_rx (priv->ioaddr, false); +Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1990
Quoted 5 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +5
-0+netif_napi_del (&priv->napi); + +sxgbe_mdio_unregister (ndev); + +netif_carrier_off (ndev);This is not required, both the PHY library and the network stack will do that for you.
Quoted 2 lines
You mean
netif_napi_delandnetif_carrier_off? or all ofsxgbe_dvr_removefunction? I think dma/mac control are needed.
I mean netif_carrier_off() is not required, everything else is.
Quoted 55 lines
Quoted 47 lines
[snip]
Quoted 43 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +43
-0+/* register with kernel subsystem */ + err =mdiobus_register (mdio_bus); +if (err !=0 ) { +netdev_err (ndev,"mdiobus register failed\n" ); + goto mdiobus_err; + } + +for (phy_addr =0 ; phy_addr <PHY_MAX_ADDR ; phy_addr++) { +struct phy_device *phy = mdio_bus->phy_map[phy_addr]; +if (phy) { +char irq_num[4 ]; +char *irq_str; +/* If an IRQ was provided to be assigned after +* the bus probe, do it here. +*/ +if ((mdio_data->irqs ==NULL ) && + (mdio_data->probed_phy_irq >0 )) { + irqlist[phy_addr] = mdio_data->probed_phy_irq; + phy->irq = mdio_data->probed_phy_irq; + } + +/* If we're going to bind the MAC to this PHY bus, +* and no PHY number was provided to the MAC, +* use the one probed here. +*/ +if (priv->plat->phy_addr ==-1 ) + priv->plat->phy_addr = phy_addr; + + act = (priv->plat->phy_addr == phy_addr); +switch (phy->irq) { +case PHY_POLL : + irq_str ="POLL" ; +break ; +case PHY_IGNORE_INTERRUPT : + irq_str ="IGNORE" ; +break ; +default : +sprintf (irq_num,"%d" , phy->irq); + irq_str = irq_num; +break ; + } + netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n", + phy->phy_id, phy_addr, irq_str,Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 242
Quoted 3 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +3
-0+ dev_name(&phy->dev), act ? " active" : ""); + phy_found =1 ; + }This is clunky, and you are duplicating what
of_mdiobus_register()will do for you, but since you are not using the standard Ethernet PHY device tree node, you could not use that code. So please use the standard Ethernet PHY device tree node such that you can remove that code and leverage it instead.
Quoted 1 line
I'll consider it. but I think after this patch set.
Humm, I would rather you do this know this will eliminate all this code in your driver which duplicates an existing function in the kernel.
Signature · 1 line
Florian
Byungho An
maintainerQuoted 13 lines · Florian Fainelli
2014-03-18 15:16 GMT-07:00 Byungho An <[email protected]>:
Quoted 12 lines
Quoted 11 lines · Florian Fainelli
2014-03-18 11:19 GMT-07:00 Byungho An <[email protected]>:
Quoted 9 lines
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
- sxgbe core initialization
- Tx and Rx support
- MDIO support
- ISRs for Tx and Rx
- ifconfig support to driver
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Too many files to review at once, the diffstat was around 5000+ lines! You should split this into logical parts, or just submit the basic bits for now and add the features later.
Yes. but I think it is one logically, after this patch there won't be much code at once.
Since you are adding multiple objects to the
Makefileat once, you could very well split the patches to reflect that and submit one object as a separate patch. Also, sometimes, even if the driver is feature complete, it helps submitting the basic support first, and then start adding new features to it progressively.
But it is basic framework itself.
Since this #2 patch contains changes that are required for its basic functionality, it is not easy to split.
Quoted 157 lines
Quoted 89 lines
Quoted 35 lines
[snip]
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1931
Quoted 12 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +12
-0+ ret =register_netdev (ndev); +if (ret) { +pr_err ("%s: ERROR %i registering the device\n" , __func__, ret); + goto error_netdev_register; + } + + priv->sxgbe_clk =clk_get (priv->device,SXGBE_RESOURCE_NAME ); +if (IS_ERR (priv->sxgbe_clk)) { +netdev_warn (ndev,"%s: warning: cannot get CSR clock\n" , + __func__); + goto error_clk_get; + }This is racy, after
register_netdev()is called, the network stack is free to use the interface, which means that as much as possible needs to be initialized before you call it, including clocks, and MDIO.Quoted 13 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +13
-0+ +/* If a specific clk_csr value is passed from the platform +* this means that the CSR Clock Range selection cannot be +* changed at run-time and it is fixed. Viceversa the driver'll try to +* set the MDC clock dynamically according to the csr actual +* clock input. +*/ +if (!priv->plat->clk_csr) +sxgbe_clk_csr_set (priv); +else + priv->clk_csr = priv->plat->clk_csr; + +/* MDIO bus Registration */ Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1950
Quoted 6 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +6
-0+ ret =sxgbe_mdio_register (ndev); +if (ret <0 ) { +netdev_dbg (ndev,"%s: MDIO bus (id: %d) registration failed\n" , + __func__, priv->plat->bus_id); + goto error_mdio_register; + }Don't do this, register your MDIO bus before calling
register_netdev().OK.
Quoted 36 lines
Quoted 36 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +35
-0+ +sxgbe_check_ether_addr (priv); + +return priv; + +error_mdio_register: +clk_put (priv->sxgbe_clk); +error_clk_get: +unregister_netdev (ndev); +error_netdev_register: +netif_napi_del (&priv->napi); +error_free_netdev: +free_netdev (ndev); + +return NULL ; +} + +/** +* sxgbe_dvr_remove +* @ndev: net device pointer +* Description: this function resets the TX/RX processes, disables +the MAC RX/TX +* changes the link status, releases the DMA descriptor rings. +*/ +int sxgbe_dvr_remove (struct net_device *ndev) { +struct sxgbe_priv_data *priv =netdev_priv (ndev); + +netdev_info (ndev,"%s: removing driver\n" , __func__); + + priv->hw->dma->stop_rx (priv->ioaddr,SXGBE_RX_QUEUES ); + priv->hw->dma->stop_tx (priv->ioaddr,SXGBE_TX_QUEUES ); + + priv->hw->mac->enable_tx (priv->ioaddr, false); + priv->hw->mac->enable_rx (priv->ioaddr, false); +Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c line 1990
Quoted 5 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c new file +5
-0+netif_napi_del (&priv->napi); + +sxgbe_mdio_unregister (ndev); + +netif_carrier_off (ndev);This is not required, both the PHY library and the network stack will do that for you.
Quoted 2 lines
You mean
netif_napi_delandnetif_carrier_off? or all ofsxgbe_dvr_removefunction? I think dma/mac control are needed.I mean
netif_carrier_off()is not required, everything else is.Quoted 55 lines
Quoted 47 lines
[snip]
Quoted 43 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +43
-0+/* register with kernel subsystem */ + err =mdiobus_register (mdio_bus); +if (err !=0 ) { +netdev_err (ndev,"mdiobus register failed\n" ); + goto mdiobus_err; + } + +for (phy_addr =0 ; phy_addr <PHY_MAX_ADDR ; phy_addr++) { +struct phy_device *phy = mdio_bus->phy_map[phy_addr]; +if (phy) { +char irq_num[4 ]; +char *irq_str; +/* If an IRQ was provided to be assigned after +* the bus probe, do it here. +*/ +if ((mdio_data->irqs ==NULL ) && + (mdio_data->probed_phy_irq >0 )) { + irqlist[phy_addr] = mdio_data->probed_phy_irq; + phy->irq = mdio_data->probed_phy_irq; + } + +/* If we're going to bind the MAC to this PHY bus, +* and no PHY number was provided to the MAC, +* use the one probed here. +*/ +if (priv->plat->phy_addr ==-1 ) + priv->plat->phy_addr = phy_addr; + + act = (priv->plat->phy_addr == phy_addr); +switch (phy->irq) { +case PHY_POLL : + irq_str ="POLL" ; +break ; +case PHY_IGNORE_INTERRUPT : + irq_str ="IGNORE" ; +break ; +default : +sprintf (irq_num,"%d" , phy->irq); + irq_str = irq_num; +break ; + } + netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n", + phy->phy_id, phy_addr, irq_str,Quoted 8 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 242
Quoted 3 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c new file +3
-0+ dev_name(&phy->dev), act ? " active" : ""); + phy_found =1 ; + }This is clunky, and you are duplicating what
of_mdiobus_register()
will do for you, but since you are not using the standard Ethernet
PHY device tree node, you could not use that code. So please use the
standard Ethernet PHY device tree node such that you can remove that code and leverage it instead.Quoted 1 line
I'll consider it. but I think after this patch set.
Humm, I would rather you do this know this will eliminate all this code in your driver which duplicates an existing function in the kernel. --
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Byungho An
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
More trivia, nothing that should stop this from
being applied and updated later...
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c
Quoted 1 line
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +0
-0
[]
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 35
Quoted 4 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +4
-0+static int sxgbe_mdio_busy_wait (void __iomem *ioaddr,unsigned int mii_data) +{ +unsigned long cur_time; +unsigned long fin_time = jiffies +3 *HZ ;/* 30 ms */
This is actually 3 seconds.
If this should be 30ms, then use msecs_to_jiffies(30)
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 46
Quoted 11 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +11
-0+ +do { + cur_time = jiffies; +if (readl (ioaddr + mii_data) &SXGBE_MII_BUSY ) +cpu_relax (); +else +return 0 ; + }while (!time_after_eq (cur_time, fin_time)); + +return -EBUSY ; +}
This may be clearer as
unsigned long fin_time = jiffies + msecs_to_jiffies(30); while (!time_after(jiffies, fin_time)) if (!(readl(ioaddr + mii_data) & SXGBE_MII_BUSY)) return 0; cpu_relax(); } return -EBUSY;
Byungho An
maintainerQuoted 11 lines · Joe Perches
Quoted 3 lines · Byungho An
From: Siva Reddy <[email protected]>
This patch adds support for Samsung 10Gb ethernet driver(sxgbe).
More trivia, nothing that should stop this from being applied and updated later...
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c
Quoted 2 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +0
-0[]
Quoted 7 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 35
Quoted 4 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +4
-0+static int sxgbe_mdio_busy_wait (void __iomem *ioaddr,unsigned int +mii_data) { +unsigned long cur_time; +unsigned long fin_time = jiffies +3 *HZ ;/* 30 ms */ This is actually 3 seconds.
If this should be 30ms, then usemsecs_to_jiffies(30)
This is a typo, comment will be changed to "3 sec".
Quoted 15 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c line 46
Quoted 12 lines
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c +11
-0+ +do { + cur_time = jiffies; +if (readl (ioaddr + mii_data) &SXGBE_MII_BUSY ) +cpu_relax (); +else +return 0 ; + }while (!time_after_eq (cur_time, fin_time)); + +return -EBUSY ; +}This may be clearer as
Quoted 9 lines
unsigned long fin_time = jiffies + msecs_to_jiffies(30); while (!time_after(jiffies, fin_time)) if (!(readl(ioaddr + mii_data) & SXGBE_MII_BUSY)) return 0; cpu_relax(); } return -EBUSY;
OK.