Lines Matching refs:memac
421 static int check_init_parameters(struct fman_mac *memac) in check_init_parameters() argument
423 if (!memac->exception_cb) { in check_init_parameters()
427 if (!memac->event_cb) { in check_init_parameters()
462 struct fman_mac *memac = (struct fman_mac *)handle; in memac_err_exception() local
463 struct memac_regs __iomem *regs = memac->regs; in memac_err_exception()
479 memac->exception_cb(memac->dev_id, FM_MAC_EX_TS_FIFO_ECC_ERR); in memac_err_exception()
481 memac->exception_cb(memac->dev_id, FM_MAC_EX_10G_TX_ECC_ER); in memac_err_exception()
483 memac->exception_cb(memac->dev_id, FM_MAC_EX_10G_RX_ECC_ER); in memac_err_exception()
488 struct fman_mac *memac = (struct fman_mac *)handle; in memac_exception() local
489 struct memac_regs __iomem *regs = memac->regs; in memac_exception()
505 memac->exception_cb(memac->dev_id, in memac_exception()
509 static void free_init_resources(struct fman_mac *memac) in free_init_resources() argument
511 fman_unregister_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in free_init_resources()
514 fman_unregister_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in free_init_resources()
518 free_hash_table(memac->multicast_addr_hash); in free_init_resources()
519 memac->multicast_addr_hash = NULL; in free_init_resources()
522 free_hash_table(memac->unicast_addr_hash); in free_init_resources()
523 memac->unicast_addr_hash = NULL; in free_init_resources()
526 static int memac_enable(struct fman_mac *memac) in memac_enable() argument
530 ret = phy_init(memac->serdes); in memac_enable()
532 dev_err(memac->dev_id->dev, in memac_enable()
537 ret = phy_power_on(memac->serdes); in memac_enable()
539 dev_err(memac->dev_id->dev, in memac_enable()
541 phy_exit(memac->serdes); in memac_enable()
547 static void memac_disable(struct fman_mac *memac) in memac_disable() argument
549 phy_power_off(memac->serdes); in memac_disable()
550 phy_exit(memac->serdes); in memac_disable()
553 static int memac_set_promiscuous(struct fman_mac *memac, bool new_val) in memac_set_promiscuous() argument
555 struct memac_regs __iomem *regs = memac->regs; in memac_set_promiscuous()
569 static int memac_set_tx_pause_frames(struct fman_mac *memac, u8 priority, in memac_set_tx_pause_frames() argument
572 struct memac_regs __iomem *regs = memac->regs; in memac_set_tx_pause_frames()
604 static int memac_accept_rx_pause_frames(struct fman_mac *memac, bool en) in memac_accept_rx_pause_frames() argument
606 struct memac_regs __iomem *regs = memac->regs; in memac_accept_rx_pause_frames()
623 struct fman_mac *memac = fman_config_to_mac(config)->fman_mac; in memac_get_caps() local
627 memac->rgmii_no_half_duplex) in memac_get_caps()
665 struct fman_mac *memac = fman_config_to_mac(config)->fman_mac; in memac_select_pcs() local
670 return memac->sgmii_pcs; in memac_select_pcs()
672 return memac->qsgmii_pcs; in memac_select_pcs()
674 return memac->xfi_pcs; in memac_select_pcs()
683 struct fman_mac *memac = fman_config_to_mac(config)->fman_mac; in memac_prepare() local
690 return phy_set_mode_ext(memac->serdes, PHY_MODE_ETHERNET, in memac_prepare()
716 struct fman_mac *memac = mac_dev->fman_mac; in memac_link_up() local
717 struct memac_regs __iomem *regs = memac->regs; in memac_link_up()
722 memac_set_tx_pause_frames(memac, 0, pause_time, 0); in memac_link_up()
723 memac_accept_rx_pause_frames(memac, rx_pause); in memac_link_up()
744 if (memac->fm_rev_info.major == 6 && in memac_link_up()
745 memac->fm_rev_info.minor == 4) in memac_link_up()
766 struct fman_mac *memac = fman_config_to_mac(config)->fman_mac; in memac_link_down() local
767 struct memac_regs __iomem *regs = memac->regs; in memac_link_down()
785 static int memac_modify_mac_address(struct fman_mac *memac, in memac_modify_mac_address() argument
788 add_addr_in_paddr(memac->regs, (const u8 *)(*enet_addr), 0); in memac_modify_mac_address()
793 static int memac_add_hash_mac_address(struct fman_mac *memac, in memac_add_hash_mac_address() argument
796 struct memac_regs __iomem *regs = memac->regs; in memac_add_hash_mac_address()
818 &memac->multicast_addr_hash->lsts[hash]); in memac_add_hash_mac_address()
824 static int memac_set_allmulti(struct fman_mac *memac, bool enable) in memac_set_allmulti() argument
827 struct memac_regs __iomem *regs = memac->regs; in memac_set_allmulti()
839 memac->allmulti_enabled = enable; in memac_set_allmulti()
844 static int memac_set_tstamp(struct fman_mac *memac, bool enable) in memac_set_tstamp() argument
849 static int memac_del_hash_mac_address(struct fman_mac *memac, in memac_del_hash_mac_address() argument
852 struct memac_regs __iomem *regs = memac->regs; in memac_del_hash_mac_address()
862 list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) { in memac_del_hash_mac_address()
871 if (!memac->allmulti_enabled) { in memac_del_hash_mac_address()
872 if (list_empty(&memac->multicast_addr_hash->lsts[hash])) in memac_del_hash_mac_address()
880 static int memac_set_exception(struct fman_mac *memac, in memac_set_exception() argument
888 memac->exceptions |= bit_mask; in memac_set_exception()
890 memac->exceptions &= ~bit_mask; in memac_set_exception()
895 set_exception(memac->regs, bit_mask, enable); in memac_set_exception()
900 static int memac_init(struct fman_mac *memac) in memac_init() argument
907 err = check_init_parameters(memac); in memac_init()
911 memac_drv_param = memac->memac_drv_param; in memac_init()
915 err = reset(memac->regs); in memac_init()
923 if (memac->addr != 0) { in memac_init()
924 MAKE_ENET_ADDR_FROM_UINT64(memac->addr, eth_addr); in memac_init()
925 add_addr_in_paddr(memac->regs, (const u8 *)eth_addr, 0); in memac_init()
928 init(memac->regs, memac->memac_drv_param, memac->exceptions); in memac_init()
933 if ((memac->fm_rev_info.major == 6) && in memac_init()
934 ((memac->fm_rev_info.minor == 0) || in memac_init()
935 (memac->fm_rev_info.minor == 3))) { in memac_init()
939 reg32 = ioread32be(&memac->regs->command_config); in memac_init()
941 iowrite32be(reg32, &memac->regs->command_config); in memac_init()
945 err = fman_set_mac_max_frame(memac->fm, memac->mac_id, in memac_init()
952 memac->multicast_addr_hash = alloc_hash_table(HASH_TABLE_SIZE); in memac_init()
953 if (!memac->multicast_addr_hash) { in memac_init()
954 free_init_resources(memac); in memac_init()
959 memac->unicast_addr_hash = alloc_hash_table(HASH_TABLE_SIZE); in memac_init()
960 if (!memac->unicast_addr_hash) { in memac_init()
961 free_init_resources(memac); in memac_init()
966 fman_register_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in memac_init()
967 FMAN_INTR_TYPE_ERR, memac_err_exception, memac); in memac_init()
969 fman_register_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in memac_init()
970 FMAN_INTR_TYPE_NORMAL, memac_exception, memac); in memac_init()
983 static int memac_free(struct fman_mac *memac) in memac_free() argument
985 free_init_resources(memac); in memac_free()
987 pcs_put(memac->sgmii_pcs); in memac_free()
988 pcs_put(memac->qsgmii_pcs); in memac_free()
989 pcs_put(memac->xfi_pcs); in memac_free()
990 kfree(memac->memac_drv_param); in memac_free()
991 kfree(memac); in memac_free()
999 struct fman_mac *memac; in memac_config() local
1003 memac = kzalloc(sizeof(*memac), GFP_KERNEL); in memac_config()
1004 if (!memac) in memac_config()
1010 memac_free(memac); in memac_config()
1015 memac->memac_drv_param = memac_drv_param; in memac_config()
1019 memac->addr = ENET_ADDR_TO_UINT64(mac_dev->addr); in memac_config()
1021 memac->regs = mac_dev->vaddr; in memac_config()
1022 memac->mac_id = params->mac_id; in memac_config()
1023 memac->exceptions = (MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | in memac_config()
1025 memac->exception_cb = params->exception_cb; in memac_config()
1026 memac->event_cb = params->event_cb; in memac_config()
1027 memac->dev_id = mac_dev; in memac_config()
1028 memac->fm = params->fm; in memac_config()
1031 fman_get_revision(memac->fm, &memac->fm_rev_info); in memac_config()
1033 return memac; in memac_config()
1070 struct fman_mac *memac; in memac_initialization() local
1098 memac = mac_dev->fman_mac; in memac_initialization()
1099 memac->memac_drv_param->max_frame_length = fman_get_max_frm(); in memac_initialization()
1100 memac->memac_drv_param->reset_on_init = true; in memac_initialization()
1104 memac->xfi_pcs = memac_pcs_create(mac_node, err); in memac_initialization()
1105 if (IS_ERR(memac->xfi_pcs)) { in memac_initialization()
1106 err = PTR_ERR(memac->xfi_pcs); in memac_initialization()
1116 memac->qsgmii_pcs = memac_pcs_create(mac_node, err); in memac_initialization()
1117 if (IS_ERR(memac->qsgmii_pcs)) { in memac_initialization()
1118 err = PTR_ERR(memac->qsgmii_pcs); in memac_initialization()
1149 memac->xfi_pcs = pcs; in memac_initialization()
1151 memac->sgmii_pcs = pcs; in memac_initialization()
1153 memac->serdes = devm_of_phy_optional_get(mac_dev->dev, mac_node, in memac_initialization()
1155 if (!memac->serdes) { in memac_initialization()
1157 } else if (IS_ERR(memac->serdes)) { in memac_initialization()
1158 err = PTR_ERR(memac->serdes); in memac_initialization()
1172 if (memac->sgmii_pcs && in memac_initialization()
1179 if (memac->sgmii_pcs && in memac_initialization()
1183 if (memac->qsgmii_pcs && in memac_initialization()
1189 if (memac->xfi_pcs && in memac_initialization()
1221 memac->rgmii_no_half_duplex = true; in memac_initialization()