aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-08-09 19:22:43 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-10 20:27:40 -0400
commitdbc4ec522d2ee2b3fa24d329a7a63594aba3b069 (patch)
tree34e5a05721e2c11a089dbd984300a67110addac7 /drivers/net/ethernet/ti
parent606f39939595a4d4540406bfc11f265b2036af6d (diff)
net: ethernet: ti: cpsw: move napi struct to cpsw_common
The napi structs are common for both net devices in dual_emac mode, In order to not hold duplicate links to them, move to cpsw_common. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r--drivers/net/ethernet/ti/cpsw.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index ab5488b0cbae..2c2e36a416c1 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -367,6 +367,8 @@ static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset)
367struct cpsw_common { 367struct cpsw_common {
368 struct device *dev; 368 struct device *dev;
369 struct cpsw_platform_data data; 369 struct cpsw_platform_data data;
370 struct napi_struct napi_rx;
371 struct napi_struct napi_tx;
370 struct cpsw_ss_regs __iomem *regs; 372 struct cpsw_ss_regs __iomem *regs;
371 struct cpsw_wr_regs __iomem *wr_regs; 373 struct cpsw_wr_regs __iomem *wr_regs;
372 u8 __iomem *hw_stats; 374 u8 __iomem *hw_stats;
@@ -382,8 +384,6 @@ struct cpsw_common {
382 384
383struct cpsw_priv { 385struct cpsw_priv {
384 struct net_device *ndev; 386 struct net_device *ndev;
385 struct napi_struct napi_rx;
386 struct napi_struct napi_tx;
387 struct device *dev; 387 struct device *dev;
388 u32 msg_enable; 388 u32 msg_enable;
389 u32 version; 389 u32 version;
@@ -488,7 +488,7 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
488#define CPSW_STATS_LEN ARRAY_SIZE(cpsw_gstrings_stats) 488#define CPSW_STATS_LEN ARRAY_SIZE(cpsw_gstrings_stats)
489 489
490#define ndev_to_cpsw(ndev) (((struct cpsw_priv *)netdev_priv(ndev))->cpsw) 490#define ndev_to_cpsw(ndev) (((struct cpsw_priv *)netdev_priv(ndev))->cpsw)
491#define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi) 491#define napi_to_cpsw(napi) container_of(napi, struct cpsw_common, napi)
492#define for_each_slave(priv, func, arg...) \ 492#define for_each_slave(priv, func, arg...) \
493 do { \ 493 do { \
494 struct cpsw_slave *slave; \ 494 struct cpsw_slave *slave; \
@@ -752,8 +752,7 @@ requeue:
752 752
753static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id) 753static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
754{ 754{
755 struct cpsw_priv *priv = dev_id; 755 struct cpsw_common *cpsw = dev_id;
756 struct cpsw_common *cpsw = priv->cpsw;
757 756
758 writel(0, &cpsw->wr_regs->tx_en); 757 writel(0, &cpsw->wr_regs->tx_en);
759 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX); 758 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX);
@@ -763,14 +762,13 @@ static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
763 cpsw->tx_irq_disabled = true; 762 cpsw->tx_irq_disabled = true;
764 } 763 }
765 764
766 napi_schedule(&priv->napi_tx); 765 napi_schedule(&cpsw->napi_tx);
767 return IRQ_HANDLED; 766 return IRQ_HANDLED;
768} 767}
769 768
770static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id) 769static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
771{ 770{
772 struct cpsw_priv *priv = dev_id; 771 struct cpsw_common *cpsw = dev_id;
773 struct cpsw_common *cpsw = priv->cpsw;
774 772
775 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX); 773 cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX);
776 writel(0, &cpsw->wr_regs->rx_en); 774 writel(0, &cpsw->wr_regs->rx_en);
@@ -780,15 +778,14 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
780 cpsw->rx_irq_disabled = true; 778 cpsw->rx_irq_disabled = true;
781 } 779 }
782 780
783 napi_schedule(&priv->napi_rx); 781 napi_schedule(&cpsw->napi_rx);
784 return IRQ_HANDLED; 782 return IRQ_HANDLED;
785} 783}
786 784
787static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget) 785static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
788{ 786{
789 struct cpsw_priv *priv = napi_to_priv(napi_tx); 787 struct cpsw_common *cpsw = napi_to_cpsw(napi_tx);
790 int num_tx; 788 int num_tx;
791 struct cpsw_common *cpsw = priv->cpsw;
792 789
793 num_tx = cpdma_chan_process(cpsw->txch, budget); 790 num_tx = cpdma_chan_process(cpsw->txch, budget);
794 if (num_tx < budget) { 791 if (num_tx < budget) {
@@ -805,9 +802,8 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
805 802
806static int cpsw_rx_poll(struct napi_struct *napi_rx, int budget) 803static int cpsw_rx_poll(struct napi_struct *napi_rx, int budget)
807{ 804{
808 struct cpsw_priv *priv = napi_to_priv(napi_rx); 805 struct cpsw_common *cpsw = napi_to_cpsw(napi_rx);
809 int num_rx; 806 int num_rx;
810 struct cpsw_common *cpsw = priv->cpsw;
811 807
812 num_rx = cpdma_chan_process(cpsw->rxch, budget); 808 num_rx = cpdma_chan_process(cpsw->rxch, budget);
813 if (num_rx < budget) { 809 if (num_rx < budget) {
@@ -1283,7 +1279,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
1283 ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); 1279 ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);
1284 1280
1285 if (!cpsw_common_res_usage_state(cpsw)) { 1281 if (!cpsw_common_res_usage_state(cpsw)) {
1286 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(cpsw, 0);
1287 int buf_num; 1282 int buf_num;
1288 1283
1289 /* setup tx dma to fixed prio and zero offset */ 1284 /* setup tx dma to fixed prio and zero offset */
@@ -1299,8 +1294,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
1299 /* Enable internal fifo flow control */ 1294 /* Enable internal fifo flow control */
1300 writel(0x7, &cpsw->regs->flow_control); 1295 writel(0x7, &cpsw->regs->flow_control);
1301 1296
1302 napi_enable(&priv_sl0->napi_rx); 1297 napi_enable(&cpsw->napi_rx);
1303 napi_enable(&priv_sl0->napi_tx); 1298 napi_enable(&cpsw->napi_tx);
1304 1299
1305 if (cpsw->tx_irq_disabled) { 1300 if (cpsw->tx_irq_disabled) {
1306 cpsw->tx_irq_disabled = false; 1301 cpsw->tx_irq_disabled = false;
@@ -1373,10 +1368,8 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1373 netif_carrier_off(priv->ndev); 1368 netif_carrier_off(priv->ndev);
1374 1369
1375 if (cpsw_common_res_usage_state(cpsw) <= 1) { 1370 if (cpsw_common_res_usage_state(cpsw) <= 1) {
1376 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(cpsw, 0); 1371 napi_disable(&cpsw->napi_rx);
1377 1372 napi_disable(&cpsw->napi_tx);
1378 napi_disable(&priv_sl0->napi_rx);
1379 napi_disable(&priv_sl0->napi_tx);
1380 cpts_unregister(priv->cpts); 1373 cpts_unregister(priv->cpts);
1381 cpsw_intr_disable(cpsw); 1374 cpsw_intr_disable(cpsw);
1382 cpdma_ctlr_stop(cpsw->dma); 1375 cpdma_ctlr_stop(cpsw->dma);
@@ -1656,13 +1649,12 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
1656#ifdef CONFIG_NET_POLL_CONTROLLER 1649#ifdef CONFIG_NET_POLL_CONTROLLER
1657static void cpsw_ndo_poll_controller(struct net_device *ndev) 1650static void cpsw_ndo_poll_controller(struct net_device *ndev)
1658{ 1651{
1659 struct cpsw_priv *priv = netdev_priv(ndev); 1652 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1660 struct cpsw_common *cpsw = priv->cpsw;
1661 1653
1662 cpsw_intr_disable(priv->cpsw); 1654 cpsw_intr_disable(cpsw);
1663 cpsw_rx_interrupt(cpsw->irqs_table[0], priv); 1655 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw);
1664 cpsw_tx_interrupt(cpsw->irqs_table[1], priv); 1656 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw);
1665 cpsw_intr_enable(priv->cpsw); 1657 cpsw_intr_enable(cpsw);
1666} 1658}
1667#endif 1659#endif
1668 1660
@@ -2512,7 +2504,7 @@ static int cpsw_probe(struct platform_device *pdev)
2512 2504
2513 cpsw->irqs_table[0] = irq; 2505 cpsw->irqs_table[0] = irq;
2514 ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt, 2506 ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt,
2515 0, dev_name(&pdev->dev), priv); 2507 0, dev_name(&pdev->dev), cpsw);
2516 if (ret < 0) { 2508 if (ret < 0) {
2517 dev_err(priv->dev, "error attaching irq (%d)\n", ret); 2509 dev_err(priv->dev, "error attaching irq (%d)\n", ret);
2518 goto clean_ale_ret; 2510 goto clean_ale_ret;
@@ -2527,7 +2519,7 @@ static int cpsw_probe(struct platform_device *pdev)
2527 2519
2528 cpsw->irqs_table[1] = irq; 2520 cpsw->irqs_table[1] = irq;
2529 ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt, 2521 ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt,
2530 0, dev_name(&pdev->dev), priv); 2522 0, dev_name(&pdev->dev), cpsw);
2531 if (ret < 0) { 2523 if (ret < 0) {
2532 dev_err(priv->dev, "error attaching irq (%d)\n", ret); 2524 dev_err(priv->dev, "error attaching irq (%d)\n", ret);
2533 goto clean_ale_ret; 2525 goto clean_ale_ret;
@@ -2537,8 +2529,8 @@ static int cpsw_probe(struct platform_device *pdev)
2537 2529
2538 ndev->netdev_ops = &cpsw_netdev_ops; 2530 ndev->netdev_ops = &cpsw_netdev_ops;
2539 ndev->ethtool_ops = &cpsw_ethtool_ops; 2531 ndev->ethtool_ops = &cpsw_ethtool_ops;
2540 netif_napi_add(ndev, &priv->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT); 2532 netif_napi_add(ndev, &cpsw->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT);
2541 netif_tx_napi_add(ndev, &priv->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT); 2533 netif_tx_napi_add(ndev, &cpsw->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT);
2542 2534
2543 /* register the network device */ 2535 /* register the network device */
2544 SET_NETDEV_DEV(ndev, &pdev->dev); 2536 SET_NETDEV_DEV(ndev, &pdev->dev);