Lines Matching refs:priv
163 static void stmmac_clk_csr_set(struct stmmac_priv *priv) in stmmac_clk_csr_set() argument
167 clk_rate = clk_get_rate(priv->stmmac_clk); in stmmac_clk_csr_set()
176 if (!(priv->clk_csr & MAC_CSR_H_FRQ_MASK)) { in stmmac_clk_csr_set()
178 priv->clk_csr = STMMAC_CSR_20_35M; in stmmac_clk_csr_set()
180 priv->clk_csr = STMMAC_CSR_35_60M; in stmmac_clk_csr_set()
182 priv->clk_csr = STMMAC_CSR_60_100M; in stmmac_clk_csr_set()
184 priv->clk_csr = STMMAC_CSR_100_150M; in stmmac_clk_csr_set()
186 priv->clk_csr = STMMAC_CSR_150_250M; in stmmac_clk_csr_set()
188 priv->clk_csr = STMMAC_CSR_250_300M; in stmmac_clk_csr_set()
201 static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) in stmmac_tx_avail() argument
203 return priv->dirty_tx + priv->dma_tx_size - priv->cur_tx - 1; in stmmac_tx_avail()
212 static inline void stmmac_hw_fix_mac_speed(struct stmmac_priv *priv) in stmmac_hw_fix_mac_speed() argument
214 struct phy_device *phydev = priv->phydev; in stmmac_hw_fix_mac_speed()
216 if (likely(priv->plat->fix_mac_speed)) in stmmac_hw_fix_mac_speed()
217 priv->plat->fix_mac_speed(priv->plat->bsp_priv, phydev->speed); in stmmac_hw_fix_mac_speed()
226 static void stmmac_enable_eee_mode(struct stmmac_priv *priv) in stmmac_enable_eee_mode() argument
229 if ((priv->dirty_tx == priv->cur_tx) && in stmmac_enable_eee_mode()
230 (priv->tx_path_in_lpi_mode == false)) in stmmac_enable_eee_mode()
231 priv->hw->mac->set_eee_mode(priv->hw); in stmmac_enable_eee_mode()
240 void stmmac_disable_eee_mode(struct stmmac_priv *priv) in stmmac_disable_eee_mode() argument
242 priv->hw->mac->reset_eee_mode(priv->hw); in stmmac_disable_eee_mode()
243 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_disable_eee_mode()
244 priv->tx_path_in_lpi_mode = false; in stmmac_disable_eee_mode()
256 struct stmmac_priv *priv = (struct stmmac_priv *)arg; in stmmac_eee_ctrl_timer() local
258 stmmac_enable_eee_mode(priv); in stmmac_eee_ctrl_timer()
259 mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(eee_timer)); in stmmac_eee_ctrl_timer()
270 bool stmmac_eee_init(struct stmmac_priv *priv) in stmmac_eee_init() argument
272 char *phy_bus_name = priv->plat->phy_bus_name; in stmmac_eee_init()
279 if ((priv->pcs == STMMAC_PCS_RGMII) || (priv->pcs == STMMAC_PCS_TBI) || in stmmac_eee_init()
280 (priv->pcs == STMMAC_PCS_RTBI)) in stmmac_eee_init()
288 if (priv->dma_cap.eee) { in stmmac_eee_init()
289 int tx_lpi_timer = priv->tx_lpi_timer; in stmmac_eee_init()
292 if (phy_init_eee(priv->phydev, 1)) { in stmmac_eee_init()
298 spin_lock_irqsave(&priv->lock, flags); in stmmac_eee_init()
299 if (priv->eee_active) { in stmmac_eee_init()
301 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_eee_init()
302 priv->hw->mac->set_eee_timer(priv->hw, 0, in stmmac_eee_init()
305 priv->eee_active = 0; in stmmac_eee_init()
306 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_eee_init()
310 spin_lock_irqsave(&priv->lock, flags); in stmmac_eee_init()
311 if (!priv->eee_active) { in stmmac_eee_init()
312 priv->eee_active = 1; in stmmac_eee_init()
313 setup_timer(&priv->eee_ctrl_timer, in stmmac_eee_init()
315 (unsigned long)priv); in stmmac_eee_init()
316 mod_timer(&priv->eee_ctrl_timer, in stmmac_eee_init()
319 priv->hw->mac->set_eee_timer(priv->hw, in stmmac_eee_init()
324 priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); in stmmac_eee_init()
327 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_eee_init()
343 static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, in stmmac_get_tx_hwtstamp() argument
350 if (!priv->hwts_tx_en) in stmmac_get_tx_hwtstamp()
357 if (priv->adv_ts) in stmmac_get_tx_hwtstamp()
358 desc = (priv->dma_etx + entry); in stmmac_get_tx_hwtstamp()
360 desc = (priv->dma_tx + entry); in stmmac_get_tx_hwtstamp()
363 if (!priv->hw->desc->get_tx_timestamp_status((struct dma_desc *)desc)) in stmmac_get_tx_hwtstamp()
367 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); in stmmac_get_tx_hwtstamp()
385 static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, in stmmac_get_rx_hwtstamp() argument
392 if (!priv->hwts_rx_en) in stmmac_get_rx_hwtstamp()
395 if (priv->adv_ts) in stmmac_get_rx_hwtstamp()
396 desc = (priv->dma_erx + entry); in stmmac_get_rx_hwtstamp()
398 desc = (priv->dma_rx + entry); in stmmac_get_rx_hwtstamp()
401 if (!priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) in stmmac_get_rx_hwtstamp()
405 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); in stmmac_get_rx_hwtstamp()
424 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_hwtstamp_ioctl() local
438 if (!(priv->dma_cap.time_stamp || priv->adv_ts)) { in stmmac_hwtstamp_ioctl()
439 netdev_alert(priv->dev, "No support for HW time stamping\n"); in stmmac_hwtstamp_ioctl()
440 priv->hwts_tx_en = 0; in stmmac_hwtstamp_ioctl()
441 priv->hwts_rx_en = 0; in stmmac_hwtstamp_ioctl()
461 if (priv->adv_ts) { in stmmac_hwtstamp_ioctl()
590 priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); in stmmac_hwtstamp_ioctl()
591 priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; in stmmac_hwtstamp_ioctl()
593 if (!priv->hwts_tx_en && !priv->hwts_rx_en) in stmmac_hwtstamp_ioctl()
594 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0); in stmmac_hwtstamp_ioctl()
601 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, value); in stmmac_hwtstamp_ioctl()
604 priv->hw->ptp->config_sub_second_increment(priv->ioaddr); in stmmac_hwtstamp_ioctl()
618 priv->default_addend = div_u64(temp, priv->clk_ptp_rate); in stmmac_hwtstamp_ioctl()
619 priv->hw->ptp->config_addend(priv->ioaddr, in stmmac_hwtstamp_ioctl()
620 priv->default_addend); in stmmac_hwtstamp_ioctl()
624 priv->hw->ptp->init_systime(priv->ioaddr, now.tv_sec, in stmmac_hwtstamp_ioctl()
639 static int stmmac_init_ptp(struct stmmac_priv *priv) in stmmac_init_ptp() argument
641 if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) in stmmac_init_ptp()
645 priv->clk_ptp_ref = devm_clk_get(priv->device, "clk_ptp_ref"); in stmmac_init_ptp()
646 if (IS_ERR(priv->clk_ptp_ref)) { in stmmac_init_ptp()
647 priv->clk_ptp_rate = clk_get_rate(priv->stmmac_clk); in stmmac_init_ptp()
648 priv->clk_ptp_ref = NULL; in stmmac_init_ptp()
650 clk_prepare_enable(priv->clk_ptp_ref); in stmmac_init_ptp()
651 priv->clk_ptp_rate = clk_get_rate(priv->clk_ptp_ref); in stmmac_init_ptp()
654 priv->adv_ts = 0; in stmmac_init_ptp()
655 if (priv->dma_cap.atime_stamp && priv->extend_desc) in stmmac_init_ptp()
656 priv->adv_ts = 1; in stmmac_init_ptp()
658 if (netif_msg_hw(priv) && priv->dma_cap.time_stamp) in stmmac_init_ptp()
661 if (netif_msg_hw(priv) && priv->adv_ts) in stmmac_init_ptp()
664 priv->hw->ptp = &stmmac_ptp; in stmmac_init_ptp()
665 priv->hwts_tx_en = 0; in stmmac_init_ptp()
666 priv->hwts_rx_en = 0; in stmmac_init_ptp()
668 return stmmac_ptp_register(priv); in stmmac_init_ptp()
671 static void stmmac_release_ptp(struct stmmac_priv *priv) in stmmac_release_ptp() argument
673 if (priv->clk_ptp_ref) in stmmac_release_ptp()
674 clk_disable_unprepare(priv->clk_ptp_ref); in stmmac_release_ptp()
675 stmmac_ptp_unregister(priv); in stmmac_release_ptp()
689 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_adjust_link() local
690 struct phy_device *phydev = priv->phydev; in stmmac_adjust_link()
693 unsigned int fc = priv->flow_ctrl, pause_time = priv->pause; in stmmac_adjust_link()
698 spin_lock_irqsave(&priv->lock, flags); in stmmac_adjust_link()
701 u32 ctrl = readl(priv->ioaddr + MAC_CTRL_REG); in stmmac_adjust_link()
705 if (phydev->duplex != priv->oldduplex) { in stmmac_adjust_link()
708 ctrl &= ~priv->hw->link.duplex; in stmmac_adjust_link()
710 ctrl |= priv->hw->link.duplex; in stmmac_adjust_link()
711 priv->oldduplex = phydev->duplex; in stmmac_adjust_link()
715 priv->hw->mac->flow_ctrl(priv->hw, phydev->duplex, in stmmac_adjust_link()
718 if (phydev->speed != priv->speed) { in stmmac_adjust_link()
722 if (likely(priv->plat->has_gmac)) in stmmac_adjust_link()
723 ctrl &= ~priv->hw->link.port; in stmmac_adjust_link()
724 stmmac_hw_fix_mac_speed(priv); in stmmac_adjust_link()
728 if (priv->plat->has_gmac) { in stmmac_adjust_link()
729 ctrl |= priv->hw->link.port; in stmmac_adjust_link()
731 ctrl |= priv->hw->link.speed; in stmmac_adjust_link()
733 ctrl &= ~(priv->hw->link.speed); in stmmac_adjust_link()
736 ctrl &= ~priv->hw->link.port; in stmmac_adjust_link()
738 stmmac_hw_fix_mac_speed(priv); in stmmac_adjust_link()
741 if (netif_msg_link(priv)) in stmmac_adjust_link()
747 priv->speed = phydev->speed; in stmmac_adjust_link()
750 writel(ctrl, priv->ioaddr + MAC_CTRL_REG); in stmmac_adjust_link()
752 if (!priv->oldlink) { in stmmac_adjust_link()
754 priv->oldlink = 1; in stmmac_adjust_link()
756 } else if (priv->oldlink) { in stmmac_adjust_link()
758 priv->oldlink = 0; in stmmac_adjust_link()
759 priv->speed = 0; in stmmac_adjust_link()
760 priv->oldduplex = -1; in stmmac_adjust_link()
763 if (new_state && netif_msg_link(priv)) in stmmac_adjust_link()
766 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_adjust_link()
771 priv->eee_enabled = stmmac_eee_init(priv); in stmmac_adjust_link()
781 static void stmmac_check_pcs_mode(struct stmmac_priv *priv) in stmmac_check_pcs_mode() argument
783 int interface = priv->plat->interface; in stmmac_check_pcs_mode()
785 if (priv->dma_cap.pcs) { in stmmac_check_pcs_mode()
791 priv->pcs = STMMAC_PCS_RGMII; in stmmac_check_pcs_mode()
794 priv->pcs = STMMAC_PCS_SGMII; in stmmac_check_pcs_mode()
809 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_init_phy() local
813 int interface = priv->plat->interface; in stmmac_init_phy()
814 int max_speed = priv->plat->max_speed; in stmmac_init_phy()
815 priv->oldlink = 0; in stmmac_init_phy()
816 priv->speed = 0; in stmmac_init_phy()
817 priv->oldduplex = -1; in stmmac_init_phy()
819 if (priv->plat->phy_bus_name) in stmmac_init_phy()
821 priv->plat->phy_bus_name, priv->plat->bus_id); in stmmac_init_phy()
824 priv->plat->bus_id); in stmmac_init_phy()
827 priv->plat->phy_addr); in stmmac_init_phy()
861 priv->phydev = phydev; in stmmac_init_phy()
900 static void stmmac_display_rings(struct stmmac_priv *priv) in stmmac_display_rings() argument
902 unsigned int txsize = priv->dma_tx_size; in stmmac_display_rings()
903 unsigned int rxsize = priv->dma_rx_size; in stmmac_display_rings()
905 if (priv->extend_desc) { in stmmac_display_rings()
907 stmmac_display_ring((void *)priv->dma_erx, rxsize, 1); in stmmac_display_rings()
909 stmmac_display_ring((void *)priv->dma_etx, txsize, 1); in stmmac_display_rings()
912 stmmac_display_ring((void *)priv->dma_rx, rxsize, 0); in stmmac_display_rings()
914 stmmac_display_ring((void *)priv->dma_tx, txsize, 0); in stmmac_display_rings()
940 static void stmmac_clear_descriptors(struct stmmac_priv *priv) in stmmac_clear_descriptors() argument
943 unsigned int txsize = priv->dma_tx_size; in stmmac_clear_descriptors()
944 unsigned int rxsize = priv->dma_rx_size; in stmmac_clear_descriptors()
948 if (priv->extend_desc) in stmmac_clear_descriptors()
949 priv->hw->desc->init_rx_desc(&priv->dma_erx[i].basic, in stmmac_clear_descriptors()
950 priv->use_riwt, priv->mode, in stmmac_clear_descriptors()
953 priv->hw->desc->init_rx_desc(&priv->dma_rx[i], in stmmac_clear_descriptors()
954 priv->use_riwt, priv->mode, in stmmac_clear_descriptors()
957 if (priv->extend_desc) in stmmac_clear_descriptors()
958 priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, in stmmac_clear_descriptors()
959 priv->mode, in stmmac_clear_descriptors()
962 priv->hw->desc->init_tx_desc(&priv->dma_tx[i], in stmmac_clear_descriptors()
963 priv->mode, in stmmac_clear_descriptors()
976 static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, in stmmac_init_rx_buffers() argument
981 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, in stmmac_init_rx_buffers()
988 priv->rx_skbuff[i] = skb; in stmmac_init_rx_buffers()
989 priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data, in stmmac_init_rx_buffers()
990 priv->dma_buf_sz, in stmmac_init_rx_buffers()
992 if (dma_mapping_error(priv->device, priv->rx_skbuff_dma[i])) { in stmmac_init_rx_buffers()
998 p->des2 = priv->rx_skbuff_dma[i]; in stmmac_init_rx_buffers()
1000 if ((priv->hw->mode->init_desc3) && in stmmac_init_rx_buffers()
1001 (priv->dma_buf_sz == BUF_SIZE_16KiB)) in stmmac_init_rx_buffers()
1002 priv->hw->mode->init_desc3(p); in stmmac_init_rx_buffers()
1007 static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i) in stmmac_free_rx_buffers() argument
1009 if (priv->rx_skbuff[i]) { in stmmac_free_rx_buffers()
1010 dma_unmap_single(priv->device, priv->rx_skbuff_dma[i], in stmmac_free_rx_buffers()
1011 priv->dma_buf_sz, DMA_FROM_DEVICE); in stmmac_free_rx_buffers()
1012 dev_kfree_skb_any(priv->rx_skbuff[i]); in stmmac_free_rx_buffers()
1014 priv->rx_skbuff[i] = NULL; in stmmac_free_rx_buffers()
1028 struct stmmac_priv *priv = netdev_priv(dev); in init_dma_desc_rings() local
1029 unsigned int txsize = priv->dma_tx_size; in init_dma_desc_rings()
1030 unsigned int rxsize = priv->dma_rx_size; in init_dma_desc_rings()
1034 if (priv->hw->mode->set_16kib_bfsize) in init_dma_desc_rings()
1035 bfsize = priv->hw->mode->set_16kib_bfsize(dev->mtu); in init_dma_desc_rings()
1038 bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz); in init_dma_desc_rings()
1040 priv->dma_buf_sz = bfsize; in init_dma_desc_rings()
1042 if (netif_msg_probe(priv)) in init_dma_desc_rings()
1046 if (netif_msg_probe(priv)) { in init_dma_desc_rings()
1048 (u32) priv->dma_rx_phy, (u32) priv->dma_tx_phy); in init_dma_desc_rings()
1055 if (priv->extend_desc) in init_dma_desc_rings()
1056 p = &((priv->dma_erx + i)->basic); in init_dma_desc_rings()
1058 p = priv->dma_rx + i; in init_dma_desc_rings()
1060 ret = stmmac_init_rx_buffers(priv, p, i, flags); in init_dma_desc_rings()
1064 if (netif_msg_probe(priv)) in init_dma_desc_rings()
1065 pr_debug("[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i], in init_dma_desc_rings()
1066 priv->rx_skbuff[i]->data, in init_dma_desc_rings()
1067 (unsigned int)priv->rx_skbuff_dma[i]); in init_dma_desc_rings()
1069 priv->cur_rx = 0; in init_dma_desc_rings()
1070 priv->dirty_rx = (unsigned int)(i - rxsize); in init_dma_desc_rings()
1074 if (priv->mode == STMMAC_CHAIN_MODE) { in init_dma_desc_rings()
1075 if (priv->extend_desc) { in init_dma_desc_rings()
1076 priv->hw->mode->init(priv->dma_erx, priv->dma_rx_phy, in init_dma_desc_rings()
1078 priv->hw->mode->init(priv->dma_etx, priv->dma_tx_phy, in init_dma_desc_rings()
1081 priv->hw->mode->init(priv->dma_rx, priv->dma_rx_phy, in init_dma_desc_rings()
1083 priv->hw->mode->init(priv->dma_tx, priv->dma_tx_phy, in init_dma_desc_rings()
1091 if (priv->extend_desc) in init_dma_desc_rings()
1092 p = &((priv->dma_etx + i)->basic); in init_dma_desc_rings()
1094 p = priv->dma_tx + i; in init_dma_desc_rings()
1096 priv->tx_skbuff_dma[i].buf = 0; in init_dma_desc_rings()
1097 priv->tx_skbuff_dma[i].map_as_page = false; in init_dma_desc_rings()
1098 priv->tx_skbuff[i] = NULL; in init_dma_desc_rings()
1101 priv->dirty_tx = 0; in init_dma_desc_rings()
1102 priv->cur_tx = 0; in init_dma_desc_rings()
1103 netdev_reset_queue(priv->dev); in init_dma_desc_rings()
1105 stmmac_clear_descriptors(priv); in init_dma_desc_rings()
1107 if (netif_msg_hw(priv)) in init_dma_desc_rings()
1108 stmmac_display_rings(priv); in init_dma_desc_rings()
1113 stmmac_free_rx_buffers(priv, i); in init_dma_desc_rings()
1117 static void dma_free_rx_skbufs(struct stmmac_priv *priv) in dma_free_rx_skbufs() argument
1121 for (i = 0; i < priv->dma_rx_size; i++) in dma_free_rx_skbufs()
1122 stmmac_free_rx_buffers(priv, i); in dma_free_rx_skbufs()
1125 static void dma_free_tx_skbufs(struct stmmac_priv *priv) in dma_free_tx_skbufs() argument
1129 for (i = 0; i < priv->dma_tx_size; i++) { in dma_free_tx_skbufs()
1132 if (priv->extend_desc) in dma_free_tx_skbufs()
1133 p = &((priv->dma_etx + i)->basic); in dma_free_tx_skbufs()
1135 p = priv->dma_tx + i; in dma_free_tx_skbufs()
1137 if (priv->tx_skbuff_dma[i].buf) { in dma_free_tx_skbufs()
1138 if (priv->tx_skbuff_dma[i].map_as_page) in dma_free_tx_skbufs()
1139 dma_unmap_page(priv->device, in dma_free_tx_skbufs()
1140 priv->tx_skbuff_dma[i].buf, in dma_free_tx_skbufs()
1141 priv->hw->desc->get_tx_len(p), in dma_free_tx_skbufs()
1144 dma_unmap_single(priv->device, in dma_free_tx_skbufs()
1145 priv->tx_skbuff_dma[i].buf, in dma_free_tx_skbufs()
1146 priv->hw->desc->get_tx_len(p), in dma_free_tx_skbufs()
1150 if (priv->tx_skbuff[i] != NULL) { in dma_free_tx_skbufs()
1151 dev_kfree_skb_any(priv->tx_skbuff[i]); in dma_free_tx_skbufs()
1152 priv->tx_skbuff[i] = NULL; in dma_free_tx_skbufs()
1153 priv->tx_skbuff_dma[i].buf = 0; in dma_free_tx_skbufs()
1154 priv->tx_skbuff_dma[i].map_as_page = false; in dma_free_tx_skbufs()
1167 static int alloc_dma_desc_resources(struct stmmac_priv *priv) in alloc_dma_desc_resources() argument
1169 unsigned int txsize = priv->dma_tx_size; in alloc_dma_desc_resources()
1170 unsigned int rxsize = priv->dma_rx_size; in alloc_dma_desc_resources()
1173 priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t), in alloc_dma_desc_resources()
1175 if (!priv->rx_skbuff_dma) in alloc_dma_desc_resources()
1178 priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *), in alloc_dma_desc_resources()
1180 if (!priv->rx_skbuff) in alloc_dma_desc_resources()
1183 priv->tx_skbuff_dma = kmalloc_array(txsize, in alloc_dma_desc_resources()
1184 sizeof(*priv->tx_skbuff_dma), in alloc_dma_desc_resources()
1186 if (!priv->tx_skbuff_dma) in alloc_dma_desc_resources()
1189 priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *), in alloc_dma_desc_resources()
1191 if (!priv->tx_skbuff) in alloc_dma_desc_resources()
1194 if (priv->extend_desc) { in alloc_dma_desc_resources()
1195 priv->dma_erx = dma_zalloc_coherent(priv->device, rxsize * in alloc_dma_desc_resources()
1198 &priv->dma_rx_phy, in alloc_dma_desc_resources()
1200 if (!priv->dma_erx) in alloc_dma_desc_resources()
1203 priv->dma_etx = dma_zalloc_coherent(priv->device, txsize * in alloc_dma_desc_resources()
1206 &priv->dma_tx_phy, in alloc_dma_desc_resources()
1208 if (!priv->dma_etx) { in alloc_dma_desc_resources()
1209 dma_free_coherent(priv->device, priv->dma_rx_size * in alloc_dma_desc_resources()
1211 priv->dma_erx, priv->dma_rx_phy); in alloc_dma_desc_resources()
1215 priv->dma_rx = dma_zalloc_coherent(priv->device, rxsize * in alloc_dma_desc_resources()
1217 &priv->dma_rx_phy, in alloc_dma_desc_resources()
1219 if (!priv->dma_rx) in alloc_dma_desc_resources()
1222 priv->dma_tx = dma_zalloc_coherent(priv->device, txsize * in alloc_dma_desc_resources()
1224 &priv->dma_tx_phy, in alloc_dma_desc_resources()
1226 if (!priv->dma_tx) { in alloc_dma_desc_resources()
1227 dma_free_coherent(priv->device, priv->dma_rx_size * in alloc_dma_desc_resources()
1229 priv->dma_rx, priv->dma_rx_phy); in alloc_dma_desc_resources()
1237 kfree(priv->tx_skbuff); in alloc_dma_desc_resources()
1239 kfree(priv->tx_skbuff_dma); in alloc_dma_desc_resources()
1241 kfree(priv->rx_skbuff); in alloc_dma_desc_resources()
1243 kfree(priv->rx_skbuff_dma); in alloc_dma_desc_resources()
1247 static void free_dma_desc_resources(struct stmmac_priv *priv) in free_dma_desc_resources() argument
1250 dma_free_rx_skbufs(priv); in free_dma_desc_resources()
1251 dma_free_tx_skbufs(priv); in free_dma_desc_resources()
1254 if (!priv->extend_desc) { in free_dma_desc_resources()
1255 dma_free_coherent(priv->device, in free_dma_desc_resources()
1256 priv->dma_tx_size * sizeof(struct dma_desc), in free_dma_desc_resources()
1257 priv->dma_tx, priv->dma_tx_phy); in free_dma_desc_resources()
1258 dma_free_coherent(priv->device, in free_dma_desc_resources()
1259 priv->dma_rx_size * sizeof(struct dma_desc), in free_dma_desc_resources()
1260 priv->dma_rx, priv->dma_rx_phy); in free_dma_desc_resources()
1262 dma_free_coherent(priv->device, priv->dma_tx_size * in free_dma_desc_resources()
1264 priv->dma_etx, priv->dma_tx_phy); in free_dma_desc_resources()
1265 dma_free_coherent(priv->device, priv->dma_rx_size * in free_dma_desc_resources()
1267 priv->dma_erx, priv->dma_rx_phy); in free_dma_desc_resources()
1269 kfree(priv->rx_skbuff_dma); in free_dma_desc_resources()
1270 kfree(priv->rx_skbuff); in free_dma_desc_resources()
1271 kfree(priv->tx_skbuff_dma); in free_dma_desc_resources()
1272 kfree(priv->tx_skbuff); in free_dma_desc_resources()
1281 static void stmmac_dma_operation_mode(struct stmmac_priv *priv) in stmmac_dma_operation_mode() argument
1283 int rxfifosz = priv->plat->rx_fifo_size; in stmmac_dma_operation_mode()
1285 if (priv->plat->force_thresh_dma_mode) in stmmac_dma_operation_mode()
1286 priv->hw->dma->dma_mode(priv->ioaddr, tc, tc, rxfifosz); in stmmac_dma_operation_mode()
1287 else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) { in stmmac_dma_operation_mode()
1295 priv->hw->dma->dma_mode(priv->ioaddr, SF_DMA_MODE, SF_DMA_MODE, in stmmac_dma_operation_mode()
1297 priv->xstats.threshold = SF_DMA_MODE; in stmmac_dma_operation_mode()
1299 priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE, in stmmac_dma_operation_mode()
1308 static void stmmac_tx_clean(struct stmmac_priv *priv) in stmmac_tx_clean() argument
1310 unsigned int txsize = priv->dma_tx_size; in stmmac_tx_clean()
1313 spin_lock(&priv->tx_lock); in stmmac_tx_clean()
1315 priv->xstats.tx_clean++; in stmmac_tx_clean()
1317 while (priv->dirty_tx != priv->cur_tx) { in stmmac_tx_clean()
1319 unsigned int entry = priv->dirty_tx % txsize; in stmmac_tx_clean()
1320 struct sk_buff *skb = priv->tx_skbuff[entry]; in stmmac_tx_clean()
1323 if (priv->extend_desc) in stmmac_tx_clean()
1324 p = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_tx_clean()
1326 p = priv->dma_tx + entry; in stmmac_tx_clean()
1329 if (priv->hw->desc->get_tx_owner(p)) in stmmac_tx_clean()
1333 last = priv->hw->desc->get_tx_ls(p); in stmmac_tx_clean()
1336 priv->hw->desc->tx_status(&priv->dev->stats, in stmmac_tx_clean()
1337 &priv->xstats, p, in stmmac_tx_clean()
1338 priv->ioaddr); in stmmac_tx_clean()
1340 priv->dev->stats.tx_packets++; in stmmac_tx_clean()
1341 priv->xstats.tx_pkt_n++; in stmmac_tx_clean()
1343 priv->dev->stats.tx_errors++; in stmmac_tx_clean()
1345 stmmac_get_tx_hwtstamp(priv, entry, skb); in stmmac_tx_clean()
1347 if (netif_msg_tx_done(priv)) in stmmac_tx_clean()
1349 priv->cur_tx, priv->dirty_tx); in stmmac_tx_clean()
1351 if (likely(priv->tx_skbuff_dma[entry].buf)) { in stmmac_tx_clean()
1352 if (priv->tx_skbuff_dma[entry].map_as_page) in stmmac_tx_clean()
1353 dma_unmap_page(priv->device, in stmmac_tx_clean()
1354 priv->tx_skbuff_dma[entry].buf, in stmmac_tx_clean()
1355 priv->hw->desc->get_tx_len(p), in stmmac_tx_clean()
1358 dma_unmap_single(priv->device, in stmmac_tx_clean()
1359 priv->tx_skbuff_dma[entry].buf, in stmmac_tx_clean()
1360 priv->hw->desc->get_tx_len(p), in stmmac_tx_clean()
1362 priv->tx_skbuff_dma[entry].buf = 0; in stmmac_tx_clean()
1363 priv->tx_skbuff_dma[entry].map_as_page = false; in stmmac_tx_clean()
1365 priv->hw->mode->clean_desc3(priv, p); in stmmac_tx_clean()
1371 priv->tx_skbuff[entry] = NULL; in stmmac_tx_clean()
1374 priv->hw->desc->release_tx_desc(p, priv->mode); in stmmac_tx_clean()
1376 priv->dirty_tx++; in stmmac_tx_clean()
1379 netdev_completed_queue(priv->dev, pkts_compl, bytes_compl); in stmmac_tx_clean()
1381 if (unlikely(netif_queue_stopped(priv->dev) && in stmmac_tx_clean()
1382 stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) { in stmmac_tx_clean()
1383 netif_tx_lock(priv->dev); in stmmac_tx_clean()
1384 if (netif_queue_stopped(priv->dev) && in stmmac_tx_clean()
1385 stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv)) { in stmmac_tx_clean()
1386 if (netif_msg_tx_done(priv)) in stmmac_tx_clean()
1388 netif_wake_queue(priv->dev); in stmmac_tx_clean()
1390 netif_tx_unlock(priv->dev); in stmmac_tx_clean()
1393 if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) { in stmmac_tx_clean()
1394 stmmac_enable_eee_mode(priv); in stmmac_tx_clean()
1395 mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(eee_timer)); in stmmac_tx_clean()
1397 spin_unlock(&priv->tx_lock); in stmmac_tx_clean()
1400 static inline void stmmac_enable_dma_irq(struct stmmac_priv *priv) in stmmac_enable_dma_irq() argument
1402 priv->hw->dma->enable_dma_irq(priv->ioaddr); in stmmac_enable_dma_irq()
1405 static inline void stmmac_disable_dma_irq(struct stmmac_priv *priv) in stmmac_disable_dma_irq() argument
1407 priv->hw->dma->disable_dma_irq(priv->ioaddr); in stmmac_disable_dma_irq()
1416 static void stmmac_tx_err(struct stmmac_priv *priv) in stmmac_tx_err() argument
1419 int txsize = priv->dma_tx_size; in stmmac_tx_err()
1420 netif_stop_queue(priv->dev); in stmmac_tx_err()
1422 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_tx_err()
1423 dma_free_tx_skbufs(priv); in stmmac_tx_err()
1425 if (priv->extend_desc) in stmmac_tx_err()
1426 priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, in stmmac_tx_err()
1427 priv->mode, in stmmac_tx_err()
1430 priv->hw->desc->init_tx_desc(&priv->dma_tx[i], in stmmac_tx_err()
1431 priv->mode, in stmmac_tx_err()
1433 priv->dirty_tx = 0; in stmmac_tx_err()
1434 priv->cur_tx = 0; in stmmac_tx_err()
1435 netdev_reset_queue(priv->dev); in stmmac_tx_err()
1436 priv->hw->dma->start_tx(priv->ioaddr); in stmmac_tx_err()
1438 priv->dev->stats.tx_errors++; in stmmac_tx_err()
1439 netif_wake_queue(priv->dev); in stmmac_tx_err()
1449 static void stmmac_dma_interrupt(struct stmmac_priv *priv) in stmmac_dma_interrupt() argument
1452 int rxfifosz = priv->plat->rx_fifo_size; in stmmac_dma_interrupt()
1454 status = priv->hw->dma->dma_interrupt(priv->ioaddr, &priv->xstats); in stmmac_dma_interrupt()
1456 if (likely(napi_schedule_prep(&priv->napi))) { in stmmac_dma_interrupt()
1457 stmmac_disable_dma_irq(priv); in stmmac_dma_interrupt()
1458 __napi_schedule(&priv->napi); in stmmac_dma_interrupt()
1463 if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && in stmmac_dma_interrupt()
1466 if (priv->plat->force_thresh_dma_mode) in stmmac_dma_interrupt()
1467 priv->hw->dma->dma_mode(priv->ioaddr, tc, tc, in stmmac_dma_interrupt()
1470 priv->hw->dma->dma_mode(priv->ioaddr, tc, in stmmac_dma_interrupt()
1472 priv->xstats.threshold = tc; in stmmac_dma_interrupt()
1475 stmmac_tx_err(priv); in stmmac_dma_interrupt()
1483 static void stmmac_mmc_setup(struct stmmac_priv *priv) in stmmac_mmc_setup() argument
1488 dwmac_mmc_intr_all_mask(priv->ioaddr); in stmmac_mmc_setup()
1490 if (priv->dma_cap.rmon) { in stmmac_mmc_setup()
1491 dwmac_mmc_ctrl(priv->ioaddr, mode); in stmmac_mmc_setup()
1492 memset(&priv->mmc, 0, sizeof(struct stmmac_counters)); in stmmac_mmc_setup()
1503 static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv) in stmmac_get_synopsys_id() argument
1505 u32 hwid = priv->hw->synopsys_uid; in stmmac_get_synopsys_id()
1527 static void stmmac_selec_desc_mode(struct stmmac_priv *priv) in stmmac_selec_desc_mode() argument
1529 if (priv->plat->enh_desc) { in stmmac_selec_desc_mode()
1533 if (priv->synopsys_id >= DWMAC_CORE_3_50) { in stmmac_selec_desc_mode()
1535 priv->extend_desc = 1; in stmmac_selec_desc_mode()
1539 priv->hw->desc = &enh_desc_ops; in stmmac_selec_desc_mode()
1542 priv->hw->desc = &ndesc_ops; in stmmac_selec_desc_mode()
1555 static int stmmac_get_hw_features(struct stmmac_priv *priv) in stmmac_get_hw_features() argument
1559 if (priv->hw->dma->get_hw_feature) { in stmmac_get_hw_features()
1560 hw_cap = priv->hw->dma->get_hw_feature(priv->ioaddr); in stmmac_get_hw_features()
1562 priv->dma_cap.mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL); in stmmac_get_hw_features()
1563 priv->dma_cap.mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1; in stmmac_get_hw_features()
1564 priv->dma_cap.half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2; in stmmac_get_hw_features()
1565 priv->dma_cap.hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4; in stmmac_get_hw_features()
1566 priv->dma_cap.multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5; in stmmac_get_hw_features()
1567 priv->dma_cap.pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6; in stmmac_get_hw_features()
1568 priv->dma_cap.sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8; in stmmac_get_hw_features()
1569 priv->dma_cap.pmt_remote_wake_up = in stmmac_get_hw_features()
1571 priv->dma_cap.pmt_magic_frame = in stmmac_get_hw_features()
1574 priv->dma_cap.rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11; in stmmac_get_hw_features()
1576 priv->dma_cap.time_stamp = in stmmac_get_hw_features()
1579 priv->dma_cap.atime_stamp = in stmmac_get_hw_features()
1582 priv->dma_cap.eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14; in stmmac_get_hw_features()
1583 priv->dma_cap.av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15; in stmmac_get_hw_features()
1585 priv->dma_cap.tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16; in stmmac_get_hw_features()
1586 priv->dma_cap.rx_coe_type1 = in stmmac_get_hw_features()
1588 priv->dma_cap.rx_coe_type2 = in stmmac_get_hw_features()
1590 priv->dma_cap.rxfifo_over_2048 = in stmmac_get_hw_features()
1593 priv->dma_cap.number_rx_channel = in stmmac_get_hw_features()
1595 priv->dma_cap.number_tx_channel = in stmmac_get_hw_features()
1598 priv->dma_cap.enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24; in stmmac_get_hw_features()
1611 static void stmmac_check_ether_addr(struct stmmac_priv *priv) in stmmac_check_ether_addr() argument
1613 if (!is_valid_ether_addr(priv->dev->dev_addr)) { in stmmac_check_ether_addr()
1614 priv->hw->mac->get_umac_addr(priv->hw, in stmmac_check_ether_addr()
1615 priv->dev->dev_addr, 0); in stmmac_check_ether_addr()
1616 if (!is_valid_ether_addr(priv->dev->dev_addr)) in stmmac_check_ether_addr()
1617 eth_hw_addr_random(priv->dev); in stmmac_check_ether_addr()
1618 pr_info("%s: device MAC address %pM\n", priv->dev->name, in stmmac_check_ether_addr()
1619 priv->dev->dev_addr); in stmmac_check_ether_addr()
1631 static int stmmac_init_dma_engine(struct stmmac_priv *priv) in stmmac_init_dma_engine() argument
1637 if (priv->plat->dma_cfg) { in stmmac_init_dma_engine()
1638 pbl = priv->plat->dma_cfg->pbl; in stmmac_init_dma_engine()
1639 fixed_burst = priv->plat->dma_cfg->fixed_burst; in stmmac_init_dma_engine()
1640 mixed_burst = priv->plat->dma_cfg->mixed_burst; in stmmac_init_dma_engine()
1641 burst_len = priv->plat->dma_cfg->burst_len; in stmmac_init_dma_engine()
1644 if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE)) in stmmac_init_dma_engine()
1647 return priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst, mixed_burst, in stmmac_init_dma_engine()
1648 burst_len, priv->dma_tx_phy, in stmmac_init_dma_engine()
1649 priv->dma_rx_phy, atds); in stmmac_init_dma_engine()
1660 struct stmmac_priv *priv = (struct stmmac_priv *)data; in stmmac_tx_timer() local
1662 stmmac_tx_clean(priv); in stmmac_tx_timer()
1673 static void stmmac_init_tx_coalesce(struct stmmac_priv *priv) in stmmac_init_tx_coalesce() argument
1675 priv->tx_coal_frames = STMMAC_TX_FRAMES; in stmmac_init_tx_coalesce()
1676 priv->tx_coal_timer = STMMAC_COAL_TX_TIMER; in stmmac_init_tx_coalesce()
1677 init_timer(&priv->txtimer); in stmmac_init_tx_coalesce()
1678 priv->txtimer.expires = STMMAC_COAL_TIMER(priv->tx_coal_timer); in stmmac_init_tx_coalesce()
1679 priv->txtimer.data = (unsigned long)priv; in stmmac_init_tx_coalesce()
1680 priv->txtimer.function = stmmac_tx_timer; in stmmac_init_tx_coalesce()
1681 add_timer(&priv->txtimer); in stmmac_init_tx_coalesce()
1698 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_hw_setup() local
1702 ret = stmmac_init_dma_engine(priv); in stmmac_hw_setup()
1709 priv->hw->mac->set_umac_addr(priv->hw, dev->dev_addr, 0); in stmmac_hw_setup()
1712 if (priv->plat->bus_setup) in stmmac_hw_setup()
1713 priv->plat->bus_setup(priv->ioaddr); in stmmac_hw_setup()
1716 priv->hw->mac->core_init(priv->hw, dev->mtu); in stmmac_hw_setup()
1718 ret = priv->hw->mac->rx_ipc(priv->hw); in stmmac_hw_setup()
1721 priv->plat->rx_coe = STMMAC_RX_COE_NONE; in stmmac_hw_setup()
1722 priv->hw->rx_csum = 0; in stmmac_hw_setup()
1726 stmmac_set_mac(priv->ioaddr, true); in stmmac_hw_setup()
1729 stmmac_dma_operation_mode(priv); in stmmac_hw_setup()
1731 stmmac_mmc_setup(priv); in stmmac_hw_setup()
1734 ret = stmmac_init_ptp(priv); in stmmac_hw_setup()
1746 priv->hw->dma->start_tx(priv->ioaddr); in stmmac_hw_setup()
1747 priv->hw->dma->start_rx(priv->ioaddr); in stmmac_hw_setup()
1750 if (netif_msg_hw(priv)) { in stmmac_hw_setup()
1751 priv->hw->mac->dump_regs(priv->hw); in stmmac_hw_setup()
1752 priv->hw->dma->dump_regs(priv->ioaddr); in stmmac_hw_setup()
1754 priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; in stmmac_hw_setup()
1756 if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { in stmmac_hw_setup()
1757 priv->rx_riwt = MAX_DMA_RIWT; in stmmac_hw_setup()
1758 priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); in stmmac_hw_setup()
1761 if (priv->pcs && priv->hw->mac->ctrl_ane) in stmmac_hw_setup()
1762 priv->hw->mac->ctrl_ane(priv->hw, 0); in stmmac_hw_setup()
1778 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_open() local
1781 stmmac_check_ether_addr(priv); in stmmac_open()
1783 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_open()
1784 priv->pcs != STMMAC_PCS_RTBI) { in stmmac_open()
1794 memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); in stmmac_open()
1795 priv->xstats.threshold = tc; in stmmac_open()
1798 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); in stmmac_open()
1799 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); in stmmac_open()
1800 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); in stmmac_open()
1802 ret = alloc_dma_desc_resources(priv); in stmmac_open()
1820 stmmac_init_tx_coalesce(priv); in stmmac_open()
1822 if (priv->phydev) in stmmac_open()
1823 phy_start(priv->phydev); in stmmac_open()
1835 if (priv->wol_irq != dev->irq) { in stmmac_open()
1836 ret = request_irq(priv->wol_irq, stmmac_interrupt, in stmmac_open()
1840 __func__, priv->wol_irq, ret); in stmmac_open()
1846 if (priv->lpi_irq > 0) { in stmmac_open()
1847 ret = request_irq(priv->lpi_irq, stmmac_interrupt, IRQF_SHARED, in stmmac_open()
1851 __func__, priv->lpi_irq, ret); in stmmac_open()
1856 napi_enable(&priv->napi); in stmmac_open()
1862 if (priv->wol_irq != dev->irq) in stmmac_open()
1863 free_irq(priv->wol_irq, dev); in stmmac_open()
1868 free_dma_desc_resources(priv); in stmmac_open()
1870 if (priv->phydev) in stmmac_open()
1871 phy_disconnect(priv->phydev); in stmmac_open()
1884 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_release() local
1886 if (priv->eee_enabled) in stmmac_release()
1887 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_release()
1890 if (priv->phydev) { in stmmac_release()
1891 phy_stop(priv->phydev); in stmmac_release()
1892 phy_disconnect(priv->phydev); in stmmac_release()
1893 priv->phydev = NULL; in stmmac_release()
1898 napi_disable(&priv->napi); in stmmac_release()
1900 del_timer_sync(&priv->txtimer); in stmmac_release()
1904 if (priv->wol_irq != dev->irq) in stmmac_release()
1905 free_irq(priv->wol_irq, dev); in stmmac_release()
1906 if (priv->lpi_irq > 0) in stmmac_release()
1907 free_irq(priv->lpi_irq, dev); in stmmac_release()
1910 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_release()
1911 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_release()
1914 free_dma_desc_resources(priv); in stmmac_release()
1917 stmmac_set_mac(priv->ioaddr, false); in stmmac_release()
1925 stmmac_release_ptp(priv); in stmmac_release()
1940 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_xmit() local
1941 unsigned int txsize = priv->dma_tx_size; in stmmac_xmit()
1947 unsigned int enh_desc = priv->plat->enh_desc; in stmmac_xmit()
1949 spin_lock(&priv->tx_lock); in stmmac_xmit()
1951 if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { in stmmac_xmit()
1952 spin_unlock(&priv->tx_lock); in stmmac_xmit()
1961 if (priv->tx_path_in_lpi_mode) in stmmac_xmit()
1962 stmmac_disable_eee_mode(priv); in stmmac_xmit()
1964 entry = priv->cur_tx % txsize; in stmmac_xmit()
1968 if (priv->extend_desc) in stmmac_xmit()
1969 desc = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_xmit()
1971 desc = priv->dma_tx + entry; in stmmac_xmit()
1977 is_jumbo = priv->hw->mode->is_jumbo_frm(skb->len, enh_desc); in stmmac_xmit()
1980 desc->des2 = dma_map_single(priv->device, skb->data, in stmmac_xmit()
1982 if (dma_mapping_error(priv->device, desc->des2)) in stmmac_xmit()
1984 priv->tx_skbuff_dma[entry].buf = desc->des2; in stmmac_xmit()
1985 priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, in stmmac_xmit()
1986 csum_insertion, priv->mode); in stmmac_xmit()
1989 entry = priv->hw->mode->jumbo_frm(priv, skb, csum_insertion); in stmmac_xmit()
1998 priv->tx_skbuff[entry] = NULL; in stmmac_xmit()
1999 entry = (++priv->cur_tx) % txsize; in stmmac_xmit()
2000 if (priv->extend_desc) in stmmac_xmit()
2001 desc = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_xmit()
2003 desc = priv->dma_tx + entry; in stmmac_xmit()
2005 desc->des2 = skb_frag_dma_map(priv->device, frag, 0, len, in stmmac_xmit()
2007 if (dma_mapping_error(priv->device, desc->des2)) in stmmac_xmit()
2010 priv->tx_skbuff_dma[entry].buf = desc->des2; in stmmac_xmit()
2011 priv->tx_skbuff_dma[entry].map_as_page = true; in stmmac_xmit()
2012 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion, in stmmac_xmit()
2013 priv->mode); in stmmac_xmit()
2015 priv->hw->desc->set_tx_owner(desc); in stmmac_xmit()
2019 priv->tx_skbuff[entry] = skb; in stmmac_xmit()
2022 priv->hw->desc->close_tx_desc(desc); in stmmac_xmit()
2029 priv->tx_count_frames += nfrags + 1; in stmmac_xmit()
2030 if (priv->tx_coal_frames > priv->tx_count_frames) { in stmmac_xmit()
2031 priv->hw->desc->clear_tx_ic(desc); in stmmac_xmit()
2032 priv->xstats.tx_reset_ic_bit++; in stmmac_xmit()
2033 mod_timer(&priv->txtimer, in stmmac_xmit()
2034 STMMAC_COAL_TIMER(priv->tx_coal_timer)); in stmmac_xmit()
2036 priv->tx_count_frames = 0; in stmmac_xmit()
2039 priv->hw->desc->set_tx_owner(first); in stmmac_xmit()
2042 priv->cur_tx++; in stmmac_xmit()
2044 if (netif_msg_pktdata(priv)) { in stmmac_xmit()
2046 __func__, (priv->cur_tx % txsize), in stmmac_xmit()
2047 (priv->dirty_tx % txsize), entry, first, nfrags); in stmmac_xmit()
2049 if (priv->extend_desc) in stmmac_xmit()
2050 stmmac_display_ring((void *)priv->dma_etx, txsize, 1); in stmmac_xmit()
2052 stmmac_display_ring((void *)priv->dma_tx, txsize, 0); in stmmac_xmit()
2057 if (unlikely(stmmac_tx_avail(priv) <= (MAX_SKB_FRAGS + 1))) { in stmmac_xmit()
2058 if (netif_msg_hw(priv)) in stmmac_xmit()
2066 priv->hwts_tx_en)) { in stmmac_xmit()
2069 priv->hw->desc->enable_tx_timestamp(first); in stmmac_xmit()
2072 if (!priv->hwts_tx_en) in stmmac_xmit()
2076 priv->hw->dma->enable_dma_transmission(priv->ioaddr); in stmmac_xmit()
2078 spin_unlock(&priv->tx_lock); in stmmac_xmit()
2082 spin_unlock(&priv->tx_lock); in stmmac_xmit()
2083 dev_err(priv->device, "Tx dma map failed\n"); in stmmac_xmit()
2085 priv->dev->stats.tx_dropped++; in stmmac_xmit()
2112 static inline void stmmac_rx_refill(struct stmmac_priv *priv) in stmmac_rx_refill() argument
2114 unsigned int rxsize = priv->dma_rx_size; in stmmac_rx_refill()
2115 int bfsize = priv->dma_buf_sz; in stmmac_rx_refill()
2117 for (; priv->cur_rx - priv->dirty_rx > 0; priv->dirty_rx++) { in stmmac_rx_refill()
2118 unsigned int entry = priv->dirty_rx % rxsize; in stmmac_rx_refill()
2121 if (priv->extend_desc) in stmmac_rx_refill()
2122 p = (struct dma_desc *)(priv->dma_erx + entry); in stmmac_rx_refill()
2124 p = priv->dma_rx + entry; in stmmac_rx_refill()
2126 if (likely(priv->rx_skbuff[entry] == NULL)) { in stmmac_rx_refill()
2129 skb = netdev_alloc_skb_ip_align(priv->dev, bfsize); in stmmac_rx_refill()
2134 priv->rx_skbuff[entry] = skb; in stmmac_rx_refill()
2135 priv->rx_skbuff_dma[entry] = in stmmac_rx_refill()
2136 dma_map_single(priv->device, skb->data, bfsize, in stmmac_rx_refill()
2138 if (dma_mapping_error(priv->device, in stmmac_rx_refill()
2139 priv->rx_skbuff_dma[entry])) { in stmmac_rx_refill()
2140 dev_err(priv->device, "Rx dma map failed\n"); in stmmac_rx_refill()
2144 p->des2 = priv->rx_skbuff_dma[entry]; in stmmac_rx_refill()
2146 priv->hw->mode->refill_desc3(priv, p); in stmmac_rx_refill()
2148 if (netif_msg_rx_status(priv)) in stmmac_rx_refill()
2152 priv->hw->desc->set_rx_owner(p); in stmmac_rx_refill()
2164 static int stmmac_rx(struct stmmac_priv *priv, int limit) in stmmac_rx() argument
2166 unsigned int rxsize = priv->dma_rx_size; in stmmac_rx()
2167 unsigned int entry = priv->cur_rx % rxsize; in stmmac_rx()
2170 int coe = priv->hw->rx_csum; in stmmac_rx()
2172 if (netif_msg_rx_status(priv)) { in stmmac_rx()
2174 if (priv->extend_desc) in stmmac_rx()
2175 stmmac_display_ring((void *)priv->dma_erx, rxsize, 1); in stmmac_rx()
2177 stmmac_display_ring((void *)priv->dma_rx, rxsize, 0); in stmmac_rx()
2183 if (priv->extend_desc) in stmmac_rx()
2184 p = (struct dma_desc *)(priv->dma_erx + entry); in stmmac_rx()
2186 p = priv->dma_rx + entry; in stmmac_rx()
2188 if (priv->hw->desc->get_rx_owner(p)) in stmmac_rx()
2193 next_entry = (++priv->cur_rx) % rxsize; in stmmac_rx()
2194 if (priv->extend_desc) in stmmac_rx()
2195 prefetch(priv->dma_erx + next_entry); in stmmac_rx()
2197 prefetch(priv->dma_rx + next_entry); in stmmac_rx()
2200 status = priv->hw->desc->rx_status(&priv->dev->stats, in stmmac_rx()
2201 &priv->xstats, p); in stmmac_rx()
2202 if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status)) in stmmac_rx()
2203 priv->hw->desc->rx_extended_status(&priv->dev->stats, in stmmac_rx()
2204 &priv->xstats, in stmmac_rx()
2205 priv->dma_erx + in stmmac_rx()
2208 priv->dev->stats.rx_errors++; in stmmac_rx()
2209 if (priv->hwts_rx_en && !priv->extend_desc) { in stmmac_rx()
2215 priv->rx_skbuff[entry] = NULL; in stmmac_rx()
2216 dma_unmap_single(priv->device, in stmmac_rx()
2217 priv->rx_skbuff_dma[entry], in stmmac_rx()
2218 priv->dma_buf_sz, in stmmac_rx()
2225 frame_len = priv->hw->desc->get_rx_frame_len(p, coe); in stmmac_rx()
2233 if (netif_msg_rx_status(priv)) { in stmmac_rx()
2240 skb = priv->rx_skbuff[entry]; in stmmac_rx()
2243 priv->dev->name); in stmmac_rx()
2244 priv->dev->stats.rx_dropped++; in stmmac_rx()
2248 priv->rx_skbuff[entry] = NULL; in stmmac_rx()
2250 stmmac_get_rx_hwtstamp(priv, entry, skb); in stmmac_rx()
2253 dma_unmap_single(priv->device, in stmmac_rx()
2254 priv->rx_skbuff_dma[entry], in stmmac_rx()
2255 priv->dma_buf_sz, DMA_FROM_DEVICE); in stmmac_rx()
2257 if (netif_msg_pktdata(priv)) { in stmmac_rx()
2262 stmmac_rx_vlan(priv->dev, skb); in stmmac_rx()
2264 skb->protocol = eth_type_trans(skb, priv->dev); in stmmac_rx()
2271 napi_gro_receive(&priv->napi, skb); in stmmac_rx()
2273 priv->dev->stats.rx_packets++; in stmmac_rx()
2274 priv->dev->stats.rx_bytes += frame_len; in stmmac_rx()
2279 stmmac_rx_refill(priv); in stmmac_rx()
2281 priv->xstats.rx_pkt_n += count; in stmmac_rx()
2296 struct stmmac_priv *priv = container_of(napi, struct stmmac_priv, napi); in stmmac_poll() local
2299 priv->xstats.napi_poll++; in stmmac_poll()
2300 stmmac_tx_clean(priv); in stmmac_poll()
2302 work_done = stmmac_rx(priv, budget); in stmmac_poll()
2305 stmmac_enable_dma_irq(priv); in stmmac_poll()
2320 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_tx_timeout() local
2323 stmmac_tx_err(priv); in stmmac_tx_timeout()
2337 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_set_rx_mode() local
2339 priv->hw->mac->set_filter(priv->hw, dev); in stmmac_set_rx_mode()
2355 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_change_mtu() local
2363 if (priv->plat->enh_desc) in stmmac_change_mtu()
2368 if (priv->plat->maxmtu < max_mtu) in stmmac_change_mtu()
2369 max_mtu = priv->plat->maxmtu; in stmmac_change_mtu()
2385 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_fix_features() local
2387 if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) in stmmac_fix_features()
2390 if (!priv->plat->tx_coe) in stmmac_fix_features()
2398 if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) in stmmac_fix_features()
2407 struct stmmac_priv *priv = netdev_priv(netdev); in stmmac_set_features() local
2411 priv->hw->rx_csum = priv->plat->rx_coe; in stmmac_set_features()
2413 priv->hw->rx_csum = 0; in stmmac_set_features()
2417 priv->hw->mac->rx_ipc(priv->hw); in stmmac_set_features()
2436 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_interrupt() local
2438 if (priv->irq_wake) in stmmac_interrupt()
2439 pm_wakeup_event(priv->device, 0); in stmmac_interrupt()
2447 if (priv->plat->has_gmac) { in stmmac_interrupt()
2448 int status = priv->hw->mac->host_irq_status(priv->hw, in stmmac_interrupt()
2449 &priv->xstats); in stmmac_interrupt()
2453 priv->tx_path_in_lpi_mode = true; in stmmac_interrupt()
2455 priv->tx_path_in_lpi_mode = false; in stmmac_interrupt()
2460 stmmac_dma_interrupt(priv); in stmmac_interrupt()
2488 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_ioctl() local
2498 if (!priv->phydev) in stmmac_ioctl()
2500 ret = phy_mii_ioctl(priv->phydev, rq, cmd); in stmmac_ioctl()
2546 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_sysfs_ring_read() local
2547 unsigned int txsize = priv->dma_tx_size; in stmmac_sysfs_ring_read()
2548 unsigned int rxsize = priv->dma_rx_size; in stmmac_sysfs_ring_read()
2550 if (priv->extend_desc) { in stmmac_sysfs_ring_read()
2552 sysfs_display_ring((void *)priv->dma_erx, rxsize, 1, seq); in stmmac_sysfs_ring_read()
2554 sysfs_display_ring((void *)priv->dma_etx, txsize, 1, seq); in stmmac_sysfs_ring_read()
2557 sysfs_display_ring((void *)priv->dma_rx, rxsize, 0, seq); in stmmac_sysfs_ring_read()
2559 sysfs_display_ring((void *)priv->dma_tx, txsize, 0, seq); in stmmac_sysfs_ring_read()
2581 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_sysfs_dma_cap_read() local
2583 if (!priv->hw_cap_support) { in stmmac_sysfs_dma_cap_read()
2593 (priv->dma_cap.mbps_10_100) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2595 (priv->dma_cap.mbps_1000) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2597 (priv->dma_cap.half_duplex) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2599 (priv->dma_cap.hash_filter) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2601 (priv->dma_cap.multi_addr) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2603 (priv->dma_cap.pcs) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2605 (priv->dma_cap.sma_mdio) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2607 (priv->dma_cap.pmt_remote_wake_up) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2609 (priv->dma_cap.pmt_magic_frame) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2611 (priv->dma_cap.rmon) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2613 (priv->dma_cap.time_stamp) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2615 (priv->dma_cap.atime_stamp) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2617 (priv->dma_cap.eee) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2618 seq_printf(seq, "\tAV features: %s\n", (priv->dma_cap.av) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2620 (priv->dma_cap.tx_coe) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2622 (priv->dma_cap.rx_coe_type1) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2624 (priv->dma_cap.rx_coe_type2) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2626 (priv->dma_cap.rxfifo_over_2048) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2628 priv->dma_cap.number_rx_channel); in stmmac_sysfs_dma_cap_read()
2630 priv->dma_cap.number_tx_channel); in stmmac_sysfs_dma_cap_read()
2632 (priv->dma_cap.enh_desc) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2652 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_init_fs() local
2655 priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir); in stmmac_init_fs()
2657 if (!priv->dbgfs_dir || IS_ERR(priv->dbgfs_dir)) { in stmmac_init_fs()
2665 priv->dbgfs_rings_status = in stmmac_init_fs()
2667 priv->dbgfs_dir, dev, in stmmac_init_fs()
2670 if (!priv->dbgfs_rings_status || IS_ERR(priv->dbgfs_rings_status)) { in stmmac_init_fs()
2672 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_init_fs()
2678 priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", S_IRUGO, in stmmac_init_fs()
2679 priv->dbgfs_dir, in stmmac_init_fs()
2682 if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) { in stmmac_init_fs()
2684 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_init_fs()
2694 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_exit_fs() local
2696 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_exit_fs()
2724 static int stmmac_hw_init(struct stmmac_priv *priv) in stmmac_hw_init() argument
2729 if (priv->plat->has_gmac) { in stmmac_hw_init()
2730 priv->dev->priv_flags |= IFF_UNICAST_FLT; in stmmac_hw_init()
2731 mac = dwmac1000_setup(priv->ioaddr, in stmmac_hw_init()
2732 priv->plat->multicast_filter_bins, in stmmac_hw_init()
2733 priv->plat->unicast_filter_entries); in stmmac_hw_init()
2735 mac = dwmac100_setup(priv->ioaddr); in stmmac_hw_init()
2740 priv->hw = mac; in stmmac_hw_init()
2743 priv->synopsys_id = stmmac_get_synopsys_id(priv); in stmmac_hw_init()
2747 priv->hw->mode = &chain_mode_ops; in stmmac_hw_init()
2749 priv->mode = STMMAC_CHAIN_MODE; in stmmac_hw_init()
2751 priv->hw->mode = &ring_mode_ops; in stmmac_hw_init()
2753 priv->mode = STMMAC_RING_MODE; in stmmac_hw_init()
2757 priv->hw_cap_support = stmmac_get_hw_features(priv); in stmmac_hw_init()
2758 if (priv->hw_cap_support) { in stmmac_hw_init()
2766 priv->plat->enh_desc = priv->dma_cap.enh_desc; in stmmac_hw_init()
2767 priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up; in stmmac_hw_init()
2770 if (priv->plat->force_thresh_dma_mode) in stmmac_hw_init()
2771 priv->plat->tx_coe = 0; in stmmac_hw_init()
2773 priv->plat->tx_coe = priv->dma_cap.tx_coe; in stmmac_hw_init()
2775 if (priv->dma_cap.rx_coe_type2) in stmmac_hw_init()
2776 priv->plat->rx_coe = STMMAC_RX_COE_TYPE2; in stmmac_hw_init()
2777 else if (priv->dma_cap.rx_coe_type1) in stmmac_hw_init()
2778 priv->plat->rx_coe = STMMAC_RX_COE_TYPE1; in stmmac_hw_init()
2784 stmmac_selec_desc_mode(priv); in stmmac_hw_init()
2786 if (priv->plat->rx_coe) { in stmmac_hw_init()
2787 priv->hw->rx_csum = priv->plat->rx_coe; in stmmac_hw_init()
2789 priv->plat->rx_coe); in stmmac_hw_init()
2791 if (priv->plat->tx_coe) in stmmac_hw_init()
2794 if (priv->plat->pmt) { in stmmac_hw_init()
2796 device_set_wakeup_capable(priv->device, 1); in stmmac_hw_init()
2819 struct stmmac_priv *priv; in stmmac_dvr_probe() local
2827 priv = netdev_priv(ndev); in stmmac_dvr_probe()
2828 priv->device = device; in stmmac_dvr_probe()
2829 priv->dev = ndev; in stmmac_dvr_probe()
2832 priv->pause = pause; in stmmac_dvr_probe()
2833 priv->plat = plat_dat; in stmmac_dvr_probe()
2834 priv->ioaddr = addr; in stmmac_dvr_probe()
2835 priv->dev->base_addr = (unsigned long)addr; in stmmac_dvr_probe()
2844 priv->plat->phy_addr = phyaddr; in stmmac_dvr_probe()
2846 priv->stmmac_clk = devm_clk_get(priv->device, STMMAC_RESOURCE_NAME); in stmmac_dvr_probe()
2847 if (IS_ERR(priv->stmmac_clk)) { in stmmac_dvr_probe()
2848 dev_warn(priv->device, "%s: warning: cannot get CSR clock\n", in stmmac_dvr_probe()
2853 if (!priv->plat->clk_csr) { in stmmac_dvr_probe()
2854 ret = PTR_ERR(priv->stmmac_clk); in stmmac_dvr_probe()
2857 priv->stmmac_clk = NULL; in stmmac_dvr_probe()
2860 clk_prepare_enable(priv->stmmac_clk); in stmmac_dvr_probe()
2862 priv->pclk = devm_clk_get(priv->device, "pclk"); in stmmac_dvr_probe()
2863 if (IS_ERR(priv->pclk)) { in stmmac_dvr_probe()
2864 if (PTR_ERR(priv->pclk) == -EPROBE_DEFER) { in stmmac_dvr_probe()
2868 priv->pclk = NULL; in stmmac_dvr_probe()
2870 clk_prepare_enable(priv->pclk); in stmmac_dvr_probe()
2872 priv->stmmac_rst = devm_reset_control_get(priv->device, in stmmac_dvr_probe()
2874 if (IS_ERR(priv->stmmac_rst)) { in stmmac_dvr_probe()
2875 if (PTR_ERR(priv->stmmac_rst) == -EPROBE_DEFER) { in stmmac_dvr_probe()
2879 dev_info(priv->device, "no reset control found\n"); in stmmac_dvr_probe()
2880 priv->stmmac_rst = NULL; in stmmac_dvr_probe()
2882 if (priv->stmmac_rst) in stmmac_dvr_probe()
2883 reset_control_deassert(priv->stmmac_rst); in stmmac_dvr_probe()
2886 ret = stmmac_hw_init(priv); in stmmac_dvr_probe()
2900 priv->msg_enable = netif_msg_init(debug, default_msg_level); in stmmac_dvr_probe()
2903 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ in stmmac_dvr_probe()
2910 if ((priv->synopsys_id >= DWMAC_CORE_3_50) && (!priv->plat->riwt_off)) { in stmmac_dvr_probe()
2911 priv->use_riwt = 1; in stmmac_dvr_probe()
2915 netif_napi_add(ndev, &priv->napi, stmmac_poll, 64); in stmmac_dvr_probe()
2917 spin_lock_init(&priv->lock); in stmmac_dvr_probe()
2918 spin_lock_init(&priv->tx_lock); in stmmac_dvr_probe()
2932 if (!priv->plat->clk_csr) in stmmac_dvr_probe()
2933 stmmac_clk_csr_set(priv); in stmmac_dvr_probe()
2935 priv->clk_csr = priv->plat->clk_csr; in stmmac_dvr_probe()
2937 stmmac_check_pcs_mode(priv); in stmmac_dvr_probe()
2939 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_dvr_probe()
2940 priv->pcs != STMMAC_PCS_RTBI) { in stmmac_dvr_probe()
2945 __func__, priv->plat->bus_id); in stmmac_dvr_probe()
2950 return priv; in stmmac_dvr_probe()
2955 netif_napi_del(&priv->napi); in stmmac_dvr_probe()
2957 clk_disable_unprepare(priv->pclk); in stmmac_dvr_probe()
2959 clk_disable_unprepare(priv->stmmac_clk); in stmmac_dvr_probe()
2975 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_dvr_remove() local
2979 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_dvr_remove()
2980 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_dvr_remove()
2982 stmmac_set_mac(priv->ioaddr, false); in stmmac_dvr_remove()
2985 if (priv->stmmac_rst) in stmmac_dvr_remove()
2986 reset_control_assert(priv->stmmac_rst); in stmmac_dvr_remove()
2987 clk_disable_unprepare(priv->pclk); in stmmac_dvr_remove()
2988 clk_disable_unprepare(priv->stmmac_clk); in stmmac_dvr_remove()
2989 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_dvr_remove()
2990 priv->pcs != STMMAC_PCS_RTBI) in stmmac_dvr_remove()
3007 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_suspend() local
3013 if (priv->phydev) in stmmac_suspend()
3014 phy_stop(priv->phydev); in stmmac_suspend()
3016 spin_lock_irqsave(&priv->lock, flags); in stmmac_suspend()
3021 napi_disable(&priv->napi); in stmmac_suspend()
3024 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_suspend()
3025 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_suspend()
3027 stmmac_clear_descriptors(priv); in stmmac_suspend()
3030 if (device_may_wakeup(priv->device)) { in stmmac_suspend()
3031 priv->hw->mac->pmt(priv->hw, priv->wolopts); in stmmac_suspend()
3032 priv->irq_wake = 1; in stmmac_suspend()
3034 stmmac_set_mac(priv->ioaddr, false); in stmmac_suspend()
3035 pinctrl_pm_select_sleep_state(priv->device); in stmmac_suspend()
3037 clk_disable(priv->pclk); in stmmac_suspend()
3038 clk_disable(priv->stmmac_clk); in stmmac_suspend()
3040 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_suspend()
3042 priv->oldlink = 0; in stmmac_suspend()
3043 priv->speed = 0; in stmmac_suspend()
3044 priv->oldduplex = -1; in stmmac_suspend()
3057 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_resume() local
3063 spin_lock_irqsave(&priv->lock, flags); in stmmac_resume()
3071 if (device_may_wakeup(priv->device)) { in stmmac_resume()
3072 priv->hw->mac->pmt(priv->hw, 0); in stmmac_resume()
3073 priv->irq_wake = 0; in stmmac_resume()
3075 pinctrl_pm_select_default_state(priv->device); in stmmac_resume()
3077 clk_enable(priv->stmmac_clk); in stmmac_resume()
3078 clk_enable(priv->pclk); in stmmac_resume()
3080 if (priv->mii) in stmmac_resume()
3081 stmmac_mdio_reset(priv->mii); in stmmac_resume()
3088 stmmac_init_tx_coalesce(priv); in stmmac_resume()
3090 napi_enable(&priv->napi); in stmmac_resume()
3094 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_resume()
3096 if (priv->phydev) in stmmac_resume()
3097 phy_start(priv->phydev); in stmmac_resume()