aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Oltean2021-03-10 14:03:43 +0200
committerDavid S. Miller2021-03-10 13:14:15 -0800
commit27f9025d49416e35bd7f1cedc9edd0388612501f (patch)
tree4572a39d75d8b6285fdd0e5587a2013d34dac130
parent24be14e3260ad8f5b926da8ad0bc0067435e7340 (diff)
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 <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc.c4
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc.h3
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_cbdr.c19
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_pf.c2
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 718ce01daffe..80f80a1c7dd2 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 1f2e9bec1b30..9d4dbeef61ac 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 4de31b283319..bb20a58e8830 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 31d229e0912a..f083d49d7772 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);
}