• Home
  • Raw
  • Download

Lines Matching full:cpsw

37 #include "cpsw.h"
53 struct cpsw_common *cpsw; member
65 static int cpsw_slave_index_priv(struct cpsw_common *cpsw, in cpsw_slave_index_priv() argument
74 static bool cpsw_is_switch_en(struct cpsw_common *cpsw) in cpsw_is_switch_en() argument
76 return !cpsw->data.dual_emac; in cpsw_is_switch_en()
81 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_set_promiscious() local
85 if (cpsw_is_switch_en(cpsw)) in cpsw_set_promiscious()
92 for (i = 0; i < cpsw->data.slaves; i++) in cpsw_set_promiscious()
93 if (cpsw->slaves[i].ndev && in cpsw_set_promiscious()
94 (cpsw->slaves[i].ndev->flags & IFF_PROMISC)) in cpsw_set_promiscious()
99 …dev_dbg(cpsw->dev, "promiscuity not disabled as the other interface is still in promiscuity mode\n… in cpsw_set_promiscious()
104 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
107 dev_dbg(cpsw->dev, "promiscuity enabled\n"); in cpsw_set_promiscious()
110 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_set_promiscious()
112 dev_dbg(cpsw->dev, "promiscuity disabled\n"); in cpsw_set_promiscious()
128 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_mc() local
131 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_mc()
133 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_set_mc()
139 ret = cpsw_ale_add_mcast(cpsw->ale, addr, mask, flags, vid, 0); in cpsw_set_mc()
141 ret = cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid); in cpsw_set_mc()
254 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_rx_mode() local
259 cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI, priv->emac_port); in cpsw_ndo_set_rx_mode()
267 cpsw_ale_set_allmulti(cpsw->ale, in cpsw_ndo_set_rx_mode()
289 struct cpsw_common *cpsw; in cpsw_rx_handler() local
300 cpsw = ndev_to_cpsw(xmeta->ndev); in cpsw_rx_handler()
302 pkt_size = cpsw->rx_packet_max; in cpsw_rx_handler()
308 ndev = cpsw->slaves[--port].ndev; in cpsw_rx_handler()
312 pool = cpsw->page_pool[ch]; in cpsw_rx_handler()
316 if (cpsw->usage_count && status >= 0) { in cpsw_rx_handler()
375 cpts_rx_timestamp(cpsw->cpts, skb); in cpsw_rx_handler()
391 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma, in cpsw_rx_handler()
402 struct cpsw_common *cpsw = priv->cpsw; in cpsw_add_vlan_ale_entry() local
414 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask, in cpsw_add_vlan_ale_entry()
419 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
424 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_add_vlan_ale_entry()
431 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_add_vlan_ale_entry()
434 cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_add_vlan_ale_entry()
442 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_add_vid() local
445 if (cpsw_is_switch_en(cpsw)) { in cpsw_ndo_vlan_rx_add_vid()
446 dev_dbg(cpsw->dev, ".ndo_vlan_rx_add_vid called in switch mode\n"); in cpsw_ndo_vlan_rx_add_vid()
450 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_add_vid()
453 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
461 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_add_vid()
462 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_add_vid()
463 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_add_vid()
472 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_add_vid()
490 struct cpsw_common *cpsw = priv->cpsw; in cpsw_restore() local
496 cpsw_mqprio_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
499 cpsw_cbs_resume(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_restore()
504 static void cpsw_init_stp_ale_entry(struct cpsw_common *cpsw) in cpsw_init_stp_ale_entry() argument
508 cpsw_ale_add_mcast(cpsw->ale, stpa, in cpsw_init_stp_ale_entry()
513 static void cpsw_init_host_port_switch(struct cpsw_common *cpsw) in cpsw_init_host_port_switch() argument
515 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_switch()
517 writel(CPSW_FIFO_NORMAL_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_switch()
519 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_switch()
521 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, in cpsw_init_host_port_switch()
525 cpsw_init_stp_ale_entry(cpsw); in cpsw_init_host_port_switch()
527 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 1); in cpsw_init_host_port_switch()
528 dev_dbg(cpsw->dev, "Set P0_UNI_FLOOD\n"); in cpsw_init_host_port_switch()
529 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 0); in cpsw_init_host_port_switch()
532 static void cpsw_init_host_port_dual_mac(struct cpsw_common *cpsw) in cpsw_init_host_port_dual_mac() argument
534 int vlan = cpsw->data.default_vlan; in cpsw_init_host_port_dual_mac()
536 writel(CPSW_FIFO_DUAL_MAC_MODE, &cpsw->host_port_regs->tx_in_ctl); in cpsw_init_host_port_dual_mac()
538 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 0); in cpsw_init_host_port_dual_mac()
539 dev_dbg(cpsw->dev, "unset P0_UNI_FLOOD\n"); in cpsw_init_host_port_dual_mac()
541 writel(vlan, &cpsw->host_port_regs->port_vlan); in cpsw_init_host_port_dual_mac()
543 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); in cpsw_init_host_port_dual_mac()
545 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_PORT_NOLEARN, 1); in cpsw_init_host_port_dual_mac()
550 struct cpsw_common *cpsw = priv->cpsw; in cpsw_init_host_port() local
554 soft_reset("cpsw", &cpsw->regs->soft_reset); in cpsw_init_host_port()
555 cpsw_ale_start(cpsw->ale); in cpsw_init_host_port()
558 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE, in cpsw_init_host_port()
560 control_reg = readl(&cpsw->regs->control); in cpsw_init_host_port()
562 writel(control_reg, &cpsw->regs->control); in cpsw_init_host_port()
566 &cpsw->host_port_regs->cpdma_tx_pri_map); in cpsw_init_host_port()
567 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map); in cpsw_init_host_port()
570 writel_relaxed(0, &cpsw->regs->ptype); in cpsw_init_host_port()
573 writel_relaxed(0x7, &cpsw->regs->stat_port_en); in cpsw_init_host_port()
576 writel(0x7, &cpsw->regs->flow_control); in cpsw_init_host_port()
578 if (cpsw_is_switch_en(cpsw)) in cpsw_init_host_port()
579 cpsw_init_host_port_switch(cpsw); in cpsw_init_host_port()
581 cpsw_init_host_port_dual_mac(cpsw); in cpsw_init_host_port()
583 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, in cpsw_init_host_port()
591 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_dual_emac_def_ale_entries() local
594 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_dual_emac_def_ale_entries()
598 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, in cpsw_port_add_dual_emac_def_ale_entries()
600 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_dual_emac_def_ale_entries()
603 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_dual_emac_def_ale_entries()
606 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
609 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_dual_emac_def_ale_entries()
617 struct cpsw_common *cpsw = priv->cpsw; in cpsw_port_add_switch_def_ale_entries() local
620 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
622 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
634 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_port_add_switch_def_ale_entries()
637 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_port_add_switch_def_ale_entries()
640 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, in cpsw_port_add_switch_def_ale_entries()
643 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : in cpsw_port_add_switch_def_ale_entries()
651 struct cpsw_common *cpsw = priv->cpsw; in cpsw_adjust_link() local
656 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_adjust_link()
687 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
701 cpsw_ale_control_set(cpsw->ale, priv->emac_port, in cpsw_adjust_link()
714 if (phy->link && cpsw_need_resplit(cpsw)) in cpsw_adjust_link()
715 cpsw_split_res(cpsw); in cpsw_adjust_link()
720 struct cpsw_common *cpsw = priv->cpsw; in cpsw_slave_open() local
730 switch (cpsw->version) { in cpsw_slave_open()
755 cpsw->rx_packet_max); in cpsw_slave_open()
760 if (cpsw_is_switch_en(cpsw)) in cpsw_slave_open()
793 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_stop() local
797 slave = &cpsw->slaves[priv->emac_port - 1]; in cpsw_ndo_stop()
810 if (cpsw->usage_count <= 1) { in cpsw_ndo_stop()
811 napi_disable(&cpsw->napi_rx); in cpsw_ndo_stop()
812 napi_disable(&cpsw->napi_tx); in cpsw_ndo_stop()
813 cpts_unregister(cpsw->cpts); in cpsw_ndo_stop()
814 cpsw_intr_disable(cpsw); in cpsw_ndo_stop()
815 cpdma_ctlr_stop(cpsw->dma); in cpsw_ndo_stop()
816 cpsw_ale_stop(cpsw->ale); in cpsw_ndo_stop()
817 cpsw_destroy_xdp_rxqs(cpsw); in cpsw_ndo_stop()
820 if (cpsw_need_resplit(cpsw)) in cpsw_ndo_stop()
821 cpsw_split_res(cpsw); in cpsw_ndo_stop()
823 cpsw->usage_count--; in cpsw_ndo_stop()
824 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_stop()
831 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_open() local
835 cpsw_is_switch_en(cpsw) ? "switch" : "dual_mac"); in cpsw_ndo_open()
836 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_open()
841 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num); in cpsw_ndo_open()
847 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num); in cpsw_ndo_open()
854 if (!cpsw->usage_count) in cpsw_ndo_open()
856 cpsw_slave_open(&cpsw->slaves[priv->emac_port - 1], priv); in cpsw_ndo_open()
859 if (!cpsw->usage_count) { in cpsw_ndo_open()
863 ret = cpsw_create_xdp_rxqs(cpsw); in cpsw_ndo_open()
871 if (cpsw->cpts) { in cpsw_ndo_open()
872 if (cpts_register(cpsw->cpts)) in cpsw_ndo_open()
875 writel(0x10, &cpsw->wr_regs->misc_en); in cpsw_ndo_open()
878 napi_enable(&cpsw->napi_rx); in cpsw_ndo_open()
879 napi_enable(&cpsw->napi_tx); in cpsw_ndo_open()
881 if (cpsw->tx_irq_disabled) { in cpsw_ndo_open()
882 cpsw->tx_irq_disabled = false; in cpsw_ndo_open()
883 enable_irq(cpsw->irqs_table[1]); in cpsw_ndo_open()
886 if (cpsw->rx_irq_disabled) { in cpsw_ndo_open()
887 cpsw->rx_irq_disabled = false; in cpsw_ndo_open()
888 enable_irq(cpsw->irqs_table[0]); in cpsw_ndo_open()
895 if (cpsw->coal_intvl != 0) { in cpsw_ndo_open()
898 coal.rx_coalesce_usecs = cpsw->coal_intvl; in cpsw_ndo_open()
902 cpdma_ctlr_start(cpsw->dma); in cpsw_ndo_open()
903 cpsw_intr_enable(cpsw); in cpsw_ndo_open()
904 cpsw->usage_count++; in cpsw_ndo_open()
912 pm_runtime_put_sync(cpsw->dev); in cpsw_ndo_open()
920 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_start_xmit() local
921 struct cpts *cpts = cpsw->cpts; in cpsw_ndo_start_xmit()
937 if (q_idx >= cpsw->tx_ch_num) in cpsw_ndo_start_xmit()
938 q_idx = q_idx % cpsw->tx_ch_num; in cpsw_ndo_start_xmit()
940 txch = cpsw->txv[q_idx].ch; in cpsw_ndo_start_xmit()
981 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_set_mac_address() local
986 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_ndo_set_mac_address()
990 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_set_mac_address()
994 vid = cpsw->slaves[slave_no].port_vlan; in cpsw_ndo_set_mac_address()
997 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
999 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM, in cpsw_ndo_set_mac_address()
1004 cpsw_set_slave_mac(&cpsw->slaves[slave_no], priv); in cpsw_ndo_set_mac_address()
1006 pm_runtime_put(cpsw->dev); in cpsw_ndo_set_mac_address()
1015 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ndo_vlan_rx_kill_vid() local
1019 if (cpsw_is_switch_en(cpsw)) { in cpsw_ndo_vlan_rx_kill_vid()
1020 dev_dbg(cpsw->dev, "ndo del vlan is called in switch mode\n"); in cpsw_ndo_vlan_rx_kill_vid()
1024 if (vid == cpsw->data.default_vlan) in cpsw_ndo_vlan_rx_kill_vid()
1027 ret = pm_runtime_resume_and_get(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1035 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_ndo_vlan_rx_kill_vid()
1036 if (cpsw->slaves[i].ndev && in cpsw_ndo_vlan_rx_kill_vid()
1037 vid == cpsw->slaves[i].port_vlan) { in cpsw_ndo_vlan_rx_kill_vid()
1044 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0); in cpsw_ndo_vlan_rx_kill_vid()
1047 ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, in cpsw_ndo_vlan_rx_kill_vid()
1052 ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, in cpsw_ndo_vlan_rx_kill_vid()
1057 cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid); in cpsw_ndo_vlan_rx_kill_vid()
1060 pm_runtime_put(cpsw->dev); in cpsw_ndo_vlan_rx_kill_vid()
1081 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_ndo_poll_controller() local
1083 cpsw_intr_disable(cpsw); in cpsw_ndo_poll_controller()
1084 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw); in cpsw_ndo_poll_controller()
1085 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw); in cpsw_ndo_poll_controller()
1086 cpsw_intr_enable(cpsw); in cpsw_ndo_poll_controller()
1116 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_port_parent_id() local
1118 ppid->id_len = sizeof(cpsw->base_mac); in cpsw_get_port_parent_id()
1119 memcpy(&ppid->id, &cpsw->base_mac, ppid->id_len); in cpsw_get_port_parent_id()
1149 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_drvinfo() local
1152 pdev = to_platform_device(cpsw->dev); in cpsw_get_drvinfo()
1153 strscpy(info->driver, "cpsw-switch", sizeof(info->driver)); in cpsw_get_drvinfo()
1161 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_set_pauseparam() local
1165 slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_pauseparam()
1166 if (!cpsw->slaves[slave_no].phy) in cpsw_set_pauseparam()
1169 if (!phy_validate_pause(cpsw->slaves[slave_no].phy, pause)) in cpsw_set_pauseparam()
1175 phy_set_asym_pause(cpsw->slaves[slave_no].phy, in cpsw_set_pauseparam()
1218 static int cpsw_probe_dt(struct cpsw_common *cpsw) in cpsw_probe_dt() argument
1220 struct device_node *node = cpsw->dev->of_node, *tmp_node, *port_np; in cpsw_probe_dt()
1221 struct cpsw_platform_data *data = &cpsw->data; in cpsw_probe_dt()
1222 struct device *dev = cpsw->dev; in cpsw_probe_dt()
1347 static void cpsw_remove_dt(struct cpsw_common *cpsw) in cpsw_remove_dt() argument
1349 struct cpsw_platform_data *data = &cpsw->data; in cpsw_remove_dt()
1352 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_remove_dt()
1365 static int cpsw_create_ports(struct cpsw_common *cpsw) in cpsw_create_ports() argument
1367 struct cpsw_platform_data *data = &cpsw->data; in cpsw_create_ports()
1369 struct device *dev = cpsw->dev; in cpsw_create_ports()
1373 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_create_ports()
1388 priv->cpsw = cpsw; in cpsw_create_ports()
1397 dev_info(cpsw->dev, "Detected MACID = %pM\n", in cpsw_create_ports()
1401 dev_info(cpsw->dev, "Random MACID = %pM\n", in cpsw_create_ports()
1407 cpsw->slaves[i].ndev = ndev; in cpsw_create_ports()
1421 /* CPSW Host port CPDMA interface is shared between in cpsw_create_ports()
1426 netif_napi_add(ndev, &cpsw->napi_rx, in cpsw_create_ports()
1427 cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll); in cpsw_create_ports()
1428 netif_napi_add_tx(ndev, &cpsw->napi_tx, in cpsw_create_ports()
1429 cpsw->quirk_irq ? in cpsw_create_ports()
1439 static void cpsw_unregister_ports(struct cpsw_common *cpsw) in cpsw_unregister_ports() argument
1443 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_unregister_ports()
1444 if (!cpsw->slaves[i].ndev) in cpsw_unregister_ports()
1447 unregister_netdev(cpsw->slaves[i].ndev); in cpsw_unregister_ports()
1451 static int cpsw_register_ports(struct cpsw_common *cpsw) in cpsw_register_ports() argument
1455 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_register_ports()
1456 if (!cpsw->slaves[i].ndev) in cpsw_register_ports()
1460 ret = register_netdev(cpsw->slaves[i].ndev); in cpsw_register_ports()
1462 dev_err(cpsw->dev, in cpsw_register_ports()
1463 "cpsw: err registering net device%d\n", i); in cpsw_register_ports()
1464 cpsw->slaves[i].ndev = NULL; in cpsw_register_ports()
1470 cpsw_unregister_ports(cpsw); in cpsw_register_ports()
1477 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_port_dev_check() local
1479 return !cpsw->data.dual_emac; in cpsw_port_dev_check()
1485 static void cpsw_port_offload_fwd_mark_update(struct cpsw_common *cpsw) in cpsw_port_offload_fwd_mark_update() argument
1490 if (!cpsw->ale_bypass && in cpsw_port_offload_fwd_mark_update()
1491 (cpsw->br_members == (ALE_PORT_1 | ALE_PORT_2))) in cpsw_port_offload_fwd_mark_update()
1494 dev_dbg(cpsw->dev, "set offload_fwd_mark %d\n", set_val); in cpsw_port_offload_fwd_mark_update()
1496 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_port_offload_fwd_mark_update()
1497 struct net_device *sl_ndev = cpsw->slaves[i].ndev; in cpsw_port_offload_fwd_mark_update()
1509 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_link() local
1512 if (!cpsw->br_members) { in cpsw_netdevice_port_link()
1513 cpsw->hw_bridge_dev = br_ndev; in cpsw_netdevice_port_link()
1518 if (cpsw->hw_bridge_dev != br_ndev) in cpsw_netdevice_port_link()
1527 cpsw->br_members |= BIT(priv->emac_port); in cpsw_netdevice_port_link()
1529 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_netdevice_port_link()
1537 struct cpsw_common *cpsw = priv->cpsw; in cpsw_netdevice_port_unlink() local
1541 cpsw->br_members &= ~BIT(priv->emac_port); in cpsw_netdevice_port_unlink()
1543 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_netdevice_port_unlink()
1545 if (!cpsw->br_members) in cpsw_netdevice_port_unlink()
1546 cpsw->hw_bridge_dev = NULL; in cpsw_netdevice_port_unlink()
1585 static int cpsw_register_notifiers(struct cpsw_common *cpsw) in cpsw_register_notifiers() argument
1591 dev_err(cpsw->dev, "can't register netdevice notifier\n"); in cpsw_register_notifiers()
1595 ret = cpsw_switchdev_register_notifiers(cpsw); in cpsw_register_notifiers()
1602 static void cpsw_unregister_notifiers(struct cpsw_common *cpsw) in cpsw_unregister_notifiers() argument
1604 cpsw_switchdev_unregister_notifiers(cpsw); in cpsw_unregister_notifiers()
1615 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_get() local
1617 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_get()
1622 ctx->val.vbool = !cpsw->data.dual_emac; in cpsw_dl_switch_mode_get()
1631 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_switch_mode_set() local
1632 int vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1637 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_switch_mode_set()
1642 if (switch_en == !cpsw->data.dual_emac) in cpsw_dl_switch_mode_set()
1645 if (!switch_en && cpsw->br_members) { in cpsw_dl_switch_mode_set()
1646 dev_err(cpsw->dev, "Remove ports from BR before disabling switch mode\n"); in cpsw_dl_switch_mode_set()
1652 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1653 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1664 cpsw->data.dual_emac = !switch_en; in cpsw_dl_switch_mode_set()
1665 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1666 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1673 vlan = cpsw->data.default_vlan; in cpsw_dl_switch_mode_set()
1682 dev_info(cpsw->dev, "Enable switch mode\n"); in cpsw_dl_switch_mode_set()
1685 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1688 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1689 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1691 cpsw_init_host_port_switch(cpsw); in cpsw_dl_switch_mode_set()
1693 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1694 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1709 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1710 cpsw->data.dual_emac = false; in cpsw_dl_switch_mode_set()
1712 dev_info(cpsw->dev, "Disable switch mode\n"); in cpsw_dl_switch_mode_set()
1715 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 1); in cpsw_dl_switch_mode_set()
1717 cpsw_ale_control_set(cpsw->ale, 0, ALE_CLEAR, 1); in cpsw_dl_switch_mode_set()
1718 cpsw_ale_control_get(cpsw->ale, 0, ALE_AGEOUT); in cpsw_dl_switch_mode_set()
1720 cpsw_init_host_port_dual_mac(cpsw); in cpsw_dl_switch_mode_set()
1722 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_dl_switch_mode_set()
1723 struct cpsw_slave *slave = &cpsw->slaves[i]; in cpsw_dl_switch_mode_set()
1736 cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); in cpsw_dl_switch_mode_set()
1737 cpsw->data.dual_emac = true; in cpsw_dl_switch_mode_set()
1749 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_get() local
1751 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_get()
1755 ctx->val.vbool = cpsw_ale_control_get(cpsw->ale, 0, ALE_BYPASS); in cpsw_dl_ale_ctrl_get()
1768 struct cpsw_common *cpsw = dl_priv->cpsw; in cpsw_dl_ale_ctrl_set() local
1771 dev_dbg(cpsw->dev, "%s id:%u\n", __func__, id); in cpsw_dl_ale_ctrl_set()
1775 ret = cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, in cpsw_dl_ale_ctrl_set()
1778 cpsw->ale_bypass = ctx->val.vbool; in cpsw_dl_ale_ctrl_set()
1779 cpsw_port_offload_fwd_mark_update(cpsw); in cpsw_dl_ale_ctrl_set()
1801 static int cpsw_register_devlink(struct cpsw_common *cpsw) in cpsw_register_devlink() argument
1803 struct device *dev = cpsw->dev; in cpsw_register_devlink()
1807 cpsw->devlink = devlink_alloc(&cpsw_devlink_ops, sizeof(*dl_priv), dev); in cpsw_register_devlink()
1808 if (!cpsw->devlink) in cpsw_register_devlink()
1811 dl_priv = devlink_priv(cpsw->devlink); in cpsw_register_devlink()
1812 dl_priv->cpsw = cpsw; in cpsw_register_devlink()
1814 ret = devlink_params_register(cpsw->devlink, cpsw_devlink_params, in cpsw_register_devlink()
1821 devlink_register(cpsw->devlink); in cpsw_register_devlink()
1825 devlink_free(cpsw->devlink); in cpsw_register_devlink()
1829 static void cpsw_unregister_devlink(struct cpsw_common *cpsw) in cpsw_unregister_devlink() argument
1831 devlink_unregister(cpsw->devlink); in cpsw_unregister_devlink()
1832 devlink_params_unregister(cpsw->devlink, cpsw_devlink_params, in cpsw_unregister_devlink()
1834 devlink_free(cpsw->devlink); in cpsw_unregister_devlink()
1838 { .compatible = "ti,cpsw-switch"},
1839 { .compatible = "ti,am335x-cpsw-switch"},
1840 { .compatible = "ti,am4372-cpsw-switch"},
1841 { .compatible = "ti,dra7-cpsw-switch"},
1855 struct cpsw_common *cpsw; in cpsw_probe() local
1863 cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL); in cpsw_probe()
1864 if (!cpsw) in cpsw_probe()
1869 cpsw->dev = dev; in cpsw_probe()
1871 cpsw->slaves = devm_kcalloc(dev, in cpsw_probe()
1875 if (!cpsw->slaves) in cpsw_probe()
1891 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; in cpsw_probe()
1898 cpsw->regs = ss_regs; in cpsw_probe()
1903 cpsw->irqs_table[0] = irq; in cpsw_probe()
1908 cpsw->irqs_table[1] = irq; in cpsw_probe()
1913 cpsw->misc_irq = irq; in cpsw_probe()
1915 platform_set_drvdata(pdev, cpsw); in cpsw_probe()
1928 ret = cpsw_probe_dt(cpsw); in cpsw_probe()
1934 cpsw->quirk_irq = true; in cpsw_probe()
1936 cpsw->rx_packet_max = rx_packet_max; in cpsw_probe()
1937 cpsw->descs_pool_size = descs_pool_size; in cpsw_probe()
1938 eth_random_addr(cpsw->base_mac); in cpsw_probe()
1940 ret = cpsw_init_common(cpsw, ss_regs, ale_ageout, in cpsw_probe()
1946 cpsw->wr_regs = cpsw->version == CPSW_VERSION_1 ? in cpsw_probe()
1950 ch = cpsw->quirk_irq ? 0 : 7; in cpsw_probe()
1951 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0); in cpsw_probe()
1952 if (IS_ERR(cpsw->txv[0].ch)) { in cpsw_probe()
1954 ret = PTR_ERR(cpsw->txv[0].ch); in cpsw_probe()
1958 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1); in cpsw_probe()
1959 if (IS_ERR(cpsw->rxv[0].ch)) { in cpsw_probe()
1961 ret = PTR_ERR(cpsw->rxv[0].ch); in cpsw_probe()
1964 cpsw_split_res(cpsw); in cpsw_probe()
1967 ret = cpsw_create_ports(cpsw); in cpsw_probe()
1979 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt, in cpsw_probe()
1980 0, dev_name(dev), cpsw); in cpsw_probe()
1986 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt, in cpsw_probe()
1987 0, dev_name(dev), cpsw); in cpsw_probe()
1993 if (!cpsw->cpts) in cpsw_probe()
1996 ret = devm_request_irq(dev, cpsw->misc_irq, cpsw_misc_interrupt, in cpsw_probe()
1997 0, dev_name(&pdev->dev), cpsw); in cpsw_probe()
2004 cpts_set_irqpoll(cpsw->cpts, false); in cpsw_probe()
2007 ret = cpsw_register_notifiers(cpsw); in cpsw_probe()
2011 ret = cpsw_register_devlink(cpsw); in cpsw_probe()
2015 ret = cpsw_register_ports(cpsw); in cpsw_probe()
2021 cpsw->version, CPSW_MAJOR_VERSION(cpsw->version), in cpsw_probe()
2022 CPSW_MINOR_VERSION(cpsw->version), in cpsw_probe()
2023 CPSW_RTL_VERSION(cpsw->version)); in cpsw_probe()
2030 cpsw_unregister_notifiers(cpsw); in cpsw_probe()
2032 cpsw_unregister_ports(cpsw); in cpsw_probe()
2034 cpts_release(cpsw->cpts); in cpsw_probe()
2035 cpdma_ctlr_destroy(cpsw->dma); in cpsw_probe()
2037 cpsw_remove_dt(cpsw); in cpsw_probe()
2045 struct cpsw_common *cpsw = platform_get_drvdata(pdev); in cpsw_remove() local
2052 cpsw_unregister_notifiers(cpsw); in cpsw_remove()
2053 cpsw_unregister_devlink(cpsw); in cpsw_remove()
2054 cpsw_unregister_ports(cpsw); in cpsw_remove()
2056 cpts_release(cpsw->cpts); in cpsw_remove()
2057 cpdma_ctlr_destroy(cpsw->dma); in cpsw_remove()
2058 cpsw_remove_dt(cpsw); in cpsw_remove()
2066 struct cpsw_common *cpsw = dev_get_drvdata(dev); in cpsw_suspend() local
2071 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_suspend()
2072 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_suspend()
2090 struct cpsw_common *cpsw = dev_get_drvdata(dev); in cpsw_resume() local
2099 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_resume()
2100 struct net_device *ndev = cpsw->slaves[i].ndev; in cpsw_resume()
2117 .name = "cpsw-switch",
2128 MODULE_DESCRIPTION("TI CPSW switchdev Ethernet driver");