net: bcmgenet: minor bug fixes
Subsystems (3)
Doug Berger
maintainerv2 cover net: bcmgenet: minor bug fixes
v2: Accidentally sent the wrong set after rebasing.
This collection contains a number of fixes for minor issues with the bcmgenet driver most of which were present in the initial submission of the driver.
Some bugs were uncovered by inspection prior to the upcoming update for GENETv5 support:
net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
net: bcmgenet: correct MIB access of UniMAC RUNT counters
net: bcmgenet: reserved phy revisions must be checked first
net: bcmgenet: synchronize irq0 status between the isr and task
Others bugs were found in power management testing:
net: bcmgenet: power down internal phy if open or resume fails
net: bcmgenet: Power up the internal PHY before probing the MII
net: bcmgenet: decouple flow control from bcmgenet_tx_reclaim
net: bcmgenet: add begin/complete ethtool ops
Doug Berger (7):
net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
net: bcmgenet: correct MIB access of UniMAC RUNT counters
net: bcmgenet: reserved phy revisions must be checked first
net: bcmgenet: power down internal phy if open or resume fails
net: bcmgenet: synchronize irq0 status between the isr and task
net: bcmgenet: Power up the internal PHY before probing the MII
net: bcmgenet: decouple flow control from bcmgenet_tx_reclaim
Edwin Chan (1):
net: bcmgenet: add begin/complete ethtool ops
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 206 ++++++++++++++++++------- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 16 +- 2 files changed, 158 insertions(+), 64 deletions(-)
Signature · 1 line
2.11.1
Doug Berger
maintainerPATCH v2 1/8 net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
The location of the RBUF overflow and error counters has moved between different version of the GENET MAC. This commit corrects the driver to read from the correct locations depending on the version of the GENET MAC.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 60 +++++++++++++++++++++++--- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 10 +++-- 2 files changed, 60 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +53 -7
@@ -1,7 +1,7 @@/* * Broadcom GENET (Gigabit Ethernet) controller driver * -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -778,8 +778,9 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {STAT_GENET_RUNT ("rx_runt_bytes" , mib.rx_runt_bytes),/* Misc UniMAC counters */ STAT_GENET_MISC ("rbuf_ovflow_cnt" , mib.rbuf_ovflow_cnt, -UMAC_RBUF_OVFL_CNT ), -STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt,UMAC_RBUF_ERR_CNT ), +UMAC_RBUF_OVFL_CNT_V1 ), +STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt, +UMAC_RBUF_ERR_CNT_V1 ),STAT_GENET_MISC ("mdf_err_cnt" , mib.mdf_err_cnt,UMAC_MDF_ERR_CNT ),STAT_GENET_SOFT_MIB ("alloc_rx_buff_failed" , mib.alloc_rx_buff_failed), STAT_GENET_SOFT_MIB("rx_dma_failed", mib.rx_dma_failed),
@@ -821,6 +822,45 @@ static void bcmgenet_get_strings(struct net_device *dev, u32 stringset, } } +static u32 bcmgenet_update_stat_misc (struct bcmgenet_priv *priv,u16 offset) +{ +u16 new_offset; +u32 val; + +switch (offset) { +case UMAC_RBUF_OVFL_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_OVFL_CNT_V2 ; +else + new_offset =RBUF_OVFL_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +case UMAC_RBUF_ERR_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_ERR_CNT_V2 ; +else + new_offset =RBUF_ERR_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +default : + val =bcmgenet_umac_readl (priv, offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , offset); +break ; + } + +return val; +} +static void bcmgenet_update_mib_counters (struct bcmgenet_priv *priv) {int i, j =0 ;
@@ -845,10 +885,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv) UMAC_MIB_START + j + offset);break ;case BCMGENET_STAT_MISC : - val =bcmgenet_umac_readl (priv, s->reg_offset); -/* clear if overflowed */ -if (val == ~0 ) -bcmgenet_umac_writel (priv,0 , s->reg_offset); +if (GENET_IS_V1 (priv)) { + val =bcmgenet_umac_readl (priv, s->reg_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , + s->reg_offset); + }else { + val =bcmgenet_update_stat_misc (priv, + s->reg_offset); + }break ; }
drivers/net/ethernet/broadcom/genet/bcmgenet.h +7 -3
@@ -1,5 +1,5 @@/* -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -214,7 +214,9 @@ struct bcmgenet_mib_counters {#define MDIO_REG_SHIFT 16#define MDIO_REG_MASK 0x1F -#define UMAC_RBUF_OVFL_CNT 0x61C +#define UMAC_RBUF_OVFL_CNT_V1 0x61C +#define RBUF_OVFL_CNT_V2 0x80 +#define RBUF_OVFL_CNT_V3PLUS 0x94#define UMAC_MPD_CTRL 0x620#define MPD_EN (1 << 0)
@@ -224,7 +226,9 @@ struct bcmgenet_mib_counters {#define UMAC_MPD_PW_MS 0x624#define UMAC_MPD_PW_LS 0x628 -#define UMAC_RBUF_ERR_CNT 0x634 +#define UMAC_RBUF_ERR_CNT_V1 0x634 +#define RBUF_ERR_CNT_V2 0x84 +#define RBUF_ERR_CNT_V3PLUS 0x98#define UMAC_MDF_ERR_CNT 0x638#define UMAC_MDF_CTRL 0x650#define UMAC_MDF_ADDR 0x654
Signature · 1 line
2.11.1
Re: [PATCH v2 net 1/8] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
Quoted 7 lines · Doug Berger
The location of the RBUF overflow and error counters has moved between different version of the GENET MAC. This commit corrects the driver to read from the correct locations depending on the version of the GENET MAC.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 2/8 net: bcmgenet: correct MIB access of UniMAC RUNT counters
In reply to Doug BergerThe gap between the Tx status counters and the Rx RUNT counters is now being added to allow correct reporting of the registers.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +7 -4
@@ -876,13 +876,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)case BCMGENET_STAT_NETDEV :case BCMGENET_STAT_SOFT :continue ; -case BCMGENET_STAT_MIB_RX : -case BCMGENET_STAT_MIB_TX :case BCMGENET_STAT_RUNT : -if (s->type !=BCMGENET_STAT_MIB_RX ) - offset =BCMGENET_STAT_OFFSET ; + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_TX : + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_RX : val =bcmgenet_umac_readl (priv,UMAC_MIB_START + j + offset); + offset =0 ;/* Reset Offset */ break ;case BCMGENET_STAT_MISC :if (GENET_IS_V1 (priv)) {
Signature · 1 line
2.11.1
Re: [PATCH v2 net 2/8] net: bcmgenet: correct MIB access of UniMAC RUNT counters
Quoted 5 lines · Doug Berger
The gap between the Tx status counters and the Rx RUNT counters is now being added to allow correct reporting of the registers.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 3/8 net: bcmgenet: reserved phy revisions must be checked first
In reply to Doug BergerThe reserved gphy_rev value of 0x01ff must be tested before the old or new scheme for GPHY major versioning are tested, otherwise it will be treated as 0xff00 according to the old scheme.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -6
@@ -3226,6 +3226,12 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)*/ gphy_rev = reg &0xffff ; +/* This is reserved so should require special treatment */ +if (gphy_rev ==0 || gphy_rev ==0x01ff ) { +pr_warn ("Invalid GPHY revision detected: 0x%04x\n" , gphy_rev); +return ; + } +/* This is the good old scheme, just GPHY major, no minor nor patch */ if ((gphy_rev &0xf0 ) !=0 ) priv->gphy_rev = gphy_rev <<8 ;
@@ -3234,12 +3240,6 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)else if ((gphy_rev &0xff00 ) !=0 ) priv->gphy_rev = gphy_rev; -/* This is reserved so should require special treatment */ -else if (gphy_rev ==0 || gphy_rev ==0x01ff ) { -pr_warn ("Invalid GPHY revision detected: 0x%04x\n" , gphy_rev); -return ; - } -#ifdef CONFIG_PHYS_ADDR_T_64BIT if (!(params->flags &GENET_HAS_40BITS ))pr_warn ("GENET does not support 40-bits PA\n" );
Signature · 1 line
2.11.1
Re: [PATCH v2 net 3/8] net: bcmgenet: reserved phy revisions must be checked first
Quoted 6 lines · Doug Berger
The reserved
gphy_revvalue of0x01ffmust be tested before the old or new scheme for GPHY major versioning are tested, otherwise it will be treated as0xff00according to the old scheme.Fixes b04a2f5b9ff5 ("net: bcmgenet: add support for new GENET PHY revision scheme")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 4/8 net: bcmgenet: power down internal phy if open or resume fails
In reply to Doug BergerSince the internal PHY is powered up during the open and resume functions it should be powered back down if the functions fail.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -0
@@ -2850,6 +2850,8 @@ static int bcmgenet_open(struct net_device *dev) err_fini_dma:bcmgenet_fini_dma (priv); err_clk_disable: +if (priv->internal_phy) +bcmgenet_power_down (priv,GENET_POWER_PASSIVE );clk_disable_unprepare (priv->clk);return ret; }
@@ -3551,6 +3553,8 @@ static int bcmgenet_resume(struct device *d)return 0 ; out_clk_disable: +if (priv->internal_phy) +bcmgenet_power_down (priv,GENET_POWER_PASSIVE );clk_disable_unprepare (priv->clk);return ret; }
Signature · 1 line
2.11.1
Re: [PATCH v2 net 4/8] net: bcmgenet: power down internal phy if open or resume fails
Quoted 5 lines · Doug Berger
Since the internal PHY is powered up during the open and resume functions it should be powered back down if the functions fail.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 5/8 net: bcmgenet: synchronize irq0 status between the isr and task
In reply to Doug BergerAdd a spinlock to ensure that irq0_stat is not unintentionally altered as the result of preemption. Also removed unserviced irq0 interrupts and removed irq1_stat since there is no bottom half service for those interrupts.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 73 ++++++++++++++------------ drivers/net/ethernet/broadcom/genet/bcmgenet.h | 6 ++- 2 files changed, 44 insertions(+), 35 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +40 -33
@@ -2506,24 +2506,28 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv)/* Interrupt bottom half */ static void bcmgenet_irq_task (struct work_struct *work) { +unsigned long flags; +unsigned int status;struct bcmgenet_priv *priv =container_of ( work, struct bcmgenet_priv, bcmgenet_irq_work);netif_dbg (priv, intr, priv->dev,"%s\n" , __func__); -if (priv->irq0_stat &UMAC_IRQ_MPD_R ) { - priv->irq0_stat &= ~UMAC_IRQ_MPD_R ; +spin_lock_irqsave (&priv->lock, flags); + status = priv->irq0_stat; + priv->irq0_stat =0 ; +spin_unlock_irqrestore (&priv->lock, flags); + +if (status &UMAC_IRQ_MPD_R ) {netif_dbg (priv, wol, priv->dev,"magic packet detected, waking up\n" );bcmgenet_power_up (priv,GENET_POWER_WOL_MAGIC ); }/* Link UP/DOWN event */ -if (priv->irq0_stat &UMAC_IRQ_LINK_EVENT ) { +if (status &UMAC_IRQ_LINK_EVENT )phy_mac_interrupt (priv->phydev, - !!(priv->irq0_stat &UMAC_IRQ_LINK_UP )); - priv->irq0_stat &= ~UMAC_IRQ_LINK_EVENT ; - } + !!(status &UMAC_IRQ_LINK_UP )); }/* bcmgenet_isr1: handle Rx and Tx priority queues */
@@ -2532,22 +2536,21 @@ static irqreturn_t bcmgenet_isr1(int irq, void *dev_id)struct bcmgenet_priv *priv = dev_id;struct bcmgenet_rx_ring *rx_ring;struct bcmgenet_tx_ring *tx_ring; -unsigned int index; +unsigned int index, status; -/* Save irq status for bottom-half processing. */ - priv->irq1_stat = -bcmgenet_intrl2_1_readl (priv,INTRL2_CPU_STAT ) & +/* Read irq status */ + status =bcmgenet_intrl2_1_readl (priv,INTRL2_CPU_STAT ) & ~bcmgenet_intrl2_1_readl (priv,INTRL2_CPU_MASK_STATUS );/* clear interrupts */ -bcmgenet_intrl2_1_writel (priv, priv->irq1_stat,INTRL2_CPU_CLEAR ); +bcmgenet_intrl2_1_writel (priv, status,INTRL2_CPU_CLEAR );netif_dbg (priv, intr, priv->dev, -"%s: IRQ=0x%x\n" , __func__, priv->irq1_stat); +"%s: IRQ=0x%x\n" , __func__, status);/* Check Rx priority queue interrupts */ for (index =0 ; index < priv->hw_params->rx_queues; index++) { -if (!(priv->irq1_stat &BIT (UMAC_IRQ1_RX_INTR_SHIFT + index))) +if (!(status &BIT (UMAC_IRQ1_RX_INTR_SHIFT + index)))continue ; rx_ring = &priv->rx_rings[index];
@@ -2560,7 +2563,7 @@ static irqreturn_t bcmgenet_isr1(int irq, void *dev_id)/* Check Tx priority queue interrupts */ for (index =0 ; index < priv->hw_params->tx_queues; index++) { -if (!(priv->irq1_stat &BIT (index))) +if (!(status &BIT (index)))continue ; tx_ring = &priv->tx_rings[index];
@@ -2580,19 +2583,20 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id)struct bcmgenet_priv *priv = dev_id;struct bcmgenet_rx_ring *rx_ring;struct bcmgenet_tx_ring *tx_ring; +unsigned int status; +unsigned long flags; -/* Save irq status for bottom-half processing. */ - priv->irq0_stat = -bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_STAT ) & +/* Read irq status */ + status =bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_STAT ) & ~bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_MASK_STATUS );/* clear interrupts */ -bcmgenet_intrl2_0_writel (priv, priv->irq0_stat,INTRL2_CPU_CLEAR ); +bcmgenet_intrl2_0_writel (priv, status,INTRL2_CPU_CLEAR );netif_dbg (priv, intr, priv->dev, -"IRQ=0x%x\n" , priv->irq0_stat); +"IRQ=0x%x\n" , status); -if (priv->irq0_stat &UMAC_IRQ_RXDMA_DONE ) { +if (status &UMAC_IRQ_RXDMA_DONE ) { rx_ring = &priv->rx_rings[DESC_INDEX ];if (likely (napi_schedule_prep (&rx_ring->napi))) {
@@ -2601,7 +2605,7 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id) } } -if (priv->irq0_stat &UMAC_IRQ_TXDMA_DONE ) { +if (status &UMAC_IRQ_TXDMA_DONE ) { tx_ring = &priv->tx_rings[DESC_INDEX ];if (likely (napi_schedule_prep (&tx_ring->napi))) {
@@ -2610,22 +2614,23 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id) } } -if (priv->irq0_stat & (UMAC_IRQ_PHY_DET_R | -UMAC_IRQ_PHY_DET_F | -UMAC_IRQ_LINK_EVENT | -UMAC_IRQ_HFB_SM | -UMAC_IRQ_HFB_MM | -UMAC_IRQ_MPD_R )) { -/* all other interested interrupts handled in bottom half */ -schedule_work (&priv->bcmgenet_irq_work); - } -if ((priv->hw_params->flags &GENET_HAS_MDIO_INTR ) && - priv->irq0_stat & (UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR )) { - priv->irq0_stat &= ~(UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR ); + status & (UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR )) {wake_up (&priv->wq); } +/* all other interested interrupts handled in bottom half */ + status &= (UMAC_IRQ_LINK_EVENT | +UMAC_IRQ_MPD_R ); +if (status) { +/* Save irq status for bottom-half processing. */ +spin_lock_irqsave (&priv->lock, flags); + priv->irq0_stat |= status; +spin_unlock_irqrestore (&priv->lock, flags); + +schedule_work (&priv->bcmgenet_irq_work); + } +return IRQ_HANDLED ; }
@@ -3327,6 +3332,8 @@ static int bcmgenet_probe(struct platform_device *pdev) goto err; } +spin_lock_init (&priv->lock); +SET_NETDEV_DEV (dev, &pdev->dev);dev_set_drvdata (&pdev->dev, dev);ether_addr_copy (dev->dev_addr, macaddr);
drivers/net/ethernet/broadcom/genet/bcmgenet.h +4 -2
@@ -623,11 +623,13 @@ struct bcmgenet_priv {struct work_struct bcmgenet_irq_work;int irq0;int irq1; -unsigned int irq0_stat; -unsigned int irq1_stat;int wol_irq;bool wol_irq_disabled; +/* shared status */ +spinlock_t lock; +unsigned int irq0_stat; +/* HW descriptors/checksum variables */ bool desc_64b_en;bool desc_rxchk_en;
Signature · 1 line
2.11.1
Re: [PATCH v2 net 5/8] net: bcmgenet: synchronize irq0 status between the isr and task
Quoted 7 lines · Doug Berger
Add a spinlock to ensure that
irq0_statis not unintentionally altered as the result of preemption. Also removed unserviced irq0 interrupts and removedirq1_statsince there is no bottom half service for those interrupts.Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 6/8 net: bcmgenet: Power up the internal PHY before probing the MII
In reply to Doug BergerWhen using the internal PHY it must be powered up when the MII is probed or the PHY will not be detected. Since the PHY is powered up at reset this has not been a problem. However, when the kernel is restarted with kexec the PHY will likely be powered down when the kernel starts so it will not be detected and the Ethernet link will not be established.
This commit explicitly powers up the internal PHY when the GENET driver is probed to correct this behavior.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -3289,6 +3289,7 @@ static int bcmgenet_probe(struct platform_device *pdev)const void *macaddr;struct resource *r;int err = -EIO ; +const char *phy_mode_str;/* Up to GENET_MAX_MQ_CNT + 1 TX queues and RX queues */ dev = alloc_etherdev_mqs(sizeof(*priv), GENET_MAX_MQ_CNT + 1,
@@ -3396,6 +3397,13 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->clk_eee =NULL ; } +/* If this is an internal GPHY, power it on now, before UniMAC is +* brought out of reset as absolutely no UniMAC activity is allowed +*/ +if (dn && !of_property_read_string (dn,"phy-mode" , &phy_mode_str) && + !strcasecmp (phy_mode_str,"internal" )) +bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); + err =reset_umac (priv);if (err) goto err_clk_disable;
Signature · 1 line
2.11.1
Re: [PATCH v2 net 6/8] net: bcmgenet: Power up the internal PHY before probing the MII
Quoted 11 lines · Doug Berger
When using the internal PHY it must be powered up when the MII is probed or the PHY will not be detected. Since the PHY is powered up at reset this has not been a problem. However, when the kernel is restarted with kexec the PHY will likely be powered down when the kernel starts so it will not be detected and the Ethernet link will not be established.
This commit explicitly powers up the internal PHY when the GENET driver is probed to correct this behavior.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 7/8 net: bcmgenet: add begin/complete ethtool ops
In reply to Doug BergerFrom: Edwin Chan <[email protected]>
Make sure clock is enabled for ethtool ops.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +18 -0
@@ -450,6 +450,22 @@ static inline void bcmgenet_rdma_ring_writel(struct bcmgenet_priv *priv, genet_dma_ring_regs[r]); } +static int bcmgenet_begin (struct net_device *dev) +{ +struct bcmgenet_priv *priv =netdev_priv (dev); + +/* Turn on the clock */ +return clk_prepare_enable (priv->clk); +} + +static void bcmgenet_complete (struct net_device *dev) +{ +struct bcmgenet_priv *priv =netdev_priv (dev); + +/* Turn off the clock */ +clk_disable_unprepare (priv->clk); +} +static int bcmgenet_get_link_ksettings (struct net_device *dev,struct ethtool_link_ksettings *cmd) {
@@ -1022,6 +1038,8 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)/* standard ethtool support functions. */ static const struct ethtool_ops bcmgenet_ethtool_ops = { + .begin = bcmgenet_begin, + .complete = bcmgenet_complete, .get_strings = bcmgenet_get_strings, .get_sset_count = bcmgenet_get_sset_count, .get_ethtool_stats = bcmgenet_get_ethtool_stats,
Signature · 1 line
2.11.1
Re: [PATCH v2 net 7/8] net: bcmgenet: add begin/complete ethtool ops
Quoted 7 lines · Doug Berger
From: Edwin Chan <[email protected]>
Make sure clock is enabled for ethtool ops.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Edwin Chan <[email protected]>Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH v2 8/8 net: bcmgenet: decouple flow control from bcmgenet_tx_reclaim
In reply to Doug BergerThe bcmgenet_tx_reclaim() function is used to reclaim transmit resources in different places within the driver. Most of them should not affect the state of the transmit flow control.
This commit relocates the logic for waking tx queues based on freed resources to the napi polling function where it is more appropriate.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +11 -9
@@ -1234,7 +1234,6 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,struct bcmgenet_priv *priv =netdev_priv (dev);struct device *kdev = &priv->pdev->dev;struct enet_cb *tx_cb_ptr; -struct netdev_queue *txq;unsigned int pkts_compl =0 ;unsigned int bytes_compl =0 ;unsigned int c_index;
@@ -1286,13 +1285,8 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, dev->stats.tx_packets += pkts_compl; dev->stats.tx_bytes += bytes_compl; - txq =netdev_get_tx_queue (dev, ring->queue); -netdev_tx_completed_queue (txq, pkts_compl, bytes_compl); - -if (ring->free_bds > (MAX_SKB_FRAGS +1 )) { -if (netif_tx_queue_stopped (txq)) -netif_tx_wake_queue (txq); - } +netdev_tx_completed_queue (netdev_get_tx_queue (dev, ring->queue), + pkts_compl, bytes_compl);return pkts_compl; }
@@ -1315,8 +1309,16 @@ static int bcmgenet_tx_poll(struct napi_struct *napi, int budget)struct bcmgenet_tx_ring *ring = container_of(napi, struct bcmgenet_tx_ring, napi);unsigned int work_done =0 ; +struct netdev_queue *txq; +unsigned long flags; - work_done =bcmgenet_tx_reclaim (ring->priv->dev, ring); +spin_lock_irqsave (&ring->lock, flags); + work_done =__bcmgenet_tx_reclaim (ring->priv->dev, ring); +if (ring->free_bds > (MAX_SKB_FRAGS +1 )) { + txq =netdev_get_tx_queue (ring->priv->dev, ring->queue); +netif_tx_wake_queue (txq); + } +spin_unlock_irqrestore (&ring->lock, flags);if (work_done ==0 ) {napi_complete (napi);
Signature · 1 line
2.11.1
Re: [PATCH v2 net 8/8] net: bcmgenet: decouple flow control from bcmgenet_tx_reclaim
Quoted 10 lines · Doug Berger
The
bcmgenet_tx_reclaim()function is used to reclaim transmit resources in different places within the driver. Most of them should not affect the state of the transmit flow control.This commit relocates the logic for waking tx queues based on freed resources to the napi polling function where it is more appropriate.
Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Quoted 5 lines · Doug Berger
v2: Accidentally sent the wrong set after rebasing.
This collection contains a number of fixes for minor issues with the bcmgenet driver most of which were present in the initial submission of the driver.
This entire series looks great, thanks for getting this out!
Quoted 30 lines
Some bugs were uncovered by inspection prior to the upcoming update for GENETv5 support:
net: bcmgenet: correct theRBUF_OVFL_CNTandRBUF_ERR_CNTMIB values
net: bcmgenet: correct MIB access of UniMAC RUNT counters
net: bcmgenet: reserved phy revisions must be checked first
net: bcmgenet: synchronize irq0 status between the isr and taskOthers bugs were found in power management testing:
net: bcmgenet: power down internal phy if open or resume fails
net: bcmgenet: Power up the internal PHY before probing the MII
net: bcmgenet: decouple flow control frombcmgenet_tx_reclaim
net: bcmgenet: add begin/complete ethtool opsDoug Berger (7):
net: bcmgenet: correct theRBUF_OVFL_CNTandRBUF_ERR_CNTMIB values
net: bcmgenet: correct MIB access of UniMAC RUNT counters
net: bcmgenet: reserved phy revisions must be checked first
net: bcmgenet: power down internal phy if open or resume fails
net: bcmgenet: synchronize irq0 status between the isr and task
net: bcmgenet: Power up the internal PHY before probing the MII
net: bcmgenet: decouple flow control frombcmgenet_tx_reclaimEdwin Chan (1):
net: bcmgenet: add begin/complete ethtool opsdrivers/net/ethernet/broadcom/genet/bcmgenet.c | 206 ++++++++++++++++++------- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 16 +- 2 files changed, 158 insertions(+), 64 deletions(-)
Signature · 1 line
Florian
David Miller
maintainerFrom: Doug Berger <[email protected]>
Date: Thu, 9 Mar 2017 16:58:42 -0800
Quoted 5 lines
v2: Accidentally sent the wrong set after rebasing.
This collection contains a number of fixes for minor issues with the bcmgenet driver most of which were present in the initial submission of the driver.
...
Series applied, thanks Doug.