Re: [PATCH v3 13/13] net: ethernet: ti: cpsw: move ale, cpts and drivers params under cpsw_common

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 04:52 AM, Ivan Khoronzhuk wrote:
> The ale, cpts, version, rx_packet_max, bus_freq, interrupt pacing
> parameters are common per net device that uses the same h/w. So,
> move them to common driver structure.
> 
> Signed-off-by: Ivan Khoronzhuk 

Reviewed-by: Mugunthan V N 

Regards
Mugunthan V N


[PATCH v3 13/13] net: ethernet: ti: cpsw: move ale, cpts and drivers params under cpsw_common

2016-08-09 Thread Ivan Khoronzhuk
The ale, cpts, version, rx_packet_max, bus_freq, interrupt pacing
parameters are common per net device that uses the same h/w. So,
move them to common driver structure.

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

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 2c2e36a..b4d3b41 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -373,28 +373,28 @@ struct cpsw_common {
struct cpsw_wr_regs __iomem *wr_regs;
u8 __iomem  *hw_stats;
struct cpsw_host_regs __iomem   *host_port_regs;
+   u32 version;
+   u32 coal_intvl;
+   u32 bus_freq_mhz;
+   int rx_packet_max;
struct cpsw_slave   *slaves;
struct cpdma_ctlr   *dma;
struct cpdma_chan   *txch, *rxch;
+   struct cpsw_ale *ale;
boolquirk_irq;
boolrx_irq_disabled;
booltx_irq_disabled;
u32 irqs_table[IRQ_NUM];
+   struct cpts *cpts;
 };
 
 struct cpsw_priv {
struct net_device   *ndev;
struct device   *dev;
u32 msg_enable;
-   u32 version;
-   u32 coal_intvl;
-   u32 bus_freq_mhz;
-   int rx_packet_max;
u8  mac_addr[ETH_ALEN];
-   struct cpsw_ale *ale;
boolrx_pause;
booltx_pause;
-   struct cpts *cpts;
u32 emac_port;
struct cpsw_common *cpsw;
 };
@@ -502,22 +502,16 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
n; n--) \
(func)(slave++, ##arg); \
} while (0)
-#define cpsw_get_slave_priv(cpsw, __slave_no__)
\
-   (((__slave_no__ < cpsw->data.slaves) && \
-   (cpsw->slaves[__slave_no__].ndev)) ?\
-   netdev_priv(cpsw->slaves[__slave_no__].ndev) : NULL)\
 
-#define cpsw_dual_emac_src_port_detect(cpsw, status, priv, ndev, skb)  \
+#define cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb)
\
do {\
if (!cpsw->data.dual_emac)  \
break;  \
if (CPDMA_RX_SOURCE_PORT(status) == 1) {\
ndev = cpsw->slaves[0].ndev;\
-   priv = netdev_priv(ndev);   \
skb->dev = ndev;\
} else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \
ndev = cpsw->slaves[1].ndev;\
-   priv = netdev_priv(ndev);   \
skb->dev = ndev;\
}   \
} while (0)
@@ -528,11 +522,11 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
priv->emac_port;\
int slave_port = cpsw_get_slave_port(   \
slave->slave_num);  \
-   cpsw_ale_add_mcast(priv->ale, addr, \
+   cpsw_ale_add_mcast(cpsw->ale, addr, \
1 << slave_port | ALE_PORT_HOST,\
ALE_VLAN, slave->port_vlan, 0); \
} else {\
-   cpsw_ale_add_mcast(priv->ale, addr, \
+   cpsw_ale_add_mcast(cpsw->ale, addr, \
ALE_ALL_PORTS,  \
0, 0, 0);   \
}   \
@@ -545,9 +539,8 @@ static inline int cpsw_get_slave_port(u32 slave_num)
 
 static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
 {
-   struct cpsw_priv *priv = netdev_priv(ndev);
-   struct cpsw_common *cpsw = priv->cpsw;
-   struct