net: stmmac: enable platform specific safety features
authorWong Vee Khee <vee.khee.wong@linux.intel.com>
Tue, 1 Jun 2021 13:52:35 +0000 (21:52 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Jun 2021 23:59:50 +0000 (16:59 -0700)
On Intel platforms, not all safety features are enabled on the hardware.
The current implementation enable all safety features by default. This
will cause mass error and warning printouts after the module is loaded.

Introduce platform specific safety features flag to enable or disable
each safety features.

Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/net/ethernet/stmicro/stmmac/dwmac5.c
drivers/net/ethernet/stmicro/stmmac/dwmac5.h
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
drivers/net/ethernet/stmicro/stmmac/hwif.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
include/linux/stmmac.h

index e36a8cc59ad0a232203b4de79d82c4e1bcb4e326..2ecf93c84b9d2d1850c6e9ae311fc1c11024e84c 100644 (file)
@@ -568,6 +568,16 @@ static int ehl_common_data(struct pci_dev *pdev,
        plat->tx_queues_to_use = 8;
        plat->clk_ptp_rate = 200000000;
 
+       plat->safety_feat_cfg->tsoee = 1;
+       plat->safety_feat_cfg->mrxpee = 1;
+       plat->safety_feat_cfg->mestee = 1;
+       plat->safety_feat_cfg->mrxee = 1;
+       plat->safety_feat_cfg->mtxee = 1;
+       plat->safety_feat_cfg->epsi = 0;
+       plat->safety_feat_cfg->edpp = 0;
+       plat->safety_feat_cfg->prtyen = 0;
+       plat->safety_feat_cfg->tmouten = 0;
+
        return intel_mgbe_common_data(pdev, plat);
 }
 
@@ -683,6 +693,16 @@ static int tgl_common_data(struct pci_dev *pdev,
        plat->tx_queues_to_use = 4;
        plat->clk_ptp_rate = 200000000;
 
+       plat->safety_feat_cfg->tsoee = 1;
+       plat->safety_feat_cfg->mrxpee = 0;
+       plat->safety_feat_cfg->mestee = 1;
+       plat->safety_feat_cfg->mrxee = 1;
+       plat->safety_feat_cfg->mtxee = 1;
+       plat->safety_feat_cfg->epsi = 0;
+       plat->safety_feat_cfg->edpp = 0;
+       plat->safety_feat_cfg->prtyen = 0;
+       plat->safety_feat_cfg->tmouten = 0;
+
        return intel_mgbe_common_data(pdev, plat);
 }
 
@@ -959,6 +979,12 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,
        if (!plat->dma_cfg)
                return -ENOMEM;
 
+       plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
+                                            sizeof(*plat->safety_feat_cfg),
+                                            GFP_KERNEL);
+       if (!plat->safety_feat_cfg)
+               return -ENOMEM;
+
        /* Enable pci device */
        ret = pcim_enable_device(pdev);
        if (ret) {
index d8c6ff72523773446ec5d96b63419c3e44700ec0..9c2d40f853ed0429d19d2ac0d647640f29dda878 100644 (file)
@@ -183,7 +183,8 @@ static void dwmac5_handle_dma_err(struct net_device *ndev,
                        STAT_OFF(dma_errors), stats);
 }
 
