Lines Matching defs:cpsw
41 #include "cpsw.h"
52 MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)");
56 MODULE_PARM_DESC(ale_ageout, "cpsw ale ageout interval (seconds)");
69 struct cpsw_common *cpsw = (priv)->cpsw; \
71 if (cpsw->data.dual_emac) \
72 (func)((cpsw)->slaves + priv->emac_port, ##arg);\
74 for (n = cpsw->data.slaves, \
75 slave = cpsw->slaves; \
80 static int cpsw_slave_index_priv(struct cpsw_common *cpsw,
83 return cpsw->data.dual_emac ? priv->emac_port : cpsw->data.active_slave;
96 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
97 struct cpsw_ale *ale = cpsw->ale;
100 if (cpsw->data.dual_emac) {
107 for (i = 0; i < cpsw->data.slaves; i++)
108 if (cpsw->slaves[i].ndev->flags & IFF_PROMISC)
131 for (i = 0; i <= cpsw->data.slaves; i++) {
159 for (i = 0; i <= cpsw->data.slaves; i++) {
182 struct cpsw_common *cpsw = priv->cpsw;
186 if (cpsw->data.dual_emac)
187 vid = cpsw->slaves[priv->emac_port].port_vlan;
192 mask = cpsw->data.dual_emac ? ALE_PORT_HOST : ALE_ALL_PORTS;
196 ret = cpsw_ale_add_mcast(cpsw->ale, addr, mask, flags, vid, 0);
198 ret = cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid);
311 struct cpsw_common *cpsw = priv->cpsw;
314 if (cpsw->data.dual_emac)
320 cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI, slave_port);
328 cpsw_ale_set_allmulti(cpsw->ale,
349 struct cpsw_common *cpsw = ndev_to_cpsw(xmeta->ndev);
350 int pkt_size = cpsw->rx_packet_max;
360 if (cpsw->data.dual_emac && status >= 0) {
363 ndev = cpsw->slaves[--port].ndev;
367 pool = cpsw->page_pool[ch];
370 if (cpsw->data.dual_emac && cpsw->usage_count &&
405 port = priv->emac_port + cpsw->data.dual_emac;
430 cpts_rx_timestamp(cpsw->cpts, skb);
446 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma,
460 struct cpsw_common *cpsw = priv->cpsw;
492 cpsw_ale_control_set(cpsw->ale, slave_port,
505 cpsw_ale_control_set(cpsw->ale, slave_port,
522 struct cpsw_common *cpsw = priv->cpsw;
528 if (cpsw_need_resplit(cpsw))
529 cpsw_split_res(cpsw);
544 struct cpsw_common *cpsw = priv->cpsw;
547 if (cpsw->version == CPSW_VERSION_1)
551 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask,
553 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
555 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
558 cpsw_ale_control_set(cpsw->ale, slave_port,
566 struct cpsw_common *cpsw = priv->cpsw;
575 switch (cpsw->version) {
600 cpsw->rx_packet_max);
607 if (cpsw->data.dual_emac)
610 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
647 cpsw_phy_sel(cpsw->dev, slave->phy->interface,
653 struct cpsw_common *cpsw = priv->cpsw;
654 const int vlan = cpsw->data.default_vlan;
659 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
662 writel(vlan, &cpsw->host_port_regs->port_vlan);
664 for (i = 0; i < cpsw->data.slaves; i++)
665 slave_write(cpsw->slaves + i, vlan, reg);
672 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS,
681 struct cpsw_common *cpsw = priv->cpsw;
684 soft_reset("cpsw", &cpsw->regs->soft_reset);
685 cpsw_ale_start(cpsw->ale);
688 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE,
690 control_reg = readl(&cpsw->regs->control);
692 writel(control_reg, &cpsw->regs->control);
693 fifo_mode = (cpsw->data.dual_emac) ? CPSW_FIFO_DUAL_MAC_MODE :
695 writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl);
699 &cpsw->host_port_regs->cpdma_tx_pri_map);
700 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map);
702 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
705 if (!cpsw->data.dual_emac) {
706 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
708 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
713 static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw)
724 cpsw_ale_control_set(cpsw->ale, slave_port,
757 struct cpsw_common *cpsw = priv->cpsw;
761 ret = pm_runtime_resume_and_get(cpsw->dev);
768 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num);
774 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num);
780 reg = cpsw->version;
782 dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n",
787 if (!cpsw->usage_count)
792 if (!cpsw->data.dual_emac)
795 cpsw_ale_add_vlan(cpsw->ale, cpsw->data.default_vlan,
799 if (!cpsw->usage_count) {
801 writel_relaxed(0, &cpsw->regs->ptype);
804 writel_relaxed(0x7, &cpsw->regs->stat_port_en);
807 writel(0x7, &cpsw->regs->flow_control);
809 napi_enable(&cpsw->napi_rx);
810 napi_enable(&cpsw->napi_tx);
812 if (cpsw->tx_irq_disabled) {
813 cpsw->tx_irq_disabled = false;
814 enable_irq(cpsw->irqs_table[1]);
817 if (cpsw->rx_irq_disabled) {
818 cpsw->rx_irq_disabled = false;
819 enable_irq(cpsw->irqs_table[0]);
825 ret = cpsw_create_xdp_rxqs(cpsw);
833 if (cpsw->cpts) {
834 if (cpts_register(cpsw->cpts))
837 writel(0x10, &cpsw->wr_regs->misc_en);
844 if (cpsw->coal_intvl != 0) {
847 coal.rx_coalesce_usecs = cpsw->coal_intvl;
851 cpdma_ctlr_start(cpsw->dma);
852 cpsw_intr_enable(cpsw);
853 cpsw->usage_count++;
858 if (!cpsw->usage_count) {
859 napi_disable(&cpsw->napi_rx);
860 napi_disable(&cpsw->napi_tx);
861 cpdma_ctlr_stop(cpsw->dma);
862 cpsw_destroy_xdp_rxqs(cpsw);
865 for_each_slave(priv, cpsw_slave_stop, cpsw);
866 pm_runtime_put_sync(cpsw->dev);
874 struct cpsw_common *cpsw = priv->cpsw;
876 cpsw_info(priv, ifdown, "shutting down cpsw device\n");
881 if (cpsw->usage_count <= 1) {
882 napi_disable(&cpsw->napi_rx);
883 napi_disable(&cpsw->napi_tx);
884 cpts_unregister(cpsw->cpts);
885 cpsw_intr_disable(cpsw);
886 cpdma_ctlr_stop(cpsw->dma);
887 cpsw_ale_stop(cpsw->ale);
888 cpsw_destroy_xdp_rxqs(cpsw);
890 for_each_slave(priv, cpsw_slave_stop, cpsw);
892 if (cpsw_need_resplit(cpsw))
893 cpsw_split_res(cpsw);
895 cpsw->usage_count--;
896 pm_runtime_put_sync(cpsw->dev);
904 struct cpsw_common *cpsw = priv->cpsw;
905 struct cpts *cpts = cpsw->cpts;
921 if (q_idx >= cpsw->tx_ch_num)
922 q_idx = q_idx % cpsw->tx_ch_num;
924 txch = cpsw->txv[q_idx].ch;
928 priv->emac_port + cpsw->data.dual_emac);
965 struct cpsw_common *cpsw = priv->cpsw;
973 ret = pm_runtime_resume_and_get(cpsw->dev);
977 if (cpsw->data.dual_emac) {
978 vid = cpsw->slaves[priv->emac_port].port_vlan;
982 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
984 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM,
991 pm_runtime_put(cpsw->dev);
1003 struct cpsw_common *cpsw = priv->cpsw;
1005 if (cpsw->data.dual_emac) {
1021 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask,
1026 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
1031 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
1038 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1041 cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1049 struct cpsw_common *cpsw = priv->cpsw;
1052 if (vid == cpsw->data.default_vlan)
1055 ret = pm_runtime_resume_and_get(cpsw->dev);
1059 if (cpsw->data.dual_emac) {
1066 for (i = 0; i < cpsw->data.slaves; i++) {
1067 if (vid == cpsw->slaves[i].port_vlan) {
1077 pm_runtime_put(cpsw->dev);
1085 struct cpsw_common *cpsw = priv->cpsw;
1088 if (vid == cpsw->data.default_vlan)
1091 ret = pm_runtime_resume_and_get(cpsw->dev);
1095 if (cpsw->data.dual_emac) {
1098 for (i = 0; i < cpsw->data.slaves; i++) {
1099 if (vid == cpsw->slaves[i].port_vlan)
1105 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1106 ret |= cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1108 ret |= cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
1110 ret |= cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid);
1112 pm_runtime_put(cpsw->dev);
1120 struct cpsw_common *cpsw = priv->cpsw;
1132 port = priv->emac_port + cpsw->data.dual_emac;
1144 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1146 cpsw_intr_disable(cpsw);
1147 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw);
1148 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw);
1149 cpsw_intr_enable(cpsw);
1176 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1177 struct platform_device *pdev = to_platform_device(cpsw->dev);
1179 strscpy(info->driver, "cpsw", sizeof(info->driver));
1400 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1401 struct cpsw_platform_data *data = &cpsw->data;
1429 struct cpsw_common *cpsw = priv->cpsw;
1430 struct cpsw_platform_data *data = &cpsw->data;
1435 ndev = devm_alloc_etherdev_mqs(cpsw->dev, sizeof(struct cpsw_priv),
1438 dev_err(cpsw->dev, "cpsw: error allocating net_device\n");
1443 priv_sl2->cpsw = cpsw;
1451 dev_info(cpsw->dev, "cpsw: Detected MACID = %pM\n",
1455 dev_info(cpsw->dev, "cpsw: Random MACID = %pM\n",
1461 cpsw->slaves[1].ndev = ndev;
1470 SET_NETDEV_DEV(ndev, cpsw->dev);
1471 ndev->dev.of_node = cpsw->slaves[1].data->slave_node;
1474 dev_err(cpsw->dev, "cpsw: error registering net device\n");
1480 { .compatible = "ti,cpsw"},
1481 { .compatible = "ti,am335x-cpsw"},
1482 { .compatible = "ti,am4372-cpsw"},
1483 { .compatible = "ti,dra7-cpsw"},
1504 struct cpsw_common *cpsw;
1508 cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL);
1509 if (!cpsw)
1512 platform_set_drvdata(pdev, cpsw);
1515 cpsw->dev = dev;
1530 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000;
1535 cpsw->regs = ss_regs;
1537 cpsw->wr_regs = devm_platform_ioremap_resource(pdev, 1);
1538 if (IS_ERR(cpsw->wr_regs))
1539 return PTR_ERR(cpsw->wr_regs);
1545 cpsw->irqs_table[0] = irq;
1551 cpsw->irqs_table[1] = irq;
1557 cpsw->misc_irq = irq;
1571 ret = cpsw_probe_dt(&cpsw->data, pdev);
1577 cpsw->quirk_irq = true;
1579 data = &cpsw->data;
1580 cpsw->slaves = devm_kcalloc(dev,
1583 if (!cpsw->slaves) {
1588 cpsw->rx_packet_max = max(rx_packet_max, CPSW_MAX_PACKET_SIZE);
1589 cpsw->descs_pool_size = descs_pool_size;
1591 ret = cpsw_init_common(cpsw, ss_regs, ale_ageout,
1597 ch = cpsw->quirk_irq ? 0 : 7;
1598 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0);
1599 if (IS_ERR(cpsw->txv[0].ch)) {
1601 ret = PTR_ERR(cpsw->txv[0].ch);
1605 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
1606 if (IS_ERR(cpsw->rxv[0].ch)) {
1608 ret = PTR_ERR(cpsw->rxv[0].ch);
1611 cpsw_split_res(cpsw);
1623 priv->cpsw = cpsw;
1639 cpsw->slaves[0].ndev = ndev;
1647 netif_napi_add(ndev, &cpsw->napi_rx,
1648 cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll);
1649 netif_napi_add_tx(ndev, &cpsw->napi_tx,
1650 cpsw->quirk_irq ? cpsw_tx_poll : cpsw_tx_mq_poll);
1654 ndev->dev.of_node = cpsw->slaves[0].data->slave_node;
1662 if (cpsw->data.dual_emac) {
1677 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt,
1678 0, dev_name(dev), cpsw);
1685 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt,
1686 0, dev_name(&pdev->dev), cpsw);
1692 if (!cpsw->cpts)
1695 ret = devm_request_irq(&pdev->dev, cpsw->misc_irq, cpsw_misc_interrupt,
1696 0, dev_name(&pdev->dev), cpsw);
1703 cpts_set_irqpoll(cpsw->cpts, false);
1708 &ss_res->start, cpsw->irqs_table[0], descs_pool_size);
1717 cpts_release(cpsw->cpts);
1718 cpdma_ctlr_destroy(cpsw->dma);
1729 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1736 for (i = 0; i < cpsw->data.slaves; i++)
1737 if (cpsw->slaves[i].ndev)
1738 unregister_netdev(cpsw->slaves[i].ndev);
1740 cpts_release(cpsw->cpts);
1741 cpdma_ctlr_destroy(cpsw->dma);
1751 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1756 for (i = 0; i < cpsw->data.slaves; i++)
1757 if (cpsw->slaves[i].ndev)
1758 if (netif_running(cpsw->slaves[i].ndev))
1759 cpsw_ndo_stop(cpsw->slaves[i].ndev);
1771 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1780 for (i = 0; i < cpsw->data.slaves; i++)
1781 if (cpsw->slaves[i].ndev)
1782 if (netif_running(cpsw->slaves[i].ndev))
1783 cpsw_ndo_open(cpsw->slaves[i].ndev);
1795 .name = "cpsw",