net: stmmac: EST interrupts and ethtool
Subsystems (4)
cover net: stmmac: EST interrupts and ethtool
From: Mohammad Athari Bin Ismail <[email protected]>
This patchset adds support for handling EST interrupts and reporting EST errors. Additionally, the errors are added into ethtool statistic.
Ong Boon Leong (1):
net: stmmac: Add EST errors into ethtool statistic
Voon Weifeng (1):
net: stmmac: EST interrupts handling and error reporting
drivers/net/ethernet/stmicro/stmmac/common.h | 6 ++ drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 86 +++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 32 +++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 + .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 4 + 6 files changed, 138 insertions(+)
Signature · 1 line
2.17.1
PATCH v2 1/2 net: stmmac: EST interrupts handling and error reporting
From: Voon Weifeng <[email protected]>
Enabled EST related interrupts as below:
1) Constant Gate Control Error (CGCE)
2) Head-of-Line Blocking due to Scheduling (HLBS)
3) Head-of-Line Blocking due to Frame Size (HLBF).
4) Base Time Register error (BTRE)
5) Switch to S/W owned list Complete (SWLC)
For HLBS, the user will get the info of all the queues that shows this error. For HLBF, the user will get the info of all the queue with the latest frame size which causes the error. Frame size 0 indicates no error.
The ISR handling takes place when EST feature is enabled by user.
---
v2 changelog:
- Changed dwmac5_est_irq_status() function declaration to void.
- Changed queue value display for HLB(sched) error to hex.
--- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 75 +++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 32 ++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 3 + 4 files changed, 114 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +75 -0
@@ -595,9 +595,84 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, ctrl &= ~EEST ;writel (ctrl, ioaddr +MTL_EST_CONTROL ); + +/* Configure EST interrupt */ +if (cfg->enable) + ctrl = (IECGCE |IEHS |IEHF |IEBE |IECC ); +else + ctrl =0 ; + +writel (ctrl, ioaddr +MTL_EST_INT_EN ); +return 0 ; } +void dwmac5_est_irq_status (void __iomem *ioaddr,struct net_device *dev, +u32 txqcnt) +{ +u32 status, value, feqn, hbfq, hbfs, btrl; +u32 txqcnt_mask = (1 << txqcnt) -1 ; + + status =readl (ioaddr +MTL_EST_STATUS ); + + value = (CGCE |HLBS |HLBF |BTRE |SWLC ); + +/* Return if there is no error */ +if (!(status & value)) +return ; + +if (status &CGCE ) { +/* Clear Interrupt */ +writel (CGCE , ioaddr +MTL_EST_STATUS ); + } + +if (status &HLBS ) { + value =readl (ioaddr +MTL_EST_SCH_ERR ); + value &= txqcnt_mask; + +/* Clear Interrupt */ +writel (value, ioaddr +MTL_EST_SCH_ERR ); + +/* Collecting info to shows all the queues that has HLBS +* issue. The only way to clear this is to clear the +* statistic +*/ +if (net_ratelimit ()) +netdev_err (dev,"EST: HLB(sched) Queue 0x%x\n" , value); + } + +if (status &HLBF ) { + value =readl (ioaddr +MTL_EST_FRM_SZ_ERR ); + feqn = value & txqcnt_mask; + + value =readl (ioaddr +MTL_EST_FRM_SZ_CAP ); + hbfq = (value &SZ_CAP_HBFQ_MASK (txqcnt)) >>SZ_CAP_HBFQ_SHIFT ; + hbfs = value &SZ_CAP_HBFS_MASK ; + +/* Clear Interrupt */ +writel (feqn, ioaddr +MTL_EST_FRM_SZ_ERR ); + +if (net_ratelimit ()) +netdev_err (dev,"EST: HLB(size) Queue %u Size %u\n" , + hbfq, hbfs); + } + +if (status &BTRE ) { + btrl = (status &BTRL ) >>BTRL_SHIFT ; + +if (net_ratelimit ()) +netdev_info (dev,"EST: BTR Error Loop Count %u\n" , + btrl); + +writel (BTRE , ioaddr +MTL_EST_STATUS ); + } + +if (status &SWLC ) { +writel (SWLC , ioaddr +MTL_EST_STATUS ); +netdev_info (dev,"EST: SWOL has been switched\n" ); + } +} +void dwmac5_fpe_configure (void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable) {
drivers/net/ethernet/stmicro/stmmac/dwmac5.h +32 -0
@@ -38,6 +38,36 @@#define PTOV_SHIFT 24#define SSWL BIT(1)#define EEST BIT(0) + +#define MTL_EST_STATUS 0x00000c58 +#define BTRL GENMASK(11, 8) +#define BTRL_SHIFT 8 +#define BTRL_MAX (0xF << BTRL_SHIFT) +#define SWOL BIT(7) +#define SWOL_SHIFT 7 +#define CGCE BIT(4) +#define HLBS BIT(3) +#define HLBF BIT(2) +#define BTRE BIT(1) +#define SWLC BIT(0) + +#define MTL_EST_SCH_ERR 0x00000c60 +#define MTL_EST_FRM_SZ_ERR 0x00000c64 +#define MTL_EST_FRM_SZ_CAP 0x00000c68 +#define SZ_CAP_HBFS_MASK GENMASK(14, 0) +#define SZ_CAP_HBFQ_SHIFT 16 +#define SZ_CAP_HBFQ_MASK (_val) ({ typeof(_val) (val) = (_val); \ + ((val) > 4 ? GENMASK(18, 16) : \ + (val) > 2 ? GENMASK(17, 16) : \ + BIT(16)); }) + +#define MTL_EST_INT_EN 0x00000c70 +#define IECGCE CGCE +#define IEHS HLBS +#define IEHF HLBF +#define IEBE BTRE +#define IECC SWLC +#define MTL_EST_GCL_CONTROL 0x00000c80#define BTR_LOW 0x0#define BTR_HIGH 0x1
@@ -111,6 +141,8 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index, u32 sub_second_inc, u32 systime_flags);int dwmac5_est_configure (void __iomem *ioaddr,struct stmmac_est *cfg,unsigned int ptp_rate); +void dwmac5_est_irq_status (void __iomem *ioaddr,struct net_device *dev, +u32 txqcnt);void dwmac5_fpe_configure (void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable);
drivers/net/ethernet/stmicro/stmmac/hwif.h +4 -0
@@ -393,6 +393,8 @@ struct stmmac_ops {void (*set_arp_offload)(struct mac_device_info *hw,bool en,u32 addr);int (*est_configure)(void __iomem *ioaddr,struct stmmac_est *cfg,unsigned int ptp_rate); +void (*est_irq_status)(void __iomem *ioaddr,struct net_device *dev, +u32 txqcnt);void (*fpe_configure)(void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable); };
@@ -491,6 +493,8 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_arp_offload, __args) #define stmmac_est_configure(__priv, __args...) \ stmmac_do_callback(__priv, mac, est_configure, __args) +#define stmmac_est_irq_status(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, est_irq_status, __args) #define stmmac_fpe_configure(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, fpe_configure, __args)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -0
@@ -4286,6 +4286,9 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)if (stmmac_safety_feat_interrupt (priv))return IRQ_HANDLED ; +if (priv->dma_cap.estsel) +stmmac_est_irq_status (priv, priv->ioaddr, priv->dev, tx_cnt); +/* To handle GMAC own interrupts */ if ((priv->plat->has_gmac) || xmac) {int status =stmmac_host_irq_status (priv, priv->hw, &priv->xstats);
Signature · 1 line
2.17.1
PATCH 2/2 net: stmmac: Add EST errors into ethtool statistic
In reply to [email protected]From: Ong Boon Leong <[email protected]>
Below EST errors are added into ethtool statistic:
1) Constant Gate Control Error (CGCE):
The counter "mtl_est_cgce" increases everytime CGCE interrupt is triggered.
2) Head-of-Line Blocking due to Scheduling (HLBS):
The counter "mtl_est_hlbs" increases everytime HLBS interrupt is triggered.
3) Head-of-Line Blocking due to Frame Size (HLBF):
The counter "mtl_est_hlbf" increases everytime HLBF interrupt is triggered.
4) Base Time Register error (BTRE):
The counter "mtl_est_btre" increases everytime BTRE interrupt is triggered but BTRL not reaches maximum value of 15.
5) Base Time Register Error Loop Count (BTRL) reaches maximum value:
The counter "mtl_est_btrlm" increases everytime BTRE interrupt is triggered and BTRL value reaches maximum value of 15.
Please refer to MTL_EST_STATUS register in DesignWare Cores Ethernet Quality-of-Service Databook for more detail explanation.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 6 ++++++ drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 13 ++++++++++++- drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 2 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- 6 files changed, 28 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +6 -0
@@ -182,6 +182,12 @@ struct stmmac_extra_stats {/* TSO */ unsigned long tx_tso_frames;unsigned long tx_tso_nfrags; +/* EST */ +unsigned long mtl_est_cgce; +unsigned long mtl_est_hlbs; +unsigned long mtl_est_hlbf; +unsigned long mtl_est_btre; +unsigned long mtl_est_btrlm; };/* Safety Feature statistics exposed by ethtool */
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +12 -1
@@ -608,7 +608,7 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, }void dwmac5_est_irq_status (void __iomem *ioaddr,struct net_device *dev, -u32 txqcnt) +struct stmmac_extra_stats *x,u32 txqcnt) {u32 status, value, feqn, hbfq, hbfs, btrl;u32 txqcnt_mask = (1 << txqcnt) -1 ;
@@ -624,12 +624,16 @@ void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev,if (status &CGCE ) {/* Clear Interrupt */ writel (CGCE , ioaddr +MTL_EST_STATUS ); + + x->mtl_est_cgce++; }if (status &HLBS ) { value =readl (ioaddr +MTL_EST_SCH_ERR ); value &= txqcnt_mask; + x->mtl_est_hlbs++; +/* Clear Interrupt */ writel (value, ioaddr +MTL_EST_SCH_ERR );
@@ -649,6 +653,8 @@ void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, hbfq = (value &SZ_CAP_HBFQ_MASK (txqcnt)) >>SZ_CAP_HBFQ_SHIFT ; hbfs = value &SZ_CAP_HBFS_MASK ; + x->mtl_est_hlbf++; +/* Clear Interrupt */ writel (feqn, ioaddr +MTL_EST_FRM_SZ_ERR );
@@ -658,6 +664,11 @@ void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, }if (status &BTRE ) { +if ((status &BTRL ) ==BTRL_MAX ) + x->mtl_est_btrlm++; +else + x->mtl_est_btre++; + btrl = (status &BTRL ) >>BTRL_SHIFT ;if (net_ratelimit ())
drivers/net/ethernet/stmicro/stmmac/dwmac5.h +1 -1
@@ -142,7 +142,7 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,int dwmac5_est_configure (void __iomem *ioaddr,struct stmmac_est *cfg,unsigned int ptp_rate);void dwmac5_est_irq_status (void __iomem *ioaddr,struct net_device *dev, -u32 txqcnt); +struct stmmac_extra_stats *x,u32 txqcnt);void dwmac5_fpe_configure (void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable);
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -1
@@ -394,7 +394,7 @@ struct stmmac_ops {int (*est_configure)(void __iomem *ioaddr,struct stmmac_est *cfg,unsigned int ptp_rate);void (*est_irq_status)(void __iomem *ioaddr,struct net_device *dev, -u32 txqcnt); +struct stmmac_extra_stats *x,u32 txqcnt);void (*fpe_configure)(void __iomem *ioaddr,u32 num_txq,u32 num_rxq,bool enable); };
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +6 -0
@@ -158,6 +158,12 @@ static const struct stmmac_stats stmmac_gstrings_stats[] = {/* TSO */ STMMAC_STAT (tx_tso_frames),STMMAC_STAT (tx_tso_nfrags), +/* EST */ +STMMAC_STAT (mtl_est_cgce), +STMMAC_STAT (mtl_est_hlbs), +STMMAC_STAT (mtl_est_hlbf), +STMMAC_STAT (mtl_est_btre), + STMMAC_STAT(mtl_est_btrlm), };#define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -4287,7 +4287,8 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)return IRQ_HANDLED ;if (priv->dma_cap.estsel) -stmmac_est_irq_status (priv, priv->ioaddr, priv->dev, tx_cnt); +stmmac_est_irq_status (priv, priv->ioaddr, priv->dev, + &priv->xstats, tx_cnt);/* To handle GMAC own interrupts */ if ((priv->plat->has_gmac) || xmac) {
Signature · 1 line
2.17.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Thu, 18 Mar 2021 08:50:51 +0800 you wrote:
From: Mohammad Athari Bin Ismail <[email protected]>
This patchset adds support for handling EST interrupts and reporting EST errors. Additionally, the errors are added into ethtool statistic.
Ong Boon Leong (1):
net: stmmac: Add EST errors into ethtool statistic[...]
Here is the summary with links:
- [net-next,v2,1/2] net: stmmac: EST interrupts handling and error reporting
https://git.kernel.org/netdev/net-next/c/e49aa315cb01 - [net-next,2/2] net: stmmac: Add EST errors into ethtool statistic https://git.kernel.org/netdev/net-next/c/9f298959191b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html