Re: [PATCH v3 09/13] net: ethernet: ti: cpsw: move cpdma resources to cpsw_common

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 04:52 AM, Ivan Khoronzhuk wrote:
> Every net device private struct holds links to shared cpdma resources.
> No need to save and every time synchronize these resources per net dev.
> So, move it to common driver struct.
> 
> Signed-off-by: Ivan Khoronzhuk 

Reviewed-by: Mugunthan V N 

Regards
Mugunthan V N


[PATCH v3 09/13] net: ethernet: ti: cpsw: move cpdma resources to cpsw_common

2016-08-09 Thread Ivan Khoronzhuk
Every net device private struct holds links to shared cpdma resources.
No need to save and every time synchronize these resources per net dev.
So, move it to common driver struct.

Signed-off-by: Ivan Khoronzhuk 
---
 drivers/net/ethernet/ti/cpsw.c | 97 +-
 1 file changed, 48 insertions(+), 49 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 5db2a55..6d99d1e 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -369,6 +369,8 @@ struct cpsw_common {
struct cpsw_wr_regs __iomem *wr_regs;
u8 __iomem  *hw_stats;
struct cpsw_host_regs __iomem   *host_port_regs;
+   struct cpdma_ctlr   *dma;
+   struct cpdma_chan   *txch, *rxch;
 };
 
 struct cpsw_priv {
@@ -384,8 +386,6 @@ struct cpsw_priv {
int rx_packet_max;
u8  mac_addr[ETH_ALEN];
struct cpsw_slave   *slaves;
-   struct cpdma_ctlr   *dma;
-   struct cpdma_chan   *txch, *rxch;
struct cpsw_ale *ale;
boolrx_pause;
booltx_pause;
@@ -654,25 +654,21 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
}
 }
 
-static void cpsw_intr_enable(struct cpsw_priv *priv)
+static void cpsw_intr_enable(struct cpsw_common *cpsw)
 {
-   struct cpsw_common *cpsw = priv->cpsw;
-
__raw_writel(0xFF, >wr_regs->tx_en);
__raw_writel(0xFF, >wr_regs->rx_en);
 
-   cpdma_ctlr_int_ctrl(priv->dma, true);
+   cpdma_ctlr_int_ctrl(cpsw->dma, true);
return;
 }
 
-static void cpsw_intr_disable(struct cpsw_priv *priv)
+static void cpsw_intr_disable(struct cpsw_common *cpsw)
 {
-   struct cpsw_common *cpsw = priv->cpsw;
-
__raw_writel(0, >wr_regs->tx_en);
__raw_writel(0, >wr_regs->rx_en);
 
-   cpdma_ctlr_int_ctrl(priv->dma, false);
+   cpdma_ctlr_int_ctrl(cpsw->dma, false);
return;
 }
 
@@ -700,6 +696,7 @@ static void cpsw_rx_handler(void *token, int len, int 
status)
struct net_device   *ndev = skb->dev;
struct cpsw_priv*priv = netdev_priv(ndev);
int ret = 0;
+   struct cpsw_common  *cpsw = priv->cpsw;
 
cpsw_dual_emac_src_port_detect(status, priv, ndev, skb);
 
@@ -745,8 +742,8 @@ static void cpsw_rx_handler(void *token, int len, int 
status)
}
 
 requeue:
-   ret = cpdma_chan_submit(priv->rxch, new_skb, new_skb->data,
-   skb_tailroom(new_skb), 0);
+   ret = cpdma_chan_submit(cpsw->rxch, new_skb, new_skb->data,
+   skb_tailroom(new_skb), 0);
if (WARN_ON(ret < 0))
dev_kfree_skb_any(new_skb);
 }
@@ -757,7 +754,7 @@ static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
struct cpsw_common *cpsw = priv->cpsw;
 
writel(0, >wr_regs->tx_en);
-   cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
+   cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX);
 
if (priv->quirk_irq) {
disable_irq_nosync(priv->irqs_table[1]);
@@ -773,7 +770,7 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
struct cpsw_priv *priv = dev_id;
struct cpsw_common *cpsw = priv->cpsw;
 
-   cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
+   cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX);
writel(0, >wr_regs->rx_en);
 
if (priv->quirk_irq) {
@@ -791,7 +788,7 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int 
budget)
int num_tx;
struct cpsw_common  *cpsw = priv->cpsw;
 
-   num_tx = cpdma_chan_process(priv->txch, budget);
+   num_tx = cpdma_chan_process(cpsw->txch, budget);
if (num_tx < budget) {
napi_complete(napi_tx);
writel(0xff, >wr_regs->tx_en);
@@ -810,7 +807,7 @@ static int cpsw_rx_poll(struct napi_struct *napi_rx, int 
budget)
int num_rx;
struct cpsw_common  *cpsw = priv->cpsw;
 
-   num_rx = cpdma_chan_process(priv->rxch, budget);
+   num_rx = cpdma_chan_process(cpsw->rxch, budget);
if (num_rx < budget) {
napi_complete(napi_rx);
writel(0xff, >wr_regs->rx_en);
@@ -1020,17 +1017,16 @@ static void cpsw_get_strings(struct net_device *ndev, 
u32 stringset, u8 *data)
 static void cpsw_get_ethtool_stats(struct net_device *ndev,
struct ethtool_stats *stats, u64 *data)
 {
-   struct cpsw_priv *priv = netdev_priv(ndev);
struct cpdma_chan_stats rx_stats;
struct cpdma_chan_stats tx_stats;
u32 val;
u8 *p;
int i;
-   struct cpsw_common *cpsw = priv->cpsw;
+   struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
 
/*