Lines Matching full:emac

55 static int emac_get_tx_ts(struct prueth_emac *emac,  in emac_get_tx_ts()  argument
58 struct prueth *prueth = emac->prueth; in emac_get_tx_ts()
59 int slice = prueth_emac_slice(emac); in emac_get_tx_ts()
75 static void tx_ts_work(struct prueth_emac *emac) in tx_ts_work() argument
86 ret = emac_get_tx_ts(emac, &tsr); in tx_ts_work()
91 !emac->tx_ts_skb[tsr.cookie]) { in tx_ts_work()
92 netdev_err(emac->ndev, "Invalid TX TS cookie 0x%x\n", in tx_ts_work()
97 skb = emac->tx_ts_skb[tsr.cookie]; in tx_ts_work()
98 emac->tx_ts_skb[tsr.cookie] = NULL; /* free slot */ in tx_ts_work()
100 netdev_err(emac->ndev, "Driver Bug! got NULL skb\n"); in tx_ts_work()
104 hi_sw = readl(emac->prueth->shram.va + in tx_ts_work()
115 if (atomic_dec_and_test(&emac->tx_ts_pending)) /* no more? */ in tx_ts_work()
122 struct prueth_emac *emac = dev_id; in prueth_tx_ts_irq() local
125 tx_ts_work(emac); in prueth_tx_ts_irq()
208 struct prueth_emac *emac; in prueth_emac_common_start() local
212 if (!prueth->emac[ICSS_SLICE0] && !prueth->emac[ICSS_SLICE1]) in prueth_emac_common_start()
228 emac = prueth->emac[slice]; in prueth_emac_common_start()
229 if (!emac) in prueth_emac_common_start()
231 ret = icssg_config(prueth, emac, slice); in prueth_emac_common_start()
235 mutex_lock(&emac->ndev->phydev->lock); in prueth_emac_common_start()
236 emac_adjust_link(emac->ndev); in prueth_emac_common_start()
237 mutex_unlock(&emac->ndev->phydev->lock); in prueth_emac_common_start()
244 emac = prueth->emac[ICSS_SLICE0] ? prueth->emac[ICSS_SLICE0] : in prueth_emac_common_start()
245 prueth->emac[ICSS_SLICE1]; in prueth_emac_common_start()
246 ret = icss_iep_init(emac->iep, &prueth_iep_clockops, in prueth_emac_common_start()
247 emac, IEP_DEFAULT_CYCLE_TIME_NS); in prueth_emac_common_start()
267 struct prueth_emac *emac; in prueth_emac_common_stop() local
269 if (!prueth->emac[ICSS_SLICE0] && !prueth->emac[ICSS_SLICE1]) in prueth_emac_common_stop()
277 emac = prueth->emac[ICSS_SLICE0] ? prueth->emac[ICSS_SLICE0] : in prueth_emac_common_stop()
278 prueth->emac[ICSS_SLICE1]; in prueth_emac_common_stop()
279 icss_iep_exit(emac->iep); in prueth_emac_common_stop()
287 struct prueth_emac *emac = netdev_priv(ndev); in emac_adjust_link() local
289 struct prueth *prueth = emac->prueth; in emac_adjust_link()
295 if (phydev->duplex != emac->duplex) { in emac_adjust_link()
297 emac->duplex = phydev->duplex; in emac_adjust_link()
299 if (phydev->speed != emac->speed) { in emac_adjust_link()
301 emac->speed = phydev->speed; in emac_adjust_link()
303 if (!emac->link) { in emac_adjust_link()
305 emac->link = 1; in emac_adjust_link()
307 } else if (emac->link) { in emac_adjust_link()
309 emac->link = 0; in emac_adjust_link()
312 emac->speed = SPEED_1000; in emac_adjust_link()
315 emac->duplex = DUPLEX_FULL; in emac_adjust_link()
324 if (emac->link) { in emac_adjust_link()
325 if (emac->duplex == DUPLEX_HALF) in emac_adjust_link()
326 icssg_config_half_duplex(emac); in emac_adjust_link()
328 icssg_update_rgmii_cfg(prueth->miig_rt, emac); in emac_adjust_link()
331 spin_lock_irqsave(&emac->lock, flags); in emac_adjust_link()
332 icssg_config_ipg(emac); in emac_adjust_link()
333 spin_unlock_irqrestore(&emac->lock, flags); in emac_adjust_link()
334 icssg_config_set_speed(emac); in emac_adjust_link()
335 icssg_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD); in emac_adjust_link()
338 icssg_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); in emac_adjust_link()
342 if (emac->link) { in emac_adjust_link()
347 prueth_cleanup_tx_ts(emac); in emac_adjust_link()
353 struct prueth_emac *emac = in emac_rx_timer_callback() local
357 enable_irq(emac->rx_chns.irq[rx_flow]); in emac_rx_timer_callback()
361 static int emac_phy_connect(struct prueth_emac *emac) in emac_phy_connect() argument
363 struct prueth *prueth = emac->prueth; in emac_phy_connect()
364 struct net_device *ndev = emac->ndev; in emac_phy_connect()
366 ndev->phydev = of_phy_connect(emac->ndev, emac->phy_node, in emac_phy_connect()
368 emac->phy_if); in emac_phy_connect()
371 emac->phy_node->full_name); in emac_phy_connect()
375 if (!emac->half_duplex) { in emac_phy_connect()
386 if (emac->phy_if == PHY_INTERFACE_MODE_MII) in emac_phy_connect()
395 struct prueth_emac *emac = clockops_data; in prueth_iep_gettime() local
396 struct prueth *prueth = emac->prueth; in prueth_iep_gettime()
409 iepcount_hi = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
413 iepcount_lo = icss_iep_get_count_low(emac->iep); in prueth_iep_gettime()
416 iepcount_hi_r = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
432 struct prueth_emac *emac = clockops_data; in prueth_iep_settime() local
438 sc_descp = emac->prueth->shram.va + TIMESYNC_FW_WC_SETCLOCK_DESC_OFFSET; in prueth_iep_settime()
448 /* Count from 0 to (cycle time) - emac->iep->def_inc */ in prueth_iep_settime()
449 sc_desc.CMP0_current = cycletime - emac->iep->def_inc; in prueth_iep_settime()
463 dev_err(emac->prueth->dev, "settime timeout\n"); in prueth_iep_settime()
470 struct prueth_emac *emac = clockops_data; in prueth_perout_enable() local
510 writel(reduction_factor, emac->prueth->shram.va + in prueth_perout_enable()
513 current_cycle = icssg_read_time(emac->prueth->shram.va + in prueth_perout_enable()
519 hi_lo_writeq(start_offset, emac->prueth->shram.va + in prueth_perout_enable()
531 static int prueth_create_xdp_rxqs(struct prueth_emac *emac) in prueth_create_xdp_rxqs() argument
533 struct xdp_rxq_info *rxq = &emac->rx_chns.xdp_rxq; in prueth_create_xdp_rxqs()
534 struct page_pool *pool = emac->rx_chns.pg_pool; in prueth_create_xdp_rxqs()
537 ret = xdp_rxq_info_reg(rxq, emac->ndev, 0, emac->napi_rx.napi_id); in prueth_create_xdp_rxqs()
548 static void prueth_destroy_xdp_rxqs(struct prueth_emac *emac) in prueth_destroy_xdp_rxqs() argument
550 struct xdp_rxq_info *rxq = &emac->rx_chns.xdp_rxq; in prueth_destroy_xdp_rxqs()
561 struct prueth_emac *emac; in icssg_prueth_add_mcast() local
567 emac = netdev_priv(real_dev); in icssg_prueth_add_mcast()
569 port_mask = BIT(emac->port_id) | icssg_fdb_lookup(emac, addr, vlan_id); in icssg_prueth_add_mcast()
570 icssg_fdb_add_del(emac, addr, vlan_id, port_mask, true); in icssg_prueth_add_mcast()
571 icssg_vtbl_modify(emac, vlan_id, port_mask, port_mask, true); in icssg_prueth_add_mcast()
579 struct prueth_emac *emac; in icssg_prueth_del_mcast() local
586 emac = netdev_priv(real_dev); in icssg_prueth_del_mcast()
588 port_mask = BIT(emac->port_id); in icssg_prueth_del_mcast()
589 other_port_mask = port_mask ^ icssg_fdb_lookup(emac, addr, vlan_id); in icssg_prueth_del_mcast()
591 icssg_fdb_add_del(emac, addr, vlan_id, port_mask, false); in icssg_prueth_del_mcast()
592 icssg_vtbl_modify(emac, vlan_id, port_mask, port_mask, false); in icssg_prueth_del_mcast()
595 icssg_fdb_add_del(emac, addr, vlan_id, other_port_mask, true); in icssg_prueth_del_mcast()
596 icssg_vtbl_modify(emac, vlan_id, other_port_mask, in icssg_prueth_del_mcast()
603 static void icssg_prueth_hsr_fdb_add_del(struct prueth_emac *emac, in icssg_prueth_hsr_fdb_add_del() argument
606 icssg_fdb_add_del(emac, addr, vid, in icssg_prueth_hsr_fdb_add_del()
613 icssg_vtbl_modify(emac, vid, BIT(emac->port_id), in icssg_prueth_hsr_fdb_add_del()
614 BIT(emac->port_id), add); in icssg_prueth_hsr_fdb_add_del()
620 struct prueth_emac *emac; in icssg_prueth_hsr_add_mcast() local
628 emac = netdev_priv(hsr_get_port_ndev(real_dev, i)); in icssg_prueth_hsr_add_mcast()
629 if (!emac) in icssg_prueth_hsr_add_mcast()
631 icssg_prueth_hsr_fdb_add_del(emac, addr, vlan_id, in icssg_prueth_hsr_add_mcast()
635 emac = netdev_priv(real_dev); in icssg_prueth_hsr_add_mcast()
636 icssg_prueth_hsr_fdb_add_del(emac, addr, vlan_id, true); in icssg_prueth_hsr_add_mcast()
645 struct prueth_emac *emac; in icssg_prueth_hsr_del_mcast() local
653 emac = netdev_priv(hsr_get_port_ndev(real_dev, i)); in icssg_prueth_hsr_del_mcast()
654 if (!emac) in icssg_prueth_hsr_del_mcast()
656 icssg_prueth_hsr_fdb_add_del(emac, addr, vlan_id, in icssg_prueth_hsr_del_mcast()
660 emac = netdev_priv(real_dev); in icssg_prueth_hsr_del_mcast()
661 icssg_prueth_hsr_fdb_add_del(emac, addr, vlan_id, false); in icssg_prueth_hsr_del_mcast()
670 struct prueth_emac *emac = args; in icssg_update_vlan_mcast() local
676 __hw_addr_sync_multiple(&emac->vlan_mcast_list[vid], &vdev->mc, in icssg_update_vlan_mcast()
680 if (emac->prueth->is_hsr_offload_mode) in icssg_update_vlan_mcast()
681 __hw_addr_sync_dev(&emac->vlan_mcast_list[vid], vdev, in icssg_update_vlan_mcast()
685 __hw_addr_sync_dev(&emac->vlan_mcast_list[vid], vdev, in icssg_update_vlan_mcast()
693 * emac_ndo_open - EMAC device open
702 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_open() local
703 int ret, i, num_data_chn = emac->tx_ch_num; in emac_ndo_open()
705 struct prueth *prueth = emac->prueth; in emac_ndo_open()
706 int slice = prueth_emac_slice(emac); in emac_ndo_open()
712 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in emac_ndo_open()
714 icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
715 icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
724 init_completion(&emac->cmd_complete); in emac_ndo_open()
725 ret = prueth_init_tx_chns(emac); in emac_ndo_open()
732 ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", in emac_ndo_open()
739 ret = prueth_ndev_add_tx_napi(emac); in emac_ndo_open()
745 ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, in emac_ndo_open()
746 IRQF_TRIGGER_HIGH, dev_name(dev), emac); in emac_ndo_open()
758 flow_cfg = emac->dram.va + ICSSG_CONFIG_OFFSET + PSI_L_REGULAR_FLOW_ID_BASE_OFFSET; in emac_ndo_open()
759 writew(emac->rx_flow_id_base, &flow_cfg->rx_base_flow); in emac_ndo_open()
760 ret = emac_fdb_flow_id_updated(emac); in emac_ndo_open()
769 ret = request_threaded_irq(emac->tx_ts_irq, NULL, prueth_tx_ts_irq, in emac_ndo_open()
770 IRQF_ONESHOT, dev_name(dev), emac); in emac_ndo_open()
775 ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE); in emac_ndo_open()
779 ret = prueth_create_xdp_rxqs(emac); in emac_ndo_open()
783 ret = k3_udma_glue_enable_rx_chn(emac->rx_chns.rx_chn); in emac_ndo_open()
787 for (i = 0; i < emac->tx_ch_num; i++) { in emac_ndo_open()
788 ret = k3_udma_glue_enable_tx_chn(emac->tx_chns[i].tx_chn); in emac_ndo_open()
794 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_open()
795 napi_enable(&emac->tx_chns[i].napi_tx); in emac_ndo_open()
796 napi_enable(&emac->napi_rx); in emac_ndo_open()
803 queue_work(system_long_wq, &emac->stats_work.work); in emac_ndo_open()
811 prueth_reset_tx_chan(emac, i, false); in emac_ndo_open()
813 prueth_destroy_xdp_rxqs(emac); in emac_ndo_open()
815 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, false); in emac_ndo_open()
817 free_irq(emac->tx_ts_irq, emac); in emac_ndo_open()
822 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_open()
824 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_open()
826 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_open()
828 prueth_cleanup_tx_chns(emac); in emac_ndo_open()
834 * emac_ndo_stop - EMAC device stop
843 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_stop() local
844 struct prueth *prueth = emac->prueth; in emac_ndo_stop()
856 if (emac->prueth->is_hsr_offload_mode) in emac_ndo_stop()
861 atomic_set(&emac->tdown_cnt, emac->tx_ch_num); in emac_ndo_stop()
865 reinit_completion(&emac->tdown_complete); in emac_ndo_stop()
866 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
867 k3_udma_glue_tdown_tx_chn(emac->tx_chns[i].tx_chn, false); in emac_ndo_stop()
869 ret = wait_for_completion_timeout(&emac->tdown_complete, in emac_ndo_stop()
874 prueth_reset_tx_chan(emac, emac->tx_ch_num, true); in emac_ndo_stop()
875 for (i = 0; i < emac->tx_ch_num; i++) { in emac_ndo_stop()
876 napi_disable(&emac->tx_chns[i].napi_tx); in emac_ndo_stop()
877 hrtimer_cancel(&emac->tx_chns[i].tx_hrtimer); in emac_ndo_stop()
881 k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true); in emac_ndo_stop()
883 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true); in emac_ndo_stop()
884 prueth_destroy_xdp_rxqs(emac); in emac_ndo_stop()
885 napi_disable(&emac->napi_rx); in emac_ndo_stop()
886 hrtimer_cancel(&emac->rx_hrtimer); in emac_ndo_stop()
888 cancel_work_sync(&emac->rx_mode_work); in emac_ndo_stop()
891 cancel_delayed_work_sync(&emac->stats_work); in emac_ndo_stop()
897 free_irq(emac->tx_ts_irq, emac); in emac_ndo_stop()
899 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_stop()
900 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_stop()
902 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_stop()
903 prueth_cleanup_tx_chns(emac); in emac_ndo_stop()
912 struct prueth_emac *emac = container_of(work, struct prueth_emac, rx_mode_work); in emac_ndo_set_rx_mode_work() local
913 struct net_device *ndev = emac->ndev; in emac_ndo_set_rx_mode_work()
921 icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
922 icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
925 icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
926 icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
931 icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
935 if (emac->prueth->is_hsr_offload_mode) { in emac_ndo_set_rx_mode_work()
939 vlan_for_each(emac->prueth->hsr_dev, in emac_ndo_set_rx_mode_work()
940 icssg_update_vlan_mcast, emac); in emac_ndo_set_rx_mode_work()
947 vlan_for_each(ndev, icssg_update_vlan_mcast, emac); in emac_ndo_set_rx_mode_work()
954 * emac_ndo_set_rx_mode - EMAC set receive mode function
955 * @ndev: The EMAC network adapter
962 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_set_rx_mode() local
964 queue_work(emac->cmd_wq, &emac->rx_mode_work); in emac_ndo_set_rx_mode()
993 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_vlan_rx_add_vid() local
994 struct prueth *prueth = emac->prueth; in emac_ndo_vlan_rx_add_vid()
995 int port_mask = BIT(emac->port_id); in emac_ndo_vlan_rx_add_vid()
1001 __hw_addr_init(&emac->vlan_mcast_list[vid]); in emac_ndo_vlan_rx_add_vid()
1002 netdev_dbg(emac->ndev, "VID add vid:%u port_mask:%X untag_mask %X\n", in emac_ndo_vlan_rx_add_vid()
1005 icssg_vtbl_modify(emac, vid, port_mask, untag_mask, true); in emac_ndo_vlan_rx_add_vid()
1006 icssg_set_pvid(emac->prueth, vid, emac->port_id); in emac_ndo_vlan_rx_add_vid()
1014 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_vlan_rx_del_vid() local
1015 struct prueth *prueth = emac->prueth; in emac_ndo_vlan_rx_del_vid()
1016 int port_mask = BIT(emac->port_id); in emac_ndo_vlan_rx_del_vid()
1022 netdev_dbg(emac->ndev, "VID del vid:%u port_mask:%X untag_mask %X\n", in emac_ndo_vlan_rx_del_vid()
1024 icssg_vtbl_modify(emac, vid, port_mask, untag_mask, false); in emac_ndo_vlan_rx_del_vid()
1045 struct prueth_emac *emac = netdev_priv(dev); in emac_xdp_xmit() local
1046 struct net_device *ndev = emac->ndev; in emac_xdp_xmit()
1055 q_idx = cpu % emac->tx_ch_num; in emac_xdp_xmit()
1064 err = emac_xmit_xdp_frame(emac, xdpf, NULL, q_idx); in emac_xdp_xmit()
1078 * @emac: emac device
1083 static int emac_xdp_setup(struct prueth_emac *emac, struct netdev_bpf *bpf) in emac_xdp_setup() argument
1087 if (!emac->xdpi.prog && !prog) in emac_xdp_setup()
1090 WRITE_ONCE(emac->xdp_prog, prog); in emac_xdp_setup()
1092 xdp_attachment_setup(&emac->xdpi, bpf); in emac_xdp_setup()
1106 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_bpf() local
1110 return emac_xdp_setup(emac, bpf); in emac_ndo_bpf()
1138 struct prueth_emac *emac; in prueth_netdev_init() local
1152 ndev = alloc_etherdev_mq(sizeof(*emac), num_tx_chn); in prueth_netdev_init()
1156 emac = netdev_priv(ndev); in prueth_netdev_init()
1157 emac->prueth = prueth; in prueth_netdev_init()
1158 emac->ndev = ndev; in prueth_netdev_init()
1159 emac->port_id = port; in prueth_netdev_init()
1160 emac->xdp_prog = NULL; in prueth_netdev_init()
1161 emac->ndev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; in prueth_netdev_init()
1162 emac->cmd_wq = create_singlethread_workqueue("icssg_cmd_wq"); in prueth_netdev_init()
1163 if (!emac->cmd_wq) { in prueth_netdev_init()
1167 INIT_WORK(&emac->rx_mode_work, emac_ndo_set_rx_mode_work); in prueth_netdev_init()
1169 INIT_DELAYED_WORK(&emac->stats_work, icssg_stats_work_handler); in prueth_netdev_init()
1174 &emac->dram); in prueth_netdev_init()
1181 emac->tx_ch_num = 1; in prueth_netdev_init()
1184 if (emac->port_id == PRUETH_PORT_MII1) in prueth_netdev_init()
1186 emac->tx_ts_irq = platform_get_irq_byname_optional(prueth->pdev, irq_name); in prueth_netdev_init()
1187 if (emac->tx_ts_irq < 0) { in prueth_netdev_init()
1188 ret = dev_err_probe(prueth->dev, emac->tx_ts_irq, "could not get tx_ts_irq\n"); in prueth_netdev_init()
1193 spin_lock_init(&emac->lock); in prueth_netdev_init()
1194 mutex_init(&emac->cmd_lock); in prueth_netdev_init()
1196 emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0); in prueth_netdev_init()
1197 if (!emac->phy_node && !of_phy_is_fixed_link(eth_node)) { in prueth_netdev_init()
1209 emac->phy_node = eth_node; in prueth_netdev_init()
1212 ret = of_get_phy_mode(eth_node, &emac->phy_if); in prueth_netdev_init()
1218 if (emac->phy_if != PHY_INTERFACE_MODE_MII && in prueth_netdev_init()
1219 !phy_interface_mode_is_rgmii(emac->phy_if)) { in prueth_netdev_init()
1220 dev_err(prueth->dev, "PHY mode unsupported %s\n", phy_modes(emac->phy_if)); in prueth_netdev_init()
1230 switch (emac->phy_if) { in prueth_netdev_init()
1232 emac->phy_if = PHY_INTERFACE_MODE_RGMII_RXID; in prueth_netdev_init()
1235 emac->phy_if = PHY_INTERFACE_MODE_RGMII; in prueth_netdev_init()
1253 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in prueth_netdev_init()
1268 netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll); in prueth_netdev_init()
1269 hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC, in prueth_netdev_init()
1271 prueth->emac[mac] = emac; in prueth_netdev_init()
1276 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_init()
1278 destroy_workqueue(emac->cmd_wq); in prueth_netdev_init()
1280 emac->ndev = NULL; in prueth_netdev_init()
1281 prueth->emac[mac] = NULL; in prueth_netdev_init()
1290 struct prueth_emac *emac = netdev_priv(ndev); in prueth_dev_check() local
1292 return emac->prueth->is_switch_mode; in prueth_dev_check()
1309 struct prueth_emac *emac = prueth->emac[i]; in prueth_offload_fwd_mark_update() local
1311 if (!emac || !emac->ndev) in prueth_offload_fwd_mark_update()
1314 emac->offload_fwd_mark = set_val; in prueth_offload_fwd_mark_update()
1320 struct prueth_emac *emac0 = prueth->emac[PRUETH_MAC0]; in prueth_emac_restart()
1321 struct prueth_emac *emac1 = prueth->emac[PRUETH_MAC1]; in prueth_emac_restart()
1363 struct prueth_emac *emac; in icssg_change_mode() local
1373 emac = prueth->emac[mac]; in icssg_change_mode()
1375 if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM) in icssg_change_mode()
1376 icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE); in icssg_change_mode()
1378 icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE); in icssg_change_mode()
1381 if (netif_running(emac->ndev)) { in icssg_change_mode()
1382 icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan, in icssg_change_mode()
1388 icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID, in icssg_change_mode()
1389 BIT(emac->port_id) | DEFAULT_PORT_MASK, in icssg_change_mode()
1390 BIT(emac->port_id) | DEFAULT_UNTAG_MASK, in icssg_change_mode()
1393 icssg_vtbl_modify(emac, DEFAULT_VID, in icssg_change_mode()
1396 icssg_set_pvid(prueth, emac->port_vlan, emac->port_id); in icssg_change_mode()
1398 icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE); in icssg_change_mode()
1407 struct prueth_emac *emac = netdev_priv(ndev); in prueth_netdevice_port_link() local
1408 struct prueth *prueth = emac->prueth; in prueth_netdevice_port_link()
1421 err = switchdev_bridge_port_offload(br_ndev, ndev, emac, in prueth_netdevice_port_link()
1428 prueth->br_members |= BIT(emac->port_id); in prueth_netdevice_port_link()
1435 emac->port_vlan = prueth->default_vlan; in prueth_netdevice_port_link()
1447 struct prueth_emac *emac = netdev_priv(ndev); in prueth_netdevice_port_unlink() local
1448 struct prueth *prueth = emac->prueth; in prueth_netdevice_port_unlink()
1451 prueth->br_members &= ~BIT(emac->port_id); in prueth_netdevice_port_unlink()
1455 emac->port_vlan = 0; in prueth_netdevice_port_unlink()
1471 struct prueth_emac *emac = netdev_priv(ndev); in prueth_hsr_port_link() local
1472 struct prueth *prueth = emac->prueth; in prueth_hsr_port_link()
1476 emac0 = prueth->emac[PRUETH_MAC0]; in prueth_hsr_port_link()
1477 emac1 = prueth->emac[PRUETH_MAC1]; in prueth_hsr_port_link()
1482 prueth->hsr_members |= BIT(emac->port_id); in prueth_hsr_port_link()
1505 struct prueth_emac *emac = netdev_priv(ndev); in prueth_hsr_port_unlink() local
1506 struct prueth *prueth = emac->prueth; in prueth_hsr_port_unlink()
1511 emac0 = prueth->emac[PRUETH_MAC0]; in prueth_hsr_port_unlink()
1512 emac1 = prueth->emac[PRUETH_MAC1]; in prueth_hsr_port_unlink()
1514 prueth->hsr_members &= ~BIT(emac->port_id); in prueth_hsr_port_unlink()
1536 struct prueth_emac *emac = netdev_priv(ndev); in prueth_netdevice_event() local
1537 struct prueth *prueth = emac->prueth; in prueth_netdevice_event()
1872 /* Read EMAC firmware names from device tree */ in prueth_probe()
1875 /* Generate other mode firmware names based on EMAC firmware names */ in prueth_probe()
1894 prueth->emac[PRUETH_MAC0]->half_duplex = in prueth_probe()
1897 prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; in prueth_probe()
1908 prueth->emac[PRUETH_MAC1]->half_duplex = in prueth_probe()
1911 prueth->emac[PRUETH_MAC1]->iep = prueth->iep0; in prueth_probe()
1916 ret = register_netdev(prueth->emac[PRUETH_MAC0]->ndev); in prueth_probe()
1922 prueth->registered_netdevs[PRUETH_MAC0] = prueth->emac[PRUETH_MAC0]->ndev; in prueth_probe()
1924 ret = emac_phy_connect(prueth->emac[PRUETH_MAC0]); in prueth_probe()
1930 phy_attached_info(prueth->emac[PRUETH_MAC0]->ndev->phydev); in prueth_probe()
1934 ret = register_netdev(prueth->emac[PRUETH_MAC1]->ndev); in prueth_probe()
1940 prueth->registered_netdevs[PRUETH_MAC1] = prueth->emac[PRUETH_MAC1]->ndev; in prueth_probe()
1941 ret = emac_phy_connect(prueth->emac[PRUETH_MAC1]); in prueth_probe()
1947 phy_attached_info(prueth->emac[PRUETH_MAC1]->ndev->phydev); in prueth_probe()
1958 dev_info(dev, "TI PRU ethernet driver initialized: %s EMAC mode\n", in prueth_probe()
1971 if (prueth->emac[i]->ndev->phydev) { in prueth_probe()
1972 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_probe()
1973 prueth->emac[i]->ndev->phydev = NULL; in prueth_probe()
2031 phy_stop(prueth->emac[i]->ndev->phydev); in prueth_remove()
2032 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_remove()
2033 prueth->emac[i]->ndev->phydev = NULL; in prueth_remove()