From 27f9025d49416e35bd7f1cedc9edd0388612501f Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Wed, 10 Mar 2021 14:03:43 +0200 Subject: [PATCH] net: enetc: save the mode register address inside struct enetc_cbdr enetc_clear_cbdr depends on struct enetc_hw because it must disable the ring through a register write. We'd like to remove that dependency, so let's do what's already done with the producer and consumer indices, which is to save the iomem address in a variable kept in struct enetc_cbdr. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++-- drivers/net/ethernet/freescale/enetc/enetc.h | 3 ++- drivers/net/ethernet/freescale/enetc/enetc_cbdr.c | 19 ++++++++++--------- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 718ce01..80f80a1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1074,7 +1074,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) return 0; err_alloc_cls: - enetc_clear_cbdr(&si->hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); return err; @@ -1084,7 +1084,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; - enetc_clear_cbdr(&si->hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); kfree(priv->cls_rules); diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 1f2e9be..9d4dbee 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -98,6 +98,7 @@ struct enetc_cbdr { void *bd_base; /* points to Rx or Tx BD ring */ void __iomem *pir; void __iomem *cir; + void __iomem *mr; /* mode register */ int bd_count; /* # of BDs */ int next_to_use; @@ -314,7 +315,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev); int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, struct enetc_cbdr *cbdr); void enetc_free_cbdr(struct enetc_cbdr *cbdr); -void enetc_clear_cbdr(struct enetc_hw *hw); +void enetc_clear_cbdr(struct enetc_cbdr *cbdr); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 4de31b2..bb20a58 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -24,6 +24,10 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, cbdr->next_to_use = 0; cbdr->dma_dev = dev; + cbdr->pir = hw->reg + ENETC_SICBDRPIR; + cbdr->cir = hw->reg + ENETC_SICBDRCIR; + cbdr->mr = hw->reg + ENETC_SICBDRMR; + /* set CBDR cache attributes */ enetc_wr(hw, ENETC_SICAR2, ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); @@ -32,14 +36,10 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, enetc_wr(hw, ENETC_SICBDRBAR1, upper_32_bits(cbdr->bd_dma_base)); enetc_wr(hw, ENETC_SICBDRLENR, ENETC_RTBLENR_LEN(cbdr->bd_count)); - enetc_wr(hw, ENETC_SICBDRPIR, 0); - enetc_wr(hw, ENETC_SICBDRCIR, 0); - + enetc_wr_reg(cbdr->pir, cbdr->next_to_clean); + enetc_wr_reg(cbdr->cir, cbdr->next_to_use); /* enable ring */ - enetc_wr(hw, ENETC_SICBDRMR, BIT(31)); - - cbdr->pir = hw->reg + ENETC_SICBDRPIR; - cbdr->cir = hw->reg + ENETC_SICBDRCIR; + enetc_wr_reg(cbdr->mr, BIT(31)); return 0; } @@ -54,9 +54,10 @@ void enetc_free_cbdr(struct enetc_cbdr *cbdr) cbdr->dma_dev = NULL; } -void enetc_clear_cbdr(struct enetc_hw *hw) +void enetc_clear_cbdr(struct enetc_cbdr *cbdr) { - enetc_wr(hw, ENETC_SICBDRMR, 0); + /* disable ring */ + enetc_wr_reg(cbdr->mr, 0); } static void enetc_clean_cbdr(struct enetc_cbdr *ring) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 31d229e..f083d49 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1095,7 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si) enetc_init_port_rfs_memory(si); enetc_init_port_rss_memory(si); - enetc_clear_cbdr(hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); } -- 2.7.4