Lines Matching +full:fiber +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2014-2015 Hisilicon Limited.
57 switch (mac_cb->max_speed) { in hns_get_enet_interface()
59 return g_mac_mode_100[mac_cb->phy_if]; in hns_get_enet_interface()
61 return g_mac_mode_1000[mac_cb->phy_if]; in hns_get_enet_interface()
77 if (!mac_ctrl_drv->get_link_status) in hns_mac_link_anti_shake()
82 mac_ctrl_drv->get_link_status(mac_ctrl_drv, &link_status); in hns_mac_link_anti_shake()
97 if (mac_ctrl_drv->get_link_status) in hns_mac_get_link_status()
98 mac_ctrl_drv->get_link_status(mac_ctrl_drv, link_status); in hns_mac_get_link_status()
102 if (mac_cb->media_type == HNAE_MEDIA_TYPE_FIBER) { in hns_mac_get_link_status()
103 ret = mac_cb->dsaf_dev->misc_op->get_sfp_prsnt(mac_cb, in hns_mac_get_link_status()
108 /* for FIBER port, it may have a fake link up. in hns_mac_get_link_status()
110 * anti-shake. the anti-shake time is base on tests. in hns_mac_get_link_status()
111 * only FIBER port need to do this. in hns_mac_get_link_status()
113 if (*link_status && !mac_cb->link) in hns_mac_get_link_status()
117 mac_cb->link = *link_status; in hns_mac_get_link_status()
128 if (!mac_ctrl_drv->get_info) in hns_mac_get_port_info()
129 return -ENODEV; in hns_mac_get_port_info()
131 mac_ctrl_drv->get_info(mac_ctrl_drv, &info); in hns_mac_get_port_info()
143 *hns_mac_need_adjust_link - check is need change mac speed and duplex register
153 mac_ctrl_drv = (struct mac_driver *)(mac_cb->priv.mac); in hns_mac_need_adjust_link()
155 if (mac_ctrl_drv->need_adjust_link) in hns_mac_need_adjust_link()
156 return mac_ctrl_drv->need_adjust_link(mac_ctrl_drv, in hns_mac_need_adjust_link()
167 mac_ctrl_drv = (struct mac_driver *)(mac_cb->priv.mac); in hns_mac_adjust_link()
169 mac_cb->speed = speed; in hns_mac_adjust_link()
170 mac_cb->half_duplex = !duplex; in hns_mac_adjust_link()
172 if (mac_ctrl_drv->adjust_link) { in hns_mac_adjust_link()
173 ret = mac_ctrl_drv->adjust_link(mac_ctrl_drv, in hns_mac_adjust_link()
176 dev_err(mac_cb->dev, in hns_mac_adjust_link()
178 mac_cb->dsaf_dev->ae_dev.name, in hns_mac_adjust_link()
179 mac_cb->mac_id, ret); in hns_mac_adjust_link()
186 *hns_mac_get_inner_port_num - get mac table inner port number
198 if (mac_cb->dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) { in hns_mac_get_inner_port_num()
199 if (mac_cb->mac_id != DSAF_MAX_PORT_NUM) { in hns_mac_get_inner_port_num()
200 dev_err(mac_cb->dev, in hns_mac_get_inner_port_num()
202 mac_cb->dsaf_dev->ae_dev.name, in hns_mac_get_inner_port_num()
203 mac_cb->mac_id, vmid); in hns_mac_get_inner_port_num()
204 return -EINVAL; in hns_mac_get_inner_port_num()
206 } else if (mac_cb->dsaf_dev->dsaf_mode < DSAF_MODE_MAX) { in hns_mac_get_inner_port_num()
207 if (mac_cb->mac_id >= DSAF_MAX_PORT_NUM) { in hns_mac_get_inner_port_num()
208 dev_err(mac_cb->dev, in hns_mac_get_inner_port_num()
210 mac_cb->dsaf_dev->ae_dev.name, in hns_mac_get_inner_port_num()
211 mac_cb->mac_id, vmid); in hns_mac_get_inner_port_num()
212 return -EINVAL; in hns_mac_get_inner_port_num()
215 dev_err(mac_cb->dev, "dsaf mode invalid, %s mac%d!\n", in hns_mac_get_inner_port_num()
216 mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id); in hns_mac_get_inner_port_num()
217 return -EINVAL; in hns_mac_get_inner_port_num()
220 if (vmid >= mac_cb->dsaf_dev->rcb_common[0]->max_vfn) { in hns_mac_get_inner_port_num()
221 dev_err(mac_cb->dev, "input invalid, %s mac%d vmid%d !\n", in hns_mac_get_inner_port_num()
222 mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id, vmid); in hns_mac_get_inner_port_num()
223 return -EINVAL; in hns_mac_get_inner_port_num()
226 q_num_per_vf = mac_cb->dsaf_dev->rcb_common[0]->max_q_per_vf; in hns_mac_get_inner_port_num()
227 vf_num_per_port = mac_cb->dsaf_dev->rcb_common[0]->max_vfn; in hns_mac_get_inner_port_num()
230 vf_num_per_port * q_num_per_vf * mac_cb->mac_id; in hns_mac_get_inner_port_num()
232 switch (mac_cb->dsaf_dev->dsaf_mode) { in hns_mac_get_inner_port_num()
254 dev_err(mac_cb->dev, "dsaf mode invalid, %s mac%d!\n", in hns_mac_get_inner_port_num()
255 mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id); in hns_mac_get_inner_port_num()
256 return -EINVAL; in hns_mac_get_inner_port_num()
266 *hns_mac_change_vf_addr - change vf mac address
276 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_change_vf_addr()
280 old_entry = &mac_cb->addr_entry_idx[vmid]; in hns_mac_change_vf_addr()
283 mac_entry.in_vlan_id = old_entry->vlan_id; in hns_mac_change_vf_addr()
284 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_change_vf_addr()
290 if ((old_entry->valid != 0) && in hns_mac_change_vf_addr()
291 (memcmp(old_entry->addr, in hns_mac_change_vf_addr()
294 old_entry->vlan_id, in hns_mac_change_vf_addr()
295 mac_cb->mac_id, in hns_mac_change_vf_addr()
296 old_entry->addr); in hns_mac_change_vf_addr()
306 if ((mac_ctrl_drv->set_mac_addr) && (vmid == 0)) in hns_mac_change_vf_addr()
307 mac_ctrl_drv->set_mac_addr(mac_cb->priv.mac, addr); in hns_mac_change_vf_addr()
309 memcpy(old_entry->addr, addr, sizeof(old_entry->addr)); in hns_mac_change_vf_addr()
310 old_entry->valid = 1; in hns_mac_change_vf_addr()
317 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_add_uc_addr()
322 return -ENOSPC; in hns_mac_add_uc_addr()
326 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_add_uc_addr()
337 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_rm_uc_addr()
342 return -ENOSPC; in hns_mac_rm_uc_addr()
346 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_rm_uc_addr()
358 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_set_multi()
364 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_set_multi()
372 dev_err(dsaf_dev->dev, in hns_mac_set_multi()
374 mac_cb->dsaf_dev->ae_dev.name, in hns_mac_set_multi()
375 mac_cb->mac_id, ret); in hns_mac_set_multi()
385 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_clr_multicast()
392 return hns_dsaf_clr_mac_mc_port(dsaf_dev, mac_cb->mac_id, port_num); in hns_mac_clr_multicast()
398 param->vaddr = mac_cb->vaddr; in hns_mac_param_get()
399 param->mac_mode = hns_get_enet_interface(mac_cb); in hns_mac_param_get()
400 ether_addr_copy(param->addr, mac_cb->addr_entry_idx[0].addr); in hns_mac_param_get()
401 param->mac_id = mac_cb->mac_id; in hns_mac_param_get()
402 param->dev = mac_cb->dev; in hns_mac_param_get()
406 * hns_mac_port_config_bc_en - set broadcast rx&tx enable
411 * return 0 - success , negative --fail
417 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_port_config_bc_en()
420 /* directy return ok in debug network mode */ in hns_mac_port_config_bc_en()
421 if (mac_cb->mac_type == HNAE_PORT_DEBUG) in hns_mac_port_config_bc_en()
427 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_port_config_bc_en()
441 * hns_mac_vm_config_bc_en - set broadcast rx&tx enable
445 * return 0 - success , negative --fail
450 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_mac_vm_config_bc_en()
455 if (mac_cb->mac_type == HNAE_PORT_DEBUG) in hns_mac_vm_config_bc_en()
458 uc_mac_entry = &mac_cb->addr_entry_idx[vmid]; in hns_mac_vm_config_bc_en()
462 mac_entry.in_vlan_id = uc_mac_entry->vlan_id; in hns_mac_vm_config_bc_en()
463 mac_entry.in_port_num = mac_cb->mac_id; in hns_mac_vm_config_bc_en()
483 if (drv->wait_fifo_clean) in hns_mac_wait_fifo_clean()
484 return drv->wait_fifo_clean(drv); in hns_mac_wait_fifo_clean()
492 bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver); in hns_mac_reset()
494 drv->mac_init(drv); in hns_mac_reset()
496 if (drv->config_max_frame_length) in hns_mac_reset()
497 drv->config_max_frame_length(drv, mac_cb->max_frm); in hns_mac_reset()
499 if (drv->set_tx_auto_pause_frames) in hns_mac_reset()
500 drv->set_tx_auto_pause_frames(drv, mac_cb->tx_pause_frm_time); in hns_mac_reset()
502 if (drv->set_an_mode) in hns_mac_reset()
503 drv->set_an_mode(drv, 1); in hns_mac_reset()
505 if (drv->mac_pausefrm_cfg) { in hns_mac_reset()
506 if (mac_cb->mac_type == HNAE_PORT_DEBUG) in hns_mac_reset()
507 drv->mac_pausefrm_cfg(drv, !is_ver1, !is_ver1); in hns_mac_reset()
509 drv->mac_pausefrm_cfg(drv, 0, 1); in hns_mac_reset()
519 return -EINVAL; in hns_mac_set_mtu()
521 if (!drv->config_max_frame_length) in hns_mac_set_mtu()
522 return -ECHILD; in hns_mac_set_mtu()
528 drv->config_max_frame_length(drv, new_frm); in hns_mac_set_mtu()
530 mac_cb->max_frm = new_frm; in hns_mac_set_mtu()
540 if (mac_drv->mac_en_flg == MAC_EN_FLAG_V) { in hns_mac_start()
542 mac_drv->virt_dev_num += 1; in hns_mac_start()
546 if (mac_drv->mac_enable) { in hns_mac_start()
547 mac_drv->mac_enable(mac_cb->priv.mac, MAC_COMM_MODE_RX_AND_TX); in hns_mac_start()
548 mac_drv->mac_en_flg = MAC_EN_FLAG_V; in hns_mac_start()
557 if (mac_ctrl_drv->virt_dev_num > 0) { in hns_mac_stop()
558 mac_ctrl_drv->virt_dev_num -= 1; in hns_mac_stop()
559 if (mac_ctrl_drv->virt_dev_num > 0) in hns_mac_stop()
563 if (mac_ctrl_drv->mac_disable) in hns_mac_stop()
564 mac_ctrl_drv->mac_disable(mac_cb->priv.mac, in hns_mac_stop()
567 mac_ctrl_drv->mac_en_flg = 0; in hns_mac_stop()
568 mac_cb->link = 0; in hns_mac_stop()
569 mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb); in hns_mac_stop()
573 * hns_mac_get_autoneg - get auto autonegotiation
576 * return 0 - success , negative --fail
582 if (mac_ctrl_drv->autoneg_stat) in hns_mac_get_autoneg()
583 mac_ctrl_drv->autoneg_stat(mac_ctrl_drv, auto_neg); in hns_mac_get_autoneg()
589 * hns_mac_get_pauseparam - set rx & tx pause parameter
593 * return 0 - success , negative --fail
599 if (mac_ctrl_drv->get_pause_enable) { in hns_mac_get_pauseparam()
600 mac_ctrl_drv->get_pause_enable(mac_ctrl_drv, rx_en, tx_en); in hns_mac_get_pauseparam()
608 * hns_mac_set_autoneg - set auto autonegotiation
611 * return 0 - success , negative --fail
617 if (mac_cb->phy_if == PHY_INTERFACE_MODE_XGMII && enable) { in hns_mac_set_autoneg()
618 dev_err(mac_cb->dev, "enabling autoneg is not allowed!\n"); in hns_mac_set_autoneg()
619 return -ENOTSUPP; in hns_mac_set_autoneg()
622 if (mac_ctrl_drv->set_an_mode) in hns_mac_set_autoneg()
623 mac_ctrl_drv->set_an_mode(mac_ctrl_drv, enable); in hns_mac_set_autoneg()
629 * hns_mac_set_pauseparam - set rx & tx pause parameter
633 * return 0 - success , negative --fail
638 bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver); in hns_mac_set_pauseparam()
640 if (mac_cb->mac_type == HNAE_PORT_DEBUG) { in hns_mac_set_pauseparam()
642 dev_err(mac_cb->dev, "macv1 can't enable tx/rx_pause!\n"); in hns_mac_set_pauseparam()
643 return -EINVAL; in hns_mac_set_pauseparam()
647 if (mac_ctrl_drv->mac_pausefrm_cfg) in hns_mac_set_pauseparam()
648 mac_ctrl_drv->mac_pausefrm_cfg(mac_ctrl_drv, rx_en, tx_en); in hns_mac_set_pauseparam()
654 * hns_mac_init_ex - mac init
656 * return 0 - success , negative --fail
675 return -ENOMEM; in hns_mac_init_ex()
677 mac_cb->priv.mac = (void *)drv; in hns_mac_init_ex()
680 hns_mac_adjust_link(mac_cb, mac_cb->speed, !mac_cb->half_duplex); in hns_mac_init_ex()
682 ret = hns_mac_port_config_bc_en(mac_cb, mac_cb->mac_id, 0, true); in hns_mac_init_ex()
689 drv->mac_free(mac_cb->priv.mac); in hns_mac_init_ex()
690 mac_cb->priv.mac = NULL; in hns_mac_init_ex()
701 ret = fwnode_property_read_u32(fwnode, "phy-addr", &addr); in hns_mac_phy_parse_addr()
709 return -EINVAL; in hns_mac_phy_parse_addr()
724 rc = fwnode_property_read_string(mac_cb->fw_port, in hns_mac_register_phydev()
725 "phy-mode", &phy_type); in hns_mac_register_phydev()
734 return -ENODATA; in hns_mac_register_phydev()
738 return -EIO; in hns_mac_register_phydev()
740 phy->irq = mdio->irq[addr]; in hns_mac_register_phydev()
748 dev_err(&mdio->dev, "registered phy fail at address %i\n", in hns_mac_register_phydev()
750 return -ENODEV; in hns_mac_register_phydev()
753 mac_cb->phy_dev = phy; in hns_mac_register_phydev()
755 dev_dbg(&mdio->dev, "registered phy at address %i\n", addr); in hns_mac_register_phydev()
769 if (!to_acpi_device_node(mac_cb->fw_port)) in hns_mac_register_phy()
770 return -ENODEV; in hns_mac_register_phy()
773 mac_cb->fw_port, "mdio-node", 0, &args); in hns_mac_register_phy()
777 return -EINVAL; in hns_mac_register_phy()
779 addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port); in hns_mac_register_phy()
786 dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n", in hns_mac_register_phy()
787 mac_cb->mac_id); in hns_mac_register_phy()
788 return -EINVAL; in hns_mac_register_phy()
793 dev_err(mac_cb->dev, in hns_mac_register_phy()
795 mac_cb->mac_id); in hns_mac_register_phy()
796 return -EPROBE_DEFER; in hns_mac_register_phy()
801 dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n", in hns_mac_register_phy()
802 mac_cb->mac_id, addr); in hns_mac_register_phy()
809 if (!to_acpi_device_node(mac_cb->fw_port) || !mac_cb->phy_dev) in hns_mac_remove_phydev()
812 phy_device_remove(mac_cb->phy_dev); in hns_mac_remove_phydev()
813 phy_device_free(mac_cb->phy_dev); in hns_mac_remove_phydev()
815 mac_cb->phy_dev = NULL; in hns_mac_remove_phydev()
825 {HNAE_MEDIA_TYPE_FIBER, "fiber" },
831 *hns_mac_get_info - get mac information from device node
833 * return: 0 --success, negative --fail
844 mac_cb->link = false; in hns_mac_get_info()
845 mac_cb->half_duplex = false; in hns_mac_get_info()
846 mac_cb->media_type = HNAE_MEDIA_TYPE_UNKNOWN; in hns_mac_get_info()
847 mac_cb->speed = mac_phy_to_speed[mac_cb->phy_if]; in hns_mac_get_info()
848 mac_cb->max_speed = mac_cb->speed; in hns_mac_get_info()
850 if (mac_cb->phy_if == PHY_INTERFACE_MODE_SGMII) { in hns_mac_get_info()
851 mac_cb->if_support = MAC_GMAC_SUPPORTED; in hns_mac_get_info()
852 mac_cb->if_support |= SUPPORTED_1000baseT_Full; in hns_mac_get_info()
853 } else if (mac_cb->phy_if == PHY_INTERFACE_MODE_XGMII) { in hns_mac_get_info()
854 mac_cb->if_support = SUPPORTED_10000baseR_FEC; in hns_mac_get_info()
855 mac_cb->if_support |= SUPPORTED_10000baseKR_Full; in hns_mac_get_info()
858 mac_cb->max_frm = MAC_DEFAULT_MTU; in hns_mac_get_info()
859 mac_cb->tx_pause_frm_time = MAC_DEFAULT_PAUSE_TIME; in hns_mac_get_info()
860 mac_cb->port_rst_off = mac_cb->mac_id; in hns_mac_get_info()
861 mac_cb->port_mode_off = 0; in hns_mac_get_info()
863 /* if the dsaf node doesn't contain a port subnode, get phy-handle in hns_mac_get_info()
866 if (!mac_cb->fw_port) { in hns_mac_get_info()
867 np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle", in hns_mac_get_info()
868 mac_cb->mac_id); in hns_mac_get_info()
869 mac_cb->phy_dev = of_phy_find_device(np); in hns_mac_get_info()
870 if (mac_cb->phy_dev) { in hns_mac_get_info()
874 put_device(&mac_cb->phy_dev->mdio.dev); in hns_mac_get_info()
876 dev_dbg(mac_cb->dev, "mac%d phy_node: %pOFn\n", in hns_mac_get_info()
877 mac_cb->mac_id, np); in hns_mac_get_info()
884 if (is_of_node(mac_cb->fw_port)) { in hns_mac_get_info()
886 np = of_parse_phandle(to_of_node(mac_cb->fw_port), in hns_mac_get_info()
887 "phy-handle", 0); in hns_mac_get_info()
888 mac_cb->phy_dev = of_phy_find_device(np); in hns_mac_get_info()
889 if (mac_cb->phy_dev) { in hns_mac_get_info()
893 put_device(&mac_cb->phy_dev->mdio.dev); in hns_mac_get_info()
894 dev_dbg(mac_cb->dev, "mac%d phy_node: %pOFn\n", in hns_mac_get_info()
895 mac_cb->mac_id, np); in hns_mac_get_info()
899 np = of_parse_phandle(to_of_node(mac_cb->fw_port), in hns_mac_get_info()
900 "serdes-syscon", 0); in hns_mac_get_info()
904 dev_err(mac_cb->dev, "serdes-syscon is needed!\n"); in hns_mac_get_info()
905 return -EINVAL; in hns_mac_get_info()
907 mac_cb->serdes_ctrl = syscon; in hns_mac_get_info()
909 ret = fwnode_property_read_u32(mac_cb->fw_port, in hns_mac_get_info()
910 "port-rst-offset", in hns_mac_get_info()
911 &mac_cb->port_rst_off); in hns_mac_get_info()
913 dev_dbg(mac_cb->dev, in hns_mac_get_info()
914 "mac%d port-rst-offset not found, use default value.\n", in hns_mac_get_info()
915 mac_cb->mac_id); in hns_mac_get_info()
918 ret = fwnode_property_read_u32(mac_cb->fw_port, in hns_mac_get_info()
919 "port-mode-offset", in hns_mac_get_info()
920 &mac_cb->port_mode_off); in hns_mac_get_info()
922 dev_dbg(mac_cb->dev, in hns_mac_get_info()
923 "mac%d port-mode-offset not found, use default value.\n", in hns_mac_get_info()
924 mac_cb->mac_id); in hns_mac_get_info()
928 to_of_node(mac_cb->fw_port), "cpld-syscon", 1, 0, in hns_mac_get_info()
931 dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n", in hns_mac_get_info()
932 mac_cb->mac_id); in hns_mac_get_info()
933 mac_cb->cpld_ctrl = NULL; in hns_mac_get_info()
938 dev_dbg(mac_cb->dev, "no cpld-syscon found!\n"); in hns_mac_get_info()
939 mac_cb->cpld_ctrl = NULL; in hns_mac_get_info()
941 mac_cb->cpld_ctrl = syscon; in hns_mac_get_info()
942 mac_cb->cpld_ctrl_reg = cpld_args.args[0]; in hns_mac_get_info()
945 } else if (is_acpi_node(mac_cb->fw_port)) { in hns_mac_get_info()
952 if (ret == -EPROBE_DEFER) in hns_mac_get_info()
955 dev_err(mac_cb->dev, "mac%d cannot find phy node\n", in hns_mac_get_info()
956 mac_cb->mac_id); in hns_mac_get_info()
959 if (!fwnode_property_read_string(mac_cb->fw_port, "media-type", in hns_mac_get_info()
964 mac_cb->media_type = media_type_defs[i].value; in hns_mac_get_info()
970 if (fwnode_property_read_u8_array(mac_cb->fw_port, "mc-mac-mask", in hns_mac_get_info()
971 mac_cb->mc_mask, ETH_ALEN)) { in hns_mac_get_info()
972 dev_warn(mac_cb->dev, in hns_mac_get_info()
973 "no mc-mac-mask property, set to default value.\n"); in hns_mac_get_info()
974 eth_broadcast_addr(mac_cb->mc_mask); in hns_mac_get_info()
981 * hns_mac_get_mode - get mac mode
983 * return 0 - gmac, 1 - xgmac , negative --fail
993 return -EINVAL; in hns_mac_get_mode()
1001 u8 __iomem *base = dsaf_dev->io_base; in hns_mac_get_vaddr()
1002 int mac_id = mac_cb->mac_id; in hns_mac_get_vaddr()
1004 if (mac_cb->mac_type == HNAE_PORT_SERVICE) in hns_mac_get_vaddr()
1005 return base + 0x40000 + mac_id * 0x4000 - in hns_mac_get_vaddr()
1008 return dsaf_dev->ppe_base + 0x1000; in hns_mac_get_vaddr()
1012 * hns_mac_get_cfg - get mac cfg from dtb or acpi table
1015 * return 0 - success , negative --fail
1023 mac_cb->dsaf_dev = dsaf_dev; in hns_mac_get_cfg()
1024 mac_cb->dev = dsaf_dev->dev; in hns_mac_get_cfg()
1026 mac_cb->sys_ctl_vaddr = dsaf_dev->sc_base; in hns_mac_get_cfg()
1027 mac_cb->serdes_vaddr = dsaf_dev->sds_base; in hns_mac_get_cfg()
1029 mac_cb->sfp_prsnt = 0; in hns_mac_get_cfg()
1030 mac_cb->txpkt_for_led = 0; in hns_mac_get_cfg()
1031 mac_cb->rxpkt_for_led = 0; in hns_mac_get_cfg()
1034 mac_cb->mac_type = HNAE_PORT_SERVICE; in hns_mac_get_cfg()
1036 mac_cb->mac_type = HNAE_PORT_DEBUG; in hns_mac_get_cfg()
1038 mac_cb->phy_if = dsaf_dev->misc_op->get_phy_if(mac_cb); in hns_mac_get_cfg()
1040 ret = hns_mac_get_mode(mac_cb->phy_if); in hns_mac_get_cfg()
1042 dev_err(dsaf_dev->dev, in hns_mac_get_cfg()
1044 mac_cb->mac_id, ret); in hns_mac_get_cfg()
1053 mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb); in hns_mac_get_cfg()
1054 mac_cb->vaddr = hns_mac_get_vaddr(dsaf_dev, mac_cb, mac_mode_idx); in hns_mac_get_cfg()
1067 void hns_mac_enable(struct hns_mac_cb *mac_cb, enum mac_commom_mode mode) in hns_mac_enable() argument
1071 mac_ctrl_drv->mac_enable(mac_cb->priv.mac, mode); in hns_mac_enable()
1074 void hns_mac_disable(struct hns_mac_cb *mac_cb, enum mac_commom_mode mode) in hns_mac_disable() argument
1078 mac_ctrl_drv->mac_disable(mac_cb->priv.mac, mode); in hns_mac_disable()
1082 * hns_mac_init - init mac
1084 * return 0 - success , negative --fail
1095 device_for_each_child_node(dsaf_dev->dev, child) { in hns_mac_init()
1099 dev_err(dsaf_dev->dev, in hns_mac_init()
1105 dev_err(dsaf_dev->dev, in hns_mac_init()
1107 return -EINVAL; in hns_mac_init()
1109 mac_cb = devm_kzalloc(dsaf_dev->dev, sizeof(*mac_cb), in hns_mac_init()
1113 return -ENOMEM; in hns_mac_init()
1115 mac_cb->fw_port = child; in hns_mac_init()
1116 mac_cb->mac_id = (u8)port_id; in hns_mac_init()
1117 dsaf_dev->mac_cb[port_id] = mac_cb; in hns_mac_init()
1126 mac_cb = devm_kzalloc(dsaf_dev->dev, sizeof(*mac_cb), in hns_mac_init()
1129 return -ENOMEM; in hns_mac_init()
1131 mac_cb->mac_id = port_id; in hns_mac_init()
1132 dsaf_dev->mac_cb[port_id] = mac_cb; in hns_mac_init()
1138 mac_cb = dsaf_dev->mac_cb[port_id]; in hns_mac_init()
1160 if (!dsaf_dev->mac_cb[i]) in hns_mac_uninit()
1163 dsaf_dev->misc_op->cpld_reset_led(dsaf_dev->mac_cb[i]); in hns_mac_uninit()
1164 hns_mac_remove_phydev(dsaf_dev->mac_cb[i]); in hns_mac_uninit()
1165 dsaf_dev->mac_cb[i] = NULL; in hns_mac_uninit()
1175 if (drv->config_loopback) in hns_mac_config_mac_loopback()
1176 ret = drv->config_loopback(drv, loop, en); in hns_mac_config_mac_loopback()
1178 ret = -ENOTSUPP; in hns_mac_config_mac_loopback()
1187 mac_ctrl_drv->update_stats(mac_ctrl_drv); in hns_mac_update_stats()
1194 mac_ctrl_drv->get_ethtool_stats(mac_ctrl_drv, data); in hns_mac_get_stats()
1202 mac_ctrl_drv->get_strings(stringset, data); in hns_mac_get_strings()
1209 return mac_ctrl_drv->get_sset_count(stringset); in hns_mac_get_sset_count()
1216 hns_dsaf_set_promisc_tcam(mac_cb->dsaf_dev, mac_cb->mac_id, !!en); in hns_mac_set_promisc()
1218 if (mac_ctrl_drv->set_promiscuous) in hns_mac_set_promisc()
1219 mac_ctrl_drv->set_promiscuous(mac_ctrl_drv, en); in hns_mac_set_promisc()
1226 return mac_ctrl_drv->get_regs_count(); in hns_mac_get_regs_count()
1233 mac_ctrl_drv->get_regs(mac_ctrl_drv, data); in hns_mac_get_regs()
1241 txpkts = mac_cb->txpkt_for_led - mac_cb->hw_stats.tx_good_pkts; in hns_set_led_opt()
1242 rxpkts = mac_cb->rxpkt_for_led - mac_cb->hw_stats.rx_good_pkts; in hns_set_led_opt()
1247 mac_cb->txpkt_for_led = mac_cb->hw_stats.tx_good_pkts; in hns_set_led_opt()
1248 mac_cb->rxpkt_for_led = mac_cb->hw_stats.rx_good_pkts; in hns_set_led_opt()
1249 mac_cb->dsaf_dev->misc_op->cpld_set_led(mac_cb, (int)mac_cb->link, in hns_set_led_opt()
1250 mac_cb->speed, nic_data); in hns_set_led_opt()
1259 return mac_cb->dsaf_dev->misc_op->cpld_set_led_id(mac_cb, status); in hns_cpld_led_set_id()