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 &&
411 port = priv->emac_port + cpsw->data.dual_emac;
438 cpts_rx_timestamp(cpsw->cpts, skb);
454 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma,
468 struct cpsw_common *cpsw = priv->cpsw;
500 cpsw_ale_control_set(cpsw->ale, slave_port,
513 cpsw_ale_control_set(cpsw->ale, slave_port,
530 struct cpsw_common *cpsw = priv->cpsw;
536 if (cpsw_need_resplit(cpsw))
537 cpsw_split_res(cpsw);
552 struct cpsw_common *cpsw = priv->cpsw;
555 if (cpsw->version == CPSW_VERSION_1)
559 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask,
561 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
563 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
566 cpsw_ale_control_set(cpsw->ale, slave_port,
574 struct cpsw_common *cpsw = priv->cpsw;
583 switch (cpsw->version) {
608 cpsw->rx_packet_max);
615 if (cpsw->data.dual_emac)
618 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
653 cpsw_phy_sel(cpsw->dev, slave->phy->interface,
659 struct cpsw_common *cpsw = priv->cpsw;
660 const int vlan = cpsw->data.default_vlan;
665 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
668 writel(vlan, &cpsw->host_port_regs->port_vlan);
670 for (i = 0; i < cpsw->data.slaves; i++)
671 slave_write(cpsw->slaves + i, vlan, reg);
678 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS,
687 struct cpsw_common *cpsw = priv->cpsw;
690 soft_reset("cpsw", &cpsw->regs->soft_reset);
691 cpsw_ale_start(cpsw->ale);
694 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE,
696 control_reg = readl(&cpsw->regs->control);
698 writel(control_reg, &cpsw->regs->control);
699 fifo_mode = (cpsw->data.dual_emac) ? CPSW_FIFO_DUAL_MAC_MODE :
701 writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl);
705 &cpsw->host_port_regs->cpdma_tx_pri_map);
706 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map);
708 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
711 if (!cpsw->data.dual_emac) {
712 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
714 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
719 static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw)
730 cpsw_ale_control_set(cpsw->ale, slave_port,
763 struct cpsw_common *cpsw = priv->cpsw;
767 ret = pm_runtime_get_sync(cpsw->dev);
769 pm_runtime_put_noidle(cpsw->dev);
776 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num);
782 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num);
788 reg = cpsw->version;
790 dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n",
795 if (!cpsw->usage_count)
800 if (!cpsw->data.dual_emac)
803 cpsw_ale_add_vlan(cpsw->ale, cpsw->data.default_vlan,
807 if (!cpsw->usage_count) {
809 writel_relaxed(0, &cpsw->regs->ptype);
812 writel_relaxed(0x7, &cpsw->regs->stat_port_en);
815 writel(0x7, &cpsw->regs->flow_control);
817 napi_enable(&cpsw->napi_rx);
818 napi_enable(&cpsw->napi_tx);
820 if (cpsw->tx_irq_disabled) {
821 cpsw->tx_irq_disabled = false;
822 enable_irq(cpsw->irqs_table[1]);
825 if (cpsw->rx_irq_disabled) {
826 cpsw->rx_irq_disabled = false;
827 enable_irq(cpsw->irqs_table[0]);
833 ret = cpsw_create_xdp_rxqs(cpsw);
841 if (cpsw->cpts) {
842 if (cpts_register(cpsw->cpts))
845 writel(0x10, &cpsw->wr_regs->misc_en);
852 if (cpsw->coal_intvl != 0) {
855 coal.rx_coalesce_usecs = cpsw->coal_intvl;
859 cpdma_ctlr_start(cpsw->dma);
860 cpsw_intr_enable(cpsw);
861 cpsw->usage_count++;
866 if (!cpsw->usage_count) {
867 napi_disable(&cpsw->napi_rx);
868 napi_disable(&cpsw->napi_tx);
869 cpdma_ctlr_stop(cpsw->dma);
870 cpsw_destroy_xdp_rxqs(cpsw);
873 for_each_slave(priv, cpsw_slave_stop, cpsw);
874 pm_runtime_put_sync(cpsw->dev);
882 struct cpsw_common *cpsw = priv->cpsw;
884 cpsw_info(priv, ifdown, "shutting down cpsw device\n");
889 if (cpsw->usage_count <= 1) {
890 napi_disable(&cpsw->napi_rx);
891 napi_disable(&cpsw->napi_tx);
892 cpts_unregister(cpsw->cpts);
893 cpsw_intr_disable(cpsw);
894 cpdma_ctlr_stop(cpsw->dma);
895 cpsw_ale_stop(cpsw->ale);
896 cpsw_destroy_xdp_rxqs(cpsw);
898 for_each_slave(priv, cpsw_slave_stop, cpsw);
900 if (cpsw_need_resplit(cpsw))
901 cpsw_split_res(cpsw);
903 cpsw->usage_count--;
904 pm_runtime_put_sync(cpsw->dev);
912 struct cpsw_common *cpsw = priv->cpsw;
913 struct cpts *cpts = cpsw->cpts;
929 if (q_idx >= cpsw->tx_ch_num)
930 q_idx = q_idx % cpsw->tx_ch_num;
932 txch = cpsw->txv[q_idx].ch;
936 priv->emac_port + cpsw->data.dual_emac);
973 struct cpsw_common *cpsw = priv->cpsw;
981 ret = pm_runtime_get_sync(cpsw->dev);
983 pm_runtime_put_noidle(cpsw->dev);
987 if (cpsw->data.dual_emac) {
988 vid = cpsw->slaves[priv->emac_port].port_vlan;
992 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
994 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM,
1001 pm_runtime_put(cpsw->dev);
1013 struct cpsw_common *cpsw = priv->cpsw;
1015 if (cpsw->data.dual_emac) {
1031 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask,
1036 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
1041 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
1048 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1051 cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1059 struct cpsw_common *cpsw = priv->cpsw;
1062 if (vid == cpsw->data.default_vlan)
1065 ret = pm_runtime_get_sync(cpsw->dev);
1067 pm_runtime_put_noidle(cpsw->dev);
1071 if (cpsw->data.dual_emac) {
1078 for (i = 0; i < cpsw->data.slaves; i++) {
1079 if (vid == cpsw->slaves[i].port_vlan) {
1089 pm_runtime_put(cpsw->dev);
1097 struct cpsw_common *cpsw = priv->cpsw;
1100 if (vid == cpsw->data.default_vlan)
1103 ret = pm_runtime_get_sync(cpsw->dev);
1105 pm_runtime_put_noidle(cpsw->dev);
1109 if (cpsw->data.dual_emac) {
1112 for (i = 0; i < cpsw->data.slaves; i++) {
1113 if (vid == cpsw->slaves[i].port_vlan)
1119 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1120 ret |= cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1122 ret |= cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
1124 ret |= cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid);
1126 pm_runtime_put(cpsw->dev);
1134 struct cpsw_common *cpsw = priv->cpsw;
1149 port = priv->emac_port + cpsw->data.dual_emac;
1160 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1162 cpsw_intr_disable(cpsw);
1163 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw);
1164 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw);
1165 cpsw_intr_enable(cpsw);
1192 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1193 struct platform_device *pdev = to_platform_device(cpsw->dev);
1195 strlcpy(info->driver, "cpsw", sizeof(info->driver));
1420 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1421 struct cpsw_platform_data *data = &cpsw->data;
1449 struct cpsw_common *cpsw = priv->cpsw;
1450 struct cpsw_platform_data *data = &cpsw->data;
1455 ndev = devm_alloc_etherdev_mqs(cpsw->dev, sizeof(struct cpsw_priv),
1458 dev_err(cpsw->dev, "cpsw: error allocating net_device\n");
1463 priv_sl2->cpsw = cpsw;
1471 dev_info(cpsw->dev, "cpsw: Detected MACID = %pM\n",
1475 dev_info(cpsw->dev, "cpsw: Random MACID = %pM\n",
1481 cpsw->slaves[1].ndev = ndev;
1488 SET_NETDEV_DEV(ndev, cpsw->dev);
1489 ndev->dev.of_node = cpsw->slaves[1].data->slave_node;
1492 dev_err(cpsw->dev, "cpsw: error registering net device\n");
1498 { .compatible = "ti,cpsw"},
1499 { .compatible = "ti,am335x-cpsw"},
1500 { .compatible = "ti,am4372-cpsw"},
1501 { .compatible = "ti,dra7-cpsw"},
1522 struct cpsw_common *cpsw;
1526 cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL);
1527 if (!cpsw)
1530 platform_set_drvdata(pdev, cpsw);
1533 cpsw->dev = dev;
1548 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000;
1554 cpsw->regs = ss_regs;
1556 cpsw->wr_regs = devm_platform_ioremap_resource(pdev, 1);
1557 if (IS_ERR(cpsw->wr_regs))
1558 return PTR_ERR(cpsw->wr_regs);
1564 cpsw->irqs_table[0] = irq;
1570 cpsw->irqs_table[1] = irq;
1576 cpsw->misc_irq = irq;
1592 ret = cpsw_probe_dt(&cpsw->data, pdev);
1598 cpsw->quirk_irq = true;
1600 data = &cpsw->data;
1601 cpsw->slaves = devm_kcalloc(dev,
1604 if (!cpsw->slaves) {
1609 cpsw->rx_packet_max = max(rx_packet_max, CPSW_MAX_PACKET_SIZE);
1610 cpsw->descs_pool_size = descs_pool_size;
1612 ret = cpsw_init_common(cpsw, ss_regs, ale_ageout,
1618 ch = cpsw->quirk_irq ? 0 : 7;
1619 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0);
1620 if (IS_ERR(cpsw->txv[0].ch)) {
1622 ret = PTR_ERR(cpsw->txv[0].ch);
1626 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
1627 if (IS_ERR(cpsw->rxv[0].ch)) {
1629 ret = PTR_ERR(cpsw->rxv[0].ch);
1632 cpsw_split_res(cpsw);
1644 priv->cpsw = cpsw;
1660 cpsw->slaves[0].ndev = ndev;
1666 netif_napi_add(ndev, &cpsw->napi_rx,
1667 cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll,
1669 netif_tx_napi_add(ndev, &cpsw->napi_tx,
1670 cpsw->quirk_irq ? cpsw_tx_poll : cpsw_tx_mq_poll,
1675 ndev->dev.of_node = cpsw->slaves[0].data->slave_node;
1683 if (cpsw->data.dual_emac) {
1698 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt,
1699 0, dev_name(dev), cpsw);
1706 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt,
1707 0, dev_name(&pdev->dev), cpsw);
1713 if (!cpsw->cpts)
1716 ret = devm_request_irq(&pdev->dev, cpsw->misc_irq, cpsw_misc_interrupt,
1717 0, dev_name(&pdev->dev), cpsw);
1724 cpts_set_irqpoll(cpsw->cpts, false);
1729 &ss_res->start, cpsw->irqs_table[0], descs_pool_size);
1738 cpts_release(cpsw->cpts);
1739 cpdma_ctlr_destroy(cpsw->dma);
1750 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1759 for (i = 0; i < cpsw->data.slaves; i++)
1760 if (cpsw->slaves[i].ndev)
1761 unregister_netdev(cpsw->slaves[i].ndev);
1763 cpts_release(cpsw->cpts);
1764 cpdma_ctlr_destroy(cpsw->dma);
1774 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1779 for (i = 0; i < cpsw->data.slaves; i++)
1780 if (cpsw->slaves[i].ndev)
1781 if (netif_running(cpsw->slaves[i].ndev))
1782 cpsw_ndo_stop(cpsw->slaves[i].ndev);
1794 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1803 for (i = 0; i < cpsw->data.slaves; i++)
1804 if (cpsw->slaves[i].ndev)
1805 if (netif_running(cpsw->slaves[i].ndev))
1806 cpsw_ndo_open(cpsw->slaves[i].ndev);
1818 .name = "cpsw",