Lines Matching +full:slave +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
67 if (priv->emac_port == HOST_PORT_NUM) in cpsw_slave_index_priv()
68 return -1; in cpsw_slave_index_priv()
70 return priv->emac_port - 1; in cpsw_slave_index_priv()
75 return !cpsw->data.dual_emac; in cpsw_is_switch_en()
87 /* Enabling promiscuous mode for one interface will be in cpsw_set_promiscious()
91 for (i = 0; i < cpsw->data.slaves; i++) in cpsw_set_promiscious()
92 if (cpsw->slaves[i].ndev && in cpsw_set_promiscious()
93 (cpsw->slaves[i].ndev->flags & IFF_PROMISC)) in cpsw_set_promiscious()
98 …dev_dbg(cpsw->dev, "promiscuity not disabled as the other interface is still in promiscuity mode\n… in cpsw_set_promiscious()
103 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
106 dev_dbg(cpsw->dev, "promiscuity enabled\n"); in cpsw_set_promiscious()
109 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
111 dev_dbg(cpsw->dev, "promiscuity disabled\n"); in cpsw_set_promiscious()
116 * cpsw_set_mc - adds multicast entry to the table if it's not added or deletes
127 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_mc()
132 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_set_mc()
138 ret = cpsw_ale_add_mcast(cpsw->ale, addr, mask, flags, vid, 0); in cpsw_set_mc()
140 ret = cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid); in cpsw_set_mc()
151 if (!vdev || !(vdev->flags & IFF_UP)) in cpsw_update_vlan_mc()
156 if (ether_addr_equal(ha->addr, sync_ctx->addr)) { in cpsw_update_vlan_mc()
157 found = ha->sync_cnt; in cpsw_update_vlan_mc()
163 sync_ctx->consumed++; in cpsw_update_vlan_mc()
165 if (sync_ctx->flush) { in cpsw_update_vlan_mc()
167 cpsw_set_mc(sync_ctx->ndev, sync_ctx->addr, vid, 0); in cpsw_update_vlan_mc()
172 ret = cpsw_set_mc(sync_ctx->ndev, sync_ctx->addr, vid, 1); in cpsw_update_vlan_mc()
189 ret = cpsw_set_mc(ndev, addr, -1, 1); in cpsw_add_mc_addr()
205 cpsw_set_mc(ndev, addr, -1, 0); in cpsw_del_mc_addr()
216 if (!vdev || !(vdev->flags & IFF_UP)) in cpsw_purge_vlan_mc()
221 if (ether_addr_equal(ha->addr, sync_ctx->addr)) { in cpsw_purge_vlan_mc()
222 found = ha->sync_cnt; in cpsw_purge_vlan_mc()
230 sync_ctx->consumed++; in cpsw_purge_vlan_mc()
231 cpsw_set_mc(sync_ctx->ndev, sync_ctx->addr, vid, 0); in cpsw_purge_vlan_mc()
245 cpsw_set_mc(ndev, addr, -1, 0); in cpsw_purge_all_mc()
253 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_rx_mode()
255 if (ndev->flags & IFF_PROMISC) { in cpsw_ndo_set_rx_mode()
256 /* Enable promiscuous mode */ in cpsw_ndo_set_rx_mode()
258 cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI, priv->emac_port); in cpsw_ndo_set_rx_mode()
262 /* Disable promiscuous mode */ in cpsw_ndo_set_rx_mode()
266 cpsw_ale_set_allmulti(cpsw->ale, in cpsw_ndo_set_rx_mode()
267 ndev->flags & IFF_ALLMULTI, priv->emac_port); in cpsw_ndo_set_rx_mode()
270 __hw_addr_ref_sync_dev(&ndev->mc, ndev, cpsw_add_mc_addr, in cpsw_ndo_set_rx_mode()
299 cpsw = ndev_to_cpsw(xmeta->ndev); in cpsw_rx_handler()
300 ndev = xmeta->ndev; in cpsw_rx_handler()
301 pkt_size = cpsw->rx_packet_max; in cpsw_rx_handler()
302 ch = xmeta->ch; in cpsw_rx_handler()
307 ndev = cpsw->slaves[--port].ndev; in cpsw_rx_handler()
311 pool = cpsw->page_pool[ch]; in cpsw_rx_handler()
314 /* In dual emac mode check for all interfaces */ in cpsw_rx_handler()
315 if (cpsw->usage_count && status >= 0) { in cpsw_rx_handler()
334 ndev->stats.rx_dropped++; in cpsw_rx_handler()
338 if (priv->xdp_prog) { in cpsw_rx_handler()
341 xdp_init_buff(&xdp, PAGE_SIZE, &priv->xdp_rxq[ch]); in cpsw_rx_handler()
344 size -= CPSW_RX_VLAN_ENCAP_HDR_SIZE; in cpsw_rx_handler()
349 ret = cpsw_run_xdp(priv, ch, &xdp, page, priv->emac_port, &len); in cpsw_rx_handler()
353 headroom = xdp.data - xdp.data_hard_start; in cpsw_rx_handler()
362 ndev->stats.rx_dropped++; in cpsw_rx_handler()
367 skb->offload_fwd_mark = priv->offload_fwd_mark; in cpsw_rx_handler()
370 skb->dev = ndev; in cpsw_rx_handler()
373 if (priv->rx_ts_enabled) in cpsw_rx_handler()
374 cpts_rx_timestamp(cpsw->cpts, skb); in cpsw_rx_handler()
375 skb->protocol = eth_type_trans(skb, ndev); in cpsw_rx_handler()
381 ndev->stats.rx_bytes += len; in cpsw_rx_handler()
382 ndev->stats.rx_packets++; in cpsw_rx_handler()
386 xmeta->ndev = ndev; in cpsw_rx_handler()
387 xmeta->ch = ch; in cpsw_rx_handler()
390 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma, in cpsw_rx_handler()
393 WARN_ON(ret == -ENOMEM); in cpsw_rx_handler()
401 struct cpsw_common *cpsw = priv->cpsw; in cpsw_add_vlan_ale_entry()
407 port_mask = (1 << priv->emac_port) | ALE_PORT_HOST; in cpsw_add_vlan_ale_entry()
410 if (priv->ndev->flags & IFF_ALLMULTI) in cpsw_add_vlan_ale_entry()
413 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask, in cpsw_add_vlan_ale_entry()
418 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
423 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_add_vlan_ale_entry()
430 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
433 cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_add_vlan_ale_entry()
441 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_add_vid()
445 dev_dbg(cpsw->dev, ".ndo_vlan_rx_add_vid called in switch mode\n"); in cpsw_ndo_vlan_rx_add_vid()
449 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_add_vid()
452 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
460 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_add_vid()
461 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_add_vid()
462 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_add_vid()
463 ret = -EINVAL; in cpsw_ndo_vlan_rx_add_vid()
468 dev_dbg(priv->dev, "Adding vlanid %d to vlan filter\n", vid); in cpsw_ndo_vlan_rx_add_vid()
471 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
482 cpsw_ndo_vlan_rx_add_vid(priv->ndev, 0, vid); in cpsw_restore_vlans()
489 struct cpsw_common *cpsw = priv->cpsw; in cpsw_restore()
492 vlan_for_each(priv->ndev, cpsw_restore_vlans, priv); in cpsw_restore()
495 cpsw_mqprio_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
498 cpsw_cbs_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
507 cpsw_ale_add_mcast(cpsw->ale, stpa, in cpsw_init_stp_ale_entry()
514 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_switch()
516 writel(CPSW_FIFO_NORMAL_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_switch()
518 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_switch()
520 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, in cpsw_init_host_port_switch()
526 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 1); in cpsw_init_host_port_switch()
527 dev_dbg(cpsw->dev, "Set P0_UNI_FLOOD\n"); in cpsw_init_host_port_switch()
528 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 0); in cpsw_init_host_port_switch()
533 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_dual_mac()
535 writel(CPSW_FIFO_DUAL_MAC_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_dual_mac()
537 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 0); in cpsw_init_host_port_dual_mac()
538 dev_dbg(cpsw->dev, "unset P0_UNI_FLOOD\n"); in cpsw_init_host_port_dual_mac()
540 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_dual_mac()
542 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); in cpsw_init_host_port_dual_mac()
543 /* learning make no sense in dual_mac mode */ in cpsw_init_host_port_dual_mac()
544 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 1); in cpsw_init_host_port_dual_mac()
549 struct cpsw_common *cpsw = priv->cpsw; in cpsw_init_host_port()
553 soft_reset("cpsw", &cpsw->regs->soft_reset); in cpsw_init_host_port()
554 cpsw_ale_start(cpsw->ale); in cpsw_init_host_port()
556 /* switch to vlan unaware mode */ in cpsw_init_host_port()
557 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE, in cpsw_init_host_port()
559 control_reg = readl(&cpsw->regs->control); in cpsw_init_host_port()
561 writel(control_reg, &cpsw->regs->control); in cpsw_init_host_port()
565 &cpsw->host_port_regs->cpdma_tx_pri_map); in cpsw_init_host_port()
566 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map); in cpsw_init_host_port()
569 writel_relaxed(0, &cpsw->regs->ptype); in cpsw_init_host_port()
572 writel_relaxed(0x7, &cpsw->regs->stat_port_en); in cpsw_init_host_port()
575 writel(0x7, &cpsw->regs->flow_control); in cpsw_init_host_port()
582 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_init_host_port()
587 struct cpsw_slave *slave) in cpsw_port_add_dual_emac_def_ale_entries() argument
589 u32 port_mask = 1 << priv->emac_port | ALE_PORT_HOST; in cpsw_port_add_dual_emac_def_ale_entries()
590 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_dual_emac_def_ale_entries()
593 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_dual_emac_def_ale_entries()
595 slave_write(slave, slave->port_vlan, reg); in cpsw_port_add_dual_emac_def_ale_entries()
597 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, in cpsw_port_add_dual_emac_def_ale_entries()
599 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_dual_emac_def_ale_entries()
600 ALE_PORT_HOST, ALE_VLAN, slave->port_vlan, in cpsw_port_add_dual_emac_def_ale_entries()
602 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_dual_emac_def_ale_entries()
604 ALE_SECURE, slave->port_vlan); in cpsw_port_add_dual_emac_def_ale_entries()
605 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
607 /* learning make no sense in dual_mac mode */ in cpsw_port_add_dual_emac_def_ale_entries()
608 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
613 struct cpsw_slave *slave) in cpsw_port_add_switch_def_ale_entries() argument
615 u32 port_mask = 1 << priv->emac_port | ALE_PORT_HOST; in cpsw_port_add_switch_def_ale_entries()
616 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_switch_def_ale_entries()
619 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
621 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
633 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
636 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_switch_def_ale_entries()
637 port_mask, ALE_VLAN, slave->port_vlan, in cpsw_port_add_switch_def_ale_entries()
639 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_switch_def_ale_entries()
640 HOST_PORT_NUM, ALE_VLAN, slave->port_vlan); in cpsw_port_add_switch_def_ale_entries()
642 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_switch_def_ale_entries()
644 slave_write(slave, slave->port_vlan, reg); in cpsw_port_add_switch_def_ale_entries()
650 struct cpsw_common *cpsw = priv->cpsw; in cpsw_adjust_link()
651 struct cpsw_slave *slave; in cpsw_adjust_link() local
655 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_adjust_link()
656 phy = slave->phy; in cpsw_adjust_link()
661 if (phy->link) { in cpsw_adjust_link()
664 if (phy->speed == 1000) in cpsw_adjust_link()
666 if (phy->duplex) in cpsw_adjust_link()
669 /* set speed_in input in case RMII mode is used in 100Mbps */ in cpsw_adjust_link()
670 if (phy->speed == 100) in cpsw_adjust_link()
672 /* in band mode only works in 10Mbps RGMII mode */ in cpsw_adjust_link()
673 else if ((phy->speed == 10) && phy_interface_is_rgmii(phy)) in cpsw_adjust_link()
674 mac_control |= CPSW_SL_CTL_EXT_EN; /* In Band mode */ in cpsw_adjust_link()
676 if (priv->rx_pause) in cpsw_adjust_link()
679 if (priv->tx_pause) in cpsw_adjust_link()
682 if (mac_control != slave->mac_control) in cpsw_adjust_link()
683 cpsw_sl_ctl_set(slave->mac_sl, mac_control); in cpsw_adjust_link()
686 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
691 if (priv->shp_cfg_speed && in cpsw_adjust_link()
692 priv->shp_cfg_speed != slave->phy->speed && in cpsw_adjust_link()
694 dev_warn(priv->dev, "Speed was changed, CBS shaper speeds are changed!"); in cpsw_adjust_link()
700 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
703 cpsw_sl_wait_for_idle(slave->mac_sl, 100); in cpsw_adjust_link()
705 cpsw_sl_ctl_reset(slave->mac_sl); in cpsw_adjust_link()
708 if (mac_control != slave->mac_control) in cpsw_adjust_link()
711 slave->mac_control = mac_control; in cpsw_adjust_link()
713 if (phy->link && cpsw_need_resplit(cpsw)) in cpsw_adjust_link()
717 static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) in cpsw_slave_open() argument
719 struct cpsw_common *cpsw = priv->cpsw; in cpsw_slave_open()
722 cpsw_sl_reset(slave->mac_sl, 100); in cpsw_slave_open()
723 cpsw_sl_ctl_reset(slave->mac_sl); in cpsw_slave_open()
726 cpsw_sl_reg_write(slave->mac_sl, CPSW_SL_RX_PRI_MAP, in cpsw_slave_open()
729 switch (cpsw->version) { in cpsw_slave_open()
731 slave_write(slave, TX_PRIORITY_MAPPING, CPSW1_TX_PRI_MAP); in cpsw_slave_open()
733 * flow control mode in cpsw_slave_open()
735 slave_write(slave, in cpsw_slave_open()
742 slave_write(slave, TX_PRIORITY_MAPPING, CPSW2_TX_PRI_MAP); in cpsw_slave_open()
744 * flow control mode in cpsw_slave_open()
746 slave_write(slave, in cpsw_slave_open()
753 cpsw_sl_reg_write(slave->mac_sl, CPSW_SL_RX_MAXLEN, in cpsw_slave_open()
754 cpsw->rx_packet_max); in cpsw_slave_open()
755 cpsw_set_slave_mac(slave, priv); in cpsw_slave_open()
757 slave->mac_control = 0; /* no link yet */ in cpsw_slave_open()
760 cpsw_port_add_switch_def_ale_entries(priv, slave); in cpsw_slave_open()
762 cpsw_port_add_dual_emac_def_ale_entries(priv, slave); in cpsw_slave_open()
764 if (!slave->data->phy_node) in cpsw_slave_open()
765 dev_err(priv->dev, "no phy found on slave %d\n", in cpsw_slave_open()
766 slave->slave_num); in cpsw_slave_open()
767 phy = of_phy_connect(priv->ndev, slave->data->phy_node, in cpsw_slave_open()
768 &cpsw_adjust_link, 0, slave->data->phy_if); in cpsw_slave_open()
770 dev_err(priv->dev, "phy \"%pOF\" not found on slave %d\n", in cpsw_slave_open()
771 slave->data->phy_node, in cpsw_slave_open()
772 slave->slave_num); in cpsw_slave_open()
775 slave->phy = phy; in cpsw_slave_open()
777 phy_attached_info(slave->phy); in cpsw_slave_open()
779 phy_start(slave->phy); in cpsw_slave_open()
782 phy_set_mode_ext(slave->data->ifphy, PHY_MODE_ETHERNET, in cpsw_slave_open()
783 slave->data->phy_if); in cpsw_slave_open()
789 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_stop()
790 struct cpsw_slave *slave; in cpsw_ndo_stop() local
793 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_ndo_stop()
794 if (slave->phy) in cpsw_ndo_stop()
795 phy_stop(slave->phy); in cpsw_ndo_stop()
797 netif_tx_stop_all_queues(priv->ndev); in cpsw_ndo_stop()
799 if (slave->phy) { in cpsw_ndo_stop()
800 phy_disconnect(slave->phy); in cpsw_ndo_stop()
801 slave->phy = NULL; in cpsw_ndo_stop()
804 __hw_addr_ref_unsync_dev(&ndev->mc, ndev, cpsw_purge_all_mc); in cpsw_ndo_stop()
806 if (cpsw->usage_count <= 1) { in cpsw_ndo_stop()
807 napi_disable(&cpsw->napi_rx); in cpsw_ndo_stop()
808 napi_disable(&cpsw->napi_tx); in cpsw_ndo_stop()
809 cpts_unregister(cpsw->cpts); in cpsw_ndo_stop()
811 cpdma_ctlr_stop(cpsw->dma); in cpsw_ndo_stop()
812 cpsw_ale_stop(cpsw->ale); in cpsw_ndo_stop()
819 cpsw->usage_count--; in cpsw_ndo_stop()
820 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_stop()
827 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_open()
830 dev_info(priv->dev, "starting ndev. mode: %s\n", in cpsw_ndo_open()
832 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_open()
837 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num); in cpsw_ndo_open()
839 dev_err(priv->dev, "cannot set real number of tx queues\n"); in cpsw_ndo_open()
843 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num); in cpsw_ndo_open()
845 dev_err(priv->dev, "cannot set real number of rx queues\n"); in cpsw_ndo_open()
849 /* Initialize host and slave ports */ in cpsw_ndo_open()
850 if (!cpsw->usage_count) in cpsw_ndo_open()
852 cpsw_slave_open(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_ndo_open()
855 if (!cpsw->usage_count) { in cpsw_ndo_open()
867 if (cpsw->cpts) { in cpsw_ndo_open()
868 if (cpts_register(cpsw->cpts)) in cpsw_ndo_open()
869 dev_err(priv->dev, "error registering cpts device\n"); in cpsw_ndo_open()
871 writel(0x10, &cpsw->wr_regs->misc_en); in cpsw_ndo_open()
874 napi_enable(&cpsw->napi_rx); in cpsw_ndo_open()
875 napi_enable(&cpsw->napi_tx); in cpsw_ndo_open()
877 if (cpsw->tx_irq_disabled) { in cpsw_ndo_open()
878 cpsw->tx_irq_disabled = false; in cpsw_ndo_open()
879 enable_irq(cpsw->irqs_table[1]); in cpsw_ndo_open()
882 if (cpsw->rx_irq_disabled) { in cpsw_ndo_open()
883 cpsw->rx_irq_disabled = false; in cpsw_ndo_open()
884 enable_irq(cpsw->irqs_table[0]); in cpsw_ndo_open()
891 if (cpsw->coal_intvl != 0) { in cpsw_ndo_open()
894 coal.rx_coalesce_usecs = cpsw->coal_intvl; in cpsw_ndo_open()
898 cpdma_ctlr_start(cpsw->dma); in cpsw_ndo_open()
900 cpsw->usage_count++; in cpsw_ndo_open()
908 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_open()
916 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_start_xmit()
917 struct cpts *cpts = cpsw->cpts; in cpsw_ndo_start_xmit()
922 if (skb_put_padto(skb, READ_ONCE(priv->tx_packet_min))) { in cpsw_ndo_start_xmit()
924 ndev->stats.tx_dropped++; in cpsw_ndo_start_xmit()
928 if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && in cpsw_ndo_start_xmit()
929 priv->tx_ts_enabled && cpts_can_timestamp(cpts, skb)) in cpsw_ndo_start_xmit()
930 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in cpsw_ndo_start_xmit()
933 if (q_idx >= cpsw->tx_ch_num) in cpsw_ndo_start_xmit()
934 q_idx = q_idx % cpsw->tx_ch_num; in cpsw_ndo_start_xmit()
936 txch = cpsw->txv[q_idx].ch; in cpsw_ndo_start_xmit()
939 ret = cpdma_chan_submit(txch, skb, skb->data, skb->len, in cpsw_ndo_start_xmit()
940 priv->emac_port); in cpsw_ndo_start_xmit()
961 ndev->stats.tx_dropped++; in cpsw_ndo_start_xmit()
977 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_mac_address()
983 if (!is_valid_ether_addr(addr->sa_data)) in cpsw_ndo_set_mac_address()
984 return -EADDRNOTAVAIL; in cpsw_ndo_set_mac_address()
986 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_set_mac_address()
990 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_ndo_set_mac_address()
993 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
995 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
998 ether_addr_copy(priv->mac_addr, addr->sa_data); in cpsw_ndo_set_mac_address()
999 eth_hw_addr_set(ndev, priv->mac_addr); in cpsw_ndo_set_mac_address()
1000 cpsw_set_slave_mac(&cpsw->slaves[slave_no], priv); in cpsw_ndo_set_mac_address()
1002 pm_runtime_put(cpsw->dev); in cpsw_ndo_set_mac_address()
1011 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_kill_vid()
1016 dev_dbg(cpsw->dev, "ndo del vlan is called in switch mode\n"); in cpsw_ndo_vlan_rx_kill_vid()
1020 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_kill_vid()
1023 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1031 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_kill_vid()
1032 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_kill_vid()
1033 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_kill_vid()
1034 ret = -EINVAL; in cpsw_ndo_vlan_rx_kill_vid()
1039 dev_dbg(priv->dev, "removing vlanid %d from vlan filter\n", vid); in cpsw_ndo_vlan_rx_kill_vid()
1040 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_ndo_vlan_rx_kill_vid()
1042 dev_err(priv->dev, "cpsw_ale_del_vlan() failed: ret %d\n", ret); in cpsw_ndo_vlan_rx_kill_vid()
1043 ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_ndo_vlan_rx_kill_vid()
1046 dev_err(priv->dev, "cpsw_ale_del_ucast() failed: ret %d\n", in cpsw_ndo_vlan_rx_kill_vid()
1048 ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_ndo_vlan_rx_kill_vid()
1051 dev_err(priv->dev, "cpsw_ale_del_mcast failed. ret %d\n", in cpsw_ndo_vlan_rx_kill_vid()
1053 cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid); in cpsw_ndo_vlan_rx_kill_vid()
1056 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1066 err = snprintf(name, len, "p%d", priv->emac_port); in cpsw_ndo_get_phys_port_name()
1069 return -EINVAL; in cpsw_ndo_get_phys_port_name()
1080 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw); in cpsw_ndo_poll_controller()
1081 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw); in cpsw_ndo_poll_controller()
1094 return -EINVAL; in cpsw_ndo_xdp_xmit()
1098 if (xdpf->len < READ_ONCE(priv->tx_packet_min)) in cpsw_ndo_xdp_xmit()
1101 if (cpsw_xdp_tx_frame(priv, xdpf, NULL, priv->emac_port)) in cpsw_ndo_xdp_xmit()
1114 ppid->id_len = sizeof(cpsw->base_mac); in cpsw_get_port_parent_id()
1115 memcpy(&ppid->id, &cpsw->base_mac, ppid->id_len); in cpsw_get_port_parent_id()
1148 pdev = to_platform_device(cpsw->dev); in cpsw_get_drvinfo()
1149 strscpy(info->driver, "cpsw-switch", sizeof(info->driver)); in cpsw_get_drvinfo()
1150 strscpy(info->version, "2.0", sizeof(info->version)); in cpsw_get_drvinfo()
1151 strscpy(info->bus_info, pdev->name, sizeof(info->bus_info)); in cpsw_get_drvinfo()
1162 if (!cpsw->slaves[slave_no].phy) in cpsw_set_pauseparam()
1163 return -EINVAL; in cpsw_set_pauseparam()
1165 if (!phy_validate_pause(cpsw->slaves[slave_no].phy, pause)) in cpsw_set_pauseparam()
1166 return -EINVAL; in cpsw_set_pauseparam()
1168 priv->rx_pause = pause->rx_pause ? true : false; in cpsw_set_pauseparam()
1169 priv->tx_pause = pause->tx_pause ? true : false; in cpsw_set_pauseparam()
1171 phy_set_asym_pause(cpsw->slaves[slave_no].phy, in cpsw_set_pauseparam()
1172 priv->rx_pause, priv->tx_pause); in cpsw_set_pauseparam()
1216 struct device_node *node = cpsw->dev->of_node, *tmp_node, *port_np; in cpsw_probe_dt()
1217 struct cpsw_platform_data *data = &cpsw->data; in cpsw_probe_dt()
1218 struct device *dev = cpsw->dev; in cpsw_probe_dt()
1223 return -EINVAL; in cpsw_probe_dt()
1225 tmp_node = of_get_child_by_name(node, "ethernet-ports"); in cpsw_probe_dt()
1227 return -ENOENT; in cpsw_probe_dt()
1228 data->slaves = of_get_child_count(tmp_node); in cpsw_probe_dt()
1229 if (data->slaves != CPSW_SLAVE_PORTS_NUM) { in cpsw_probe_dt()
1231 return -ENOENT; in cpsw_probe_dt()
1234 data->active_slave = 0; in cpsw_probe_dt()
1235 data->channels = CPSW_MAX_QUEUES; in cpsw_probe_dt()
1236 data->dual_emac = true; in cpsw_probe_dt()
1237 data->bd_ram_size = CPSW_BD_RAM_SIZE; in cpsw_probe_dt()
1238 data->mac_control = 0; in cpsw_probe_dt()
1240 data->slave_data = devm_kcalloc(dev, CPSW_SLAVE_PORTS_NUM, in cpsw_probe_dt()
1243 if (!data->slave_data) { in cpsw_probe_dt()
1245 return -ENOMEM; in cpsw_probe_dt()
1269 ret = -EINVAL; in cpsw_probe_dt()
1273 slave_data = &data->slave_data[port_id - 1]; in cpsw_probe_dt()
1275 slave_data->disabled = !of_device_is_available(port_np); in cpsw_probe_dt()
1276 if (slave_data->disabled) in cpsw_probe_dt()
1279 slave_data->slave_node = port_np; in cpsw_probe_dt()
1280 slave_data->ifphy = devm_of_phy_get(dev, port_np, NULL); in cpsw_probe_dt()
1281 if (IS_ERR(slave_data->ifphy)) { in cpsw_probe_dt()
1282 ret = PTR_ERR(slave_data->ifphy); in cpsw_probe_dt()
1291 dev_err_probe(dev, ret, "%pOF failed to register fixed-link phy\n", in cpsw_probe_dt()
1295 slave_data->phy_node = of_node_get(port_np); in cpsw_probe_dt()
1297 slave_data->phy_node = in cpsw_probe_dt()
1298 of_parse_phandle(port_np, "phy-handle", 0); in cpsw_probe_dt()
1301 if (!slave_data->phy_node) { in cpsw_probe_dt()
1303 ret = -ENODEV; in cpsw_probe_dt()
1307 ret = of_get_phy_mode(port_np, &slave_data->phy_if); in cpsw_probe_dt()
1309 dev_err(dev, "%pOF read phy-mode err %d\n", in cpsw_probe_dt()
1314 ret = of_get_mac_address(port_np, slave_data->mac_addr); in cpsw_probe_dt()
1316 ret = ti_cm_get_macid(dev, port_id - 1, in cpsw_probe_dt()
1317 slave_data->mac_addr); in cpsw_probe_dt()
1322 if (of_property_read_u32(port_np, "ti,dual-emac-pvid", in cpsw_probe_dt()
1326 slave_data->dual_emac_res_vlan = port_id; in cpsw_probe_dt()
1328 port_np, slave_data->dual_emac_res_vlan); in cpsw_probe_dt()
1330 slave_data->dual_emac_res_vlan = prop; in cpsw_probe_dt()
1345 struct cpsw_platform_data *data = &cpsw->data; in cpsw_remove_dt()
1348 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_remove_dt()
1349 struct cpsw_slave_data *slave_data = &data->slave_data[i]; in cpsw_remove_dt()
1350 struct device_node *port_np = slave_data->phy_node; in cpsw_remove_dt()
1363 struct cpsw_platform_data *data = &cpsw->data; in cpsw_create_ports()
1365 struct device *dev = cpsw->dev; in cpsw_create_ports()
1369 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_create_ports()
1370 struct cpsw_slave_data *slave_data = &data->slave_data[i]; in cpsw_create_ports()
1372 if (slave_data->disabled) in cpsw_create_ports()
1380 return -ENOMEM; in cpsw_create_ports()
1384 priv->cpsw = cpsw; in cpsw_create_ports()
1385 priv->ndev = ndev; in cpsw_create_ports()
1386 priv->dev = dev; in cpsw_create_ports()
1387 priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); in cpsw_create_ports()
1388 priv->emac_port = i + 1; in cpsw_create_ports()
1389 priv->tx_packet_min = CPSW_MIN_PACKET_SIZE; in cpsw_create_ports()
1391 if (is_valid_ether_addr(slave_data->mac_addr)) { in cpsw_create_ports()
1392 ether_addr_copy(priv->mac_addr, slave_data->mac_addr); in cpsw_create_ports()
1393 dev_info(cpsw->dev, "Detected MACID = %pM\n", in cpsw_create_ports()
1394 priv->mac_addr); in cpsw_create_ports()
1396 eth_random_addr(slave_data->mac_addr); in cpsw_create_ports()
1397 dev_info(cpsw->dev, "Random MACID = %pM\n", in cpsw_create_ports()
1398 priv->mac_addr); in cpsw_create_ports()
1400 eth_hw_addr_set(ndev, slave_data->mac_addr); in cpsw_create_ports()
1401 ether_addr_copy(priv->mac_addr, slave_data->mac_addr); in cpsw_create_ports()
1403 cpsw->slaves[i].ndev = ndev; in cpsw_create_ports()
1405 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | in cpsw_create_ports()
1408 ndev->netdev_ops = &cpsw_netdev_ops; in cpsw_create_ports()
1409 ndev->ethtool_ops = &cpsw_ethtool_ops; in cpsw_create_ports()
1418 netif_napi_add(ndev, &cpsw->napi_rx, in cpsw_create_ports()
1419 cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll); in cpsw_create_ports()
1420 netif_napi_add_tx(ndev, &cpsw->napi_tx, in cpsw_create_ports()
1421 cpsw->quirk_irq ? in cpsw_create_ports()
1435 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_unregister_ports()
1436 if (!cpsw->slaves[i].ndev) in cpsw_unregister_ports()
1439 unregister_netdev(cpsw->slaves[i].ndev); in cpsw_unregister_ports()
1447 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_register_ports()
1448 if (!cpsw->slaves[i].ndev) in cpsw_register_ports()
1452 ret = register_netdev(cpsw->slaves[i].ndev); in cpsw_register_ports()
1454 dev_err(cpsw->dev, in cpsw_register_ports()
1456 cpsw->slaves[i].ndev = NULL; in cpsw_register_ports()
1468 if (ndev->netdev_ops == &cpsw_netdev_ops) { in cpsw_port_dev_check()
1471 return !cpsw->data.dual_emac; in cpsw_port_dev_check()
1482 if (!cpsw->ale_bypass && in cpsw_port_offload_fwd_mark_update()
1483 (cpsw->br_members == (ALE_PORT_1 | ALE_PORT_2))) in cpsw_port_offload_fwd_mark_update()
1486 dev_dbg(cpsw->dev, "set offload_fwd_mark %d\n", set_val); in cpsw_port_offload_fwd_mark_update()
1488 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_port_offload_fwd_mark_update()
1489 struct net_device *sl_ndev = cpsw->slaves[i].ndev; in cpsw_port_offload_fwd_mark_update()
1492 priv->offload_fwd_mark = set_val; in cpsw_port_offload_fwd_mark_update()
1501 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_link()
1504 if (!cpsw->br_members) { in cpsw_netdevice_port_link()
1505 cpsw->hw_bridge_dev = br_ndev; in cpsw_netdevice_port_link()
1510 if (cpsw->hw_bridge_dev != br_ndev) in cpsw_netdevice_port_link()
1511 return -EOPNOTSUPP; in cpsw_netdevice_port_link()
1519 cpsw->br_members |= BIT(priv->emac_port); in cpsw_netdevice_port_link()
1529 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_unlink()
1533 cpsw->br_members &= ~BIT(priv->emac_port); in cpsw_netdevice_port_unlink()
1537 if (!cpsw->br_members) in cpsw_netdevice_port_unlink()
1538 cpsw->hw_bridge_dev = NULL; in cpsw_netdevice_port_unlink()
1557 if (netif_is_bridge_master(info->upper_dev)) { in cpsw_netdevice_event()
1558 if (info->linking) in cpsw_netdevice_event()
1560 info->upper_dev, in cpsw_netdevice_event()
1583 dev_err(cpsw->dev, "can't register netdevice notifier\n"); in cpsw_register_notifiers()
1607 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_get()
1609 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_get()
1612 return -EOPNOTSUPP; in cpsw_dl_switch_mode_get()
1614 ctx->val.vbool = !cpsw->data.dual_emac; in cpsw_dl_switch_mode_get()
1623 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_set()
1624 int vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1625 bool switch_en = ctx->val.vbool; in cpsw_dl_switch_mode_set()
1629 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_set()
1632 return -EOPNOTSUPP; in cpsw_dl_switch_mode_set()
1634 if (switch_en == !cpsw->data.dual_emac) in cpsw_dl_switch_mode_set()
1637 if (!switch_en && cpsw->br_members) { in cpsw_dl_switch_mode_set()
1638 dev_err(cpsw->dev, "Remove ports from BR before disabling switch mode\n"); in cpsw_dl_switch_mode_set()
1639 return -EINVAL; in cpsw_dl_switch_mode_set()
1644 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1645 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set() local
1646 struct net_device *sl_ndev = slave->ndev; in cpsw_dl_switch_mode_set()
1656 cpsw->data.dual_emac = !switch_en; in cpsw_dl_switch_mode_set()
1657 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1658 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set() local
1659 struct net_device *sl_ndev = slave->ndev; in cpsw_dl_switch_mode_set()
1665 vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1667 vlan = slave->data->dual_emac_res_vlan; in cpsw_dl_switch_mode_set()
1668 slave->port_vlan = vlan; in cpsw_dl_switch_mode_set()
1674 dev_info(cpsw->dev, "Enable switch mode\n"); in cpsw_dl_switch_mode_set()
1676 /* enable bypass - no forwarding; all traffic goes to Host */ in cpsw_dl_switch_mode_set()
1677 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1680 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1681 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1685 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1686 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set() local
1687 struct net_device *sl_ndev = slave->ndev; in cpsw_dl_switch_mode_set()
1694 slave->port_vlan = vlan; in cpsw_dl_switch_mode_set()
1695 WRITE_ONCE(priv->tx_packet_min, CPSW_MIN_PACKET_SIZE_VLAN); in cpsw_dl_switch_mode_set()
1698 slave); in cpsw_dl_switch_mode_set()
1701 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1702 cpsw->data.dual_emac = false; in cpsw_dl_switch_mode_set()
1704 dev_info(cpsw->dev, "Disable switch mode\n"); in cpsw_dl_switch_mode_set()
1706 /* enable bypass - no forwarding; all traffic goes to Host */ in cpsw_dl_switch_mode_set()
1707 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1709 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1710 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1714 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1715 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set() local
1716 struct net_device *sl_ndev = slave->ndev; in cpsw_dl_switch_mode_set()
1722 priv = netdev_priv(slave->ndev); in cpsw_dl_switch_mode_set()
1723 slave->port_vlan = slave->data->dual_emac_res_vlan; in cpsw_dl_switch_mode_set()
1724 WRITE_ONCE(priv->tx_packet_min, CPSW_MIN_PACKET_SIZE); in cpsw_dl_switch_mode_set()
1725 cpsw_port_add_dual_emac_def_ale_entries(priv, slave); in cpsw_dl_switch_mode_set()
1728 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1729 cpsw->data.dual_emac = true; in cpsw_dl_switch_mode_set()
1741 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_get()
1743 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_get()
1747 ctx->val.vbool = cpsw_ale_control_get(cpsw->ale, 0, ALE_BYPASS); in cpsw_dl_ale_ctrl_get()
1750 return -EOPNOTSUPP; in cpsw_dl_ale_ctrl_get()
1760 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_set()
1761 int ret = -EOPNOTSUPP; in cpsw_dl_ale_ctrl_set()
1763 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_set()
1767 ret = cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, in cpsw_dl_ale_ctrl_set()
1768 ctx->val.vbool); in cpsw_dl_ale_ctrl_set()
1770 cpsw->ale_bypass = ctx->val.vbool; in cpsw_dl_ale_ctrl_set()
1775 return -EOPNOTSUPP; in cpsw_dl_ale_ctrl_set()
1795 struct device *dev = cpsw->dev; in cpsw_register_devlink()
1799 cpsw->devlink = devlink_alloc(&cpsw_devlink_ops, sizeof(*dl_priv), dev); in cpsw_register_devlink()
1800 if (!cpsw->devlink) in cpsw_register_devlink()
1801 return -ENOMEM; in cpsw_register_devlink()
1803 dl_priv = devlink_priv(cpsw->devlink); in cpsw_register_devlink()
1804 dl_priv->cpsw = cpsw; in cpsw_register_devlink()
1806 ret = devlink_params_register(cpsw->devlink, cpsw_devlink_params, in cpsw_register_devlink()
1813 devlink_register(cpsw->devlink); in cpsw_register_devlink()
1817 devlink_free(cpsw->devlink); in cpsw_register_devlink()
1823 devlink_unregister(cpsw->devlink); in cpsw_unregister_devlink()
1824 devlink_params_unregister(cpsw->devlink, cpsw_devlink_params, in cpsw_unregister_devlink()
1826 devlink_free(cpsw->devlink); in cpsw_unregister_devlink()
1830 { .compatible = "ti,cpsw-switch"},
1831 { .compatible = "ti,am335x-cpsw-switch"},
1832 { .compatible = "ti,am4372-cpsw-switch"},
1833 { .compatible = "ti,dra7-cpsw-switch"},
1846 struct device *dev = &pdev->dev; in cpsw_probe()
1849 struct gpio_descs *mode; in cpsw_probe() local
1857 return -ENOMEM; in cpsw_probe()
1861 cpsw->dev = dev; in cpsw_probe()
1863 cpsw->slaves = devm_kcalloc(dev, in cpsw_probe()
1867 if (!cpsw->slaves) in cpsw_probe()
1868 return -ENOMEM; in cpsw_probe()
1870 mode = devm_gpiod_get_array_optional(dev, "mode", GPIOD_OUT_LOW); in cpsw_probe()
1871 if (IS_ERR(mode)) { in cpsw_probe()
1872 ret = PTR_ERR(mode); in cpsw_probe()
1883 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; in cpsw_probe()
1890 cpsw->regs = ss_regs; in cpsw_probe()
1895 cpsw->irqs_table[0] = irq; in cpsw_probe()
1900 cpsw->irqs_table[1] = irq; in cpsw_probe()
1905 cpsw->misc_irq = irq; in cpsw_probe()
1926 cpsw->quirk_irq = true; in cpsw_probe()
1928 cpsw->rx_packet_max = rx_packet_max; in cpsw_probe()
1929 cpsw->descs_pool_size = descs_pool_size; in cpsw_probe()
1930 eth_random_addr(cpsw->base_mac); in cpsw_probe()
1933 (u32 __force)ss_res->start + CPSW2_BD_OFFSET, in cpsw_probe()
1938 cpsw->wr_regs = cpsw->version == CPSW_VERSION_1 ? in cpsw_probe()
1942 ch = cpsw->quirk_irq ? 0 : 7; in cpsw_probe()
1943 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0); in cpsw_probe()
1944 if (IS_ERR(cpsw->txv[0].ch)) { in cpsw_probe()
1946 ret = PTR_ERR(cpsw->txv[0].ch); in cpsw_probe()
1950 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1); in cpsw_probe()
1951 if (IS_ERR(cpsw->rxv[0].ch)) { in cpsw_probe()
1953 ret = PTR_ERR(cpsw->rxv[0].ch); in cpsw_probe()
1971 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt, in cpsw_probe()
1978 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt, in cpsw_probe()
1985 if (!cpsw->cpts) in cpsw_probe()
1988 ret = devm_request_irq(dev, cpsw->misc_irq, cpsw_misc_interrupt, in cpsw_probe()
1989 0, dev_name(&pdev->dev), cpsw); in cpsw_probe()
1996 cpts_set_irqpoll(cpsw->cpts, false); in cpsw_probe()
2012 &ss_res->start, descs_pool_size, in cpsw_probe()
2013 cpsw->version, CPSW_MAJOR_VERSION(cpsw->version), in cpsw_probe()
2014 CPSW_MINOR_VERSION(cpsw->version), in cpsw_probe()
2015 CPSW_RTL_VERSION(cpsw->version)); in cpsw_probe()
2026 cpts_release(cpsw->cpts); in cpsw_probe()
2027 cpdma_ctlr_destroy(cpsw->dma); in cpsw_probe()
2040 ret = pm_runtime_resume_and_get(&pdev->dev); in cpsw_remove()
2048 cpts_release(cpsw->cpts); in cpsw_remove()
2049 cpdma_ctlr_destroy(cpsw->dma); in cpsw_remove()
2051 pm_runtime_put_sync(&pdev->dev); in cpsw_remove()
2052 pm_runtime_disable(&pdev->dev); in cpsw_remove()
2063 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_suspend()
2064 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_suspend()
2091 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_resume()
2092 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_resume()
2109 .name = "cpsw-switch",