-int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
+int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
+                             struct stmmac_safety_feature_cfg *safety_feat_cfg)
 {
        u32 value;
 
@@ -193,11 +194,16 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
        /* 1. Enable Safety Features */
        value = readl(ioaddr + MTL_ECC_CONTROL);
        value |= MEEAO; /* MTL ECC Error Addr Status Override */
-       value |= TSOEE; /* TSO ECC */
-       value |= MRXPEE; /* MTL RX Parser ECC */
-       value |= MESTEE; /* MTL EST ECC */
-       value |= MRXEE; /* MTL RX FIFO ECC */
-       value |= MTXEE; /* MTL TX FIFO ECC */
+       if (safety_feat_cfg->tsoee)
+               value |= TSOEE; /* TSO ECC */
+       if (safety_feat_cfg->mrxpee)
+               value |= MRXPEE; /* MTL RX Parser ECC */
+       if (safety_feat_cfg->mestee)
+               value |= MESTEE; /* MTL EST ECC */
+       if (safety_feat_cfg->mrxee)
+               value |= MRXEE; /* MTL RX FIFO ECC */
+       if (safety_feat_cfg->mtxee)
+               value |= MTXEE; /* MTL TX FIFO ECC */
        writel(value, ioaddr + MTL_ECC_CONTROL);
 
        /* 2. Enable MTL Safety Interrupts */
@@ -219,13 +225,16 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
 
        /* 5. Enable Parity and Timeout for FSM */
        value = readl(ioaddr + MAC_FSM_CONTROL);
-       value |= PRTYEN; /* FSM Parity Feature */
-       value |= TMOUTEN; /* FSM Timeout Feature */
+       if (safety_feat_cfg->prtyen)
+               value |= PRTYEN; /* FSM Parity Feature */
+       if (safety_feat_cfg->tmouten)
+               value |= TMOUTEN; /* FSM Timeout Feature */
        writel(value, ioaddr + MAC_FSM_CONTROL);
 
        /* 4. Enable Data Parity Protection */
        value = readl(ioaddr + MTL_DPP_CONTROL);
-       value |= EDPP;
+       if (safety_feat_cfg->edpp)
+               value |= EDPP;
        writel(value, ioaddr + MTL_DPP_CONTROL);
 
        /*
@@ -235,7 +244,8 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
        if (asp <= 0x2)
                return 0;
 
-       value |= EPSI;
+       if (safety_feat_cfg->epsi)
+               value |= EPSI;
        writel(value, ioaddr + MTL_DPP_CONTROL);
        return 0;
 }
index 6b2fd37b29ada6ac122f7832c794b06af9bb13be..53c138d0ff4808d3ca4b4f3fcd456afbe85ae493 100644 (file)
 
 #define GMAC_INT_FPE_EN                        BIT(17)
 
-int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp);
+int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
+                             struct stmmac_safety_feature_cfg *safety_cfg);
 int dwmac5_safety_feat_irq_status(struct net_device *ndev,
                void __iomem *ioaddr, unsigned int asp,
                struct stmmac_safety_stats *stats);
index ad4df9bddcf351503c5d90f17ad3e95a1bd2b616..c4d78fa93663b5bc1eaffef9fa03e59a88230dc2 100644 (file)
@@ -801,7 +801,9 @@ static void dwxgmac3_handle_dma_err(struct net_device *ndev,
                           dwxgmac3_dma_errors, STAT_OFF(dma_errors), stats);
 }
 
-static int dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
+static int
+dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
+                           struct stmmac_safety_feature_cfg *safety_cfg)
 {
        u32 value;
 
index 75a8b90c202a18a519766b9ceca5d33ff370e905..dbafedb242909a7b5acee17b837ea39934249aed 100644 (file)
@@ -348,7 +348,8 @@ struct stmmac_ops {
        void (*pcs_rane)(void __iomem *ioaddr, bool restart);
        void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
        /* Safety Features */
-       int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp);
+       int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
+                                 struct stmmac_safety_feature_cfg *safety_cfg);
        int (*safety_feat_irq_status)(struct net_device *ndev,
                        void __iomem *ioaddr, unsigned int asp,
                        struct stmmac_safety_stats *stats);
index 9962a1041d35ffc0b20a23e54680d2615b9e3903..13720bf6f6ff90bd3fe97b2eabc59d42a11b12e9 100644 (file)
@@ -3172,7 +3172,8 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)
 {
        if (priv->dma_cap.asp) {
                netdev_info(priv->dev, "Enabling Safety Features\n");
-               stmmac_safety_feat_config(priv, priv->ioaddr, priv->dma_cap.asp);
+               stmmac_safety_feat_config(priv, priv->ioaddr, priv->dma_cap.asp,
+                                         priv->plat->safety_feat_cfg);
        } else {
                netdev_info(priv->dev, "No Safety Features support found\n");
        }
index 95e0e4d6f74d23b960eab17d59f318a8bebf7ed2..fcf17d8a0494b7a464e2e704bf049d44738640fe 100644 (file)
@@ -174,6 +174,12 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
        if (!plat->dma_cfg)
                return -ENOMEM;
 
+       plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
+                                            sizeof(*plat->safety_feat_cfg),
+                                            GFP_KERNEL);
+       if (!plat->safety_feat_cfg)
+               return -ENOMEM;
+
        /* Enable pci device */
        ret = pci_enable_device(pdev);
        if (ret) {
@@ -203,6 +209,16 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
        res.wol_irq = pdev->irq;
        res.irq = pdev->irq;
 
+       plat->safety_feat_cfg->tsoee = 1;
+       plat->safety_feat_cfg->mrxpee = 1;
+       plat->safety_feat_cfg->mestee = 1;
+       plat->safety_feat_cfg->mrxee = 1;
+       plat->safety_feat_cfg->mtxee = 1;
+       plat->safety_feat_cfg->epsi = 1;
+       plat->safety_feat_cfg->edpp = 1;
+       plat->safety_feat_cfg->prtyen = 1;
+       plat->safety_feat_cfg->tmouten = 1;
+
        return stmmac_dvr_probe(&pdev->dev, plat, &res);
 }
 
index e14a12df381bc11be0c964e12f407200b7b3a3b2..e55a4807e3eacc3f472d3013c4b7c168dd14ba41 100644 (file)
@@ -172,6 +172,18 @@ struct stmmac_fpe_cfg {
        enum stmmac_fpe_state lo_fpe_state;     /* Local station FPE state */
 };
 
+struct stmmac_safety_feature_cfg {
+       u32 tsoee;
+       u32 mrxpee;
+       u32 mestee;
+       u32 mrxee;
+       u32 mtxee;
+       u32 epsi;
+       u32 edpp;
+       u32 prtyen;
+       u32 tmouten;
+};
+
 struct plat_stmmacenet_data {
        int bus_id;
        int phy_addr;
@@ -184,6 +196,7 @@ struct plat_stmmacenet_data {
        struct stmmac_dma_cfg *dma_cfg;
        struct stmmac_est *est;
        struct stmmac_fpe_cfg *fpe_cfg;
+       struct stmmac_safety_feature_cfg *safety_feat_cfg;
        int clk_csr;
        int has_gmac;
        int enh_desc;