Lines Matching refs:cpsw
51 struct cpsw_common *cpsw; member
63 static int cpsw_slave_index_priv(struct cpsw_common *cpsw, in cpsw_slave_index_priv() argument
72 static bool cpsw_is_switch_en(struct cpsw_common *cpsw) in cpsw_is_switch_en() argument
74 return !cpsw->data.dual_emac; in cpsw_is_switch_en()
79 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_set_promiscious() local
83 if (cpsw_is_switch_en(cpsw)) in cpsw_set_promiscious()
90 for (i = 0; i < cpsw->data.slaves; i++) in cpsw_set_promiscious()
91 if (cpsw->slaves[i].ndev && in cpsw_set_promiscious()
92 (cpsw->slaves[i].ndev->flags & IFF_PROMISC)) in cpsw_set_promiscious()
97 …dev_dbg(cpsw->dev, "promiscuity not disabled as the other interface is still in promiscuity mode\n… in cpsw_set_promiscious()
102 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
105 dev_dbg(cpsw->dev, "promiscuity enabled\n"); in cpsw_set_promiscious()
108 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
110 dev_dbg(cpsw->dev, "promiscuity disabled\n"); in cpsw_set_promiscious()
126 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_mc() local
129 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_mc()
131 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_set_mc()
137 ret = cpsw_ale_add_mcast(cpsw->ale, addr, mask, flags, vid, 0); in cpsw_set_mc()
139 ret = cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid); in cpsw_set_mc()
252 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_rx_mode() local
257 cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI, priv->emac_port); in cpsw_ndo_set_rx_mode()
265 cpsw_ale_set_allmulti(cpsw->ale, in cpsw_ndo_set_rx_mode()
287 struct cpsw_common *cpsw; in cpsw_rx_handler() local
298 cpsw = ndev_to_cpsw(xmeta->ndev); in cpsw_rx_handler()
300 pkt_size = cpsw->rx_packet_max; in cpsw_rx_handler()
306 ndev = cpsw->slaves[--port].ndev; in cpsw_rx_handler()
310 pool = cpsw->page_pool[ch]; in cpsw_rx_handler()
314 if (cpsw->usage_count && status >= 0) { in cpsw_rx_handler()
381 cpts_rx_timestamp(cpsw->cpts, skb); in cpsw_rx_handler()
397 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma, in cpsw_rx_handler()
408 struct cpsw_common *cpsw = priv->cpsw; in cpsw_add_vlan_ale_entry() local
420 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask, in cpsw_add_vlan_ale_entry()
425 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
430 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_add_vlan_ale_entry()
437 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
440 cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_add_vlan_ale_entry()
448 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_add_vid() local
451 if (cpsw_is_switch_en(cpsw)) { in cpsw_ndo_vlan_rx_add_vid()
452 dev_dbg(cpsw->dev, ".ndo_vlan_rx_add_vid called in switch mode\n"); in cpsw_ndo_vlan_rx_add_vid()
456 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_add_vid()
459 ret = pm_runtime_get_sync(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
461 pm_runtime_put_noidle(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
469 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_add_vid()
470 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_add_vid()
471 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_add_vid()
480 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
498 struct cpsw_common *cpsw = priv->cpsw; in cpsw_restore() local
504 cpsw_mqprio_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
507 cpsw_cbs_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
510 static void cpsw_init_stp_ale_entry(struct cpsw_common *cpsw) in cpsw_init_stp_ale_entry() argument
514 cpsw_ale_add_mcast(cpsw->ale, stpa, in cpsw_init_stp_ale_entry()
519 static void cpsw_init_host_port_switch(struct cpsw_common *cpsw) in cpsw_init_host_port_switch() argument
521 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_switch()
523 writel(CPSW_FIFO_NORMAL_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_switch()
525 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_switch()
527 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, in cpsw_init_host_port_switch()
531 cpsw_init_stp_ale_entry(cpsw); in cpsw_init_host_port_switch()
533 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 1); in cpsw_init_host_port_switch()
534 dev_dbg(cpsw->dev, "Set P0_UNI_FLOOD\n"); in cpsw_init_host_port_switch()
535 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 0); in cpsw_init_host_port_switch()
538 static void cpsw_init_host_port_dual_mac(struct cpsw_common *cpsw) in cpsw_init_host_port_dual_mac() argument
540 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_dual_mac()
542 writel(CPSW_FIFO_DUAL_MAC_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_dual_mac()
544 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 0); in cpsw_init_host_port_dual_mac()
545 dev_dbg(cpsw->dev, "unset P0_UNI_FLOOD\n"); in cpsw_init_host_port_dual_mac()
547 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_dual_mac()
549 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); in cpsw_init_host_port_dual_mac()
551 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 1); in cpsw_init_host_port_dual_mac()
556 struct cpsw_common *cpsw = priv->cpsw; in cpsw_init_host_port() local
560 soft_reset("cpsw", &cpsw->regs->soft_reset); in cpsw_init_host_port()
561 cpsw_ale_start(cpsw->ale); in cpsw_init_host_port()
564 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE, in cpsw_init_host_port()
566 control_reg = readl(&cpsw->regs->control); in cpsw_init_host_port()
568 writel(control_reg, &cpsw->regs->control); in cpsw_init_host_port()
572 &cpsw->host_port_regs->cpdma_tx_pri_map); in cpsw_init_host_port()
573 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map); in cpsw_init_host_port()
576 writel_relaxed(0, &cpsw->regs->ptype); in cpsw_init_host_port()
579 writel_relaxed(0x7, &cpsw->regs->stat_port_en); in cpsw_init_host_port()
582 writel(0x7, &cpsw->regs->flow_control); in cpsw_init_host_port()
584 if (cpsw_is_switch_en(cpsw)) in cpsw_init_host_port()
585 cpsw_init_host_port_switch(cpsw); in cpsw_init_host_port()
587 cpsw_init_host_port_dual_mac(cpsw); in cpsw_init_host_port()
589 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_init_host_port()
597 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_dual_emac_def_ale_entries() local
600 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_dual_emac_def_ale_entries()
604 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, in cpsw_port_add_dual_emac_def_ale_entries()
606 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_dual_emac_def_ale_entries()
609 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_dual_emac_def_ale_entries()
612 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
615 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
623 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_switch_def_ale_entries() local
626 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
628 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
640 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
643 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_switch_def_ale_entries()
646 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_switch_def_ale_entries()
649 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_switch_def_ale_entries()
657 struct cpsw_common *cpsw = priv->cpsw; in cpsw_adjust_link() local
662 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_adjust_link()
693 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
707 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
720 if (phy->link && cpsw_need_resplit(cpsw)) in cpsw_adjust_link()
721 cpsw_split_res(cpsw); in cpsw_adjust_link()
726 struct cpsw_common *cpsw = priv->cpsw; in cpsw_slave_open() local
736 switch (cpsw->version) { in cpsw_slave_open()
761 cpsw->rx_packet_max); in cpsw_slave_open()
766 if (cpsw_is_switch_en(cpsw)) in cpsw_slave_open()
796 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_stop() local
800 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_ndo_stop()
813 if (cpsw->usage_count <= 1) { in cpsw_ndo_stop()
814 napi_disable(&cpsw->napi_rx); in cpsw_ndo_stop()
815 napi_disable(&cpsw->napi_tx); in cpsw_ndo_stop()
816 cpts_unregister(cpsw->cpts); in cpsw_ndo_stop()
817 cpsw_intr_disable(cpsw); in cpsw_ndo_stop()
818 cpdma_ctlr_stop(cpsw->dma); in cpsw_ndo_stop()
819 cpsw_ale_stop(cpsw->ale); in cpsw_ndo_stop()
820 cpsw_destroy_xdp_rxqs(cpsw); in cpsw_ndo_stop()
823 if (cpsw_need_resplit(cpsw)) in cpsw_ndo_stop()
824 cpsw_split_res(cpsw); in cpsw_ndo_stop()
826 cpsw->usage_count--; in cpsw_ndo_stop()
827 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_stop()
834 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_open() local
838 cpsw_is_switch_en(cpsw) ? "switch" : "dual_mac"); in cpsw_ndo_open()
839 ret = pm_runtime_get_sync(cpsw->dev); in cpsw_ndo_open()
841 pm_runtime_put_noidle(cpsw->dev); in cpsw_ndo_open()
846 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num); in cpsw_ndo_open()
852 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num); in cpsw_ndo_open()
859 if (!cpsw->usage_count) in cpsw_ndo_open()
861 cpsw_slave_open(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_ndo_open()
864 if (!cpsw->usage_count) { in cpsw_ndo_open()
868 ret = cpsw_create_xdp_rxqs(cpsw); in cpsw_ndo_open()
876 if (cpsw->cpts) { in cpsw_ndo_open()
877 if (cpts_register(cpsw->cpts)) in cpsw_ndo_open()
880 writel(0x10, &cpsw->wr_regs->misc_en); in cpsw_ndo_open()
883 napi_enable(&cpsw->napi_rx); in cpsw_ndo_open()
884 napi_enable(&cpsw->napi_tx); in cpsw_ndo_open()
886 if (cpsw->tx_irq_disabled) { in cpsw_ndo_open()
887 cpsw->tx_irq_disabled = false; in cpsw_ndo_open()
888 enable_irq(cpsw->irqs_table[1]); in cpsw_ndo_open()
891 if (cpsw->rx_irq_disabled) { in cpsw_ndo_open()
892 cpsw->rx_irq_disabled = false; in cpsw_ndo_open()
893 enable_irq(cpsw->irqs_table[0]); in cpsw_ndo_open()
900 if (cpsw->coal_intvl != 0) { in cpsw_ndo_open()
903 coal.rx_coalesce_usecs = cpsw->coal_intvl; in cpsw_ndo_open()
907 cpdma_ctlr_start(cpsw->dma); in cpsw_ndo_open()
908 cpsw_intr_enable(cpsw); in cpsw_ndo_open()
909 cpsw->usage_count++; in cpsw_ndo_open()
917 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_open()
925 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_start_xmit() local
926 struct cpts *cpts = cpsw->cpts; in cpsw_ndo_start_xmit()
942 if (q_idx >= cpsw->tx_ch_num) in cpsw_ndo_start_xmit()
943 q_idx = q_idx % cpsw->tx_ch_num; in cpsw_ndo_start_xmit()
945 txch = cpsw->txv[q_idx].ch; in cpsw_ndo_start_xmit()
986 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_mac_address() local
991 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_ndo_set_mac_address()
995 ret = pm_runtime_get_sync(cpsw->dev); in cpsw_ndo_set_mac_address()
997 pm_runtime_put_noidle(cpsw->dev); in cpsw_ndo_set_mac_address()
1001 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_ndo_set_mac_address()
1004 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
1006 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
1011 cpsw_set_slave_mac(&cpsw->slaves[slave_no], priv); in cpsw_ndo_set_mac_address()
1013 pm_runtime_put(cpsw->dev); in cpsw_ndo_set_mac_address()
1022 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_kill_vid() local
1026 if (cpsw_is_switch_en(cpsw)) { in cpsw_ndo_vlan_rx_kill_vid()
1027 dev_dbg(cpsw->dev, "ndo del vlan is called in switch mode\n"); in cpsw_ndo_vlan_rx_kill_vid()
1031 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_kill_vid()
1034 ret = pm_runtime_get_sync(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1036 pm_runtime_put_noidle(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1044 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_kill_vid()
1045 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_kill_vid()
1046 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_kill_vid()
1053 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_ndo_vlan_rx_kill_vid()
1056 ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_ndo_vlan_rx_kill_vid()
1061 ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_ndo_vlan_rx_kill_vid()
1066 cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid); in cpsw_ndo_vlan_rx_kill_vid()
1069 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1090 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_ndo_poll_controller() local
1092 cpsw_intr_disable(cpsw); in cpsw_ndo_poll_controller()
1093 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw); in cpsw_ndo_poll_controller()
1094 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw); in cpsw_ndo_poll_controller()
1095 cpsw_intr_enable(cpsw); in cpsw_ndo_poll_controller()
1127 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_port_parent_id() local
1129 ppid->id_len = sizeof(cpsw->base_mac); in cpsw_get_port_parent_id()
1130 memcpy(&ppid->id, &cpsw->base_mac, ppid->id_len); in cpsw_get_port_parent_id()
1160 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_drvinfo() local
1163 pdev = to_platform_device(cpsw->dev); in cpsw_get_drvinfo()
1172 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_set_pauseparam() local
1176 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_pauseparam()
1177 if (!cpsw->slaves[slave_no].phy) in cpsw_set_pauseparam()
1180 if (!phy_validate_pause(cpsw->slaves[slave_no].phy, pause)) in cpsw_set_pauseparam()
1186 phy_set_asym_pause(cpsw->slaves[slave_no].phy, in cpsw_set_pauseparam()
1229 static int cpsw_probe_dt(struct cpsw_common *cpsw) in cpsw_probe_dt() argument
1231 struct device_node *node = cpsw->dev->of_node, *tmp_node, *port_np; in cpsw_probe_dt()
1232 struct cpsw_platform_data *data = &cpsw->data; in cpsw_probe_dt()
1233 struct device *dev = cpsw->dev; in cpsw_probe_dt()
1362 static void cpsw_remove_dt(struct cpsw_common *cpsw) in cpsw_remove_dt() argument
1364 struct cpsw_platform_data *data = &cpsw->data; in cpsw_remove_dt()
1367 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_remove_dt()
1380 static int cpsw_create_ports(struct cpsw_common *cpsw) in cpsw_create_ports() argument
1382 struct cpsw_platform_data *data = &cpsw->data; in cpsw_create_ports()
1384 struct device *dev = cpsw->dev; in cpsw_create_ports()
1388 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_create_ports()
1403 priv->cpsw = cpsw; in cpsw_create_ports()
1412 dev_info(cpsw->dev, "Detected MACID = %pM\n", in cpsw_create_ports()
1416 dev_info(cpsw->dev, "Random MACID = %pM\n", in cpsw_create_ports()
1422 cpsw->slaves[i].ndev = ndev; in cpsw_create_ports()
1437 netif_napi_add(ndev, &cpsw->napi_rx, in cpsw_create_ports()
1438 cpsw->quirk_irq ? in cpsw_create_ports()
1441 netif_tx_napi_add(ndev, &cpsw->napi_tx, in cpsw_create_ports()
1442 cpsw->quirk_irq ? in cpsw_create_ports()
1453 static void cpsw_unregister_ports(struct cpsw_common *cpsw) in cpsw_unregister_ports() argument
1457 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_unregister_ports()
1458 if (!cpsw->slaves[i].ndev) in cpsw_unregister_ports()
1461 unregister_netdev(cpsw->slaves[i].ndev); in cpsw_unregister_ports()
1465 static int cpsw_register_ports(struct cpsw_common *cpsw) in cpsw_register_ports() argument
1469 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_register_ports()
1470 if (!cpsw->slaves[i].ndev) in cpsw_register_ports()
1474 ret = register_netdev(cpsw->slaves[i].ndev); in cpsw_register_ports()
1476 dev_err(cpsw->dev, in cpsw_register_ports()
1478 cpsw->slaves[i].ndev = NULL; in cpsw_register_ports()
1484 cpsw_unregister_ports(cpsw); in cpsw_register_ports()
1491 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_port_dev_check() local
1493 return !cpsw->data.dual_emac; in cpsw_port_dev_check()
1499 static void cpsw_port_offload_fwd_mark_update(struct cpsw_common *cpsw) in cpsw_port_offload_fwd_mark_update() argument
1504 if (!cpsw->ale_bypass && in cpsw_port_offload_fwd_mark_update()
1505 (cpsw->br_members == (ALE_PORT_1 | ALE_PORT_2))) in cpsw_port_offload_fwd_mark_update()
1508 dev_dbg(cpsw->dev, "set offload_fwd_mark %d\n", set_val); in cpsw_port_offload_fwd_mark_update()
1510 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_port_offload_fwd_mark_update()
1511 struct net_device *sl_ndev = cpsw->slaves[i].ndev; in cpsw_port_offload_fwd_mark_update()
1522 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_link() local
1524 if (!cpsw->br_members) { in cpsw_netdevice_port_link()
1525 cpsw->hw_bridge_dev = br_ndev; in cpsw_netdevice_port_link()
1530 if (cpsw->hw_bridge_dev != br_ndev) in cpsw_netdevice_port_link()
1534 cpsw->br_members |= BIT(priv->emac_port); in cpsw_netdevice_port_link()
1536 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_netdevice_port_link()
1544 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_unlink() local
1546 cpsw->br_members &= ~BIT(priv->emac_port); in cpsw_netdevice_port_unlink()
1548 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_netdevice_port_unlink()
1550 if (!cpsw->br_members) in cpsw_netdevice_port_unlink()
1551 cpsw->hw_bridge_dev = NULL; in cpsw_netdevice_port_unlink()
1588 static int cpsw_register_notifiers(struct cpsw_common *cpsw) in cpsw_register_notifiers() argument
1594 dev_err(cpsw->dev, "can't register netdevice notifier\n"); in cpsw_register_notifiers()
1598 ret = cpsw_switchdev_register_notifiers(cpsw); in cpsw_register_notifiers()
1605 static void cpsw_unregister_notifiers(struct cpsw_common *cpsw) in cpsw_unregister_notifiers() argument
1607 cpsw_switchdev_unregister_notifiers(cpsw); in cpsw_unregister_notifiers()
1618 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_get() local
1620 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_get()
1625 ctx->val.vbool = !cpsw->data.dual_emac; in cpsw_dl_switch_mode_get()
1634 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_set() local
1635 int vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1640 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_set()
1645 if (switch_en == !cpsw->data.dual_emac) in cpsw_dl_switch_mode_set()
1648 if (!switch_en && cpsw->br_members) { in cpsw_dl_switch_mode_set()
1649 dev_err(cpsw->dev, "Remove ports from BR before disabling switch mode\n"); in cpsw_dl_switch_mode_set()
1655 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1656 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1667 cpsw->data.dual_emac = !switch_en; in cpsw_dl_switch_mode_set()
1668 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1669 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1676 vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1685 dev_info(cpsw->dev, "Enable switch mode\n"); in cpsw_dl_switch_mode_set()
1688 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1691 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1692 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1694 cpsw_init_host_port_switch(cpsw); in cpsw_dl_switch_mode_set()
1696 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1697 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1712 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1713 cpsw->data.dual_emac = false; in cpsw_dl_switch_mode_set()
1715 dev_info(cpsw->dev, "Disable switch mode\n"); in cpsw_dl_switch_mode_set()
1718 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1720 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1721 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1723 cpsw_init_host_port_dual_mac(cpsw); in cpsw_dl_switch_mode_set()
1725 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1726 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1739 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1740 cpsw->data.dual_emac = true; in cpsw_dl_switch_mode_set()
1752 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_get() local
1754 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_get()
1758 ctx->val.vbool = cpsw_ale_control_get(cpsw->ale, 0, ALE_BYPASS); in cpsw_dl_ale_ctrl_get()
1771 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_set() local
1774 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_set()
1778 ret = cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, in cpsw_dl_ale_ctrl_set()
1781 cpsw->ale_bypass = ctx->val.vbool; in cpsw_dl_ale_ctrl_set()
1782 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_dl_ale_ctrl_set()
1804 static int cpsw_register_devlink(struct cpsw_common *cpsw) in cpsw_register_devlink() argument
1806 struct device *dev = cpsw->dev; in cpsw_register_devlink()
1810 cpsw->devlink = devlink_alloc(&cpsw_devlink_ops, sizeof(*dl_priv)); in cpsw_register_devlink()
1811 if (!cpsw->devlink) in cpsw_register_devlink()
1814 dl_priv = devlink_priv(cpsw->devlink); in cpsw_register_devlink()
1815 dl_priv->cpsw = cpsw; in cpsw_register_devlink()
1817 ret = devlink_register(cpsw->devlink, dev); in cpsw_register_devlink()
1823 ret = devlink_params_register(cpsw->devlink, cpsw_devlink_params, in cpsw_register_devlink()
1830 devlink_params_publish(cpsw->devlink); in cpsw_register_devlink()
1834 devlink_unregister(cpsw->devlink); in cpsw_register_devlink()
1836 devlink_free(cpsw->devlink); in cpsw_register_devlink()
1840 static void cpsw_unregister_devlink(struct cpsw_common *cpsw) in cpsw_unregister_devlink() argument
1842 devlink_params_unpublish(cpsw->devlink); in cpsw_unregister_devlink()
1843 devlink_params_unregister(cpsw->devlink, cpsw_devlink_params, in cpsw_unregister_devlink()
1845 devlink_unregister(cpsw->devlink); in cpsw_unregister_devlink()
1846 devlink_free(cpsw->devlink); in cpsw_unregister_devlink()
1867 struct cpsw_common *cpsw; in cpsw_probe() local
1875 cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL); in cpsw_probe()
1876 if (!cpsw) in cpsw_probe()
1881 cpsw->dev = dev; in cpsw_probe()
1883 cpsw->slaves = devm_kcalloc(dev, in cpsw_probe()
1887 if (!cpsw->slaves) in cpsw_probe()
1903 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; in cpsw_probe()
1911 cpsw->regs = ss_regs; in cpsw_probe()
1916 cpsw->irqs_table[0] = irq; in cpsw_probe()
1921 cpsw->irqs_table[1] = irq; in cpsw_probe()
1926 cpsw->misc_irq = irq; in cpsw_probe()
1928 platform_set_drvdata(pdev, cpsw); in cpsw_probe()
1942 ret = cpsw_probe_dt(cpsw); in cpsw_probe()
1948 cpsw->quirk_irq = true; in cpsw_probe()
1950 cpsw->rx_packet_max = rx_packet_max; in cpsw_probe()
1951 cpsw->descs_pool_size = descs_pool_size; in cpsw_probe()
1952 eth_random_addr(cpsw->base_mac); in cpsw_probe()
1954 ret = cpsw_init_common(cpsw, ss_regs, ale_ageout, in cpsw_probe()
1960 cpsw->wr_regs = cpsw->version == CPSW_VERSION_1 ? in cpsw_probe()
1964 ch = cpsw->quirk_irq ? 0 : 7; in cpsw_probe()
1965 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0); in cpsw_probe()
1966 if (IS_ERR(cpsw->txv[0].ch)) { in cpsw_probe()
1968 ret = PTR_ERR(cpsw->txv[0].ch); in cpsw_probe()
1972 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1); in cpsw_probe()
1973 if (IS_ERR(cpsw->rxv[0].ch)) { in cpsw_probe()
1975 ret = PTR_ERR(cpsw->rxv[0].ch); in cpsw_probe()
1978 cpsw_split_res(cpsw); in cpsw_probe()
1981 ret = cpsw_create_ports(cpsw); in cpsw_probe()
1993 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt, in cpsw_probe()
1994 0, dev_name(dev), cpsw); in cpsw_probe()
2000 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt, in cpsw_probe()
2001 0, dev_name(dev), cpsw); in cpsw_probe()
2007 if (!cpsw->cpts) in cpsw_probe()
2010 ret = devm_request_irq(dev, cpsw->misc_irq, cpsw_misc_interrupt, in cpsw_probe()
2011 0, dev_name(&pdev->dev), cpsw); in cpsw_probe()
2018 cpts_set_irqpoll(cpsw->cpts, false); in cpsw_probe()
2021 ret = cpsw_register_notifiers(cpsw); in cpsw_probe()
2025 ret = cpsw_register_devlink(cpsw); in cpsw_probe()
2029 ret = cpsw_register_ports(cpsw); in cpsw_probe()
2035 cpsw->version, CPSW_MAJOR_VERSION(cpsw->version), in cpsw_probe()
2036 CPSW_MINOR_VERSION(cpsw->version), in cpsw_probe()
2037 CPSW_RTL_VERSION(cpsw->version)); in cpsw_probe()
2044 cpsw_unregister_notifiers(cpsw); in cpsw_probe()
2046 cpsw_unregister_ports(cpsw); in cpsw_probe()
2048 cpts_release(cpsw->cpts); in cpsw_probe()
2049 cpdma_ctlr_destroy(cpsw->dma); in cpsw_probe()
2051 cpsw_remove_dt(cpsw); in cpsw_probe()
2059 struct cpsw_common *cpsw = platform_get_drvdata(pdev); in cpsw_remove() local
2068 cpsw_unregister_notifiers(cpsw); in cpsw_remove()
2069 cpsw_unregister_devlink(cpsw); in cpsw_remove()
2070 cpsw_unregister_ports(cpsw); in cpsw_remove()
2072 cpts_release(cpsw->cpts); in cpsw_remove()
2073 cpdma_ctlr_destroy(cpsw->dma); in cpsw_remove()
2074 cpsw_remove_dt(cpsw); in cpsw_remove()
2082 struct cpsw_common *cpsw = dev_get_drvdata(dev); in cpsw_suspend() local
2087 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_suspend()
2088 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_suspend()
2106 struct cpsw_common *cpsw = dev_get_drvdata(dev); in cpsw_resume() local
2115 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_resume()
2116 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_resume()