Lines Matching refs:ndev
42 static inline void moxart_emac_write(struct net_device *ndev, in moxart_emac_write() argument
45 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_emac_write()
50 static void moxart_update_mac_address(struct net_device *ndev) in moxart_update_mac_address() argument
52 moxart_emac_write(ndev, REG_MAC_MS_ADDRESS, in moxart_update_mac_address()
53 ((ndev->dev_addr[0] << 8) | (ndev->dev_addr[1]))); in moxart_update_mac_address()
54 moxart_emac_write(ndev, REG_MAC_MS_ADDRESS + 4, in moxart_update_mac_address()
55 ((ndev->dev_addr[2] << 24) | in moxart_update_mac_address()
56 (ndev->dev_addr[3] << 16) | in moxart_update_mac_address()
57 (ndev->dev_addr[4] << 8) | in moxart_update_mac_address()
58 (ndev->dev_addr[5]))); in moxart_update_mac_address()
61 static int moxart_set_mac_address(struct net_device *ndev, void *addr) in moxart_set_mac_address() argument
65 eth_hw_addr_set(ndev, address->sa_data); in moxart_set_mac_address()
66 moxart_update_mac_address(ndev); in moxart_set_mac_address()
71 static void moxart_mac_free_memory(struct net_device *ndev) in moxart_mac_free_memory() argument
73 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_free_memory()
89 static void moxart_mac_reset(struct net_device *ndev) in moxart_mac_reset() argument
91 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_reset()
102 static void moxart_mac_enable(struct net_device *ndev) in moxart_mac_enable() argument
104 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_enable()
117 static void moxart_mac_setup_desc_ring(struct net_device *ndev) in moxart_mac_setup_desc_ring() argument
119 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_setup_desc_ring()
147 netdev_err(ndev, "DMA mapping error\n"); in moxart_mac_setup_desc_ring()
163 static int moxart_mac_open(struct net_device *ndev) in moxart_mac_open() argument
165 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_open()
169 moxart_mac_reset(ndev); in moxart_mac_open()
170 moxart_update_mac_address(ndev); in moxart_mac_open()
171 moxart_mac_setup_desc_ring(ndev); in moxart_mac_open()
172 moxart_mac_enable(ndev); in moxart_mac_open()
173 netif_start_queue(ndev); in moxart_mac_open()
175 netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n", in moxart_mac_open()
182 static int moxart_mac_stop(struct net_device *ndev) in moxart_mac_stop() argument
184 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_stop()
189 netif_stop_queue(ndev); in moxart_mac_stop()
210 struct net_device *ndev = priv->ndev; in moxart_rx_poll() local
228 ndev->stats.rx_dropped++; in moxart_rx_poll()
229 ndev->stats.rx_errors++; in moxart_rx_poll()
241 skb = netdev_alloc_skb_ip_align(ndev, len); in moxart_rx_poll()
245 ndev->stats.rx_dropped++; in moxart_rx_poll()
246 ndev->stats.rx_errors++; in moxart_rx_poll()
252 skb->protocol = eth_type_trans(skb, ndev); in moxart_rx_poll()
256 ndev->stats.rx_packets++; in moxart_rx_poll()
257 ndev->stats.rx_bytes += len; in moxart_rx_poll()
259 ndev->stats.multicast++; in moxart_rx_poll()
278 static int moxart_tx_queue_space(struct net_device *ndev) in moxart_tx_queue_space() argument
280 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_tx_queue_space()
285 static void moxart_tx_finished(struct net_device *ndev) in moxart_tx_finished() argument
287 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_tx_finished()
295 ndev->stats.tx_packets++; in moxart_tx_finished()
296 ndev->stats.tx_bytes += priv->tx_skb[tx_tail]->len; in moxart_tx_finished()
304 if (netif_queue_stopped(ndev) && in moxart_tx_finished()
305 moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD) in moxart_tx_finished()
306 netif_wake_queue(ndev); in moxart_tx_finished()
311 struct net_device *ndev = (struct net_device *)dev_id; in moxart_mac_interrupt() local
312 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_interrupt()
316 moxart_tx_finished(ndev); in moxart_mac_interrupt()
330 struct net_device *ndev) in moxart_mac_start_xmit() argument
332 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_start_xmit()
344 if (moxart_tx_queue_space(ndev) == 1) in moxart_mac_start_xmit()
345 netif_stop_queue(ndev); in moxart_mac_start_xmit()
349 ndev->stats.tx_dropped++; in moxart_mac_start_xmit()
359 netdev_err(ndev, "DMA mapping error\n"); in moxart_mac_start_xmit()
392 netif_trans_update(ndev); in moxart_mac_start_xmit()
400 static void moxart_mac_setmulticast(struct net_device *ndev) in moxart_mac_setmulticast() argument
402 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_setmulticast()
406 netdev_for_each_mc_addr(ha, ndev) { in moxart_mac_setmulticast()
421 static void moxart_mac_set_rx_mode(struct net_device *ndev) in moxart_mac_set_rx_mode() argument
423 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_set_rx_mode()
427 (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) : in moxart_mac_set_rx_mode()
430 (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) : in moxart_mac_set_rx_mode()
433 if ((ndev->flags & IFF_MULTICAST) && netdev_mc_count(ndev)) { in moxart_mac_set_rx_mode()
435 moxart_mac_setmulticast(ndev); in moxart_mac_set_rx_mode()
458 struct net_device *ndev; in moxart_mac_probe() local
464 ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t)); in moxart_mac_probe()
465 if (!ndev) in moxart_mac_probe()
470 netdev_err(ndev, "irq_of_parse_and_map failed\n"); in moxart_mac_probe()
475 priv = netdev_priv(ndev); in moxart_mac_probe()
476 priv->ndev = ndev; in moxart_mac_probe()
484 ndev->base_addr = res->start; in moxart_mac_probe()
486 ret = platform_get_ethdev_address(p_dev, ndev); in moxart_mac_probe()
490 eth_hw_addr_random(ndev); in moxart_mac_probe()
491 moxart_update_mac_address(ndev); in moxart_mac_probe()
528 platform_set_drvdata(pdev, ndev); in moxart_mac_probe()
531 pdev->name, ndev); in moxart_mac_probe()
533 netdev_err(ndev, "devm_request_irq failed\n"); in moxart_mac_probe()
537 ndev->netdev_ops = &moxart_netdev_ops; in moxart_mac_probe()
538 netif_napi_add_weight(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM); in moxart_mac_probe()
539 ndev->priv_flags |= IFF_UNICAST_FLT; in moxart_mac_probe()
540 ndev->irq = irq; in moxart_mac_probe()
542 SET_NETDEV_DEV(ndev, &pdev->dev); in moxart_mac_probe()
544 ret = register_netdev(ndev); in moxart_mac_probe()
548 netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n", in moxart_mac_probe()
549 __func__, ndev->irq, ndev->dev_addr); in moxart_mac_probe()
554 netdev_err(ndev, "init failed\n"); in moxart_mac_probe()
555 moxart_mac_free_memory(ndev); in moxart_mac_probe()
557 free_netdev(ndev); in moxart_mac_probe()
563 struct net_device *ndev = platform_get_drvdata(pdev); in moxart_remove() local
565 unregister_netdev(ndev); in moxart_remove()
566 devm_free_irq(&pdev->dev, ndev->irq, ndev); in moxart_remove()
567 moxart_mac_free_memory(ndev); in moxart_remove()
568 free_netdev(ndev); in moxart_remove()