• Home
  • Raw
  • Download

Lines Matching refs:mp

430 static inline u32 rdl(struct mv643xx_eth_private *mp, int offset)  in rdl()  argument
432 return readl(mp->shared->base + offset); in rdl()
435 static inline u32 rdlp(struct mv643xx_eth_private *mp, int offset) in rdlp() argument
437 return readl(mp->base + offset); in rdlp()
440 static inline void wrl(struct mv643xx_eth_private *mp, int offset, u32 data) in wrl() argument
442 writel(data, mp->shared->base + offset); in wrl()
445 static inline void wrlp(struct mv643xx_eth_private *mp, int offset, u32 data) in wrlp() argument
447 writel(data, mp->base + offset); in wrlp()
464 struct mv643xx_eth_private *mp = rxq_to_mp(rxq); in rxq_enable() local
465 wrlp(mp, RXQ_COMMAND, 1 << rxq->index); in rxq_enable()
470 struct mv643xx_eth_private *mp = rxq_to_mp(rxq); in rxq_disable() local
473 wrlp(mp, RXQ_COMMAND, mask << 8); in rxq_disable()
474 while (rdlp(mp, RXQ_COMMAND) & mask) in rxq_disable()
480 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_reset_hw_ptr() local
485 wrlp(mp, TXQ_CURRENT_DESC_PTR(txq->index), addr); in txq_reset_hw_ptr()
490 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_enable() local
491 wrlp(mp, TXQ_COMMAND, 1 << txq->index); in txq_enable()
496 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_disable() local
499 wrlp(mp, TXQ_COMMAND, mask << 8); in txq_disable()
500 while (rdlp(mp, TXQ_COMMAND) & mask) in txq_disable()
506 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_maybe_wake() local
507 struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index); in txq_maybe_wake()
519 struct mv643xx_eth_private *mp = rxq_to_mp(rxq); in rxq_process() local
520 struct net_device_stats *stats = &mp->dev->stats; in rxq_process()
544 dma_unmap_single(mp->dev->dev.parent, rx_desc->buf_ptr, in rxq_process()
549 mp->work_rx_refill |= 1 << rxq->index; in rxq_process()
581 skb->protocol = eth_type_trans(skb, mp->dev); in rxq_process()
583 napi_gro_receive(&mp->napi, skb); in rxq_process()
593 netdev_err(mp->dev, in rxq_process()
604 mp->work_rx &= ~(1 << rxq->index); in rxq_process()
611 struct mv643xx_eth_private *mp = rxq_to_mp(rxq); in rxq_refill() local
621 skb = netdev_alloc_skb(mp->dev, mp->skb_size); in rxq_refill()
624 mp->oom = 1; in rxq_refill()
641 rx_desc->buf_ptr = dma_map_single(mp->dev->dev.parent, in rxq_refill()
659 mp->work_rx_refill &= ~(1 << rxq->index); in rxq_refill()
686 static int skb_tx_csum(struct mv643xx_eth_private *mp, struct sk_buff *skb, in skb_tx_csum() argument
702 if (length - hdr_len > mp->shared->tx_csum_limit || in skb_tx_csum()
793 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_put_hdr_tso() local
805 ret = skb_tx_csum(mp, skb, &l4i_chk, &cmd_csum, length); in txq_put_hdr_tso()
835 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_submit_tso() local
892 mp->work_tx_end &= ~(1 << txq->index); in txq_submit_tso()
908 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_submit_frag_skb() local
938 desc->buf_ptr = skb_frag_dma_map(mp->dev->dev.parent, in txq_submit_frag_skb()
947 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_submit_skb() local
964 ret = skb_tx_csum(mp, skb, &l4i_chk, &cmd_sts, skb->len); in txq_submit_skb()
985 desc->buf_ptr = dma_map_single(mp->dev->dev.parent, skb->data, in txq_submit_skb()
997 mp->work_tx_end &= ~(1 << txq->index); in txq_submit_skb()
1010 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_xmit() local
1016 txq = mp->txq + queue; in mv643xx_eth_xmit()
1049 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_kick() local
1050 struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index); in txq_kick()
1056 if (rdlp(mp, TXQ_COMMAND) & (1 << txq->index)) in txq_kick()
1059 hw_desc_ptr = rdlp(mp, TXQ_CURRENT_DESC_PTR(txq->index)); in txq_kick()
1069 mp->work_tx_end &= ~(1 << txq->index); in txq_kick()
1074 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_reclaim() local
1075 struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index); in txq_reclaim()
1109 dma_unmap_page(mp->dev->dev.parent, in txq_reclaim()
1114 dma_unmap_single(mp->dev->dev.parent, in txq_reclaim()
1128 netdev_info(mp->dev, "tx error\n"); in txq_reclaim()
1129 mp->dev->stats.tx_errors++; in txq_reclaim()
1137 mp->work_tx &= ~(1 << txq->index); in txq_reclaim()
1148 static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst) in tx_set_rate() argument
1154 token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); in tx_set_rate()
1158 mtu = (mp->dev->mtu + 255) >> 8; in tx_set_rate()
1166 switch (mp->shared->tx_bw_control) { in tx_set_rate()
1168 wrlp(mp, TX_BW_RATE, token_rate); in tx_set_rate()
1169 wrlp(mp, TX_BW_MTU, mtu); in tx_set_rate()
1170 wrlp(mp, TX_BW_BURST, bucket_size); in tx_set_rate()
1173 wrlp(mp, TX_BW_RATE_MOVED, token_rate); in tx_set_rate()
1174 wrlp(mp, TX_BW_MTU_MOVED, mtu); in tx_set_rate()
1175 wrlp(mp, TX_BW_BURST_MOVED, bucket_size); in tx_set_rate()
1182 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_set_rate() local
1186 token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); in txq_set_rate()
1194 wrlp(mp, TXQ_BW_TOKENS(txq->index), token_rate << 14); in txq_set_rate()
1195 wrlp(mp, TXQ_BW_CONF(txq->index), (bucket_size << 10) | token_rate); in txq_set_rate()
1200 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_set_fixed_prio_mode() local
1208 switch (mp->shared->tx_bw_control) { in txq_set_fixed_prio_mode()
1218 val = rdlp(mp, off); in txq_set_fixed_prio_mode()
1220 wrlp(mp, off, val); in txq_set_fixed_prio_mode()
1228 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_adjust_link() local
1229 u32 pscr = rdlp(mp, PORT_SERIAL_CONTROL); in mv643xx_eth_adjust_link()
1263 wrlp(mp, PORT_SERIAL_CONTROL, pscr); in mv643xx_eth_adjust_link()
1269 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_get_stats() local
1276 for (i = 0; i < mp->txq_count; i++) { in mv643xx_eth_get_stats()
1277 struct tx_queue *txq = mp->txq + i; in mv643xx_eth_get_stats()
1291 static inline u32 mib_read(struct mv643xx_eth_private *mp, int offset) in mib_read() argument
1293 return rdl(mp, MIB_COUNTERS(mp->port_num) + offset); in mib_read()
1296 static void mib_counters_clear(struct mv643xx_eth_private *mp) in mib_counters_clear() argument
1301 mib_read(mp, i); in mib_counters_clear()
1304 rdlp(mp, RX_DISCARD_FRAME_CNT); in mib_counters_clear()
1305 rdlp(mp, RX_OVERRUN_FRAME_CNT); in mib_counters_clear()
1308 static void mib_counters_update(struct mv643xx_eth_private *mp) in mib_counters_update() argument
1310 struct mib_counters *p = &mp->mib_counters; in mib_counters_update()
1312 spin_lock_bh(&mp->mib_counters_lock); in mib_counters_update()
1313 p->good_octets_received += mib_read(mp, 0x00); in mib_counters_update()
1314 p->bad_octets_received += mib_read(mp, 0x08); in mib_counters_update()
1315 p->internal_mac_transmit_err += mib_read(mp, 0x0c); in mib_counters_update()
1316 p->good_frames_received += mib_read(mp, 0x10); in mib_counters_update()
1317 p->bad_frames_received += mib_read(mp, 0x14); in mib_counters_update()
1318 p->broadcast_frames_received += mib_read(mp, 0x18); in mib_counters_update()
1319 p->multicast_frames_received += mib_read(mp, 0x1c); in mib_counters_update()
1320 p->frames_64_octets += mib_read(mp, 0x20); in mib_counters_update()
1321 p->frames_65_to_127_octets += mib_read(mp, 0x24); in mib_counters_update()
1322 p->frames_128_to_255_octets += mib_read(mp, 0x28); in mib_counters_update()
1323 p->frames_256_to_511_octets += mib_read(mp, 0x2c); in mib_counters_update()
1324 p->frames_512_to_1023_octets += mib_read(mp, 0x30); in mib_counters_update()
1325 p->frames_1024_to_max_octets += mib_read(mp, 0x34); in mib_counters_update()
1326 p->good_octets_sent += mib_read(mp, 0x38); in mib_counters_update()
1327 p->good_frames_sent += mib_read(mp, 0x40); in mib_counters_update()
1328 p->excessive_collision += mib_read(mp, 0x44); in mib_counters_update()
1329 p->multicast_frames_sent += mib_read(mp, 0x48); in mib_counters_update()
1330 p->broadcast_frames_sent += mib_read(mp, 0x4c); in mib_counters_update()
1331 p->unrec_mac_control_received += mib_read(mp, 0x50); in mib_counters_update()
1332 p->fc_sent += mib_read(mp, 0x54); in mib_counters_update()
1333 p->good_fc_received += mib_read(mp, 0x58); in mib_counters_update()
1334 p->bad_fc_received += mib_read(mp, 0x5c); in mib_counters_update()
1335 p->undersize_received += mib_read(mp, 0x60); in mib_counters_update()
1336 p->fragments_received += mib_read(mp, 0x64); in mib_counters_update()
1337 p->oversize_received += mib_read(mp, 0x68); in mib_counters_update()
1338 p->jabber_received += mib_read(mp, 0x6c); in mib_counters_update()
1339 p->mac_receive_error += mib_read(mp, 0x70); in mib_counters_update()
1340 p->bad_crc_event += mib_read(mp, 0x74); in mib_counters_update()
1341 p->collision += mib_read(mp, 0x78); in mib_counters_update()
1342 p->late_collision += mib_read(mp, 0x7c); in mib_counters_update()
1344 p->rx_discard += rdlp(mp, RX_DISCARD_FRAME_CNT); in mib_counters_update()
1345 p->rx_overrun += rdlp(mp, RX_OVERRUN_FRAME_CNT); in mib_counters_update()
1346 spin_unlock_bh(&mp->mib_counters_lock); in mib_counters_update()
1351 struct mv643xx_eth_private *mp = (void *)_mp; in mib_counters_timer_wrapper() local
1352 mib_counters_update(mp); in mib_counters_timer_wrapper()
1353 mod_timer(&mp->mib_counters_timer, jiffies + 30 * HZ); in mib_counters_timer_wrapper()
1369 static unsigned int get_rx_coal(struct mv643xx_eth_private *mp) in get_rx_coal() argument
1371 u32 val = rdlp(mp, SDMA_CONFIG); in get_rx_coal()
1374 if (mp->shared->extended_rx_coal_limit) in get_rx_coal()
1380 temp += mp->t_clk / 2; in get_rx_coal()
1381 do_div(temp, mp->t_clk); in get_rx_coal()
1386 static void set_rx_coal(struct mv643xx_eth_private *mp, unsigned int usec) in set_rx_coal() argument
1391 temp = (u64)usec * mp->t_clk; in set_rx_coal()
1395 val = rdlp(mp, SDMA_CONFIG); in set_rx_coal()
1396 if (mp->shared->extended_rx_coal_limit) { in set_rx_coal()
1408 wrlp(mp, SDMA_CONFIG, val); in set_rx_coal()
1411 static unsigned int get_tx_coal(struct mv643xx_eth_private *mp) in get_tx_coal() argument
1415 temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4; in get_tx_coal()
1417 temp += mp->t_clk / 2; in get_tx_coal()
1418 do_div(temp, mp->t_clk); in get_tx_coal()
1423 static void set_tx_coal(struct mv643xx_eth_private *mp, unsigned int usec) in set_tx_coal() argument
1427 temp = (u64)usec * mp->t_clk; in set_tx_coal()
1434 wrlp(mp, TX_FIFO_URGENT_THRESHOLD, temp << 4); in set_tx_coal()
1498 mv643xx_eth_get_link_ksettings_phy(struct mv643xx_eth_private *mp, in mv643xx_eth_get_link_ksettings_phy() argument
1501 struct net_device *dev = mp->dev; in mv643xx_eth_get_link_ksettings_phy()
1524 mv643xx_eth_get_link_ksettings_phyless(struct mv643xx_eth_private *mp, in mv643xx_eth_get_link_ksettings_phyless() argument
1530 port_status = rdlp(mp, PORT_STATUS); in mv643xx_eth_get_link_ksettings_phyless()
1592 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_get_link_ksettings() local
1595 return mv643xx_eth_get_link_ksettings_phy(mp, cmd); in mv643xx_eth_get_link_ksettings()
1597 return mv643xx_eth_get_link_ksettings_phyless(mp, cmd); in mv643xx_eth_get_link_ksettings()
1640 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_get_coalesce() local
1642 ec->rx_coalesce_usecs = get_rx_coal(mp); in mv643xx_eth_get_coalesce()
1643 ec->tx_coalesce_usecs = get_tx_coal(mp); in mv643xx_eth_get_coalesce()
1651 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_set_coalesce() local
1653 set_rx_coal(mp, ec->rx_coalesce_usecs); in mv643xx_eth_set_coalesce()
1654 set_tx_coal(mp, ec->tx_coalesce_usecs); in mv643xx_eth_set_coalesce()
1662 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_get_ringparam() local
1667 er->rx_pending = mp->rx_ring_size; in mv643xx_eth_get_ringparam()
1668 er->tx_pending = mp->tx_ring_size; in mv643xx_eth_get_ringparam()
1674 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_set_ringparam() local
1679 mp->rx_ring_size = er->rx_pending < 4096 ? er->rx_pending : 4096; in mv643xx_eth_set_ringparam()
1680 mp->tx_ring_size = clamp_t(unsigned int, er->tx_pending, in mv643xx_eth_set_ringparam()
1682 if (mp->tx_ring_size != er->tx_pending) in mv643xx_eth_set_ringparam()
1684 mp->tx_ring_size, er->tx_pending); in mv643xx_eth_set_ringparam()
1702 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_set_features() local
1705 wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000); in mv643xx_eth_set_features()
1728 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_get_ethtool_stats() local
1732 mib_counters_update(mp); in mv643xx_eth_get_ethtool_stats()
1741 p = ((void *)mp->dev) + stat->netdev_off; in mv643xx_eth_get_ethtool_stats()
1743 p = ((void *)mp) + stat->mp_off; in mv643xx_eth_get_ethtool_stats()
1778 static void uc_addr_get(struct mv643xx_eth_private *mp, unsigned char *addr) in uc_addr_get() argument
1780 unsigned int mac_h = rdlp(mp, MAC_ADDR_HIGH); in uc_addr_get()
1781 unsigned int mac_l = rdlp(mp, MAC_ADDR_LOW); in uc_addr_get()
1791 static void uc_addr_set(struct mv643xx_eth_private *mp, unsigned char *addr) in uc_addr_set() argument
1793 wrlp(mp, MAC_ADDR_HIGH, in uc_addr_set()
1795 wrlp(mp, MAC_ADDR_LOW, (addr[4] << 8) | addr[5]); in uc_addr_set()
1821 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_program_unicast_filter() local
1826 uc_addr_set(mp, dev->dev_addr); in mv643xx_eth_program_unicast_filter()
1828 port_config = rdlp(mp, PORT_CONFIG) & ~UNICAST_PROMISCUOUS_MODE; in mv643xx_eth_program_unicast_filter()
1837 int off = UNICAST_TABLE(mp->port_num) + i; in mv643xx_eth_program_unicast_filter()
1851 wrl(mp, off, v); in mv643xx_eth_program_unicast_filter()
1854 wrlp(mp, PORT_CONFIG, port_config); in mv643xx_eth_program_unicast_filter()
1877 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_program_multicast_filter() local
1909 wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i * sizeof(u32), in mv643xx_eth_program_multicast_filter()
1911 wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i * sizeof(u32), in mv643xx_eth_program_multicast_filter()
1920 wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i * sizeof(u32), in mv643xx_eth_program_multicast_filter()
1922 wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i * sizeof(u32), in mv643xx_eth_program_multicast_filter()
1951 static int rxq_init(struct mv643xx_eth_private *mp, int index) in rxq_init() argument
1953 struct rx_queue *rxq = mp->rxq + index; in rxq_init()
1960 rxq->rx_ring_size = mp->rx_ring_size; in rxq_init()
1968 if (index == 0 && size <= mp->rx_desc_sram_size) { in rxq_init()
1969 rxq->rx_desc_area = ioremap(mp->rx_desc_sram_addr, in rxq_init()
1970 mp->rx_desc_sram_size); in rxq_init()
1971 rxq->rx_desc_dma = mp->rx_desc_sram_addr; in rxq_init()
1973 rxq->rx_desc_area = dma_alloc_coherent(mp->dev->dev.parent, in rxq_init()
1979 netdev_err(mp->dev, in rxq_init()
2007 if (index == 0 && size <= mp->rx_desc_sram_size) in rxq_init()
2010 dma_free_coherent(mp->dev->dev.parent, size, in rxq_init()
2020 struct mv643xx_eth_private *mp = rxq_to_mp(rxq); in rxq_deinit() local
2033 netdev_err(mp->dev, "error freeing rx ring -- %d skbs stuck\n", in rxq_deinit()
2038 rxq->rx_desc_area_size <= mp->rx_desc_sram_size) in rxq_deinit()
2041 dma_free_coherent(mp->dev->dev.parent, rxq->rx_desc_area_size, in rxq_deinit()
2047 static int txq_init(struct mv643xx_eth_private *mp, int index) in txq_init() argument
2049 struct tx_queue *txq = mp->txq + index; in txq_init()
2057 txq->tx_ring_size = mp->tx_ring_size; in txq_init()
2072 if (index == 0 && size <= mp->tx_desc_sram_size) { in txq_init()
2073 txq->tx_desc_area = ioremap(mp->tx_desc_sram_addr, in txq_init()
2074 mp->tx_desc_sram_size); in txq_init()
2075 txq->tx_desc_dma = mp->tx_desc_sram_addr; in txq_init()
2077 txq->tx_desc_area = dma_alloc_coherent(mp->dev->dev.parent, in txq_init()
2083 netdev_err(mp->dev, in txq_init()
2113 txq->tso_hdrs = dma_alloc_coherent(mp->dev->dev.parent, in txq_init()
2127 if (index == 0 && size <= mp->tx_desc_sram_size) in txq_init()
2130 dma_free_coherent(mp->dev->dev.parent, txq->tx_desc_area_size, in txq_init()
2137 struct mv643xx_eth_private *mp = txq_to_mp(txq); in txq_deinit() local
2145 txq->tx_desc_area_size <= mp->tx_desc_sram_size) in txq_deinit()
2148 dma_free_coherent(mp->dev->dev.parent, txq->tx_desc_area_size, in txq_deinit()
2153 dma_free_coherent(mp->dev->dev.parent, in txq_deinit()
2160 static int mv643xx_eth_collect_events(struct mv643xx_eth_private *mp) in mv643xx_eth_collect_events() argument
2165 int_cause = rdlp(mp, INT_CAUSE) & mp->int_mask; in mv643xx_eth_collect_events()
2172 int_cause_ext = rdlp(mp, INT_CAUSE_EXT); in mv643xx_eth_collect_events()
2176 wrlp(mp, INT_CAUSE, ~int_cause); in mv643xx_eth_collect_events()
2177 mp->work_tx_end |= ((int_cause & INT_TX_END) >> 19) & in mv643xx_eth_collect_events()
2178 ~(rdlp(mp, TXQ_COMMAND) & 0xff); in mv643xx_eth_collect_events()
2179 mp->work_rx |= (int_cause & INT_RX) >> 2; in mv643xx_eth_collect_events()
2184 wrlp(mp, INT_CAUSE_EXT, ~int_cause_ext); in mv643xx_eth_collect_events()
2186 mp->work_link = 1; in mv643xx_eth_collect_events()
2187 mp->work_tx |= int_cause_ext & INT_EXT_TX; in mv643xx_eth_collect_events()
2196 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_irq() local
2198 if (unlikely(!mv643xx_eth_collect_events(mp))) in mv643xx_eth_irq()
2201 wrlp(mp, INT_MASK, 0); in mv643xx_eth_irq()
2202 napi_schedule(&mp->napi); in mv643xx_eth_irq()
2207 static void handle_link_event(struct mv643xx_eth_private *mp) in handle_link_event() argument
2209 struct net_device *dev = mp->dev; in handle_link_event()
2215 port_status = rdlp(mp, PORT_STATUS); in handle_link_event()
2224 for (i = 0; i < mp->txq_count; i++) { in handle_link_event()
2225 struct tx_queue *txq = mp->txq + i; in handle_link_event()
2260 struct mv643xx_eth_private *mp; in mv643xx_eth_poll() local
2263 mp = container_of(napi, struct mv643xx_eth_private, napi); in mv643xx_eth_poll()
2265 if (unlikely(mp->oom)) { in mv643xx_eth_poll()
2266 mp->oom = 0; in mv643xx_eth_poll()
2267 del_timer(&mp->rx_oom); in mv643xx_eth_poll()
2276 if (mp->work_link) { in mv643xx_eth_poll()
2277 mp->work_link = 0; in mv643xx_eth_poll()
2278 handle_link_event(mp); in mv643xx_eth_poll()
2283 queue_mask = mp->work_tx | mp->work_tx_end | mp->work_rx; in mv643xx_eth_poll()
2284 if (likely(!mp->oom)) in mv643xx_eth_poll()
2285 queue_mask |= mp->work_rx_refill; in mv643xx_eth_poll()
2288 if (mv643xx_eth_collect_events(mp)) in mv643xx_eth_poll()
2300 if (mp->work_tx_end & queue_mask) { in mv643xx_eth_poll()
2301 txq_kick(mp->txq + queue); in mv643xx_eth_poll()
2302 } else if (mp->work_tx & queue_mask) { in mv643xx_eth_poll()
2303 work_done += txq_reclaim(mp->txq + queue, work_tbd, 0); in mv643xx_eth_poll()
2304 txq_maybe_wake(mp->txq + queue); in mv643xx_eth_poll()
2305 } else if (mp->work_rx & queue_mask) { in mv643xx_eth_poll()
2306 work_done += rxq_process(mp->rxq + queue, work_tbd); in mv643xx_eth_poll()
2307 } else if (!mp->oom && (mp->work_rx_refill & queue_mask)) { in mv643xx_eth_poll()
2308 work_done += rxq_refill(mp->rxq + queue, work_tbd); in mv643xx_eth_poll()
2315 if (mp->oom) in mv643xx_eth_poll()
2316 mod_timer(&mp->rx_oom, jiffies + (HZ / 10)); in mv643xx_eth_poll()
2318 wrlp(mp, INT_MASK, mp->int_mask); in mv643xx_eth_poll()
2326 struct mv643xx_eth_private *mp = (void *)data; in oom_timer_wrapper() local
2328 napi_schedule(&mp->napi); in oom_timer_wrapper()
2331 static void port_start(struct mv643xx_eth_private *mp) in port_start() argument
2333 struct net_device *dev = mp->dev; in port_start()
2353 pscr = rdlp(mp, PORT_SERIAL_CONTROL); in port_start()
2356 wrlp(mp, PORT_SERIAL_CONTROL, pscr); in port_start()
2361 wrlp(mp, PORT_SERIAL_CONTROL, pscr); in port_start()
2366 tx_set_rate(mp, 1000000000, 16777216); in port_start()
2367 for (i = 0; i < mp->txq_count; i++) { in port_start()
2368 struct tx_queue *txq = mp->txq + i; in port_start()
2380 mv643xx_eth_set_features(mp->dev, mp->dev->features); in port_start()
2385 wrlp(mp, PORT_CONFIG_EXT, 0x00000000); in port_start()
2390 mv643xx_eth_program_unicast_filter(mp->dev); in port_start()
2395 for (i = 0; i < mp->rxq_count; i++) { in port_start()
2396 struct rx_queue *rxq = mp->rxq + i; in port_start()
2401 wrlp(mp, RXQ_CURRENT_DESC_PTR(i), addr); in port_start()
2407 static void mv643xx_eth_recalc_skb_size(struct mv643xx_eth_private *mp) in mv643xx_eth_recalc_skb_size() argument
2417 skb_size = mp->dev->mtu + 36; in mv643xx_eth_recalc_skb_size()
2424 mp->skb_size = (skb_size + 7) & ~7; in mv643xx_eth_recalc_skb_size()
2432 mp->skb_size += SKB_DMA_REALIGN; in mv643xx_eth_recalc_skb_size()
2437 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_open() local
2441 wrlp(mp, INT_CAUSE, 0); in mv643xx_eth_open()
2442 wrlp(mp, INT_CAUSE_EXT, 0); in mv643xx_eth_open()
2443 rdlp(mp, INT_CAUSE_EXT); in mv643xx_eth_open()
2452 mv643xx_eth_recalc_skb_size(mp); in mv643xx_eth_open()
2454 napi_enable(&mp->napi); in mv643xx_eth_open()
2456 mp->int_mask = INT_EXT; in mv643xx_eth_open()
2458 for (i = 0; i < mp->rxq_count; i++) { in mv643xx_eth_open()
2459 err = rxq_init(mp, i); in mv643xx_eth_open()
2462 rxq_deinit(mp->rxq + i); in mv643xx_eth_open()
2466 rxq_refill(mp->rxq + i, INT_MAX); in mv643xx_eth_open()
2467 mp->int_mask |= INT_RX_0 << i; in mv643xx_eth_open()
2470 if (mp->oom) { in mv643xx_eth_open()
2471 mp->rx_oom.expires = jiffies + (HZ / 10); in mv643xx_eth_open()
2472 add_timer(&mp->rx_oom); in mv643xx_eth_open()
2475 for (i = 0; i < mp->txq_count; i++) { in mv643xx_eth_open()
2476 err = txq_init(mp, i); in mv643xx_eth_open()
2479 txq_deinit(mp->txq + i); in mv643xx_eth_open()
2482 mp->int_mask |= INT_TX_END_0 << i; in mv643xx_eth_open()
2485 add_timer(&mp->mib_counters_timer); in mv643xx_eth_open()
2486 port_start(mp); in mv643xx_eth_open()
2488 wrlp(mp, INT_MASK_EXT, INT_EXT_LINK_PHY | INT_EXT_TX); in mv643xx_eth_open()
2489 wrlp(mp, INT_MASK, mp->int_mask); in mv643xx_eth_open()
2495 for (i = 0; i < mp->rxq_count; i++) in mv643xx_eth_open()
2496 rxq_deinit(mp->rxq + i); in mv643xx_eth_open()
2503 static void port_reset(struct mv643xx_eth_private *mp) in port_reset() argument
2508 for (i = 0; i < mp->rxq_count; i++) in port_reset()
2509 rxq_disable(mp->rxq + i); in port_reset()
2510 for (i = 0; i < mp->txq_count; i++) in port_reset()
2511 txq_disable(mp->txq + i); in port_reset()
2514 u32 ps = rdlp(mp, PORT_STATUS); in port_reset()
2522 data = rdlp(mp, PORT_SERIAL_CONTROL); in port_reset()
2526 wrlp(mp, PORT_SERIAL_CONTROL, data); in port_reset()
2531 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_stop() local
2534 wrlp(mp, INT_MASK_EXT, 0x00000000); in mv643xx_eth_stop()
2535 wrlp(mp, INT_MASK, 0x00000000); in mv643xx_eth_stop()
2536 rdlp(mp, INT_MASK); in mv643xx_eth_stop()
2538 napi_disable(&mp->napi); in mv643xx_eth_stop()
2540 del_timer_sync(&mp->rx_oom); in mv643xx_eth_stop()
2547 port_reset(mp); in mv643xx_eth_stop()
2549 mib_counters_update(mp); in mv643xx_eth_stop()
2550 del_timer_sync(&mp->mib_counters_timer); in mv643xx_eth_stop()
2552 for (i = 0; i < mp->rxq_count; i++) in mv643xx_eth_stop()
2553 rxq_deinit(mp->rxq + i); in mv643xx_eth_stop()
2554 for (i = 0; i < mp->txq_count; i++) in mv643xx_eth_stop()
2555 txq_deinit(mp->txq + i); in mv643xx_eth_stop()
2575 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_change_mtu() local
2578 mv643xx_eth_recalc_skb_size(mp); in mv643xx_eth_change_mtu()
2579 tx_set_rate(mp, 1000000000, 16777216); in mv643xx_eth_change_mtu()
2601 struct mv643xx_eth_private *mp; in tx_timeout_task() local
2603 mp = container_of(ugly, struct mv643xx_eth_private, tx_timeout_task); in tx_timeout_task()
2604 if (netif_running(mp->dev)) { in tx_timeout_task()
2605 netif_tx_stop_all_queues(mp->dev); in tx_timeout_task()
2606 port_reset(mp); in tx_timeout_task()
2607 port_start(mp); in tx_timeout_task()
2608 netif_tx_wake_all_queues(mp->dev); in tx_timeout_task()
2614 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_tx_timeout() local
2618 schedule_work(&mp->tx_timeout_task); in mv643xx_eth_tx_timeout()
2624 struct mv643xx_eth_private *mp = netdev_priv(dev); in mv643xx_eth_netpoll() local
2626 wrlp(mp, INT_MASK, 0x00000000); in mv643xx_eth_netpoll()
2627 rdlp(mp, INT_MASK); in mv643xx_eth_netpoll()
2631 wrlp(mp, INT_MASK, mp->int_mask); in mv643xx_eth_netpoll()
2923 static void phy_addr_set(struct mv643xx_eth_private *mp, int phy_addr) in phy_addr_set() argument
2925 int addr_shift = 5 * mp->port_num; in phy_addr_set()
2928 data = rdl(mp, PHY_ADDR); in phy_addr_set()
2931 wrl(mp, PHY_ADDR, data); in phy_addr_set()
2934 static int phy_addr_get(struct mv643xx_eth_private *mp) in phy_addr_get() argument
2938 data = rdl(mp, PHY_ADDR); in phy_addr_get()
2940 return (data >> (5 * mp->port_num)) & 0x1f; in phy_addr_get()
2943 static void set_params(struct mv643xx_eth_private *mp, in set_params() argument
2946 struct net_device *dev = mp->dev; in set_params()
2952 uc_addr_get(mp, dev->dev_addr); in set_params()
2954 mp->rx_ring_size = DEFAULT_RX_QUEUE_SIZE; in set_params()
2956 mp->rx_ring_size = pd->rx_queue_size; in set_params()
2957 mp->rx_desc_sram_addr = pd->rx_sram_addr; in set_params()
2958 mp->rx_desc_sram_size = pd->rx_sram_size; in set_params()
2960 mp->rxq_count = pd->rx_queue_count ? : 1; in set_params()
2966 mp->tx_ring_size = clamp_t(unsigned int, tx_ring_size, in set_params()
2968 if (mp->tx_ring_size != tx_ring_size) in set_params()
2970 mp->tx_ring_size, tx_ring_size); in set_params()
2972 mp->tx_desc_sram_addr = pd->tx_sram_addr; in set_params()
2973 mp->tx_desc_sram_size = pd->tx_sram_size; in set_params()
2975 mp->txq_count = pd->tx_queue_count ? : 1; in set_params()
2978 static int get_phy_mode(struct mv643xx_eth_private *mp) in get_phy_mode() argument
2980 struct device *dev = mp->dev->dev.parent; in get_phy_mode()
2994 static struct phy_device *phy_scan(struct mv643xx_eth_private *mp, in phy_scan() argument
3004 start = phy_addr_get(mp) & 0x1f; in phy_scan()
3019 phydev = phy_connect(mp->dev, phy_id, mv643xx_eth_adjust_link, in phy_scan()
3020 get_phy_mode(mp)); in phy_scan()
3022 phy_addr_set(mp, addr); in phy_scan()
3030 static void phy_init(struct mv643xx_eth_private *mp, int speed, int duplex) in phy_init() argument
3032 struct net_device *dev = mp->dev; in phy_init()
3049 static void init_pscr(struct mv643xx_eth_private *mp, int speed, int duplex) in init_pscr() argument
3051 struct net_device *dev = mp->dev; in init_pscr()
3054 pscr = rdlp(mp, PORT_SERIAL_CONTROL); in init_pscr()
3057 wrlp(mp, PORT_SERIAL_CONTROL, pscr); in init_pscr()
3075 wrlp(mp, PORT_SERIAL_CONTROL, pscr); in init_pscr()
3098 struct mv643xx_eth_private *mp; in mv643xx_eth_probe() local
3120 mp = netdev_priv(dev); in mv643xx_eth_probe()
3121 platform_set_drvdata(pdev, mp); in mv643xx_eth_probe()
3123 mp->shared = platform_get_drvdata(pd->shared); in mv643xx_eth_probe()
3124 mp->base = mp->shared->base + 0x0400 + (pd->port_number << 10); in mv643xx_eth_probe()
3125 mp->port_num = pd->port_number; in mv643xx_eth_probe()
3127 mp->dev = dev; in mv643xx_eth_probe()
3135 wrlp(mp, PORT_SERIAL_CONTROL1, in mv643xx_eth_probe()
3136 rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN); in mv643xx_eth_probe()
3142 mp->t_clk = 133000000; in mv643xx_eth_probe()
3143 mp->clk = devm_clk_get(&pdev->dev, NULL); in mv643xx_eth_probe()
3144 if (!IS_ERR(mp->clk)) { in mv643xx_eth_probe()
3145 clk_prepare_enable(mp->clk); in mv643xx_eth_probe()
3146 mp->t_clk = clk_get_rate(mp->clk); in mv643xx_eth_probe()
3147 } else if (!IS_ERR(mp->shared->clk)) { in mv643xx_eth_probe()
3148 mp->t_clk = clk_get_rate(mp->shared->clk); in mv643xx_eth_probe()
3151 set_params(mp, pd); in mv643xx_eth_probe()
3152 netif_set_real_num_tx_queues(dev, mp->txq_count); in mv643xx_eth_probe()
3153 netif_set_real_num_rx_queues(dev, mp->rxq_count); in mv643xx_eth_probe()
3157 phydev = of_phy_connect(mp->dev, pd->phy_node, in mv643xx_eth_probe()
3159 get_phy_mode(mp)); in mv643xx_eth_probe()
3163 phy_addr_set(mp, phydev->mdio.addr); in mv643xx_eth_probe()
3165 phydev = phy_scan(mp, pd->phy_addr); in mv643xx_eth_probe()
3170 phy_init(mp, pd->speed, pd->duplex); in mv643xx_eth_probe()
3181 init_pscr(mp, pd->speed, pd->duplex); in mv643xx_eth_probe()
3184 mib_counters_clear(mp); in mv643xx_eth_probe()
3186 setup_timer(&mp->mib_counters_timer, mib_counters_timer_wrapper, in mv643xx_eth_probe()
3187 (unsigned long)mp); in mv643xx_eth_probe()
3188 mp->mib_counters_timer.expires = jiffies + 30 * HZ; in mv643xx_eth_probe()
3190 spin_lock_init(&mp->mib_counters_lock); in mv643xx_eth_probe()
3192 INIT_WORK(&mp->tx_timeout_task, tx_timeout_task); in mv643xx_eth_probe()
3194 netif_napi_add(dev, &mp->napi, mv643xx_eth_poll, NAPI_POLL_WEIGHT); in mv643xx_eth_probe()
3196 setup_timer(&mp->rx_oom, oom_timer_wrapper, (unsigned long)mp); in mv643xx_eth_probe()
3221 if (mp->shared->win_protect) in mv643xx_eth_probe()
3222 wrl(mp, WINDOW_PROTECT(mp->port_num), mp->shared->win_protect); in mv643xx_eth_probe()
3226 wrlp(mp, SDMA_CONFIG, PORT_SDMA_CONFIG_DEFAULT_VALUE); in mv643xx_eth_probe()
3228 set_rx_coal(mp, 250); in mv643xx_eth_probe()
3229 set_tx_coal(mp, 0); in mv643xx_eth_probe()
3236 mp->port_num, dev->dev_addr); in mv643xx_eth_probe()
3238 if (mp->tx_desc_sram_size > 0) in mv643xx_eth_probe()
3244 if (!IS_ERR(mp->clk)) in mv643xx_eth_probe()
3245 clk_disable_unprepare(mp->clk); in mv643xx_eth_probe()
3253 struct mv643xx_eth_private *mp = platform_get_drvdata(pdev); in mv643xx_eth_remove() local
3254 struct net_device *dev = mp->dev; in mv643xx_eth_remove()
3256 unregister_netdev(mp->dev); in mv643xx_eth_remove()
3259 cancel_work_sync(&mp->tx_timeout_task); in mv643xx_eth_remove()
3261 if (!IS_ERR(mp->clk)) in mv643xx_eth_remove()
3262 clk_disable_unprepare(mp->clk); in mv643xx_eth_remove()
3264 free_netdev(mp->dev); in mv643xx_eth_remove()
3271 struct mv643xx_eth_private *mp = platform_get_drvdata(pdev); in mv643xx_eth_shutdown() local
3274 wrlp(mp, INT_MASK, 0); in mv643xx_eth_shutdown()
3275 rdlp(mp, INT_MASK); in mv643xx_eth_shutdown()
3277 if (netif_running(mp->dev)) in mv643xx_eth_shutdown()
3278 port_reset(mp); in mv643xx_eth_shutdown()